Webserver+3d print
cyclone_tcp/dhcpv6/dhcpv6_relay.h@0:8918a71cdbe9, 2017-02-04 (annotated)
- Committer:
- Sergunb
- Date:
- Sat Feb 04 18:15:49 2017 +0000
- Revision:
- 0:8918a71cdbe9
nothing else
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Sergunb | 0:8918a71cdbe9 | 1 | /** |
Sergunb | 0:8918a71cdbe9 | 2 | * @file dhcpv6_relay.h |
Sergunb | 0:8918a71cdbe9 | 3 | * @brief DHCPv6 relay agent (Dynamic Host Configuration Protocol for IPv6) |
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 _DHCPV6_RELAY_H |
Sergunb | 0:8918a71cdbe9 | 30 | #define _DHCPV6_RELAY_H |
Sergunb | 0:8918a71cdbe9 | 31 | |
Sergunb | 0:8918a71cdbe9 | 32 | //Dependencies |
Sergunb | 0:8918a71cdbe9 | 33 | #include "dhcpv6/dhcpv6_common.h" |
Sergunb | 0:8918a71cdbe9 | 34 | #include "core/socket.h" |
Sergunb | 0:8918a71cdbe9 | 35 | |
Sergunb | 0:8918a71cdbe9 | 36 | //DHCPv6 relay agent support |
Sergunb | 0:8918a71cdbe9 | 37 | #ifndef DHCPV6_RELAY_SUPPORT |
Sergunb | 0:8918a71cdbe9 | 38 | #define DHCPV6_RELAY_SUPPORT ENABLED |
Sergunb | 0:8918a71cdbe9 | 39 | #elif (DHCPV6_RELAY_SUPPORT != ENABLED && DHCPV6_RELAY_SUPPORT != DISABLED) |
Sergunb | 0:8918a71cdbe9 | 40 | #error DHCPV6_RELAY_SUPPORT parameter is not valid |
Sergunb | 0:8918a71cdbe9 | 41 | #endif |
Sergunb | 0:8918a71cdbe9 | 42 | |
Sergunb | 0:8918a71cdbe9 | 43 | //Stack size required to run the DHCPv6 relay agent |
Sergunb | 0:8918a71cdbe9 | 44 | #ifndef DHCPV6_RELAY_STACK_SIZE |
Sergunb | 0:8918a71cdbe9 | 45 | #define DHCPV6_RELAY_STACK_SIZE 500 |
Sergunb | 0:8918a71cdbe9 | 46 | #elif (DHCPV6_RELAY_STACK_SIZE < 1) |
Sergunb | 0:8918a71cdbe9 | 47 | #error DHCPV6_RELAY_STACK_SIZE parameter is not valid |
Sergunb | 0:8918a71cdbe9 | 48 | #endif |
Sergunb | 0:8918a71cdbe9 | 49 | |
Sergunb | 0:8918a71cdbe9 | 50 | //Priority at which the DHCPv6 relay agent should run |
Sergunb | 0:8918a71cdbe9 | 51 | #ifndef DHCPV6_RELAY_PRIORITY |
Sergunb | 0:8918a71cdbe9 | 52 | #define DHCPV6_RELAY_PRIORITY OS_TASK_PRIORITY_NORMAL |
Sergunb | 0:8918a71cdbe9 | 53 | #endif |
Sergunb | 0:8918a71cdbe9 | 54 | |
Sergunb | 0:8918a71cdbe9 | 55 | //Maximum number of client-facing interfaces |
Sergunb | 0:8918a71cdbe9 | 56 | #ifndef DHCPV6_RELAY_MAX_CLIENT_IF |
Sergunb | 0:8918a71cdbe9 | 57 | #define DHCPV6_RELAY_MAX_CLIENT_IF 4 |
Sergunb | 0:8918a71cdbe9 | 58 | #elif (DHCPV6_RELAY_MAX_CLIENT_IF < 1) |
Sergunb | 0:8918a71cdbe9 | 59 | #error DHCPV6_RELAY_MAX_CLIENT_IF parameter is not valid |
Sergunb | 0:8918a71cdbe9 | 60 | #endif |
Sergunb | 0:8918a71cdbe9 | 61 | |
Sergunb | 0:8918a71cdbe9 | 62 | //The amount of overhead added by relay forwarding |
Sergunb | 0:8918a71cdbe9 | 63 | #define DHCPV6_RELAY_FORW_OVERHEAD (sizeof(Dhcpv6RelayMessage) + 2 * sizeof(Dhcpv6Option) + sizeof(uint32_t)) |
Sergunb | 0:8918a71cdbe9 | 64 | |
Sergunb | 0:8918a71cdbe9 | 65 | |
Sergunb | 0:8918a71cdbe9 | 66 | /** |
Sergunb | 0:8918a71cdbe9 | 67 | * @brief DHCPv6 relay agent settings |
Sergunb | 0:8918a71cdbe9 | 68 | **/ |
Sergunb | 0:8918a71cdbe9 | 69 | |
Sergunb | 0:8918a71cdbe9 | 70 | typedef struct |
Sergunb | 0:8918a71cdbe9 | 71 | { |
Sergunb | 0:8918a71cdbe9 | 72 | NetInterface *serverInterface; ///<Network-facing interface |
Sergunb | 0:8918a71cdbe9 | 73 | NetInterface *clientInterface[DHCPV6_RELAY_MAX_CLIENT_IF]; ///<Client-facing interfaces |
Sergunb | 0:8918a71cdbe9 | 74 | uint_t clientInterfaceCount; ///<Number of client-facing interfaces |
Sergunb | 0:8918a71cdbe9 | 75 | Ipv6Addr serverAddress; ///<Address to be used when relaying messages to the server |
Sergunb | 0:8918a71cdbe9 | 76 | } Dhcpv6RelaySettings; |
Sergunb | 0:8918a71cdbe9 | 77 | |
Sergunb | 0:8918a71cdbe9 | 78 | |
Sergunb | 0:8918a71cdbe9 | 79 | /** |
Sergunb | 0:8918a71cdbe9 | 80 | * @brief DHCPv6 relay agent context |
Sergunb | 0:8918a71cdbe9 | 81 | **/ |
Sergunb | 0:8918a71cdbe9 | 82 | |
Sergunb | 0:8918a71cdbe9 | 83 | typedef struct |
Sergunb | 0:8918a71cdbe9 | 84 | { |
Sergunb | 0:8918a71cdbe9 | 85 | NetInterface *serverInterface; ///<Network-facing interface |
Sergunb | 0:8918a71cdbe9 | 86 | NetInterface *clientInterface[DHCPV6_RELAY_MAX_CLIENT_IF]; ///<Client-facing interfaces |
Sergunb | 0:8918a71cdbe9 | 87 | uint_t clientInterfaceCount; ///<Number of client-facing interfaces |
Sergunb | 0:8918a71cdbe9 | 88 | Ipv6Addr serverAddress; ///<Address to be used when relaying messages to the server |
Sergunb | 0:8918a71cdbe9 | 89 | Socket *serverSocket; ///<Socket that handles the network-facing interface |
Sergunb | 0:8918a71cdbe9 | 90 | Socket *clientSocket[DHCPV6_RELAY_MAX_CLIENT_IF]; ///<Sockets that handle client-facing interfaces |
Sergunb | 0:8918a71cdbe9 | 91 | SocketEventDesc eventDesc[DHCPV6_RELAY_MAX_CLIENT_IF]; ///<The events the application is interested in |
Sergunb | 0:8918a71cdbe9 | 92 | bool_t running; ///<DHCPv6 relay agent is currently running or not? |
Sergunb | 0:8918a71cdbe9 | 93 | bool_t stopRequest; ///<Stop request |
Sergunb | 0:8918a71cdbe9 | 94 | OsEvent ackEvent; ///<Event object use to acknowledge user requests |
Sergunb | 0:8918a71cdbe9 | 95 | OsEvent event; ///<Event object used to poll the sockets |
Sergunb | 0:8918a71cdbe9 | 96 | uint8_t buffer[DHCPV6_MAX_MSG_SIZE]; ///<Scratch buffer to store DHCPv6 messages |
Sergunb | 0:8918a71cdbe9 | 97 | } Dhcpv6RelayContext; |
Sergunb | 0:8918a71cdbe9 | 98 | |
Sergunb | 0:8918a71cdbe9 | 99 | |
Sergunb | 0:8918a71cdbe9 | 100 | //DHCPv6 relay agent specific functions |
Sergunb | 0:8918a71cdbe9 | 101 | error_t dhcpv6RelayStart(Dhcpv6RelayContext *context, const Dhcpv6RelaySettings *settings); |
Sergunb | 0:8918a71cdbe9 | 102 | error_t dhcpv6RelayStop(Dhcpv6RelayContext *context); |
Sergunb | 0:8918a71cdbe9 | 103 | |
Sergunb | 0:8918a71cdbe9 | 104 | error_t dhcpv6RelayJoinMulticastGroup(Dhcpv6RelayContext *context); |
Sergunb | 0:8918a71cdbe9 | 105 | error_t dhcpv6RelayLeaveMulticastGroup(Dhcpv6RelayContext *context); |
Sergunb | 0:8918a71cdbe9 | 106 | |
Sergunb | 0:8918a71cdbe9 | 107 | void dhcpv6RelayTask(void *param); |
Sergunb | 0:8918a71cdbe9 | 108 | |
Sergunb | 0:8918a71cdbe9 | 109 | error_t dhcpv6ForwardClientMessage(Dhcpv6RelayContext *context, uint_t index); |
Sergunb | 0:8918a71cdbe9 | 110 | error_t dhcpv6ForwardRelayReplyMessage(Dhcpv6RelayContext *context); |
Sergunb | 0:8918a71cdbe9 | 111 | |
Sergunb | 0:8918a71cdbe9 | 112 | #endif |
Sergunb | 0:8918a71cdbe9 | 113 |