Webserver+3d print

Dependents:   Nucleo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ndp_router_adv.h Source File

ndp_router_adv.h

Go to the documentation of this file.
00001 /**
00002  * @file ndp_router_adv.h
00003  * @brief Router advertisement service
00004  *
00005  * @section License
00006  *
00007  * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved.
00008  *
00009  * This file is part of CycloneTCP Open.
00010  *
00011  * This program is free software; you can redistribute it and/or
00012  * modify it under the terms of the GNU General Public License
00013  * as published by the Free Software Foundation; either version 2
00014  * of the License, or (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software Foundation,
00023  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00024  *
00025  * @author Oryx Embedded SARL (www.oryx-embedded.com)
00026  * @version 1.7.6
00027  **/
00028 
00029 #ifndef _NDP_ROUTER_ADV_H
00030 #define _NDP_ROUTER_ADV_H
00031 
00032 //Dependencies
00033 #include "core/net.h"
00034 #include "ipv6/ipv6.h"
00035 
00036 //RA service support
00037 #ifndef NDP_ROUTER_ADV_SUPPORT
00038    #define NDP_ROUTER_ADV_SUPPORT DISABLED
00039 #elif (NDP_ROUTER_ADV_SUPPORT != ENABLED && NDP_ROUTER_ADV_SUPPORT != DISABLED)
00040    #error NDP_ROUTER_ADV_SUPPORT parameter is not valid
00041 #endif
00042 
00043 //RA service tick interval
00044 #ifndef NDP_ROUTER_ADV_TICK_INTERVAL
00045    #define NDP_ROUTER_ADV_TICK_INTERVAL 100
00046 #elif (NDP_ROUTER_ADV_TICK_INTERVAL < 10)
00047    #error NDP_ROUTER_ADV_TICK_INTERVAL parameter is not valid
00048 #endif
00049 
00050 
00051 /**
00052  * @brief IPv6 prefix information
00053  **/
00054 
00055 typedef struct
00056 {
00057    Ipv6Addr prefix;
00058    uint8_t length;
00059    bool_t onLinkFlag;
00060    bool_t autonomousFlag;
00061    uint32_t validLifetime;
00062    uint32_t preferredLifetime;
00063 } NdpRouterAdvPrefixInfo;
00064 
00065 
00066 /**
00067  * @brief Route information
00068  **/
00069 
00070 typedef struct
00071 {
00072    Ipv6Addr prefix;
00073    uint8_t length;
00074    uint8_t preference;
00075    uint32_t routeLifetime;
00076 } NdpRouterAdvRouteInfo;
00077 
00078 
00079 /**
00080  * @brief Context information for 6LoWPAN header compression
00081  **/
00082 
00083 typedef struct
00084 {
00085    uint8_t cid;
00086    Ipv6Addr prefix;
00087    uint8_t length;
00088    bool_t compression;
00089    uint16_t validLifetime;
00090 } NdpRouterAdvContextInfo;
00091 
00092 
00093 /**
00094  * @brief RA service settings
00095  **/
00096 
00097 typedef struct
00098 {
00099    NetInterface *interface;
00100    systime_t maxRtrAdvInterval;
00101    systime_t minRtrAdvInterval;
00102    uint8_t curHopLimit;
00103    bool_t managedFlag;
00104    bool_t otherConfigFlag;
00105    bool_t homeAgentFlag;
00106    uint8_t preference;
00107    bool_t proxyFlag;
00108    uint16_t defaultLifetime;
00109    uint32_t reachableTime;
00110    uint32_t retransTimer;
00111    uint32_t linkMtu;
00112    NdpRouterAdvPrefixInfo *prefixList;
00113    uint_t prefixListLength;
00114    NdpRouterAdvRouteInfo *routeList;
00115    uint_t routeListLength;
00116    NdpRouterAdvContextInfo *contextList;
00117    uint_t contextListLength;
00118 } NdpRouterAdvSettings;
00119 
00120 
00121 /**
00122  * @brief RA service context
00123  **/
00124 
00125 typedef struct
00126 {
00127    NdpRouterAdvSettings settings; ///<RA service settings
00128    bool_t running;                ///<This flag tells whether the RA service is running
00129    systime_t timestamp;           ///<Timestamp to manage retransmissions
00130    systime_t timeout;             ///<Timeout value
00131    uint_t routerAdvCount;         ///<Router Advertisement message counter
00132 } NdpRouterAdvContext;
00133 
00134 
00135 //Tick counter to handle periodic operations
00136 extern systime_t ndpRouterAdvTickCounter;
00137 
00138 //RA service related functions
00139 void ndpRouterAdvGetDefaultSettings(NdpRouterAdvSettings *settings);
00140 error_t ndpRouterAdvInit(NdpRouterAdvContext *context, const NdpRouterAdvSettings *settings);
00141 error_t ndpRouterAdvStart(NdpRouterAdvContext *context);
00142 error_t ndpRouterAdvStop(NdpRouterAdvContext *context);
00143 
00144 void ndpRouterAdvTick(NdpRouterAdvContext *context);
00145 void ndpRouterAdvLinkChangeEvent(NdpRouterAdvContext *context);
00146 
00147 void ndpProcessRouterSol(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader,
00148    const NetBuffer *buffer, size_t offset, uint8_t hopLimit);
00149 
00150 error_t ndpSendRouterAdv(NdpRouterAdvContext *context, uint16_t routerLifetime);
00151 
00152 #endif
00153