36#define Ipv6Header struct _Ipv6Header
39#define Ipv6FragmentHeader struct _Ipv6FragmentHeader
42#define Ipv6PseudoHeader struct _Ipv6PseudoHeader
51 #define IPV6_SUPPORT DISABLED
52#elif (IPV6_SUPPORT != ENABLED && IPV6_SUPPORT != DISABLED)
53 #error IPV6_SUPPORT parameter is not valid
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
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
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
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
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
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
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
106#define IPV6_VERSION 6
108#define IPV6_DEFAULT_MTU 1280
111#define IPV6_ADDR(a, b, c, d, e, f, g, h) {{{ \
112 MSB(a), LSB(a), MSB(b), LSB(b), MSB(c), LSB(c), MSB(d), LSB(d), \
113 MSB(e), LSB(e), MSB(f), LSB(f), MSB(g), LSB(g), MSB(h), LSB(h)}}}
116#define ipv6CopyAddr(destIpAddr, srcIpAddr) \
117 osMemcpy(destIpAddr, srcIpAddr, sizeof(Ipv6Addr))
120#define ipv6CompAddr(ipAddr1, ipAddr2) \
121 (!osMemcmp(ipAddr1, ipAddr2, sizeof(Ipv6Addr)))
124#define ipv6IsLinkLocalUnicastAddr(ipAddr) \
125 ((ipAddr)->b[0] == 0xFE && ((ipAddr)->b[1] & 0xC0) == 0x80)
128#define ipv6IsSiteLocalUnicastAddr(ipAddr) \
129 ((ipAddr)->b[0] == 0xFE && ((ipAddr)->b[1] & 0xC0) == 0xC0)
132#define ipv6IsMulticastAddr(ipAddr) \
133 ((ipAddr)->b[0] == 0xFF)
136#define ipv6IsSolicitedNodeAddr(ipAddr) \
137 ipv6CompPrefix(ipAddr, &IPV6_SOLICITED_NODE_ADDR_PREFIX, 104)
151 IPV6_ADDR_SCOPE_INTERFACE_LOCAL = 1,
152 IPV6_ADDR_SCOPE_LINK_LOCAL = 2,
153 IPV6_ADDR_SCOPE_ADMIN_LOCAL = 4,
154 IPV6_ADDR_SCOPE_SITE_LOCAL = 5,
155 IPV6_ADDR_SCOPE_ORGANIZATION_LOCAL = 8,
156 IPV6_ADDR_SCOPE_GLOBAL = 14
179 IPV6_HOP_BY_HOP_OPT_HEADER = 0,
181 IPV6_UDP_HEADER = 17,
182 IPV6_ROUTING_HEADER = 43,
183 IPV6_FRAGMENT_HEADER = 44,
184 IPV6_ESP_HEADER = 50,
186 IPV6_ICMPV6_HEADER = 58,
187 IPV6_NO_NEXT_HEADER = 59,
188 IPV6_DEST_OPT_HEADER = 60
198 IPV6_OFFSET_MASK = 0xFFF8,
199 IPV6_FLAG_RES1 = 0x0004,
200 IPV6_FLAG_RES2 = 0x0002,
211 IPV6_OPTION_TYPE_MASK = 0x1F,
212 IPV6_OPTION_TYPE_PAD1 = 0x00,
213 IPV6_OPTION_TYPE_PADN = 0x01
223 IPV6_ACTION_MASK = 0xC0,
224 IPV6_ACTION_SKIP_OPTION = 0x00,
225 IPV6_ACTION_DISCARD_PACKET = 0x40,
226 IPV6_ACTION_SEND_ICMP_ERROR_ALL = 0x80,
227 IPV6_ACTION_SEND_ICMP_ERROR_UNI = 0xC0
232#if defined(__CWCC__) || defined(_WIN32)
233 #pragma pack(push, 1)
258#if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
260 uint8_t trafficClassH : 4;
261 uint8_t trafficClassL : 4;
262 uint8_t flowLabelH : 4;
264 uint8_t trafficClassH : 4;
266 uint8_t flowLabelH : 4;
267 uint8_t trafficClassL : 4;
288} Ipv6HopByHopOptHeader;
312 uint8_t segmentsLeft;
326 uint16_t fragmentOffset;
327 uint32_t identification;
340 uint32_t securityParamIndex;
341 uint32_t sequenceNumber;
352 uint32_t securityParamIndex;
353 uint32_t sequenceNumber;
354 uint8_t payloadData[];
385#if defined(__CWCC__) || defined(_WIN32)
466 Ipv6Addr anycastAddrList[IPV6_ANYCAST_ADDR_LIST_SIZE];
469 Ipv6Addr dnsServerList[IPV6_DNS_SERVER_LIST_SIZE];
471#if (IPV6_FRAG_SUPPORT == ENABLED)
479extern const Ipv6Addr IPV6_UNSPECIFIED_ADDR;
480extern const Ipv6Addr IPV6_LOOPBACK_ADDR;
481extern const Ipv6Addr IPV6_LINK_LOCAL_ALL_NODES_ADDR;
482extern const Ipv6Addr IPV6_LINK_LOCAL_ALL_ROUTERS_ADDR;
483extern const Ipv6Addr IPV6_LINK_LOCAL_ADDR_PREFIX;
484extern const Ipv6Addr IPV6_SOLICITED_NODE_ADDR_PREFIX;
487error_t ipv6Init(NetInterface *interface);
489error_t ipv6SetMtu(NetInterface *interface,
size_t mtu);
490error_t ipv6GetMtu(NetInterface *interface,
size_t *mtu);
492error_t ipv6SetDefaultHopLimit(NetInterface *interface, uint8_t hopLimit);
494error_t ipv6SetLinkLocalAddr(NetInterface *interface,
const Ipv6Addr *addr);
495error_t ipv6GetLinkLocalAddr(NetInterface *interface, Ipv6Addr *addr);
496Ipv6AddrState ipv6GetLinkLocalAddrState(NetInterface *interface);
498error_t ipv6SetGlobalAddr(NetInterface *interface, uint_t index,
const Ipv6Addr *addr);
499error_t ipv6GetGlobalAddr(NetInterface *interface, uint_t index, Ipv6Addr *addr);
500Ipv6AddrState ipv6GetGlobalAddrState(NetInterface *interface, uint_t index);
502error_t ipv6SetAnycastAddr(NetInterface *interface, uint_t index,
const Ipv6Addr *addr);
503error_t ipv6GetAnycastAddr(NetInterface *interface, uint_t index, Ipv6Addr *addr);
505error_t ipv6SetPrefix(NetInterface *interface,
506 uint_t index,
const Ipv6Addr *prefix, uint_t length);
508error_t ipv6GetPrefix(NetInterface *interface,
509 uint_t index, Ipv6Addr *prefix, uint_t *length);
511error_t ipv6SetDefaultRouter(NetInterface *interface, uint_t index,
const Ipv6Addr *addr);
512error_t ipv6GetDefaultRouter(NetInterface *interface, uint_t index, Ipv6Addr *addr);
514error_t ipv6SetDnsServer(NetInterface *interface, uint_t index,
const Ipv6Addr *addr);
515error_t ipv6GetDnsServer(NetInterface *interface, uint_t index, Ipv6Addr *addr);
517void ipv6LinkChangeEvent(NetInterface *interface);
519void ipv6ProcessPacket(NetInterface *interface,
NetBuffer *ipPacket,
520 size_t ipPacketOffset, NetRxAncillary *ancillary);
522error_t ipv6ParseHopByHopOptHeader(NetInterface *interface,
const NetBuffer *ipPacket,
523 size_t ipPacketOffset,
size_t *headerOffset,
size_t *nextHeaderOffset);
525error_t ipv6ParseDestOptHeader(NetInterface *interface,
const NetBuffer *ipPacket,
526 size_t ipPacketOffset,
size_t *headerOffset,
size_t *nextHeaderOffset);
528error_t ipv6ParseRoutingHeader(NetInterface *interface,
const NetBuffer *ipPacket,
529 size_t ipPacketOffset,
size_t *headerOffset,
size_t *nextHeaderOffset);
531error_t ipv6ParseAhHeader(NetInterface *interface,
const NetBuffer *ipPacket,
532 size_t ipPacketOffset,
size_t *headerOffset,
size_t *nextHeaderOffset);
534error_t ipv6ParseEspHeader(NetInterface *interface,
const NetBuffer *ipPacket,
535 size_t ipPacketOffset,
size_t *headerOffset,
size_t *nextHeaderOffset);
538 size_t ipPacketOffset,
size_t optionOffset,
size_t optionLen);
540error_t ipv6SendDatagram(NetInterface *interface,
541 const Ipv6PseudoHeader *pseudoHeader,
NetBuffer *buffer,
size_t offset,
542 NetTxAncillary *ancillary);
544error_t ipv6SendPacket(NetInterface *interface,
545 const Ipv6PseudoHeader *pseudoHeader, uint32_t fragId,
size_t fragOffset,
546 NetBuffer *buffer,
size_t offset, NetTxAncillary *ancillary);
548error_t ipv6JoinMulticastGroup(NetInterface *interface,
const Ipv6Addr *groupAddr);
549error_t ipv6LeaveMulticastGroup(NetInterface *interface,
const Ipv6Addr *groupAddr);
551error_t ipv6StringToAddr(
const char_t *str, Ipv6Addr *ipAddr);
552char_t *ipv6AddrToString(
const Ipv6Addr *ipAddr, char_t *str);
554void ipv6DumpHeader(
const Ipv6Header *ipHeader);
error_t
Error codes.
Definition error.h:43
Ipv6NextHeaderType
IPv6 Next Header types.
Definition ipv6.h:178
__packed_struct _Ipv6FragmentHeader
IPv6 Fragment header.
Definition ipv6.h:323
Ipv6AddrScope
IPv6 address scopes.
Definition ipv6.h:150
Ipv6OptionType
IPv6 option types.
Definition ipv6.h:210
Ipv6Actions
Actions to be taken for unrecognized options.
Definition ipv6.h:222
Ipv6FragmentOffset
IPv6 fragment offset field.
Definition ipv6.h:197
__packed_struct _Ipv6Header
IPv6 header.
Definition ipv6.h:257
typedef __packed_struct
IPv6 network address.
Definition ipv6.h:242
Ipv6AddrState
IPv6 address state.
Definition ipv6.h:165
@ IPV6_ADDR_STATE_DEPRECATED
An address assigned to an interface whose use is discouraged.
Definition ipv6.h:169
@ IPV6_ADDR_STATE_PREFERRED
An address assigned to an interface whose use is unrestricted.
Definition ipv6.h:168
@ IPV6_ADDR_STATE_INVALID
An address that is not assigned to any interface.
Definition ipv6.h:166
@ IPV6_ADDR_STATE_TENTATIVE
An address whose uniqueness on a link is being verified.
Definition ipv6.h:167
__packed_struct _Ipv6PseudoHeader
IPv6 pseudo header.
Definition ipv6.h:375
IPv6 fragmentation and reassembly.
uint32_t systime_t
System time.
Definition os_port_none.h:90
IPv6 address entry.
Definition ipv6.h:395
bool_t permanent
Permanently assigned address.
Definition ipv6.h:401
systime_t preferredLifetime
Preferred lifetime.
Definition ipv6.h:400
Ipv6Addr addr
IPv6 address.
Definition ipv6.h:396
systime_t timestamp
Timestamp to manage entry lifetime.
Definition ipv6.h:402
systime_t validLifetime
Valid lifetime.
Definition ipv6.h:399
uint_t dadRetransmitCount
Retransmission counter for Duplicate Address Detection.
Definition ipv6.h:404
systime_t dadTimeout
Timeout value for Duplicate Address Detection.
Definition ipv6.h:403
Ipv6AddrState state
IPv6 address state.
Definition ipv6.h:397
bool_t duplicate
The address is a duplicate.
Definition ipv6.h:398
IPv6 context.
Definition ipv6.h:458
bool_t isRouter
A flag indicating whether routing is enabled on this interface.
Definition ipv6.h:460
uint8_t defaultHopLimit
Default Hop Limit value.
Definition ipv6.h:461
size_t linkMtu
Maximum transmission unit.
Definition ipv6.h:459
bool_t enableEchoReq
Support for ICMPv6 Echo Request messages.
Definition ipv6.h:463
uint8_t curHopLimit
Current Hop Limit value.
Definition ipv6.h:462
uint32_t identification
IPv6 fragment identification field.
Definition ipv6.h:472
bool_t enableMulticastEchoReq
Support for multicast ICMPv6 Echo Request messages.
Definition ipv6.h:464
IPv6 multicast filter entry.
Definition ipv6.h:444
uint_t state
MLD node state.
Definition ipv6.h:447
uint_t refCount
Reference count for the current entry.
Definition ipv6.h:446
systime_t timer
Delay timer.
Definition ipv6.h:449
bool_t flag
MLD flag.
Definition ipv6.h:448
Ipv6Addr addr
Multicast address.
Definition ipv6.h:445
Fragmented packet descriptor.
Definition ipv6_frag.h:131
Prefix list entry.
Definition ipv6.h:413
bool_t autonomousFlag
Autonomous flag.
Definition ipv6.h:417
bool_t onLinkFlag
On-link flag.
Definition ipv6.h:416
systime_t timestamp
Timestamp to manage entry lifetime.
Definition ipv6.h:421
uint8_t prefixLen
IPv6 prefix length.
Definition ipv6.h:415
bool_t permanent
Permanently assigned prefix.
Definition ipv6.h:420
systime_t validLifetime
Valid lifetime.
Definition ipv6.h:418
Ipv6Addr prefix
IPv6 prefix information.
Definition ipv6.h:414
systime_t preferredLifetime
Preferred lifetime.
Definition ipv6.h:419
Default router list entry.
Definition ipv6.h:430
systime_t timestamp
Timestamp to manage entry lifetime.
Definition ipv6.h:435
bool_t permanent
Permanently assigned router.
Definition ipv6.h:434
uint8_t preference
Preference value.
Definition ipv6.h:433
Ipv6Addr addr
Router address.
Definition ipv6.h:431
systime_t lifetime
Router lifetime.
Definition ipv6.h:432
Structure describing a buffer that spans multiple chunks.
Definition net_mem.h:89