1 /* dhcp6.h
2 
3    DHCPv6 Protocol structures... */
4 
5 /*
6  * Copyright (c) 2006-2017 by Internet Systems Consortium, Inc. ("ISC")
7  *
8  * This Source Code Form is subject to the terms of the Mozilla Public
9  * License, v. 2.0. If a copy of the MPL was not distributed with this
10  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
13  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14  * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
15  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
18  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19  *
20  *   Internet Systems Consortium, Inc.
21  *   950 Charter Street
22  *   Redwood City, CA 94063
23  *   <info@isc.org>
24  *   https://www.isc.org/
25  */
26 
27 
28 /* DHCPv6 Option codes: */
29 
30 #define D6O_CLIENTID				1 /* RFC3315 */
31 #define D6O_SERVERID				2
32 #define D6O_IA_NA				3
33 #define D6O_IA_TA				4
34 #define D6O_IAADDR				5
35 #define D6O_ORO					6
36 #define D6O_PREFERENCE				7
37 #define D6O_ELAPSED_TIME			8
38 #define D6O_RELAY_MSG				9
39 /* Option code 10 unassigned. */
40 #define D6O_AUTH				11
41 #define D6O_UNICAST				12
42 #define D6O_STATUS_CODE				13
43 #define D6O_RAPID_COMMIT			14
44 #define D6O_USER_CLASS				15
45 #define D6O_VENDOR_CLASS			16
46 #define D6O_VENDOR_OPTS				17
47 #define D6O_INTERFACE_ID			18
48 #define D6O_RECONF_MSG				19
49 #define D6O_RECONF_ACCEPT			20
50 #define D6O_SIP_SERVERS_DNS			21 /* RFC3319 */
51 #define D6O_SIP_SERVERS_ADDR			22 /* RFC3319 */
52 #define D6O_NAME_SERVERS			23 /* RFC3646 */
53 #define D6O_DOMAIN_SEARCH			24 /* RFC3646 */
54 #define D6O_IA_PD				25 /* RFC3633 */
55 #define D6O_IAPREFIX				26 /* RFC3633 */
56 #define D6O_NIS_SERVERS				27 /* RFC3898 */
57 #define D6O_NISP_SERVERS			28 /* RFC3898 */
58 #define D6O_NIS_DOMAIN_NAME			29 /* RFC3898 */
59 #define D6O_NISP_DOMAIN_NAME			30 /* RFC3898 */
60 #define D6O_SNTP_SERVERS			31 /* RFC4075 */
61 #define D6O_INFORMATION_REFRESH_TIME		32 /* RFC4242 */
62 #define D6O_BCMCS_SERVER_D			33 /* RFC4280 */
63 #define D6O_BCMCS_SERVER_A			34 /* RFC4280 */
64 /* 35 is unassigned */
65 #define D6O_GEOCONF_CIVIC			36 /* RFC4776 */
66 #define D6O_REMOTE_ID				37 /* RFC4649 */
67 #define D6O_SUBSCRIBER_ID			38 /* RFC4580 */
68 #define D6O_CLIENT_FQDN				39 /* RFC4704 */
69 #define D6O_PANA_AGENT				40 /* paa-option */
70 #define D6O_NEW_POSIX_TIMEZONE			41 /* RFC4833 */
71 #define D6O_NEW_TZDB_TIMEZONE			42 /* RFC4833 */
72 #define D6O_ERO					43 /* RFC4994 */
73 #define D6O_LQ_QUERY				44 /* RFC5007 */
74 #define D6O_CLIENT_DATA				45 /* RFC5007 */
75 #define D6O_CLT_TIME				46 /* RFC5007 */
76 #define D6O_LQ_RELAY_DATA			47 /* RFC5007 */
77 #define D6O_LQ_CLIENT_LINK			48 /* RFC5007 */
78 #define D6O_MIP6_HNIDF				49 /* RFC6610 */
79 #define D6O_MIP6_VDINF				50 /* RFC6610 */
80 #define D6O_V6_LOST				51 /* RFC5223 */
81 #define D6O_CAPWAP_AC_V6			52 /* RFC5417 */
82 #define D6O_RELAY_ID				53 /* RFC5460 */
83 #define D6O_IPV6_ADDRESS_MOS			54 /* RFC5678 */
84 #define D6O_IPV6_FQDN_MOS			55 /* RFC5678 */
85 #define D6O_NTP_SERVER				56 /* RFC5908 */
86 #define D6O_V6_ACCESS_DOMAIN			57 /* RFC5986 */
87 #define D6O_SIP_UA_CS_LIST			58 /* RFC6011 */
88 #define D6O_BOOTFILE_URL			59 /* RFC5970 */
89 #define D6O_BOOTFILE_PARAM			60 /* RFC5970 */
90 #define D6O_CLIENT_ARCH_TYPE			61 /* RFC5970 */
91 #define D6O_NII					62 /* RFC5970 */
92 #define D6O_GEOLOCATION				63 /* RFC6225 */
93 #define D6O_AFTR_NAME				64 /* RFC6334 */
94 #define D6O_ERP_LOCAL_DOMAIN_NAME		65 /* RFC6440 */
95 #define D6O_RSOO				66 /* RFC6422 */
96 #define D6O_PD_EXCLUDE				67 /* RFC6603 */
97 #define D6O_VSS					68 /* RFC6607 */
98 #define D6O_MIP6_IDINF				69 /* RFC6610 */
99 #define D6O_MIP6_UDINF				70 /* RFC6610 */
100 #define D6O_MIP6_HNP				71 /* RFC6610 */
101 #define D6O_MIP6_HAA				72 /* RFC6610 */
102 #define D6O_MIP6_HAF				73 /* RFC6610 */
103 #define D6O_RDNSS_SELECTION			74 /* RFC6731 */
104 #define D6O_KRB_PRINCIPAL_NAME			75 /* RFC6784 */
105 #define D6O_KRB_REALM_NAME			76 /* RFC6784 */
106 #define D6O_KRB_DEFAULT_REALM_NAME		77 /* RFC6784 */
107 #define D6O_KRB_KDC				78 /* RFC6784 */
108 #define D6O_CLIENT_LINKLAYER_ADDR		79 /* RFC6939 */
109 #define D6O_LINK_ADDRESS			80 /* RFC6977 */
110 #define D6O_RADIUS				81 /* RFC7037 */
111 #define D6O_SOL_MAX_RT				82 /* RFC7083 */
112 #define D6O_INF_MAX_RT				83 /* RFC7083 */
113 #define D6O_ADDRSEL				84 /* RFC7078 */
114 #define D6O_ADDRSEL_TABLE			85 /* RFC7078 */
115 #define D6O_V6_PCP_SERVER			86 /* RFC7291 */
116 #define D6O_DHCPV4_MSG				87 /* RFC7341 */
117 #define D6O_DHCP4_O_DHCP6_SERVER		88 /* RFC7341 */
118 /* not yet assigned but next free value */
119 #define D6O_RELAY_SOURCE_PORT			135 /* I-D */
120 
121 /*
122  * Status Codes, from RFC 3315 section 24.4, and RFC 3633, 5007, 5460.
123  */
124 #define STATUS_Success		 0
125 #define STATUS_UnspecFail	 1
126 #define STATUS_NoAddrsAvail	 2
127 #define STATUS_NoBinding	 3
128 #define STATUS_NotOnLink	 4
129 #define STATUS_UseMulticast	 5
130 #define STATUS_NoPrefixAvail	 6
131 #define STATUS_UnknownQueryType	 7
132 #define STATUS_MalformedQuery	 8
133 #define STATUS_NotConfigured	 9
134 #define STATUS_NotAllowed	10
135 #define STATUS_QueryTerminated	11
136 
137 /*
138  * DHCPv6 message types, defined in section 5.3 of RFC 3315
139  */
140 #define DHCPV6_SOLICIT		    1
141 #define DHCPV6_ADVERTISE	    2
142 #define DHCPV6_REQUEST		    3
143 #define DHCPV6_CONFIRM		    4
144 #define DHCPV6_RENEW		    5
145 #define DHCPV6_REBIND		    6
146 #define DHCPV6_REPLY		    7
147 #define DHCPV6_RELEASE		    8
148 #define DHCPV6_DECLINE		    9
149 #define DHCPV6_RECONFIGURE	   10
150 #define DHCPV6_INFORMATION_REQUEST 11
151 #define DHCPV6_RELAY_FORW	   12
152 #define DHCPV6_RELAY_REPL	   13
153 #define DHCPV6_LEASEQUERY	   14	/* RFC5007 */
154 #define DHCPV6_LEASEQUERY_REPLY	   15	/* RFC5007 */
155 #define DHCPV6_LEASEQUERY_DONE	   16	/* RFC5460 */
156 #define DHCPV6_LEASEQUERY_DATA	   17	/* RFC5460 */
157 #define DHCPV6_RECONFIGURE_REQUEST 18	/* RFC6977 */
158 #define DHCPV6_RECONFIGURE_REPLY   19	/* RFC6977 */
159 #define DHCPV6_DHCPV4_QUERY	   20	/* RFC7341 */
160 #define DHCPV6_DHCPV4_RESPONSE	   21	/* RFC7341 */
161 
162 extern const char *dhcpv6_type_names[];
163 extern const int dhcpv6_type_name_max;
164 
165 /* DUID type definitions (RFC3315 section 9).
166  */
167 #define DUID_LLT	1
168 #define DUID_EN		2
169 #define DUID_LL		3
170 #define DUID_UUID	4	/* RFC6355 */
171 
172 /* Offsets into IA_*'s where Option spaces commence.  */
173 #define IA_NA_OFFSET 12 /* IAID, T1, T2, all 4 octets each */
174 #define IA_TA_OFFSET  4 /* IAID only, 4 octets */
175 #define IA_PD_OFFSET 12 /* IAID, T1, T2, all 4 octets each */
176 
177 /* Offset into IAADDR's where Option spaces commence. */
178 #define IAADDR_OFFSET 24
179 
180 /* Offset into IAPREFIX's where Option spaces commence. */
181 #define IAPREFIX_OFFSET 25
182 
183 /* Offset into LQ_QUERY's where Option spaces commence. */
184 #define LQ_QUERY_OFFSET 17
185 
186 /*
187  * DHCPv6 well-known multicast addressess, from section 5.1 of RFC 3315
188  */
189 #define All_DHCP_Relay_Agents_and_Servers "FF02::1:2"
190 #define All_DHCP_Servers "FF05::1:3"
191 
192 /*
193  * DHCPv6 Retransmission Constants (RFC3315 section 5.5, RFC 5007)
194  */
195 
196 #define SOL_MAX_DELAY     1
197 #define SOL_TIMEOUT       1
198 #define SOL_MAX_RT      120
199 #define REQ_TIMEOUT       1
200 #define REQ_MAX_RT       30
201 #define REQ_MAX_RC       10
202 #define CNF_MAX_DELAY     1
203 #define CNF_TIMEOUT       1
204 #define CNF_MAX_RT        4
205 #define CNF_MAX_RD       10
206 #define REN_TIMEOUT      10
207 #define REN_MAX_RT      600
208 #define REB_TIMEOUT      10
209 #define REB_MAX_RT      600
210 #define INF_MAX_DELAY     1
211 #define INF_TIMEOUT       1
212 #define INF_MAX_RT      120
213 #define REL_TIMEOUT       1
214 #define REL_MAX_RC        5
215 #define DEC_TIMEOUT       1
216 #define DEC_MAX_RC        5
217 #define REC_TIMEOUT       2
218 #define REC_MAX_RC        8
219 #define HOP_COUNT_LIMIT  32
220 #define LQ6_TIMEOUT       1
221 #define LQ6_MAX_RT       10
222 #define LQ6_MAX_RC        5
223 
224 /*
225  * Normal packet format, defined in section 6 of RFC 3315
226  */
227 struct dhcpv6_packet {
228 	unsigned char msg_type;
229 	unsigned char transaction_id[3];
230 	unsigned char options[FLEXIBLE_ARRAY_MEMBER];
231 };
232 
233 /* Offset into DHCPV6 Reply packets where Options spaces commence. */
234 #define REPLY_OPTIONS_INDEX 4
235 
236 /*
237  * Relay packet format, defined in section 7 of RFC 3315
238  */
239 struct dhcpv6_relay_packet {
240 	unsigned char msg_type;
241 	unsigned char hop_count;
242 	unsigned char link_address[16];
243 	unsigned char peer_address[16];
244 	unsigned char options[FLEXIBLE_ARRAY_MEMBER];
245 };
246 #define MAX_V6RELAY_HOPS 32
247 
248 /*
249  * DHCPv4-over-DHCPv6 packet format, defined in RFC 4731
250  */
251 struct dhcpv4_over_dhcpv6_packet {
252 	unsigned char msg_type;
253 	unsigned char flags[3];
254 	unsigned char options[FLEXIBLE_ARRAY_MEMBER];
255 };
256 #define DHCP4O6_QUERY_UNICAST	128
257 
258 /* DHCPv4-over-DHCPv6 ISC vendor suboptions */
259 #define D4O6_INTERFACE		60000
260 #define D4O6_SRC_ADDRESS	60001
261 
262 /* Leasequery query-types (RFC 5007, 5460) */
263 
264 #define LQ6QT_BY_ADDRESS	1
265 #define LQ6QT_BY_CLIENTID	2
266 #define LQ6QT_BY_RELAY_ID	3
267 #define LQ6QT_BY_LINK_ADDRESS	4
268 #define LQ6QT_BY_REMOTE_ID	5
269 
270 /*
271  * DUID time starts 2000-01-01.
272  * This constant is the number of seconds since 1970-01-01,
273  * when the Unix epoch began.
274  */
275 #define DUID_TIME_EPOCH 946684800
276 
277 /* Information-Request Time option (RFC 4242) */
278 
279 #define IRT_DEFAULT	86400
280 #define IRT_MINIMUM	600
281 
282 #define EUI_64_ID_LEN 12  /* 2 for duid-type, 2 for hardware type, 8 for ID */
283 #define IAID_LEN 4
284 
285 /* Offsets with iasubopt wire data of data values for IA_NA and TA */
286 #define IASUBOPT_NA_ADDR_OFFSET		0
287 #define IASUBOPT_NA_PREF_OFFSET		16
288 #define IASUBOPT_NA_VALID_OFFSET	20
289 #define IASUBOPT_NA_LEN			24
290 
291 /* Offsets with iasubopt wire data of data values for PD */
292 #define IASUBOPT_PD_PREF_OFFSET		0
293 #define IASUBOPT_PD_VALID_OFFSET	4
294 #define IASUBOPT_PD_PREFLEN_OFFSET	8
295 #define IASUBOPT_PD_PREFIX_OFFSET	9
296 #define IASUBOPT_PD_LEN			25
297