Sergey Pastor / 1

Dependents:   Nucleo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers slaac.h Source File

slaac.h

Go to the documentation of this file.
00001 /**
00002  * @file slaac.h
00003  * @brief IPv6 Stateless Address Autoconfiguration
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 _SLAAC_H
00030 #define _SLAAC_H
00031 
00032 //Dependencies
00033 #include "core/net.h"
00034 #include "ipv6/ndp.h"
00035 
00036 //SLAAC support
00037 #ifndef SLAAC_SUPPORT
00038    #define SLAAC_SUPPORT ENABLED
00039 #elif (SLAAC_SUPPORT != ENABLED && SLAAC_SUPPORT != DISABLED)
00040    #error SLAAC_SUPPORT parameter is not valid
00041 #endif
00042 
00043 //Time constant
00044 #define SLAAC_LIFETIME_2_HOURS (2 * 3600 * 1000)
00045 
00046 //Forward declaration of SlaacContext structure
00047 struct _SlaacContext;
00048 #define SlaacContext struct _SlaacContext
00049 
00050 
00051 /**
00052  * @brief Link state change callback
00053  **/
00054 
00055 typedef void (*SlaacLinkChangeCallback)(SlaacContext *context,
00056    NetInterface *interface, bool_t linkState);
00057 
00058 
00059 /**
00060  * @brief Router Advertisement parsing callback
00061  **/
00062 
00063 typedef void (*SlaacParseRouterAdvCallback)(SlaacContext *context,
00064    NdpRouterAdvMessage *message, size_t length);
00065 
00066 
00067 /**
00068  * @brief SLAAC settings
00069  **/
00070 
00071 typedef struct
00072 {
00073    NetInterface *interface;                            ///<Network interface to configure
00074    bool_t manualDnsConfig;                             ///<Force manual DNS configuration
00075    SlaacLinkChangeCallback linkChangeEvent;            ///<Link state change event
00076    SlaacParseRouterAdvCallback parseRouterAdvCallback; ///<Router Advertisement parsing callback
00077 } SlaacSettings;
00078 
00079 
00080 /**
00081  * @brief SLAAC context
00082  **/
00083 
00084 struct _SlaacContext
00085 {
00086    SlaacSettings settings; ///<SLAAC settings
00087    bool_t running;         ///<SLAAC is currently running
00088    bool_t configUpdated;   ///<This flag is set when IPv6 configuration has been updated
00089 };
00090 
00091 
00092 //SLAAC related functions
00093 void slaacGetDefaultSettings(SlaacSettings *settings);
00094 error_t slaacInit(SlaacContext *context, const SlaacSettings *settings);
00095 error_t slaacStart(SlaacContext *context);
00096 error_t slaacStop(SlaacContext *context);
00097 
00098 void slaacLinkChangeEvent(SlaacContext *context);
00099 
00100 void slaacParseRouterAdv(SlaacContext *context,
00101    NdpRouterAdvMessage *message, size_t length);
00102 
00103 void slaacParsePrefixInfoOption(SlaacContext *context,
00104    NdpPrefixInfoOption *option);
00105 
00106 error_t slaacGenerateLinkLocalAddr(SlaacContext *context);
00107 
00108 void slaacDumpConfig(SlaacContext *context);
00109 
00110 #endif
00111