CLEANFILES+= dhcpcd-embedded.h dhcpcd-embedded.c
-dhcpcd-embedded.h: genembedh dhcpcd-embedded.conf dhcpcd-embedded.h.in
+dhcpcd-embedded.h: genembedh dhcpcd-definitions.conf dhcpcd-embedded.h.in
${HOST_SH} ${.ALLSRC} $^ > $@
-dhcpcd-embedded.c: genembedc dhcpcd-embedded.conf
+dhcpcd-embedded.c: genembedc dhcpcd-definitions.conf
${HOST_SH} ${.ALLSRC} $^ > $@
if-options.c: dhcpcd-embedded.h
${PROG}: ${DEPEND} ${OBJS}
${CC} ${LDFLAGS} -o $@ ${OBJS} ${LDADD}
-_embeddedinstall: dhcpcd-embedded.conf
+_embeddedinstall: dhcpcd-definitions.conf
${INSTALL} -d ${DESTDIR}${SCRIPTSDIR}
- ${INSTALL} -m ${CONFMODE} dhcpcd-embedded.conf ${DESTDIR}${SCRIPTSDIR}
+ ${INSTALL} -m ${CONFMODE} dhcpcd-definitions.conf ${DESTDIR}${SCRIPTSDIR}
_proginstall: ${PROG}
${INSTALL} -d ${DESTDIR}${SBINDIR}
import: ${SRCS}
rm -rf /tmp/${DISTPREFIX}
${INSTALL} -d /tmp/${DISTPREFIX}
- cp ${SRCS} dhcpcd.conf dhcpcd-embedded.conf *.in /tmp/${DISTPREFIX}
+ cp ${SRCS} dhcpcd.conf dhcpcd-definitions.conf *.in /tmp/${DISTPREFIX}
cp $$(${CC} ${CPPFLAGS} -MM ${SRCS} | \
sed -e 's/^.*\.c //g' -e 's/.*\.c$$//g' -e 's/\\//g' | \
tr ' ' '\n' | \
for x in \
/tmp/${DISTPREFIX}/dhcpcd-run-hooks.in \
/tmp/${DISTPREFIX}/dhcpcd.conf \
- /tmp/${DISTPREFIX}/dhcpcd-embedded.conf \
+ /tmp/${DISTPREFIX}/dhcpcd-definitions.conf \
; do \
if test -e "$$x"; then \
if test "$$(sed -ne 1p $$x)" = "#!/bin/sh" \
--disable-inet6
You can also move the embedded extended configuration from the dhcpcd binary
-to an external file (LIBEXECDIR/dhcpcd-embedded.conf)
+to an external file (LIBEXECDIR/dhcpcd-definitions.conf)
--disable-embedded
If dhcpcd cannot load this file at runtime, dhcpcd will work but will not be
-able to decode any DHCP/DHCPv6 options present within the file.
+able to decode any DHCP/DHCPv6 options that are not defined by the user
+in /etc/dhcpcd.conf.
To prepare dhcpcd for import into a platform source tree (like NetBSD)
you can use the make import target to create /tmp/dhcpcd-$version and
fi
if [ -z "$EMBEDDED" -o "$EMBEDDED" = yes ]; then
- echo "dhcpcd-embedded.conf will be embedded in dhcpcd itself"
+ echo "dhcpcd-definitions.conf will be embedded in dhcpcd itself"
echo "SRCS+= dhcpcd-embedded.c" >>$CONFIG_MK
else
- echo "dhcpcd-embedded.conf will be installed to $LIBEXECDIR"
- echo "CFLAGS+= -DEMBEDDED_CONFIG=\\\"$LIBEXECDIR/dhcpcd-embedded.conf\\\"" >>$CONFIG_MK
+ echo "dhcpcd-definitions.conf will be installed to $LIBEXECDIR"
+ echo "CFLAGS+= -DEMBEDDED_CONFIG=\\\"$LIBEXECDIR/dhcpcd-definitions.conf\\\"" >>$CONFIG_MK
echo "EMBEDDEDINSTALL= _embeddedinstall" >>$CONFIG_MK
fi
size_t dhcp6_override_len = 0;
#endif
-int make_option_mask(const struct dhcp_opt *dopts,
+int make_option_mask(const struct dhcp_opt *dopts, size_t dopts_len,
uint8_t *mask, const char *opts, int add)
{
char *token, *o, *p, *t;
const struct dhcp_opt *opt;
int match, n;
+ size_t i;
o = p = strdup(opts);
if (opts == NULL)
while ((token = strsep(&p, ", "))) {
if (*token == '\0')
continue;
- for (opt = dopts; opt->option; opt++) {
- if (!opt->v.var)
- continue;
+ for (i = 0, opt = dopts; i < dopts_len; i++, opt++) {
match = 0;
if (strcmp(opt->v.var, token) == 0)
match = 1;
#define add_option_mask(var, val) (var[val >> 3] |= 1 << (val & 7))
#define del_option_mask(var, val) (var[val >> 3] &= ~(1 << (val & 7)))
#define has_option_mask(var, val) (var[val >>3] & (1 << (val & 7)))
-int make_option_mask(const struct dhcp_opt *, uint8_t *, const char *, int);
+int make_option_mask(const struct dhcp_opt *, size_t,
+ uint8_t *, const char *, int);
size_t encode_rfc1035(const char *src, uint8_t *dst);
ssize_t decode_rfc3397(char *, ssize_t, int, const uint8_t *);
{ 0, NULL }
};
-#define O(a, b, c) {.option = (a), .type = (b), .v.var = (c) }
-const struct dhcp_opt dhcp_opts[] = {
- O(1, ADDRIPV4 | REQUEST, "subnet_mask"),
- /* RFC 3442 states that the CSR has to come before all other
- * routes. For completeness, we also specify static routes,
- * then routers. */
- O(121, RFC3442, "classless_static_routes"),
- O(249, RFC3442, "ms_classless_static_routes"),
- O(33, IPV4A | REQUEST, "static_routes"),
- O(3, IPV4A | REQUEST, "routers"),
- O(2, UINT32, "time_offset"),
- O(4, IPV4A, "time_servers"),
- O(5, IPV4A, "ien116_name_servers"),
- O(6, IPV4A, "domain_name_servers"),
- O(7, IPV4A, "log_servers"),
- O(8, IPV4A, "cookie_servers"),
- O(9, IPV4A, "lpr_servers"),
- O(10, IPV4A, "impress_servers"),
- O(11, IPV4A, "resource_location_servers"),
- O(12, STRING, "host_name"),
- O(13, UINT16, "boot_size"),
- O(14, STRING, "merit_dump"),
- O(15, STRING, "domain_name"),
- O(16, ADDRIPV4, "swap_server"),
- O(17, STRING, "root_path"),
- O(18, STRING, "extensions_path"),
- O(19, UINT8, "ip_forwarding"),
- O(20, UINT8, "non_local_source_routing"),
- O(21, IPV4A, "policy_filter"),
- O(22, SINT16, "max_dgram_reassembly"),
- O(23, UINT16, "default_ip_ttl"),
- O(24, UINT32, "path_mtu_aging_timeout"),
- O(25, UINT16 | ARRAY, "path_mtu_plateau_table"),
- O(26, UINT16, "interface_mtu"),
- O(27, UINT8, "all_subnets_local"),
- O(28, ADDRIPV4 | REQUEST, "broadcast_address"),
- O(29, UINT8, "perform_mask_discovery"),
- O(30, UINT8, "mask_supplier"),
- O(31, UINT8, "router_discovery"),
- O(32, ADDRIPV4, "router_solicitation_address"),
- O(34, UINT8, "trailer_encapsulation"),
- O(35, UINT32, "arp_cache_timeout"),
- O(36, UINT16, "ieee802_3_encapsulation"),
- O(37, UINT8, "default_tcp_ttl"),
- O(38, UINT32, "tcp_keepalive_interval"),
- O(39, UINT8, "tcp_keepalive_garbage"),
- O(40, STRING, "nis_domain"),
- O(41, IPV4A, "nis_servers"),
- O(42, IPV4A, "ntp_servers"),
- O(43, STRING, "vendor_encapsulated_options"),
- O(44, IPV4A, "netbios_name_servers"),
- O(45, ADDRIPV4, "netbios_dd_server"),
- O(46, UINT8, "netbios_node_type"),
- O(47, STRING, "netbios_scope"),
- O(48, IPV4A, "font_servers"),
- O(49, IPV4A, "x_display_manager"),
- O(50, ADDRIPV4, "dhcp_requested_address"),
- O(51, UINT32 | REQUEST, "dhcp_lease_time"),
- O(52, UINT8, "dhcp_option_overload"),
- O(53, UINT8, "dhcp_message_type"),
- O(54, ADDRIPV4, "dhcp_server_identifier"),
- O(55, UINT8 | ARRAY, "dhcp_parameter_request_list"),
- O(56, STRING, "dhcp_message"),
- O(57, UINT16, "dhcp_max_message_size"),
- O(58, UINT32 | REQUEST, "dhcp_renewal_time"),
- O(59, UINT32 | REQUEST, "dhcp_rebinding_time"),
- O(64, STRING, "nisplus_domain"),
- O(65, IPV4A, "nisplus_servers"),
- O(66, STRING, "tftp_server_name"),
- O(67, STRING, "bootfile_name"),
- O(68, IPV4A, "mobile_ip_home_agent"),
- O(69, IPV4A, "smtp_server"),
- O(70, IPV4A, "pop_server"),
- O(71, IPV4A, "nntp_server"),
- O(72, IPV4A, "www_server"),
- O(73, IPV4A, "finger_server"),
- O(74, IPV4A, "irc_server"),
- O(75, IPV4A, "streettalk_server"),
- O(76, IPV4A, "streettalk_directory_assistance_server"),
- O(77, STRING, "user_class"),
- O(80, FLAG | NOREQ, "rapid_commit"),
- O(81, STRING | RFC3397, "fqdn"),
- O(85, IPV4A, "nds_servers"),
- O(86, STRING, "nds_tree_name"),
- O(87, STRING, "nds_context"),
- O(88, STRING | RFC3397, "bcms_controller_names"),
- O(89, IPV4A, "bcms_controller_address"),
- O(91, UINT32, "client_last_transaction_time"),
- O(92, IPV4A, "associated_ip"),
- O(98, STRING, "uap_servers"),
- O(100, STRING, "posix_timezone"),
- O(101, STRING, "tzdb_timezone"),
- O(112, IPV4A, "netinfo_server_address"),
- O(113, STRING, "netinfo_server_tag"),
- O(114, STRING, "default_url"),
- O(118, ADDRIPV4, "subnet_selection"),
- O(119, STRING | RFC3397, "domain_search"),
- O(120, STRING | RFC3361, "sip_server"),
- O(212, RFC5969, "sixrd"),
- O(0, 0, NULL)
-};
-#undef O
-
static const char *dhcp_params[] = {
"ip_address",
"subnet_cidr",
struct dhcp_message dhcp;
};
-struct dhcp_opt *dhcp_eopts = NULL;
-size_t dhcp_eopts_len = 0;
+struct dhcp_opt *dhcp_opts = NULL;
+size_t dhcp_opts_len = 0;
static const size_t udp_dhcp_len = sizeof(struct udp_dhcp_packet);
void
dhcp_printoptions(void)
{
- const struct dhcp_opt *opt;
const char **p;
+ size_t i;
+ const struct dhcp_opt *opt;
for (p = dhcp_params; *p; p++)
printf(" %s\n", *p);
- for (opt = dhcp_opts; opt->option; opt++)
- if (opt->v.var)
- printf("%03d %s\n", opt->option, opt->v.var);
+ for (i = 0, opt = dhcp_opts; i < dhcp_opts_len; i++, opt++)
+ printf("%03d %s\n", opt->option, opt->v.var);
}
#ifdef DEBUG_MEMORY
uint8_t *n_params = NULL;
uint32_t ul;
uint16_t sz;
- size_t len;
+ size_t len, i;
const struct dhcp_opt *opt;
const struct if_options *ifo = iface->options;
const struct dhcp_state *state = D_CSTATE(iface);
*p++ = DHO_PARAMETERREQUESTLIST;
n_params = p;
*p++ = 0;
- for (opt = dhcp_opts; opt->option; opt++) {
+ for (i = 0, opt = dhcp_opts; i < dhcp_opts_len; i++, opt++) {
if (!(opt->type & REQUEST ||
has_option_mask(ifo->requestmask, opt->option)))
continue;
}
static const struct dhcp_opt *
-dhcp_getoverride(const struct if_options *ifo, uint16_t o, int e)
+dhcp_getoverride(const struct if_options *ifo, uint16_t o)
{
size_t i;
const struct dhcp_opt *opt;
if (opt->option == o)
return opt;
}
- if (e) {
- for (i = 0, opt = dhcp_eopts;
- i < dhcp_eopts_len;
- i++, opt++)
- {
- if (opt->option == o)
- return opt;
- }
- }
return NULL;
}
get_option_uint8(&overl, dhcp, DHO_OPTIONSOVERLOADED);
if (!env) {
- for (opt = dhcp_opts; opt->option; opt++) {
- if (!opt->v.var)
- continue;
- if (has_option_mask(ifo->nomask, opt->option))
- continue;
- if (dhcp_getoverride(ifo, opt->option, 1))
- continue;
- p = get_option(dhcp, opt->option, &pl);
- if (!p)
- continue;
- e += dhcp_envoption(NULL, prefix, "", ifp->name,
- opt, dhcp_getoption, p, pl);
- }
if (dhcp->yiaddr || dhcp->ciaddr)
e += 5;
if (*dhcp->bootfile && !(overl & 1))
e++;
if (*dhcp->servername && !(overl & 2))
e++;
- for (oi = 0, opt = dhcp_eopts;
- oi < dhcp_eopts_len;
+ for (oi = 0, opt = dhcp_opts;
+ oi < dhcp_opts_len;
oi++, opt++)
{
if (has_option_mask(ifo->nomask, opt->option))
continue;
- if (dhcp_getoverride(ifo, opt->option, 0))
+ if (dhcp_getoverride(ifo, opt->option))
continue;
p = get_option(dhcp, opt->option, &pl);
if (!p)
setvar(&ep, prefix, "subnet_cidr", cidr);
if (get_option_addr(&brd, dhcp, DHO_BROADCAST) == -1) {
brd.s_addr = addr.s_addr | ~net.s_addr;
- setvar(&ep, prefix, "broadcast_address", inet_ntoa(brd));
+ setvar(&ep, prefix, "broadcast_address",
+ inet_ntoa(brd));
}
addr.s_addr = dhcp->yiaddr & net.s_addr;
setvar(&ep, prefix, "network_number", inet_ntoa(addr));
if (*dhcp->bootfile && !(overl & 1))
setvar(&ep, prefix, "filename", (const char *)dhcp->bootfile);
if (*dhcp->servername && !(overl & 2))
- setvar(&ep, prefix, "server_name", (const char *)dhcp->servername);
-
- for (opt = dhcp_opts; opt->option; opt++) {
- if (!opt->v.var)
- continue;
- if (has_option_mask(ifo->nomask, opt->option))
- continue;
- if (dhcp_getoverride(ifo, opt->option, 1))
- continue;
- p = get_option(dhcp, opt->option, &pl);
- if (!p)
- continue;
- /* No override, which means it's not embedded, so just
- * grab the FQDN itself */
- if (opt->option == DHO_FQDN) {
- p += 3;
- pl -= 3;
- }
- ep += dhcp_envoption(ep, prefix, "", ifp->name,
- opt, dhcp_getoption, p, pl);
- }
+ setvar(&ep, prefix, "server_name",
+ (const char *)dhcp->servername);
- for (oi = 0, opt = dhcp_eopts;
- oi < dhcp_eopts_len;
+ for (oi = 0, opt = dhcp_opts;
+ oi < dhcp_opts_len;
oi++, opt++)
{
if (has_option_mask(ifo->nomask, opt->option))
continue;
- if (dhcp_getoverride(ifo, opt->option, 0))
+ if (dhcp_getoverride(ifo, opt->option))
continue;
if ((p = get_option(dhcp, opt->option, &pl)))
ep += dhcp_envoption(ep, prefix, "", ifp->name,
#include "net.h"
#ifdef INET
-extern const struct dhcp_opt dhcp_opts[];
-
-extern struct dhcp_opt *dhcp_eopts;
-extern size_t dhcp_eopts_len;
+extern struct dhcp_opt *dhcp_opts;
+extern size_t dhcp_opts_len;
char *decode_rfc3361(int dl, const uint8_t *data);
ssize_t decode_rfc3442(char *out, ssize_t len, int pl, const uint8_t *p);
{ 0, NULL }
};
-#define IPV6A ADDRIPV6 | ARRAY
-#define O(a, b, c) {.option = (a), .type = (b), .v.var = (c) }
-const struct dhcp_opt dhcp6_opts[] = {
- O(D6_OPTION_CLIENTID, BINHEX, "client_id"),
- O(D6_OPTION_SERVERID, BINHEX, "server_id"),
- O(D6_OPTION_IA_ADDR, IPV6A, "ia_addr"),
- O(D6_OPTION_PREFERENCE, UINT8, "preference"),
- O(D6_OPTION_UNICAST, ADDRIPV6, "unicast"),
- O(D6_OPTION_RAPID_COMMIT, FLAG | NOREQ, "rapid_commit"),
- O(D6_OPTION_STATUS_CODE, SCODE, "status_code"),
- O(D6_OPTION_SIP_SERVERS_NAME, RFC3397, "sip_servers_names"),
- O(D6_OPTION_SIP_SERVERS_ADDRESS,IPV6A, "sip_servers_addresses"),
- O(D6_OPTION_DNS_SERVERS, IPV6A, "name_servers"),
- O(D6_OPTION_DOMAIN_LIST, RFC3397, "domain_search"),
- O(D6_OPTION_NIS_SERVERS, IPV6A, "nis_servers"),
- O(D6_OPTION_NISP_SERVERS, IPV6A, "nisp_servers"),
- O(D6_OPTION_NIS_DOMAIN_NAME, RFC3397, "nis_domain_name"),
- O(D6_OPTION_NISP_DOMAIN_NAME, RFC3397, "nisp_domain_name"),
- O(D6_OPTION_SNTP_SERVERS, IPV6A, "sntp_servers"),
- O(D6_OPTION_INFO_REFRESH_TIME, UINT32, "info_refresh_time"),
- O(D6_OPTION_BCMS_SERVER_D, RFC3397, "bcms_server_d"),
- O(D6_OPTION_BCMS_SERVER_A, IPV6A, "bcms_server_a"),
- O(D6_OPTION_FQDN, RFC3397, "fqdn"),
- O(D6_OPTION_POSIX_TIMEZONE, STRING, "posix_timezone"),
- O(D6_OPTION_TZDB_TIMEZONE, STRING, "tzdb_timezone"),
- O(0, 0, NULL)
-};
-#undef O
-
-struct dhcp_opt *dhcp6_eopts = NULL;
-size_t dhcp6_eopts_len = 0;
+struct dhcp_opt *dhcp6_opts = NULL;
+size_t dhcp6_opts_len = 0;
struct dhcp_compat {
uint8_t dhcp_opt;
}
static const struct dhcp_opt *
-dhcp6_getoverride(const struct if_options *ifo, uint16_t o, int e)
+dhcp6_getoverride(const struct if_options *ifo, uint16_t o)
{
size_t i;
const struct dhcp_opt *opt;
if (opt->option == o)
return opt;
}
- if (e != 0) {
- for (i = 0, opt = dhcp6_eopts;
- i < dhcp6_eopts_len;
- i++, opt++)
- {
- if (opt->option == o)
- return opt;
- }
- }
return NULL;
}
n = 0;
ep = env;
ifo = ifp->options;
- for (opt = dhcp6_opts; opt->option; opt++) {
- if (!opt->v.var)
- continue;
- if (has_option_mask(ifo->nomask6, opt->option))
+
+ for (oi = 0, opt = dhcp6_opts;
+ oi < dhcp6_opts_len;
+ oi++, opt++)
+ {
+ if (has_option_mask(ifo->nomask, opt->option))
continue;
- if (dhcp6_getoverride(ifo, opt->option, 1))
+ if (dhcp6_getoverride(ifo, opt->option))
continue;
+
o = dhcp6_getmoption(opt->option, m, mlen);
if (o == NULL)
continue;
ol = ntohs(o->len);
od = D6_COPTION_DATA(o);
- /* No override, which means it's not embedded, so just
- * grab the FQDN itself */
- if (opt->option == D6_OPTION_FQDN) {
- ol--;
- od++;
- }
n += dhcp_envoption(env == NULL ? NULL : &env[n],
prefix, "_dhcp6", ifp->name, opt, dhcp6_getoption, od, ol);
}
}
}
- for (oi = 0, opt = dhcp6_eopts;
- oi < dhcp6_eopts_len;
- oi++, opt++)
- {
- if (has_option_mask(ifo->nomask, opt->option))
- continue;
- if (dhcp6_getoverride(ifo, opt->option, 0))
- continue;
-
- o = dhcp6_getmoption(opt->option, m, mlen);
- if (o == NULL)
- continue;
- ol = ntohs(o->len);
- od = D6_COPTION_DATA(o);
- n += dhcp_envoption(env == NULL ? NULL : &env[n],
- prefix, "_dhcp6", ifp->name, opt, dhcp6_getoption, od, ol);
- }
-
for (oi = 0, opt = ifo->dhcp6_override;
oi < ifo->dhcp6_override_len;
oi++, opt++)
#include "dhcp.h"
#include "ipv6.h"
-extern const struct dhcp_opt dhcp6_opts[];
struct dhcp6_message {
uint8_t type;
((const uint8_t *)(o) + sizeof(struct dhcp6_option))
#ifdef INET6
-extern struct dhcp_opt *dhcp6_eopts;
-extern size_t dhcp6_eopts_len;
+extern struct dhcp_opt *dhcp6_opts;
+extern size_t dhcp6_opts_len;
void dhcp6_printoptions(void);
int dhcp6_addrexists(const struct ipv6_addr *);
--- /dev/null
+# DHCP option definitions for dhcpcd(8)
+# These are used to translate DHCP options into shell variables
+# for use in dhcpcd-run-hooks(8)
+# See dhcpcd.conf(5) for details
+
+##############################################################################
+# DHCP RFC2132 options unless otheriwse stated
+define 1 request ipaddress subnet_mask
+# RFC3442 states that the CSR has to come before all other routes
+# For completeness we also specify static routes then routers
+define 121 rfc3442 classless_static_routes
+define 249 rfc3442 ms_classless_static_routes
+define 33 request array ipaddress static_routes
+define 3 request array ipaddress routers
+define 2 uint32 time_offset
+define 4 array ipaddress time_servers
+define 5 array ipaddress ien116_name_servers
+define 6 array ipaddress domain_name_servers
+define 7 array ipaddress log_servers
+define 8 array ipaddress cookie_servers
+define 9 array ipaddress lpr_servers
+define 10 array ipaddress impress_servers
+define 11 array ipaddress resource_location_servers
+define 12 string host_name
+define 13 uint16 boot_size
+define 14 string merit_dump
+define 15 string domain_name
+define 16 ipaddress swap_server
+define 17 string root_path
+define 18 string extensions_path
+define 19 byte ip_forwarding
+define 20 byte non_local_source_routing
+define 21 array ipaddress policy_filter
+define 22 int16 max_dgram_reassembly
+define 23 uint16 default_ip_ttl
+define 24 uint32 path_mtu_aging_timeout
+define 25 array uint16 path_mtu_plateau_table
+define 26 uint16 interface_mtu
+define 27 byte all_subnets_local
+define 28 request ipaddress broadcast_address
+define 29 byte perform_mask_discovery
+define 30 byte mask_supplier
+define 31 byte router_discovery
+define 32 ipaddress router_solicitation_address
+define 34 byte trailer_encapsulation
+define 35 uint32 arp_cache_timeout
+define 36 uint16 ieee802_3_encapsulation
+define 37 byte default_tcp_ttl
+define 38 uint32 tcp_keepalive_interval
+define 39 byte tcp_keepalive_garbage
+define 40 string nis_domain
+define 41 array ipaddress nis_servers
+define 42 array ipaddress ntp_servers
+define 43 string vendor_encapsulated_options
+define 44 array ipaddress netbios_name_servers
+define 45 ipaddress netbios_dd_server
+define 46 byte netbios_node_type
+define 47 string netbios_scope
+define 48 array ipaddress font_servers
+define 49 array ipaddress x_display_manager
+define 50 ipaddress dhcp_requested_address
+define 51 request uint32 dhcp_lease_time
+define 52 byte dhcp_option_overload
+define 53 byte dhcp_message_type
+define 54 ipaddress dhcp_server_identifier
+define 55 array byte dhcp_parameter_request_list
+define 56 string dhcp_message
+define 57 uint16 dhcp_max_message_size
+define 58 request uint32 dhcp_renewal_time
+define 59 request uint32 dhcp_rebinding_time
+define 64 string nisplus_domain
+define 65 array ipaddress nisplus_servers
+define 66 string tftp_server_name
+define 67 string bootfile_name
+define 68 array ipaddress mobile_ip_home_agent
+define 69 array ipaddress smtp_server
+define 70 array ipaddress pop_server
+define 71 array ipaddress nntp_server
+define 72 array ipaddress www_server
+define 73 array ipaddress finger_server
+define 74 array ipaddress irc_server
+define 75 array ipaddress streettalk_server
+define 76 array ipaddress streettalk_directory_assistance_server
+
+# DHCP User Class, RFC3004
+define 77 string user_class
+
+# DHCP Rapid Commit, RFC4039
+define 80 norequest flag rapid_commit
+
+# DHCP Fully Qualified Domain Name, RFC4702
+define 81 embed fqdn
+embed byte flags
+embed byte rcode1
+embed byte rcode2
+embed domain fqdn
+
+# DHCP Novell Directory Services, RFC2241
+define 85 array ipaddress nds_servers
+define 86 string nds_tree_name
+define 87 string nds_context
+
+# DHCP Broadcast and Multicast Control Server, RFC4280
+define 88 domain bcms_controller_names
+define 89 array ipaddress bcms_controller_address
+
+# DHCP Leasequery, RFC4388
+define 91 uint32 client_last_transaction_time
+define 92 array ipaddress associated_ip
+
+# DHCP The Open Group's User Authentication Protocol, RFC2485
+define 98 string uap_servers
+
+# DHCP Timezone, RFC4883
+define 100 string posix_timezone
+define 101 string tzdb_timezone
+
+# DHCP Subnet Selection, RFC3011
+define 118 ipaddress subnet_selection
+
+# DHCP Domain Search, RFC3397
+define 119 domain domain_search
+
+# DHCP Session Initiated Protocol Servers, RFC3361
+define 120 rfc3361 sip_server
+
+# DHCP IPv6 Rapid Deployment on IPv4 Infrastructures, RFC5969
+define 212 rfc5969 sixrd
+
+##############################################################################
+# DHCPv6 options, RFC3315
+define6 1 binhex client_id
+define6 2 binhex server_id
+
+# DHCPv6 addresses.
+# These are currently handled internally by dhcpcd(8) and only
+# the addresses are exposed to dhcpcd-run-hooks(8).
+# When they can be expressed properly they will be uncommented.
+# many signifies that it could occur more than once and be index.
+# option signifies that the specified option can be encapsulated.
+# For example:
+# ia_na_count=1
+# ia_na_1_iaid="00112233"
+# ia_na_1_t1=3600
+# ia_na_1_t2=7200
+# ia_na_1_ia_addr_count=1
+# ia_na_1_ia_addr_1_addr="dead:beef"
+# ia_na_1_ia_addr_1_pltime="3600"
+# ia_na_1_ia_addr_1_pltime="7200"
+# ia_na_1_ia_addr_1_status_code=0
+# ia_na_1_ia_addr_1_status_code_message="OK"
+# ia_na_1_code=0
+# ia_na_1_status_code_message="OK"
+#
+#define6 3 embed many ia_na
+#embed uint32 iaid
+#embed uint32 t1
+#embed uint32 t2
+#encap option 5
+#encap option 13
+#define6 4 embed many ia_ta
+#embed uint32 iaid
+#encap option 5
+#encap option 13
+#define6 5 embed many ia_addr
+#embed ip6address addr
+#embed uint32 pltime
+#embed uint32 vltime
+#encap option 13
+
+define6 6 array uint16 option_request
+define6 7 byte preference
+define6 8 uint16 elased_time
+define6 9 binhex dhcp_relay_msg
+
+define6 11 embed auth
+embed byte protocol
+embed byte algorithm
+embed binhex:8 replay_detection
+embed binhex information
+
+define6 12 ip6address unicast
+
+define6 13 norequest embed status_code
+embed uint16 status_code
+embed string message
+
+define6 14 norequest flag rapid_commit
+define6 15 binhex user_class
+define6 16 binhex vendor_class
+define6 17 binhex vendor_options
+define6 18 binhex interface_id
+define6 19 byte reconfigure_msg
+define6 20 flag reconfigure_accept
+
+# DHCPv6 Session Initiation Protocol Options, RFC3319
+define6 21 domain sip_servers_names
+define6 22 array ip6address sip_servers_addresses
+
+# DHCPv6 DNS Configuration Options, RFC3646
+define6 23 array ip6address name_servers
+define6 24 domain domain_search
+
+# DHCPv6 Network Information Service Options, RFC3898
+define6 27 array ip6address nis_servers
+define6 28 array ip6address nisp_servers
+define6 29 domain nis_domain_name
+define6 30 domain nisp_domain_name
+
+# DHCPv6 Simple Network Time Protocol Servers Option, RFC4075
+define6 31 array ip6address sntp_servers
+
+# DHCPv6 Information Refresh Time, RFC4242
+define6 32 uint32 info_refresh_time
+
+# DHCPv6 Broadcast and Multicast Control Server, RFC4280
+define6 33 domain bcms_server_d
+define6 34 array ip6address bcms_server_a
+
+# DHCPv6 Fully Qualified Domain Name, RFC4704
+define6 39 embed fqdn
+embed byte fqdn_flags
+embed domain fqdn
+
+# DHCPv6 Timezone options, RFC4883
+define6 41 string posix_timezone
+define6 42 string tzdb_timezone
+
+# DHCPv6 Network Time Protocol Server, RFC5908
+define6 56 encap ntp_server
+encap 1 ip6address addr
+encap 2 ip6address mcast_addr
+encap 3 ip6address fqdn
+++ /dev/null
-# Embedded option definitions for dhcpcd(8)
-
-# DHCP Fully Qualified Domain Name, RFC4702
-define 81 embed fqdn
-embed byte flags
-embed byte rcode1
-embed byte rcode2
-embed domain fqdn
-
-# DHCPv6 Fully Qualified Domain Name, RFC4704
-define6 39 embed fqdn
-embed byte flags
-embed domain fqdn
-
-# DHCPv6 Network Time Protocol Server, RFC5908
-define6 56 encap ntp_server
-encap 1 ip6address addr
-encap 2 ip6address mcast_addr
-encap 3 ip6address fqdn
free(ifdv);
#ifdef INET
- for (n = 0; n < dhcp_eopts_len; n++)
- free_dhcp_opt_embenc(&dhcp_eopts[n]);
- free(dhcp_eopts);
+ for (n = 0; n < dhcp_opts_len; n++)
+ free_dhcp_opt_embenc(&dhcp_opts[n]);
+ free(dhcp_opts);
#endif
#ifdef INET6
- for (n = 0; n < dhcp6_eopts_len; n++)
- free_dhcp_opt_embenc(&dhcp6_eopts[n]);
- free(dhcp6_eopts);
+ for (n = 0; n < dhcp6_opts_len; n++)
+ free_dhcp_opt_embenc(&dhcp6_opts[n]);
+ free(dhcp6_opts);
#endif
}
set -e
: ${TOOL_SED:=sed}
-CONF=${1:-dhcpcd-embedded.conf}
+CONF=${1:-dhcpcd-definitions.conf}
cat <<EOF
/*
: ${TOOL_SED:=sed}
: ${TOOL_GREP:=grep}
: ${TOOL_WC:=wc}
-CONF=${1:-dhcpcd-embedded.conf}
+CONF=${1:-dhcpcd-definitions.conf}
H=${2:-dhcpcd-embedded.h.in}
INITDEFINES=$($TOOL_GREP "^define " $CONF | $TOOL_WC -l)
#endif
static const char *
-set_option_space(const char *arg, const struct dhcp_opt **d,
+set_option_space(const char *arg, const struct dhcp_opt **d, size_t *dl,
struct if_options *ifo,
uint8_t *request[], uint8_t *require[], uint8_t *no[])
{
#ifdef INET6
if (strncmp(arg, "dhcp6_", strlen("dhcp6_")) == 0) {
*d = dhcp6_opts;
+ *dl = dhcp6_opts_len;
*request = ifo->requestmask6;
*require = ifo->requiremask6;
*no = ifo->nomask6;
#ifdef INET
*d = dhcp_opts;
+ *dl = dhcp_opts_len;
#else
*d = NULL;
+ *dl = 0;
#endif
*request = ifo->requestmask;
*require = ifo->requiremask;
}
break;
case 'o':
- arg = set_option_space(arg, &d, ifo, &request, &require, &no);
- if (make_option_mask(d, request, arg, 1) != 0) {
+ arg = set_option_space(arg, &d, &dl, ifo,
+ &request, &require, &no);
+ if (make_option_mask(d, dl, request, arg, 1) != 0) {
syslog(LOG_ERR, "unknown option `%s'", arg);
return -1;
}
ifo->options &= ~DHCPCD_IPV4LL;
break;
case 'O':
- arg = set_option_space(arg, &d, ifo, &request, &require, &no);
- if (make_option_mask(d, request, arg, -1) != 0 ||
- make_option_mask(d, require, arg, -1) != 0 ||
- make_option_mask(d, no, arg, 1) != 0)
+ arg = set_option_space(arg, &d, &dl, ifo,
+ &request, &require, &no);
+ if (make_option_mask(d, dl, request, arg, -1) != 0 ||
+ make_option_mask(d, dl, require, arg, -1) != 0 ||
+ make_option_mask(d, dl, no, arg, 1) != 0)
{
syslog(LOG_ERR, "unknown option `%s'", arg);
return -1;
}
break;
case 'Q':
- arg = set_option_space(arg, &d, ifo, &request, &require, &no);
- if (make_option_mask(d, require, arg, 1) != 0 ||
- make_option_mask(d, request, arg, 1) != 0)
+ arg = set_option_space(arg, &d, &dl, ifo,
+ &request, &require, &no);
+ if (make_option_mask(d, dl, require, arg, 1) != 0 ||
+ make_option_mask(d, dl, request, arg, 1) != 0)
{
syslog(LOG_ERR, "unknown option `%s'", arg);
return -1;
ifo->arping[ifo->arping_len++] = addr.s_addr;
break;
case O_DESTINATION:
- if (make_option_mask(dhcp_opts, ifo->dstmask, arg, 2) != 0) {
+ if (make_option_mask(dhcp_opts, dhcp_opts_len,
+ ifo->dstmask, arg, 2) != 0) {
if (errno == EINVAL)
syslog(LOG_ERR, "option `%s' does not take"
" an IPv4 address", arg);
free(buf);
#endif
#ifdef INET
- dhcp_eopts = ifo->dhcp_override;
- dhcp_eopts_len = ifo->dhcp_override_len;
+ dhcp_opts = ifo->dhcp_override;
+ dhcp_opts_len = ifo->dhcp_override_len;
#else
for (i = 0; i < ifo->dhcp_override_len; i++)
free_dhcp_opt_embenc(&ifo->dhcp_override[i]);
ifo->dhcp_override_len = 0;
#ifdef INET6
- dhcp6_eopts = ifo->dhcp6_override;
- dhcp6_eopts_len = ifo->dhcp6_override_len;
+ dhcp6_opts = ifo->dhcp6_override;
+ dhcp6_opts_len = ifo->dhcp6_override_len;
#else
for (i = 0; i < ifo->dhcp6_override_len; i++)
free_dhcp_opt_embenc(&ifo->dhcp6_override[i]);