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-2019 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 1.9.6
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 {
227 } NdpOptionType;
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 {
256 } NdpState;
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 
269 typedef __start_packed struct
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 __start_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 #ifdef _CPU_BIG_ENDIAN
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 __start_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 __start_packed struct
331 {
332  uint8_t type; //0
333  uint8_t code; //1
334  uint16_t checksum; //2-3
335 #ifdef _CPU_BIG_ENDIAN
336  uint32_t r : 1; //4
337  uint32_t s : 1;
338  uint32_t o : 1;
339  uint32_t reserved1 : 5;
340  uint32_t reserved2 : 24; //5-7
341 #else
342  uint32_t reserved1 : 5; //4
343  uint32_t o : 1;
344  uint32_t s : 1;
345  uint32_t r : 1;
346  uint32_t reserved2 : 24; //5-7
347 #endif
348  Ipv6Addr targetAddr; //8-23
349  uint8_t options[]; //24
351 
352 
353 /**
354  * @brief Redirect message
355  **/
356 
357 typedef __start_packed struct
358 {
359  uint8_t type; //0
360  uint8_t code; //1
361  uint16_t checksum; //2-3
362  uint32_t reserved; //4-7
363  Ipv6Addr targetAddr; //8-23
365  uint8_t options[]; //40
367 
368 
369 /**
370  * @brief Neighbor Discovery option general format
371  **/
372 
373 typedef __start_packed struct
374 {
375  uint8_t type; //0
376  uint8_t length; //1
377  uint8_t value[]; //2
379 
380 
381 /**
382  * @brief Source/Target Link-Layer Address option
383  **/
384 
385 typedef __start_packed struct
386 {
387  uint8_t type; //0
388  uint8_t length; //1
391 
392 
393 /**
394  * @brief Prefix Information option (PIO)
395  **/
396 
397 typedef __start_packed struct
398 {
399  uint8_t type; //0
400  uint8_t length; //1
401  uint8_t prefixLength; //2
402 #ifdef _CPU_BIG_ENDIAN
403  uint8_t l : 1; //3
404  uint8_t a : 1;
405  uint8_t r : 1;
406  uint8_t reserved1 : 5;
407 #else
408  uint8_t reserved1 : 5; //3
409  uint8_t r : 1;
410  uint8_t a : 1;
411  uint8_t l : 1;
412 #endif
413  uint32_t validLifetime; //4-7
414  uint32_t preferredLifetime; //8-11
415  uint32_t reserved2; //12-15
416  Ipv6Addr prefix; //16-31
418 
419 
420 /**
421  * @brief Redirected Header option (RHO)
422  **/
423 
424 typedef __start_packed struct
425 {
426  uint8_t type; //0
427  uint8_t length; //1
428  uint16_t reserved1; //2-3
429  uint32_t reserved2; //4-7
430  uint8_t ipPacket[]; //8
432 
433 
434 /**
435  * @brief MTU option
436  **/
437 
438 typedef __start_packed struct
439 {
440  uint8_t type; //0
441  uint8_t length; //1
442  uint16_t reserved; //2-3
443  uint32_t mtu; //4-7
445 
446 
447 /**
448  * @brief Route Information option (RIO)
449  **/
450 
451 typedef __start_packed struct
452 {
453  uint8_t type; //0
454  uint8_t length; //1
455  uint8_t prefixLength; //2
456 #ifdef _CPU_BIG_ENDIAN
457  uint8_t reserved1 : 3; //3
458  uint8_t prf : 2;
459  uint8_t reserved2 : 3;
460 #else
461  uint8_t reserved2 : 3; //3
462  uint8_t prf : 2;
463  uint8_t reserved1 : 3;
464 #endif
465  uint32_t routeLifetime; //4-7
466  Ipv6Addr prefix; //8
468 
469 
470 /**
471  * @brief Recursive DNS Server option (RDNSS)
472  **/
473 
474 typedef __start_packed struct
475 {
476  uint8_t type; //0
477  uint8_t length; //1
478  uint16_t reserved; //2-3
479  uint32_t lifetime; //4-7
482 
483 
484 /**
485  * @brief DNS Search List option (DNSSL)
486  **/
487 
488 typedef __start_packed struct
489 {
490  uint8_t type; //0
491  uint8_t length; //1
492  uint16_t reserved; //2-3
493  uint32_t lifetime; //4-7
494  uint8_t domainNames[]; //8
496 
497 
498 /**
499  * @brief 6LoWPAN Context option (6CO)
500  **/
501 
502 typedef __start_packed struct
503 {
504  uint8_t type; //0
505  uint8_t length; //1
506  uint8_t contextLength; //2
507 #ifdef _CPU_BIG_ENDIAN
508  uint8_t reserved1 : 3; //3
509  uint8_t c : 1;
510  uint8_t cid : 4;
511 #else
512  uint8_t cid : 4; //3
513  uint8_t c : 1;
514  uint8_t reserved1 : 3;
515 #endif
516  uint16_t reserved2; //4-5
517  uint16_t validLifetime; //6-7
520 
521 
522 //CodeWarrior or Win32 compiler?
523 #if defined(__CWCC__) || defined(_WIN32)
524  #pragma pack(pop)
525 #endif
526 
527 
528 /**
529  * @brief NDP queue item
530  **/
531 
532 typedef struct
533 {
534  NetInterface *srcInterface; //<Interface from which the packet has been received
535  NetBuffer *buffer; ///<Packet waiting for address resolution
536  size_t offset; ///<Offset to the first byte of the packet
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  NdpNeighborCacheEntry neighborCache[NDP_NEIGHBOR_CACHE_SIZE]; ///<Neighbor cache
589  NdpDestCacheEntry destCache[NDP_DEST_CACHE_SIZE]; ///<Destination cache
590 } NdpContext;
591 
592 
593 //Tick counter to handle periodic operations
595 
596 //NDP related functions
597 error_t ndpInit(NetInterface *interface);
598 
599 error_t ndpResolve(NetInterface *interface, const Ipv6Addr *ipAddr, MacAddr *macAddr);
600 
601 error_t ndpEnqueuePacket(NetInterface *srcInterface, NetInterface *destInterface,
602  const Ipv6Addr *ipAddr, NetBuffer *buffer, size_t offset);
603 
604 void ndpTick(NetInterface *interface);
605 void ndpLinkChangeEvent(NetInterface *interface);
606 
607 void ndpProcessRouterAdv(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader,
608  const NetBuffer *buffer, size_t offset, uint8_t hopLimit);
609 
610 void ndpProcessNeighborSol(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader,
611  const NetBuffer *buffer, size_t offset, uint8_t hopLimit);
612 
613 void ndpProcessNeighborAdv(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader,
614  const NetBuffer *buffer, size_t offset, uint8_t hopLimit);
615 
616 void ndpProcessRedirect(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader,
617  const NetBuffer *buffer, size_t offset, uint8_t hopLimit);
618 
620 
622  const Ipv6Addr *targetIpAddr, bool_t multicast);
623 
625  const Ipv6Addr *targetIpAddr, const Ipv6Addr *destIpAddr);
626 
628  const NetBuffer *ipPacket, size_t ipPacketOffset);
629 
635 
636 //C++ guard
637 #ifdef __cplusplus
638 }
639 #endif
640 
641 #endif
__start_packed struct @200 NdpRouteInfoOption
Route Information option (RIO)
NdpRouterSelPreference
Router selection preferences.
Definition: ndp.h:234
int bool_t
Definition: compiler_port.h:49
@ NDP_ROUTER_SEL_PREFERENCE_MEDIUM
Definition: ndp.h:236
__start_packed struct @195 NdpOption
Neighbor Discovery option general format.
uint8_t a
Definition: ndp.h:410
@ NDP_STATE_STALE
Definition: ndp.h:252
uint32_t reserved1
Definition: ndp.h:342
@ 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:1473
#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:366
Ipv6Addr prefix
Definition: ndp.h:416
__start_packed struct @198 NdpRedirectedHeaderOption
Redirected Header option (RHO)
uint8_t p
Definition: ndp.h:298
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:88
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
void ndpProcessNeighborSol(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, uint8_t hopLimit)
Neighbor Solicitation message processing.
Definition: ndp.c:685
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
void ndpDumpRouterSolMessage(const NdpRouterSolMessage *message)
Dump Router Solicitation message for debugging purpose.
Definition: ndp.c:1894
systime_t rtrSolicitationInterval
Time interval between retransmissions of RS messages.
Definition: ndp.h:582
uint8_t value[]
Definition: ndp.h:377
Ipv6Addr destAddr
Definition: ndp.h:364
MacAddr linkLayerAddr
Definition: ndp.h:389
uint_t queueSize
Number of queued packets.
Definition: ndp.h:554
Neighbor cache entry.
Definition: ndp.h:544
Ipv6Addr targetAddr
Definition: ndp.h:321
void ndpProcessRouterAdv(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, uint8_t hopLimit)
Router Advertisement message processing.
Definition: ndp.c:403
systime_t minRtrSolicitationDelay
Minimum delay before transmitting the first RS message.
Definition: ndp.h:580
__start_packed struct @194 NdpRedirectMessage
Redirect message.
__start_packed struct @190 NdpRouterSolMessage
Router Solicitation message.
__start_packed struct @192 NdpNeighborSolMessage
Neighbor Solicitation message.
@ NDP_STATE_NONE
Definition: ndp.h:249
void ndpDumpRouterAdvMessage(const NdpRouterAdvMessage *message)
Dump Router Advertisement message for debugging purpose.
Definition: ndp.c:1908
Ipv6Addr destAddr
Destination IPv6 address.
Definition: ndp.h:564
uint32_t lifetime
Definition: ndp.h:479
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:536
uint32_t s
Definition: ndp.h:344
__start_packed struct @201 NdpRdnssOption
Recursive DNS Server option (RDNSS)
uint32_t r
Definition: ndp.h:345
@ NDP_OPT_RECURSIVE_DNS_SERVER
Definition: ndp.h:222
uint8_t ipPacket[]
Definition: ndp.h:430
systime_t timestamp
Timestamp to manage entry lifetime.
Definition: ndp.h:550
uint32_t validLifetime
Definition: ndp.h:413
@ 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
__start_packed struct @197 NdpPrefixInfoOption
Prefix Information option (PIO)
uint8_t h
Definition: ndp.h:300
__start_packed struct @193 NdpNeighborAdvMessage
Neighbor Advertisement message.
void ndpDumpNeighborSolMessage(const NdpNeighborSolMessage *message)
Dump Neighbor Solicitation message for debugging purpose.
Definition: ndp.c:1928
error_t ndpSendRedirect(NetInterface *interface, const Ipv6Addr *targetAddr, const NetBuffer *ipPacket, size_t ipPacketOffset)
Send a Redirect message.
Definition: ndp.c:1735
MacAddr macAddr
Link layer address associated with the IPv6 address.
Definition: ndp.h:548
error_t
Error codes.
Definition: error.h:42
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:575
systime_t timestamp
Timestamp to manage retransmissions.
Definition: ndp.h:586
uint8_t cid
Definition: ndp.h:512
__start_packed struct @203 NdpContextOption
6LoWPAN Context option (6CO)
@ NDP_OPT_DNS_SEARCH_LIST
Definition: ndp.h:223
error_t ndpEnqueuePacket(NetInterface *srcInterface, NetInterface *destInterface, const Ipv6Addr *ipAddr, NetBuffer *buffer, size_t offset)
Enqueue an IPv6 packet waiting for address resolution.
Definition: ndp.c:192
uint32_t reserved
Definition: ndp.h:274
#define NetInterface
Definition: net.h:36
uint32_t routeLifetime
Definition: ndp.h:465
@ NDP_STATE_DELAY
Definition: ndp.h:253
Ipv6Addr address[]
Definition: ndp.h:480
__start_packed struct _Ipv4Header __end_packed
@ NDP_OPT_CAPTIVE_PORTAL
Definition: ndp.h:225
__start_packed struct @179 Ipv6Addr
IPv6 network address.
NdpState
Neighbor cache entry states.
Definition: ndp.h:247
uint8_t code
Definition: ndp.h:272
systime_t ndpTickCounter
Definition: ndp.c:59
@ NDP_STATE_INCOMPLETE
Definition: ndp.h:250
uint_t maxRtrSolicitations
Number of retransmissions for RS messages.
Definition: ndp.h:583
uint32_t mtu
Definition: ndp.h:443
#define NDP_DEST_CACHE_SIZE
Definition: ndp.h:60
@ NDP_STATE_REACHABLE
Definition: ndp.h:251
uint8_t l
Definition: ndp.h:411
NDP queue item.
Definition: ndp.h:532
uint8_t contextLength
Definition: ndp.h:506
uint32_t retransTimer
The time between retransmissions of NS messages.
Definition: ndp.h:578
Ipv6Addr contextPrefix
Definition: ndp.h:518
__start_packed struct @191 NdpRouterAdvMessage
Router Advertisement message.
Ipv6Addr ipAddr
Unicast IPv6 address.
Definition: ndp.h:547
NetInterface * srcInterface
Definition: ndp.h:534
@ 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:100
void ndpProcessRedirect(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, uint8_t hopLimit)
Redirect message processing.
Definition: ndp.c:1166
@ NDP_OPT_ROUTE_INFORMATION
Definition: ndp.h:221
NdpState state
Reachability state.
Definition: ndp.h:546
Destination cache entry.
Definition: ndp.h:562
uint8_t prf
Definition: ndp.h:299
@ NDP_OPT_REDIRECTED_HEADER
Definition: ndp.h:219
@ NDP_OPT_PREFIX_INFORMATION
Definition: ndp.h:218
void ndpProcessNeighborAdv(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, uint8_t hopLimit)
Neighbor Advertisement message processing.
Definition: ndp.c:919
uint8_t prefixLength
Definition: ndp.h:401
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:1961
NetBuffer * buffer
Packet waiting for address resolution.
Definition: ndp.h:535
uint8_t message[]
Definition: chap.h:152
__start_packed struct @196 NdpLinkLayerAddrOption
Source/Target Link-Layer Address option.
uint32_t reserved2
Definition: ndp.h:346
NdpOptionType
Neighbor Discovery options.
Definition: ndp.h:214
systime_t timeout
Timeout value.
Definition: ndp.h:587
uint8_t o
Definition: ndp.h:301
uint32_t preferredLifetime
Definition: ndp.h:414
void ndpDumpNeighborAdvMessage(const NdpNeighborAdvMessage *message)
Dump Neighbor Advertisement message for debugging purpose.
Definition: ndp.c:1943
uint_t rtrSolicitationCount
Retransmission counter for RS messages.
Definition: ndp.h:584
uint16_t checksum
Definition: ndp.h:273
unsigned int uint_t
Definition: compiler_port.h:45
TCP/IP stack core.
void ndpTick(NetInterface *interface)
NDP timer handler.
Definition: ndp.c:276
error_t ndpSendNeighborAdv(NetInterface *interface, const Ipv6Addr *targetIpAddr, const Ipv6Addr *destIpAddr)
Send a Neighbor Advertisement message.
Definition: ndp.c:1593
@ NDP_STATE_PERMANENT
Definition: ndp.h:255
uint8_t type
Definition: ndp.h:271
uint8_t length
Definition: ndp.h:376
__start_packed struct @199 NdpMtuOption
MTU option.
error_t ndpSendRouterSol(NetInterface *interface)
Send a Router Solicitation message.
Definition: ndp.c:1366
@ NDP_STATE_PROBE
Definition: ndp.h:254
uint32_t systime_t
Definition: compiler_port.h:46
uint8_t ipAddr[4]
Definition: mib_common.h:187
@ NDP_OPT_6LOWPAN_CONTEXT
Definition: ndp.h:224
uint32_t retransTimer
Definition: ndp.h:306
__start_packed struct @202 NdpDnsslOption
DNS Search List option (DNSSL)
uint8_t c
Definition: ndp.h:513
systime_t timeout
Timeout value.
Definition: ndp.h:551
bool_t isRouter
A flag indicating whether the neighbor is a router or a host.
Definition: ndp.h:549
Ipv6Addr nextHop
IPv6 address of the next-hop neighbor.
Definition: ndp.h:565
uint8_t domainNames[]
Definition: ndp.h:494
__start_packed struct @108 MacAddr
MAC address.
@ NDP_ROUTER_SEL_PREFERENCE_RESERVED
Definition: ndp.h:238
Ipv4Addr destIpAddr
Definition: ipcp.h:78