mirror of
https://github.com/espressif/esp-lwip.git
synced 2026-06-05 21:04:45 +00:00
nd6: Add support to enable/disable ND6 protocol
2.1.3-esp: 7896c6ca lwip: add LWIP ND6 config
This commit is contained in:
@@ -2085,6 +2085,7 @@ PREDEFINED = __DOXYGEN__=1 \
|
|||||||
LWIP_TCPIP_CORE_LOCKING=1 \
|
LWIP_TCPIP_CORE_LOCKING=1 \
|
||||||
LWIP_IPV4=1 \
|
LWIP_IPV4=1 \
|
||||||
LWIP_IPV6=1 \
|
LWIP_IPV6=1 \
|
||||||
|
LWIP_ND6=1 \
|
||||||
LWIP_ICMP=1 \
|
LWIP_ICMP=1 \
|
||||||
LWIP_RAW=1 \
|
LWIP_RAW=1 \
|
||||||
LWIP_DHCP=1 \
|
LWIP_DHCP=1 \
|
||||||
|
|||||||
@@ -2085,6 +2085,7 @@ PREDEFINED = __DOXYGEN__=1 \
|
|||||||
LWIP_TCPIP_CORE_LOCKING=1 \
|
LWIP_TCPIP_CORE_LOCKING=1 \
|
||||||
LWIP_IPV4=1 \
|
LWIP_IPV4=1 \
|
||||||
LWIP_IPV6=1 \
|
LWIP_IPV6=1 \
|
||||||
|
LWIP_ND6=1 \
|
||||||
LWIP_ICMP=1 \
|
LWIP_ICMP=1 \
|
||||||
LWIP_RAW=1 \
|
LWIP_RAW=1 \
|
||||||
LWIP_DHCP=1 \
|
LWIP_DHCP=1 \
|
||||||
|
|||||||
@@ -118,7 +118,9 @@ icmp6_input(struct pbuf *p, struct netif *inp)
|
|||||||
case ICMP6_TYPE_RA: /* Router advertisement */
|
case ICMP6_TYPE_RA: /* Router advertisement */
|
||||||
case ICMP6_TYPE_RD: /* Redirect */
|
case ICMP6_TYPE_RD: /* Redirect */
|
||||||
case ICMP6_TYPE_PTB: /* Packet too big */
|
case ICMP6_TYPE_PTB: /* Packet too big */
|
||||||
|
#if LWIP_ND6
|
||||||
nd6_input(p, inp);
|
nd6_input(p, inp);
|
||||||
|
#endif /* LWIP_ND6 */
|
||||||
return;
|
return;
|
||||||
case ICMP6_TYPE_RS:
|
case ICMP6_TYPE_RS:
|
||||||
#if LWIP_IPV6_FORWARD
|
#if LWIP_IPV6_FORWARD
|
||||||
|
|||||||
@@ -208,7 +208,9 @@ ip6_route(const ip6_addr_t *src, const ip6_addr_t *dest)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Get the netif for a suitable router-announced route. */
|
/* Get the netif for a suitable router-announced route. */
|
||||||
|
#if LWIP_ND6
|
||||||
netif = nd6_find_route(dest);
|
netif = nd6_find_route(dest);
|
||||||
|
#endif /* LWIP_ND6 */
|
||||||
if (netif != NULL) {
|
if (netif != NULL) {
|
||||||
return netif;
|
return netif;
|
||||||
}
|
}
|
||||||
@@ -1266,7 +1268,11 @@ ip6_output_if_src(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest,
|
|||||||
#endif /* ENABLE_LOOPBACK */
|
#endif /* ENABLE_LOOPBACK */
|
||||||
#if LWIP_IPV6_FRAG
|
#if LWIP_IPV6_FRAG
|
||||||
/* don't fragment if interface has mtu set to 0 [loopif] */
|
/* don't fragment if interface has mtu set to 0 [loopif] */
|
||||||
|
#if LWIP_ND6
|
||||||
if (netif_mtu6(netif) && (p->tot_len > nd6_get_destination_mtu(dest, netif))) {
|
if (netif_mtu6(netif) && (p->tot_len > nd6_get_destination_mtu(dest, netif))) {
|
||||||
|
#else
|
||||||
|
if (netif_mtu6(netif) && (p->tot_len > IP6_MIN_MTU_LENGTH)) {
|
||||||
|
#endif /* LWIP_ND6 */
|
||||||
return ip6_frag(p, netif, dest);
|
return ip6_frag(p, netif, dest);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -765,7 +765,11 @@ ip6_frag(struct pbuf *p, struct netif *netif, const ip6_addr_t *dest)
|
|||||||
#endif
|
#endif
|
||||||
static u32_t identification;
|
static u32_t identification;
|
||||||
u16_t left, cop;
|
u16_t left, cop;
|
||||||
|
#if LWIP_ND6
|
||||||
const u16_t mtu = nd6_get_destination_mtu(dest, netif);
|
const u16_t mtu = nd6_get_destination_mtu(dest, netif);
|
||||||
|
#else
|
||||||
|
const u16_t mtu = IP6_MIN_MTU_LENGTH;
|
||||||
|
#endif /* LWIP_ND6 */
|
||||||
const u16_t nfb = (u16_t)((mtu - (IP6_HLEN + IP6_FRAG_HLEN)) & IP6_FRAG_OFFSET_MASK);
|
const u16_t nfb = (u16_t)((mtu - (IP6_HLEN + IP6_FRAG_HLEN)) & IP6_FRAG_OFFSET_MASK);
|
||||||
u16_t fragment_offset = 0;
|
u16_t fragment_offset = 0;
|
||||||
u16_t last;
|
u16_t last;
|
||||||
|
|||||||
+2
-2
@@ -43,7 +43,7 @@
|
|||||||
|
|
||||||
#include "lwip/opt.h"
|
#include "lwip/opt.h"
|
||||||
|
|
||||||
#if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */
|
#if LWIP_IPV6 && LWIP_ND6 /* don't build if not configured for use in lwipopts.h */
|
||||||
|
|
||||||
#include "lwip/nd6.h"
|
#include "lwip/nd6.h"
|
||||||
#include "lwip/priv/nd6_priv.h"
|
#include "lwip/priv/nd6_priv.h"
|
||||||
@@ -2490,4 +2490,4 @@ nd6_restart_netif(struct netif *netif)
|
|||||||
#endif /* LWIP_IPV6_SEND_ROUTER_SOLICIT */
|
#endif /* LWIP_IPV6_SEND_ROUTER_SOLICIT */
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* LWIP_IPV6 */
|
#endif /* LWIP_IPV6 && LWIP_ND6 */
|
||||||
|
|||||||
+10
-8
@@ -345,7 +345,9 @@ netif_add(struct netif *netif,
|
|||||||
/* IPv6 address autoconfiguration should be enabled by default */
|
/* IPv6 address autoconfiguration should be enabled by default */
|
||||||
netif->ip6_autoconfig_enabled = 1;
|
netif->ip6_autoconfig_enabled = 1;
|
||||||
#endif /* LWIP_IPV6_AUTOCONFIG */
|
#endif /* LWIP_IPV6_AUTOCONFIG */
|
||||||
|
#if LWIP_ND6
|
||||||
nd6_restart_netif(netif);
|
nd6_restart_netif(netif);
|
||||||
|
#endif /* LWIP_ND6*/
|
||||||
#endif /* LWIP_IPV6 */
|
#endif /* LWIP_IPV6 */
|
||||||
#if LWIP_NETIF_STATUS_CALLBACK
|
#if LWIP_NETIF_STATUS_CALLBACK
|
||||||
netif->status_callback = NULL;
|
netif->status_callback = NULL;
|
||||||
@@ -896,9 +898,9 @@ netif_set_up(struct netif *netif)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
netif_issue_reports(netif, NETIF_REPORT_TYPE_IPV4 | NETIF_REPORT_TYPE_IPV6);
|
netif_issue_reports(netif, NETIF_REPORT_TYPE_IPV4 | NETIF_REPORT_TYPE_IPV6);
|
||||||
#if LWIP_IPV6
|
#if LWIP_IPV6 && LWIP_ND6
|
||||||
nd6_restart_netif(netif);
|
nd6_restart_netif(netif);
|
||||||
#endif /* LWIP_IPV6 */
|
#endif /* LWIP_IPV6 && LWIP_ND6 */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -976,9 +978,9 @@ netif_set_down(struct netif *netif)
|
|||||||
}
|
}
|
||||||
#endif /* LWIP_IPV4 && LWIP_ARP */
|
#endif /* LWIP_IPV4 && LWIP_ARP */
|
||||||
|
|
||||||
#if LWIP_IPV6
|
#if LWIP_IPV6 && LWIP_ND6
|
||||||
nd6_cleanup_netif(netif);
|
nd6_cleanup_netif(netif);
|
||||||
#endif /* LWIP_IPV6 */
|
#endif /* LWIP_IPV6 && LWIP_ND6 */
|
||||||
|
|
||||||
NETIF_STATUS_CALLBACK(netif);
|
NETIF_STATUS_CALLBACK(netif);
|
||||||
}
|
}
|
||||||
@@ -1039,9 +1041,9 @@ netif_set_link_up(struct netif *netif)
|
|||||||
#endif /* LWIP_AUTOIP */
|
#endif /* LWIP_AUTOIP */
|
||||||
|
|
||||||
netif_issue_reports(netif, NETIF_REPORT_TYPE_IPV4 | NETIF_REPORT_TYPE_IPV6);
|
netif_issue_reports(netif, NETIF_REPORT_TYPE_IPV4 | NETIF_REPORT_TYPE_IPV6);
|
||||||
#if LWIP_IPV6
|
#if LWIP_IPV6 && LWIP_ND6
|
||||||
nd6_restart_netif(netif);
|
nd6_restart_netif(netif);
|
||||||
#endif /* LWIP_IPV6 */
|
#endif /* LWIP_IPV6 && LWIP_ND6 */
|
||||||
|
|
||||||
NETIF_LINK_CALLBACK(netif);
|
NETIF_LINK_CALLBACK(netif);
|
||||||
#if LWIP_NETIF_EXT_STATUS_CALLBACK
|
#if LWIP_NETIF_EXT_STATUS_CALLBACK
|
||||||
@@ -1464,12 +1466,12 @@ netif_ip6_addr_set_state(struct netif *netif, s8_t addr_idx, u8_t state)
|
|||||||
u8_t new_valid = state & IP6_ADDR_VALID;
|
u8_t new_valid = state & IP6_ADDR_VALID;
|
||||||
LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_STATE, ("netif_ip6_addr_set_state: netif address state being changed\n"));
|
LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_STATE, ("netif_ip6_addr_set_state: netif address state being changed\n"));
|
||||||
|
|
||||||
#if LWIP_IPV6_MLD
|
#if LWIP_IPV6_MLD && LWIP_ND6
|
||||||
/* Reevaluate solicited-node multicast group membership. */
|
/* Reevaluate solicited-node multicast group membership. */
|
||||||
if (netif->flags & NETIF_FLAG_MLD6) {
|
if (netif->flags & NETIF_FLAG_MLD6) {
|
||||||
nd6_adjust_mld_membership(netif, addr_idx, state);
|
nd6_adjust_mld_membership(netif, addr_idx, state);
|
||||||
}
|
}
|
||||||
#endif /* LWIP_IPV6_MLD */
|
#endif /* LWIP_IPV6_MLD && LWIP_ND6 */
|
||||||
|
|
||||||
if (old_valid && !new_valid) {
|
if (old_valid && !new_valid) {
|
||||||
/* address about to be removed by setting invalid */
|
/* address about to be removed by setting invalid */
|
||||||
|
|||||||
@@ -2265,8 +2265,13 @@ tcp_eff_send_mss_netif(u16_t sendmss, struct netif *outif, const ip_addr_t *dest
|
|||||||
if (IP_IS_V6(dest))
|
if (IP_IS_V6(dest))
|
||||||
#endif /* LWIP_IPV4 */
|
#endif /* LWIP_IPV4 */
|
||||||
{
|
{
|
||||||
|
#if LWIP_ND6
|
||||||
/* First look in destination cache, to see if there is a Path MTU. */
|
/* First look in destination cache, to see if there is a Path MTU. */
|
||||||
mtu = nd6_get_destination_mtu(ip_2_ip6(dest), outif);
|
mtu = nd6_get_destination_mtu(ip_2_ip6(dest), outif);
|
||||||
|
#else
|
||||||
|
LWIP_UNUSED_ARG(outif); /* in case LWIP_ND6 is disabled */
|
||||||
|
mtu = TCP_MSS;
|
||||||
|
#endif /* LWIP_ND6 */
|
||||||
}
|
}
|
||||||
#if LWIP_IPV4
|
#if LWIP_IPV4
|
||||||
else
|
else
|
||||||
|
|||||||
+4
-4
@@ -1328,12 +1328,12 @@ tcp_receive(struct tcp_pcb *pcb)
|
|||||||
}
|
}
|
||||||
#endif /* TCP_OVERSIZE */
|
#endif /* TCP_OVERSIZE */
|
||||||
|
|
||||||
#if LWIP_IPV6 && LWIP_ND6_TCP_REACHABILITY_HINTS
|
#if LWIP_IPV6 && LWIP_ND6_TCP_REACHABILITY_HINTS && LWIP_ND6
|
||||||
if (ip_current_is_v6()) {
|
if (ip_current_is_v6()) {
|
||||||
/* Inform neighbor reachability of forward progress. */
|
/* Inform neighbor reachability of forward progress. */
|
||||||
nd6_reachability_hint(ip6_current_src_addr());
|
nd6_reachability_hint(ip6_current_src_addr());
|
||||||
}
|
}
|
||||||
#endif /* LWIP_IPV6 && LWIP_ND6_TCP_REACHABILITY_HINTS*/
|
#endif /* LWIP_IPV6 && LWIP_ND6_TCP_REACHABILITY_HINTS && LWIP_ND6 */
|
||||||
|
|
||||||
pcb->snd_buf = (tcpwnd_size_t)(pcb->snd_buf + recv_acked);
|
pcb->snd_buf = (tcpwnd_size_t)(pcb->snd_buf + recv_acked);
|
||||||
/* check if this ACK ends our retransmission of in-flight data */
|
/* check if this ACK ends our retransmission of in-flight data */
|
||||||
@@ -1675,12 +1675,12 @@ tcp_receive(struct tcp_pcb *pcb)
|
|||||||
}
|
}
|
||||||
#endif /* LWIP_TCP_SACK_OUT */
|
#endif /* LWIP_TCP_SACK_OUT */
|
||||||
|
|
||||||
#if LWIP_IPV6 && LWIP_ND6_TCP_REACHABILITY_HINTS
|
#if LWIP_IPV6 && LWIP_ND6_TCP_REACHABILITY_HINTS && LWIP_ND6
|
||||||
if (ip_current_is_v6()) {
|
if (ip_current_is_v6()) {
|
||||||
/* Inform neighbor reachability of forward progress. */
|
/* Inform neighbor reachability of forward progress. */
|
||||||
nd6_reachability_hint(ip6_current_src_addr());
|
nd6_reachability_hint(ip6_current_src_addr());
|
||||||
}
|
}
|
||||||
#endif /* LWIP_IPV6 && LWIP_ND6_TCP_REACHABILITY_HINTS*/
|
#endif /* LWIP_IPV6 && LWIP_ND6_TCP_REACHABILITY_HINTS && LWIP_ND6*/
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* We get here if the incoming segment is out-of-sequence. */
|
/* We get here if the incoming segment is out-of-sequence. */
|
||||||
|
|||||||
@@ -104,7 +104,9 @@ const struct lwip_cyclic_timer lwip_cyclic_timers[] = {
|
|||||||
{DNS_TMR_INTERVAL, HANDLER(dns_tmr)},
|
{DNS_TMR_INTERVAL, HANDLER(dns_tmr)},
|
||||||
#endif /* LWIP_DNS */
|
#endif /* LWIP_DNS */
|
||||||
#if LWIP_IPV6
|
#if LWIP_IPV6
|
||||||
|
#if LWIP_ND6
|
||||||
{ND6_TMR_INTERVAL, HANDLER(nd6_tmr)},
|
{ND6_TMR_INTERVAL, HANDLER(nd6_tmr)},
|
||||||
|
#endif /* LWIP_ND6 */
|
||||||
#if LWIP_IPV6_REASS && !ESP_LWIP_IP6_REASSEMBLY_TIMERS_ONDEMAND
|
#if LWIP_IPV6_REASS && !ESP_LWIP_IP6_REASSEMBLY_TIMERS_ONDEMAND
|
||||||
{IP6_REASS_TMR_INTERVAL, HANDLER(ip6_reass_tmr)},
|
{IP6_REASS_TMR_INTERVAL, HANDLER(ip6_reass_tmr)},
|
||||||
#endif /* LWIP_IPV6_REASS */
|
#endif /* LWIP_IPV6_REASS */
|
||||||
|
|||||||
@@ -2448,6 +2448,18 @@
|
|||||||
#define LWIP_IPV6 0
|
#define LWIP_IPV6 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LWIP_ND6==1: Enable NDP
|
||||||
|
* when LWIP_IPV6 is enabled in lwIP, NDP timer is enabled by default with a timeout of 1 second.
|
||||||
|
* However, in the case of sleepy end-device, NDP is not required.
|
||||||
|
* This leads to CPU waking up every 1 second, resulting in increased power consumption.
|
||||||
|
* Therefore, add a option to control nd6, using LWIP_ND6 enable/disable ND6 protocol.
|
||||||
|
* Unless you are very clear that you do not need to use ND6, please do not disable it!
|
||||||
|
*/
|
||||||
|
#if !defined LWIP_ND6 || defined __DOXYGEN__
|
||||||
|
#define LWIP_ND6 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IPV6_REASS_MAXAGE: Maximum time (in multiples of IP6_REASS_TMR_INTERVAL - so seconds, normally)
|
* IPV6_REASS_MAXAGE: Maximum time (in multiples of IP6_REASS_TMR_INTERVAL - so seconds, normally)
|
||||||
* a fragmented IP packet waits for all fragments to arrive. If not all fragments arrived
|
* a fragmented IP packet waits for all fragments to arrive. If not all fragments arrived
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
#define SYS_LIGHTWEIGHT_PROT 0
|
#define SYS_LIGHTWEIGHT_PROT 0
|
||||||
|
|
||||||
#define LWIP_IPV6 1
|
#define LWIP_IPV6 1
|
||||||
|
#define LWIP_ND6 1
|
||||||
#define IPV6_FRAG_COPYHEADER 1
|
#define IPV6_FRAG_COPYHEADER 1
|
||||||
#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 0
|
#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 0
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
#define LWIP_TESTMODE 1
|
#define LWIP_TESTMODE 1
|
||||||
|
|
||||||
#define LWIP_IPV6 1
|
#define LWIP_IPV6 1
|
||||||
|
#define LWIP_ND6 1
|
||||||
|
|
||||||
#define LWIP_CHECKSUM_ON_COPY 1
|
#define LWIP_CHECKSUM_ON_COPY 1
|
||||||
#define TCP_CHECKSUM_ON_COPY_SANITY_CHECK 1
|
#define TCP_CHECKSUM_ON_COPY_SANITY_CHECK 1
|
||||||
|
|||||||
Reference in New Issue
Block a user