Webserver+3d print

Dependents:   Nucleo

Committer:
Sergunb
Date:
Sat Feb 04 18:15:49 2017 +0000
Revision:
0:8918a71cdbe9
nothing else

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Sergunb 0:8918a71cdbe9 1 /**
Sergunb 0:8918a71cdbe9 2 * @file ndp_router_adv.h
Sergunb 0:8918a71cdbe9 3 * @brief Router advertisement service
Sergunb 0:8918a71cdbe9 4 *
Sergunb 0:8918a71cdbe9 5 * @section License
Sergunb 0:8918a71cdbe9 6 *
Sergunb 0:8918a71cdbe9 7 * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved.
Sergunb 0:8918a71cdbe9 8 *
Sergunb 0:8918a71cdbe9 9 * This file is part of CycloneTCP Open.
Sergunb 0:8918a71cdbe9 10 *
Sergunb 0:8918a71cdbe9 11 * This program is free software; you can redistribute it and/or
Sergunb 0:8918a71cdbe9 12 * modify it under the terms of the GNU General Public License
Sergunb 0:8918a71cdbe9 13 * as published by the Free Software Foundation; either version 2
Sergunb 0:8918a71cdbe9 14 * of the License, or (at your option) any later version.
Sergunb 0:8918a71cdbe9 15 *
Sergunb 0:8918a71cdbe9 16 * This program is distributed in the hope that it will be useful,
Sergunb 0:8918a71cdbe9 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Sergunb 0:8918a71cdbe9 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Sergunb 0:8918a71cdbe9 19 * GNU General Public License for more details.
Sergunb 0:8918a71cdbe9 20 *
Sergunb 0:8918a71cdbe9 21 * You should have received a copy of the GNU General Public License
Sergunb 0:8918a71cdbe9 22 * along with this program; if not, write to the Free Software Foundation,
Sergunb 0:8918a71cdbe9 23 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Sergunb 0:8918a71cdbe9 24 *
Sergunb 0:8918a71cdbe9 25 * @author Oryx Embedded SARL (www.oryx-embedded.com)
Sergunb 0:8918a71cdbe9 26 * @version 1.7.6
Sergunb 0:8918a71cdbe9 27 **/
Sergunb 0:8918a71cdbe9 28
Sergunb 0:8918a71cdbe9 29 #ifndef _NDP_ROUTER_ADV_H
Sergunb 0:8918a71cdbe9 30 #define _NDP_ROUTER_ADV_H
Sergunb 0:8918a71cdbe9 31
Sergunb 0:8918a71cdbe9 32 //Dependencies
Sergunb 0:8918a71cdbe9 33 #include "core/net.h"
Sergunb 0:8918a71cdbe9 34 #include "ipv6/ipv6.h"
Sergunb 0:8918a71cdbe9 35
Sergunb 0:8918a71cdbe9 36 //RA service support
Sergunb 0:8918a71cdbe9 37 #ifndef NDP_ROUTER_ADV_SUPPORT
Sergunb 0:8918a71cdbe9 38 #define NDP_ROUTER_ADV_SUPPORT DISABLED
Sergunb 0:8918a71cdbe9 39 #elif (NDP_ROUTER_ADV_SUPPORT != ENABLED && NDP_ROUTER_ADV_SUPPORT != DISABLED)
Sergunb 0:8918a71cdbe9 40 #error NDP_ROUTER_ADV_SUPPORT parameter is not valid
Sergunb 0:8918a71cdbe9 41 #endif
Sergunb 0:8918a71cdbe9 42
Sergunb 0:8918a71cdbe9 43 //RA service tick interval
Sergunb 0:8918a71cdbe9 44 #ifndef NDP_ROUTER_ADV_TICK_INTERVAL
Sergunb 0:8918a71cdbe9 45 #define NDP_ROUTER_ADV_TICK_INTERVAL 100
Sergunb 0:8918a71cdbe9 46 #elif (NDP_ROUTER_ADV_TICK_INTERVAL < 10)
Sergunb 0:8918a71cdbe9 47 #error NDP_ROUTER_ADV_TICK_INTERVAL parameter is not valid
Sergunb 0:8918a71cdbe9 48 #endif
Sergunb 0:8918a71cdbe9 49
Sergunb 0:8918a71cdbe9 50
Sergunb 0:8918a71cdbe9 51 /**
Sergunb 0:8918a71cdbe9 52 * @brief IPv6 prefix information
Sergunb 0:8918a71cdbe9 53 **/
Sergunb 0:8918a71cdbe9 54
Sergunb 0:8918a71cdbe9 55 typedef struct
Sergunb 0:8918a71cdbe9 56 {
Sergunb 0:8918a71cdbe9 57 Ipv6Addr prefix;
Sergunb 0:8918a71cdbe9 58 uint8_t length;
Sergunb 0:8918a71cdbe9 59 bool_t onLinkFlag;
Sergunb 0:8918a71cdbe9 60 bool_t autonomousFlag;
Sergunb 0:8918a71cdbe9 61 uint32_t validLifetime;
Sergunb 0:8918a71cdbe9 62 uint32_t preferredLifetime;
Sergunb 0:8918a71cdbe9 63 } NdpRouterAdvPrefixInfo;
Sergunb 0:8918a71cdbe9 64
Sergunb 0:8918a71cdbe9 65
Sergunb 0:8918a71cdbe9 66 /**
Sergunb 0:8918a71cdbe9 67 * @brief Route information
Sergunb 0:8918a71cdbe9 68 **/
Sergunb 0:8918a71cdbe9 69
Sergunb 0:8918a71cdbe9 70 typedef struct
Sergunb 0:8918a71cdbe9 71 {
Sergunb 0:8918a71cdbe9 72 Ipv6Addr prefix;
Sergunb 0:8918a71cdbe9 73 uint8_t length;
Sergunb 0:8918a71cdbe9 74 uint8_t preference;
Sergunb 0:8918a71cdbe9 75 uint32_t routeLifetime;
Sergunb 0:8918a71cdbe9 76 } NdpRouterAdvRouteInfo;
Sergunb 0:8918a71cdbe9 77
Sergunb 0:8918a71cdbe9 78
Sergunb 0:8918a71cdbe9 79 /**
Sergunb 0:8918a71cdbe9 80 * @brief Context information for 6LoWPAN header compression
Sergunb 0:8918a71cdbe9 81 **/
Sergunb 0:8918a71cdbe9 82
Sergunb 0:8918a71cdbe9 83 typedef struct
Sergunb 0:8918a71cdbe9 84 {
Sergunb 0:8918a71cdbe9 85 uint8_t cid;
Sergunb 0:8918a71cdbe9 86 Ipv6Addr prefix;
Sergunb 0:8918a71cdbe9 87 uint8_t length;
Sergunb 0:8918a71cdbe9 88 bool_t compression;
Sergunb 0:8918a71cdbe9 89 uint16_t validLifetime;
Sergunb 0:8918a71cdbe9 90 } NdpRouterAdvContextInfo;
Sergunb 0:8918a71cdbe9 91
Sergunb 0:8918a71cdbe9 92
Sergunb 0:8918a71cdbe9 93 /**
Sergunb 0:8918a71cdbe9 94 * @brief RA service settings
Sergunb 0:8918a71cdbe9 95 **/
Sergunb 0:8918a71cdbe9 96
Sergunb 0:8918a71cdbe9 97 typedef struct
Sergunb 0:8918a71cdbe9 98 {
Sergunb 0:8918a71cdbe9 99 NetInterface *interface;
Sergunb 0:8918a71cdbe9 100 systime_t maxRtrAdvInterval;
Sergunb 0:8918a71cdbe9 101 systime_t minRtrAdvInterval;
Sergunb 0:8918a71cdbe9 102 uint8_t curHopLimit;
Sergunb 0:8918a71cdbe9 103 bool_t managedFlag;
Sergunb 0:8918a71cdbe9 104 bool_t otherConfigFlag;
Sergunb 0:8918a71cdbe9 105 bool_t homeAgentFlag;
Sergunb 0:8918a71cdbe9 106 uint8_t preference;
Sergunb 0:8918a71cdbe9 107 bool_t proxyFlag;
Sergunb 0:8918a71cdbe9 108 uint16_t defaultLifetime;
Sergunb 0:8918a71cdbe9 109 uint32_t reachableTime;
Sergunb 0:8918a71cdbe9 110 uint32_t retransTimer;
Sergunb 0:8918a71cdbe9 111 uint32_t linkMtu;
Sergunb 0:8918a71cdbe9 112 NdpRouterAdvPrefixInfo *prefixList;
Sergunb 0:8918a71cdbe9 113 uint_t prefixListLength;
Sergunb 0:8918a71cdbe9 114 NdpRouterAdvRouteInfo *routeList;
Sergunb 0:8918a71cdbe9 115 uint_t routeListLength;
Sergunb 0:8918a71cdbe9 116 NdpRouterAdvContextInfo *contextList;
Sergunb 0:8918a71cdbe9 117 uint_t contextListLength;
Sergunb 0:8918a71cdbe9 118 } NdpRouterAdvSettings;
Sergunb 0:8918a71cdbe9 119
Sergunb 0:8918a71cdbe9 120
Sergunb 0:8918a71cdbe9 121 /**
Sergunb 0:8918a71cdbe9 122 * @brief RA service context
Sergunb 0:8918a71cdbe9 123 **/
Sergunb 0:8918a71cdbe9 124
Sergunb 0:8918a71cdbe9 125 typedef struct
Sergunb 0:8918a71cdbe9 126 {
Sergunb 0:8918a71cdbe9 127 NdpRouterAdvSettings settings; ///<RA service settings
Sergunb 0:8918a71cdbe9 128 bool_t running; ///<This flag tells whether the RA service is running
Sergunb 0:8918a71cdbe9 129 systime_t timestamp; ///<Timestamp to manage retransmissions
Sergunb 0:8918a71cdbe9 130 systime_t timeout; ///<Timeout value
Sergunb 0:8918a71cdbe9 131 uint_t routerAdvCount; ///<Router Advertisement message counter
Sergunb 0:8918a71cdbe9 132 } NdpRouterAdvContext;
Sergunb 0:8918a71cdbe9 133
Sergunb 0:8918a71cdbe9 134
Sergunb 0:8918a71cdbe9 135 //Tick counter to handle periodic operations
Sergunb 0:8918a71cdbe9 136 extern systime_t ndpRouterAdvTickCounter;
Sergunb 0:8918a71cdbe9 137
Sergunb 0:8918a71cdbe9 138 //RA service related functions
Sergunb 0:8918a71cdbe9 139 void ndpRouterAdvGetDefaultSettings(NdpRouterAdvSettings *settings);
Sergunb 0:8918a71cdbe9 140 error_t ndpRouterAdvInit(NdpRouterAdvContext *context, const NdpRouterAdvSettings *settings);
Sergunb 0:8918a71cdbe9 141 error_t ndpRouterAdvStart(NdpRouterAdvContext *context);
Sergunb 0:8918a71cdbe9 142 error_t ndpRouterAdvStop(NdpRouterAdvContext *context);
Sergunb 0:8918a71cdbe9 143
Sergunb 0:8918a71cdbe9 144 void ndpRouterAdvTick(NdpRouterAdvContext *context);
Sergunb 0:8918a71cdbe9 145 void ndpRouterAdvLinkChangeEvent(NdpRouterAdvContext *context);
Sergunb 0:8918a71cdbe9 146
Sergunb 0:8918a71cdbe9 147 void ndpProcessRouterSol(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader,
Sergunb 0:8918a71cdbe9 148 const NetBuffer *buffer, size_t offset, uint8_t hopLimit);
Sergunb 0:8918a71cdbe9 149
Sergunb 0:8918a71cdbe9 150 error_t ndpSendRouterAdv(NdpRouterAdvContext *context, uint16_t routerLifetime);
Sergunb 0:8918a71cdbe9 151
Sergunb 0:8918a71cdbe9 152 #endif
Sergunb 0:8918a71cdbe9 153