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