mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 20:41:14 +00:00
lwip: Enable IPV6_ONLY option for UDP sockets (BSD & netconn)
* setsockopt(s, IPV6_ONLY, &one, sizeof(int)) will disable IPV6-only mode. Incoming/outgoing IPV4 packets are dropped. * Otherwise, sockets bound to IPV6_ANY_ADDR can receive unicast packets for IPV4 or IPV6. * sendto() a IPV6-mapped-IPV4 address on a UDP socket works correctly (not supported for RAW or TCP sockets.) * getaddrinfo() option AI_V4MAPPED is implemented. As well as extending support to TCP & RAW, there is some potential improvement to dropping incoming packets - the drop happens a bit late in the process and there is no "ICMP port unreachable" response sent.
This commit is contained in:

committed by
Angus Gratton

parent
961180617e
commit
04a2cefb26
@@ -2373,10 +2373,6 @@ lwip_getsockopt_impl(int s, int level, int optname, void *optval, socklen_t *opt
|
||||
switch (optname) {
|
||||
case IPV6_V6ONLY:
|
||||
LWIP_SOCKOPT_CHECK_OPTLEN_CONN(sock, *optlen, int);
|
||||
/* @todo: this does not work for datagram sockets, yet */
|
||||
if (NETCONNTYPE_GROUP(netconn_type(sock->conn)) != NETCONN_TCP) {
|
||||
return ENOPROTOOPT;
|
||||
}
|
||||
*(int*)optval = (netconn_get_ipv6only(sock->conn) ? 1 : 0);
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IPV6, IPV6_V6ONLY) = %d\n",
|
||||
s, *(int *)optval));
|
||||
@@ -2811,12 +2807,7 @@ lwip_setsockopt_impl(int s, int level, int optname, const void *optval, socklen_
|
||||
case IPPROTO_IPV6:
|
||||
switch (optname) {
|
||||
case IPV6_V6ONLY:
|
||||
/* @todo: this does not work for datagram sockets, yet */
|
||||
#if CONFIG_MDNS
|
||||
//LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock, optlen, int, NETCONN_TCP);
|
||||
#else
|
||||
LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock, optlen, int, NETCONN_TCP);
|
||||
#endif
|
||||
LWIP_SOCKOPT_CHECK_OPTLEN_CONN(sock, optlen, int);
|
||||
if (*(const int*)optval) {
|
||||
netconn_set_ipv6only(sock->conn, 1);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user