ndp.h
Go to the documentation of this file.
1 /**
2  * @file ndp.h
3  * @brief NDP (Neighbor Discovery Protocol)
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2023 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.3.0
29  **/
30 
31 #ifndef _NDP_H
32 #define _NDP_H
33 
34 //Dependencies
35 #include "core/net.h"
36 
37 //NDP support
38 #ifndef NDP_SUPPORT
39  #define NDP_SUPPORT ENABLED
40 #elif (NDP_SUPPORT != ENABLED && NDP_SUPPORT != DISABLED)
41  #error NDP_SUPPORT parameter is not valid
42 #endif
43 
44 //NDP tick interval
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
49 #endif
50 
51 //Neighbor cache size
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
56 #endif
57 
58 //Destination cache size
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
63 #endif
64 
65 //Maximum number of packets waiting for address resolution to complete
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
70 #endif
71 
72 //Maximum time interval between Router Advertisements
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
77 #endif
78 
79 //Maximum time interval between initial Router Advertisements
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
84 #endif
85 
86 //Maximum number of initial Router Advertisements
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
91 #endif
92 
93 //Maximum number of final Router Advertisements
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
98 #endif
99 
100 //Minimum delay between Router Advertisements
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
105 #endif
106 
107 //Maximum delay for Router Advertisements sent in response to a Router Solicitation
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
112 #endif
113 
114 //Minimum delay before transmitting the first Router Solicitation message
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
119 #endif
120 
121 //Maximum delay before transmitting the first Router Solicitation message
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
126 #endif
127 
128 //The time between retransmissions of Router Solicitation messages
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
133 #endif
134 
135 //Number of retransmissions for Router Solicitation messages
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
140 #endif
141 
142 //Number of retransmissions for multicast Neighbor Solicitation messages
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
147 #endif
148 
149 //Number of retransmissions for unicast Neighbor Solicitation messages
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
154 #endif
155 
156 //Maximum number of Neighbor Solicitation messages sent while performing DAD
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
161 #endif
162 
163 //Delay before sending Neighbor Advertisements if the target address is an anycast address
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
168 #endif
169 
170 //Maximum number of unsolicited Neighbor Advertisements
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
175 #endif
176 
177 //The time a neighbor is considered reachable after receiving a reachability confirmation
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
182 #endif
183 
184 //The time between retransmissions of Neighbor Solicitation messages
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
189 #endif
190 
191 //Delay before sending the first probe
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
196 #endif
197 
198 //Hop Limit used by NDP messages
199 #define NDP_HOP_LIMIT 255
200 
201 //Infinite lifetime
202 #define NDP_INFINITE_LIFETIME 0xFFFFFFFF
203 
204 //C++ guard
205 #ifdef __cplusplus
206 extern "C" {
207 #endif
208 
209 
210 /**
211  * @brief Neighbor Discovery options
212  **/
213 
214 typedef enum
215 {
226  NDP_OPT_ANY = 255
228 
229 
230 /**
231  * @brief Router selection preferences
232  **/
233 
234 typedef enum
235 {
241 
242 
243 /**
244  * @brief Neighbor cache entry states
245  **/
246 
247 typedef enum
248 {
257 
258 
259 //CodeWarrior or Win32 compiler?
260 #if defined(__CWCC__) || defined(_WIN32)
261  #pragma pack(push, 1)
262 #endif
263 
264 
265 /**
266  * @brief Router Solicitation message
267  **/
268 
270 {
271  uint8_t type; //0
272  uint8_t code; //1
273  uint16_t checksum; //2-3
274  uint32_t reserved; //4-7
275  uint8_t options[]; //8
277 
278 
279 /**
280  * @brief Router Advertisement message
281  **/
282 
283 typedef __packed_struct
284 {
285  uint8_t type; //0
286  uint8_t code; //1
287  uint16_t checksum; //2-3
288  uint8_t curHopLimit; //4
289 #if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
290  uint8_t m : 1; //5
291  uint8_t o : 1;
292  uint8_t h : 1;
293  uint8_t prf : 2;
294  uint8_t p : 1;
295  uint8_t reserved : 2;
296 #else
297  uint8_t reserved : 2; //5
298  uint8_t p : 1;
299  uint8_t prf : 2;
300  uint8_t h : 1;
301  uint8_t o : 1;
302  uint8_t m : 1;
303 #endif
304  uint16_t routerLifetime; //6-7
305  uint32_t reachableTime; //8-11
306  uint32_t retransTimer; //12-15
307  uint8_t options[]; //16
309 
310 
311 /**
312  * @brief Neighbor Solicitation message
313  **/
314 
315 typedef __packed_struct
316 {
317  uint8_t type; //0
318  uint8_t code; //1
319  uint16_t checksum; //2-3
320  uint32_t reserved; //4-7
322  uint8_t options[]; //24
324 
325 
326 /**
327  * @brief Neighbor Advertisement message
328  **/
329 
330 typedef __packed_struct
331 {
332  uint8_t type; //0
333  uint8_t code; //1
334  uint16_t checksum; //2-3
335 #if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
336  uint8_t r : 1; //4
337  uint8_t s : 1;
338  uint8_t o : 1;
339  uint8_t reserved1 : 5;
340 #else
341  uint8_t reserved1 : 5; //4
342  uint8_t o : 1;
343  uint8_t s : 1;
344  uint8_t r : 1;
345 #endif
346  uint8_t reserved2[3]; //5-7
347  Ipv6Addr targetAddr; //8-23
348  uint8_t options[]; //24
350 
351 
352 /**
353  * @brief Redirect message
354  **/
355 
356 typedef __packed_struct
357 {
358  uint8_t type; //0
359  uint8_t code; //1
360  uint16_t checksum; //2-3
361  uint32_t reserved; //4-7
362  Ipv6Addr targetAddr; //8-23
364  uint8_t options[]; //40
366 
367 
368 /**
369  * @brief Neighbor Discovery option general format
370  **/
371 
372 typedef __packed_struct
373 {
374  uint8_t type; //0
375  uint8_t length; //1
376  uint8_t value[]; //2
378 
379 
380 /**
381  * @brief Source/Target Link-Layer Address option
382  **/
383 
384 typedef __packed_struct
385 {
386  uint8_t type; //0
387  uint8_t length; //1
390 
391 
392 /**
393  * @brief Prefix Information option (PIO)
394  **/
395 
396 typedef __packed_struct
397 {
398  uint8_t type; //0
399  uint8_t length; //1
400  uint8_t prefixLength; //2
401 #if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
402  uint8_t l : 1; //3
403  uint8_t a : 1;
404  uint8_t r : 1;
405  uint8_t reserved1 : 5;
406 #else
407  uint8_t reserved1 : 5; //3
408  uint8_t r : 1;
409  uint8_t a : 1;
410  uint8_t l : 1;
411 #endif
412  uint32_t validLifetime; //4-7
413  uint32_t preferredLifetime; //8-11
414  uint32_t reserved2; //12-15
415  Ipv6Addr prefix; //16-31
417 
418 
419 /**
420  * @brief Redirected Header option (RHO)
421  **/
422 
423 typedef __packed_struct
424 {
425  uint8_t type; //0
426  uint8_t length; //1
427  uint16_t reserved1; //2-3
428  uint32_t reserved2; //4-7
429  uint8_t ipPacket[]; //8
431 
432 
433 /**
434  * @brief MTU option
435  **/
436 
437 typedef __packed_struct
438 {
439  uint8_t type; //0
440  uint8_t length; //1
441  uint16_t reserved; //2-3
442  uint32_t mtu; //4-7
444 
445 
446 /**
447  * @brief Route Information option (RIO)
448  **/
449 
450 typedef __packed_struct
451 {
452  uint8_t type; //0
453  uint8_t length; //1
454  uint8_t prefixLength; //2
455 #if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
456  uint8_t reserved1 : 3; //3
457  uint8_t prf : 2;
458  uint8_t reserved2 : 3;
459 #else
460  uint8_t reserved2 : 3; //3
461  uint8_t prf : 2;
462  uint8_t reserved1 : 3;
463 #endif
464  uint32_t routeLifetime; //4-7
465  Ipv6Addr prefix; //8
467 
468 
469 /**
470  * @brief Recursive DNS Server option (RDNSS)
471  **/
472 
473 typedef __packed_struct
474 {
475  uint8_t type; //0
476  uint8_t length; //1
477  uint16_t reserved; //2-3
478  uint32_t lifetime; //4-7
481 
482 
483 /**
484  * @brief DNS Search List option (DNSSL)
485  **/
486 
487 typedef __packed_struct
488 {
489  uint8_t type; //0
490  uint8_t length; //1
491  uint16_t reserved; //2-3
492  uint32_t lifetime; //4-7
493  uint8_t domainNames[]; //8
495 
496 
497 /**
498  * @brief 6LoWPAN Context option (6CO)
499  **/
500 
501 typedef __packed_struct
502 {
503  uint8_t type; //0
504  uint8_t length; //1
505  uint8_t contextLength; //2
506 #if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
507  uint8_t reserved1 : 3; //3
508  uint8_t c : 1;
509  uint8_t cid : 4;
510 #else
511  uint8_t cid : 4; //3
512  uint8_t c : 1;
513  uint8_t reserved1 : 3;
514 #endif
515  uint16_t reserved2; //4-5
516  uint16_t validLifetime; //6-7
519 
520 
521 //CodeWarrior or Win32 compiler?
522 #if defined(__CWCC__) || defined(_WIN32)
523  #pragma pack(pop)
524 #endif
525 
526 
527 /**
528  * @brief NDP queue item
529  **/
530 
531 typedef struct
532 {
533  NetInterface *srcInterface; ///<Interface from which the packet has been received
534  NetBuffer *buffer; ///<Packet waiting for address resolution
535  size_t offset; ///<Offset to the first byte of the packet
536  NetTxAncillary ancillary; ///<Additional options
537 } NdpQueueItem;
538 
539 
540 /**
541  * @brief Neighbor cache entry
542  **/
543 
544 typedef struct
545 {
546  NdpState state; ///<Reachability state
547  Ipv6Addr ipAddr; ///<Unicast IPv6 address
548  MacAddr macAddr; ///<Link layer address associated with the IPv6 address
549  bool_t isRouter; ///<A flag indicating whether the neighbor is a router or a host
550  systime_t timestamp; ///<Timestamp to manage entry lifetime
551  systime_t timeout; ///<Timeout value
552  uint_t retransmitCount; ///<Retransmission counter
553  NdpQueueItem queue[NDP_MAX_PENDING_PACKETS]; ///<Packets waiting for address resolution to complete
554  uint_t queueSize; ///<Number of queued packets
556 
557 
558 /**
559  * @brief Destination cache entry
560  **/
561 
562 typedef struct
563 {
564  Ipv6Addr destAddr; ///<Destination IPv6 address
565  Ipv6Addr nextHop; ///<IPv6 address of the next-hop neighbor
566  size_t pathMtu; ///<Path MTU
567  systime_t timestamp; ///<Timestamp to manage entry lifetime
569 
570 
571 /**
572  * @brief NDP context
573  **/
574 
575 typedef struct
576 {
577  uint32_t reachableTime; ///<The time a node assumes a neighbor is reachable
578  uint32_t retransTimer; ///<The time between retransmissions of NS messages
579  uint_t dupAddrDetectTransmits; ///<Maximum number of NS messages sent while performing DAD
580  systime_t minRtrSolicitationDelay; ///<Minimum delay before transmitting the first RS message
581  systime_t maxRtrSolicitationDelay; ///<Maximum delay before transmitting the first RS message
582  systime_t rtrSolicitationInterval; ///<Time interval between retransmissions of RS messages
583  uint_t maxRtrSolicitations; ///<Number of retransmissions for RS messages
584  uint_t rtrSolicitationCount; ///<Retransmission counter for RS messages
585  bool_t rtrAdvReceived; ///<Valid RA message received
586  systime_t timestamp; ///<Timestamp to manage retransmissions
587  systime_t timeout; ///<Timeout value
588  bool_t enable; ///<Enable address resolution using Neighbor Discovery protocol
589  NdpNeighborCacheEntry neighborCache[NDP_NEIGHBOR_CACHE_SIZE]; ///<Neighbor cache
590  NdpDestCacheEntry destCache[NDP_DEST_CACHE_SIZE]; ///<Destination cache
591 } NdpContext;
592 
593 
594 //Tick counter to handle periodic operations
596 
597 //NDP related functions
598 error_t ndpInit(NetInterface *interface);
599 error_t ndpEnable(NetInterface *interface, bool_t enable);
600 
602  const MacAddr *macAddr);
603 
605 
606 error_t ndpResolve(NetInterface *interface, const Ipv6Addr *ipAddr,
607  MacAddr *macAddr);
608 
610  NetInterface *destInterface, const Ipv6Addr *ipAddr, NetBuffer *buffer,
611  size_t offset, NetTxAncillary *ancillary);
612 
613 void ndpTick(NetInterface *interface);
614 void ndpLinkChangeEvent(NetInterface *interface);
615 
616 void ndpProcessRouterAdv(NetInterface *interface,
617  const Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer,
618  size_t offset, uint8_t hopLimit);
619 
620 void ndpProcessNeighborSol(NetInterface *interface,
621  const Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer,
622  size_t offset, uint8_t hopLimit);
623 
624 void ndpProcessNeighborAdv(NetInterface *interface,
625  const Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer,
626  size_t offset, uint8_t hopLimit);
627 
628 void ndpProcessRedirect(NetInterface *interface,
629  const Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer,
630  size_t offset, uint8_t hopLimit);
631 
633 
635  const Ipv6Addr *targetIpAddr, bool_t multicast);
636 
638  const Ipv6Addr *targetIpAddr, const Ipv6Addr *destIpAddr);
639 
641  const NetBuffer *ipPacket, size_t ipPacketOffset);
642 
648 
649 //C++ guard
650 #ifdef __cplusplus
651 }
652 #endif
653 
654 #endif
NdpRouterSelPreference
Router selection preferences.
Definition: ndp.h:235
int bool_t
Definition: compiler_port.h:53
@ NDP_ROUTER_SEL_PREFERENCE_MEDIUM
Definition: ndp.h:236
typedef __packed_struct
Router Solicitation message.
Definition: ndp.h:270
uint8_t a
Definition: ndp.h:409
@ NDP_STATE_STALE
Definition: ndp.h:252
uint8_t reserved1
Definition: ndp.h:341
@ NDP_OPT_ANY
Definition: ndp.h:226
error_t ndpSendNeighborSol(NetInterface *interface, const Ipv6Addr *targetIpAddr, bool_t multicast)
Send a Neighbor Solicitation message.
Definition: ndp.c:1689
#define NDP_MAX_PENDING_PACKETS
Definition: ndp.h:67
@ NDP_OPT_MTU
Definition: ndp.h:220
void ndpLinkChangeEvent(NetInterface *interface)
Callback function for link change event.
Definition: ndp.c:541
Ipv6Addr prefix
Definition: ndp.h:415
error_t ndpEnqueuePacket(NetInterface *srcInterface, NetInterface *destInterface, const Ipv6Addr *ipAddr, NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Enqueue an IPv6 packet waiting for address resolution.
Definition: ndp.c:360
uint8_t p
Definition: ndp.h:298
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:89
uint8_t message[]
Definition: chap.h:152
uint8_t options[]
Definition: ndp.h:275
@ NDP_ROUTER_SEL_PREFERENCE_LOW
Definition: ndp.h:239
uint32_t reachableTime
The time a node assumes a neighbor is reachable.
Definition: ndp.h:577
NetTxAncillary ancillary
Additional options.
Definition: ndp.h:536
bool_t rtrAdvReceived
Valid RA message received.
Definition: ndp.h:585
#define NDP_NEIGHBOR_CACHE_SIZE
Definition: ndp.h:53
@ NDP_OPT_SOURCE_LINK_LAYER_ADDR
Definition: ndp.h:216
NdpRedirectMessage
Definition: ndp.h:365
void ndpDumpRouterSolMessage(const NdpRouterSolMessage *message)
Dump Router Solicitation message for debugging purpose.
Definition: ndp.c:2162
systime_t rtrSolicitationInterval
Time interval between retransmissions of RS messages.
Definition: ndp.h:582
uint8_t value[]
Definition: ndp.h:376
Ipv6Addr destAddr
Definition: ndp.h:363
Ipv6Addr
Definition: ipv6.h:249
MacAddr linkLayerAddr
Definition: ndp.h:388
uint_t queueSize
Number of queued packets.
Definition: ndp.h:554
Neighbor cache entry.
Definition: ndp.h:545
Ipv6Addr targetAddr
Definition: ndp.h:321
systime_t minRtrSolicitationDelay
Minimum delay before transmitting the first RS message.
Definition: ndp.h:580
@ NDP_STATE_NONE
Definition: ndp.h:249
void ndpDumpRouterAdvMessage(const NdpRouterAdvMessage *message)
Dump Router Advertisement message for debugging purpose.
Definition: ndp.c:2176
Ipv6Addr destAddr
Destination IPv6 address.
Definition: ndp.h:564
void ndpProcessNeighborSol(NetInterface *interface, const Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, uint8_t hopLimit)
Neighbor Solicitation message processing.
Definition: ndp.c:867
uint32_t lifetime
Definition: ndp.h:478
NdpContextOption
Definition: ndp.h:518
uint8_t curHopLimit
Definition: ndp.h:288
error_t ndpInit(NetInterface *interface)
Neighbor cache initialization.
Definition: ndp.c:68
size_t pathMtu
Path MTU.
Definition: ndp.h:566
size_t offset
Offset to the first byte of the packet.
Definition: ndp.h:535
error_t ndpRemoveStaticEntry(NetInterface *interface, const Ipv6Addr *ipAddr)
Remove a static entry from the Neighbor cache.
Definition: ndp.c:215
uint8_t r
Definition: ndp.h:344
@ NDP_OPT_RECURSIVE_DNS_SERVER
Definition: ndp.h:222
uint8_t ipPacket[]
Definition: ndp.h:429
systime_t timestamp
Timestamp to manage entry lifetime.
Definition: ndp.h:550
uint8_t reserved2[3]
Definition: ndp.h:346
uint32_t validLifetime
Definition: ndp.h:412
@ NDP_OPT_TARGET_LINK_LAYER_ADDR
Definition: ndp.h:217
uint_t dupAddrDetectTransmits
Maximum number of NS messages sent while performing DAD.
Definition: ndp.h:579
uint8_t h
Definition: ndp.h:300
void ndpDumpNeighborSolMessage(const NdpNeighborSolMessage *message)
Dump Neighbor Solicitation message for debugging purpose.
Definition: ndp.c:2196
error_t ndpSendRedirect(NetInterface *interface, const Ipv6Addr *targetAddr, const NetBuffer *ipPacket, size_t ipPacketOffset)
Send a Redirect message.
Definition: ndp.c:1991
MacAddr macAddr
Link layer address associated with the IPv6 address.
Definition: ndp.h:548
NdpRouterAdvMessage
Definition: ndp.h:308
error_t
Error codes.
Definition: error.h:43
NdpNeighborSolMessage
Definition: ndp.h:323
uint16_t routerLifetime
Definition: ndp.h:304
#define Ipv6PseudoHeader
Definition: ipv6.h:42
systime_t timestamp
Timestamp to manage entry lifetime.
Definition: ndp.h:567
NDP context.
Definition: ndp.h:576
NdpOption
Definition: ndp.h:377
systime_t timestamp
Timestamp to manage retransmissions.
Definition: ndp.h:586
uint8_t cid
Definition: ndp.h:511
@ NDP_OPT_DNS_SEARCH_LIST
Definition: ndp.h:223
NdpNeighborAdvMessage
Definition: ndp.h:349
uint32_t reserved
Definition: ndp.h:274
#define NetInterface
Definition: net.h:36
NdpMtuOption
Definition: ndp.h:443
uint32_t routeLifetime
Definition: ndp.h:464
@ NDP_STATE_DELAY
Definition: ndp.h:253
Ipv6Addr address[]
Definition: ndp.h:479
bool_t enable
Enable address resolution using Neighbor Discovery protocol.
Definition: ndp.h:588
@ NDP_OPT_CAPTIVE_PORTAL
Definition: ndp.h:225
#define NetTxAncillary
Definition: net_misc.h:36
NdpRouterSolMessage
Definition: ndp.h:276
NdpState
Neighbor cache entry states.
Definition: ndp.h:248
uint8_t code
Definition: ndp.h:272
systime_t ndpTickCounter
Definition: ndp.c:59
@ NDP_STATE_INCOMPLETE
Definition: ndp.h:250
uint8_t o
Definition: ndp.h:301
uint_t maxRtrSolicitations
Number of retransmissions for RS messages.
Definition: ndp.h:583
uint32_t mtu
Definition: ndp.h:442
uint8_t hopLimit
Definition: ipv6.h:272
#define NDP_DEST_CACHE_SIZE
Definition: ndp.h:60
@ NDP_STATE_REACHABLE
Definition: ndp.h:251
MacAddr
Definition: ethernet.h:193
NdpRouteInfoOption
Definition: ndp.h:466
NdpRedirectedHeaderOption
Definition: ndp.h:430
uint8_t type
Definition: coap_common.h:174
uint8_t l
Definition: ndp.h:410
uint32_t systime_t
System time.
NDP queue item.
Definition: ndp.h:532
uint8_t contextLength
Definition: ndp.h:505
uint32_t retransTimer
The time between retransmissions of NS messages.
Definition: ndp.h:578
Ipv6Addr contextPrefix
Definition: ndp.h:517
Ipv6Addr ipAddr
Unicast IPv6 address.
Definition: ndp.h:547
NdpLinkLayerAddrOption
Definition: ndp.h:389
NetInterface * srcInterface
Interface from which the packet has been received.
Definition: ndp.h:533
@ NDP_ROUTER_SEL_PREFERENCE_HIGH
Definition: ndp.h:237
systime_t maxRtrSolicitationDelay
Maximum delay before transmitting the first RS message.
Definition: ndp.h:581
uint8_t m
Definition: ndp.h:302
error_t ndpResolve(NetInterface *interface, const Ipv6Addr *ipAddr, MacAddr *macAddr)
Address resolution using Neighbor Discovery protocol.
Definition: ndp.c:260
void ndpProcessRedirect(NetInterface *interface, const Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, uint8_t hopLimit)
Redirect message processing.
Definition: ndp.c:1359
@ NDP_OPT_ROUTE_INFORMATION
Definition: ndp.h:221
NdpState state
Reachability state.
Definition: ndp.h:546
Destination cache entry.
Definition: ndp.h:563
uint8_t prf
Definition: ndp.h:299
@ NDP_OPT_REDIRECTED_HEADER
Definition: ndp.h:219
@ NDP_OPT_PREFIX_INFORMATION
Definition: ndp.h:218
error_t ndpAddStaticEntry(NetInterface *interface, const Ipv6Addr *ipAddr, const MacAddr *macAddr)
Add a static entry in the Neighbor cache.
Definition: ndp.c:141
uint8_t prefixLength
Definition: ndp.h:400
uint32_t reachableTime
Definition: ndp.h:305
uint_t retransmitCount
Retransmission counter.
Definition: ndp.h:552
void ndpDumpRedirectMessage(const NdpRedirectMessage *message)
Dump Redirect message for debugging purpose.
Definition: ndp.c:2229
NetBuffer * buffer
Packet waiting for address resolution.
Definition: ndp.h:534
NdpOptionType
Neighbor Discovery options.
Definition: ndp.h:215
systime_t timeout
Timeout value.
Definition: ndp.h:587
uint8_t s
Definition: ndp.h:343
Ipv4Addr ipAddr
Definition: ipcp.h:103
uint32_t preferredLifetime
Definition: ndp.h:413
void ndpDumpNeighborAdvMessage(const NdpNeighborAdvMessage *message)
Dump Neighbor Advertisement message for debugging purpose.
Definition: ndp.c:2211
uint_t rtrSolicitationCount
Retransmission counter for RS messages.
Definition: ndp.h:584
uint16_t checksum
Definition: ndp.h:273
error_t ndpEnable(NetInterface *interface, bool_t enable)
Enable address resolution using Neighbor Discovery protocol.
Definition: ndp.c:106
unsigned int uint_t
Definition: compiler_port.h:50
NdpPrefixInfoOption
Definition: ndp.h:416
TCP/IP stack core.
void ndpTick(NetInterface *interface)
NDP timer handler.
Definition: ndp.c:450
error_t ndpSendNeighborAdv(NetInterface *interface, const Ipv6Addr *targetIpAddr, const Ipv6Addr *destIpAddr)
Send a Neighbor Advertisement message.
Definition: ndp.c:1822
@ NDP_STATE_PERMANENT
Definition: ndp.h:255
uint8_t length
Definition: ndp.h:375
error_t ndpSendRouterSol(NetInterface *interface)
Send a Router Solicitation message.
Definition: ndp.c:1569
@ NDP_STATE_PROBE
Definition: ndp.h:254
@ NDP_OPT_6LOWPAN_CONTEXT
Definition: ndp.h:224
uint32_t retransTimer
Definition: ndp.h:306
uint8_t c
Definition: ndp.h:512
systime_t timeout
Timeout value.
Definition: ndp.h:551
void ndpProcessRouterAdv(NetInterface *interface, const Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, uint8_t hopLimit)
Router Advertisement message processing.
Definition: ndp.c:578
bool_t isRouter
A flag indicating whether the neighbor is a router or a host.
Definition: ndp.h:549
NdpRdnssOption
Definition: ndp.h:480
Ipv6Addr nextHop
IPv6 address of the next-hop neighbor.
Definition: ndp.h:565
uint8_t domainNames[]
Definition: ndp.h:493
@ NDP_ROUTER_SEL_PREFERENCE_RESERVED
Definition: ndp.h:238
void ndpProcessNeighborAdv(NetInterface *interface, const Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, uint8_t hopLimit)
Neighbor Advertisement message processing.
Definition: ndp.c:1112
NdpDnsslOption
Definition: ndp.h:494
Ipv4Addr destIpAddr
Definition: ipcp.h:78