mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-05 22:29:49 +00:00
Dual-stack: Use IPv6 mapped IPv4 addresses in receive() and getaddr() only in socket API, not in netconn API.
It is better to present correct IP types in netconn API. Netconn API now accepts IPv6 mapped IPv4 addresses as well as IPv6 and IPv4 in send(), bind() and connect(), but does NOT map IPv4 to IPv6 mapped IPv4 in getaddr() and receive() functions.
This commit is contained in:
parent
792224ead0
commit
180ba72a06
@ -231,14 +231,6 @@ netconn_getaddr(struct netconn *conn, ip_addr_t *addr, u16_t *port, u8_t local)
|
|||||||
err = netconn_apimsg(lwip_netconn_do_getaddr, &msg);
|
err = netconn_apimsg(lwip_netconn_do_getaddr, &msg);
|
||||||
#endif /* LWIP_MPU_COMPATIBLE */
|
#endif /* LWIP_MPU_COMPATIBLE */
|
||||||
API_MSG_VAR_FREE(msg);
|
API_MSG_VAR_FREE(msg);
|
||||||
|
|
||||||
#if LWIP_IPV4 && LWIP_IPV6
|
|
||||||
/* Dual-stack: Map IPv4 addresses to IPv6 mapped IPv4 */
|
|
||||||
if (NETCONNTYPE_ISIPV6(netconn_type(conn)) && IP_IS_V4(addr)) {
|
|
||||||
ip4_2_ipv6_mapped_ipv4(ip_2_ip6(addr), ip_2_ip4(addr));
|
|
||||||
IP_SET_TYPE(addr, IPADDR_TYPE_V6);
|
|
||||||
}
|
|
||||||
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -607,18 +599,8 @@ netconn_recv_data(struct netconn *conn, void **new_buf)
|
|||||||
#endif /* LWIP_TCP && (LWIP_UDP || LWIP_RAW) */
|
#endif /* LWIP_TCP && (LWIP_UDP || LWIP_RAW) */
|
||||||
#if (LWIP_UDP || LWIP_RAW)
|
#if (LWIP_UDP || LWIP_RAW)
|
||||||
{
|
{
|
||||||
struct netbuf* nbuf = (struct netbuf*)buf;
|
|
||||||
|
|
||||||
LWIP_ASSERT("buf != NULL", buf != NULL);
|
LWIP_ASSERT("buf != NULL", buf != NULL);
|
||||||
len = netbuf_len(nbuf);
|
len = netbuf_len((struct netbuf*)buf);
|
||||||
|
|
||||||
#if LWIP_IPV4 && LWIP_IPV6
|
|
||||||
/* Dual-stack: Map IPv4 addresses to IPv6 mapped IPv4 */
|
|
||||||
if (NETCONNTYPE_ISIPV6(netconn_type(conn)) && IP_IS_V4_VAL(nbuf->addr)) {
|
|
||||||
ip4_2_ipv6_mapped_ipv4(ip_2_ip6(&nbuf->addr), ip_2_ip4(&nbuf->addr));
|
|
||||||
IP_SET_TYPE_VAL(nbuf->addr, IPADDR_TYPE_V6);
|
|
||||||
}
|
|
||||||
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
|
||||||
}
|
}
|
||||||
#endif /* (LWIP_UDP || LWIP_RAW) */
|
#endif /* (LWIP_UDP || LWIP_RAW) */
|
||||||
|
|
||||||
|
@ -847,6 +847,15 @@ lwip_recvfrom(int s, void *mem, size_t len, int flags,
|
|||||||
port = netbuf_fromport((struct netbuf *)buf);
|
port = netbuf_fromport((struct netbuf *)buf);
|
||||||
fromaddr = netbuf_fromaddr((struct netbuf *)buf);
|
fromaddr = netbuf_fromaddr((struct netbuf *)buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LWIP_IPV4 && LWIP_IPV6
|
||||||
|
/* Dual-stack: Map IPv4 addresses to IPv6 mapped IPv4 */
|
||||||
|
if (NETCONNTYPE_ISIPV6(netconn_type(sock->conn)) && IP_IS_V4(fromaddr)) {
|
||||||
|
ip4_2_ipv6_mapped_ipv4(ip_2_ip6(fromaddr), ip_2_ip4(fromaddr));
|
||||||
|
IP_SET_TYPE(fromaddr, IPADDR_TYPE_V6);
|
||||||
|
}
|
||||||
|
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
||||||
|
|
||||||
IPADDR_PORT_TO_SOCKADDR(&saddr, fromaddr, port);
|
IPADDR_PORT_TO_SOCKADDR(&saddr, fromaddr, port);
|
||||||
ip_addr_debug_print(SOCKETS_DEBUG, fromaddr);
|
ip_addr_debug_print(SOCKETS_DEBUG, fromaddr);
|
||||||
LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F" len=%d\n", port, off));
|
LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F" len=%d\n", port, off));
|
||||||
@ -1710,6 +1719,15 @@ lwip_getaddrname(int s, struct sockaddr *name, socklen_t *namelen, u8_t local)
|
|||||||
sock_set_errno(sock, err_to_errno(err));
|
sock_set_errno(sock, err_to_errno(err));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LWIP_IPV4 && LWIP_IPV6
|
||||||
|
/* Dual-stack: Map IPv4 addresses to IPv6 mapped IPv4 */
|
||||||
|
if (NETCONNTYPE_ISIPV6(netconn_type(sock->conn)) && IP_IS_V4_VAL(naddr)) {
|
||||||
|
ip4_2_ipv6_mapped_ipv4(ip_2_ip6(&naddr), ip_2_ip4(&naddr));
|
||||||
|
IP_SET_TYPE_VAL(naddr, IPADDR_TYPE_V6);
|
||||||
|
}
|
||||||
|
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
||||||
|
|
||||||
IPADDR_PORT_TO_SOCKADDR(&saddr, &naddr, port);
|
IPADDR_PORT_TO_SOCKADDR(&saddr, &naddr, port);
|
||||||
|
|
||||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getaddrname(%d, addr=", s));
|
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getaddrname(%d, addr=", s));
|
||||||
|
Loading…
Reference in New Issue
Block a user