]>
Commit | Line | Data |
---|---|---|
1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ | |
2 | #pragma once | |
3 | ||
4 | /*** | |
5 | Copyright © 2014 Intel Corporation. All rights reserved. | |
6 | ***/ | |
7 | ||
8 | #include "forward.h" | |
9 | #include "sparse-endian.h" | |
10 | ||
11 | struct DHCP6Message { | |
12 | union { | |
13 | struct { | |
14 | uint8_t type; | |
15 | uint8_t _pad[3]; | |
16 | } _packed_; | |
17 | be32_t transaction_id; | |
18 | }; | |
19 | uint8_t options[]; | |
20 | } _packed_; | |
21 | ||
22 | typedef struct DHCP6Message DHCP6Message; | |
23 | ||
24 | #define DHCP6_MIN_OPTIONS_SIZE \ | |
25 | 1280 - sizeof(struct ip6_hdr) - sizeof(struct udphdr) | |
26 | ||
27 | #define IN6_ADDR_ALL_DHCP6_RELAY_AGENTS_AND_SERVERS \ | |
28 | ((const struct in6_addr) { { { \ | |
29 | 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ | |
30 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, \ | |
31 | } } } ) | |
32 | ||
33 | enum { | |
34 | DHCP6_PORT_SERVER = 547, | |
35 | DHCP6_PORT_CLIENT = 546, | |
36 | }; | |
37 | ||
38 | #define DHCP6_INF_TIMEOUT (1 * USEC_PER_SEC) | |
39 | #define DHCP6_INF_MAX_RT (120 * USEC_PER_SEC) | |
40 | #define DHCP6_SOL_MAX_DELAY (1 * USEC_PER_SEC) | |
41 | #define DHCP6_SOL_TIMEOUT (1 * USEC_PER_SEC) | |
42 | #define DHCP6_SOL_MAX_RT (120 * USEC_PER_SEC) | |
43 | #define DHCP6_REQ_TIMEOUT (1 * USEC_PER_SEC) | |
44 | #define DHCP6_REQ_MAX_RT (120 * USEC_PER_SEC) | |
45 | #define DHCP6_REQ_MAX_RC 10 | |
46 | #define DHCP6_REN_TIMEOUT (10 * USEC_PER_SEC) | |
47 | #define DHCP6_REN_MAX_RT (600 * USEC_PER_SEC) | |
48 | #define DHCP6_REB_TIMEOUT (10 * USEC_PER_SEC) | |
49 | #define DHCP6_REB_MAX_RT (600 * USEC_PER_SEC) | |
50 | ||
51 | typedef enum DHCP6State { | |
52 | DHCP6_STATE_STOPPED, | |
53 | DHCP6_STATE_INFORMATION_REQUEST, | |
54 | DHCP6_STATE_SOLICITATION, | |
55 | DHCP6_STATE_REQUEST, | |
56 | DHCP6_STATE_BOUND, | |
57 | DHCP6_STATE_RENEW, | |
58 | DHCP6_STATE_REBIND, | |
59 | DHCP6_STATE_STOPPING, | |
60 | _DHCP6_STATE_MAX, | |
61 | _DHCP6_STATE_INVALID = -EINVAL, | |
62 | } DHCP6State; | |
63 | ||
64 | /* https://www.iana.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xhtml#dhcpv6-parameters-1 */ | |
65 | typedef enum DHCP6MessageType { | |
66 | DHCP6_MESSAGE_SOLICIT = 1, /* RFC 8415 */ | |
67 | DHCP6_MESSAGE_ADVERTISE = 2, /* RFC 8415 */ | |
68 | DHCP6_MESSAGE_REQUEST = 3, /* RFC 8415 */ | |
69 | DHCP6_MESSAGE_CONFIRM = 4, /* RFC 8415 */ | |
70 | DHCP6_MESSAGE_RENEW = 5, /* RFC 8415 */ | |
71 | DHCP6_MESSAGE_REBIND = 6, /* RFC 8415 */ | |
72 | DHCP6_MESSAGE_REPLY = 7, /* RFC 8415 */ | |
73 | DHCP6_MESSAGE_RELEASE = 8, /* RFC 8415 */ | |
74 | DHCP6_MESSAGE_DECLINE = 9, /* RFC 8415 */ | |
75 | DHCP6_MESSAGE_RECONFIGURE = 10, /* RFC 8415 */ | |
76 | DHCP6_MESSAGE_INFORMATION_REQUEST = 11, /* RFC 8415 */ | |
77 | DHCP6_MESSAGE_RELAY_FORWARD = 12, /* RFC 8415 */ | |
78 | DHCP6_MESSAGE_RELAY_REPLY = 13, /* RFC 8415 */ | |
79 | DHCP6_MESSAGE_LEASE_QUERY = 14, /* RFC 5007 */ | |
80 | DHCP6_MESSAGE_LEASE_QUERY_REPLY = 15, /* RFC 5007 */ | |
81 | DHCP6_MESSAGE_LEASE_QUERY_DONE = 16, /* RFC 5460 */ | |
82 | DHCP6_MESSAGE_LEASE_QUERY_DATA = 17, /* RFC 5460 */ | |
83 | DHCP6_MESSAGE_RECONFIGURE_REQUEST = 18, /* RFC 6977 */ | |
84 | DHCP6_MESSAGE_RECONFIGURE_REPLY = 19, /* RFC 6977 */ | |
85 | DHCP6_MESSAGE_DHCPV4_QUERY = 20, /* RFC 7341 */ | |
86 | DHCP6_MESSAGE_DHCPV4_RESPONSE = 21, /* RFC 7341 */ | |
87 | DHCP6_MESSAGE_ACTIVE_LEASE_QUERY = 22, /* RFC 7653 */ | |
88 | DHCP6_MESSAGE_START_TLS = 23, /* RFC 7653 */ | |
89 | DHCP6_MESSAGE_BINDING_UPDATE = 24, /* RFC 8156 */ | |
90 | DHCP6_MESSAGE_BINDING_REPLY = 25, /* RFC 8156 */ | |
91 | DHCP6_MESSAGE_POOL_REQUEST = 26, /* RFC 8156 */ | |
92 | DHCP6_MESSAGE_POOL_RESPONSE = 27, /* RFC 8156 */ | |
93 | DHCP6_MESSAGE_UPDATE_REQUEST = 28, /* RFC 8156 */ | |
94 | DHCP6_MESSAGE_UPDATE_REQUEST_ALL = 29, /* RFC 8156 */ | |
95 | DHCP6_MESSAGE_UPDATE_DONE = 30, /* RFC 8156 */ | |
96 | DHCP6_MESSAGE_CONNECT = 31, /* RFC 8156 */ | |
97 | DHCP6_MESSAGE_CONNECT_REPLY = 32, /* RFC 8156 */ | |
98 | DHCP6_MESSAGE_DISCONNECT = 33, /* RFC 8156 */ | |
99 | DHCP6_MESSAGE_STATE = 34, /* RFC 8156 */ | |
100 | DHCP6_MESSAGE_CONTACT = 35, /* RFC 8156 */ | |
101 | _DHCP6_MESSAGE_TYPE_MAX, | |
102 | _DHCP6_MESSAGE_TYPE_INVALID = -EINVAL, | |
103 | } DHCP6MessageType; | |
104 | ||
105 | typedef enum DHCP6NTPSubOption { | |
106 | DHCP6_NTP_SUBOPTION_SRV_ADDR = 1, | |
107 | DHCP6_NTP_SUBOPTION_MC_ADDR = 2, | |
108 | DHCP6_NTP_SUBOPTION_SRV_FQDN = 3, | |
109 | _DHCP6_NTP_SUBOPTION_MAX, | |
110 | _DHCP6_NTP_SUBOPTION_INVALID = -EINVAL, | |
111 | } DHCP6NTPSubOption; | |
112 | ||
113 | /* | |
114 | * RFC 8415, RFC 5007 and RFC 7653 status codes: | |
115 | * https://www.iana.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xhtml#dhcpv6-parameters-5 | |
116 | */ | |
117 | typedef enum DHCP6Status { | |
118 | DHCP6_STATUS_SUCCESS = 0, | |
119 | DHCP6_STATUS_UNSPEC_FAIL = 1, | |
120 | DHCP6_STATUS_NO_ADDRS_AVAIL = 2, | |
121 | DHCP6_STATUS_NO_BINDING = 3, | |
122 | DHCP6_STATUS_NOT_ON_LINK = 4, | |
123 | DHCP6_STATUS_USE_MULTICAST = 5, | |
124 | DHCP6_STATUS_NO_PREFIX_AVAIL = 6, | |
125 | DHCP6_STATUS_UNKNOWN_QUERY_TYPE = 7, | |
126 | DHCP6_STATUS_MALFORMED_QUERY = 8, | |
127 | DHCP6_STATUS_NOT_CONFIGURED = 9, | |
128 | DHCP6_STATUS_NOT_ALLOWED = 10, | |
129 | DHCP6_STATUS_QUERY_TERMINATED = 11, | |
130 | DHCP6_STATUS_DATA_MISSING = 12, | |
131 | DHCP6_STATUS_CATCHUP_COMPLETE = 13, | |
132 | DHCP6_STATUS_NOT_SUPPORTED = 14, | |
133 | DHCP6_STATUS_TLS_CONNECTION_REFUSED = 15, | |
134 | DHCP6_STATUS_ADDRESS_IN_USE = 16, | |
135 | DHCP6_STATUS_CONFIGURATION_CONFLICT = 17, | |
136 | DHCP6_STATUS_MISSING_BINDING_INFORMATION = 18, | |
137 | DHCP6_STATUS_OUTDATED_BINDING_INFORMATION = 19, | |
138 | DHCP6_STATUS_SERVER_SHUTTING_DOWN = 20, | |
139 | DHCP6_STATUS_DNS_UPDATE_NOT_SUPPORTED = 21, | |
140 | DHCP6_STATUS_EXCESSIVE_TIME_SKEW = 22, | |
141 | _DHCP6_STATUS_MAX, | |
142 | _DHCP6_STATUS_INVALID = -EINVAL, | |
143 | } DHCP6Status; | |
144 | ||
145 | typedef enum DHCP6FQDNFlag { | |
146 | DHCP6_FQDN_FLAG_S = 1 << 0, | |
147 | DHCP6_FQDN_FLAG_O = 1 << 1, | |
148 | DHCP6_FQDN_FLAG_N = 1 << 2, | |
149 | } DHCP6FQDNFlag; | |
150 | ||
151 | const char* dhcp6_state_to_string(DHCP6State s) _const_; | |
152 | const char* dhcp6_message_type_to_string(DHCP6MessageType s) _const_; | |
153 | DHCP6MessageType dhcp6_message_type_from_string(const char *s) _pure_; | |
154 | const char* dhcp6_message_status_to_string(DHCP6Status s) _const_; | |
155 | DHCP6Status dhcp6_message_status_from_string(const char *s) _pure_; | |
156 | int dhcp6_message_status_to_errno(DHCP6Status s); |