ndp_router_adv.h
Go to the documentation of this file.
1 /**
2  * @file ndp_router_adv.h
3  * @brief Router advertisement service
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2020 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.8
29  **/
30 
31 #ifndef _NDP_ROUTER_ADV_H
32 #define _NDP_ROUTER_ADV_H
33 
34 //Dependencies
35 #include "core/net.h"
36 #include "ipv6/ipv6.h"
37 
38 //RA service support
39 #ifndef NDP_ROUTER_ADV_SUPPORT
40  #define NDP_ROUTER_ADV_SUPPORT DISABLED
41 #elif (NDP_ROUTER_ADV_SUPPORT != ENABLED && NDP_ROUTER_ADV_SUPPORT != DISABLED)
42  #error NDP_ROUTER_ADV_SUPPORT parameter is not valid
43 #endif
44 
45 //RA service tick interval
46 #ifndef NDP_ROUTER_ADV_TICK_INTERVAL
47  #define NDP_ROUTER_ADV_TICK_INTERVAL 100
48 #elif (NDP_ROUTER_ADV_TICK_INTERVAL < 10)
49  #error NDP_ROUTER_ADV_TICK_INTERVAL parameter is not valid
50 #endif
51 
52 //C++ guard
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
57 
58 /**
59  * @brief IPv6 prefix information
60  **/
61 
62 typedef struct
63 {
65  uint8_t length;
68  uint32_t validLifetime;
71 
72 
73 /**
74  * @brief Route information
75  **/
76 
77 typedef struct
78 {
80  uint8_t length;
81  uint8_t preference;
82  uint32_t routeLifetime;
84 
85 
86 /**
87  * @brief Context information for 6LoWPAN header compression
88  **/
89 
90 typedef struct
91 {
92  uint8_t cid;
94  uint8_t length;
96  uint16_t validLifetime;
98 
99 
100 /**
101  * @brief RA service settings
102  **/
103 
104 typedef struct
105 {
109  uint8_t curHopLimit;
113  uint8_t preference;
115  uint16_t defaultLifetime;
116  uint32_t reachableTime;
117  uint32_t retransTimer;
118  uint32_t linkMtu;
126 
127 
128 /**
129  * @brief RA service context
130  **/
131 
132 typedef struct
133 {
134  NdpRouterAdvSettings settings; ///<RA service settings
135  bool_t running; ///<This flag tells whether the RA service is running
136  systime_t timestamp; ///<Timestamp to manage retransmissions
137  systime_t timeout; ///<Timeout value
138  uint_t routerAdvCount; ///<Router Advertisement message counter
140 
141 
142 //Tick counter to handle periodic operations
144 
145 //RA service related functions
147 
149  const NdpRouterAdvSettings *settings);
150 
153 
156 
157 void ndpProcessRouterSol(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader,
158  const NetBuffer *buffer, size_t offset, uint8_t hopLimit);
159 
161 
162 //C++ guard
163 #ifdef __cplusplus
164 }
165 #endif
166 
167 #endif
IPv6 (Internet Protocol Version 6)
int bool_t
Definition: compiler_port.h:49
NdpRouterAdvSettings settings
RA service settings.
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:88
systime_t timestamp
Timestamp to manage retransmissions.
bool_t running
This flag tells whether the RA service is running.
uint_t routerAdvCount
Router Advertisement message counter.
error_t ndpRouterAdvStop(NdpRouterAdvContext *context)
Stop RA service.
void ndpRouterAdvGetDefaultSettings(NdpRouterAdvSettings *settings)
Initialize settings with default values.
IPv6 prefix information.
NdpRouterAdvRouteInfo * routeList
Route information.
error_t ndpSendRouterAdv(NdpRouterAdvContext *context, uint16_t routerLifetime)
Send a Router Advertisement message.
error_t
Error codes.
Definition: error.h:42
uint16_t routerLifetime
Definition: ndp.h:304
#define Ipv6PseudoHeader
Definition: ipv6.h:42
#define NetInterface
Definition: net.h:36
void ndpRouterAdvLinkChangeEvent(NdpRouterAdvContext *context)
Callback function for link change event.
void ndpProcessRouterSol(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, uint8_t hopLimit)
Router Solicitation message processing.
error_t ndpRouterAdvStart(NdpRouterAdvContext *context)
Start RA service.
NdpRouterAdvContextInfo * contextList
Context information for 6LoWPAN header compression.
RA service context.
RA service settings.
NetInterface * interface
error_t ndpRouterAdvInit(NdpRouterAdvContext *context, const NdpRouterAdvSettings *settings)
RA service initialization.
__start_packed struct @77 Ipv6Addr
IPv6 network address.
systime_t timeout
Timeout value.
unsigned int uint_t
Definition: compiler_port.h:45
TCP/IP stack core.
void ndpRouterAdvTick(NdpRouterAdvContext *context)
RA service timer handler.
uint32_t systime_t
Definition: compiler_port.h:46
systime_t ndpRouterAdvTickCounter
NdpRouterAdvPrefixInfo * prefixList