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-2021 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.1.2
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
206extern "C" {
207#endif
208
209
210/**
211 * @brief Neighbor Discovery options
212 **/
213
214typedef enum
215{
226 NDP_OPT_ANY = 255
228
229
230/**
231 * @brief Router selection preferences
232 **/
233
234typedef enum
235{
241
242
243/**
244 * @brief Neighbor cache entry states
245 **/
246
247typedef 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
269typedef __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
283typedef __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#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
315typedef __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
330typedef __start_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
356typedef __start_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
372typedef __start_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
384typedef __start_packed struct
385{
386 uint8_t type; //0
387 uint8_t length; //1
390
391
392/**
393 * @brief Prefix Information option (PIO)
394 **/
395
396typedef __start_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
417
418
419/**
420 * @brief Redirected Header option (RHO)
421 **/
422
423typedef __start_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
437typedef __start_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
450typedef __start_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
473typedef __start_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
487typedef __start_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
501typedef __start_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
531typedef 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
538
539
540/**
541 * @brief Neighbor cache entry
542 **/
543
544typedef 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
562typedef 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
575typedef 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
597error_t ndpInit(NetInterface *interface);
598
600 MacAddr *macAddr);
601
603 NetInterface *destInterface, const Ipv6Addr *ipAddr, NetBuffer *buffer,
604 size_t offset, NetTxAncillary *ancillary);
605
606void ndpTick(NetInterface *interface);
607void ndpLinkChangeEvent(NetInterface *interface);
608
609void ndpProcessRouterAdv(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader,
610 const NetBuffer *buffer, size_t offset, uint8_t hopLimit);
611
612void ndpProcessNeighborSol(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader,
613 const NetBuffer *buffer, size_t offset, uint8_t hopLimit);
614
615void ndpProcessNeighborAdv(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader,
616 const NetBuffer *buffer, size_t offset, uint8_t hopLimit);
617
618void ndpProcessRedirect(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader,
619 const NetBuffer *buffer, size_t offset, uint8_t hopLimit);
620
622
624 const Ipv6Addr *targetIpAddr, bool_t multicast);
625
627 const Ipv6Addr *targetIpAddr, const Ipv6Addr *destIpAddr);
628
630 const NetBuffer *ipPacket, size_t ipPacketOffset);
631
637
638//C++ guard
639#ifdef __cplusplus
640}
641#endif
642
643#endif
uint8_t message[]
Definition: chap.h:152
unsigned int uint_t
Definition: compiler_port.h:45
int bool_t
Definition: compiler_port.h:49
uint32_t systime_t
Definition: compiler_port.h:46
error_t
Error codes.
Definition: error.h:43
__start_packed struct @116 MacAddr
MAC address.
Ipv4Addr destIpAddr
Definition: ipcp.h:78
__start_packed struct _Ipv4Header __end_packed
#define Ipv6PseudoHeader
Definition: ipv6.h:42
__start_packed struct @188 Ipv6Addr
IPv6 network address.
uint8_t ipAddr[4]
Definition: mib_common.h:187
void ndpDumpNeighborSolMessage(const NdpNeighborSolMessage *message)
Dump Neighbor Solicitation message for debugging purpose.
Definition: ndp.c:1987
void ndpDumpRedirectMessage(const NdpRedirectMessage *message)
Dump Redirect message for debugging purpose.
Definition: ndp.c:2020
void ndpDumpNeighborAdvMessage(const NdpNeighborAdvMessage *message)
Dump Neighbor Advertisement message for debugging purpose.
Definition: ndp.c:2002
__start_packed struct @206 NdpPrefixInfoOption
Prefix Information option (PIO)
__start_packed struct @208 NdpMtuOption
MTU option.
Ipv6Addr address[]
Definition: ndp.h:479
uint8_t type
Definition: ndp.h:271
__start_packed struct @209 NdpRouteInfoOption
Route Information option (RIO)
uint8_t h
Definition: ndp.h:300
error_t ndpSendRedirect(NetInterface *interface, const Ipv6Addr *targetAddr, const NetBuffer *ipPacket, size_t ipPacketOffset)
Send a Redirect message.
Definition: ndp.c:1782
void ndpDumpRouterAdvMessage(const NdpRouterAdvMessage *message)
Dump Router Advertisement message for debugging purpose.
Definition: ndp.c:1967
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
uint8_t reserved1
Definition: ndp.h:341
Ipv6Addr targetAddr
Definition: ndp.h:321
uint8_t c
Definition: ndp.h:512
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:196
uint16_t routerLifetime
Definition: ndp.h:304
uint32_t mtu
Definition: ndp.h:442
uint32_t preferredLifetime
Definition: ndp.h:413
uint8_t reserved2[3]
Definition: ndp.h:346
__start_packed struct @207 NdpRedirectedHeaderOption
Redirected Header option (RHO)
error_t ndpSendNeighborAdv(NetInterface *interface, const Ipv6Addr *targetIpAddr, const Ipv6Addr *destIpAddr)
Send a Neighbor Advertisement message.
Definition: ndp.c:1626
__start_packed struct @212 NdpContextOption
6LoWPAN Context option (6CO)
void ndpProcessNeighborSol(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, uint8_t hopLimit)
Neighbor Solicitation message processing.
Definition: ndp.c:694
error_t ndpInit(NetInterface *interface)
Neighbor cache initialization.
Definition: ndp.c:69
uint8_t r
Definition: ndp.h:344
__start_packed struct @202 NdpNeighborAdvMessage
Neighbor Advertisement message.
uint8_t s
Definition: ndp.h:343
uint8_t l
Definition: ndp.h:410
__start_packed struct @205 NdpLinkLayerAddrOption
Source/Target Link-Layer Address option.
uint32_t routeLifetime
Definition: ndp.h:464
uint32_t lifetime
Definition: ndp.h:478
uint32_t validLifetime
Definition: ndp.h:412
uint32_t reserved
Definition: ndp.h:274
uint8_t domainNames[]
Definition: ndp.h:493
uint8_t p
Definition: ndp.h:298
uint16_t checksum
Definition: ndp.h:273
uint8_t o
Definition: ndp.h:301
uint8_t m
Definition: ndp.h:302
uint8_t ipPacket[]
Definition: ndp.h:429
error_t ndpSendRouterSol(NetInterface *interface)
Send a Router Solicitation message.
Definition: ndp.c:1375
uint8_t curHopLimit
Definition: ndp.h:288
uint8_t options[]
Definition: ndp.h:275
#define NDP_DEST_CACHE_SIZE
Definition: ndp.h:60
void ndpDumpRouterSolMessage(const NdpRouterSolMessage *message)
Dump Router Solicitation message for debugging purpose.
Definition: ndp.c:1953
uint8_t prefixLength
Definition: ndp.h:400
Ipv6Addr prefix
Definition: ndp.h:415
uint32_t reachableTime
Definition: ndp.h:305
uint32_t retransTimer
Definition: ndp.h:306
uint8_t cid
Definition: ndp.h:511
MacAddr linkLayerAddr
Definition: ndp.h:388
uint8_t code
Definition: ndp.h:272
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
void ndpProcessRedirect(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, uint8_t hopLimit)
Redirect message processing.
Definition: ndp.c:1175
__start_packed struct @201 NdpNeighborSolMessage
Neighbor Solicitation message.
error_t ndpSendNeighborSol(NetInterface *interface, const Ipv6Addr *targetIpAddr, bool_t multicast)
Send a Neighbor Solicitation message.
Definition: ndp.c:1494
void ndpProcessRouterAdv(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, uint8_t hopLimit)
Router Advertisement message processing.
Definition: ndp.c:412
uint8_t contextLength
Definition: ndp.h:505
void ndpLinkChangeEvent(NetInterface *interface)
Callback function for link change event.
Definition: ndp.c:375
Ipv6Addr destAddr
Definition: ndp.h:363
uint8_t length
Definition: ndp.h:375
void ndpProcessNeighborAdv(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, uint8_t hopLimit)
Neighbor Advertisement message processing.
Definition: ndp.c:928
__start_packed struct @200 NdpRouterAdvMessage
Router Advertisement message.
systime_t ndpTickCounter
Definition: ndp.c:60
__start_packed struct @204 NdpOption
Neighbor Discovery option general format.
uint8_t prf
Definition: ndp.h:299
__start_packed struct @211 NdpDnsslOption
DNS Search List option (DNSSL)
Ipv6Addr contextPrefix
Definition: ndp.h:517
uint8_t value[]
Definition: ndp.h:376
void ndpTick(NetInterface *interface)
NDP timer handler.
Definition: ndp.c:285
#define NDP_NEIGHBOR_CACHE_SIZE
Definition: ndp.h:53
__start_packed struct @203 NdpRedirectMessage
Redirect message.
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
__start_packed struct @210 NdpRdnssOption
Recursive DNS Server option (RDNSS)
uint8_t a
Definition: ndp.h:409
error_t ndpResolve(NetInterface *interface, const Ipv6Addr *ipAddr, MacAddr *macAddr)
Address resolution using Neighbor Discovery protocol.
Definition: ndp.c:101
__start_packed struct @199 NdpRouterSolMessage
Router Solicitation message.
TCP/IP stack core.
#define NetInterface
Definition: net.h:36
#define NetTxAncillary
Definition: net_misc.h:36
NDP context.
Definition: ndp.h:576
systime_t timestamp
Timestamp to manage retransmissions.
Definition: ndp.h:586
uint_t rtrSolicitationCount
Retransmission counter for RS messages.
Definition: ndp.h:584
uint_t dupAddrDetectTransmits
Maximum number of NS messages sent while performing DAD.
Definition: ndp.h:579
systime_t minRtrSolicitationDelay
Minimum delay before transmitting the first RS message.
Definition: ndp.h:580
uint32_t reachableTime
The time a node assumes a neighbor is reachable.
Definition: ndp.h:577
uint32_t retransTimer
The time between retransmissions of NS messages.
Definition: ndp.h:578
systime_t maxRtrSolicitationDelay
Maximum delay before transmitting the first RS message.
Definition: ndp.h:581
bool_t rtrAdvReceived
Valid RA message received.
Definition: ndp.h:585
systime_t timeout
Timeout value.
Definition: ndp.h:587
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
Destination cache entry.
Definition: ndp.h:563
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
Ipv6Addr destAddr
Destination IPv6 address.
Definition: ndp.h:564
Neighbor cache entry.
Definition: ndp.h:545
systime_t timestamp
Timestamp to manage entry lifetime.
Definition: ndp.h:550
Ipv6Addr ipAddr
Unicast IPv6 address.
Definition: ndp.h:547
bool_t isRouter
A flag indicating whether the neighbor is a router or a host.
Definition: ndp.h:549
MacAddr macAddr
Link layer address associated with the IPv6 address.
Definition: ndp.h:548
NdpState state
Reachability state.
Definition: ndp.h:546
uint_t retransmitCount
Retransmission counter.
Definition: ndp.h:552
uint_t queueSize
Number of queued packets.
Definition: ndp.h:554
systime_t timeout
Timeout value.
Definition: ndp.h:551
NDP queue item.
Definition: ndp.h:532
NetInterface * srcInterface
Interface from which the packet has been received.
Definition: ndp.h:533
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
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:89