Webserver+3d print
cyclone_tcp/dhcpv6/dhcpv6_common.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_common.h |
Sergunb | 0:8918a71cdbe9 | 3 | * @brief Functions common to DHCPv6 client, server and relay agent |
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_COMMON_H |
Sergunb | 0:8918a71cdbe9 | 30 | #define _DHCPV6_COMMON_H |
Sergunb | 0:8918a71cdbe9 | 31 | |
Sergunb | 0:8918a71cdbe9 | 32 | //Dependencies |
Sergunb | 0:8918a71cdbe9 | 33 | #include "core/net.h" |
Sergunb | 0:8918a71cdbe9 | 34 | #include "core/ethernet.h" |
Sergunb | 0:8918a71cdbe9 | 35 | #include "ipv6/ipv6.h" |
Sergunb | 0:8918a71cdbe9 | 36 | |
Sergunb | 0:8918a71cdbe9 | 37 | //UDP ports used by DHCPv6 clients and servers |
Sergunb | 0:8918a71cdbe9 | 38 | #define DHCPV6_CLIENT_PORT 546 |
Sergunb | 0:8918a71cdbe9 | 39 | #define DHCPV6_SERVER_PORT 547 |
Sergunb | 0:8918a71cdbe9 | 40 | |
Sergunb | 0:8918a71cdbe9 | 41 | //Maximum DHCPv6 message size |
Sergunb | 0:8918a71cdbe9 | 42 | #define DHCPV6_MAX_MSG_SIZE 1232 |
Sergunb | 0:8918a71cdbe9 | 43 | //Maximum DUID size (128 octets not including the type code) |
Sergunb | 0:8918a71cdbe9 | 44 | #define DHCPV6_MAX_DUID_SIZE 130 |
Sergunb | 0:8918a71cdbe9 | 45 | |
Sergunb | 0:8918a71cdbe9 | 46 | //Maximum hop count in a relay-forward message |
Sergunb | 0:8918a71cdbe9 | 47 | #define DHCPV6_HOP_COUNT_LIMIT 32 |
Sergunb | 0:8918a71cdbe9 | 48 | //Highest server preference value |
Sergunb | 0:8918a71cdbe9 | 49 | #define DHCPV6_MAX_SERVER_PREFERENCE 255 |
Sergunb | 0:8918a71cdbe9 | 50 | //Infinite lifetime representation |
Sergunb | 0:8918a71cdbe9 | 51 | #define DHCPV6_INFINITE_TIME 0xFFFFFFFF |
Sergunb | 0:8918a71cdbe9 | 52 | |
Sergunb | 0:8918a71cdbe9 | 53 | |
Sergunb | 0:8918a71cdbe9 | 54 | /** |
Sergunb | 0:8918a71cdbe9 | 55 | * @brief DUID types |
Sergunb | 0:8918a71cdbe9 | 56 | **/ |
Sergunb | 0:8918a71cdbe9 | 57 | |
Sergunb | 0:8918a71cdbe9 | 58 | typedef enum |
Sergunb | 0:8918a71cdbe9 | 59 | { |
Sergunb | 0:8918a71cdbe9 | 60 | DHCPV6_DUID_LLT = 1, |
Sergunb | 0:8918a71cdbe9 | 61 | DHCPV6_DUID_EN = 2, |
Sergunb | 0:8918a71cdbe9 | 62 | DHCPV6_DUID_LL = 3 |
Sergunb | 0:8918a71cdbe9 | 63 | } Dhcpv6DuidType; |
Sergunb | 0:8918a71cdbe9 | 64 | |
Sergunb | 0:8918a71cdbe9 | 65 | |
Sergunb | 0:8918a71cdbe9 | 66 | /** |
Sergunb | 0:8918a71cdbe9 | 67 | * @brief Hardware types |
Sergunb | 0:8918a71cdbe9 | 68 | **/ |
Sergunb | 0:8918a71cdbe9 | 69 | |
Sergunb | 0:8918a71cdbe9 | 70 | typedef enum |
Sergunb | 0:8918a71cdbe9 | 71 | { |
Sergunb | 0:8918a71cdbe9 | 72 | DHCPV6_HARDWARE_TYPE_ETH = 1, |
Sergunb | 0:8918a71cdbe9 | 73 | DHCPV6_HARDWARE_TYPE_EUI64 = 27 |
Sergunb | 0:8918a71cdbe9 | 74 | } Dhcpv6HardwareType; |
Sergunb | 0:8918a71cdbe9 | 75 | |
Sergunb | 0:8918a71cdbe9 | 76 | |
Sergunb | 0:8918a71cdbe9 | 77 | /** |
Sergunb | 0:8918a71cdbe9 | 78 | * @brief DHCPv6 message types |
Sergunb | 0:8918a71cdbe9 | 79 | **/ |
Sergunb | 0:8918a71cdbe9 | 80 | |
Sergunb | 0:8918a71cdbe9 | 81 | typedef enum |
Sergunb | 0:8918a71cdbe9 | 82 | { |
Sergunb | 0:8918a71cdbe9 | 83 | DHCPV6_MSG_TYPE_SOLICIT = 1, |
Sergunb | 0:8918a71cdbe9 | 84 | DHCPV6_MSG_TYPE_ADVERTISE = 2, |
Sergunb | 0:8918a71cdbe9 | 85 | DHCPV6_MSG_TYPE_REQUEST = 3, |
Sergunb | 0:8918a71cdbe9 | 86 | DHCPV6_MSG_TYPE_CONFIRM = 4, |
Sergunb | 0:8918a71cdbe9 | 87 | DHCPV6_MSG_TYPE_RENEW = 5, |
Sergunb | 0:8918a71cdbe9 | 88 | DHCPV6_MSG_TYPE_REBIND = 6, |
Sergunb | 0:8918a71cdbe9 | 89 | DHCPV6_MSG_TYPE_REPLY = 7, |
Sergunb | 0:8918a71cdbe9 | 90 | DHCPV6_MSG_TYPE_RELEASE = 8, |
Sergunb | 0:8918a71cdbe9 | 91 | DHCPV6_MSG_TYPE_DECLINE = 9, |
Sergunb | 0:8918a71cdbe9 | 92 | DHCPV6_MSG_TYPE_RECONFIGURE = 10, |
Sergunb | 0:8918a71cdbe9 | 93 | DHCPV6_MSG_TYPE_INFO_REQUEST = 11, |
Sergunb | 0:8918a71cdbe9 | 94 | DHCPV6_MSG_TYPE_RELAY_FORW = 12, |
Sergunb | 0:8918a71cdbe9 | 95 | DHCPV6_MSG_TYPE_RELAY_REPL = 13 |
Sergunb | 0:8918a71cdbe9 | 96 | } Dhcpv6MessageType; |
Sergunb | 0:8918a71cdbe9 | 97 | |
Sergunb | 0:8918a71cdbe9 | 98 | |
Sergunb | 0:8918a71cdbe9 | 99 | /** |
Sergunb | 0:8918a71cdbe9 | 100 | * @brief DHCPv6 option codes |
Sergunb | 0:8918a71cdbe9 | 101 | **/ |
Sergunb | 0:8918a71cdbe9 | 102 | |
Sergunb | 0:8918a71cdbe9 | 103 | typedef enum |
Sergunb | 0:8918a71cdbe9 | 104 | { |
Sergunb | 0:8918a71cdbe9 | 105 | DHCPV6_OPTION_CLIENTID = 1, |
Sergunb | 0:8918a71cdbe9 | 106 | DHCPV6_OPTION_SERVERID = 2, |
Sergunb | 0:8918a71cdbe9 | 107 | DHCPV6_OPTION_IA_NA = 3, |
Sergunb | 0:8918a71cdbe9 | 108 | DHCPV6_OPTION_IA_TA = 4, |
Sergunb | 0:8918a71cdbe9 | 109 | DHCPV6_OPTION_IAADDR = 5, |
Sergunb | 0:8918a71cdbe9 | 110 | DHCPV6_OPTION_ORO = 6, |
Sergunb | 0:8918a71cdbe9 | 111 | DHCPV6_OPTION_PREFERENCE = 7, |
Sergunb | 0:8918a71cdbe9 | 112 | DHCPV6_OPTION_ELAPSED_TIME = 8, |
Sergunb | 0:8918a71cdbe9 | 113 | DHCPV6_OPTION_RELAY_MSG = 9, |
Sergunb | 0:8918a71cdbe9 | 114 | DHCPV6_OPTION_AUTH = 11, |
Sergunb | 0:8918a71cdbe9 | 115 | DHCPV6_OPTION_UNICAST = 12, |
Sergunb | 0:8918a71cdbe9 | 116 | DHCPV6_OPTION_STATUS_CODE = 13, |
Sergunb | 0:8918a71cdbe9 | 117 | DHCPV6_OPTION_RAPID_COMMIT = 14, |
Sergunb | 0:8918a71cdbe9 | 118 | DHCPV6_OPTION_USER_CLASS = 15, |
Sergunb | 0:8918a71cdbe9 | 119 | DHCPV6_OPTION_VENDOR_CLASS = 16, |
Sergunb | 0:8918a71cdbe9 | 120 | DHCPV6_OPTION_VENDOR_OPTS = 17, |
Sergunb | 0:8918a71cdbe9 | 121 | DHCPV6_OPTION_INTERFACE_ID = 18, |
Sergunb | 0:8918a71cdbe9 | 122 | DHCPV6_OPTION_RECONF_MSG = 19, |
Sergunb | 0:8918a71cdbe9 | 123 | DHCPV6_OPTION_RECONF_ACCEPT = 20, |
Sergunb | 0:8918a71cdbe9 | 124 | DHCPV6_OPTION_DNS_SERVERS = 23, |
Sergunb | 0:8918a71cdbe9 | 125 | DHCPV6_OPTION_DOMAIN_LIST = 24, |
Sergunb | 0:8918a71cdbe9 | 126 | DHCPV6_OPTION_IA_PD = 25, |
Sergunb | 0:8918a71cdbe9 | 127 | DHCPV6_OPTION_IAPREFIX = 26, |
Sergunb | 0:8918a71cdbe9 | 128 | DHCPV6_OPTION_FQDN = 39 |
Sergunb | 0:8918a71cdbe9 | 129 | } Dhcpv6OptionCode; |
Sergunb | 0:8918a71cdbe9 | 130 | |
Sergunb | 0:8918a71cdbe9 | 131 | |
Sergunb | 0:8918a71cdbe9 | 132 | /** |
Sergunb | 0:8918a71cdbe9 | 133 | * @brief Status code |
Sergunb | 0:8918a71cdbe9 | 134 | **/ |
Sergunb | 0:8918a71cdbe9 | 135 | |
Sergunb | 0:8918a71cdbe9 | 136 | typedef enum |
Sergunb | 0:8918a71cdbe9 | 137 | { |
Sergunb | 0:8918a71cdbe9 | 138 | DHCPV6_STATUS_SUCCESS = 0, |
Sergunb | 0:8918a71cdbe9 | 139 | DHCPV6_STATUS_UNSPEC_FAILURE = 1, |
Sergunb | 0:8918a71cdbe9 | 140 | DHCPV6_STATUS_NO_ADDRS_AVAILABLE = 2, |
Sergunb | 0:8918a71cdbe9 | 141 | DHCPV6_STATUS_NO_BINDING = 3, |
Sergunb | 0:8918a71cdbe9 | 142 | DHCPV6_STATUS_NOT_ON_LINK = 4, |
Sergunb | 0:8918a71cdbe9 | 143 | DHCPV6_STATUS_USE_MULTICAST = 5 |
Sergunb | 0:8918a71cdbe9 | 144 | } Dhcpv6StatusCode; |
Sergunb | 0:8918a71cdbe9 | 145 | |
Sergunb | 0:8918a71cdbe9 | 146 | |
Sergunb | 0:8918a71cdbe9 | 147 | //CodeWarrior or Win32 compiler? |
Sergunb | 0:8918a71cdbe9 | 148 | #if defined(__CWCC__) || defined(_WIN32) |
Sergunb | 0:8918a71cdbe9 | 149 | #pragma pack(push, 1) |
Sergunb | 0:8918a71cdbe9 | 150 | #endif |
Sergunb | 0:8918a71cdbe9 | 151 | |
Sergunb | 0:8918a71cdbe9 | 152 | |
Sergunb | 0:8918a71cdbe9 | 153 | /** |
Sergunb | 0:8918a71cdbe9 | 154 | * @brief DUID-LLT structure |
Sergunb | 0:8918a71cdbe9 | 155 | **/ |
Sergunb | 0:8918a71cdbe9 | 156 | |
Sergunb | 0:8918a71cdbe9 | 157 | typedef __start_packed struct |
Sergunb | 0:8918a71cdbe9 | 158 | { |
Sergunb | 0:8918a71cdbe9 | 159 | uint16_t type; //0-1 |
Sergunb | 0:8918a71cdbe9 | 160 | uint16_t hardwareType; //2-3 |
Sergunb | 0:8918a71cdbe9 | 161 | uint32_t time; //4-7 |
Sergunb | 0:8918a71cdbe9 | 162 | MacAddr linkLayerAddr; //8-13 |
Sergunb | 0:8918a71cdbe9 | 163 | } __end_packed Dhcpv6DuidLlt; |
Sergunb | 0:8918a71cdbe9 | 164 | |
Sergunb | 0:8918a71cdbe9 | 165 | |
Sergunb | 0:8918a71cdbe9 | 166 | /** |
Sergunb | 0:8918a71cdbe9 | 167 | * @brief DUID-EN structure |
Sergunb | 0:8918a71cdbe9 | 168 | **/ |
Sergunb | 0:8918a71cdbe9 | 169 | |
Sergunb | 0:8918a71cdbe9 | 170 | typedef __start_packed struct |
Sergunb | 0:8918a71cdbe9 | 171 | { |
Sergunb | 0:8918a71cdbe9 | 172 | uint16_t type; //0-1 |
Sergunb | 0:8918a71cdbe9 | 173 | uint32_t enterpriseNumber; //2-5 |
Sergunb | 0:8918a71cdbe9 | 174 | uint8_t identifier[]; //6 |
Sergunb | 0:8918a71cdbe9 | 175 | } __end_packed Dhcpv6DuidEn; |
Sergunb | 0:8918a71cdbe9 | 176 | |
Sergunb | 0:8918a71cdbe9 | 177 | |
Sergunb | 0:8918a71cdbe9 | 178 | /** |
Sergunb | 0:8918a71cdbe9 | 179 | * @brief DUID-LL structure |
Sergunb | 0:8918a71cdbe9 | 180 | **/ |
Sergunb | 0:8918a71cdbe9 | 181 | |
Sergunb | 0:8918a71cdbe9 | 182 | typedef __start_packed struct |
Sergunb | 0:8918a71cdbe9 | 183 | { |
Sergunb | 0:8918a71cdbe9 | 184 | uint16_t type; //0-1 |
Sergunb | 0:8918a71cdbe9 | 185 | uint16_t hardwareType; //2-3 |
Sergunb | 0:8918a71cdbe9 | 186 | #if (ETH_SUPPORT == ENABLED) |
Sergunb | 0:8918a71cdbe9 | 187 | MacAddr linkLayerAddr; //4-9 |
Sergunb | 0:8918a71cdbe9 | 188 | #else |
Sergunb | 0:8918a71cdbe9 | 189 | Eui64 linkLayerAddr; //4-11 |
Sergunb | 0:8918a71cdbe9 | 190 | #endif |
Sergunb | 0:8918a71cdbe9 | 191 | } __end_packed Dhcpv6DuidLl; |
Sergunb | 0:8918a71cdbe9 | 192 | |
Sergunb | 0:8918a71cdbe9 | 193 | |
Sergunb | 0:8918a71cdbe9 | 194 | /** |
Sergunb | 0:8918a71cdbe9 | 195 | * @brief DHCPv6 message |
Sergunb | 0:8918a71cdbe9 | 196 | **/ |
Sergunb | 0:8918a71cdbe9 | 197 | |
Sergunb | 0:8918a71cdbe9 | 198 | typedef __start_packed struct |
Sergunb | 0:8918a71cdbe9 | 199 | { |
Sergunb | 0:8918a71cdbe9 | 200 | uint8_t msgType; //0 |
Sergunb | 0:8918a71cdbe9 | 201 | uint8_t transactionId[3]; //1-3 |
Sergunb | 0:8918a71cdbe9 | 202 | uint8_t options[]; //4 |
Sergunb | 0:8918a71cdbe9 | 203 | } __end_packed Dhcpv6Message; |
Sergunb | 0:8918a71cdbe9 | 204 | |
Sergunb | 0:8918a71cdbe9 | 205 | |
Sergunb | 0:8918a71cdbe9 | 206 | /** |
Sergunb | 0:8918a71cdbe9 | 207 | * @brief DHCPv6 relay agent message |
Sergunb | 0:8918a71cdbe9 | 208 | **/ |
Sergunb | 0:8918a71cdbe9 | 209 | |
Sergunb | 0:8918a71cdbe9 | 210 | typedef __start_packed struct |
Sergunb | 0:8918a71cdbe9 | 211 | { |
Sergunb | 0:8918a71cdbe9 | 212 | uint8_t msgType; //0 |
Sergunb | 0:8918a71cdbe9 | 213 | uint8_t hopCount; //1 |
Sergunb | 0:8918a71cdbe9 | 214 | Ipv6Addr linkAddress; //2-17 |
Sergunb | 0:8918a71cdbe9 | 215 | Ipv6Addr peerAddress; //18-33 |
Sergunb | 0:8918a71cdbe9 | 216 | uint8_t options[]; //34 |
Sergunb | 0:8918a71cdbe9 | 217 | } __end_packed Dhcpv6RelayMessage; |
Sergunb | 0:8918a71cdbe9 | 218 | |
Sergunb | 0:8918a71cdbe9 | 219 | |
Sergunb | 0:8918a71cdbe9 | 220 | /** |
Sergunb | 0:8918a71cdbe9 | 221 | * @brief DHCPv6 option |
Sergunb | 0:8918a71cdbe9 | 222 | **/ |
Sergunb | 0:8918a71cdbe9 | 223 | |
Sergunb | 0:8918a71cdbe9 | 224 | typedef __start_packed struct |
Sergunb | 0:8918a71cdbe9 | 225 | { |
Sergunb | 0:8918a71cdbe9 | 226 | uint16_t code; //0-1 |
Sergunb | 0:8918a71cdbe9 | 227 | uint16_t length; //2-3 |
Sergunb | 0:8918a71cdbe9 | 228 | uint8_t value[]; //4 |
Sergunb | 0:8918a71cdbe9 | 229 | } __end_packed Dhcpv6Option; |
Sergunb | 0:8918a71cdbe9 | 230 | |
Sergunb | 0:8918a71cdbe9 | 231 | |
Sergunb | 0:8918a71cdbe9 | 232 | /** |
Sergunb | 0:8918a71cdbe9 | 233 | * @brief Identity Association for Non-temporary Addresses option |
Sergunb | 0:8918a71cdbe9 | 234 | **/ |
Sergunb | 0:8918a71cdbe9 | 235 | |
Sergunb | 0:8918a71cdbe9 | 236 | typedef __start_packed struct |
Sergunb | 0:8918a71cdbe9 | 237 | { |
Sergunb | 0:8918a71cdbe9 | 238 | uint32_t iaId; //0-3 |
Sergunb | 0:8918a71cdbe9 | 239 | uint32_t t1; //4-7 |
Sergunb | 0:8918a71cdbe9 | 240 | uint32_t t2; //8-11 |
Sergunb | 0:8918a71cdbe9 | 241 | uint8_t options[]; //12 |
Sergunb | 0:8918a71cdbe9 | 242 | } __end_packed Dhcpv6IaNaOption; |
Sergunb | 0:8918a71cdbe9 | 243 | |
Sergunb | 0:8918a71cdbe9 | 244 | |
Sergunb | 0:8918a71cdbe9 | 245 | /** |
Sergunb | 0:8918a71cdbe9 | 246 | * @brief Identity Association for Temporary Addresses option |
Sergunb | 0:8918a71cdbe9 | 247 | **/ |
Sergunb | 0:8918a71cdbe9 | 248 | |
Sergunb | 0:8918a71cdbe9 | 249 | typedef __start_packed struct |
Sergunb | 0:8918a71cdbe9 | 250 | { |
Sergunb | 0:8918a71cdbe9 | 251 | uint32_t iaId; //0-3 |
Sergunb | 0:8918a71cdbe9 | 252 | uint8_t options[]; //4 |
Sergunb | 0:8918a71cdbe9 | 253 | } Dhcpv6IaTaOption; |
Sergunb | 0:8918a71cdbe9 | 254 | |
Sergunb | 0:8918a71cdbe9 | 255 | |
Sergunb | 0:8918a71cdbe9 | 256 | /** |
Sergunb | 0:8918a71cdbe9 | 257 | * @brief IA Address option |
Sergunb | 0:8918a71cdbe9 | 258 | **/ |
Sergunb | 0:8918a71cdbe9 | 259 | |
Sergunb | 0:8918a71cdbe9 | 260 | typedef __start_packed struct |
Sergunb | 0:8918a71cdbe9 | 261 | { |
Sergunb | 0:8918a71cdbe9 | 262 | Ipv6Addr address; //0-15 |
Sergunb | 0:8918a71cdbe9 | 263 | uint32_t preferredLifetime; //16-19 |
Sergunb | 0:8918a71cdbe9 | 264 | uint32_t validLifetime; //20-23 |
Sergunb | 0:8918a71cdbe9 | 265 | uint8_t options[]; //24 |
Sergunb | 0:8918a71cdbe9 | 266 | } __end_packed Dhcpv6IaAddrOption; |
Sergunb | 0:8918a71cdbe9 | 267 | |
Sergunb | 0:8918a71cdbe9 | 268 | |
Sergunb | 0:8918a71cdbe9 | 269 | /** |
Sergunb | 0:8918a71cdbe9 | 270 | * @brief Option Request option |
Sergunb | 0:8918a71cdbe9 | 271 | **/ |
Sergunb | 0:8918a71cdbe9 | 272 | |
Sergunb | 0:8918a71cdbe9 | 273 | typedef __start_packed struct |
Sergunb | 0:8918a71cdbe9 | 274 | { |
Sergunb | 0:8918a71cdbe9 | 275 | uint16_t requestedOption[1]; //0-1 |
Sergunb | 0:8918a71cdbe9 | 276 | } __end_packed Dhcpv6OroOption; |
Sergunb | 0:8918a71cdbe9 | 277 | |
Sergunb | 0:8918a71cdbe9 | 278 | |
Sergunb | 0:8918a71cdbe9 | 279 | /** |
Sergunb | 0:8918a71cdbe9 | 280 | * @brief Preference option |
Sergunb | 0:8918a71cdbe9 | 281 | **/ |
Sergunb | 0:8918a71cdbe9 | 282 | |
Sergunb | 0:8918a71cdbe9 | 283 | typedef __start_packed struct |
Sergunb | 0:8918a71cdbe9 | 284 | { |
Sergunb | 0:8918a71cdbe9 | 285 | uint8_t value; //0 |
Sergunb | 0:8918a71cdbe9 | 286 | } __end_packed Dhcpv6PreferenceOption; |
Sergunb | 0:8918a71cdbe9 | 287 | |
Sergunb | 0:8918a71cdbe9 | 288 | |
Sergunb | 0:8918a71cdbe9 | 289 | /** |
Sergunb | 0:8918a71cdbe9 | 290 | * @brief Elapsed Time option |
Sergunb | 0:8918a71cdbe9 | 291 | **/ |
Sergunb | 0:8918a71cdbe9 | 292 | |
Sergunb | 0:8918a71cdbe9 | 293 | typedef __start_packed struct |
Sergunb | 0:8918a71cdbe9 | 294 | { |
Sergunb | 0:8918a71cdbe9 | 295 | uint16_t value; //0-1 |
Sergunb | 0:8918a71cdbe9 | 296 | } __end_packed Dhcpv6ElapsedTimeOption; |
Sergunb | 0:8918a71cdbe9 | 297 | |
Sergunb | 0:8918a71cdbe9 | 298 | |
Sergunb | 0:8918a71cdbe9 | 299 | /** |
Sergunb | 0:8918a71cdbe9 | 300 | * @brief Authentication option |
Sergunb | 0:8918a71cdbe9 | 301 | **/ |
Sergunb | 0:8918a71cdbe9 | 302 | |
Sergunb | 0:8918a71cdbe9 | 303 | typedef __start_packed struct |
Sergunb | 0:8918a71cdbe9 | 304 | { |
Sergunb | 0:8918a71cdbe9 | 305 | uint8_t protocol; //0 |
Sergunb | 0:8918a71cdbe9 | 306 | uint8_t algorithm; //1 |
Sergunb | 0:8918a71cdbe9 | 307 | uint8_t rdm; //2 |
Sergunb | 0:8918a71cdbe9 | 308 | uint8_t replayDetection[8]; //3-10 |
Sergunb | 0:8918a71cdbe9 | 309 | uint8_t authInfo[]; //11 |
Sergunb | 0:8918a71cdbe9 | 310 | } __end_packed Dhcpv6AuthOption; |
Sergunb | 0:8918a71cdbe9 | 311 | |
Sergunb | 0:8918a71cdbe9 | 312 | |
Sergunb | 0:8918a71cdbe9 | 313 | /** |
Sergunb | 0:8918a71cdbe9 | 314 | * @brief Server Unicast option |
Sergunb | 0:8918a71cdbe9 | 315 | **/ |
Sergunb | 0:8918a71cdbe9 | 316 | |
Sergunb | 0:8918a71cdbe9 | 317 | typedef __start_packed struct |
Sergunb | 0:8918a71cdbe9 | 318 | { |
Sergunb | 0:8918a71cdbe9 | 319 | Ipv6Addr serverAddr; //0-15 |
Sergunb | 0:8918a71cdbe9 | 320 | } __end_packed Dhcpv6ServerUnicastOption; |
Sergunb | 0:8918a71cdbe9 | 321 | |
Sergunb | 0:8918a71cdbe9 | 322 | |
Sergunb | 0:8918a71cdbe9 | 323 | /** |
Sergunb | 0:8918a71cdbe9 | 324 | * @brief Status Code option |
Sergunb | 0:8918a71cdbe9 | 325 | **/ |
Sergunb | 0:8918a71cdbe9 | 326 | |
Sergunb | 0:8918a71cdbe9 | 327 | typedef __start_packed struct |
Sergunb | 0:8918a71cdbe9 | 328 | { |
Sergunb | 0:8918a71cdbe9 | 329 | uint16_t statusCode; //0-1 |
Sergunb | 0:8918a71cdbe9 | 330 | char_t statusMessage[]; //2 |
Sergunb | 0:8918a71cdbe9 | 331 | } __end_packed Dhcpv6StatusCodeOption; |
Sergunb | 0:8918a71cdbe9 | 332 | |
Sergunb | 0:8918a71cdbe9 | 333 | |
Sergunb | 0:8918a71cdbe9 | 334 | /** |
Sergunb | 0:8918a71cdbe9 | 335 | * @brief Reconfigure Message option |
Sergunb | 0:8918a71cdbe9 | 336 | **/ |
Sergunb | 0:8918a71cdbe9 | 337 | |
Sergunb | 0:8918a71cdbe9 | 338 | typedef __start_packed struct |
Sergunb | 0:8918a71cdbe9 | 339 | { |
Sergunb | 0:8918a71cdbe9 | 340 | uint8_t msgType; //0 |
Sergunb | 0:8918a71cdbe9 | 341 | } __end_packed Dhcpv6ReconfMessageOption; |
Sergunb | 0:8918a71cdbe9 | 342 | |
Sergunb | 0:8918a71cdbe9 | 343 | |
Sergunb | 0:8918a71cdbe9 | 344 | /** |
Sergunb | 0:8918a71cdbe9 | 345 | * @brief DNS Recursive Name Server option |
Sergunb | 0:8918a71cdbe9 | 346 | **/ |
Sergunb | 0:8918a71cdbe9 | 347 | |
Sergunb | 0:8918a71cdbe9 | 348 | typedef __start_packed struct |
Sergunb | 0:8918a71cdbe9 | 349 | { |
Sergunb | 0:8918a71cdbe9 | 350 | Ipv6Addr address[1]; //0-15 |
Sergunb | 0:8918a71cdbe9 | 351 | } __end_packed Dhcpv6DnsServersOption; |
Sergunb | 0:8918a71cdbe9 | 352 | |
Sergunb | 0:8918a71cdbe9 | 353 | |
Sergunb | 0:8918a71cdbe9 | 354 | /** |
Sergunb | 0:8918a71cdbe9 | 355 | * @brief Domain Search List option |
Sergunb | 0:8918a71cdbe9 | 356 | **/ |
Sergunb | 0:8918a71cdbe9 | 357 | |
Sergunb | 0:8918a71cdbe9 | 358 | typedef __start_packed struct |
Sergunb | 0:8918a71cdbe9 | 359 | { |
Sergunb | 0:8918a71cdbe9 | 360 | uint8_t searchList[1]; //0 |
Sergunb | 0:8918a71cdbe9 | 361 | } __end_packed Dhcpv6DomainListOption; |
Sergunb | 0:8918a71cdbe9 | 362 | |
Sergunb | 0:8918a71cdbe9 | 363 | |
Sergunb | 0:8918a71cdbe9 | 364 | /** |
Sergunb | 0:8918a71cdbe9 | 365 | * @brief Identity Association for Prefix Delegation Option |
Sergunb | 0:8918a71cdbe9 | 366 | **/ |
Sergunb | 0:8918a71cdbe9 | 367 | |
Sergunb | 0:8918a71cdbe9 | 368 | typedef __start_packed struct |
Sergunb | 0:8918a71cdbe9 | 369 | { |
Sergunb | 0:8918a71cdbe9 | 370 | uint32_t iaId; //0-3 |
Sergunb | 0:8918a71cdbe9 | 371 | uint32_t t1; //4-7 |
Sergunb | 0:8918a71cdbe9 | 372 | uint32_t t2; //8-11 |
Sergunb | 0:8918a71cdbe9 | 373 | uint8_t options[]; //12 |
Sergunb | 0:8918a71cdbe9 | 374 | } __end_packed Dhcpv6IaPdOption; |
Sergunb | 0:8918a71cdbe9 | 375 | |
Sergunb | 0:8918a71cdbe9 | 376 | |
Sergunb | 0:8918a71cdbe9 | 377 | /** |
Sergunb | 0:8918a71cdbe9 | 378 | * @brief IA_PD Prefix option |
Sergunb | 0:8918a71cdbe9 | 379 | **/ |
Sergunb | 0:8918a71cdbe9 | 380 | |
Sergunb | 0:8918a71cdbe9 | 381 | typedef __start_packed struct |
Sergunb | 0:8918a71cdbe9 | 382 | { |
Sergunb | 0:8918a71cdbe9 | 383 | uint32_t preferredLifetime; //0-3 |
Sergunb | 0:8918a71cdbe9 | 384 | uint32_t validLifetime; //4-7 |
Sergunb | 0:8918a71cdbe9 | 385 | uint8_t prefixLength; //8 |
Sergunb | 0:8918a71cdbe9 | 386 | Ipv6Addr prefix; //9-24 |
Sergunb | 0:8918a71cdbe9 | 387 | uint8_t options[]; //25 |
Sergunb | 0:8918a71cdbe9 | 388 | } __end_packed Dhcpv6IaPrefixOption; |
Sergunb | 0:8918a71cdbe9 | 389 | |
Sergunb | 0:8918a71cdbe9 | 390 | |
Sergunb | 0:8918a71cdbe9 | 391 | /** |
Sergunb | 0:8918a71cdbe9 | 392 | * @brief Fully Qualified Domain Name option |
Sergunb | 0:8918a71cdbe9 | 393 | **/ |
Sergunb | 0:8918a71cdbe9 | 394 | |
Sergunb | 0:8918a71cdbe9 | 395 | typedef __start_packed struct |
Sergunb | 0:8918a71cdbe9 | 396 | { |
Sergunb | 0:8918a71cdbe9 | 397 | #ifdef _CPU_BIG_ENDIAN |
Sergunb | 0:8918a71cdbe9 | 398 | uint8_t mbz : 5; //0 |
Sergunb | 0:8918a71cdbe9 | 399 | uint8_t n : 1; |
Sergunb | 0:8918a71cdbe9 | 400 | uint8_t o : 1; |
Sergunb | 0:8918a71cdbe9 | 401 | uint8_t s : 1; |
Sergunb | 0:8918a71cdbe9 | 402 | #else |
Sergunb | 0:8918a71cdbe9 | 403 | uint8_t s : 1; //0 |
Sergunb | 0:8918a71cdbe9 | 404 | uint8_t o : 1; |
Sergunb | 0:8918a71cdbe9 | 405 | uint8_t n : 1; |
Sergunb | 0:8918a71cdbe9 | 406 | uint8_t mbz : 5; |
Sergunb | 0:8918a71cdbe9 | 407 | #endif |
Sergunb | 0:8918a71cdbe9 | 408 | uint8_t domainName[]; //1 |
Sergunb | 0:8918a71cdbe9 | 409 | } __end_packed Dhcpv6FqdnOption; |
Sergunb | 0:8918a71cdbe9 | 410 | |
Sergunb | 0:8918a71cdbe9 | 411 | |
Sergunb | 0:8918a71cdbe9 | 412 | //CodeWarrior or Win32 compiler? |
Sergunb | 0:8918a71cdbe9 | 413 | #if defined(__CWCC__) || defined(_WIN32) |
Sergunb | 0:8918a71cdbe9 | 414 | #pragma pack(pop) |
Sergunb | 0:8918a71cdbe9 | 415 | #endif |
Sergunb | 0:8918a71cdbe9 | 416 | |
Sergunb | 0:8918a71cdbe9 | 417 | |
Sergunb | 0:8918a71cdbe9 | 418 | //DHCPv6 related constants |
Sergunb | 0:8918a71cdbe9 | 419 | extern const Ipv6Addr DHCPV6_ALL_RELAY_AGENTS_AND_SERVERS_ADDR; |
Sergunb | 0:8918a71cdbe9 | 420 | extern const Ipv6Addr DHCPV6_ALL_SERVERS_ADDR; |
Sergunb | 0:8918a71cdbe9 | 421 | |
Sergunb | 0:8918a71cdbe9 | 422 | //DHCPv6 related functions |
Sergunb | 0:8918a71cdbe9 | 423 | Dhcpv6StatusCode dhcpv6GetStatusCode(const uint8_t *options, size_t length); |
Sergunb | 0:8918a71cdbe9 | 424 | |
Sergunb | 0:8918a71cdbe9 | 425 | Dhcpv6Option *dhcpv6AddOption(void *message, size_t *messageLength, |
Sergunb | 0:8918a71cdbe9 | 426 | uint16_t optionCode, const void *optionValue, size_t optionLength); |
Sergunb | 0:8918a71cdbe9 | 427 | |
Sergunb | 0:8918a71cdbe9 | 428 | Dhcpv6Option *dhcpv6AddSubOption(Dhcpv6Option *baseOption, size_t *messageLength, |
Sergunb | 0:8918a71cdbe9 | 429 | uint16_t optionCode, const void *optionValue, size_t optionLength); |
Sergunb | 0:8918a71cdbe9 | 430 | |
Sergunb | 0:8918a71cdbe9 | 431 | Dhcpv6Option *dhcpv6GetOption(const uint8_t *options, |
Sergunb | 0:8918a71cdbe9 | 432 | size_t optionsLength, uint16_t optionCode); |
Sergunb | 0:8918a71cdbe9 | 433 | |
Sergunb | 0:8918a71cdbe9 | 434 | int32_t dhcpv6Rand(int32_t value); |
Sergunb | 0:8918a71cdbe9 | 435 | int32_t dhcpv6RandRange(int32_t min, int32_t max); |
Sergunb | 0:8918a71cdbe9 | 436 | |
Sergunb | 0:8918a71cdbe9 | 437 | #endif |
Sergunb | 0:8918a71cdbe9 | 438 |