dhcpv6_relay.h
Go to the documentation of this file.
1 /**
2  * @file dhcpv6_relay.h
3  * @brief DHCPv6 relay agent (Dynamic Host Configuration Protocol for IPv6)
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 _DHCPV6_RELAY_H
30 #define _DHCPV6_RELAY_H
31 
32 //Dependencies
33 #include "dhcpv6/dhcpv6_common.h"
34 #include "core/socket.h"
35 
36 //DHCPv6 relay agent support
37 #ifndef DHCPV6_RELAY_SUPPORT
38  #define DHCPV6_RELAY_SUPPORT ENABLED
39 #elif (DHCPV6_RELAY_SUPPORT != ENABLED && DHCPV6_RELAY_SUPPORT != DISABLED)
40  #error DHCPV6_RELAY_SUPPORT parameter is not valid
41 #endif
42 
43 //Stack size required to run the DHCPv6 relay agent
44 #ifndef DHCPV6_RELAY_STACK_SIZE
45  #define DHCPV6_RELAY_STACK_SIZE 500
46 #elif (DHCPV6_RELAY_STACK_SIZE < 1)
47  #error DHCPV6_RELAY_STACK_SIZE parameter is not valid
48 #endif
49 
50 //Priority at which the DHCPv6 relay agent should run
51 #ifndef DHCPV6_RELAY_PRIORITY
52  #define DHCPV6_RELAY_PRIORITY OS_TASK_PRIORITY_NORMAL
53 #endif
54 
55 //Maximum number of client-facing interfaces
56 #ifndef DHCPV6_RELAY_MAX_CLIENT_IF
57  #define DHCPV6_RELAY_MAX_CLIENT_IF 4
58 #elif (DHCPV6_RELAY_MAX_CLIENT_IF < 1)
59  #error DHCPV6_RELAY_MAX_CLIENT_IF parameter is not valid
60 #endif
61 
62 //The amount of overhead added by relay forwarding
63 #define DHCPV6_RELAY_FORW_OVERHEAD (sizeof(Dhcpv6RelayMessage) + 2 * sizeof(Dhcpv6Option) + sizeof(uint32_t))
64 
65 //C++ guard
66 #ifdef __cplusplus
67  extern "C" {
68 #endif
69 
70 
71 /**
72  * @brief DHCPv6 relay agent settings
73  **/
74 
75 typedef struct
76 {
77  NetInterface *serverInterface; ///<Network-facing interface
78  NetInterface *clientInterface[DHCPV6_RELAY_MAX_CLIENT_IF]; ///<Client-facing interfaces
79  uint_t clientInterfaceCount; ///<Number of client-facing interfaces
80  Ipv6Addr serverAddress; ///<Address to be used when relaying messages to the server
82 
83 
84 /**
85  * @brief DHCPv6 relay agent context
86  **/
87 
88 typedef struct
89 {
90  NetInterface *serverInterface; ///<Network-facing interface
91  NetInterface *clientInterface[DHCPV6_RELAY_MAX_CLIENT_IF]; ///<Client-facing interfaces
92  uint_t clientInterfaceCount; ///<Number of client-facing interfaces
93  Ipv6Addr serverAddress; ///<Address to be used when relaying messages to the server
94  Socket *serverSocket; ///<Socket that handles the network-facing interface
95  Socket *clientSocket[DHCPV6_RELAY_MAX_CLIENT_IF]; ///<Sockets that handle client-facing interfaces
96  SocketEventDesc eventDesc[DHCPV6_RELAY_MAX_CLIENT_IF]; ///<The events the application is interested in
97  bool_t running; ///<DHCPv6 relay agent is currently running or not?
98  bool_t stopRequest; ///<Stop request
99  OsEvent ackEvent; ///<Event object use to acknowledge user requests
100  OsEvent event; ///<Event object used to poll the sockets
101  uint8_t buffer[DHCPV6_MAX_MSG_SIZE]; ///<Scratch buffer to store DHCPv6 messages
103 
104 
105 //DHCPv6 relay agent specific functions
108 
111 
112 void dhcpv6RelayTask(void *param);
113 
116 
117 //C++ guard
118 #ifdef __cplusplus
119  }
120 #endif
121 
122 #endif
bool_t running
DHCPv6 relay agent is currently running or not?
Definition: dhcpv6_relay.h:97
NetInterface * serverInterface
Network-facing interface.
Definition: dhcpv6_relay.h:90
error_t dhcpv6RelayStop(Dhcpv6RelayContext *context)
Stop DHCPv6 relay agent.
Definition: dhcpv6_relay.c:245
uint_t clientInterfaceCount
Number of client-facing interfaces.
Definition: dhcpv6_relay.h:92
NetInterface * serverInterface
Network-facing interface.
Definition: dhcpv6_relay.h:77
void dhcpv6RelayTask(void *param)
DHCPv6 relay agent task.
Definition: dhcpv6_relay.c:359
__start_packed struct @183 Ipv6Addr
IPv6 network address.
error_t dhcpv6ForwardClientMessage(Dhcpv6RelayContext *context, uint_t index)
Forward client message.
Definition: dhcpv6_relay.c:428
uint_t clientInterfaceCount
Number of client-facing interfaces.
Definition: dhcpv6_relay.h:79
Event object.
error_t dhcpv6RelayLeaveMulticastGroup(Dhcpv6RelayContext *context)
Leave All_DHCP_Relay_Agents_and_Servers multicast group.
Definition: dhcpv6_relay.c:336
DHCPv6 relay agent settings.
Definition: dhcpv6_relay.h:75
OsEvent ackEvent
Event object use to acknowledge user requests.
Definition: dhcpv6_relay.h:99
#define Socket
Definition: socket.h:34
Definitions common to DHCPv6 client, server and relay agent.
Ipv6Addr serverAddress
Address to be used when relaying messages to the server.
Definition: dhcpv6_relay.h:93
OsEvent event
Event object used to poll the sockets.
Definition: dhcpv6_relay.h:100
#define DHCPV6_RELAY_MAX_CLIENT_IF
Definition: dhcpv6_relay.h:57
Ipv6Addr serverAddress
Address to be used when relaying messages to the server.
Definition: dhcpv6_relay.h:80
error_t dhcpv6RelayJoinMulticastGroup(Dhcpv6RelayContext *context)
Join All_DHCP_Relay_Agents_and_Servers multicast group.
Definition: dhcpv6_relay.c:294
Structure describing socket events.
Definition: socket.h:303
error_t
Error codes.
Definition: error.h:40
unsigned int uint_t
Definition: compiler_port.h:43
#define NetInterface
Definition: net.h:34
error_t dhcpv6ForwardRelayReplyMessage(Dhcpv6RelayContext *context)
Forward Relay-Reply message.
Definition: dhcpv6_relay.c:557
DHCPv6 relay agent context.
Definition: dhcpv6_relay.h:88
#define DHCPV6_MAX_MSG_SIZE
Definition: dhcpv6_common.h:42
bool_t stopRequest
Stop request.
Definition: dhcpv6_relay.h:98
Socket API.
error_t dhcpv6RelayStart(Dhcpv6RelayContext *context, const Dhcpv6RelaySettings *settings)
Start DHCPv6 relay agent.
Definition: dhcpv6_relay.c:56
int bool_t
Definition: compiler_port.h:47
Socket * serverSocket
Socket that handles the network-facing interface.
Definition: dhcpv6_relay.h:94