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-2024 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.4.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 //CC-RX, CodeWarrior or Win32 compiler?
260 #if defined(__CCRX__)
261  #pragma pack
262 #elif defined(__CWCC__) || defined(_WIN32)
263  #pragma pack(push, 1)
264 #endif
265 
266 
267 /**
268  * @brief Router Solicitation message
269  **/
270 
272 {
273  uint8_t type; //0
274  uint8_t code; //1
275  uint16_t checksum; //2-3
276  uint32_t reserved; //4-7
277  uint8_t options[]; //8
279 
280 
281 /**
282  * @brief Router Advertisement message
283  **/
284 
285 typedef __packed_struct
286 {
287  uint8_t type; //0
288  uint8_t code; //1
289  uint16_t checksum; //2-3
290  uint8_t curHopLimit; //4
291 #if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
292  uint8_t m : 1; //5
293  uint8_t o : 1;
294  uint8_t h : 1;
295  uint8_t prf : 2;
296  uint8_t p : 1;
297  uint8_t reserved : 2;
298 #else
299  uint8_t reserved : 2; //5
300  uint8_t p : 1;
301  uint8_t prf : 2;
302  uint8_t h : 1;
303  uint8_t o : 1;
304  uint8_t m : 1;
305 #endif
306  uint16_t routerLifetime; //6-7
307  uint32_t reachableTime; //8-11
308  uint32_t retransTimer; //12-15
309  uint8_t options[]; //16
311 
312 
313 /**
314  * @brief Neighbor Solicitation message
315  **/
316 
317 typedef __packed_struct
318 {
319  uint8_t type; //0
320  uint8_t code; //1
321  uint16_t checksum; //2-3
322  uint32_t reserved; //4-7
324  uint8_t options[]; //24
326 
327 
328 /**
329  * @brief Neighbor Advertisement message
330  **/
331 
332 typedef __packed_struct
333 {
334  uint8_t type; //0
335  uint8_t code; //1
336  uint16_t checksum; //2-3
337 #if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
338  uint8_t r : 1; //4
339  uint8_t s : 1;
340  uint8_t o : 1;
341  uint8_t reserved1 : 5;
342 #else
343  uint8_t reserved1 : 5; //4
344  uint8_t o : 1;
345  uint8_t s : 1;
346  uint8_t r : 1;
347 #endif
348  uint8_t reserved2[3]; //5-7
349  Ipv6Addr targetAddr; //8-23
350  uint8_t options[]; //24
352 
353 
354 /**
355  * @brief Redirect message
356  **/
357 
358 typedef __packed_struct
359 {
360  uint8_t type; //0
361  uint8_t code; //1
362  uint16_t checksum; //2-3
363  uint32_t reserved; //4-7
364  Ipv6Addr targetAddr; //8-23
366  uint8_t options[]; //40
368 
369 
370 /**
371  * @brief Neighbor Discovery option general format
372  **/
373 
374 typedef __packed_struct
375 {
376  uint8_t type; //0
377  uint8_t length; //1
378  uint8_t value[]; //2
380 
381 
382 /**
383  * @brief Source/Target Link-Layer Address option
384  **/
385 
386 typedef __packed_struct
387 {
388  uint8_t type; //0
389  uint8_t length; //1
392 
393 
394 /**
395  * @brief Prefix Information option (PIO)
396  **/
397 
398 typedef __packed_struct
399 {
400  uint8_t type; //0
401  uint8_t length; //1
402  uint8_t prefixLength; //2
403 #if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
404  uint8_t l : 1; //3
405  uint8_t a : 1;
406  uint8_t r : 1;
407  uint8_t reserved1 : 5;
408 #else
409  uint8_t reserved1 : 5; //3
410  uint8_t r : 1;
411  uint8_t a : 1;
412  uint8_t l : 1;
413 #endif
414  uint32_t validLifetime; //4-7
415  uint32_t preferredLifetime; //8-11
416  uint32_t reserved2; //12-15
417  Ipv6Addr prefix; //16-31
419 
420 
421 /**
422  * @brief Redirected Header option (RHO)
423  **/
424 
425 typedef __packed_struct
426 {
427  uint8_t type; //0
428  uint8_t length; //1
429  uint16_t reserved1; //2-3
430  uint32_t reserved2; //4-7
431  uint8_t ipPacket[]; //8
433 
434 
435 /**
436  * @brief MTU option
437  **/
438 
439 typedef __packed_struct
440 {
441  uint8_t type; //0
442  uint8_t length; //1
443  uint16_t reserved; //2-3
444  uint32_t mtu; //4-7
446 
447 
448 /**
449  * @brief Route Information option (RIO)
450  **/
451 
452 typedef __packed_struct
453 {
454  uint8_t type; //0
455  uint8_t length; //1
456  uint8_t prefixLength; //2
457 #if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
458  uint8_t reserved1 : 3; //3
459  uint8_t prf : 2;
460  uint8_t reserved2 : 3;
461 #else
462  uint8_t reserved2 : 3; //3
463  uint8_t prf : 2;
464  uint8_t reserved1 : 3;
465 #endif
466  uint32_t routeLifetime; //4-7
467  Ipv6Addr prefix; //8
469 
470 
471 /**
472  * @brief Recursive DNS Server option (RDNSS)
473  **/
474 
475 typedef __packed_struct
476 {
477  uint8_t type; //0
478  uint8_t length; //1
479  uint16_t reserved; //2-3
480  uint32_t lifetime; //4-7
483 
484 
485 /**
486  * @brief DNS Search List option (DNSSL)
487  **/
488 
489 typedef __packed_struct
490 {
491  uint8_t type; //0
492  uint8_t length; //1
493  uint16_t reserved; //2-3
494  uint32_t lifetime; //4-7
495  uint8_t domainNames[]; //8
497 
498 
499 /**
500  * @brief 6LoWPAN Context option (6CO)
501  **/
502 
503 typedef __packed_struct
504 {
505  uint8_t type; //0
506  uint8_t length; //1
507  uint8_t contextLength; //2
508 #if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
509  uint8_t reserved1 : 3; //3
510  uint8_t c : 1;
511  uint8_t cid : 4;
512 #else
513  uint8_t cid : 4; //3
514  uint8_t c : 1;
515  uint8_t reserved1 : 3;
516 #endif
517  uint16_t reserved2; //4-5
518  uint16_t validLifetime; //6-7
521 
522 
523 //CC-RX, CodeWarrior or Win32 compiler?
524 #if defined(__CCRX__)
525  #pragma unpack
526 #elif defined(__CWCC__) || defined(_WIN32)
527  #pragma pack(pop)
528 #endif
529 
530 
531 /**
532  * @brief NDP queue item
533  **/
534 
535 typedef struct
536 {
537  NetInterface *srcInterface; ///<Interface from which the packet has been received
538  NetBuffer *buffer; ///<Packet waiting for address resolution
539  size_t offset; ///<Offset to the first byte of the packet
540  NetTxAncillary ancillary; ///<Additional options
541 } NdpQueueItem;
542 
543 
544 /**
545  * @brief Neighbor cache entry
546  **/
547 
548 typedef struct
549 {
550  NdpState state; ///<Reachability state
551  Ipv6Addr ipAddr; ///<Unicast IPv6 address
552  MacAddr macAddr; ///<Link layer address associated with the IPv6 address
553  bool_t isRouter; ///<A flag indicating whether the neighbor is a router or a host
554  systime_t timestamp; ///<Timestamp to manage entry lifetime
555  systime_t timeout; ///<Timeout value
556  uint_t retransmitCount; ///<Retransmission counter
557  NdpQueueItem queue[NDP_MAX_PENDING_PACKETS]; ///<Packets waiting for address resolution to complete
558  uint_t queueSize; ///<Number of queued packets
560 
561 
562 /**
563  * @brief Destination cache entry
564  **/
565 
566 typedef struct
567 {
568  Ipv6Addr destAddr; ///<Destination IPv6 address
569  Ipv6Addr nextHop; ///<IPv6 address of the next-hop neighbor
570  size_t pathMtu; ///<Path MTU
571  systime_t timestamp; ///<Timestamp to manage entry lifetime
573 
574 
575 /**
576  * @brief NDP context
577  **/
578 
579 typedef struct
580 {
581  uint32_t reachableTime; ///<The time a node assumes a neighbor is reachable
582  uint32_t retransTimer; ///<The time between retransmissions of NS messages
583  uint_t dupAddrDetectTransmits; ///<Maximum number of NS messages sent while performing DAD
584  systime_t minRtrSolicitationDelay; ///<Minimum delay before transmitting the first RS message
585  systime_t maxRtrSolicitationDelay; ///<Maximum delay before transmitting the first RS message
586  systime_t rtrSolicitationInterval; ///<Time interval between retransmissions of RS messages
587  uint_t maxRtrSolicitations; ///<Number of retransmissions for RS messages
588  uint_t rtrSolicitationCount; ///<Retransmission counter for RS messages
589  bool_t rtrAdvReceived; ///<Valid RA message received
590  systime_t timestamp; ///<Timestamp to manage retransmissions
591  systime_t timeout; ///<Timeout value
592  bool_t enable; ///<Enable address resolution using Neighbor Discovery protocol
593  NdpNeighborCacheEntry neighborCache[NDP_NEIGHBOR_CACHE_SIZE]; ///<Neighbor cache
594  NdpDestCacheEntry destCache[NDP_DEST_CACHE_SIZE]; ///<Destination cache
595 } NdpContext;
596 
597 
598 //Tick counter to handle periodic operations
600 
601 //NDP related functions
602 error_t ndpInit(NetInterface *interface);
603 error_t ndpEnable(NetInterface *interface, bool_t enable);
604 
606  const MacAddr *macAddr);
607 
609 
610 error_t ndpResolve(NetInterface *interface, const Ipv6Addr *ipAddr,
611  MacAddr *macAddr);
612 
614  NetInterface *destInterface, const Ipv6Addr *ipAddr, NetBuffer *buffer,
615  size_t offset, NetTxAncillary *ancillary);
616 
617 void ndpTick(NetInterface *interface);
618 void ndpLinkChangeEvent(NetInterface *interface);
619 
620 void ndpProcessRouterAdv(NetInterface *interface,
621  const Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer,
622  size_t offset, uint8_t hopLimit);
623 
624 void ndpProcessNeighborSol(NetInterface *interface,
625  const Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer,
626  size_t offset, uint8_t hopLimit);
627 
628 void ndpProcessNeighborAdv(NetInterface *interface,
629  const Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer,
630  size_t offset, uint8_t hopLimit);
631 
632 void ndpProcessRedirect(NetInterface *interface,
633  const Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer,
634  size_t offset, uint8_t hopLimit);
635 
637 
639  const Ipv6Addr *targetIpAddr, bool_t multicast);
640 
642  const Ipv6Addr *targetIpAddr, const Ipv6Addr *destIpAddr);
643 
645  const NetBuffer *ipPacket, size_t ipPacketOffset);
646 
652 
653 //C++ guard
654 #ifdef __cplusplus
655 }
656 #endif
657 
658 #endif
uint8_t message[]
Definition: chap.h:154
uint8_t type
Definition: coap_common.h:176
unsigned int uint_t
Definition: compiler_port.h:50
int bool_t
Definition: compiler_port.h:53
error_t
Error codes.
Definition: error.h:43
MacAddr
Definition: ethernet.h:195
Ipv4Addr ipAddr
Definition: ipcp.h:105
Ipv4Addr destIpAddr
Definition: ipcp.h:80
Ipv6Addr
Definition: ipv6.h:251
uint8_t hopLimit
Definition: ipv6.h:274
#define Ipv6PseudoHeader
Definition: ipv6.h:42
void ndpDumpNeighborSolMessage(const NdpNeighborSolMessage *message)
Dump Neighbor Solicitation message for debugging purpose.
Definition: ndp.c:2196
void ndpProcessNeighborSol(NetInterface *interface, const Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, uint8_t hopLimit)
Neighbor Solicitation message processing.
Definition: ndp.c:867
void ndpDumpRedirectMessage(const NdpRedirectMessage *message)
Dump Redirect message for debugging purpose.
Definition: ndp.c:2229
void ndpDumpNeighborAdvMessage(const NdpNeighborAdvMessage *message)
Dump Neighbor Advertisement message for debugging purpose.
Definition: ndp.c:2211
Ipv6Addr address[]
Definition: ndp.h:481
NdpRedirectedHeaderOption
Definition: ndp.h:432
uint8_t h
Definition: ndp.h:302
error_t ndpSendRedirect(NetInterface *interface, const Ipv6Addr *targetAddr, const NetBuffer *ipPacket, size_t ipPacketOffset)
Send a Redirect message.
Definition: ndp.c:1991
void ndpDumpRouterAdvMessage(const NdpRouterAdvMessage *message)
Dump Router Advertisement message for debugging purpose.
Definition: ndp.c:2176
NdpRouterSelPreference
Router selection preferences.
Definition: ndp.h:235
@ NDP_ROUTER_SEL_PREFERENCE_RESERVED
Definition: ndp.h:238
@ NDP_ROUTER_SEL_PREFERENCE_HIGH
Definition: ndp.h:237
@ NDP_ROUTER_SEL_PREFERENCE_LOW
Definition: ndp.h:239
@ NDP_ROUTER_SEL_PREFERENCE_MEDIUM
Definition: ndp.h:236
NdpRouterAdvMessage
Definition: ndp.h:310
uint8_t reserved1
Definition: ndp.h:343
Ipv6Addr targetAddr
Definition: ndp.h:323
void ndpProcessRedirect(NetInterface *interface, const Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, uint8_t hopLimit)
Redirect message processing.
Definition: ndp.c:1359
uint8_t c
Definition: ndp.h:514
NdpRedirectMessage
Definition: ndp.h:367
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
error_t ndpAddStaticEntry(NetInterface *interface, const Ipv6Addr *ipAddr, const MacAddr *macAddr)
Add a static entry in the Neighbor cache.
Definition: ndp.c:141
uint16_t routerLifetime
Definition: ndp.h:306
uint32_t mtu
Definition: ndp.h:444
uint32_t preferredLifetime
Definition: ndp.h:415
uint8_t reserved2[3]
Definition: ndp.h:348
error_t ndpSendNeighborAdv(NetInterface *interface, const Ipv6Addr *targetIpAddr, const Ipv6Addr *destIpAddr)
Send a Neighbor Advertisement message.
Definition: ndp.c:1822
NdpRouteInfoOption
Definition: ndp.h:468
NdpNeighborSolMessage
Definition: ndp.h:325
error_t ndpInit(NetInterface *interface)
Neighbor cache initialization.
Definition: ndp.c:68
uint8_t r
Definition: ndp.h:346
uint8_t s
Definition: ndp.h:345
uint8_t l
Definition: ndp.h:412
uint32_t routeLifetime
Definition: ndp.h:466
uint32_t lifetime
Definition: ndp.h:480
uint32_t validLifetime
Definition: ndp.h:414
uint32_t reserved
Definition: ndp.h:276
error_t ndpEnable(NetInterface *interface, bool_t enable)
Enable address resolution using Neighbor Discovery protocol.
Definition: ndp.c:106
uint8_t domainNames[]
Definition: ndp.h:495
uint8_t p
Definition: ndp.h:300
uint16_t checksum
Definition: ndp.h:275
uint8_t o
Definition: ndp.h:303
uint8_t m
Definition: ndp.h:304
uint8_t ipPacket[]
Definition: ndp.h:431
error_t ndpSendRouterSol(NetInterface *interface)
Send a Router Solicitation message.
Definition: ndp.c:1569
uint8_t curHopLimit
Definition: ndp.h:290
NdpNeighborAdvMessage
Definition: ndp.h:351
uint8_t options[]
Definition: ndp.h:277
#define NDP_DEST_CACHE_SIZE
Definition: ndp.h:60
void ndpDumpRouterSolMessage(const NdpRouterSolMessage *message)
Dump Router Solicitation message for debugging purpose.
Definition: ndp.c:2162
uint8_t prefixLength
Definition: ndp.h:402
Ipv6Addr prefix
Definition: ndp.h:417
NdpMtuOption
Definition: ndp.h:445
uint32_t reachableTime
Definition: ndp.h:307
uint32_t retransTimer
Definition: ndp.h:308
uint8_t cid
Definition: ndp.h:513
error_t ndpRemoveStaticEntry(NetInterface *interface, const Ipv6Addr *ipAddr)
Remove a static entry from the Neighbor cache.
Definition: ndp.c:215
void ndpProcessNeighborAdv(NetInterface *interface, const Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, uint8_t hopLimit)
Neighbor Advertisement message processing.
Definition: ndp.c:1112
MacAddr linkLayerAddr
Definition: ndp.h:390
uint8_t code
Definition: ndp.h:274
NdpState
Neighbor cache entry states.
Definition: ndp.h:248
@ NDP_STATE_NONE
Definition: ndp.h:249
@ NDP_STATE_PROBE
Definition: ndp.h:254
@ NDP_STATE_DELAY
Definition: ndp.h:253
@ NDP_STATE_REACHABLE
Definition: ndp.h:251
@ NDP_STATE_STALE
Definition: ndp.h:252
@ NDP_STATE_PERMANENT
Definition: ndp.h:255
@ NDP_STATE_INCOMPLETE
Definition: ndp.h:250
NdpOption
Definition: ndp.h:379
NdpPrefixInfoOption
Definition: ndp.h:418
error_t ndpSendNeighborSol(NetInterface *interface, const Ipv6Addr *targetIpAddr, bool_t multicast)
Send a Neighbor Solicitation message.
Definition: ndp.c:1689
NdpContextOption
Definition: ndp.h:520
uint8_t contextLength
Definition: ndp.h:507
void ndpLinkChangeEvent(NetInterface *interface)
Callback function for link change event.
Definition: ndp.c:541
Ipv6Addr destAddr
Definition: ndp.h:365
uint8_t length
Definition: ndp.h:377
NdpLinkLayerAddrOption
Definition: ndp.h:391
systime_t ndpTickCounter
Definition: ndp.c:59
uint8_t prf
Definition: ndp.h:301
typedef __packed_struct
Router Solicitation message.
Definition: ndp.h:272
void ndpProcessRouterAdv(NetInterface *interface, const Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, uint8_t hopLimit)
Router Advertisement message processing.
Definition: ndp.c:578
Ipv6Addr contextPrefix
Definition: ndp.h:519
uint8_t value[]
Definition: ndp.h:378
void ndpTick(NetInterface *interface)
NDP timer handler.
Definition: ndp.c:450
NdpDnsslOption
Definition: ndp.h:496
NdpRouterSolMessage
Definition: ndp.h:278
#define NDP_NEIGHBOR_CACHE_SIZE
Definition: ndp.h:53
NdpRdnssOption
Definition: ndp.h:482
NdpOptionType
Neighbor Discovery options.
Definition: ndp.h:215
@ NDP_OPT_ROUTE_INFORMATION
Definition: ndp.h:221
@ NDP_OPT_REDIRECTED_HEADER
Definition: ndp.h:219
@ NDP_OPT_6LOWPAN_CONTEXT
Definition: ndp.h:224
@ NDP_OPT_ANY
Definition: ndp.h:226
@ NDP_OPT_SOURCE_LINK_LAYER_ADDR
Definition: ndp.h:216
@ NDP_OPT_RECURSIVE_DNS_SERVER
Definition: ndp.h:222
@ NDP_OPT_PREFIX_INFORMATION
Definition: ndp.h:218
@ NDP_OPT_DNS_SEARCH_LIST
Definition: ndp.h:223
@ NDP_OPT_TARGET_LINK_LAYER_ADDR
Definition: ndp.h:217
@ NDP_OPT_MTU
Definition: ndp.h:220
@ NDP_OPT_CAPTIVE_PORTAL
Definition: ndp.h:225
#define NDP_MAX_PENDING_PACKETS
Definition: ndp.h:67
uint8_t a
Definition: ndp.h:411
error_t ndpResolve(NetInterface *interface, const Ipv6Addr *ipAddr, MacAddr *macAddr)
Address resolution using Neighbor Discovery protocol.
Definition: ndp.c:260
TCP/IP stack core.
#define NetInterface
Definition: net.h:36
#define NetTxAncillary
Definition: net_misc.h:36
uint32_t systime_t
System time.
NDP context.
Definition: ndp.h:580
systime_t timestamp
Timestamp to manage retransmissions.
Definition: ndp.h:590
uint_t rtrSolicitationCount
Retransmission counter for RS messages.
Definition: ndp.h:588
uint_t dupAddrDetectTransmits
Maximum number of NS messages sent while performing DAD.
Definition: ndp.h:583
systime_t minRtrSolicitationDelay
Minimum delay before transmitting the first RS message.
Definition: ndp.h:584
uint32_t reachableTime
The time a node assumes a neighbor is reachable.
Definition: ndp.h:581
uint32_t retransTimer
The time between retransmissions of NS messages.
Definition: ndp.h:582
systime_t maxRtrSolicitationDelay
Maximum delay before transmitting the first RS message.
Definition: ndp.h:585
bool_t rtrAdvReceived
Valid RA message received.
Definition: ndp.h:589
systime_t timeout
Timeout value.
Definition: ndp.h:591
uint_t maxRtrSolicitations
Number of retransmissions for RS messages.
Definition: ndp.h:587
bool_t enable
Enable address resolution using Neighbor Discovery protocol.
Definition: ndp.h:592
systime_t rtrSolicitationInterval
Time interval between retransmissions of RS messages.
Definition: ndp.h:586
Destination cache entry.
Definition: ndp.h:567
systime_t timestamp
Timestamp to manage entry lifetime.
Definition: ndp.h:571
size_t pathMtu
Path MTU.
Definition: ndp.h:570
Ipv6Addr nextHop
IPv6 address of the next-hop neighbor.
Definition: ndp.h:569
Ipv6Addr destAddr
Destination IPv6 address.
Definition: ndp.h:568
Neighbor cache entry.
Definition: ndp.h:549
systime_t timestamp
Timestamp to manage entry lifetime.
Definition: ndp.h:554
Ipv6Addr ipAddr
Unicast IPv6 address.
Definition: ndp.h:551
bool_t isRouter
A flag indicating whether the neighbor is a router or a host.
Definition: ndp.h:553
MacAddr macAddr
Link layer address associated with the IPv6 address.
Definition: ndp.h:552
NdpState state
Reachability state.
Definition: ndp.h:550
uint_t retransmitCount
Retransmission counter.
Definition: ndp.h:556
uint_t queueSize
Number of queued packets.
Definition: ndp.h:558
systime_t timeout
Timeout value.
Definition: ndp.h:555
NDP queue item.
Definition: ndp.h:536
NetInterface * srcInterface
Interface from which the packet has been received.
Definition: ndp.h:537
NetBuffer * buffer
Packet waiting for address resolution.
Definition: ndp.h:538
size_t offset
Offset to the first byte of the packet.
Definition: ndp.h:539
NetTxAncillary ancillary
Additional options.
Definition: ndp.h:540
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:89