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