Webserver+3d print

Dependents:   Nucleo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers dhcpv6_relay.h Source File

dhcpv6_relay.h

Go to the documentation of this file.
00001 /**
00002  * @file dhcpv6_relay.h
00003  * @brief DHCPv6 relay agent (Dynamic Host Configuration Protocol for IPv6)
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 _DHCPV6_RELAY_H
00030 #define _DHCPV6_RELAY_H
00031 
00032 //Dependencies
00033 #include "dhcpv6/dhcpv6_common.h"
00034 #include "core/socket.h"
00035 
00036 //DHCPv6 relay agent support
00037 #ifndef DHCPV6_RELAY_SUPPORT
00038    #define DHCPV6_RELAY_SUPPORT ENABLED
00039 #elif (DHCPV6_RELAY_SUPPORT != ENABLED && DHCPV6_RELAY_SUPPORT != DISABLED)
00040    #error DHCPV6_RELAY_SUPPORT parameter is not valid
00041 #endif
00042 
00043 //Stack size required to run the DHCPv6 relay agent
00044 #ifndef DHCPV6_RELAY_STACK_SIZE
00045    #define DHCPV6_RELAY_STACK_SIZE 500
00046 #elif (DHCPV6_RELAY_STACK_SIZE < 1)
00047    #error DHCPV6_RELAY_STACK_SIZE parameter is not valid
00048 #endif
00049 
00050 //Priority at which the DHCPv6 relay agent should run
00051 #ifndef DHCPV6_RELAY_PRIORITY
00052    #define DHCPV6_RELAY_PRIORITY OS_TASK_PRIORITY_NORMAL
00053 #endif
00054 
00055 //Maximum number of client-facing interfaces
00056 #ifndef DHCPV6_RELAY_MAX_CLIENT_IF
00057    #define DHCPV6_RELAY_MAX_CLIENT_IF 4
00058 #elif (DHCPV6_RELAY_MAX_CLIENT_IF < 1)
00059    #error DHCPV6_RELAY_MAX_CLIENT_IF parameter is not valid
00060 #endif
00061 
00062 //The amount of overhead added by relay forwarding
00063 #define DHCPV6_RELAY_FORW_OVERHEAD (sizeof(Dhcpv6RelayMessage) + 2 * sizeof(Dhcpv6Option) + sizeof(uint32_t))
00064 
00065 
00066 /**
00067  * @brief DHCPv6 relay agent settings
00068  **/
00069 
00070 typedef struct
00071 {
00072    NetInterface *serverInterface;                             ///<Network-facing interface
00073    NetInterface *clientInterface[DHCPV6_RELAY_MAX_CLIENT_IF]; ///<Client-facing interfaces
00074    uint_t clientInterfaceCount;                               ///<Number of client-facing interfaces
00075    Ipv6Addr serverAddress;                                    ///<Address to be used when relaying messages to the server
00076 } Dhcpv6RelaySettings;
00077 
00078 
00079 /**
00080  * @brief DHCPv6 relay agent context
00081  **/
00082 
00083 typedef struct
00084 {
00085    NetInterface *serverInterface;                             ///<Network-facing interface
00086    NetInterface *clientInterface[DHCPV6_RELAY_MAX_CLIENT_IF]; ///<Client-facing interfaces
00087    uint_t clientInterfaceCount;                               ///<Number of client-facing interfaces
00088    Ipv6Addr serverAddress;                                    ///<Address to be used when relaying messages to the server
00089    Socket *serverSocket;                                      ///<Socket that handles the network-facing interface
00090    Socket *clientSocket[DHCPV6_RELAY_MAX_CLIENT_IF];          ///<Sockets that handle client-facing interfaces
00091    SocketEventDesc eventDesc[DHCPV6_RELAY_MAX_CLIENT_IF];     ///<The events the application is interested in
00092    bool_t running;                                            ///<DHCPv6 relay agent is currently running or not?
00093    bool_t stopRequest;                                        ///<Stop request
00094    OsEvent ackEvent;                                          ///<Event object use to acknowledge user requests
00095    OsEvent event;                                             ///<Event object used to poll the sockets
00096    uint8_t buffer[DHCPV6_MAX_MSG_SIZE];                       ///<Scratch buffer to store DHCPv6 messages
00097 } Dhcpv6RelayContext;
00098 
00099 
00100 //DHCPv6 relay agent specific functions
00101 error_t dhcpv6RelayStart(Dhcpv6RelayContext *context, const Dhcpv6RelaySettings *settings);
00102 error_t dhcpv6RelayStop(Dhcpv6RelayContext *context);
00103 
00104 error_t dhcpv6RelayJoinMulticastGroup(Dhcpv6RelayContext *context);
00105 error_t dhcpv6RelayLeaveMulticastGroup(Dhcpv6RelayContext *context);
00106 
00107 void dhcpv6RelayTask(void *param);
00108 
00109 error_t dhcpv6ForwardClientMessage(Dhcpv6RelayContext *context, uint_t index);
00110 error_t dhcpv6ForwardRelayReplyMessage(Dhcpv6RelayContext *context);
00111 
00112 #endif
00113