ipv6.h
Go to the documentation of this file.
1 /**
2  * @file ipv6.h
3  * @brief IPv6 (Internet Protocol Version 6)
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.4
29  **/
30 
31 #ifndef _IPV6_H
32 #define _IPV6_H
33 
34 //Forward declaration of structures
35 struct _Ipv6Header;
36 #define Ipv6Header struct _Ipv6Header
37 
38 struct _Ipv6FragmentHeader;
39 #define Ipv6FragmentHeader struct _Ipv6FragmentHeader
40 
41 struct _Ipv6PseudoHeader;
42 #define Ipv6PseudoHeader struct _Ipv6PseudoHeader
43 
44 //Dependencies
45 #include "core/net.h"
46 #include "core/ethernet.h"
47 #include "ipv6/ipv6_frag.h"
48 
49 //IPv6 support
50 #ifndef IPV6_SUPPORT
51  #define IPV6_SUPPORT DISABLED
52 #elif (IPV6_SUPPORT != ENABLED && IPV6_SUPPORT != DISABLED)
53  #error IPV6_SUPPORT parameter is not valid
54 #endif
55 
56 //Default IPv6 Hop Limit field
57 #ifndef IPV6_DEFAULT_HOP_LIMIT
58  #define IPV6_DEFAULT_HOP_LIMIT 64
59 #elif (IPV6_DEFAULT_HOP_LIMIT < 1)
60  #error IPV6_DEFAULT_HOP_LIMIT parameter is not valid
61 #endif
62 
63 //Maximum number of IPv6 unicast addresses
64 #ifndef IPV6_ADDR_LIST_SIZE
65  #define IPV6_ADDR_LIST_SIZE 3
66 #elif (IPV6_ADDR_LIST_SIZE < 2)
67  #error IPV6_ADDR_LIST_SIZE parameter is not valid
68 #endif
69 
70 //Maximum number of IPv6 anycast addresses
71 #ifndef IPV6_ANYCAST_ADDR_LIST_SIZE
72  #define IPV6_ANYCAST_ADDR_LIST_SIZE 1
73 #elif (IPV6_ANYCAST_ADDR_LIST_SIZE < 1)
74  #error IPV6_ANYCAST_ADDR_LIST_SIZE parameter is not valid
75 #endif
76 
77 //Size of the prefix list
78 #ifndef IPV6_PREFIX_LIST_SIZE
79  #define IPV6_PREFIX_LIST_SIZE 2
80 #elif (IPV6_PREFIX_LIST_SIZE < 1)
81  #error IPV6_PREFIX_LIST_SIZE parameter is not valid
82 #endif
83 
84 //Maximum number number of default routers
85 #ifndef IPV6_ROUTER_LIST_SIZE
86  #define IPV6_ROUTER_LIST_SIZE 2
87 #elif (IPV6_ROUTER_LIST_SIZE < 1)
88  #error IPV6_ROUTER_LIST_SIZE parameter is not valid
89 #endif
90 
91 //Maximum number of DNS servers
92 #ifndef IPV6_DNS_SERVER_LIST_SIZE
93  #define IPV6_DNS_SERVER_LIST_SIZE 2
94 #elif (IPV6_DNS_SERVER_LIST_SIZE < 1)
95  #error IPV6_DNS_SERVER_LIST_SIZE parameter is not valid
96 #endif
97 
98 //Size of the IPv6 multicast filter
99 #ifndef IPV6_MULTICAST_FILTER_SIZE
100  #define IPV6_MULTICAST_FILTER_SIZE 8
101 #elif (IPV6_MULTICAST_FILTER_SIZE < 1)
102  #error IPV6_MULTICAST_FILTER_SIZE parameter is not valid
103 #endif
104 
105 //Maximum number of multicast sources
106 #ifndef IPV6_MAX_MULTICAST_SOURCES
107  #define IPV6_MAX_MULTICAST_SOURCES 0
108 #elif (IPV6_MAX_MULTICAST_SOURCES < 0)
109  #error IPV6_MAX_MULTICAST_SOURCES parameter is not valid
110 #endif
111 
112 //Version number for IPv6
113 #define IPV6_VERSION 6
114 //Minimum MTU that routers and physical links are required to handle
115 #define IPV6_DEFAULT_MTU 1280
116 
117 //Macro used for defining an IPv6 address
118 #define IPV6_ADDR(a, b, c, d, e, f, g, h) {{{ \
119  MSB(a), LSB(a), MSB(b), LSB(b), MSB(c), LSB(c), MSB(d), LSB(d), \
120  MSB(e), LSB(e), MSB(f), LSB(f), MSB(g), LSB(g), MSB(h), LSB(h)}}}
121 
122 //Copy IPv6 address
123 #define ipv6CopyAddr(destIpAddr, srcIpAddr) \
124  osMemcpy(destIpAddr, srcIpAddr, sizeof(Ipv6Addr))
125 
126 //Compare IPv6 addresses
127 #define ipv6CompAddr(ipAddr1, ipAddr2) \
128  (!osMemcmp(ipAddr1, ipAddr2, sizeof(Ipv6Addr)))
129 
130 //Determine whether an IPv6 address is a link-local unicast address
131 #define ipv6IsLinkLocalUnicastAddr(ipAddr) \
132  ((ipAddr)->b[0] == 0xFE && ((ipAddr)->b[1] & 0xC0) == 0x80)
133 
134 //Determine whether an IPv6 address is a site-local unicast address
135 #define ipv6IsSiteLocalUnicastAddr(ipAddr) \
136  ((ipAddr)->b[0] == 0xFE && ((ipAddr)->b[1] & 0xC0) == 0xC0)
137 
138 //Determine whether an IPv6 address is a multicast address
139 #define ipv6IsMulticastAddr(ipAddr) \
140  ((ipAddr)->b[0] == 0xFF)
141 
142 //Determine whether an IPv6 address is a solicited-node address
143 #define ipv6IsSolicitedNodeAddr(ipAddr) \
144  ipv6CompPrefix(ipAddr, &IPV6_SOLICITED_NODE_ADDR_PREFIX, 104)
145 
146 //C++ guard
147 #ifdef __cplusplus
148 extern "C" {
149 #endif
150 
151 
152 /**
153  * @brief IPv6 address scopes
154  **/
155 
156 typedef enum
157 {
165 
166 
167 /**
168  * @brief IPv6 address state
169  **/
170 
171 typedef enum
172 {
173  IPV6_ADDR_STATE_INVALID = 0, ///<An address that is not assigned to any interface
174  IPV6_ADDR_STATE_TENTATIVE = 1, ///<An address whose uniqueness on a link is being verified
175  IPV6_ADDR_STATE_PREFERRED = 2, ///<An address assigned to an interface whose use is unrestricted
176  IPV6_ADDR_STATE_DEPRECATED = 3 ///<An address assigned to an interface whose use is discouraged
178 
179 
180 /**
181  * @brief IPv6 Next Header types
182  **/
183 
184 typedef enum
185 {
197 
198 
199 /**
200  * @brief IPv6 fragment offset field
201  **/
202 
203 typedef enum
204 {
206  IPV6_FLAG_RES1 = 0x0004,
207  IPV6_FLAG_RES2 = 0x0002,
208  IPV6_FLAG_M = 0x0001
210 
211 
212 /**
213  * @brief IPv6 option types
214  **/
215 
216 typedef enum
217 {
224 
225 
226 /**
227  * @brief Actions to be taken for unrecognized options
228  **/
229 
230 typedef enum
231 {
238 
239 
240 //CC-RX, CodeWarrior or Win32 compiler?
241 #if defined(__CCRX__)
242  #pragma pack
243 #elif defined(__CWCC__) || defined(_WIN32)
244  #pragma pack(push, 1)
245 #endif
246 
247 
248 /**
249  * @brief IPv6 network address
250  **/
251 
253 {
254  __packed_union
255  {
256  uint8_t b[16];
257  uint16_t w[8];
258  uint32_t dw[4];
259  };
261 
262 
263 /**
264  * @brief IPv6 header
265  **/
266 
268 {
269 #if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
270  uint8_t version : 4; //0
271  uint8_t trafficClassH : 4;
272  uint8_t trafficClassL : 4; //1
273  uint8_t flowLabelH : 4;
274 #else
275  uint8_t trafficClassH : 4; //0
276  uint8_t version : 4;
277  uint8_t flowLabelH : 4; //1
278  uint8_t trafficClassL : 4;
279 #endif
280  uint16_t flowLabelL; //2-3
281  uint16_t payloadLen; //4-5
282  uint8_t nextHeader; //6
283  uint8_t hopLimit; //7
286  uint8_t payload[]; //40
287 };
288 
289 
290 /**
291  * @brief IPv6 Hop-by-Hop Options header
292  **/
293 
294 typedef __packed_struct
295 {
296  uint8_t nextHeader; //0
297  uint8_t hdrExtLen; //1
298  uint8_t options[]; //2
300 
301 
302 /**
303  * @brief IPv6 Destination Options header
304  **/
305 
306 typedef __packed_struct
307 {
308  uint8_t nextHeader; //0
309  uint8_t hdrExtLen; //1
310  uint8_t options[]; //2
312 
313 
314 /**
315  * @brief IPv6 Type 0 Routing header
316  **/
317 
318 typedef __packed_struct
319 {
320  uint8_t nextHeader; //0
321  uint8_t hdrExtLen; //1
322  uint8_t routingType; //2
323  uint8_t segmentsLeft; //3
324  uint32_t reserved; //4-7
327 
328 
329 /**
330  * @brief IPv6 Fragment header
331  **/
332 
334 {
335  uint8_t nextHeader; //0
336  uint8_t reserved; //1
337  uint16_t fragmentOffset; //2-3
338  uint32_t identification; //4-7
339 };
340 
341 
342 /**
343  * @brief IPv6 Authentication header
344  **/
345 
346 typedef __packed_struct
347 {
348  uint8_t nextHeader; //0
349  uint8_t payloadLen; //1
350  uint16_t reserved; //2-3
351  uint32_t securityParamIndex; //4-7
352  uint32_t sequenceNumber; //8-11
353  uint8_t authData[]; //12
355 
356 
357 /**
358  * @brief IPv6 Encapsulating Security Payload header
359  **/
360 
361 typedef __packed_struct
362 {
363  uint32_t securityParamIndex; //0-3
364  uint32_t sequenceNumber; //4-7
365  uint8_t payloadData[]; //8
367 
368 
369 /**
370  * @brief IPv6 option
371  **/
372 
373 typedef __packed_struct
374 {
375  uint8_t type; //0
376  uint8_t length; //1
377  uint8_t data[]; //2
379 
380 
381 /**
382  * @brief IPv6 Router Alert option
383  **/
384 
385 typedef __packed_struct
386 {
387  uint8_t type; //0
388  uint8_t length; //1
389  uint16_t value; //2-3
391 
392 
393 /**
394  * @brief IPv6 pseudo header
395  **/
396 
398 {
399  Ipv6Addr srcAddr; //0-15
400  Ipv6Addr destAddr; //16-31
401  uint32_t length; //32-35
402  uint8_t reserved[3]; //36-38
403  uint8_t nextHeader; //39
404 };
405 
406 
407 //CC-RX, CodeWarrior or Win32 compiler?
408 #if defined(__CCRX__)
409  #pragma unpack
410 #elif defined(__CWCC__) || defined(_WIN32)
411  #pragma pack(pop)
412 #endif
413 
414 
415 /**
416  * @brief IPv6 address entry
417  **/
418 
419 typedef struct
420 {
421  Ipv6Addr addr; ///<IPv6 address
422  Ipv6AddrState state; ///<IPv6 address state
423  bool_t duplicate; ///<The address is a duplicate
424  systime_t validLifetime; ///<Valid lifetime
425  systime_t preferredLifetime; ///<Preferred lifetime
426  bool_t permanent; ///<Permanently assigned address
427  systime_t timestamp; ///<Timestamp to manage entry lifetime
428  systime_t dadTimeout; ///<Timeout value for Duplicate Address Detection
429  uint_t dadRetransmitCount; ///<Retransmission counter for Duplicate Address Detection
430 } Ipv6AddrEntry;
431 
432 
433 /**
434  * @brief Prefix list entry
435  **/
436 
437 typedef struct
438 {
439  Ipv6Addr prefix; ///<IPv6 prefix information
440  uint8_t prefixLen; ///<IPv6 prefix length
441  bool_t onLinkFlag; ///<On-link flag
442  bool_t autonomousFlag; ///<Autonomous flag
443  systime_t validLifetime; ///<Valid lifetime
444  systime_t preferredLifetime; ///<Preferred lifetime
445  bool_t permanent; ///<Permanently assigned prefix
446  systime_t timestamp; ///<Timestamp to manage entry lifetime
448 
449 
450 /**
451  * @brief Default router list entry
452  **/
453 
454 typedef struct
455 {
456  Ipv6Addr addr; ///<Router address
457  systime_t lifetime; ///<Router lifetime
458  uint8_t preference; ///<Preference value
459  bool_t permanent; ///<Permanently assigned router
460  systime_t timestamp; ///<Timestamp to manage entry lifetime
462 
463 
464 /**
465  * @brief Source address list
466  **/
467 
468 typedef struct
469 {
470  uint_t numSources; ///<Number of source addresses
471 #if (IPV6_MAX_MULTICAST_SOURCES > 0)
472  Ipv6Addr sources[IPV6_MAX_MULTICAST_SOURCES]; ///<Source addresses
473 #endif
475 
476 
477 /**
478  * @brief IPv6 multicast filter entry
479  **/
480 
481 typedef struct
482 {
483  Ipv6Addr addr; ///<Multicast address
484  uint_t anySourceRefCount; ///<Reference count for the current entry
485  bool_t macFilterConfigured; ///<MAC address filter is configured
486  uint_t srcFilterMode; ///<Source filter mode
487  Ipv6SrcAddrList srcFilter; ///<Source filter
489 
490 
491 /**
492  * @brief IPv6 context
493  **/
494 
495 typedef struct
496 {
497  size_t linkMtu; ///<Maximum transmission unit
498  bool_t isRouter; ///<A flag indicating whether routing is enabled on this interface
499  uint8_t defaultHopLimit; ///<Default Hop Limit value
500  uint8_t curHopLimit; ///<Current Hop Limit value
501  bool_t enableEchoReq; ///<Support for ICMPv6 Echo Request messages
502  bool_t enableMulticastEchoReq; ///<Support for multicast ICMPv6 Echo Request messages
503  Ipv6AddrEntry addrList[IPV6_ADDR_LIST_SIZE]; ///<IPv6 unicast address list
504  Ipv6Addr anycastAddrList[IPV6_ANYCAST_ADDR_LIST_SIZE]; ///<IPv6 anycast address list
505  Ipv6PrefixEntry prefixList[IPV6_PREFIX_LIST_SIZE]; ///<Prefix list
506  Ipv6RouterEntry routerList[IPV6_ROUTER_LIST_SIZE]; ///<Default router list
507  Ipv6Addr dnsServerList[IPV6_DNS_SERVER_LIST_SIZE]; ///<DNS servers
508  Ipv6FilterEntry multicastFilter[IPV6_MULTICAST_FILTER_SIZE]; ///<Multicast filter table
509 #if (IPV6_FRAG_SUPPORT == ENABLED)
510  uint32_t identification; ///<IPv6 fragment identification field
511  Ipv6FragDesc fragQueue[IPV6_MAX_FRAG_DATAGRAMS]; ///<IPv6 fragment reassembly queue
512 #endif
513 } Ipv6Context;
514 
515 
516 //IPv6 related constants
517 extern const Ipv6Addr IPV6_UNSPECIFIED_ADDR;
518 extern const Ipv6Addr IPV6_LOOPBACK_ADDR;
523 
524 //IPv6 related functions
525 error_t ipv6Init(NetInterface *interface);
526 
527 error_t ipv6SetMtu(NetInterface *interface, size_t mtu);
528 error_t ipv6GetMtu(NetInterface *interface, size_t *mtu);
529 
531 
535 
536 error_t ipv6SetGlobalAddr(NetInterface *interface, uint_t index,
537  const Ipv6Addr *addr);
538 
539 error_t ipv6GetGlobalAddr(NetInterface *interface, uint_t index,
540  Ipv6Addr *addr);
541 
543 
545  const Ipv6Addr *addr);
546 
548  Ipv6Addr *addr);
549 
550 error_t ipv6SetPrefix(NetInterface *interface, uint_t index,
551  const Ipv6Addr *prefix, uint_t length);
552 
554  uint_t *length);
555 
557  const Ipv6Addr *addr);
558 
560  Ipv6Addr *addr);
561 
562 error_t ipv6SetDnsServer(NetInterface *interface, uint_t index,
563  const Ipv6Addr *addr);
564 
566 
567 void ipv6LinkChangeEvent(NetInterface *interface);
568 
570  size_t ipPacketOffset, NetRxAncillary *ancillary);
571 
573  const NetBuffer *ipPacket, size_t ipPacketOffset, size_t *headerOffset,
574  size_t *nextHeaderOffset);
575 
577  const NetBuffer *ipPacket, size_t ipPacketOffset, size_t *headerOffset,
578  size_t *nextHeaderOffset);
579 
581  const NetBuffer *ipPacket, size_t ipPacketOffset, size_t *headerOffset,
582  size_t *nextHeaderOffset);
583 
585  size_t ipPacketOffset, size_t *headerOffset, size_t *nextHeaderOffset);
586 
588  size_t ipPacketOffset, size_t *headerOffset, size_t *nextHeaderOffset);
589 
591  size_t ipPacketOffset, size_t optionOffset, size_t optionLen);
592 
594  const Ipv6PseudoHeader *pseudoHeader, NetBuffer *buffer, size_t offset,
595  NetTxAncillary *ancillary);
596 
598  const Ipv6PseudoHeader *pseudoHeader, uint32_t fragId, size_t fragOffset,
599  NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary);
600 
602  size_t *offset);
603 
604 error_t ipv6FormatFragmentHeader(uint32_t fragId, size_t fragOffset,
605  uint8_t *nextHeader, NetBuffer *buffer, size_t *offset);
606 
609 
610 void ipv6DumpHeader(const Ipv6Header *ipHeader);
611 
612 //C++ guard
613 #ifdef __cplusplus
614 }
615 #endif
616 
617 #endif
@ IPV6_ADDR_STATE_TENTATIVE
An address whose uniqueness on a link is being verified.
Definition: ipv6.h:174
systime_t timestamp
Timestamp to manage entry lifetime.
Definition: ipv6.h:460
error_t ipv6GetPrefix(NetInterface *interface, uint_t index, Ipv6Addr *prefix, uint_t *length)
Retrieve IPv6 prefix.
Definition: ipv6.c:652
@ IPV6_ESP_HEADER
Definition: ipv6.h:191
bool_t enableMulticastEchoReq
Support for multicast ICMPv6 Echo Request messages.
Definition: ipv6.h:502
systime_t lifetime
Router lifetime.
Definition: ipv6.h:457
error_t ipv6SetGlobalAddr(NetInterface *interface, uint_t index, const Ipv6Addr *addr)
Assign global address.
Definition: ipv6.c:354
int bool_t
Definition: compiler_port.h:53
uint8_t b
Definition: nbns_common.h:104
error_t ipv6GetGlobalAddr(NetInterface *interface, uint_t index, Ipv6Addr *addr)
Retrieve global address.
Definition: ipv6.c:394
Source address list.
Definition: ipv6.h:469
uint32_t identification
IPv6 fragment identification field.
Definition: ipv6.h:510
uint8_t routingType
Definition: ipv6.h:322
error_t ipv6ParseOptions(NetInterface *interface, const NetBuffer *ipPacket, size_t ipPacketOffset, size_t optionOffset, size_t optionLen)
Parse IPv6 options.
Definition: ipv6.c:1577
Ipv6Option
Definition: ipv6.h:378
@ IPV6_ADDR_SCOPE_INTERFACE_LOCAL
Definition: ipv6.h:158
const Ipv6Addr IPV6_UNSPECIFIED_ADDR
Definition: ipv6.c:66
uint8_t curHopLimit
Current Hop Limit value.
Definition: ipv6.h:500
systime_t preferredLifetime
Preferred lifetime.
Definition: ipv6.h:444
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:89
uint_t dadRetransmitCount
Retransmission counter for Duplicate Address Detection.
Definition: ipv6.h:429
Ipv6NextHeaderType
IPv6 Next Header types.
Definition: ipv6.h:185
@ IPV6_FLAG_RES1
Definition: ipv6.h:206
Ipv6AuthHeader
Definition: ipv6.h:354
error_t ipv6SetAnycastAddr(NetInterface *interface, uint_t index, const Ipv6Addr *addr)
Assign anycast address.
Definition: ipv6.c:473
Ipv6Addr addr
IPv6 address.
Definition: ipv6.h:421
systime_t preferredLifetime
Preferred lifetime.
Definition: ipv6.h:425
#define Ipv6Header
Definition: ipv6.h:36
systime_t timestamp
Timestamp to manage entry lifetime.
Definition: ipv6.h:446
Ipv6Addr
Definition: ipv6.h:260
error_t ipv6FormatHopByHopOptHeader(uint8_t *nextHeader, NetBuffer *buffer, size_t *offset)
Format Hop-by-Hop Options header.
Definition: ipv6.c:2063
bool_t autonomousFlag
Autonomous flag.
Definition: ipv6.h:442
uint8_t defaultHopLimit
Default Hop Limit value.
Definition: ipv6.h:499
uint8_t type
Definition: coap_common.h:176
systime_t validLifetime
Valid lifetime.
Definition: ipv6.h:443
@ IPV6_FLAG_RES2
Definition: ipv6.h:207
uint32_t securityParamIndex
Definition: ipv6.h:351
@ IPV6_OPTION_TYPE_PAD1
Definition: ipv6.h:219
error_t ipv6SetDefaultHopLimit(NetInterface *interface, uint8_t hopLimit)
Set default Hop Limit value for outgoing IPv6 packets.
Definition: ipv6.c:220
Ipv6DestOptHeader
Definition: ipv6.h:311
@ IPV6_ICMPV6_HEADER
Definition: ipv6.h:193
__packed_struct _Ipv6PseudoHeader
IPv6 pseudo header.
Definition: ipv6.h:398
Ipv6Addr prefix
IPv6 prefix information.
Definition: ipv6.h:439
char_t * ipv6AddrToString(const Ipv6Addr *ipAddr, char_t *str)
Convert a binary IPv6 address to a string representation.
Definition: ipv6.c:2329
@ IPV6_ACTION_SEND_ICMP_ERROR_ALL
Definition: ipv6.h:235
@ IPV6_ACTION_DISCARD_PACKET
Definition: ipv6.h:234
Ipv6Addr addr
Router address.
Definition: ipv6.h:456
Ipv6Addr prefix
error_t ipv6GetLinkLocalAddr(NetInterface *interface, Ipv6Addr *addr)
Retrieve link-local address.
Definition: ipv6.c:286
uint8_t version
Definition: ipv6.h:276
error_t ipv6ParseAhHeader(NetInterface *interface, const NetBuffer *ipPacket, size_t ipPacketOffset, size_t *headerOffset, size_t *nextHeaderOffset)
Parse AH header.
Definition: ipv6.c:1535
IPv6 context.
Definition: ipv6.h:496
__packed_struct _Ipv6FragmentHeader
IPv6 Fragment header.
Definition: ipv6.h:334
@ IPV6_ADDR_STATE_INVALID
An address that is not assigned to any interface.
Definition: ipv6.h:173
void ipv6DumpHeader(const Ipv6Header *ipHeader)
Dump IPv6 header for debugging purpose.
Definition: ipv6.c:2400
Ethernet.
@ IPV6_OFFSET_MASK
Definition: ipv6.h:205
uint16_t flowLabelL
Definition: ipv6.h:280
uint8_t ipPacket[]
Definition: ndp.h:431
Ipv6AddrScope
IPv6 address scopes.
Definition: ipv6.h:157
@ IPV6_ADDR_SCOPE_ADMIN_LOCAL
Definition: ipv6.h:160
error_t ipv6ParseDestOptHeader(NetInterface *interface, const NetBuffer *ipPacket, size_t ipPacketOffset, size_t *headerOffset, size_t *nextHeaderOffset)
Parse Destination Options header.
Definition: ipv6.c:1399
Ipv6AddrState
IPv6 address state.
Definition: ipv6.h:172
Ipv6FragmentOffset
IPv6 fragment offset field.
Definition: ipv6.h:204
error_t
Error codes.
Definition: error.h:43
error_t ipv6FormatFragmentHeader(uint32_t fragId, size_t fragOffset, uint8_t *nextHeader, NetBuffer *buffer, size_t *offset)
Format Fragment header.
Definition: ipv6.c:2130
#define Ipv6PseudoHeader
Definition: ipv6.h:42
@ IPV6_ACTION_SKIP_OPTION
Definition: ipv6.h:233
systime_t dadTimeout
Timeout value for Duplicate Address Detection.
Definition: ipv6.h:428
Prefix list entry.
Definition: ipv6.h:438
Ipv6Addr srcAddr
Definition: ipv6.h:284
uint8_t payloadData[]
Definition: ipv6.h:365
@ IPV6_UDP_HEADER
Definition: ipv6.h:188
uint8_t hdrExtLen
Definition: ipv6.h:297
uint8_t preference
Preference value.
Definition: ipv6.h:458
error_t ipv6SetDefaultRouter(NetInterface *interface, uint_t index, const Ipv6Addr *addr)
Configure default router.
Definition: ipv6.c:707
bool_t permanent
Permanently assigned address.
Definition: ipv6.h:426
#define IPV6_MAX_MULTICAST_SOURCES
Definition: ipv6.h:107
uint_t numSources
Number of source addresses.
Definition: ipv6.h:470
#define NetRxAncillary
Definition: net_misc.h:40
#define NetInterface
Definition: net.h:36
void ipv6LinkChangeEvent(NetInterface *interface)
Callback function for link change event.
Definition: ipv6.c:884
error_t ipv6Init(NetInterface *interface)
IPv6 related initialization.
Definition: ipv6.c:96
uint8_t nextHeader
Definition: ipv6.h:282
uint8_t trafficClassL
Definition: ipv6.h:278
@ IPV6_ADDR_SCOPE_GLOBAL
Definition: ipv6.h:163
@ IPV6_HOP_BY_HOP_OPT_HEADER
Definition: ipv6.h:186
const Ipv6Addr IPV6_LINK_LOCAL_ADDR_PREFIX
Definition: ipv6.c:82
#define NetTxAncillary
Definition: net_misc.h:36
Ipv6SrcAddrList srcFilter
Source filter.
Definition: ipv6.h:487
#define IPV6_MULTICAST_FILTER_SIZE
Definition: ipv6.h:100
error_t ipv6ParseRoutingHeader(NetInterface *interface, const NetBuffer *ipPacket, size_t ipPacketOffset, size_t *headerOffset, size_t *nextHeaderOffset)
Parse Routing header.
Definition: ipv6.c:1463
uint8_t fragOffset[3]
Definition: dtls_misc.h:192
Fragmented packet descriptor.
Definition: ipv6_frag.h:135
#define IPV6_DNS_SERVER_LIST_SIZE
Definition: ipv6.h:93
bool_t duplicate
The address is a duplicate.
Definition: ipv6.h:423
@ IPV6_ADDR_SCOPE_LINK_LOCAL
Definition: ipv6.h:159
@ IPV6_OPTION_TYPE_ROUTER_ALERT
Definition: ipv6.h:222
error_t ipv6GetDefaultRouter(NetInterface *interface, uint_t index, Ipv6Addr *addr)
Retrieve default router.
Definition: ipv6.c:765
uint8_t hopLimit
Definition: ipv6.h:283
uint32_t mtu
Definition: icmpv6.h:175
const Ipv6Addr IPV6_LINK_LOCAL_ALL_NODES_ADDR
Definition: ipv6.c:74
Ipv6Addr addr
Multicast address.
Definition: ipv6.h:483
uint8_t flowLabelH
Definition: ipv6.h:277
bool_t onLinkFlag
On-link flag.
Definition: ipv6.h:441
uint32_t systime_t
System time.
error_t ipv6SetDnsServer(NetInterface *interface, uint_t index, const Ipv6Addr *addr)
Configure DNS server.
Definition: ipv6.c:817
IPv6 fragmentation and reassembly.
bool_t permanent
Permanently assigned prefix.
Definition: ipv6.h:445
Ipv6AddrState ipv6GetGlobalAddrState(NetInterface *interface, uint_t index)
Get the state of the specified global address.
Definition: ipv6.c:446
error_t ipv6SetPrefix(NetInterface *interface, uint_t index, const Ipv6Addr *prefix, uint_t length)
Configure IPv6 prefix.
Definition: ipv6.c:588
error_t ipv6ParseEspHeader(NetInterface *interface, const NetBuffer *ipPacket, size_t ipPacketOffset, size_t *headerOffset, size_t *nextHeaderOffset)
Parse ESP header.
Definition: ipv6.c:1556
char char_t
Definition: compiler_port.h:48
Ipv6RouterAlertOption
Definition: ipv6.h:390
uint8_t prefixLen
IPv6 prefix length.
Definition: ipv6.h:440
@ PV6_OPTION_TUNNEL_ENCAPSULATION_LIMIT
Definition: ipv6.h:221
const Ipv6Addr IPV6_LOOPBACK_ADDR
Definition: ipv6.c:70
error_t ipv6SetLinkLocalAddr(NetInterface *interface, const Ipv6Addr *addr)
Assign link-local address.
Definition: ipv6.c:248
#define IPV6_ANYCAST_ADDR_LIST_SIZE
Definition: ipv6.h:72
Ipv6OptionType
IPv6 option types.
Definition: ipv6.h:217
Default router list entry.
Definition: ipv6.h:455
IPv6 address entry.
Definition: ipv6.h:420
uint8_t data[]
Definition: ipv6.h:377
bool_t macFilterConfigured
MAC address filter is configured.
Definition: ipv6.h:485
typedef __packed_struct
IPv6 network address.
Definition: ipv6.h:253
@ IPV6_TCP_HEADER
Definition: ipv6.h:187
uint16_t value
Definition: ipv6.h:389
#define IPV6_ROUTER_LIST_SIZE
Definition: ipv6.h:86
#define IPV6_ADDR_LIST_SIZE
Definition: ipv6.h:65
uint8_t payload[]
Definition: ipv6.h:286
Ipv6Addr address[]
Definition: ipv6.h:325
@ IPV6_NO_NEXT_HEADER
Definition: ipv6.h:194
uint8_t authData[]
Definition: ipv6.h:353
@ IPV6_OPTION_TYPE_MASK
Definition: ipv6.h:218
uint32_t reserved
Definition: ipv6.h:324
@ IPV6_ADDR_SCOPE_ORGANIZATION_LOCAL
Definition: ipv6.h:162
error_t ipv6GetAnycastAddr(NetInterface *interface, uint_t index, Ipv6Addr *addr)
Retrieve anycast address.
Definition: ipv6.c:552
error_t ipv6ParseHopByHopOptHeader(NetInterface *interface, const NetBuffer *ipPacket, size_t ipPacketOffset, size_t *headerOffset, size_t *nextHeaderOffset)
Parse Hop-by-Hop Options header.
Definition: ipv6.c:1320
uint8_t length
Definition: ipv6.h:376
@ IPV6_FLAG_M
Definition: ipv6.h:208
uint32_t sequenceNumber
Definition: ipv6.h:352
uint_t srcFilterMode
Source filter mode.
Definition: ipv6.h:486
systime_t validLifetime
Valid lifetime.
Definition: ipv6.h:424
void ipv6ProcessPacket(NetInterface *interface, NetBuffer *ipPacket, size_t ipPacketOffset, NetRxAncillary *ancillary)
Incoming IPv6 packet processing.
Definition: ipv6.c:976
@ IPV6_ADDR_SCOPE_SITE_LOCAL
Definition: ipv6.h:161
uint32_t identification
Definition: ipv6.h:338
Ipv4Addr ipAddr
Definition: ipcp.h:105
__packed_struct _Ipv6Header
IPv6 header.
Definition: ipv6.h:268
uint16_t fragmentOffset
Definition: ipv6.h:337
Ipv4Addr addr
Definition: nbns_common.h:123
bool_t isRouter
A flag indicating whether routing is enabled on this interface.
Definition: ipv6.h:498
uint16_t payloadLen
Definition: ipv6.h:281
@ IPV6_OPTION_TYPE_PADN
Definition: ipv6.h:220
@ IPV6_ADDR_STATE_PREFERRED
An address assigned to an interface whose use is unrestricted.
Definition: ipv6.h:175
bool_t permanent
Permanently assigned router.
Definition: ipv6.h:459
uint8_t segmentsLeft
Definition: ipv6.h:323
Ipv6AddrState state
IPv6 address state.
Definition: ipv6.h:422
Ipv6RoutingHeader
Definition: ipv6.h:326
error_t ipv6SendPacket(NetInterface *interface, const Ipv6PseudoHeader *pseudoHeader, uint32_t fragId, size_t fragOffset, NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send an IPv6 packet.
Definition: ipv6.c:1781
#define IPV6_PREFIX_LIST_SIZE
Definition: ipv6.h:79
unsigned int uint_t
Definition: compiler_port.h:50
#define IPV6_MAX_FRAG_DATAGRAMS
Definition: ipv6_frag.h:62
TCP/IP stack core.
error_t ipv6SetMtu(NetInterface *interface, size_t mtu)
Change the MTU of a network interface.
Definition: ipv6.c:150
@ IPV6_ROUTING_HEADER
Definition: ipv6.h:189
@ IPV6_ADDR_STATE_DEPRECATED
An address assigned to an interface whose use is discouraged.
Definition: ipv6.h:176
const Ipv6Addr IPV6_SOLICITED_NODE_ADDR_PREFIX
Definition: ipv6.c:86
error_t ipv6GetDnsServer(NetInterface *interface, uint_t index, Ipv6Addr *addr)
Retrieve DNS server.
Definition: ipv6.c:852
uint_t anySourceRefCount
Reference count for the current entry.
Definition: ipv6.h:484
const Ipv6Addr IPV6_LINK_LOCAL_ALL_ROUTERS_ADDR
Definition: ipv6.c:78
error_t ipv6SendDatagram(NetInterface *interface, const Ipv6PseudoHeader *pseudoHeader, NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send an IPv6 datagram.
Definition: ipv6.c:1703
error_t ipv6GetMtu(NetInterface *interface, size_t *mtu)
Retrieve the MTU for the specified interface.
Definition: ipv6.c:195
Ipv6EspHeader
Definition: ipv6.h:366
size_t linkMtu
Maximum transmission unit.
Definition: ipv6.h:497
Ipv6Addr destAddr
Definition: ipv6.h:285
@ IPV6_DEST_OPT_HEADER
Definition: ipv6.h:195
Ipv6Actions
Actions to be taken for unrecognized options.
Definition: ipv6.h:231
Ipv6AddrState ipv6GetLinkLocalAddrState(NetInterface *interface)
Get the state of the link-local address.
Definition: ipv6.c:327
uint8_t options[]
Definition: ipv6.h:298
@ IPV6_ACTION_SEND_ICMP_ERROR_UNI
Definition: ipv6.h:236
@ IPV6_AH_HEADER
Definition: ipv6.h:192
bool_t enableEchoReq
Support for ICMPv6 Echo Request messages.
Definition: ipv6.h:501
@ IPV6_ACTION_MASK
Definition: ipv6.h:232
@ IPV6_FRAGMENT_HEADER
Definition: ipv6.h:190
error_t ipv6StringToAddr(const char_t *str, Ipv6Addr *ipAddr)
Convert a string representation of an IPv6 address to a binary IPv6 address.
Definition: ipv6.c:2174
systime_t timestamp
Timestamp to manage entry lifetime.
Definition: ipv6.h:427
Ipv6HopByHopOptHeader
Definition: ipv6.h:299
IPv6 multicast filter entry.
Definition: ipv6.h:482