mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-08-24 15:16:02 +00:00
Rename "IPv6 mapped IPv4 addresses" to their correct name from RFC4191: "IPv4-mapped IPv6 address"
This commit is contained in:
parent
c1c470fc4c
commit
4d8fec3b67
|
@ -587,9 +587,9 @@ lwip_bind(int s, const struct sockaddr *name, socklen_t namelen)
|
||||||
LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F")\n", local_port));
|
LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F")\n", local_port));
|
||||||
|
|
||||||
#if LWIP_IPV4 && LWIP_IPV6
|
#if LWIP_IPV4 && LWIP_IPV6
|
||||||
/* Dual-stack: Unmap IPv6 mapped IPv4 addresses */
|
/* Dual-stack: Unmap IPv4 mapped IPv6 addresses */
|
||||||
if (IP_IS_V6_VAL(local_addr) && ip6_addr_isipv6mappedipv4(ip_2_ip6(&local_addr))) {
|
if (IP_IS_V6_VAL(local_addr) && ip6_addr_isipv4mappedipv6(ip_2_ip6(&local_addr))) {
|
||||||
unmap_ipv6_mapped_ipv4(ip_2_ip4(&local_addr), ip_2_ip6(&local_addr));
|
unmap_ipv4_mapped_ipv6(ip_2_ip4(&local_addr), ip_2_ip6(&local_addr));
|
||||||
IP_SET_TYPE_VAL(local_addr, IPADDR_TYPE_V4);
|
IP_SET_TYPE_VAL(local_addr, IPADDR_TYPE_V4);
|
||||||
}
|
}
|
||||||
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
||||||
|
@ -679,9 +679,9 @@ lwip_connect(int s, const struct sockaddr *name, socklen_t namelen)
|
||||||
LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F")\n", remote_port));
|
LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F")\n", remote_port));
|
||||||
|
|
||||||
#if LWIP_IPV4 && LWIP_IPV6
|
#if LWIP_IPV4 && LWIP_IPV6
|
||||||
/* Dual-stack: Unmap IPv6 mapped IPv4 addresses */
|
/* Dual-stack: Unmap IPv4 mapped IPv6 addresses */
|
||||||
if (IP_IS_V6_VAL(remote_addr) && ip6_addr_isipv6mappedipv4(ip_2_ip6(&remote_addr))) {
|
if (IP_IS_V6_VAL(remote_addr) && ip6_addr_isipv4mappedipv6(ip_2_ip6(&remote_addr))) {
|
||||||
unmap_ipv6_mapped_ipv4(ip_2_ip4(&remote_addr), ip_2_ip6(&remote_addr));
|
unmap_ipv4_mapped_ipv6(ip_2_ip4(&remote_addr), ip_2_ip6(&remote_addr));
|
||||||
IP_SET_TYPE_VAL(remote_addr, IPADDR_TYPE_V4);
|
IP_SET_TYPE_VAL(remote_addr, IPADDR_TYPE_V4);
|
||||||
}
|
}
|
||||||
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
||||||
|
@ -867,9 +867,9 @@ lwip_recvfrom(int s, void *mem, size_t len, int flags,
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LWIP_IPV4 && LWIP_IPV6
|
#if LWIP_IPV4 && LWIP_IPV6
|
||||||
/* Dual-stack: Map IPv4 addresses to IPv6 mapped IPv4 */
|
/* Dual-stack: Map IPv4 addresses to IPv4 mapped IPv6 */
|
||||||
if (NETCONNTYPE_ISIPV6(netconn_type(sock->conn)) && IP_IS_V4(fromaddr)) {
|
if (NETCONNTYPE_ISIPV6(netconn_type(sock->conn)) && IP_IS_V4(fromaddr)) {
|
||||||
ip4_2_ipv6_mapped_ipv4(ip_2_ip6(fromaddr), ip_2_ip4(fromaddr));
|
ip4_2_ipv4_mapped_ipv6(ip_2_ip6(fromaddr), ip_2_ip4(fromaddr));
|
||||||
IP_SET_TYPE(fromaddr, IPADDR_TYPE_V6);
|
IP_SET_TYPE(fromaddr, IPADDR_TYPE_V6);
|
||||||
}
|
}
|
||||||
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
||||||
|
@ -1094,9 +1094,9 @@ lwip_sendmsg(int s, const struct msghdr *msg, int flags)
|
||||||
|
|
||||||
if (err == ERR_OK) {
|
if (err == ERR_OK) {
|
||||||
#if LWIP_IPV4 && LWIP_IPV6
|
#if LWIP_IPV4 && LWIP_IPV6
|
||||||
/* Dual-stack: Unmap IPv6 mapped IPv4 addresses */
|
/* Dual-stack: Unmap IPv4 mapped IPv6 addresses */
|
||||||
if (IP_IS_V6_VAL(chain_buf->addr) && ip6_addr_isipv6mappedipv4(ip_2_ip6(&chain_buf->addr))) {
|
if (IP_IS_V6_VAL(chain_buf->addr) && ip6_addr_isipv4mappedipv6(ip_2_ip6(&chain_buf->addr))) {
|
||||||
unmap_ipv6_mapped_ipv4(ip_2_ip4(&chain_buf->addr), ip_2_ip6(&chain_buf->addr));
|
unmap_ipv4_mapped_ipv6(ip_2_ip4(&chain_buf->addr), ip_2_ip6(&chain_buf->addr));
|
||||||
IP_SET_TYPE_VAL(chain_buf->addr, IPADDR_TYPE_V4);
|
IP_SET_TYPE_VAL(chain_buf->addr, IPADDR_TYPE_V4);
|
||||||
}
|
}
|
||||||
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
||||||
|
@ -1192,9 +1192,9 @@ lwip_sendto(int s, const void *data, size_t size, int flags,
|
||||||
#endif /* LWIP_NETIF_TX_SINGLE_PBUF */
|
#endif /* LWIP_NETIF_TX_SINGLE_PBUF */
|
||||||
if (err == ERR_OK) {
|
if (err == ERR_OK) {
|
||||||
#if LWIP_IPV4 && LWIP_IPV6
|
#if LWIP_IPV4 && LWIP_IPV6
|
||||||
/* Dual-stack: Unmap IPv6 mapped IPv4 addresses */
|
/* Dual-stack: Unmap IPv4 mapped IPv6 addresses */
|
||||||
if (IP_IS_V6_VAL(buf.addr) && ip6_addr_isipv6mappedipv4(ip_2_ip6(&buf.addr))) {
|
if (IP_IS_V6_VAL(buf.addr) && ip6_addr_isipv4mappedipv6(ip_2_ip6(&buf.addr))) {
|
||||||
unmap_ipv6_mapped_ipv4(ip_2_ip4(&buf.addr), ip_2_ip6(&buf.addr));
|
unmap_ipv4_mapped_ipv6(ip_2_ip4(&buf.addr), ip_2_ip6(&buf.addr));
|
||||||
IP_SET_TYPE_VAL(buf.addr, IPADDR_TYPE_V4);
|
IP_SET_TYPE_VAL(buf.addr, IPADDR_TYPE_V4);
|
||||||
}
|
}
|
||||||
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
||||||
|
@ -1749,10 +1749,10 @@ lwip_getaddrname(int s, struct sockaddr *name, socklen_t *namelen, u8_t local)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LWIP_IPV4 && LWIP_IPV6
|
#if LWIP_IPV4 && LWIP_IPV6
|
||||||
/* Dual-stack: Map IPv4 addresses to IPv6 mapped IPv4 */
|
/* Dual-stack: Map IPv4 addresses to IPv4 mapped IPv6 */
|
||||||
if (NETCONNTYPE_ISIPV6(netconn_type(sock->conn)) &&
|
if (NETCONNTYPE_ISIPV6(netconn_type(sock->conn)) &&
|
||||||
IP_IS_V4_VAL(naddr)) {
|
IP_IS_V4_VAL(naddr)) {
|
||||||
ip4_2_ipv6_mapped_ipv4(ip_2_ip6(&naddr), ip_2_ip4(&naddr));
|
ip4_2_ipv4_mapped_ipv6(ip_2_ip6(&naddr), ip_2_ip4(&naddr));
|
||||||
IP_SET_TYPE_VAL(naddr, IPADDR_TYPE_V6);
|
IP_SET_TYPE_VAL(naddr, IPADDR_TYPE_V6);
|
||||||
}
|
}
|
||||||
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
||||||
|
|
|
@ -527,10 +527,10 @@ ip6_input(struct pbuf *p, struct netif *inp)
|
||||||
ip_addr_copy_from_ip6_packed(ip_data.current_iphdr_dest, ip6hdr->dest);
|
ip_addr_copy_from_ip6_packed(ip_data.current_iphdr_dest, ip6hdr->dest);
|
||||||
ip_addr_copy_from_ip6_packed(ip_data.current_iphdr_src, ip6hdr->src);
|
ip_addr_copy_from_ip6_packed(ip_data.current_iphdr_src, ip6hdr->src);
|
||||||
|
|
||||||
/* Don't accept virtual IPv6 mapped IPv4 addresses.
|
/* Don't accept virtual IPv4 mapped IPv6 addresses.
|
||||||
* Don't accept multicast source addresses. */
|
* Don't accept multicast source addresses. */
|
||||||
if (ip6_addr_isipv6mappedipv4(ip_2_ip6(&ip_data.current_iphdr_dest)) ||
|
if (ip6_addr_isipv4mappedipv6(ip_2_ip6(&ip_data.current_iphdr_dest)) ||
|
||||||
ip6_addr_isipv6mappedipv4(ip_2_ip6(&ip_data.current_iphdr_src)) ||
|
ip6_addr_isipv4mappedipv6(ip_2_ip6(&ip_data.current_iphdr_src)) ||
|
||||||
ip6_addr_ismulticast(ip_2_ip6(&ip_data.current_iphdr_src))) {
|
ip6_addr_ismulticast(ip_2_ip6(&ip_data.current_iphdr_src))) {
|
||||||
IP6_STATS_INC(ip6.err);
|
IP6_STATS_INC(ip6.err);
|
||||||
IP6_STATS_INC(ip6.drop);
|
IP6_STATS_INC(ip6.drop);
|
||||||
|
|
|
@ -208,7 +208,7 @@ typedef struct ip6_addr ip6_addr_t;
|
||||||
|
|
||||||
#define ip6_addr_isuniquelocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xfe000000UL)) == PP_HTONL(0xfc000000UL))
|
#define ip6_addr_isuniquelocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xfe000000UL)) == PP_HTONL(0xfc000000UL))
|
||||||
|
|
||||||
#define ip6_addr_isipv6mappedipv4(ip6addr) (((ip6addr)->addr[0] == 0) && ((ip6addr)->addr[1] == 0) && (((ip6addr)->addr[2]) == PP_HTONL(0x0000FFFFUL)))
|
#define ip6_addr_isipv4mappedipv6(ip6addr) (((ip6addr)->addr[0] == 0) && ((ip6addr)->addr[1] == 0) && (((ip6addr)->addr[2]) == PP_HTONL(0x0000FFFFUL)))
|
||||||
|
|
||||||
#define ip6_addr_ismulticast(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff000000UL)) == PP_HTONL(0xff000000UL))
|
#define ip6_addr_ismulticast(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff000000UL)) == PP_HTONL(0xff000000UL))
|
||||||
#define ip6_addr_multicast_transient_flag(ip6addr) ((ip6addr)->addr[0] & PP_HTONL(0x00100000UL))
|
#define ip6_addr_multicast_transient_flag(ip6addr) ((ip6addr)->addr[0] & PP_HTONL(0x00100000UL))
|
||||||
|
|
|
@ -226,7 +226,7 @@ int ipaddr_aton(const char *cp, ip_addr_t *addr);
|
||||||
#define IPADDR_STRLEN_MAX IP6ADDR_STRLEN_MAX
|
#define IPADDR_STRLEN_MAX IP6ADDR_STRLEN_MAX
|
||||||
|
|
||||||
/** @ingroup ipaddr */
|
/** @ingroup ipaddr */
|
||||||
#define ip4_2_ipv6_mapped_ipv4(ip6addr, ip4addr) do { \
|
#define ip4_2_ipv4_mapped_ipv6(ip6addr, ip4addr) do { \
|
||||||
(ip6addr)->addr[3] = (ip4addr)->addr; \
|
(ip6addr)->addr[3] = (ip4addr)->addr; \
|
||||||
(ip6addr)->addr[2] = PP_HTONL(0x0000FFFFUL); \
|
(ip6addr)->addr[2] = PP_HTONL(0x0000FFFFUL); \
|
||||||
(ip6addr)->addr[1] = 0; \
|
(ip6addr)->addr[1] = 0; \
|
||||||
|
@ -234,7 +234,7 @@ int ipaddr_aton(const char *cp, ip_addr_t *addr);
|
||||||
ip6_addr_clear_zone(ip6addr); } while(0);
|
ip6_addr_clear_zone(ip6addr); } while(0);
|
||||||
|
|
||||||
/** @ingroup ipaddr */
|
/** @ingroup ipaddr */
|
||||||
#define unmap_ipv6_mapped_ipv4(ip4addr, ip6addr) \
|
#define unmap_ipv4_mapped_ipv6(ip4addr, ip6addr) \
|
||||||
(ip4addr)->addr = (ip6addr)->addr[3];
|
(ip4addr)->addr = (ip6addr)->addr[3];
|
||||||
|
|
||||||
#define IP46_ADDR_ANY(type) (((type) == IPADDR_TYPE_V6)? IP6_ADDR_ANY : IP4_ADDR_ANY)
|
#define IP46_ADDR_ANY(type) (((type) == IPADDR_TYPE_V6)? IP6_ADDR_ANY : IP4_ADDR_ANY)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user