|
|
f9ed25 |
From a26161b0fd45cdbeed3038ac63ff04e3b727248f Mon Sep 17 00:00:00 2001
|
|
|
f9ed25 |
From: Pavel Zhukov <pzhukov@redhat.com>
|
|
|
f9ed25 |
Date: Thu, 21 Feb 2019 10:19:47 +0100
|
|
|
f9ed25 |
Subject: [PATCH 02/26] additional dhclient options
|
|
|
f9ed25 |
Cc: pzhukov@redhat.com
|
|
|
f9ed25 |
|
|
|
f9ed25 |
---
|
|
|
f9ed25 |
client/clparse.c | 10 +-
|
|
|
f9ed25 |
client/dhclient.8 | 27 ++++++
|
|
|
f9ed25 |
client/dhclient.c | 271 +++++++++++++++++++++++++++++++++++++++++++++++++++-
|
|
|
f9ed25 |
common/conflex.c | 2 +
|
|
|
f9ed25 |
includes/dhcpd.h | 3 +
|
|
|
f9ed25 |
includes/dhctoken.h | 1 +
|
|
|
f9ed25 |
6 files changed, 308 insertions(+), 6 deletions(-)
|
|
|
f9ed25 |
|
|
|
f9ed25 |
diff --git a/client/clparse.c b/client/clparse.c
|
|
|
f9ed25 |
index eaf48a8..7212e3a 100644
|
|
|
f9ed25 |
--- a/client/clparse.c
|
|
|
f9ed25 |
+++ b/client/clparse.c
|
|
|
f9ed25 |
@@ -189,6 +189,7 @@ isc_result_t read_client_conf ()
|
|
|
f9ed25 |
/* Requested lease time, used by DHCPv6 (DHCPv4 uses the option cache)
|
|
|
f9ed25 |
*/
|
|
|
f9ed25 |
top_level_config.requested_lease = 7200;
|
|
|
f9ed25 |
+ top_level_config.bootp_broadcast_always = 0;
|
|
|
f9ed25 |
|
|
|
f9ed25 |
group_allocate (&top_level_config.on_receipt, MDL);
|
|
|
f9ed25 |
if (!top_level_config.on_receipt)
|
|
|
f9ed25 |
@@ -394,7 +395,8 @@ void read_client_leases ()
|
|
|
f9ed25 |
interface-declaration |
|
|
|
f9ed25 |
LEASE client-lease-statement |
|
|
|
f9ed25 |
ALIAS client-lease-statement |
|
|
|
f9ed25 |
- KEY key-definition */
|
|
|
f9ed25 |
+ KEY key-definition |
|
|
|
f9ed25 |
+ BOOTP_BROADCAST_ALWAYS */
|
|
|
f9ed25 |
|
|
|
f9ed25 |
void parse_client_statement (cfile, ip, config)
|
|
|
f9ed25 |
struct parse *cfile;
|
|
|
f9ed25 |
@@ -817,6 +819,12 @@ void parse_client_statement (cfile, ip, config)
|
|
|
f9ed25 |
parse_lease_id_format(cfile);
|
|
|
f9ed25 |
break;
|
|
|
f9ed25 |
|
|
|
f9ed25 |
+ case BOOTP_BROADCAST_ALWAYS:
|
|
|
f9ed25 |
+ token = next_token(&val, (unsigned*)0, cfile);
|
|
|
f9ed25 |
+ config -> bootp_broadcast_always = 1;
|
|
|
f9ed25 |
+ parse_semi (cfile);
|
|
|
f9ed25 |
+ return;
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
|
|
|
f9ed25 |
default:
|
|
|
f9ed25 |
lose = 0;
|
|
|
f9ed25 |
diff --git a/client/dhclient.8 b/client/dhclient.8
|
|
|
f9ed25 |
index ebc750f..6d7fbdb 100644
|
|
|
f9ed25 |
--- a/client/dhclient.8
|
|
|
f9ed25 |
+++ b/client/dhclient.8
|
|
|
f9ed25 |
@@ -134,6 +134,33 @@ dhclient - Dynamic Host Configuration Protocol Client
|
|
|
f9ed25 |
.B -w
|
|
|
f9ed25 |
]
|
|
|
f9ed25 |
[
|
|
|
f9ed25 |
+.B -B
|
|
|
f9ed25 |
+]
|
|
|
f9ed25 |
+[
|
|
|
f9ed25 |
+.B -C
|
|
|
f9ed25 |
+.I dhcp-client-identifier
|
|
|
f9ed25 |
+]
|
|
|
f9ed25 |
+[
|
|
|
f9ed25 |
+.B -H
|
|
|
f9ed25 |
+.I host-name
|
|
|
f9ed25 |
+]
|
|
|
f9ed25 |
+[
|
|
|
f9ed25 |
+.B -F
|
|
|
f9ed25 |
+.I fqdn.fqdn
|
|
|
f9ed25 |
+]
|
|
|
f9ed25 |
+[
|
|
|
f9ed25 |
+.B -V
|
|
|
f9ed25 |
+.I vendor-class-identifier
|
|
|
f9ed25 |
+]
|
|
|
f9ed25 |
+[
|
|
|
f9ed25 |
+.B --request-options
|
|
|
f9ed25 |
+.I request-option-list
|
|
|
f9ed25 |
+]
|
|
|
f9ed25 |
+[
|
|
|
f9ed25 |
+.B --timeout
|
|
|
f9ed25 |
+.I timeout
|
|
|
f9ed25 |
+]
|
|
|
f9ed25 |
+[
|
|
|
f9ed25 |
.B --dad-wait-time
|
|
|
f9ed25 |
.I seconds
|
|
|
f9ed25 |
]
|
|
|
f9ed25 |
diff --git a/client/dhclient.c b/client/dhclient.c
|
|
|
f9ed25 |
index 825ab00..26a333c 100644
|
|
|
f9ed25 |
--- a/client/dhclient.c
|
|
|
f9ed25 |
+++ b/client/dhclient.c
|
|
|
f9ed25 |
@@ -41,6 +41,12 @@
|
|
|
f9ed25 |
#include <sys/wait.h>
|
|
|
f9ed25 |
#include <limits.h>
|
|
|
f9ed25 |
|
|
|
f9ed25 |
+/*
|
|
|
f9ed25 |
+ * Defined in stdio.h when _GNU_SOURCE is set, but we don't want to define
|
|
|
f9ed25 |
+ * that when building ISC code.
|
|
|
f9ed25 |
+ */
|
|
|
f9ed25 |
+extern int asprintf(char **strp, const char *fmt, ...);
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
TIME default_lease_time = 43200; /* 12 hours... */
|
|
|
f9ed25 |
TIME max_lease_time = 86400; /* 24 hours... */
|
|
|
f9ed25 |
|
|
|
f9ed25 |
@@ -110,6 +116,10 @@ char *mockup_relay = NULL;
|
|
|
f9ed25 |
|
|
|
f9ed25 |
char *progname = NULL;
|
|
|
f9ed25 |
|
|
|
f9ed25 |
+int bootp_broadcast_always = 0;
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+extern struct option *default_requested_options[];
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
void run_stateless(int exit_mode, u_int16_t port);
|
|
|
f9ed25 |
|
|
|
f9ed25 |
static isc_result_t write_duid(struct data_string *duid);
|
|
|
f9ed25 |
@@ -183,8 +193,12 @@ static const char use_v6command[] = "Command not used for DHCPv4: %s";
|
|
|
f9ed25 |
" [-s server-addr] [-cf config-file]\n" \
|
|
|
f9ed25 |
" [-df duid-file] [-lf lease-file]\n" \
|
|
|
f9ed25 |
" [-pf pid-file] [--no-pid] [-e VAR=val]\n" \
|
|
|
f9ed25 |
-" [-sf script-file] [interface]*"
|
|
|
f9ed25 |
-
|
|
|
f9ed25 |
+" [-sf script-file] [interface]*\n" \
|
|
|
f9ed25 |
+" [-C <dhcp-client-identifier>] [-B]\n" \
|
|
|
f9ed25 |
+" [-H <host-name> | -F <fqdn.fqdn>] [--timeout <timeout>]\n" \
|
|
|
f9ed25 |
+" [-V <vendor-class-identifier>]\n" \
|
|
|
f9ed25 |
+" [--request-options <request option list>]"
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
#define DHCLIENT_USAGEH "{--version|--help|-h}"
|
|
|
f9ed25 |
|
|
|
f9ed25 |
static void
|
|
|
f9ed25 |
@@ -243,6 +257,16 @@ main(int argc, char **argv) {
|
|
|
f9ed25 |
#else
|
|
|
f9ed25 |
progname = argv[0];
|
|
|
f9ed25 |
#endif
|
|
|
f9ed25 |
+ char *dhcp_client_identifier_arg = NULL;
|
|
|
f9ed25 |
+ char *dhcp_host_name_arg = NULL;
|
|
|
f9ed25 |
+ char *dhcp_fqdn_arg = NULL;
|
|
|
f9ed25 |
+ char *dhcp_vendor_class_identifier_arg = NULL;
|
|
|
f9ed25 |
+ char *dhclient_request_options = NULL;
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ int timeout_arg = 0;
|
|
|
f9ed25 |
+ char *arg_conf = NULL;
|
|
|
f9ed25 |
+ int arg_conf_len = 0;
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
/* Initialize client globals. */
|
|
|
f9ed25 |
memset(&default_duid, 0, sizeof(default_duid));
|
|
|
f9ed25 |
|
|
|
f9ed25 |
@@ -558,6 +582,89 @@ main(int argc, char **argv) {
|
|
|
f9ed25 |
std_dhcid = 1;
|
|
|
f9ed25 |
} else if (!strcmp(argv[i], "-v")) {
|
|
|
f9ed25 |
quiet = 0;
|
|
|
f9ed25 |
+ } else if (!strcmp(argv[i], "-C")) {
|
|
|
f9ed25 |
+ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
|
|
|
f9ed25 |
+ usage(use_noarg, argv[i-1]);
|
|
|
f9ed25 |
+ exit(1);
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ if (strlen(argv[i]) >= DHCP_MAX_OPTION_LEN) {
|
|
|
f9ed25 |
+ log_error("-C option dhcp-client-identifier string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_MAX_OPTION_LEN-1);
|
|
|
f9ed25 |
+ exit(1);
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ dhcp_client_identifier_arg = argv[i];
|
|
|
f9ed25 |
+ } else if (!strcmp(argv[i], "-B")) {
|
|
|
f9ed25 |
+ bootp_broadcast_always = 1;
|
|
|
f9ed25 |
+ } else if (!strcmp(argv[i], "-H")) {
|
|
|
f9ed25 |
+ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
|
|
|
f9ed25 |
+ usage(use_noarg, argv[i-1]);
|
|
|
f9ed25 |
+ exit(1);
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ if (strlen(argv[i]) >= DHCP_MAX_OPTION_LEN) {
|
|
|
f9ed25 |
+ log_error("-H option host-name string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_MAX_OPTION_LEN-1);
|
|
|
f9ed25 |
+ exit(1);
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ if (dhcp_host_name_arg != NULL) {
|
|
|
f9ed25 |
+ log_error("The -H <host-name> and -F <fqdn> arguments are mutually exclusive");
|
|
|
f9ed25 |
+ exit(1);
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ dhcp_host_name_arg = argv[i];
|
|
|
f9ed25 |
+ } else if (!strcmp(argv[i], "-F")) {
|
|
|
f9ed25 |
+ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
|
|
|
f9ed25 |
+ usage(use_noarg, argv[i-1]);
|
|
|
f9ed25 |
+ exit(1);
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ if (strlen(argv[i]) >= DHCP_MAX_OPTION_LEN) {
|
|
|
f9ed25 |
+ log_error("-F option fqdn.fqdn string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_MAX_OPTION_LEN-1);
|
|
|
f9ed25 |
+ exit(1);
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ if (dhcp_fqdn_arg != NULL) {
|
|
|
f9ed25 |
+ log_error("Only one -F <fqdn> argument can be specified");
|
|
|
f9ed25 |
+ exit(1);
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ if (dhcp_host_name_arg != NULL) {
|
|
|
f9ed25 |
+ log_error("The -F <fqdn> and -H <host-name> arguments are mutually exclusive");
|
|
|
f9ed25 |
+ exit(1);
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ dhcp_fqdn_arg = argv[i];
|
|
|
f9ed25 |
+ } else if (!strcmp(argv[i], "--timeout")) {
|
|
|
f9ed25 |
+ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
|
|
|
f9ed25 |
+ usage(use_noarg, argv[i-1]);
|
|
|
f9ed25 |
+ exit(1);
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ if ((timeout_arg = atoi(argv[i])) <= 0) {
|
|
|
f9ed25 |
+ log_error("timeout option must be > 0 - bad value: %s",argv[i]);
|
|
|
f9ed25 |
+ exit(1);
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+ } else if (!strcmp(argv[i], "-V")) {
|
|
|
f9ed25 |
+ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
|
|
|
f9ed25 |
+ usage(use_noarg, argv[i-1]);
|
|
|
f9ed25 |
+ exit(1);
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ if (strlen(argv[i]) >= DHCP_MAX_OPTION_LEN) {
|
|
|
f9ed25 |
+ log_error("-V option vendor-class-identifier string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_MAX_OPTION_LEN-1);
|
|
|
f9ed25 |
+ exit(1);
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ dhcp_vendor_class_identifier_arg = argv[i];
|
|
|
f9ed25 |
+ } else if (!strcmp(argv[i], "--request-options")) {
|
|
|
f9ed25 |
+ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
|
|
|
f9ed25 |
+ usage(use_noarg, argv[i-1]);
|
|
|
f9ed25 |
+ exit(1);
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ dhclient_request_options = argv[i];
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
} else if (argv[i][0] == '-') {
|
|
|
f9ed25 |
usage("Unknown command: %s", argv[i]);
|
|
|
f9ed25 |
} else if (interfaces_requested < 0) {
|
|
|
f9ed25 |
@@ -754,6 +861,156 @@ main(int argc, char **argv) {
|
|
|
f9ed25 |
/* Parse the dhclient.conf file. */
|
|
|
f9ed25 |
read_client_conf();
|
|
|
f9ed25 |
|
|
|
f9ed25 |
+ /* Parse any extra command line configuration arguments: */
|
|
|
f9ed25 |
+ if ((dhcp_client_identifier_arg != NULL) && (*dhcp_client_identifier_arg != '\0')) {
|
|
|
f9ed25 |
+ arg_conf_len = asprintf(&arg_conf, "send dhcp-client-identifier \"%s\";", dhcp_client_identifier_arg);
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
|
|
f9ed25 |
+ log_fatal("Unable to send -C option dhcp-client-identifier");
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ if ((dhcp_host_name_arg != NULL) && (*dhcp_host_name_arg != '\0')) {
|
|
|
f9ed25 |
+ if (arg_conf == 0) {
|
|
|
f9ed25 |
+ arg_conf_len = asprintf(&arg_conf, "send host-name \"%s\";", dhcp_host_name_arg);
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
|
|
f9ed25 |
+ log_fatal("Unable to send -H option host-name");
|
|
|
f9ed25 |
+ } else {
|
|
|
f9ed25 |
+ char *last_arg_conf = arg_conf;
|
|
|
f9ed25 |
+ arg_conf = NULL;
|
|
|
f9ed25 |
+ arg_conf_len = asprintf(&arg_conf, "%s\nsend host-name \"%s\";", last_arg_conf, dhcp_host_name_arg);
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
|
|
f9ed25 |
+ log_fatal("Unable to send -H option host-name");
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ free(last_arg_conf);
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ if ((dhcp_fqdn_arg != NULL) && (*dhcp_fqdn_arg != '\0')) {
|
|
|
f9ed25 |
+ if (arg_conf == 0) {
|
|
|
f9ed25 |
+ arg_conf_len = asprintf(&arg_conf, "send fqdn.fqdn \"%s\";", dhcp_fqdn_arg);
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
|
|
f9ed25 |
+ log_fatal("Unable to send -F option fqdn.fqdn");
|
|
|
f9ed25 |
+ } else {
|
|
|
f9ed25 |
+ char *last_arg_conf = arg_conf;
|
|
|
f9ed25 |
+ arg_conf = NULL;
|
|
|
f9ed25 |
+ arg_conf_len = asprintf(&arg_conf, "%s\nsend fqdn.fqdn \"%s\";", last_arg_conf, dhcp_fqdn_arg);
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
|
|
f9ed25 |
+ log_fatal("Unable to send -F option fqdn.fqdn");
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ free(last_arg_conf);
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ if (timeout_arg) {
|
|
|
f9ed25 |
+ if (arg_conf == 0) {
|
|
|
f9ed25 |
+ arg_conf_len = asprintf(&arg_conf, "timeout %d;", timeout_arg);
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
|
|
f9ed25 |
+ log_fatal("Unable to process --timeout timeout argument");
|
|
|
f9ed25 |
+ } else {
|
|
|
f9ed25 |
+ char *last_arg_conf = arg_conf;
|
|
|
f9ed25 |
+ arg_conf = NULL;
|
|
|
f9ed25 |
+ arg_conf_len = asprintf(&arg_conf, "%s\ntimeout %d;", last_arg_conf, timeout_arg);
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ if ((arg_conf == 0) || (arg_conf_len == 0))
|
|
|
f9ed25 |
+ log_fatal("Unable to process --timeout timeout argument");
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ free(last_arg_conf);
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ if ((dhcp_vendor_class_identifier_arg != NULL) && (*dhcp_vendor_class_identifier_arg != '\0')) {
|
|
|
f9ed25 |
+ if (arg_conf == 0) {
|
|
|
f9ed25 |
+ arg_conf_len = asprintf(&arg_conf, "send vendor-class-identifier \"%s\";", dhcp_vendor_class_identifier_arg);
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
|
|
f9ed25 |
+ log_fatal("Unable to send -V option vendor-class-identifier");
|
|
|
f9ed25 |
+ } else {
|
|
|
f9ed25 |
+ char *last_arg_conf = arg_conf;
|
|
|
f9ed25 |
+ arg_conf = NULL;
|
|
|
f9ed25 |
+ arg_conf_len = asprintf(&arg_conf, "%s\nsend vendor-class-identifier \"%s\";", last_arg_conf, dhcp_vendor_class_identifier_arg);
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
|
|
f9ed25 |
+ log_fatal("Unable to send -V option vendor-class-identifier");
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ free(last_arg_conf);
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ if (dhclient_request_options != NULL) {
|
|
|
f9ed25 |
+ if (arg_conf == 0) {
|
|
|
f9ed25 |
+ arg_conf_len = asprintf(&arg_conf, "request %s;", dhclient_request_options);
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
|
|
f9ed25 |
+ log_fatal("Unable to parse --request-options <request options list> argument");
|
|
|
f9ed25 |
+ } else {
|
|
|
f9ed25 |
+ char *last_arg_conf = arg_conf;
|
|
|
f9ed25 |
+ arg_conf = NULL;
|
|
|
f9ed25 |
+ arg_conf_len = asprintf(&arg_conf, "%s\nrequest %s;", last_arg_conf, dhclient_request_options);
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
|
|
f9ed25 |
+ log_fatal("Unable to parse --request-options <request options list> argument");
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ free(last_arg_conf);
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ if (arg_conf) {
|
|
|
f9ed25 |
+ if (arg_conf_len == 0)
|
|
|
f9ed25 |
+ if ((arg_conf_len = strlen(arg_conf)) == 0)
|
|
|
f9ed25 |
+ /* huh ? cannot happen ! */
|
|
|
f9ed25 |
+ log_fatal("Unable to process -C/-H/-F/--timeout/-V/--request-options configuration arguments");
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ /* parse the extra dhclient.conf configuration arguments
|
|
|
f9ed25 |
+ * into top level config: */
|
|
|
f9ed25 |
+ struct parse *cfile = (struct parse *)0;
|
|
|
f9ed25 |
+ const char *val = NULL;
|
|
|
f9ed25 |
+ int token;
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ status = new_parse(&cfile, -1, arg_conf, arg_conf_len, "extra dhclient -C/-H/-F/--timeout/-V/--request-options configuration arguments", 0);
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ if ((status != ISC_R_SUCCESS) || (cfile -> warnings_occurred))
|
|
|
f9ed25 |
+ log_fatal("Cannot parse -C/-H/-F/--timeout/-V/--request-options configuration arguments !");
|
|
|
f9ed25 |
+ /* more detailed parse failures will be logged */
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ do {
|
|
|
f9ed25 |
+ token = peek_token(&val, (unsigned *)0, cfile);
|
|
|
f9ed25 |
+ if (token == END_OF_FILE)
|
|
|
f9ed25 |
+ break;
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ parse_client_statement(cfile, (struct interface_info *)0, &top_level_config);
|
|
|
f9ed25 |
+ } while (1);
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ if (cfile -> warnings_occurred)
|
|
|
f9ed25 |
+ log_fatal("Cannot parse -C/-H/-F/--timeout/-V/--request-options configuration arguments !");
|
|
|
f9ed25 |
+ end_parse(&cfile);
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ if (timeout_arg) {
|
|
|
f9ed25 |
+ /* we just set the toplevel timeout, but per-client
|
|
|
f9ed25 |
+ * timeouts may still be at defaults.
|
|
|
f9ed25 |
+ */
|
|
|
f9ed25 |
+ for (ip=interfaces; ip; ip = ip->next) {
|
|
|
f9ed25 |
+ if (ip->client->config->timeout == 60)
|
|
|
f9ed25 |
+ ip->client->config->timeout = timeout_arg;
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ if ((dhclient_request_options != 0) && (top_level_config.requested_options != default_requested_options)) {
|
|
|
f9ed25 |
+ for (ip=interfaces; ip; ip = ip->next) {
|
|
|
f9ed25 |
+ if (ip->client->config->requested_options == default_requested_options)
|
|
|
f9ed25 |
+ ip->client->config->requested_options = top_level_config.requested_options;
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ free(arg_conf);
|
|
|
f9ed25 |
+ arg_conf = NULL;
|
|
|
f9ed25 |
+ arg_conf_len = 0;
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
/* Parse the lease database. */
|
|
|
f9ed25 |
read_client_leases();
|
|
|
f9ed25 |
|
|
|
f9ed25 |
@@ -3226,7 +3483,8 @@ void make_discover (client, lease)
|
|
|
f9ed25 |
client -> packet.xid = random ();
|
|
|
f9ed25 |
client -> packet.secs = 0; /* filled in by send_discover. */
|
|
|
f9ed25 |
|
|
|
f9ed25 |
- if (can_receive_unicast_unconfigured (client -> interface))
|
|
|
f9ed25 |
+ if ((!(bootp_broadcast_always || client->config->bootp_broadcast_always))
|
|
|
f9ed25 |
+ && can_receive_unicast_unconfigured(client->interface))
|
|
|
f9ed25 |
client -> packet.flags = 0;
|
|
|
f9ed25 |
else
|
|
|
f9ed25 |
client -> packet.flags = htons (BOOTP_BROADCAST);
|
|
|
f9ed25 |
@@ -3311,7 +3569,9 @@ void make_request (client, lease)
|
|
|
f9ed25 |
} else {
|
|
|
f9ed25 |
memset (&client -> packet.ciaddr, 0,
|
|
|
f9ed25 |
sizeof client -> packet.ciaddr);
|
|
|
f9ed25 |
- if (can_receive_unicast_unconfigured (client -> interface))
|
|
|
f9ed25 |
+ if ((!(bootp_broadcast_always ||
|
|
|
f9ed25 |
+ client ->config->bootp_broadcast_always)) &&
|
|
|
f9ed25 |
+ can_receive_unicast_unconfigured (client -> interface))
|
|
|
f9ed25 |
client -> packet.flags = 0;
|
|
|
f9ed25 |
else
|
|
|
f9ed25 |
client -> packet.flags = htons (BOOTP_BROADCAST);
|
|
|
f9ed25 |
@@ -3374,7 +3634,8 @@ void make_decline (client, lease)
|
|
|
f9ed25 |
client -> packet.hops = 0;
|
|
|
f9ed25 |
client -> packet.xid = client -> xid;
|
|
|
f9ed25 |
client -> packet.secs = 0; /* Filled in by send_request. */
|
|
|
f9ed25 |
- if (can_receive_unicast_unconfigured (client -> interface))
|
|
|
f9ed25 |
+ if ((!(bootp_broadcast_always || client->config-> bootp_broadcast_always))
|
|
|
f9ed25 |
+ && can_receive_unicast_unconfigured (client->interface))
|
|
|
f9ed25 |
client -> packet.flags = 0;
|
|
|
f9ed25 |
else
|
|
|
f9ed25 |
client -> packet.flags = htons (BOOTP_BROADCAST);
|
|
|
f9ed25 |
diff --git a/common/conflex.c b/common/conflex.c
|
|
|
f9ed25 |
index 045b655..71c0bf5 100644
|
|
|
f9ed25 |
--- a/common/conflex.c
|
|
|
f9ed25 |
+++ b/common/conflex.c
|
|
|
f9ed25 |
@@ -832,6 +832,8 @@ intern(char *atom, enum dhcp_token dfv) {
|
|
|
f9ed25 |
if (!strcasecmp(atom+1, "ig-endian")) {
|
|
|
f9ed25 |
return TOKEN_BIG_ENDIAN;
|
|
|
f9ed25 |
}
|
|
|
f9ed25 |
+ if (!strcasecmp (atom + 1, "ootp-broadcast-always"))
|
|
|
f9ed25 |
+ return BOOTP_BROADCAST_ALWAYS;
|
|
|
f9ed25 |
break;
|
|
|
f9ed25 |
case 'c':
|
|
|
f9ed25 |
if (!strcasecmp(atom + 1, "ase"))
|
|
|
f9ed25 |
diff --git a/includes/dhcpd.h b/includes/dhcpd.h
|
|
|
f9ed25 |
index 5930e6a..018fa34 100644
|
|
|
f9ed25 |
--- a/includes/dhcpd.h
|
|
|
f9ed25 |
+++ b/includes/dhcpd.h
|
|
|
f9ed25 |
@@ -1269,6 +1269,9 @@ struct client_config {
|
|
|
f9ed25 |
|
|
|
f9ed25 |
int lease_id_format; /* format for IDs in lease file,
|
|
|
f9ed25 |
TOKEN_OCTAL or TOKEN_HEX */
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ int bootp_broadcast_always; /* If nonzero, always set the BOOTP_BROADCAST
|
|
|
f9ed25 |
+ flag in requests */
|
|
|
f9ed25 |
};
|
|
|
f9ed25 |
|
|
|
f9ed25 |
/* Per-interface state used in the dhcp client... */
|
|
|
f9ed25 |
diff --git a/includes/dhctoken.h b/includes/dhctoken.h
|
|
|
f9ed25 |
index 5920f4f..7e7215a 100644
|
|
|
f9ed25 |
--- a/includes/dhctoken.h
|
|
|
f9ed25 |
+++ b/includes/dhctoken.h
|
|
|
f9ed25 |
@@ -377,6 +377,7 @@ enum dhcp_token {
|
|
|
f9ed25 |
TOKEN_HEX = 677,
|
|
|
f9ed25 |
TOKEN_OCTAL = 678,
|
|
|
f9ed25 |
KEY_ALGORITHM = 679
|
|
|
f9ed25 |
+ BOOTP_BROADCAST_ALWAYS = 680
|
|
|
f9ed25 |
};
|
|
|
f9ed25 |
|
|
|
f9ed25 |
#define is_identifier(x) ((x) >= FIRST_TOKEN && \
|
|
|
f9ed25 |
--
|
|
|
f9ed25 |
2.14.5
|
|
|
f9ed25 |
|