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