_dhcpv6.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Freie Universität Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
19 #ifndef PRIV_DHCPV6_H
20 #define PRIV_DHCPV6_H
21 
22 #include <stdint.h>
23 
24 #include "byteorder.h"
25 #include "net/ipv6/addr.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
44 #define DHCPV6_ALL_RELAY_AGENTS_AND_SERVERS { 0xff, 0x02, 0x00, 0x00, \
45  0x00, 0x00, 0x00, 0x00, \
46  0x00, 0x00, 0x00, 0x00, \
47  0x00, 0x01, 0x00, 0x02 \
48  }
57 #define DHCPV6_SOL_MAX_DELAY (1U)
58 #define DHCPV6_SOL_TIMEOUT (1U)
59 #define DHCPV6_SOL_MAX_RT (3600U)
61 #define DHCPV6_REQ_TIMEOUT (1U)
62 #define DHCPV6_REQ_MAX_RT (30U)
63 #define DHCPV6_REQ_MAX_RC (10U)
65 #define DHCPV6_REN_TIMEOUT (10U)
66 #define DHCPV6_REN_MAX_RT (600U)
68 #define DHCPV6_REB_TIMEOUT (10U)
69 #define DHCPV6_REB_MAX_RT (600U)
71 #define DHCPV6_INF_MAX_DELAY (1U)
72 #define DHCPV6_INF_TIMEOUT (1U)
73 #define DHCPV6_INF_MAX_RT (3600U)
75 #define DHCPV6_IRT_DEFAULT (86400U)
76 #define DHCPV6_IRT_MINIMUM (600U)
80 #define DHCPV6_DUID_MAX_LEN (128U)
91 typedef struct __attribute__((packed)) {
92  uint8_t type;
93  uint8_t tid[3];
94 } dhcpv6_msg_t;
95 
101 typedef struct __attribute__((packed)) {
102  uint8_t type;
103  uint8_t hop_count;
115 
119 typedef union {
120  uint8_t u8[DHCPV6_DUID_MAX_LEN];
122 } dhcpv6_duid_t;
134 typedef struct __attribute__((packed)) {
137  uint8_t data[];
138 } dhcpv6_opt_t;
139 
147 typedef struct __attribute__((packed)) {
150  uint8_t duid[];
152 
159 typedef struct __attribute__((packed)) {
165  uint8_t opts[];
167 
173 typedef struct __attribute__((packed)) {
179  uint8_t opts[];
181 
187 typedef struct __attribute__((packed)) {
190  network_uint16_t opt_codes[];
192 
198 typedef struct __attribute__((packed)) {
201  uint8_t value;
210 typedef struct __attribute__((packed)) {
218 
224 typedef struct __attribute__((packed)) {
227  uint16_t msg[];
229 
235 typedef struct __attribute__((packed)) {
239  char msg[];
241 
247 typedef struct __attribute__((packed)) {
250  uint8_t iid[];
252 
259 typedef struct __attribute__((packed)) {
262  ipv6_addr_t dns_rns[];
265 
272 typedef struct __attribute__((packed)) {
278  uint8_t opts[];
280 
286 typedef struct __attribute__((packed)) {
291  uint8_t pfx_len;
293  uint8_t opts[];
295 
301 typedef struct __attribute__((packed)) {
307 
313 typedef struct __attribute__((packed)) {
318 
324 typedef struct __attribute__((packed)) {
329 
335 typedef struct __attribute__((packed)) {
338  char mud_string[];
340 
350  uint16_t netif);
351 
352 #ifdef __cplusplus
353 }
354 #endif
355 
356 #endif /* PRIV_DHCPV6_H */
#define DHCPV6_DUID_MAX_LEN
maximum length of DUID
Definition: _dhcpv6.h:80
void dhcpv6_client_dns_rns_conf(const dhcpv6_opt_dns_rns_t *opt, uint16_t netif)
Configures a DNS recursive name server provided by the server.
Functions to work with different byte orders.
Definitions for IPv6 addresses.
DUID based on link-layer address plus time.
Definition: client.h:103
Client/Server message header.
Definition: _dhcpv6.h:91
uint8_t type
message type (see DHCPv6 messeg types )
Definition: _dhcpv6.h:92
DHCPv6 DNS recursive name server option.
Definition: _dhcpv6.h:259
network_uint16_t type
DHCPV6_OPT_DNS_RNS
Definition: _dhcpv6.h:260
network_uint16_t len
length of dhcpv6_opt_status_t::dns_rns in byte
Definition: _dhcpv6.h:261
DHCPv6 client or server identifier option format.
Definition: _dhcpv6.h:147
network_uint16_t type
DHCPV6_OPT_CID or DHCPV6_OPT_SID
Definition: _dhcpv6.h:148
network_uint16_t len
length of dhcpv6_opt_t::duid in byte
Definition: _dhcpv6.h:149
DHCPv6 elapsed time option format.
Definition: _dhcpv6.h:210
network_uint16_t len
always 2
Definition: _dhcpv6.h:212
network_uint16_t elapsed_time
amount of time since client began current DHCPv6 transaction (in cs)
Definition: _dhcpv6.h:216
network_uint16_t type
DHCPV6_OPT_ELAPSED_TIME
Definition: _dhcpv6.h:211
DHCPv6 identity association for non-temporary addresses (IA_NA) option format.
Definition: _dhcpv6.h:159
network_uint32_t t2
DHCPv6 T2 time (in sec)
Definition: _dhcpv6.h:164
network_uint32_t t1
DHCPv6 T1 time (in sec)
Definition: _dhcpv6.h:163
network_uint16_t type
DHCPV6_OPT_IA_NA
Definition: _dhcpv6.h:160
network_uint32_t ia_id
Unique ID for this IA_NA.
Definition: _dhcpv6.h:162
network_uint16_t len
12 + length of dhcpv6_opt_ia_na_t::opts in byte
Definition: _dhcpv6.h:161
DHCPv6 identity association for prefix delegation option (IA_PD) format.
Definition: _dhcpv6.h:272
network_uint32_t ia_id
Unique ID for this IA_PD.
Definition: _dhcpv6.h:275
network_uint16_t len
12 + length of dhcpv6_opt_ia_pd_t::opts in byte
Definition: _dhcpv6.h:274
network_uint32_t t2
DHCPv6 T2 time (in sec)
Definition: _dhcpv6.h:277
network_uint32_t t1
DHCPv6 T1 time (in sec)
Definition: _dhcpv6.h:276
network_uint16_t type
DHCPV6_OPT_IA_PD
Definition: _dhcpv6.h:273
DHCPv6 IA address option format.
Definition: _dhcpv6.h:173
network_uint32_t pref
preferred lifetime (in sec)
Definition: _dhcpv6.h:177
network_uint16_t type
DHCPV6_OPT_IAADDR
Definition: _dhcpv6.h:174
network_uint16_t len
25 + length of dhcpv6_opt_iapfx_t::opts in byte
Definition: _dhcpv6.h:175
network_uint32_t valid
valid lifetime (in sec)
Definition: _dhcpv6.h:178
ipv6_addr_t addr
the address
Definition: _dhcpv6.h:176
DHCPv6 IA prefix option format.
Definition: _dhcpv6.h:286
uint8_t pfx_len
length of dhcpv6_opt_iapfx_t::pfx in bits
Definition: _dhcpv6.h:291
network_uint16_t type
DHCPV6_OPT_IAPFX
Definition: _dhcpv6.h:287
network_uint32_t pref
preferred lifetime (in sec)
Definition: _dhcpv6.h:289
network_uint16_t len
25 + length of dhcpv6_opt_iapfx_t::opts in byte
Definition: _dhcpv6.h:288
ipv6_addr_t pfx
the prefix
Definition: _dhcpv6.h:292
network_uint32_t valid
valid lifetime (in sec)
Definition: _dhcpv6.h:290
DHCPv6 interface-id option.
Definition: _dhcpv6.h:247
network_uint16_t len
length of dhcpv6_opt_iid_t::iid in byte
Definition: _dhcpv6.h:249
network_uint16_t type
DHCPV6_OPT_IID
Definition: _dhcpv6.h:248
DHCPv6 INF_MAX_RT option format.
Definition: _dhcpv6.h:324
network_uint16_t len
always 4
Definition: _dhcpv6.h:326
network_uint16_t type
DHCPV6_OPT_IMR
Definition: _dhcpv6.h:325
network_uint32_t value
overriding value for INF_MAX_RT (in sec)
Definition: _dhcpv6.h:327
DHCPv6 Information Refresh Time option format.
Definition: _dhcpv6.h:301
network_uint16_t type
DHCPV6_OPT_IRT
Definition: _dhcpv6.h:302
network_uint32_t value
Time duration relative to the current time (in sec)
Definition: _dhcpv6.h:304
network_uint16_t len
always 4
Definition: _dhcpv6.h:303
MUD URL DHCPv6 option format.
Definition: _dhcpv6.h:335
network_uint16_t type
DHCPV6_OPT_MUD_URL
Definition: _dhcpv6.h:336
network_uint16_t len
length of the mud_string in octets.
Definition: _dhcpv6.h:337
DHCPv6 option request option format.
Definition: _dhcpv6.h:187
network_uint16_t type
DHCPV6_OPT_ORO
Definition: _dhcpv6.h:188
network_uint16_t len
2 * number of dhcpv6_opt_oro_t::opt_codes
Definition: _dhcpv6.h:189
DHCPv6 preference option format.
Definition: _dhcpv6.h:198
network_uint16_t len
always 1
Definition: _dhcpv6.h:200
uint8_t value
preference value for the server
Definition: _dhcpv6.h:201
network_uint16_t type
DHCPV6_OPT_PREF
Definition: _dhcpv6.h:199
DHCPv6 relay message option.
Definition: _dhcpv6.h:224
network_uint16_t len
length of dhcpv6_opt_iid_t::msg in byte
Definition: _dhcpv6.h:226
network_uint16_t type
DHCPV6_OPT_RELAY_MSG
Definition: _dhcpv6.h:225
DHCPv6 SOL_MAX_RT option format.
Definition: _dhcpv6.h:313
network_uint32_t value
overriding value for SOL_MAX_RT (in sec)
Definition: _dhcpv6.h:316
network_uint16_t len
always 4
Definition: _dhcpv6.h:315
network_uint16_t type
DHCPV6_OPT_SMR
Definition: _dhcpv6.h:314
DHCPv6 status code option format.
Definition: _dhcpv6.h:235
network_uint16_t code
status code
Definition: _dhcpv6.h:238
network_uint16_t len
2 + length of dhcpv6_opt_status_t::msg in byte
Definition: _dhcpv6.h:237
network_uint16_t type
DHCPV6_OPT_STATUS
Definition: _dhcpv6.h:236
General DHCPv6 option format.
Definition: _dhcpv6.h:134
network_uint16_t type
option code
Definition: _dhcpv6.h:135
network_uint16_t len
length of dhcpv6_opt_t::data in byte
Definition: _dhcpv6.h:136
Relay Agents/Server message format.
Definition: _dhcpv6.h:101
uint8_t type
message type (see DHCPv6 messeg types )
Definition: _dhcpv6.h:102
ipv6_addr_t peer_address
The address of the client or relay agent from which the message to be relayed was received.
Definition: _dhcpv6.h:113
uint8_t hop_count
number of relays that have already relayed the message
Definition: _dhcpv6.h:103
ipv6_addr_t link_address
optional address to identify the link on which the client is located.
Definition: _dhcpv6.h:108
A 16 bit integer in big endian aka network byte order.
Definition: byteorder.h:74
A 32 bit integer in big endian aka network byte order.
Definition: byteorder.h:84
Generic storage DUID.
Definition: _dhcpv6.h:119
dhcpv6_duid_l2_t duid_l2
DUID-L2 type.
Definition: _dhcpv6.h:121
Data type to represent an IPv6 address.
Definition: addr.h:72