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