Browse Source

fix ipv6 compatibility issues (#7339)

xiaoniaoyou6hua 2 years ago
parent
commit
c34608b4a9

+ 3 - 1
components/net/lwip/lwip-2.0.3/src/include/lwip/ip_addr.h

@@ -373,7 +373,7 @@ extern const ip_addr_t ip_addr_broadcast;
 
 extern const ip_addr_t ip6_addr_any;
 
-/** 
+/**
  * @ingroup ip6addr
  * IP6_ADDR_ANY can be used as a fixed ip_addr_t
  * for the IPv6 wildcard address
@@ -400,6 +400,8 @@ extern const ip_addr_t ip6_addr_any;
 #define IP_ANY_TYPE    IP_ADDR_ANY
 #endif
 
+struct netif *lwip_ip4_route_src(const ip4_addr_t *dest, const ip4_addr_t *src);
+
 #ifdef __cplusplus
 }
 #endif

+ 3 - 1
components/net/lwip/lwip-2.1.2/src/include/lwip/ip_addr.h

@@ -404,7 +404,7 @@ extern const ip_addr_t ip_addr_broadcast;
 
 extern const ip_addr_t ip6_addr_any;
 
-/** 
+/**
  * @ingroup ip6addr
  * IP6_ADDR_ANY can be used as a fixed ip_addr_t
  * for the IPv6 wildcard address
@@ -431,6 +431,8 @@ extern const ip_addr_t ip6_addr_any;
 #define IP_ANY_TYPE    IP_ADDR_ANY
 #endif
 
+struct netif *lwip_ip4_route_src(const ip4_addr_t *dest, const ip4_addr_t *src);
+
 #ifdef __cplusplus
 }
 #endif

+ 1 - 1
components/net/lwip/lwip-2.1.2/src/include/lwip/prot/ip6.h

@@ -200,7 +200,7 @@ PACK_STRUCT_END
 #define IP6_ROUT_SEG_LEFT(hdr) ((hdr)->_segments_left)
 
 /* Fragment header. */
-#define IP6_FRAG_HLEN    8
+#define IP6_FRAG_HLEN    12
 #define IP6_FRAG_OFFSET_MASK    0xfff8
 #define IP6_FRAG_MORE_FLAG      0x0001
 

+ 4 - 0
components/net/lwip/port/ethernetif.c

@@ -246,7 +246,11 @@ int lwip_netdev_ping(struct netdev *netif, const char *host, size_t data_len,
     local.sin_len = sizeof(local);
     local.sin_family = AF_INET;
     local.sin_port = 0;
+#ifndef NETDEV_USING_IPV6
     local.sin_addr.s_addr = (netif->ip_addr.addr);
+#else
+    local.sin_addr.s_addr = (netif->ip_addr.u_addr.ip4.addr);
+#endif
     lwip_bind(s, (struct sockaddr *)&local, sizeof(struct sockaddr_in));
 
     lwip_setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &recv_timeout, sizeof(recv_timeout));

+ 1 - 3
components/net/lwip/port/lwipopts.h

@@ -585,7 +585,7 @@
 #endif
 
 /* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active timeouts. */
-#define MEMP_NUM_SYS_TIMEOUT       (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + 2*PPP_SUPPORT)
+#define MEMP_NUM_SYS_TIMEOUT       (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + PPP_SUPPORT + (LWIP_IPV6 ? (1 + (2*LWIP_IPV6)) : 0))
 
 /*
  * LWIP_COMPAT_SOCKETS==1: Enable BSD-style sockets functions names.
@@ -642,8 +642,6 @@
 #else                                /* >= v2.1.2 */
 #define LWIP_HOOK_IP4_ROUTE_SRC(src, dest)  lwip_ip4_route_src(dest, src)
 #endif
-#include "lwip/ip_addr.h"
-struct netif *lwip_ip4_route_src(const ip4_addr_t *dest, const ip4_addr_t *src);
 #endif /* RT_USING_LWIP_VER_NUM >= 0x20000 */
 
 #endif /* __LWIPOPTS_H__ */