39 #define NDP_SUPPORT ENABLED
40#elif (NDP_SUPPORT != ENABLED && NDP_SUPPORT != DISABLED)
41 #error NDP_SUPPORT parameter is not valid
45#ifndef NDP_TICK_INTERVAL
46 #define NDP_TICK_INTERVAL 200
47#elif (NDP_TICK_INTERVAL < 10)
48 #error NDP_TICK_INTERVAL parameter is not valid
52#ifndef NDP_NEIGHBOR_CACHE_SIZE
53 #define NDP_NEIGHBOR_CACHE_SIZE 8
54#elif (NDP_NEIGHBOR_CACHE_SIZE < 1)
55 #error NDP_NEIGHBOR_CACHE_SIZE parameter is not valid
59#ifndef NDP_DEST_CACHE_SIZE
60 #define NDP_DEST_CACHE_SIZE 8
61#elif (NDP_DEST_CACHE_SIZE < 1)
62 #error NDP_DEST_CACHE_SIZE parameter is not valid
66#ifndef NDP_MAX_PENDING_PACKETS
67 #define NDP_MAX_PENDING_PACKETS 2
68#elif (NDP_MAX_PENDING_PACKETS < 1)
69 #error NDP_MAX_PENDING_PACKETS parameter is not valid
73#ifndef NDP_MAX_RTR_ADVERT_INTERVAL
74 #define NDP_MAX_RTR_ADVERT_INTERVAL 600000
75#elif (NDP_MAX_RTR_ADVERT_INTERVAL < 1000)
76 #error NDP_MAX_RTR_ADVERT_INTERVAL parameter is not valid
80#ifndef NDP_MAX_INITIAL_RTR_ADVERT_INTERVAL
81 #define NDP_MAX_INITIAL_RTR_ADVERT_INTERVAL 16000
82#elif (NDP_MAX_INITIAL_RTR_ADVERT_INTERVAL < 1000)
83 #error NDP_MAX_INITIAL_RTR_ADVERT_INTERVAL parameter is not valid
87#ifndef NDP_MAX_INITIAL_RTR_ADVERTISEMENTS
88 #define NDP_MAX_INITIAL_RTR_ADVERTISEMENTS 3
89#elif (NDP_MAX_INITIAL_RTR_ADVERTISEMENTS < 1)
90 #error NDP_MAX_INITIAL_RTR_ADVERTISEMENTS parameter is not valid
94#ifndef NDP_MAX_FINAL_RTR_ADVERTISEMENTS
95 #define NDP_MAX_FINAL_RTR_ADVERTISEMENTS 3
96#elif (NDP_MAX_FINAL_RTR_ADVERTISEMENTS < 1)
97 #error NDP_MAX_FINAL_RTR_ADVERTISEMENTS parameter is not valid
101#ifndef NDP_MIN_DELAY_BETWEEN_RAS
102 #define NDP_MIN_DELAY_BETWEEN_RAS 3000
103#elif (NDP_MIN_DELAY_BETWEEN_RAS < 1000)
104 #error NDP_MIN_DELAY_BETWEEN_RAS parameter is not valid
108#ifndef NDP_MAX_RA_DELAY_TIME
109 #define NDP_MAX_RA_DELAY_TIME 500
110#elif (NDP_MAX_RA_DELAY_TIME < 100)
111 #error NDP_MAX_RA_DELAY_TIME parameter is not valid
115#ifndef NDP_MIN_RTR_SOLICITATION_DELAY
116 #define NDP_MIN_RTR_SOLICITATION_DELAY 0
117#elif (NDP_MIN_RTR_SOLICITATION_DELAY < 0)
118 #error NDP_MIN_RTR_SOLICITATION_DELAY parameter is not valid
122#ifndef NDP_MAX_RTR_SOLICITATION_DELAY
123 #define NDP_MAX_RTR_SOLICITATION_DELAY 1000
124#elif (NDP_MAX_RTR_SOLICITATION_DELAY < 0)
125 #error NDP_MAX_RTR_SOLICITATION_DELAY parameter is not valid
129#ifndef NDP_RTR_SOLICITATION_INTERVAL
130 #define NDP_RTR_SOLICITATION_INTERVAL 4000
131#elif (NDP_RTR_SOLICITATION_INTERVAL < 1000)
132 #error NDP_RTR_SOLICITATION_INTERVAL parameter is not valid
136#ifndef NDP_MAX_RTR_SOLICITATIONS
137 #define NDP_MAX_RTR_SOLICITATIONS 3
138#elif (NDP_MAX_RTR_SOLICITATIONS < 1)
139 #error NDP_MAX_RTR_SOLICITATIONS parameter is not valid
143#ifndef NDP_MAX_MULTICAST_SOLICIT
144 #define NDP_MAX_MULTICAST_SOLICIT 3
145#elif (NDP_MAX_MULTICAST_SOLICIT < 1)
146 #error NDP_MAX_MULTICAST_SOLICIT parameter is not valid
150#ifndef NDP_MAX_UNICAST_SOLICIT
151 #define NDP_MAX_UNICAST_SOLICIT 3
152#elif (NDP_MAX_UNICAST_SOLICIT < 1)
153 #error NDP_MAX_UNICAST_SOLICIT parameter is not valid
157#ifndef NDP_DUP_ADDR_DETECT_TRANSMITS
158 #define NDP_DUP_ADDR_DETECT_TRANSMITS 1
159#elif (NDP_DUP_ADDR_DETECT_TRANSMITS < 0)
160 #error NDP_DUP_ADDR_DETECT_TRANSMITS parameter is not valid
164#ifndef NDP_MAX_ANYCAST_DELAY_TIME
165 #define NDP_MAX_ANYCAST_DELAY_TIME 1000
166#elif (NDP_MAX_ANYCAST_DELAY_TIME < 100)
167 #error NDP_MAX_ANYCAST_DELAY_TIME parameter is not valid
171#ifndef NDP_MAX_NEIGHBOR_ADVERTISEMENT
172 #define NDP_MAX_NEIGHBOR_ADVERTISEMENT 3
173#elif (NDP_MAX_NEIGHBOR_ADVERTISEMENT < 0)
174 #error NDP_MAX_NEIGHBOR_ADVERTISEMENT parameter is not valid
178#ifndef NDP_REACHABLE_TIME
179 #define NDP_REACHABLE_TIME 30000
180#elif (NDP_REACHABLE_TIME < 1000)
181 #error NDP_REACHABLE_TIME parameter is not valid
185#ifndef NDP_RETRANS_TIMER
186 #define NDP_RETRANS_TIMER 1000
187#elif (NDP_RETRANS_TIMER < 100)
188 #error NDP_RETRANS_TIMER parameter is not valid
192#ifndef NDP_DELAY_FIRST_PROBE_TIME
193 #define NDP_DELAY_FIRST_PROBE_TIME 5000
194#elif (NDP_DELAY_FIRST_PROBE_TIME < 1000)
195 #error NDP_DELAY_FIRST_PROBE_TIME parameter is not valid
199#define NDP_HOP_LIMIT 255
202#define NDP_INFINITE_LIFETIME 0xFFFFFFFF
216 NDP_OPT_SOURCE_LINK_LAYER_ADDR = 1,
217 NDP_OPT_TARGET_LINK_LAYER_ADDR = 2,
218 NDP_OPT_PREFIX_INFORMATION = 3,
219 NDP_OPT_REDIRECTED_HEADER = 4,
221 NDP_OPT_ROUTE_INFORMATION = 24,
222 NDP_OPT_RECURSIVE_DNS_SERVER = 25,
223 NDP_OPT_DNS_SEARCH_LIST = 31,
224 NDP_OPT_6LOWPAN_CONTEXT = 34,
225 NDP_OPT_CAPTIVE_PORTAL = 37,
236 NDP_ROUTER_SEL_PREFERENCE_MEDIUM = 0,
237 NDP_ROUTER_SEL_PREFERENCE_HIGH = 1,
238 NDP_ROUTER_SEL_PREFERENCE_RESERVED = 2,
239 NDP_ROUTER_SEL_PREFERENCE_LOW = 3
250 NDP_STATE_INCOMPLETE = 1,
251 NDP_STATE_REACHABLE = 2,
255 NDP_STATE_PERMANENT = 6
260#if defined(__CWCC__) || defined(_WIN32)
261 #pragma pack(push, 1)
276} NdpRouterSolMessage;
289#if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
295 uint8_t reserved : 2;
297 uint8_t reserved : 2;
304 uint16_t routerLifetime;
305 uint32_t reachableTime;
306 uint32_t retransTimer;
308} NdpRouterAdvMessage;
323} NdpNeighborSolMessage;
335#if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
339 uint8_t reserved1 : 5;
341 uint8_t reserved1 : 5;
346 uint8_t reserved2[3];
349} NdpNeighborAdvMessage;
388 MacAddr linkLayerAddr;
389} NdpLinkLayerAddrOption;
400 uint8_t prefixLength;
401#if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
405 uint8_t reserved1 : 5;
407 uint8_t reserved1 : 5;
412 uint32_t validLifetime;
413 uint32_t preferredLifetime;
416} NdpPrefixInfoOption;
430} NdpRedirectedHeaderOption;
454 uint8_t prefixLength;
455#if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
456 uint8_t reserved1 : 3;
458 uint8_t reserved2 : 3;
460 uint8_t reserved2 : 3;
462 uint8_t reserved1 : 3;
464 uint32_t routeLifetime;
493 uint8_t domainNames[];
505 uint8_t contextLength;
506#if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
507 uint8_t reserved1 : 3;
513 uint8_t reserved1 : 3;
516 uint16_t validLifetime;
517 Ipv6Addr contextPrefix;
522#if defined(__CWCC__) || defined(_WIN32)
598error_t ndpInit(NetInterface *interface);
599error_t ndpEnable(NetInterface *interface, bool_t enable);
601error_t ndpAddStaticEntry(NetInterface *interface,
const Ipv6Addr *ipAddr,
602 const MacAddr *macAddr);
604error_t ndpRemoveStaticEntry(NetInterface *interface,
const Ipv6Addr *ipAddr);
606error_t ndpResolve(NetInterface *interface,
const Ipv6Addr *ipAddr,
609error_t ndpEnqueuePacket(NetInterface *srcInterface,
610 NetInterface *destInterface,
const Ipv6Addr *ipAddr,
NetBuffer *buffer,
611 size_t offset, NetTxAncillary *ancillary);
613void ndpTick(NetInterface *interface);
614void ndpLinkChangeEvent(NetInterface *interface);
616void ndpProcessRouterAdv(NetInterface *interface,
617 const Ipv6PseudoHeader *pseudoHeader,
const NetBuffer *buffer,
618 size_t offset, uint8_t hopLimit);
620void ndpProcessNeighborSol(NetInterface *interface,
621 const Ipv6PseudoHeader *pseudoHeader,
const NetBuffer *buffer,
622 size_t offset, uint8_t hopLimit);
624void ndpProcessNeighborAdv(NetInterface *interface,
625 const Ipv6PseudoHeader *pseudoHeader,
const NetBuffer *buffer,
626 size_t offset, uint8_t hopLimit);
628void ndpProcessRedirect(NetInterface *interface,
629 const Ipv6PseudoHeader *pseudoHeader,
const NetBuffer *buffer,
630 size_t offset, uint8_t hopLimit);
632error_t ndpSendRouterSol(NetInterface *interface);
634error_t ndpSendNeighborSol(NetInterface *interface,
635 const Ipv6Addr *targetIpAddr, bool_t multicast);
637error_t ndpSendNeighborAdv(NetInterface *interface,
638 const Ipv6Addr *targetIpAddr,
const Ipv6Addr *destIpAddr);
640error_t ndpSendRedirect(NetInterface *interface,
const Ipv6Addr *targetAddr,
641 const NetBuffer *ipPacket,
size_t ipPacketOffset);
643void ndpDumpRouterSolMessage(
const NdpRouterSolMessage *message);
644void ndpDumpRouterAdvMessage(
const NdpRouterAdvMessage *message);
645void ndpDumpNeighborSolMessage(
const NdpNeighborSolMessage *message);
646void ndpDumpNeighborAdvMessage(
const NdpNeighborAdvMessage *message);
647void ndpDumpRedirectMessage(
const NdpRedirectMessage *message);
error_t
Error codes.
Definition error.h:43
NdpRouterSelPreference
Router selection preferences.
Definition ndp.h:235
NdpState
Neighbor cache entry states.
Definition ndp.h:248
typedef __packed_struct
Router Solicitation message.
Definition ndp.h:270
NdpOptionType
Neighbor Discovery options.
Definition ndp.h:215
uint32_t systime_t
System time.
Definition os_port_none.h:90
NDP context.
Definition ndp.h:576
systime_t timestamp
Timestamp to manage retransmissions.
Definition ndp.h:586
systime_t timeout
Timeout value.
Definition ndp.h:587
bool_t enable
Enable address resolution using Neighbor Discovery protocol.
Definition ndp.h:588
uint_t dupAddrDetectTransmits
Maximum number of NS messages sent while performing DAD.
Definition ndp.h:579
uint32_t retransTimer
The time between retransmissions of NS messages.
Definition ndp.h:578
uint32_t reachableTime
The time a node assumes a neighbor is reachable.
Definition ndp.h:577
systime_t maxRtrSolicitationDelay
Maximum delay before transmitting the first RS message.
Definition ndp.h:581
systime_t minRtrSolicitationDelay
Minimum delay before transmitting the first RS message.
Definition ndp.h:580
uint_t rtrSolicitationCount
Retransmission counter for RS messages.
Definition ndp.h:584
uint_t maxRtrSolicitations
Number of retransmissions for RS messages.
Definition ndp.h:583
systime_t rtrSolicitationInterval
Time interval between retransmissions of RS messages.
Definition ndp.h:582
bool_t rtrAdvReceived
Valid RA message received.
Definition ndp.h:585
Destination cache entry.
Definition ndp.h:563
Ipv6Addr destAddr
Destination IPv6 address.
Definition ndp.h:564
systime_t timestamp
Timestamp to manage entry lifetime.
Definition ndp.h:567
size_t pathMtu
Path MTU.
Definition ndp.h:566
Ipv6Addr nextHop
IPv6 address of the next-hop neighbor.
Definition ndp.h:565
Neighbor cache entry.
Definition ndp.h:545
systime_t timestamp
Timestamp to manage entry lifetime.
Definition ndp.h:550
MacAddr macAddr
Link layer address associated with the IPv6 address.
Definition ndp.h:548
systime_t timeout
Timeout value.
Definition ndp.h:551
Ipv6Addr ipAddr
Unicast IPv6 address.
Definition ndp.h:547
uint_t retransmitCount
Retransmission counter.
Definition ndp.h:552
NdpState state
Reachability state.
Definition ndp.h:546
uint_t queueSize
Number of queued packets.
Definition ndp.h:554
bool_t isRouter
A flag indicating whether the neighbor is a router or a host.
Definition ndp.h:549
NDP queue item.
Definition ndp.h:532
NetBuffer * buffer
Packet waiting for address resolution.
Definition ndp.h:534
size_t offset
Offset to the first byte of the packet.
Definition ndp.h:535
NetTxAncillary ancillary
Additional options.
Definition ndp.h:536
NetInterface * srcInterface
Interface from which the packet has been received.
Definition ndp.h:533
Structure describing a buffer that spans multiple chunks.
Definition net_mem.h:89