ipv6_routing.c
Go to the documentation of this file.
1 /**
2  * @file ipv6_routing.c
3  * @brief IPv6 routing
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2019 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 1.9.6
29  **/
30 
31 //Switch to the appropriate trace level
32 #define TRACE_LEVEL IPV6_TRACE_LEVEL
33 
34 //Dependencies
35 #include <limits.h>
36 #include "core/net.h"
37 #include "core/ip.h"
38 #include "ipv6/ipv6.h"
39 #include "ipv6/ipv6_misc.h"
40 #include "ipv6/ipv6_routing.h"
41 #include "ipv6/icmpv6.h"
42 #include "ipv6/ndp.h"
43 #include "debug.h"
44 
45 //Check TCP/IP stack configuration
46 #if (IPV6_SUPPORT == ENABLED && IPV6_ROUTING_SUPPORT == ENABLED)
47 
48 //IPv6 routing table
49 static Ipv6RoutingTableEntry ipv6RoutingTable[IPV6_ROUTING_TABLE_SIZE];
50 
51 
52 /**
53  * @brief Initialize IPv6 routing table
54  * @return Error code
55  **/
56 
58 {
59  //Clear the routing table
60  memset(ipv6RoutingTable, 0, sizeof(ipv6RoutingTable));
61 
62  //Successful initialization
63  return NO_ERROR;
64 }
65 
66 
67 /**
68  * @brief Enable routing for the specified interface
69  * @param[in] interface Underlying network interface
70  * @param[in] enable When the flag is set to TRUE, routing is enabled on the
71  * interface and the router can forward packets to or from the interface
72  * @return Error code
73  **/
74 
76 {
77  //Check parameters
78  if(interface == NULL)
80 
81  //Get exclusive access
83  //Enable or disable routing
84  interface->ipv6Context.isRouter = enable;
85  //Release exclusive access
87 
88  //Successful processing
89  return NO_ERROR;
90 }
91 
92 
93 /**
94  * @brief Add a new entry in the IPv6 routing table
95  * @param[in] prefix Network destination
96  * @param[in] prefixLen Length of the prefix, in bits
97  * @param[in] interface Network interface where to forward the packet
98  * @param[in] nextHop IPv6 address of the next hop
99  * @param[in] metric Metric value
100  * @return Error code
101  **/
102 
104  NetInterface *interface, const Ipv6Addr *nextHop, uint_t metric)
105 {
106  error_t error;
107  uint_t i;
108  Ipv6RoutingTableEntry *entry;
109  Ipv6RoutingTableEntry *firstFreeEntry;
110 
111  //Check parameters
112  if(prefix == NULL || interface == NULL)
114 
115  //Keep track of the first free entry
116  firstFreeEntry = NULL;
117 
118  //Get exclusive access
120 
121  //Loop through routing table entries
122  for(i = 0; i < IPV6_ROUTING_TABLE_SIZE; i++)
123  {
124  //Point to the current entry
125  entry = &ipv6RoutingTable[i];
126 
127  //Valid entry?
128  if(entry->valid)
129  {
130  //Check prefix length
131  if(entry->prefixLen == prefixLen)
132  {
133  //Check whether the current entry matches the specified destination
134  if(ipv6CompPrefix(&entry->prefix, prefix, prefixLen))
135  break;
136  }
137  }
138  else
139  {
140  //Keep track of the first free entry
141  if(firstFreeEntry == NULL)
142  firstFreeEntry = entry;
143  }
144  }
145 
146  //If the routing table does not contain the specified destination,
147  //then a new entry should be created
148  if(i >= IPV6_ROUTING_TABLE_SIZE)
149  entry = firstFreeEntry;
150 
151  //Check whether the routing table runs out of space
152  if(entry != NULL)
153  {
154  //Network destination
155  entry->prefix = *prefix;
156  entry->prefixLen = prefixLen;
157 
158  //Interface where to forward the packet
159  entry->interface = interface;
160 
161  //Address of the next hop
162  if(nextHop != NULL)
163  entry->nextHop = *nextHop;
164  else
166 
167  //Metric value
168  entry->metric = metric;
169  //The entry is now valid
170  entry->valid = TRUE;
171 
172  //Sucessful processing
173  error = NO_ERROR;
174  }
175  else
176  {
177  //The routing table is full
178  error = ERROR_FAILURE;
179  }
180 
181  //Release exclusive access
183 
184  //Return status code
185  return error;
186 }
187 
188 
189 /**
190  * @brief Remove an entry from the IPv6 routing table
191  * @param[in] prefix Network destination
192  * @param[in] prefixLen Length of the prefix, in bits
193  * @return Error code
194  **/
195 
197 {
198  error_t error;
199  uint_t i;
200  Ipv6RoutingTableEntry *entry;
201 
202  //Initialize status code
203  error = ERROR_NOT_FOUND;
204 
205  //Get exclusive access
207 
208  //Loop through routing table entries
209  for(i = 0; i < IPV6_ROUTING_TABLE_SIZE; i++)
210  {
211  //Point to the current entry
212  entry = &ipv6RoutingTable[i];
213 
214  //Valid entry?
215  if(entry->valid)
216  {
217  //Check prefix length
218  if(entry->prefixLen == prefixLen)
219  {
220  //Check whether the current entry matches the specified destination
221  if(ipv6CompPrefix(&entry->prefix, prefix, prefixLen))
222  {
223  //Delete current entry
224  entry->valid = FALSE;
225  //The route was successfully deleted from the routing table
226  error = NO_ERROR;
227  }
228  }
229  }
230  }
231 
232  //Release exclusive access
234 
235  //Return status code
236  return error;
237 }
238 
239 
240 /**
241  * @brief Delete all routes from the IPv6 routing table
242  * @return Error code
243  **/
244 
246 {
247  //Get exclusive access
249  //Clear the routing table
250  memset(ipv6RoutingTable, 0, sizeof(ipv6RoutingTable));
251  //Release exclusive access
253 
254  //Successful processing
255  return NO_ERROR;
256 }
257 
258 
259 /**
260  * @brief Forward an IPv6 packet
261  * @param[in] srcInterface Network interface on which the packet was received
262  * @param[in] ipPacket Multi-part buffer that holds the IPv6 packet to forward
263  * @param[in] ipPacketOffset Offset to the first byte of the IPv6 packet
264  * @return Error code
265  **/
266 
268  NetBuffer *ipPacket, size_t ipPacketOffset)
269 {
270  error_t error;
271  uint_t i;
272  uint_t metric;
274  bool_t match;
275  size_t length;
276  size_t destOffset;
277  NetInterface *destInterface;
278  NetBuffer *destBuffer;
279  Ipv6Header *ipHeader;
280  Ipv6RoutingTableEntry *entry;
282 #if (ETH_SUPPORT == ENABLED)
283  NetInterface *physicalInterface;
284 #endif
285 
286  //Silently drop any IP packets received on an interface that has
287  //not been assigned a valid link-local address
289  return ERROR_NOT_CONFIGURED;
290 
291  //If routing is not enabled on the interface, then the router cannot
292  //forward packets from the interface
293  if(!srcInterface->ipv6Context.isRouter)
294  return ERROR_FAILURE;
295 
296  //Calculate the length of the IPv6 packet
297  length = netBufferGetLength(ipPacket) - ipPacketOffset;
298 
299  //Ensure the packet length is greater than 40 bytes
300  if(length < sizeof(Ipv6Header))
301  return ERROR_INVALID_LENGTH;
302 
303  //Point to the IPv6 header
304  ipHeader = netBufferAt(ipPacket, ipPacketOffset);
305 
306  //Sanity check
307  if(ipHeader == NULL)
308  return ERROR_FAILURE;
309 
310  //An IPv6 packet with a source address of unspecified must never be
311  //forwarded by an IPv6 router (refer to RFC section 3513 2.5.2)
312  if(ipv6CompAddr(&ipHeader->srcAddr, &IPV6_UNSPECIFIED_ADDR))
313  return ERROR_INVALID_ADDRESS;
314 
315  //The unspecified address must not be used as the destination address
316  //of IPv6 packets (refer to RFC section 3513 2.5.2)
317  if(ipv6CompAddr(&ipHeader->destAddr, &IPV6_UNSPECIFIED_ADDR))
318  return ERROR_INVALID_ADDRESS;
319 
320  //An IPv6 packet with a destination address of loopback must never be
321  //forwarded by an IPv6 router (refer to RFC 3513 section 2.5.3)
322  if(ipv6CompAddr(&ipHeader->destAddr, &IPV6_LOOPBACK_ADDR))
323  return ERROR_INVALID_ADDRESS;
324 
325  //Check whether the destination address is a link-local address
326  if(ipv6IsLinkLocalUnicastAddr(&ipHeader->destAddr))
327  {
328  //Forward the packet on the same network interface
329  destInterface = srcInterface;
330  //Next hop
331  destIpAddr = ipHeader->destAddr;
332  }
333  else
334  {
335  //Lowest metric value
336  metric = UINT_MAX;
337  //Longest prefix length
338  prefixLen = 0;
339  //Outgoing network interface
340  destInterface = NULL;
341 
342  //Route determination process
343  for(i = 0; i < IPV6_ROUTING_TABLE_SIZE; i++)
344  {
345  //Point to the current entry
346  entry = &ipv6RoutingTable[i];
347 
348  //Valid entry?
349  if(entry->valid && entry->interface != NULL)
350  {
351  //Clear flag
352  match = FALSE;
353 
354  //Do not forward any IP packets to an interface that has not
355  //been assigned a valid link-local address...
357  {
358  //If routing is enabled on the interface, then the router
359  //can forward packets to the interface
360  if(entry->interface->ipv6Context.isRouter)
361  {
362  //Compare the destination address with the current entry for a match
363  if(ipv6CompPrefix(&ipHeader->destAddr, &entry->prefix, entry->prefixLen))
364  {
365  //The longest matching route is the most specific route to the
366  //destination IPv6 address...
367  if(entry->prefixLen > prefixLen)
368  {
369  //Give the current route the higher precedence
370  match = TRUE;
371  }
372  else if(entry->prefixLen == prefixLen)
373  {
374  //If multiple entries with the longest match are found, the
375  //router uses the lowest metric to select the best route
376  if(entry->metric < metric)
377  {
378  //Give the current route the higher precedence
379  match = TRUE;
380  }
381  }
382  }
383  }
384  }
385 
386  //Matching entry?
387  if(match)
388  {
389  //Select the current route
390  metric = entry->metric;
391  prefixLen = entry->prefixLen;
392 
393  //Outgoing interface on which to forward the packet
394  destInterface = entry->interface;
395 
396  //Next hop
398  destIpAddr = entry->nextHop;
399  else
400  destIpAddr = ipHeader->destAddr;
401  }
402  }
403  }
404  }
405 
406  //No route to the destination?
407  if(destInterface == NULL)
408  {
409  //A Destination Unreachable message should be generated by a router
410  //in response to a packet that cannot be delivered
412  ICMPV6_CODE_NO_ROUTE_TO_DEST, 0, ipPacket, ipPacketOffset);
413 
414  //Exit immediately
415  return ERROR_NO_ROUTE;
416  }
417 
418  //Check whether the length of the IPv6 packet is larger than the link MTU
419  if(length > destInterface->ipv6Context.linkMtu)
420  {
421  //A Packet Too Big must be sent by a router in response to a packet
422  //that it cannot forward because the packet is larger than the MTU
423  //of the outgoing link
425  0, destInterface->ipv6Context.linkMtu, ipPacket, ipPacketOffset);
426 
427  //Exit immediately
428  return ERROR_INVALID_LENGTH;
429  }
430 
431  //Check whether the packet is explicitly addressed to the router itself
432  if(!ipv6CheckDestAddr(destInterface, &ipHeader->destAddr))
433  {
434  //Valid unicast address?
435  if(!ipv6IsMulticastAddr(&ipHeader->destAddr))
436  {
437  //Process IPv6 packet
438  //ipv6ProcessPacket(destInterface, ipPacket, ipPacketOffset);
439  //Exit immediately
440  return NO_ERROR;
441  }
442  }
443 
444  //Check whether the IPv6 packet is about to be sent out the interface
445  //on which it was received
446  if(destInterface == srcInterface)
447  {
448 #if (NDP_SUPPORT == ENABLED)
449  //A router should send a Redirect message whenever it forwards a packet
450  //that is not explicitly addressed to itself in which the source address
451  //identifies a neighbor, and
452  if(ipv6IsOnLink(srcInterface, &ipHeader->srcAddr))
453  {
454  //The router determines that a better first-hop node resides on the
455  //same link as the sending node for the destination address of the
456  //packet being forwarded, and
457  if(ipv6IsOnLink(destInterface, &destIpAddr))
458  {
459  //The destination address of the packet is not a multicast address
460  if(!ipv6IsMulticastAddr(&ipHeader->destAddr))
461  {
462  //Transmit a Redirect message
463  ndpSendRedirect(srcInterface, &destIpAddr, ipPacket, ipPacketOffset);
464  }
465  }
466  }
467 #endif
468  }
469  else
470  {
471  //Check whether the scope of the source address is smaller than the
472  //scope of the destination address
473  if(ipv6GetAddrScope(&ipHeader->srcAddr) < ipv6GetAddrScope(&ipHeader->destAddr))
474  {
475  //A Destination Unreachable message should be generated by a router
476  //in response to a packet that cannot be delivered without leaving
477  //the scope of the source address
479  ICMPV6_CODE_BEYOND_SCOPE_OF_SRC_ADDR, 0, ipPacket, ipPacketOffset);
480 
481  //Exit immediately
482  return ERROR_INVALID_ADDRESS;
483  }
484  }
485 
486  //Hop Limit exceeded in transit?
487  if(ipHeader->hopLimit <= 1)
488  {
489  //If a router receives a packet with a Hop Limit of zero, or if a router
490  //decrements a packet's Hop Limit to zero, it must discard the packet
491  //and originate an ICMPv6 Time Exceeded message
493  ICMPV6_CODE_HOP_LIMIT_EXCEEDED, 0, ipPacket, ipPacketOffset);
494 
495  //Exit immediately
496  return ERROR_FAILURE;
497  }
498 
499  //The Hop-by-Hop Options header, when present, must immediately follow
500  //the IPv6 header. Its presence is indicated by the value zero in the
501  //Next Header field of the IPv6 header
502  if(ipHeader->nextHeader == IPV6_HOP_BY_HOP_OPT_HEADER)
503  {
504  //Point to the extension header
505  size_t headerOffset = ipPacketOffset + sizeof(Ipv6Header);
506 
507  //Calculate the offset of the Next Header field
508  size_t nextHeaderOffset = ipPacketOffset +
509  &ipHeader->nextHeader - (uint8_t *) ipHeader;
510 
511  //The Hop-by-Hop Options header is used to carry optional information
512  //that must be examined by every node along a packet's delivery path
513  error = ipv6ParseHopByHopOptHeader(srcInterface,
514  ipPacket, ipPacketOffset, &headerOffset, &nextHeaderOffset);
515 
516  //Any error while processing the extension header?
517  if(error)
518  return error;
519  }
520 
521  //Allocate a buffer to hold the IPv6 packet
522  destBuffer = ethAllocBuffer(length, &destOffset);
523 
524  //Successful memory allocation?
525  if(destBuffer != NULL)
526  {
527  //Copy IPv6 header
528  error = netBufferCopy(destBuffer, destOffset,
529  ipPacket, ipPacketOffset, length);
530 
531  //Check status code
532  if(!error)
533  {
534  //Point to the IPv6 header
535  ipHeader = netBufferAt(destBuffer, destOffset);
536  //Every time a router forwards a packet, it decrements the Hop Limit field
537  ipHeader->hopLimit--;
538 
539 #if (ETH_SUPPORT == ENABLED)
540  //Point to the physical interface
541  physicalInterface = nicGetPhysicalInterface(destInterface);
542 
543  //Ethernet interface?
544  if(physicalInterface->nicDriver != NULL &&
545  physicalInterface->nicDriver->type == NIC_TYPE_ETHERNET)
546  {
547  MacAddr destMacAddr;
548 
549  //Destination IPv6 address
551  destIpAddr = ipHeader->destAddr;
552 
553  //Check whether the destination IPv6 address is a multicast address?
555  {
556  //Map IPv6 multicast address to MAC-layer multicast address
557  error = ipv6MapMulticastAddrToMac(&destIpAddr, &destMacAddr);
558  }
559  else
560  {
561  //Resolve host address using Neighbor Discovery protocol
562  error = ndpResolve(destInterface, &destIpAddr, &destMacAddr);
563  }
564 
565  //Successful address resolution?
566  if(!error)
567  {
568  //Debug message
569  TRACE_INFO("Forwarding IPv6 packet to %s (%" PRIuSIZE " bytes)...\r\n",
570  destInterface->name, length);
571  //Dump IP header contents for debugging purpose
572  ipv6DumpHeader(ipHeader);
573 
574  //Send Ethernet frame
575  error = ethSendFrame(destInterface, &destMacAddr,
576  destBuffer, destOffset, ETH_TYPE_IPV6);
577  }
578  //Address resolution is in progress?
579  else if(error == ERROR_IN_PROGRESS)
580  {
581  //Debug message
582  TRACE_INFO("Enqueuing IPv6 packet (%" PRIuSIZE " bytes)...\r\n", length);
583  //Dump IP header contents for debugging purpose
584  ipv6DumpHeader(ipHeader);
585 
586  //Enqueue packets waiting for address resolution
587  error = ndpEnqueuePacket(srcInterface, destInterface,
588  &destIpAddr, destBuffer, destOffset);
589  }
590  //Address resolution failed?
591  else
592  {
593  //Debug message
594  TRACE_WARNING("Cannot map IPv6 address to Ethernet address!\r\n");
595  }
596  }
597  else
598 #endif
599 #if (PPP_SUPPORT == ENABLED)
600  //PPP interface?
601  if(destInterface->nicDriver != NULL &&
602  destInterface->nicDriver->type == NIC_TYPE_PPP)
603  {
604  //Debug message
605  TRACE_INFO("Forwarding IPv6 packet to %s (%" PRIuSIZE " bytes)...\r\n",
606  destInterface->name, length);
607  //Dump IP header contents for debugging purpose
608  ipv6DumpHeader(ipHeader);
609 
610  //Send PPP frame
611  error = pppSendFrame(destInterface, destBuffer, destOffset, PPP_PROTOCOL_IPV6);
612  }
613  else
614 #endif
615  //6LoWPAN interface?
616  if(destInterface->nicDriver != NULL &&
617  destInterface->nicDriver->type == NIC_TYPE_6LOWPAN)
618  {
619  //Debug message
620  TRACE_INFO("Forwarding IPv6 packet to %s (%" PRIuSIZE " bytes)...\r\n",
621  destInterface->name, length);
622  //Dump IP header contents for debugging purpose
623  ipv6DumpHeader(ipHeader);
624 
625  //Send the packet over the specified link
626  error = nicSendPacket(destInterface, destBuffer, destOffset);
627  }
628  else
629  //Unknown interface type?
630  {
631  //Report an error
632  error = ERROR_INVALID_INTERFACE;
633  }
634  }
635 
636  //Free previously allocated memory
637  netBufferFree(destBuffer);
638  }
639  else
640  {
641  //Failed to allocate memory
642  error = ERROR_OUT_OF_MEMORY;
643  }
644 
645  //Return status code
646  return error;
647 }
648 
649 #endif
IPv6 (Internet Protocol Version 6)
@ ICMPV6_TYPE_PACKET_TOO_BIG
Definition: icmpv6.h:54
@ ICMPV6_TYPE_DEST_UNREACHABLE
Definition: icmpv6.h:53
uint8_t length
Definition: dtls_misc.h:149
int bool_t
Definition: compiler_port.h:49
@ ERROR_NOT_FOUND
Definition: error.h:145
error_t ethSendFrame(NetInterface *interface, const MacAddr *destAddr, NetBuffer *buffer, size_t offset, uint16_t type)
Send an Ethernet frame.
Definition: ethernet.c:345
@ ERROR_INVALID_INTERFACE
Invalid interface.
Definition: error.h:53
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:88
Ipv6Addr nextHop
Next hop.
Definition: ipv6_routing.h:68
error_t ndpSendRedirect(NetInterface *interface, const Ipv6Addr *targetAddr, const NetBuffer *ipPacket, size_t ipPacketOffset)
Send a Redirect message.
Definition: ndp.c:1735
#define TRUE
Definition: os_port.h:50
#define Ipv6Header
Definition: ipv6.h:36
#define IPV6_ROUTING_TABLE_SIZE
Definition: ipv6_routing.h:47
error_t nicSendPacket(NetInterface *interface, const NetBuffer *buffer, size_t offset)
Send a packet to the network controller.
Definition: nic.c:278
Routing table entry.
Definition: ipv6_routing.h:62
@ ERROR_OUT_OF_MEMORY
Definition: error.h:63
IPv6 routing.
#define ipv6CompAddr(ipAddr1, ipAddr2)
Definition: ipv6.h:121
@ ERROR_NOT_CONFIGURED
Definition: error.h:215
Ipv6Addr prefix
uint_t prefixLen
IPv6 prefix length.
Definition: ipv6_routing.h:66
uint8_t ipPacket[]
Definition: ndp.h:430
#define ipv6IsMulticastAddr(ipAddr)
Definition: ipv6.h:133
@ ERROR_IN_PROGRESS
Definition: error.h:211
error_t icmpv6SendErrorMessage(NetInterface *interface, uint8_t type, uint8_t code, uint32_t parameter, const NetBuffer *ipPacket, size_t ipPacketOffset)
Send an ICMPv6 Error message.
Definition: icmpv6.c:462
#define FALSE
Definition: os_port.h:46
ICMPv6 (Internet Control Message Protocol Version 6)
@ ERROR_INVALID_PARAMETER
Invalid parameter.
Definition: error.h:47
error_t ipv6DeleteRoute(const Ipv6Addr *prefix, uint_t prefixLen)
Remove an entry from the IPv6 routing table.
Definition: ipv6_routing.c:196
NetInterface * nicGetPhysicalInterface(NetInterface *interface)
Retrieve physical interface.
Definition: nic.c:84
error_t
Error codes.
Definition: error.h:42
void * netBufferAt(const NetBuffer *buffer, size_t offset)
Returns a pointer to the data at the specified position.
Definition: net_mem.c:413
error_t ipv6AddRoute(const Ipv6Addr *prefix, uint_t prefixLen, NetInterface *interface, const Ipv6Addr *nextHop, uint_t metric)
Add a new entry in the IPv6 routing table.
Definition: ipv6_routing.c:103
void ipv6DumpHeader(const Ipv6Header *ipHeader)
Dump IPv6 header for debugging purpose.
Definition: ipv6.c:2323
@ ERROR_INVALID_ADDRESS
Definition: error.h:102
@ ERROR_FAILURE
Generic error code.
Definition: error.h:45
error_t ipv6ForwardPacket(NetInterface *srcInterface, NetBuffer *ipPacket, size_t ipPacketOffset)
Forward an IPv6 packet.
Definition: ipv6_routing.c:267
#define NetInterface
Definition: net.h:36
error_t ipv6CheckDestAddr(NetInterface *interface, const Ipv6Addr *ipAddr)
Destination IPv6 address filtering.
Definition: ipv6_misc.c:777
uint_t ipv6GetAddrScope(const Ipv6Addr *ipAddr)
Retrieve the scope of an IPv6 address.
Definition: ipv6_misc.c:1253
void netBufferFree(NetBuffer *buffer)
Dispose a multi-part buffer.
Definition: net_mem.c:282
@ ERROR_INVALID_LENGTH
Definition: error.h:109
@ ICMPV6_CODE_HOP_LIMIT_EXCEEDED
Definition: icmpv6.h:91
Helper functions for IPv6.
@ IPV6_HOP_BY_HOP_OPT_HEADER
Definition: ipv6.h:184
OsMutex netMutex
Definition: net.c:75
const Ipv6Addr IPV6_UNSPECIFIED_ADDR
Definition: ipv6.c:67
__start_packed struct @179 Ipv6Addr
IPv6 network address.
const Ipv6Addr IPV6_LOOPBACK_ADDR
Definition: ipv6.c:71
error_t netBufferCopy(NetBuffer *dest, size_t destOffset, const NetBuffer *src, size_t srcOffset, size_t length)
Copy data between multi-part buffers.
Definition: net_mem.c:504
@ PPP_PROTOCOL_IPV6
Internet Protocol version 6.
Definition: ppp.h:200
#define TRACE_INFO(...)
Definition: debug.h:94
size_t netBufferGetLength(const NetBuffer *buffer)
Get the actual length of a multi-part buffer.
Definition: net_mem.c:297
NetInterface * interface
Outgoing network interface.
Definition: ipv6_routing.h:67
bool_t valid
Valid entry.
Definition: ipv6_routing.h:64
#define ipv6IsLinkLocalUnicastAddr(ipAddr)
Definition: ipv6.h:125
@ ERROR_NO_ROUTE
Definition: error.h:217
NDP (Neighbor Discovery Protocol)
@ NIC_TYPE_PPP
PPP interface.
Definition: nic.h:80
#define TRACE_WARNING(...)
Definition: debug.h:84
uint8_t prefixLen
error_t pppSendFrame(NetInterface *interface, NetBuffer *buffer, size_t offset, uint16_t protocol)
Send a PPP frame.
Definition: ppp.c:1006
@ ICMPV6_CODE_BEYOND_SCOPE_OF_SRC_ADDR
Definition: icmpv6.h:79
error_t ndpEnqueuePacket(NetInterface *srcInterface, NetInterface *destInterface, const Ipv6Addr *ipAddr, NetBuffer *buffer, size_t offset)
Enqueue an IPv6 packet waiting for address resolution.
Definition: ndp.c:192
uint_t metric
Metric value.
Definition: ipv6_routing.h:69
IPv4 and IPv6 common routines.
Ipv6Addr prefix
Destination.
Definition: ipv6_routing.h:65
@ ETH_TYPE_IPV6
Definition: ethernet.h:145
void osAcquireMutex(OsMutex *mutex)
Acquire ownership of the specified mutex object.
void osReleaseMutex(OsMutex *mutex)
Release ownership of the specified mutex object.
error_t ipv6EnableRouting(NetInterface *interface, bool_t enable)
Enable routing for the specified interface.
Definition: ipv6_routing.c:75
bool_t ipv6CompPrefix(const Ipv6Addr *ipAddr1, const Ipv6Addr *ipAddr2, size_t length)
Compare IPv6 address prefixes.
Definition: ipv6_misc.c:1208
error_t ipv6InitRouting(void)
Initialize IPv6 routing table.
Definition: ipv6_routing.c:57
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:1199
@ ICMPV6_CODE_NO_ROUTE_TO_DEST
Definition: icmpv6.h:77
error_t ndpResolve(NetInterface *interface, const Ipv6Addr *ipAddr, MacAddr *macAddr)
Address resolution using Neighbor Discovery protocol.
Definition: ndp.c:100
@ IPV6_ADDR_STATE_PREFERRED
An address assigned to an interface whose use is unrestricted.
Definition: ipv6.h:173
NetBuffer * ethAllocBuffer(size_t length, size_t *offset)
Allocate a buffer to hold an Ethernet frame.
Definition: ethernet.c:641
#define PRIuSIZE
Definition: compiler_port.h:78
@ NIC_TYPE_6LOWPAN
6LoWPAN interface
Definition: nic.h:81
unsigned int uint_t
Definition: compiler_port.h:45
TCP/IP stack core.
bool_t ipv6IsOnLink(NetInterface *interface, const Ipv6Addr *ipAddr)
Check whether an IPv6 address is on-link.
Definition: ipv6_misc.c:1032
#define ipv6GetLinkLocalAddrState(interface)
Definition: ipv6.h:141
error_t ipv6MapMulticastAddrToMac(const Ipv6Addr *ipAddr, MacAddr *macAddr)
Map an IPv6 multicast address to a MAC-layer multicast address.
Definition: ipv6_misc.c:1415
error_t ipv6DeleteAllRoutes(void)
Delete all routes from the IPv6 routing table.
Definition: ipv6_routing.c:245
@ NO_ERROR
Success.
Definition: error.h:44
@ ICMPV6_TYPE_TIME_EXCEEDED
Definition: icmpv6.h:55
Debugging facilities.
__start_packed struct @108 MacAddr
MAC address.
@ NIC_TYPE_ETHERNET
Ethernet interface.
Definition: nic.h:79
Ipv4Addr destIpAddr
Definition: ipcp.h:78