ipv6_routing.h
Go to the documentation of this file.
1 /**
2  * @file ipv6_routing.h
3  * @brief IPv6 routing
4  *
5  * @section License
6  *
7  * Copyright (C) 2010-2018 Oryx Embedded SARL. All rights reserved.
8  *
9  * This file is part of CycloneTCP Open.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24  *
25  * @author Oryx Embedded SARL (www.oryx-embedded.com)
26  * @version 1.9.0
27  **/
28 
29 #ifndef _IPV6_ROUTING_H
30 #define _IPV6_ROUTING_H
31 
32 //Dependencies
33 #include "core/net.h"
34 #include "ipv6/ipv6.h"
35 
36 //IPv6 routing support
37 #ifndef IPV6_ROUTING_SUPPORT
38  #define IPV6_ROUTING_SUPPORT DISABLED
39 #elif (IPV6_ROUTING_SUPPORT != ENABLED && IPV6_ROUTING_SUPPORT != DISABLED)
40  #error IPV6_ROUTING_SUPPORT parameter is not valid
41 #endif
42 
43 //Size of the IPv6 routing table
44 #ifndef IPV6_ROUTING_TABLE_SIZE
45  #define IPV6_ROUTING_TABLE_SIZE 8
46 #elif (IPV6_ROUTING_TABLE_SIZE < 1)
47  #error IPV6_ROUTING_TABLE_SIZE parameter is not valid
48 #endif
49 
50 //C++ guard
51 #ifdef __cplusplus
52  extern "C" {
53 #endif
54 
55 
56 /**
57  * @brief Routing table entry
58  **/
59 
60 typedef struct
61 {
62  bool_t valid; ///<Valid entry
63  Ipv6Addr prefix; ///<Destination
64  uint_t prefixLen; ///<IPv6 prefix length
65  NetInterface *interface; ///<Outgoing network interface
66  Ipv6Addr nextHop; ///<Next hop
67  uint_t metric; ///<Metric value
69 
70 
71 //IPv6 routing related functions
73 error_t ipv6EnableRouting(NetInterface *interface, bool_t enable);
74 
76  NetInterface *interface, const Ipv6Addr *nextHop, uint_t metric);
77 
80 
82  NetBuffer *ipPacket, size_t ipPacketOffset);
83 
84 //C++ guard
85 #ifdef __cplusplus
86  }
87 #endif
88 
89 #endif
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:101
error_t ipv6EnableRouting(NetInterface *interface, bool_t enable)
Enable routing for the specified interface.
Definition: ipv6_routing.c:73
TCP/IP stack core.
__start_packed struct @183 Ipv6Addr
IPv6 network address.
error_t ipv6DeleteAllRoutes(void)
Delete all routes from the IPv6 routing table.
Definition: ipv6_routing.c:243
NetInterface * interface
Outgoing network interface.
Definition: ipv6_routing.h:65
uint8_t ipPacket[]
Definition: ndp.h:427
uint_t prefixLen
IPv6 prefix length.
Definition: ipv6_routing.h:64
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:86
Routing table entry.
Definition: ipv6_routing.h:60
IPv6 (Internet Protocol Version 6)
Ipv6Addr prefix
error_t
Error codes.
Definition: error.h:40
unsigned int uint_t
Definition: compiler_port.h:43
#define NetInterface
Definition: net.h:34
Ipv6Addr nextHop
Next hop.
Definition: ipv6_routing.h:66
bool_t valid
Valid entry.
Definition: ipv6_routing.h:62
error_t ipv6DeleteRoute(const Ipv6Addr *prefix, uint_t prefixLen)
Remove an entry from the IPv6 routing table.
Definition: ipv6_routing.c:194
uint8_t prefixLen
error_t ipv6InitRouting(void)
Initialize IPv6 routing table.
Definition: ipv6_routing.c:55
Ipv6Addr prefix
Destination.
Definition: ipv6_routing.h:63
int bool_t
Definition: compiler_port.h:47
uint_t metric
Metric value.
Definition: ipv6_routing.h:67
error_t ipv6ForwardPacket(NetInterface *srcInterface, NetBuffer *ipPacket, size_t ipPacketOffset)
Forward an IPv6 packet.
Definition: ipv6_routing.c:265