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  * 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 #ifndef _IPV6_ROUTING_H
32 #define _IPV6_ROUTING_H
33 
34 //Dependencies
35 #include "core/net.h"
36 #include "ipv6/ipv6.h"
37 
38 //IPv6 routing support
39 #ifndef IPV6_ROUTING_SUPPORT
40  #define IPV6_ROUTING_SUPPORT DISABLED
41 #elif (IPV6_ROUTING_SUPPORT != ENABLED && IPV6_ROUTING_SUPPORT != DISABLED)
42  #error IPV6_ROUTING_SUPPORT parameter is not valid
43 #endif
44 
45 //Size of the IPv6 routing table
46 #ifndef IPV6_ROUTING_TABLE_SIZE
47  #define IPV6_ROUTING_TABLE_SIZE 8
48 #elif (IPV6_ROUTING_TABLE_SIZE < 1)
49  #error IPV6_ROUTING_TABLE_SIZE parameter is not valid
50 #endif
51 
52 //C++ guard
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
57 
58 /**
59  * @brief Routing table entry
60  **/
61 
62 typedef struct
63 {
64  bool_t valid; ///<Valid entry
65  Ipv6Addr prefix; ///<Destination
66  uint_t prefixLen; ///<IPv6 prefix length
67  NetInterface *interface; ///<Outgoing network interface
68  Ipv6Addr nextHop; ///<Next hop
69  uint_t metric; ///<Metric value
71 
72 
73 //IPv6 routing related functions
75 error_t ipv6EnableRouting(NetInterface *interface, bool_t enable);
76 
78  NetInterface *interface, const Ipv6Addr *nextHop, uint_t metric);
79 
82 
84  NetBuffer *ipPacket, size_t ipPacketOffset);
85 
86 //C++ guard
87 #ifdef __cplusplus
88 }
89 #endif
90 
91 #endif
IPv6 (Internet Protocol Version 6)
error_t ipv6InitRouting(void)
Initialize IPv6 routing table.
Definition: ipv6_routing.c:57
int bool_t
Definition: compiler_port.h:49
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:88
Ipv6Addr nextHop
Next hop.
Definition: ipv6_routing.h:68
error_t ipv6DeleteAllRoutes(void)
Delete all routes from the IPv6 routing table.
Definition: ipv6_routing.c:245
Routing table entry.
Definition: ipv6_routing.h:62
Ipv6Addr prefix
uint_t prefixLen
IPv6 prefix length.
Definition: ipv6_routing.h:66
uint8_t ipPacket[]
Definition: ndp.h:430
error_t
Error codes.
Definition: error.h:42
#define NetInterface
Definition: net.h:36
__start_packed struct @179 Ipv6Addr
IPv6 network address.
NetInterface * interface
Outgoing network interface.
Definition: ipv6_routing.h:67
bool_t valid
Valid entry.
Definition: ipv6_routing.h:64
uint8_t prefixLen
uint_t metric
Metric value.
Definition: ipv6_routing.h:69
Ipv6Addr prefix
Destination.
Definition: ipv6_routing.h:65
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
error_t ipv6ForwardPacket(NetInterface *srcInterface, NetBuffer *ipPacket, size_t ipPacketOffset)
Forward an IPv6 packet.
Definition: ipv6_routing.c:267
unsigned int uint_t
Definition: compiler_port.h:45
TCP/IP stack core.
error_t ipv6DeleteRoute(const Ipv6Addr *prefix, uint_t prefixLen)
Remove an entry from the IPv6 routing table.
Definition: ipv6_routing.c:196
error_t ipv6EnableRouting(NetInterface *interface, bool_t enable)
Enable routing for the specified interface.
Definition: ipv6_routing.c:75