* But we can support both as the hook scripts will uniqify the
* results if the server returns both options.
*/
+#ifdef INET
static const struct dhcp_compat dhcp_compats[] = { { DHO_DNSSERVER,
D6_OPTION_DNS_SERVERS },
{ DHO_HOSTNAME, D6_OPTION_FQDN }, { DHO_DNSDOMAIN, D6_OPTION_FQDN },
{ DHO_FQDN, D6_OPTION_FQDN }, { DHO_VIVCO, D6_OPTION_VENDOR_CLASS },
{ DHO_VIVSO, D6_OPTION_VENDOR_OPTS },
{ DHO_DNSSEARCH, D6_OPTION_DOMAIN_LIST }, { 0, 0 } };
+#endif
static const char *const dhcp6_statuses[] = { "Success", "Unspecified Failure",
"No Addresses Available", "No Binding", "Not On Link", "Use Multicast",
struct if_options *ifo = ifp->options;
struct dho_policy_group *pg = &ifo->dhopg_dhcp6;
struct dhcp6_state *state;
- const struct dhcp_compat *dhc;
if ((ctx->options & (DHCPCD_MANAGER | DHCPCD_PRIVSEP)) ==
DHCPCD_MANAGER &&
/* If no DHCPv6 options are configured,
match configured DHCPv4 options to DHCPv6 equivalents. */
if (pg->dhop_request.dhop_policy_len == 0) {
+#ifdef INET
+ const struct dhcp_compat *dhc;
const struct dho_policy_group *dpg = &ifo->dhopg_dhcp;
+#endif
int err;
+#ifdef INET
for (dhc = dhcp_compats; dhc->dhcp_opt; dhc++) {
if (!dho_policy_has(&dpg->dhop_request, dhc->dhcp_opt))
continue;
return;
}
}
+#else
+ err = dho_policy_add(&pg->dhop_request, D6_OPTION_DNS_SERVERS);
+ if (err == -1) {
+ logerr(__func__);
+ return;
+ }
+ err = dho_policy_add(&pg->dhop_request, D6_OPTION_DOMAIN_LIST);
+ if (err == -1) {
+ logerr(__func__);
+ return;
+ }
+#endif
if (ifo->fqdn != FQDN_DISABLE ||
ifo->options & DHCPCD_HOSTNAME) {
err = dho_policy_add(&pg->dhop_request, D6_OPTION_FQDN);
}
#endif
-static void
+static int
set_option_space(struct dhcpcd_ctx *ctx, struct if_options *ifo,
const char *arg, struct dho_policy_ctx *pctx, struct dho_policy_group **pg)
{
if (strncmp(arg, "nd_", strlen("nd_")) == 0) {
+#ifdef INET6
pctx->dopts = ctx->nd_opts;
pctx->dopts_len = ctx->nd_opts_len;
pctx->odopts = ifo->nd_override;
pctx->odopts_len = ifo->nd_override_len;
*pg = &ifo->dhopg_nd;
- return;
+ return 0;
+#else
+ errno = EPFNOSUPPORT;
+ return -1;
+#endif
}
if (strncmp(arg, "dhcp6_", strlen("dhcp6_")) == 0) {
+#ifdef DHCP6
pctx->dopts = ctx->dhcp6_opts;
pctx->dopts_len = ctx->dhcp6_opts_len;
pctx->odopts = ifo->dhcp6_override;
pctx->odopts_len = ifo->dhcp6_override_len;
*pg = &ifo->dhopg_dhcp6;
- return;
+ return 0;
+#else
+ errno = EPFNOSUPPORT;
+ return -1;
+#endif
}
+#ifdef INET
pctx->dopts = ctx->dhcp_opts;
pctx->dopts_len = ctx->dhcp_opts_len;
pctx->odopts = ifo->dhcp_override;
pctx->odopts_len = ifo->dhcp_override_len;
*pg = &ifo->dhopg_dhcp;
+ return 0;
+#else
+ errno = EPFNOSUPPORT;
+ return -1;
+#endif
}
void
ARG_REQUIRED;
if (ctx->options & DHCPCD_PRINT_PIDFILE)
break;
- set_option_space(ctx, ifo, arg, &pctx, &pg);
+ if (set_option_space(ctx, ifo, arg, &pctx, &pg) == -1)
+ return 0;
if (dho_policy_set(&pctx, &pg->dhop_request, arg, 1) != 0 ||
dho_policy_set(&pctx, &pg->dhop_remove, arg, -1) != 0 ||
dho_policy_set(&pctx, &pg->dhop_reject, arg, -1) != 0) {
ARG_REQUIRED;
if (ctx->options & DHCPCD_PRINT_PIDFILE)
break;
- set_option_space(ctx, ifo, arg, &pctx, &pg);
+ if (set_option_space(ctx, ifo, arg, &pctx, &pg) == -1)
+ return 0;
if (dho_policy_set(&pctx, &pg->dhop_reject, arg, 1) != 0 ||
dho_policy_set(&pctx, &pg->dhop_request, arg, -1) != 0 ||
dho_policy_set(&pctx, &pg->dhop_require, arg, -1) != 0) {
ARG_REQUIRED;
if (ctx->options & DHCPCD_PRINT_PIDFILE)
break;
- set_option_space(ctx, ifo, arg, &pctx, &pg);
+ if (set_option_space(ctx, ifo, arg, &pctx, &pg) == -1)
+ return 0;
if (dho_policy_set(&pctx, &pg->dhop_request, arg, -1) != 0 ||
dho_policy_set(&pctx, &pg->dhop_require, arg, -1) != 0 ||
dho_policy_set(&pctx, &pg->dhop_remove, arg, 1) != 0) {
ARG_REQUIRED;
if (ctx->options & DHCPCD_PRINT_PIDFILE)
break;
- set_option_space(ctx, ifo, arg, &pctx, &pg);
+ if (set_option_space(ctx, ifo, arg, &pctx, &pg) == -1)
+ return 0;
if (dho_policy_set(&pctx, &pg->dhop_require, arg, 1) != 0 ||
dho_policy_set(&pctx, &pg->dhop_request, arg, 1) != 0 ||
dho_policy_set(&pctx, &pg->dhop_remove, arg, -1) != 0 ||
ARG_REQUIRED;
if (ctx->options & DHCPCD_PRINT_PIDFILE)
break;
- set_option_space(ctx, ifo, arg, &pctx, &pg);
+ if (set_option_space(ctx, ifo, arg, &pctx, &pg) == -1)
+ return 0;
if (set_default_allow(ifo, pg)) {
logerr("%s: set_default_allow", __func__);
return -1;
ARG_REQUIRED;
if (ctx->options & DHCPCD_PRINT_PIDFILE)
break;
- set_option_space(ctx, ifo, arg, &pctx, &pg);
+ if (set_option_space(ctx, ifo, arg, &pctx, &pg) == -1)
+ return 0;
if (dho_policy_set(&pctx, &ifo->dhop_destination, arg, 2) !=
0) {
if (errno == EINVAL)
free(ifo->config);
}
+#ifdef INET
dho_policy_group_free(ifo->dhopg_dhcp);
dho_policy_free(ifo->dhop_destination);
+#endif
+#ifdef INET6
dho_policy_group_free(ifo->dhopg_nd);
+#endif
+#ifdef DHCP6
dho_policy_group_free(ifo->dhopg_dhcp6);
+#endif
#ifdef RT_FREE_ROUTE_TABLE
/* Stupidly, we don't know the interface when creating the