std_option_defs.h 28.4 KB
Newer Older
1
// Copyright (C) 2012-2018 Internet Systems Consortium, Inc. ("ISC")
2
//
3 4 5
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 7 8 9 10

#ifndef STD_OPTION_DEFS_H
#define STD_OPTION_DEFS_H

#include <dhcp/option_data_types.h>
11 12
#include <dhcp/dhcp4.h>
#include <dhcp/dhcp6.h>
13
#include <dhcp/option_space.h>
14

15 16 17 18
// NOTE:
// When adding a new space, make sure you also update
// src/lib/yang/adaptor_option.cc

19 20 21
namespace isc {
namespace dhcp {

22 23 24 25 26 27 28
namespace {

/// @brief Declare an array holding parameters used to create instance
/// of a definition for option comprising a record of data fields.
///
/// @param name name of the array being declared.
#ifndef RECORD_DECL
29
#define RECORD_DECL(name, ...) const OptionDataType name[] = { __VA_ARGS__ }
30 31 32 33 34 35 36 37 38 39
#endif

/// @brief A pair of values: one pointing to the array holding types of
/// data fields belonging to the record, and size of this array.
///
/// @param name name of the array holding data fields' types.
#ifndef RECORD_DEF
#define RECORD_DEF(name) name, sizeof(name) / sizeof(name[0])
#endif

40 41 42 43
#ifndef NO_RECORD_DEF
#define NO_RECORD_DEF 0, 0
#endif

44 45 46
// SLP Directory Agent option.
RECORD_DECL(DIRECTORY_AGENT_RECORDS, OPT_BOOLEAN_TYPE, OPT_IPV4_ADDRESS_TYPE);

47 48 49 50 51
// SLP Service Scope option.
//
// The scope list is optional.
RECORD_DECL(SERVICE_SCOPE_RECORDS, OPT_BOOLEAN_TYPE, OPT_STRING_TYPE);

52 53 54 55 56 57 58 59
// fqdn option record fields.
//
// Note that the flags field indicates the type of domain
// name encoding. There is a choice between deprecated
// ASCII encoding and compressed encoding described in
// RFC 1035, section 3.1. The latter could be handled
// by OPT_FQDN_TYPE but we can't use it here because
// clients may request ASCII encoding.
60 61
RECORD_DECL(FQDN_RECORDS, OPT_UINT8_TYPE, OPT_UINT8_TYPE, OPT_UINT8_TYPE,
            OPT_FQDN_TYPE);
62

63 64 65 66 67
// V-I Vendor Class record fields.
//
// Opaque data is represented here by the binary data field.
RECORD_DECL(VIVCO_RECORDS, OPT_UINT32_TYPE, OPT_BINARY_TYPE);

Shawn Routhier's avatar
Shawn Routhier committed
68 69
// RFC4578 (PXE) record fields
//
70
// Three 1 byte fields to describe a network interface: type, major and minor
Shawn Routhier's avatar
Shawn Routhier committed
71
RECORD_DECL(CLIENT_NDI_RECORDS, OPT_UINT8_TYPE, OPT_UINT8_TYPE, OPT_UINT8_TYPE);
Josh Soref's avatar
Josh Soref committed
72
// A client identifier: a 1 byte type field followed by opaque data depending on the type
Shawn Routhier's avatar
Shawn Routhier committed
73 74
RECORD_DECL(UUID_GUID_RECORDS, OPT_UINT8_TYPE, OPT_BINARY_TYPE);

75 76 77 78 79 80
// RFC6731 DHCPv4 Recursive DNS Server Selection option.
//
// Flag, two addresses and domain list
RECORD_DECL(V4_RDNSS_SELECT_RECORDS, OPT_UINT8_TYPE, OPT_IPV4_ADDRESS_TYPE,
            OPT_IPV4_ADDRESS_TYPE, OPT_FQDN_TYPE);

81 82 83
// RFC7618 DHCPv4 Port Parameter option.
//
// PSID offset, PSID-len and PSID
84
RECORD_DECL(V4_PORTPARAMS_RECORDS, OPT_UINT8_TYPE, OPT_PSID_TYPE);
85

86 87 88 89 90 91
// RFC5969 DHCPv6 6RD option.
//
// two 8 bit lengthes, an IPv6 address and one or more IPv4 addresses
RECORD_DECL(OPT_6RD_RECORDS, OPT_UINT8_TYPE, OPT_UINT8_TYPE,
            OPT_IPV6_ADDRESS_TYPE, OPT_IPV4_ADDRESS_TYPE);

92
/// @brief Definitions of standard DHCPv4 options.
93
const OptionDefParams STANDARD_V4_OPTION_DEFINITIONS[] = {
94
    { "subnet-mask", DHO_SUBNET_MASK, OPT_IPV4_ADDRESS_TYPE, false, NO_RECORD_DEF, "" },
95
    { "time-offset", DHO_TIME_OFFSET, OPT_INT32_TYPE, false, NO_RECORD_DEF, "" },
96 97
    { "routers", DHO_ROUTERS, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
    { "time-servers", DHO_TIME_SERVERS, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
98
    { "name-servers", DHO_NAME_SERVERS, OPT_IPV4_ADDRESS_TYPE,
99
      true, NO_RECORD_DEF, "" },
100
    { "domain-name-servers", DHO_DOMAIN_NAME_SERVERS,
101 102
      OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
    { "log-servers", DHO_LOG_SERVERS, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
103
    { "cookie-servers", DHO_COOKIE_SERVERS, OPT_IPV4_ADDRESS_TYPE,
104 105 106
      true, NO_RECORD_DEF, "" },
    { "lpr-servers", DHO_LPR_SERVERS, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
    { "impress-servers", DHO_IMPRESS_SERVERS, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
107
    { "resource-location-servers", DHO_RESOURCE_LOCATION_SERVERS,
108 109 110 111
      OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
    { "host-name", DHO_HOST_NAME, OPT_STRING_TYPE, false, NO_RECORD_DEF, "" },
    { "boot-size", DHO_BOOT_SIZE, OPT_UINT16_TYPE, false, NO_RECORD_DEF, "" },
    { "merit-dump", DHO_MERIT_DUMP, OPT_STRING_TYPE, false, NO_RECORD_DEF, "" },
112
    { "domain-name", DHO_DOMAIN_NAME, OPT_STRING_TYPE, false, NO_RECORD_DEF, "" },
113 114
    { "swap-server", DHO_SWAP_SERVER, OPT_IPV4_ADDRESS_TYPE, false, NO_RECORD_DEF, "" },
    { "root-path", DHO_ROOT_PATH, OPT_STRING_TYPE, false, NO_RECORD_DEF, "" },
115
    { "extensions-path", DHO_EXTENSIONS_PATH, OPT_STRING_TYPE,
116 117
      false, NO_RECORD_DEF, "" },
    { "ip-forwarding", DHO_IP_FORWARDING, OPT_BOOLEAN_TYPE, false, NO_RECORD_DEF, "" },
118
    { "non-local-source-routing", DHO_NON_LOCAL_SOURCE_ROUTING,
119 120
      OPT_BOOLEAN_TYPE, false, NO_RECORD_DEF, "" },
    { "policy-filter", DHO_POLICY_FILTER, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
121
    { "max-dgram-reassembly", DHO_MAX_DGRAM_REASSEMBLY,
122 123
      OPT_UINT16_TYPE, false, NO_RECORD_DEF, "" },
    { "default-ip-ttl", DHO_DEFAULT_IP_TTL, OPT_UINT8_TYPE, false, NO_RECORD_DEF, "" },
124
    { "path-mtu-aging-timeout", DHO_PATH_MTU_AGING_TIMEOUT,
125
      OPT_UINT32_TYPE, false, NO_RECORD_DEF, "" },
126
    { "path-mtu-plateau-table", DHO_PATH_MTU_PLATEAU_TABLE,
127 128
      OPT_UINT16_TYPE, true, NO_RECORD_DEF, "" },
    { "interface-mtu", DHO_INTERFACE_MTU, OPT_UINT16_TYPE, false, NO_RECORD_DEF, "" },
129
    { "all-subnets-local", DHO_ALL_SUBNETS_LOCAL,
130
      OPT_BOOLEAN_TYPE, false, NO_RECORD_DEF, "" },
131
    { "broadcast-address", DHO_BROADCAST_ADDRESS,
132
      OPT_IPV4_ADDRESS_TYPE, false, NO_RECORD_DEF, "" },
133
    { "perform-mask-discovery", DHO_PERFORM_MASK_DISCOVERY,
134 135
      OPT_BOOLEAN_TYPE, false, NO_RECORD_DEF, "" },
    { "mask-supplier", DHO_MASK_SUPPLIER, OPT_BOOLEAN_TYPE, false, NO_RECORD_DEF, "" },
136
    { "router-discovery", DHO_ROUTER_DISCOVERY,
137
      OPT_BOOLEAN_TYPE, false, NO_RECORD_DEF, "" },
138
    { "router-solicitation-address", DHO_ROUTER_SOLICITATION_ADDRESS,
139
      OPT_IPV4_ADDRESS_TYPE, false, NO_RECORD_DEF, "" },
140
    { "static-routes", DHO_STATIC_ROUTES,
141
      OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
142
    { "trailer-encapsulation", DHO_TRAILER_ENCAPSULATION,
143
      OPT_BOOLEAN_TYPE, false, NO_RECORD_DEF, "" },
144
    { "arp-cache-timeout", DHO_ARP_CACHE_TIMEOUT,
145
      OPT_UINT32_TYPE, false, NO_RECORD_DEF, "" },
146
    { "ieee802-3-encapsulation", DHO_IEEE802_3_ENCAPSULATION,
147 148
      OPT_BOOLEAN_TYPE, false, NO_RECORD_DEF, "" },
    { "default-tcp-ttl", DHO_DEFAULT_TCP_TTL, OPT_UINT8_TYPE, false, NO_RECORD_DEF, "" },
149
    { "tcp-keepalive-interval", DHO_TCP_KEEPALIVE_INTERVAL,
150
      OPT_UINT32_TYPE, false, NO_RECORD_DEF, "" },
151
    { "tcp-keepalive-garbage", DHO_TCP_KEEPALIVE_GARBAGE,
152 153 154 155
      OPT_BOOLEAN_TYPE, false, NO_RECORD_DEF, "" },
    { "nis-domain", DHO_NIS_DOMAIN, OPT_STRING_TYPE, false, NO_RECORD_DEF, "" },
    { "nis-servers", DHO_NIS_SERVERS, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
    { "ntp-servers", DHO_NTP_SERVERS, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
156
    /// vendor-encapsulated-options (43) is deferred
157
    { "netbios-name-servers", DHO_NETBIOS_NAME_SERVERS,
158
      OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
159
    { "netbios-dd-server", DHO_NETBIOS_DD_SERVER,
160
      OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
161
    { "netbios-node-type", DHO_NETBIOS_NODE_TYPE,
162 163 164
      OPT_UINT8_TYPE, false, NO_RECORD_DEF, "" },
    { "netbios-scope", DHO_NETBIOS_SCOPE, OPT_STRING_TYPE, false, NO_RECORD_DEF, "" },
    { "font-servers", DHO_FONT_SERVERS, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
165
    { "x-display-manager", DHO_X_DISPLAY_MANAGER,
166
      OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
167
    { "dhcp-requested-address", DHO_DHCP_REQUESTED_ADDRESS,
168 169
      OPT_IPV4_ADDRESS_TYPE, false, NO_RECORD_DEF, "" },
    { "dhcp-lease-time", DHO_DHCP_LEASE_TIME, OPT_UINT32_TYPE, false, NO_RECORD_DEF, "" },
170
    { "dhcp-option-overload", DHO_DHCP_OPTION_OVERLOAD,
171 172
      OPT_UINT8_TYPE, false, NO_RECORD_DEF, "" },
    { "dhcp-message-type", DHO_DHCP_MESSAGE_TYPE, OPT_UINT8_TYPE, false, NO_RECORD_DEF, "" },
173
    { "dhcp-server-identifier", DHO_DHCP_SERVER_IDENTIFIER,
174
      OPT_IPV4_ADDRESS_TYPE, false, NO_RECORD_DEF, "" },
175
    { "dhcp-parameter-request-list", DHO_DHCP_PARAMETER_REQUEST_LIST,
176 177
      OPT_UINT8_TYPE, true, NO_RECORD_DEF, "" },
    { "dhcp-message", DHO_DHCP_MESSAGE, OPT_STRING_TYPE, false, NO_RECORD_DEF, "" },
178
    { "dhcp-max-message-size", DHO_DHCP_MAX_MESSAGE_SIZE,
179 180
      OPT_UINT16_TYPE, false, NO_RECORD_DEF, "" },
    { "dhcp-renewal-time", DHO_DHCP_RENEWAL_TIME, OPT_UINT32_TYPE, false, NO_RECORD_DEF, "" },
181
    { "dhcp-rebinding-time", DHO_DHCP_REBINDING_TIME,
182
      OPT_UINT32_TYPE, false, NO_RECORD_DEF, "" },
183
    { "vendor-class-identifier", DHO_VENDOR_CLASS_IDENTIFIER,
184
      OPT_STRING_TYPE, false, NO_RECORD_DEF, "" },
185
    { "dhcp-client-identifier", DHO_DHCP_CLIENT_IDENTIFIER,
186 187 188
      OPT_BINARY_TYPE, false, NO_RECORD_DEF, "" },
    { "nwip-domain-name", DHO_NWIP_DOMAIN_NAME, OPT_STRING_TYPE, false, NO_RECORD_DEF, "" },
    { "nwip-suboptions", DHO_NWIP_SUBOPTIONS, OPT_BINARY_TYPE, false, NO_RECORD_DEF, "" },
189 190
    { "nisplus-domain-name", DHO_NISP_DOMAIN_NAME, OPT_STRING_TYPE, false, NO_RECORD_DEF, "" },
    { "nisplus-servers", DHO_NISP_SERVER_ADDR, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
191 192 193 194
    { "tftp-server-name", DHO_TFTP_SERVER_NAME, OPT_STRING_TYPE, false,
      NO_RECORD_DEF, "" },
    { "boot-file-name", DHO_BOOT_FILE_NAME, OPT_STRING_TYPE, false,
      NO_RECORD_DEF, "" },
195 196 197 198 199 200 201 202 203
    { "mobile-ip-home-agent", DHO_HOME_AGENT_ADDRS, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
    { "smtp-server", DHO_SMTP_SERVER, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
    { "pop-server", DHO_POP3_SERVER, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
    { "nntp-server", DHO_NNTP_SERVER, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
    { "www-server", DHO_WWW_SERVER, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
    { "finger-server", DHO_FINGER_SERVER, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
    { "irc-server", DHO_IRC_SERVER, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
    { "streettalk-server", DHO_STREETTALK_SERVER, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
    { "streettalk-directory-assistance-server", DHO_STDASERVER, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
204
    { "user-class", DHO_USER_CLASS, OPT_BINARY_TYPE, false, NO_RECORD_DEF, "" },
205 206
    { "slp-directory-agent", DHO_DIRECTORY_AGENT, OPT_RECORD_TYPE, true,
      RECORD_DEF(DIRECTORY_AGENT_RECORDS), "" },
207 208
    { "slp-service-scope", DHO_SERVICE_SCOPE, OPT_RECORD_TYPE, false,
      RECORD_DEF(SERVICE_SCOPE_RECORDS), "" },
209
    { "fqdn", DHO_FQDN, OPT_RECORD_TYPE, false, RECORD_DEF(FQDN_RECORDS), "" },
210
    { "dhcp-agent-options", DHO_DHCP_AGENT_OPTIONS,
211
      OPT_EMPTY_TYPE, false, NO_RECORD_DEF, "dhcp-agent-options-space" },
212 213 214 215 216
    { "nds-servers", DHO_NDS_SERVERS, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
    { "nds-tree-name", DHO_NDS_TREE_NAME, OPT_STRING_TYPE, false, NO_RECORD_DEF, "" },
    { "nds-context", DHO_NDS_CONTEXT, OPT_STRING_TYPE, false, NO_RECORD_DEF, "" },
    { "bcms-controller-names", DHO_BCMCS_DOMAIN_NAME_LIST, OPT_FQDN_TYPE, true, NO_RECORD_DEF, "" },
    { "bcms-controller-address", DHO_BCMCS_IPV4_ADDR, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
217 218 219 220 221 222
    // Unfortunatelly the AUTHENTICATE option contains a 64-bit
    // data field called 'replay-detection' that can't be added
    // as a record field to a custom option. Also, there is no
    // dedicated option class to handle it so we simply return
    // binary option type for now.
    // @todo implement a class to handle AUTH option.
223
    { "authenticate", DHO_AUTHENTICATE, OPT_BINARY_TYPE, false, NO_RECORD_DEF, "" },
224
    { "client-last-transaction-time", DHO_CLIENT_LAST_TRANSACTION_TIME,
225 226
      OPT_UINT32_TYPE, false, NO_RECORD_DEF, "" },
    { "associated-ip", DHO_ASSOCIATED_IP, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
Shawn Routhier's avatar
Shawn Routhier committed
227 228 229
    { "client-system", DHO_SYSTEM, OPT_UINT16_TYPE, true, NO_RECORD_DEF, "" },
    { "client-ndi", DHO_NDI, OPT_RECORD_TYPE, false, RECORD_DEF(CLIENT_NDI_RECORDS), "" },
    { "uuid-guid", DHO_UUID_GUID, OPT_RECORD_TYPE, false, RECORD_DEF(UUID_GUID_RECORDS), "" },
230 231 232 233 234 235 236 237 238
    { "uap-servers", DHO_USER_AUTH, OPT_STRING_TYPE, false, NO_RECORD_DEF, "" },
    { "geoconf-civic", DHO_GEOCONF_CIVIC, OPT_BINARY_TYPE, false, NO_RECORD_DEF, "" },
    { "pcode", DHO_PCODE, OPT_STRING_TYPE, false, NO_RECORD_DEF, "" },
    { "tcode", DHO_TCODE, OPT_STRING_TYPE, false, NO_RECORD_DEF, "" },
    { "netinfo-server-address", DHO_NETINFO_ADDR, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
    { "netinfo-server-tag", DHO_NETINFO_TAG, OPT_STRING_TYPE, false, NO_RECORD_DEF, "" },
    { "default-url", DHO_URL, OPT_STRING_TYPE, false, NO_RECORD_DEF, "" },
    { "auto-config", DHO_AUTO_CONFIG, OPT_UINT8_TYPE, false, NO_RECORD_DEF, "" },
    { "name-service-search", DHO_NAME_SERVICE_SEARCH, OPT_UINT16_TYPE, true, NO_RECORD_DEF, "" },
239
    { "subnet-selection", DHO_SUBNET_SELECTION,
240
      OPT_IPV4_ADDRESS_TYPE, false, NO_RECORD_DEF, "" },
241
    { "domain-search", DHO_DOMAIN_SEARCH, OPT_FQDN_TYPE, true, NO_RECORD_DEF, "" },
242 243
    { "vivco-suboptions", DHO_VIVCO_SUBOPTIONS, OPT_RECORD_TYPE,
      false, RECORD_DEF(VIVCO_RECORDS), "" },
244 245 246 247 248 249 250 251 252 253 254 255
    // Vendor-Identifying Vendor Specific Information option payload begins with a
    // 32-bit log enterprise number, followed by a tuple of data-len/option-data.
    // The format defined here includes 32-bit field holding enterprise number.
    // This allows for specifying option-data information where the enterprise-id
    // is represented by a uint32_t value. Previously we represented this option
    // as a binary, but that would imply that enterprise number would have to be
    // represented in binary format in the server configuration. That would be
    // inconvenient and non-intuitive.
    /// @todo We need to extend support for vendor options with ability to specify
    /// multiple enterprise numbers for a single option. Perhaps it would be
    /// ok to specify multiple instances of the "vivso-suboptions" which will be
    /// combined in a single option by the server before responding to a client.
256
    { "vivso-suboptions", DHO_VIVSO_SUBOPTIONS, OPT_UINT32_TYPE,
257 258 259 260 261
      false, NO_RECORD_DEF, "" },
    { "pana-agent", DHO_PANA_AGENT, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
    { "v4-lost", DHO_V4_LOST, OPT_FQDN_TYPE, false, NO_RECORD_DEF, "" },
    { "capwap-ac-v4", DHO_CAPWAP_AC_V4, OPT_IPV4_ADDRESS_TYPE, true, NO_RECORD_DEF, "" },
    { "sip-ua-cs-domains", DHO_SIP_UA_CONF_SERVICE_DOMAINS, OPT_FQDN_TYPE, true, NO_RECORD_DEF, "" },
262 263
    { "rdnss-selection", DHO_RDNSS_SELECT, OPT_RECORD_TYPE, true,
      RECORD_DEF(V4_RDNSS_SELECT_RECORDS), "" },
264 265 266
    { "v4-portparams", DHO_V4_PORTPARAMS, OPT_RECORD_TYPE, false,
      RECORD_DEF(V4_PORTPARAMS_RECORDS), "" },
    { "v4-captive-portal", DHO_V4_CAPTIVE_PORTAL, OPT_STRING_TYPE, false, NO_RECORD_DEF, "" },
267
    { "option-6rd", DHO_6RD, OPT_RECORD_TYPE, true, RECORD_DEF(OPT_6RD_RECORDS), "" },
268
    { "v4-access-domain", DHO_V4_ACCESS_DOMAIN, OPT_FQDN_TYPE, false, NO_RECORD_DEF, "" }
269

Andrei Pavel's avatar
Andrei Pavel committed
270
        // @todo add definitions for all remaining options.
271 272 273
};

/// Number of option definitions defined.
274 275
const int STANDARD_V4_OPTION_DEFINITIONS_SIZE =
    sizeof(STANDARD_V4_OPTION_DEFINITIONS) / sizeof(STANDARD_V4_OPTION_DEFINITIONS[0]);
276

277 278
/// Last resort definitions (only option 43 for now, these definitions
/// are applied in deferred unpacking when none is found).
Francis Dupont's avatar
Francis Dupont committed
279 280 281
const OptionDefParams LAST_RESORT_V4_OPTION_DEFINITIONS[] = {
    { "vendor-encapsulated-options", DHO_VENDOR_ENCAPSULATED_OPTIONS,
      OPT_EMPTY_TYPE, false, NO_RECORD_DEF, "vendor-encapsulated-options-space" }
282 283
};

Francis Dupont's avatar
Francis Dupont committed
284 285
const int LAST_RESORT_V4_OPTION_DEFINITIONS_SIZE = 1;

286 287
/// Start Definition of DHCPv6 options

288
// client-fqdn
289
RECORD_DECL(CLIENT_FQDN_RECORDS, OPT_UINT8_TYPE, OPT_FQDN_TYPE);
290
// geoconf-civic
291
RECORD_DECL(GEOCONF_CIVIC_RECORDS, OPT_UINT8_TYPE, OPT_UINT16_TYPE,
292 293
            OPT_BINARY_TYPE);
// iaddr
294
RECORD_DECL(IAADDR_RECORDS, OPT_IPV6_ADDRESS_TYPE, OPT_UINT32_TYPE,
295 296
            OPT_UINT32_TYPE);
// ia-na
297
RECORD_DECL(IA_NA_RECORDS, OPT_UINT32_TYPE, OPT_UINT32_TYPE, OPT_UINT32_TYPE);
298
// ia-pd
299
RECORD_DECL(IA_PD_RECORDS, OPT_UINT32_TYPE, OPT_UINT32_TYPE, OPT_UINT32_TYPE);
300
// ia-prefix
301
RECORD_DECL(IA_PREFIX_RECORDS, OPT_UINT32_TYPE, OPT_UINT32_TYPE,
302
            OPT_UINT8_TYPE, OPT_IPV6_ADDRESS_TYPE);
303
// lq-query
304
RECORD_DECL(LQ_QUERY_RECORDS, OPT_UINT8_TYPE, OPT_IPV6_ADDRESS_TYPE);
305
// lq-relay-data
306
RECORD_DECL(LQ_RELAY_DATA_RECORDS, OPT_IPV6_ADDRESS_TYPE, OPT_BINARY_TYPE);
307
// remote-id
308
RECORD_DECL(REMOTE_ID_RECORDS, OPT_UINT32_TYPE, OPT_BINARY_TYPE);
309 310 311 312 313 314 315
// s46-rule
RECORD_DECL(S46_RULE, OPT_UINT8_TYPE, OPT_UINT8_TYPE, OPT_UINT8_TYPE,
            OPT_IPV4_ADDRESS_TYPE, OPT_IPV6_PREFIX_TYPE);
// s46-v4v6bind
RECORD_DECL(S46_V4V6BIND, OPT_IPV4_ADDRESS_TYPE, OPT_IPV6_PREFIX_TYPE);
// s46-portparams
RECORD_DECL(S46_PORTPARAMS, OPT_UINT8_TYPE, OPT_PSID_TYPE);
316
// status-code
317
RECORD_DECL(STATUS_CODE_RECORDS, OPT_UINT16_TYPE, OPT_STRING_TYPE);
318
// vendor-class
319
RECORD_DECL(VENDOR_CLASS_RECORDS, OPT_UINT32_TYPE, OPT_BINARY_TYPE);
320 321 322
// rdnss-selection
RECORD_DECL(V6_RDNSS_SELECT_RECORDS, OPT_IPV6_ADDRESS_TYPE, OPT_UINT8_TYPE,
            OPT_FQDN_TYPE);
323 324 325
// sedhcpv6 signature
RECORD_DECL(SIGNATURE_RECORDS, OPT_UINT8_TYPE, OPT_UINT8_TYPE,
            OPT_BINARY_TYPE);
326

Shawn Routhier's avatar
Shawn Routhier committed
327 328 329 330 331
// RFC5970 (PXE) Class record fields
//
// Three 1 byte fileds to describe a network interface: type, major and minor
RECORD_DECL(CLIENT_NII_RECORDS, OPT_UINT8_TYPE, OPT_UINT8_TYPE, OPT_UINT8_TYPE);

332
/// Standard DHCPv6 option definitions.
333 334 335
///
/// @warning in this array, the initializers are provided for all
/// OptionDefParams struct's members despite initializers for
Andrei Pavel's avatar
Andrei Pavel committed
336
/// 'records' and 'record_size' could be omitted for entries for
337
/// which 'type' does not equal to OPT_RECORD_TYPE. If initializers
Andrei Pavel's avatar
Andrei Pavel committed
338
/// are omitted the corresponding values should default to 0.
339 340 341
/// This however does not work on Solaris (GCC) which issues a
/// warning about lack of initializers for some struct members
/// causing build to fail.
342
const OptionDefParams STANDARD_V6_OPTION_DEFINITIONS[] = {
343 344 345 346 347 348 349 350 351
    { "clientid", D6O_CLIENTID, OPT_BINARY_TYPE, false, NO_RECORD_DEF, "" },
    { "serverid", D6O_SERVERID, OPT_BINARY_TYPE, false, NO_RECORD_DEF, "" },
    { "ia-na", D6O_IA_NA, OPT_RECORD_TYPE, false, RECORD_DEF(IA_NA_RECORDS), "" },
    { "ia-ta", D6O_IA_TA, OPT_UINT32_TYPE, false, NO_RECORD_DEF, "" },
    { "iaaddr", D6O_IAADDR, OPT_RECORD_TYPE, false, RECORD_DEF(IAADDR_RECORDS), "" },
    { "oro", D6O_ORO, OPT_UINT16_TYPE, true, NO_RECORD_DEF, "" },
    { "preference", D6O_PREFERENCE, OPT_UINT8_TYPE, false, NO_RECORD_DEF, "" },
    { "elapsed-time", D6O_ELAPSED_TIME, OPT_UINT16_TYPE, false, NO_RECORD_DEF, "" },
    { "relay-msg", D6O_RELAY_MSG, OPT_BINARY_TYPE, false, NO_RECORD_DEF, "" },
Josh Soref's avatar
Josh Soref committed
352
    // Unfortunately the AUTH option contains a 64-bit data field
353 354 355 356 357
    // called 'replay-detection' that can't be added as a record
    // field to a custom option. Also, there is no dedicated
    // option class to handle it so we simply return binary
    // option type for now.
    // @todo implement a class to handle AUTH option.
358 359
    { "auth", D6O_AUTH, OPT_BINARY_TYPE, false, NO_RECORD_DEF, "" },
    { "unicast", D6O_UNICAST, OPT_IPV6_ADDRESS_TYPE, false, NO_RECORD_DEF, "" },
360
    { "status-code", D6O_STATUS_CODE, OPT_RECORD_TYPE, false,
361 362 363
      RECORD_DEF(STATUS_CODE_RECORDS), "" },
    { "rapid-commit", D6O_RAPID_COMMIT, OPT_EMPTY_TYPE, false, NO_RECORD_DEF, "" },
    { "user-class", D6O_USER_CLASS, OPT_BINARY_TYPE, false, NO_RECORD_DEF, "" },
364
    { "vendor-class", D6O_VENDOR_CLASS, OPT_RECORD_TYPE, false,
365 366 367 368 369
      RECORD_DEF(VENDOR_CLASS_RECORDS), "" },
    { "vendor-opts", D6O_VENDOR_OPTS, OPT_UINT32_TYPE, false,
      NO_RECORD_DEF, "vendor-opts-space" },
    { "interface-id", D6O_INTERFACE_ID, OPT_BINARY_TYPE, false, NO_RECORD_DEF, "" },
    { "reconf-msg", D6O_RECONF_MSG, OPT_UINT8_TYPE, false, NO_RECORD_DEF, "" },
370
    { "reconf-accept", D6O_RECONF_ACCEPT, OPT_EMPTY_TYPE, false,
371
      NO_RECORD_DEF, "" },
372
    { "sip-server-dns", D6O_SIP_SERVERS_DNS, OPT_FQDN_TYPE, true,
373
      NO_RECORD_DEF, "" },
374
    { "sip-server-addr", D6O_SIP_SERVERS_ADDR, OPT_IPV6_ADDRESS_TYPE, true,
375
      NO_RECORD_DEF, "" },
376
    { "dns-servers", D6O_NAME_SERVERS, OPT_IPV6_ADDRESS_TYPE, true,
377 378 379
      NO_RECORD_DEF, "" },
    { "domain-search", D6O_DOMAIN_SEARCH, OPT_FQDN_TYPE, true, NO_RECORD_DEF, "" },
    { "ia-pd", D6O_IA_PD, OPT_RECORD_TYPE, false, RECORD_DEF(IA_PD_RECORDS), "" },
380
    { "iaprefix", D6O_IAPREFIX, OPT_RECORD_TYPE, false,
381
      RECORD_DEF(IA_PREFIX_RECORDS), "" },
382
    { "nis-servers", D6O_NIS_SERVERS, OPT_IPV6_ADDRESS_TYPE, true,
383
      NO_RECORD_DEF, "" },
384
    { "nisp-servers", D6O_NISP_SERVERS, OPT_IPV6_ADDRESS_TYPE, true,
385
      NO_RECORD_DEF, "" },
386
    { "nis-domain-name", D6O_NIS_DOMAIN_NAME, OPT_FQDN_TYPE, true,
387
      NO_RECORD_DEF, "" },
388
    { "nisp-domain-name", D6O_NISP_DOMAIN_NAME, OPT_FQDN_TYPE, true,
389
      NO_RECORD_DEF, "" },
390
    { "sntp-servers", D6O_SNTP_SERVERS, OPT_IPV6_ADDRESS_TYPE, true,
391
      NO_RECORD_DEF, "" },
392
    { "information-refresh-time", D6O_INFORMATION_REFRESH_TIME,
393
      OPT_UINT32_TYPE, false, NO_RECORD_DEF, "" },
394
    { "bcmcs-server-dns", D6O_BCMCS_SERVER_D, OPT_FQDN_TYPE, true,
395
      NO_RECORD_DEF, "" },
396
    { "bcmcs-server-addr", D6O_BCMCS_SERVER_A, OPT_IPV6_ADDRESS_TYPE, true,
397
      NO_RECORD_DEF, "" },
398
    { "geoconf-civic", D6O_GEOCONF_CIVIC, OPT_RECORD_TYPE, false,
399
      RECORD_DEF(GEOCONF_CIVIC_RECORDS), "" },
400
    { "remote-id", D6O_REMOTE_ID, OPT_RECORD_TYPE, false,
401
      RECORD_DEF(REMOTE_ID_RECORDS), "" },
402
    { "subscriber-id", D6O_SUBSCRIBER_ID, OPT_BINARY_TYPE, false,
403
      NO_RECORD_DEF, "" },
404
    { "client-fqdn", D6O_CLIENT_FQDN, OPT_RECORD_TYPE, false,
405
      RECORD_DEF(CLIENT_FQDN_RECORDS), "" },
406
    { "pana-agent", D6O_PANA_AGENT, OPT_IPV6_ADDRESS_TYPE, true,
407
      NO_RECORD_DEF, "" },
408
    { "new-posix-timezone", D6O_NEW_POSIX_TIMEZONE, OPT_STRING_TYPE, false,
409
      NO_RECORD_DEF, "" },
410
    { "new-tzdb-timezone", D6O_NEW_TZDB_TIMEZONE, OPT_STRING_TYPE, false,
411 412
      NO_RECORD_DEF, "" },
    { "ero", D6O_ERO, OPT_UINT16_TYPE, true, NO_RECORD_DEF, "" },
413
    { "lq-query", D6O_LQ_QUERY, OPT_RECORD_TYPE, false,
414 415 416
      RECORD_DEF(LQ_QUERY_RECORDS), "" },
    { "client-data", D6O_CLIENT_DATA, OPT_EMPTY_TYPE, false, NO_RECORD_DEF, "" },
    { "clt-time", D6O_CLT_TIME, OPT_UINT32_TYPE, false, NO_RECORD_DEF, "" },
417
    { "lq-relay-data", D6O_LQ_RELAY_DATA, OPT_RECORD_TYPE, false,
418
      RECORD_DEF(LQ_RELAY_DATA_RECORDS), "" },
419
    { "lq-client-link", D6O_LQ_CLIENT_LINK, OPT_IPV6_ADDRESS_TYPE, true,
420
      NO_RECORD_DEF, "" },
421 422 423 424 425 426 427 428
    { "v6-lost", D6O_V6_LOST, OPT_FQDN_TYPE, false, NO_RECORD_DEF, "" },
    { "capwap-ac-v6", D6O_CAPWAP_AC_V6, OPT_IPV6_ADDRESS_TYPE, true,
      NO_RECORD_DEF, "" },
    { "relay-id", D6O_RELAY_ID, OPT_BINARY_TYPE, false, NO_RECORD_DEF, "" },
    { "v6-access-domain", D6O_V6_ACCESS_DOMAIN, OPT_FQDN_TYPE, false,
      NO_RECORD_DEF, "" },
    { "sip-ua-cs-list", D6O_SIP_UA_CS_LIST, OPT_FQDN_TYPE, true,
      NO_RECORD_DEF, "" },      
Shawn Routhier's avatar
Shawn Routhier committed
429
    { "bootfile-url", D6O_BOOTFILE_URL, OPT_STRING_TYPE, false, NO_RECORD_DEF, "" },
430
    { "bootfile-param", D6O_BOOTFILE_PARAM, OPT_TUPLE_TYPE, true, NO_RECORD_DEF, "" },
Shawn Routhier's avatar
Shawn Routhier committed
431 432
    { "client-arch-type", D6O_CLIENT_ARCH_TYPE, OPT_UINT16_TYPE, true, NO_RECORD_DEF, "" },
    { "nii", D6O_NII, OPT_RECORD_TYPE, false, RECORD_DEF(CLIENT_NII_RECORDS), "" },
433
    { "aftr-name", D6O_AFTR_NAME, OPT_FQDN_TYPE, false, NO_RECORD_DEF, "" },
434 435
    { "erp-local-domain-name", D6O_ERP_LOCAL_DOMAIN_NAME, OPT_FQDN_TYPE, false,
      NO_RECORD_DEF, "" },
436
    { "rsoo", D6O_RSOO, OPT_EMPTY_TYPE, false, NO_RECORD_DEF, "rsoo-opts" },
437
    { "pd-exclude", D6O_PD_EXCLUDE, OPT_IPV6_PREFIX_TYPE, false, NO_RECORD_DEF, "" },
438 439
    { "rdnss-selection", D6O_RDNSS_SELECTION, OPT_RECORD_TYPE, true,
      RECORD_DEF(V6_RDNSS_SELECT_RECORDS), "" },
440
    { "client-linklayer-addr", D6O_CLIENT_LINKLAYER_ADDR, OPT_BINARY_TYPE, false,
441
      NO_RECORD_DEF, "" },
442 443 444 445
    { "link-address", D6O_LINK_ADDRESS, OPT_IPV6_ADDRESS_TYPE, false,
      NO_RECORD_DEF, "" },
    { "solmax-rt", D6O_SOL_MAX_RT, OPT_UINT32_TYPE, false, NO_RECORD_DEF, "" },
    { "inf-max-rt", D6O_INF_MAX_RT, OPT_UINT32_TYPE, false, NO_RECORD_DEF, "" },
446 447 448
    { "dhcpv4-message", D6O_DHCPV4_MSG, OPT_BINARY_TYPE, false, NO_RECORD_DEF, "" },
    { "dhcp4o6-server-addr", D6O_DHCPV4_O_DHCPV6_SERVER, OPT_IPV6_ADDRESS_TYPE, true,
      NO_RECORD_DEF, "" },
449 450
    { "v6-captive-portal", D6O_V6_CAPTIVE_PORTAL, OPT_STRING_TYPE, false,
      NO_RECORD_DEF, "" },
451
    { "relay-source-port", D6O_RELAY_SOURCE_PORT, OPT_UINT16_TYPE, false, NO_RECORD_DEF, "" },
452 453
    { "ipv6-address-andsf", D6O_IPV6_ADDRESS_ANDSF, OPT_IPV6_ADDRESS_TYPE, true,
      NO_RECORD_DEF, "" },
454 455 456 457 458 459 460
    { "public-key", D6O_PUBLIC_KEY, OPT_BINARY_TYPE, false,
      NO_RECORD_DEF, "" },
    { "certificate", D6O_CERTIFICATE, OPT_BINARY_TYPE, false,
      NO_RECORD_DEF, "" },
    { "signature", D6O_SIGNATURE, OPT_RECORD_TYPE, false,
      RECORD_DEF(SIGNATURE_RECORDS), "" },
    { "timestamp", D6O_TIMESTAMP, OPT_BINARY_TYPE, false,
461
      NO_RECORD_DEF, "" },
462 463 464 465 466 467
    { "s46-cont-mape", D6O_S46_CONT_MAPE, OPT_EMPTY_TYPE, false, NO_RECORD_DEF,
        MAPE_V6_OPTION_SPACE },
    { "s46-cont-mapt", D6O_S46_CONT_MAPT, OPT_EMPTY_TYPE, false, NO_RECORD_DEF,
        MAPT_V6_OPTION_SPACE },
    { "s46-cont-lw", D6O_S46_CONT_LW, OPT_EMPTY_TYPE, false, NO_RECORD_DEF,
        LW_V6_OPTION_SPACE }
468 469 470 471 472 473

    // @todo There is still a bunch of options for which we have to provide
    // definitions but we don't do it because they are not really
    // critical right now.
};

474
/// Number of option definitions defined.
475 476 477 478
const int STANDARD_V6_OPTION_DEFINITIONS_SIZE =
    sizeof(STANDARD_V6_OPTION_DEFINITIONS) /
    sizeof(STANDARD_V6_OPTION_DEFINITIONS[0]);

479 480 481 482 483 484 485 486
// Option definitions that belong to two or more option spaces are defined here.
const OptionDefParams OPTION_DEF_PARAMS_S46_BR = { "s46-br", D6O_S46_BR,
    OPT_IPV6_ADDRESS_TYPE, false, NO_RECORD_DEF, "" };
const OptionDefParams OPTION_DEF_PARAMS_S46_RULE = { "s46-rule", D6O_S46_RULE,
    OPT_RECORD_TYPE, false, RECORD_DEF(S46_RULE), V4V6_RULE_OPTION_SPACE };
const OptionDefParams OPTION_DEF_PARAMS_S46_PORTPARAMS = { "s46-portparams",
    D6O_S46_PORTPARAMS, OPT_RECORD_TYPE, false, RECORD_DEF(S46_PORTPARAMS), "" };

487 488
/// @brief Definitions of vendor-specific DHCPv6 options, defined by ISC.
/// 4o6-* options are used for inter-process communication. For details, see
489
/// http://oldkea.isc.org/wiki/Dhcp4o6Design
490 491 492
///
/// @todo: As those options are defined by ISC, they do not belong in std_option_defs.h.
///        We need to move them to a separate file, e.g. isc_option_defs.h
493 494 495 496
const OptionDefParams ISC_V6_OPTION_DEFINITIONS[] = {
    { "4o6-interface", ISC_V6_4O6_INTERFACE, OPT_STRING_TYPE, false,
        NO_RECORD_DEF, "" },
    { "4o6-source-address", ISC_V6_4O6_SRC_ADDRESS, OPT_IPV6_ADDRESS_TYPE,
497 498 499
        false, NO_RECORD_DEF, "" },
    { "4o6-source-port", ISC_V6_4O6_SRC_PORT, OPT_UINT16_TYPE, false,
        NO_RECORD_DEF, "" }
500 501 502 503 504 505 506 507
};

const int ISC_V6_OPTION_DEFINITIONS_SIZE =
    sizeof(ISC_V6_OPTION_DEFINITIONS) /
    sizeof(ISC_V6_OPTION_DEFINITIONS[0]);

/// @brief MAPE option definitions
const OptionDefParams MAPE_V6_OPTION_DEFINITIONS[] = {
508 509
    OPTION_DEF_PARAMS_S46_BR,
    OPTION_DEF_PARAMS_S46_RULE
510 511 512 513
};

const int MAPE_V6_OPTION_DEFINITIONS_SIZE =
    sizeof(MAPE_V6_OPTION_DEFINITIONS) /
514
    sizeof(MAPE_V6_OPTION_DEFINITIONS[0]);
515 516 517

/// @brief MAPT option definitions
const OptionDefParams MAPT_V6_OPTION_DEFINITIONS[] = {
518 519
    OPTION_DEF_PARAMS_S46_RULE,
    { "s46-dmr", D6O_S46_DMR, OPT_IPV6_PREFIX_TYPE, false, NO_RECORD_DEF, "" }
520 521 522 523
};

const int MAPT_V6_OPTION_DEFINITIONS_SIZE =
    sizeof(MAPT_V6_OPTION_DEFINITIONS) /
524
    sizeof(MAPT_V6_OPTION_DEFINITIONS[0]);
525 526 527

/// @brief LW option definitions
const OptionDefParams LW_V6_OPTION_DEFINITIONS[] = {
528 529 530
    OPTION_DEF_PARAMS_S46_BR,
    { "s46-v4v6bind", D6O_S46_V4V6BIND, OPT_RECORD_TYPE, false,
        RECORD_DEF(S46_V4V6BIND), V4V6_BIND_OPTION_SPACE }
531 532 533 534
};

const int LW_V6_OPTION_DEFINITIONS_SIZE =
    sizeof(LW_V6_OPTION_DEFINITIONS) /
535
    sizeof(LW_V6_OPTION_DEFINITIONS[0]);
536 537 538

/// @brief Rule option definitions
const OptionDefParams V4V6_RULE_OPTION_DEFINITIONS[] = {
539
    OPTION_DEF_PARAMS_S46_PORTPARAMS
540 541 542 543
};

const int V4V6_RULE_OPTION_DEFINITIONS_SIZE =
    sizeof(V4V6_RULE_OPTION_DEFINITIONS) /
544
    sizeof(V4V6_RULE_OPTION_DEFINITIONS[0]);
545 546 547

/// @brief Bind option definitions
const OptionDefParams V4V6_BIND_OPTION_DEFINITIONS[] = {
548
    OPTION_DEF_PARAMS_S46_PORTPARAMS
549 550
};

551 552
const int V4V6_BIND_OPTION_DEFINITIONS_SIZE =
    sizeof(V4V6_BIND_OPTION_DEFINITIONS) /
553
    sizeof(V4V6_BIND_OPTION_DEFINITIONS[0]);
554

555 556 557 558
} // unnamed namespace

} // namespace dhcp
} // namespace isc
559 560

#endif // STD_OPTION_DEFS_H