slaac.h
Go to the documentation of this file.
1 /**
2  * @file slaac.h
3  * @brief IPv6 Stateless Address Autoconfiguration
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 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 2.4.4
29  **/
30 
31 #ifndef _SLAAC_H
32 #define _SLAAC_H
33 
34 //Dependencies
35 #include "core/net.h"
36 #include "ipv6/ndp.h"
37 
38 //SLAAC support
39 #ifndef SLAAC_SUPPORT
40  #define SLAAC_SUPPORT ENABLED
41 #elif (SLAAC_SUPPORT != ENABLED && SLAAC_SUPPORT != DISABLED)
42  #error SLAAC_SUPPORT parameter is not valid
43 #endif
44 
45 //Time constant
46 #define SLAAC_LIFETIME_2_HOURS (2 * 3600 * 1000)
47 
48 //Forward declaration of SlaacContext structure
49 struct _SlaacContext;
50 #define SlaacContext struct _SlaacContext
51 
52 //C++ guard
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
57 
58 /**
59  * @brief Link state change callback
60  **/
61 
62 typedef void (*SlaacLinkChangeCallback)(SlaacContext *context,
63  NetInterface *interface, bool_t linkState);
64 
65 
66 /**
67  * @brief Router Advertisement parsing callback
68  **/
69 
70 typedef void (*SlaacParseRouterAdvCallback)(SlaacContext *context,
72 
73 
74 /**
75  * @brief SLAAC settings
76  **/
77 
78 typedef struct
79 {
80  NetInterface *interface; ///<Network interface to configure
81  bool_t manualDnsConfig; ///<Force manual DNS configuration
82  SlaacLinkChangeCallback linkChangeEvent; ///<Link state change event
83  SlaacParseRouterAdvCallback parseRouterAdvCallback; ///<Router Advertisement parsing callback
85 
86 
87 /**
88  * @brief SLAAC context
89  **/
90 
92 {
93  SlaacSettings settings; ///<SLAAC settings
94  bool_t running; ///<SLAAC is currently running
95  bool_t configUpdated; ///<This flag is set when IPv6 configuration has been updated
96 };
97 
98 
99 //SLAAC related functions
100 void slaacGetDefaultSettings(SlaacSettings *settings);
101 error_t slaacInit(SlaacContext *context, const SlaacSettings *settings);
102 
104 error_t slaacStop(SlaacContext *context);
105 
106 //C++ guard
107 #ifdef __cplusplus
108 }
109 #endif
110 
111 #endif
int bool_t
Definition: compiler_port.h:53
void slaacGetDefaultSettings(SlaacSettings *settings)
Initialize settings with default values.
Definition: slaac.c:60
uint8_t message[]
Definition: chap.h:154
SlaacLinkChangeCallback linkChangeEvent
Link state change event.
Definition: slaac.h:82
bool_t running
SLAAC is currently running.
Definition: slaac.h:94
SlaacParseRouterAdvCallback parseRouterAdvCallback
Router Advertisement parsing callback.
Definition: slaac.h:83
error_t slaacStart(SlaacContext *context)
Start SLAAC process.
Definition: slaac.c:121
bool_t configUpdated
This flag is set when IPv6 configuration has been updated.
Definition: slaac.h:95
#define SlaacContext
Definition: slaac.h:50
NdpRouterAdvMessage
Definition: ndp.h:310
error_t
Error codes.
Definition: error.h:43
#define NetInterface
Definition: net.h:36
uint8_t length
Definition: tcp.h:368
bool_t manualDnsConfig
Force manual DNS configuration.
Definition: slaac.h:81
error_t slaacStop(SlaacContext *context)
Stop SLAAC process.
Definition: slaac.c:173
NDP (Neighbor Discovery Protocol)
void(* SlaacParseRouterAdvCallback)(SlaacContext *context, NdpRouterAdvMessage *message, size_t length)
Router Advertisement parsing callback.
Definition: slaac.h:70
error_t slaacInit(SlaacContext *context, const SlaacSettings *settings)
SLAAC initialization.
Definition: slaac.c:81
void(* SlaacLinkChangeCallback)(SlaacContext *context, NetInterface *interface, bool_t linkState)
Link state change callback.
Definition: slaac.h:62
NetInterface * interface
Network interface to configure.
Definition: slaac.h:80
TCP/IP stack core.
SlaacSettings settings
SLAAC settings.
Definition: slaac.h:93
SLAAC context.
Definition: slaac.h:92
SLAAC settings.
Definition: slaac.h:79