static int dhcp_open(struct interface *);
void
-dhcp_printoptions(const struct dhcpcd_ctx *ctx)
+dhcp_printoptions(const struct dhcpcd_ctx *ctx,
+ const struct dhcp_opt *opts, size_t opts_len)
{
const char * const *p;
- size_t i;
- const struct dhcp_opt *opt;
+ size_t i, j;
+ const struct dhcp_opt *opt, *opt2;
for (p = dhcp_params; *p; p++)
printf(" %s\n", *p);
- for (i = 0, opt = ctx->dhcp_opts; i < ctx->dhcp_opts_len; i++, opt++)
+ for (i = 0, opt = ctx->dhcp_opts; i < ctx->dhcp_opts_len; i++, opt++) {
+ for (j = 0, opt2 = opts; j < opts_len; j++, opt2++)
+ if (opt->option == opt2->option)
+ break;
+ if (j == opts_len)
+ printf("%03d %s\n", opt->option, opt->var);
+ }
+ for (i = 0, opt = opts; i < opts_len; i++, opt++)
printf("%03d %s\n", opt->option, opt->var);
}
ssize_t decode_rfc3442(char *, size_t, const uint8_t *p, size_t);
ssize_t decode_rfc5969(char *, size_t, const uint8_t *p, size_t);
-void dhcp_printoptions(const struct dhcpcd_ctx *);
+void dhcp_printoptions(const struct dhcpcd_ctx *,
+ const struct dhcp_opt *, size_t);
int get_option_addr(struct dhcpcd_ctx *,struct in_addr *,
const struct dhcp_message *, uint8_t);
#define is_bootp(i, m) ((m) && \
void dhcp_free(struct interface *);
int dhcp_dump(struct interface *);
#else
-#define dhcp_printoptions
#define dhcp_drop(a, b)
#define dhcp_start(a) {}
#define dhcp_reboot(a, b) b = b
};
void
-dhcp6_printoptions(const struct dhcpcd_ctx *ctx)
+dhcp6_printoptions(const struct dhcpcd_ctx *ctx,
+ const struct dhcp_opt *opts, size_t opts_len)
{
- size_t i;
- const struct dhcp_opt *opt;
+ size_t i, j;
+ const struct dhcp_opt *opt, *opt2;
for (i = 0, opt = ctx->dhcp6_opts;
i < ctx->dhcp6_opts_len; i++, opt++)
+ {
+ for (j = 0, opt2 = opts; j < opts_len; j++, opt2++)
+ if (opt2->option == opt->option)
+ break;
+ if (j == opts_len)
+ printf("%05d %s\n", opt->option, opt->var);
+ }
+ for (i = 0, opt = opts; i < opts_len; i++, opt++)
printf("%05d %s\n", opt->option, opt->var);
}
((const uint8_t *)(o) + sizeof(struct dhcp6_option))
#ifdef INET6
-void dhcp6_printoptions(const struct dhcpcd_ctx *);
+void dhcp6_printoptions(const struct dhcpcd_ctx *,
+ const struct dhcp_opt *, size_t);
int dhcp6_addrexists(struct dhcpcd_ctx *, const struct ipv6_addr *);
size_t dhcp6_find_delegates(struct interface *);
int dhcp6_start(struct interface *, enum DH6S);
void dhcp6_drop(struct interface *, const char *);
int dhcp6_dump(struct interface *);
#else
-#define dhcp6_printoptions()
#define dhcp6_addrexists(a, b) (0)
#define dhcp6_find_delegates(a)
#define dhcp6_start(a, b) (0)
ctx.ifv = argv + optind;
ifo = read_config(&ctx, NULL, NULL, NULL);
+ if (ifo == NULL)
+ goto exit_failure;
opt = add_options(&ctx, NULL, ifo, argc, argv);
if (opt != 1) {
if (opt == 0)
}
if (i == 3) {
printf("Interface options:\n");
+ if (optind == argc - 1) {
+ free_options(ifo);
+ ifo = read_config(&ctx, argv[optind], NULL, NULL);
+ if (ifo == NULL)
+ goto exit_failure;
+ add_options(&ctx, NULL, ifo, argc, argv);
+ }
if_printoptions();
#ifdef INET
if (family == 0 || family == AF_INET) {
printf("\nDHCPv4 options:\n");
- dhcp_printoptions(&ctx);
+ dhcp_printoptions(&ctx,
+ ifo->dhcp_override, ifo->dhcp_override_len);
}
#endif
#ifdef INET6
if (family == 0 || family == AF_INET6) {
printf("\nDHCPv6 options:\n");
- dhcp6_printoptions(&ctx);
+ dhcp6_printoptions(&ctx,
+ ifo->dhcp6_override, ifo->dhcp6_override_len);
}
#endif
goto exit_success;
ifp->ctx = &ctx;
TAILQ_INSERT_HEAD(ctx.ifaces, ifp, next);
}
- configure_interface(ifp, 0, NULL);
+ configure_interface(ifp, ctx.argc, ctx.argv);
if (family == 0 || family == AF_INET) {
if (dhcp_dump(ifp) == -1)
i = 1;