1 diff -up dhcp-4.3.4/client/clparse.c.options dhcp-4.3.4/client/clparse.c
2 --- dhcp-4.3.4/client/clparse.c.options 2016-03-22 14:16:51.000000000 +0100
3 +++ dhcp-4.3.4/client/clparse.c 2016-04-29 12:06:13.485470579 +0200
4 @@ -189,6 +189,7 @@ isc_result_t read_client_conf ()
5 /* Requested lease time, used by DHCPv6 (DHCPv4 uses the option cache)
7 top_level_config.requested_lease = 7200;
8 + top_level_config.bootp_broadcast_always = 0;
10 group_allocate (&top_level_config.on_receipt, MDL);
11 if (!top_level_config.on_receipt)
12 @@ -394,7 +395,8 @@ void read_client_leases ()
13 interface-declaration |
14 LEASE client-lease-statement |
15 ALIAS client-lease-statement |
16 - KEY key-definition */
17 + KEY key-definition |
18 + BOOTP_BROADCAST_ALWAYS */
20 void parse_client_statement (cfile, ip, config)
22 @@ -817,6 +819,12 @@ void parse_client_statement (cfile, ip,
23 parse_lease_id_format(cfile);
26 + case BOOTP_BROADCAST_ALWAYS:
27 + token = next_token(&val, (unsigned*)0, cfile);
28 + config -> bootp_broadcast_always = 1;
35 diff -up dhcp-4.3.4/client/dhclient.8.options dhcp-4.3.4/client/dhclient.8
36 --- dhcp-4.3.4/client/dhclient.8.options 2016-03-22 14:16:51.000000000 +0100
37 +++ dhcp-4.3.4/client/dhclient.8 2016-04-29 11:59:50.446590077 +0200
38 @@ -134,6 +134,33 @@ dhclient - Dynamic Host Configuration Pr
46 +.I dhcp-client-identifier
58 +.I vendor-class-identifier
62 +.I request-option-list
72 @@ -289,6 +316,69 @@ not to exit when it doesn't find any suc
73 program can then be used to notify the client when a network interface
74 has been added or removed, so that the client can attempt to configure an IP
75 address on that interface.
79 +Set the BOOTP broadcast flag in request packets so servers will always
83 +.BI \-C\ <dhcp-client-identifier>
84 +Specify the dhcp-client-identifier option to send to the DHCP server.
88 +Specify the host-name option to send to the DHCP server. The host-name
89 +string only contains the client's hostname prefix, to which the server will
90 +append the ddns-domainname or domain-name options, if any, to derive the
91 +fully qualified domain name of the client. The
93 +option cannot be used with the
99 +Specify the fqdn.fqdn option to send to the DHCP server. This option cannot
102 +option. The fqdn.fqdn option must specify the complete domain name of the
103 +client host, which the server may use for dynamic DNS updates.
106 +.BI \-V\ <vendor-class-identifier>
107 +Specify the vendor-class-identifier option to send to the DHCP server.
110 +.BI \--request-options\ <option>[,<option>...]
111 +Specify the list of options the client is to request from the server. The
112 +option list must be a single string consisting of option names separated
113 +by at least one command and optional space characters. The default option
117 + subnet-mask, broadcast-address, time-offset, routers,
119 + domain-search, domain-name, domain-name-servers, host-name,
121 + nis-domain, nis-servers, ntp-servers, interface-mtu
124 +.B --request-options
125 +option does not append options to the default request, it overrides the
126 +default request list. Keep this in mind if you want to request an
127 +additional option besides the default request list. You will have to
128 +specify all option names for the
129 +.B --request-options
133 +.BI \--timeout\ <timeout>
134 +Specify the time after which
136 +will decide that no DHCP servers can be contacted when no responses have been
141 Do not configure any interfaces. This is most likely to be useful in
142 diff -up dhcp-4.3.4/client/dhclient.c.options dhcp-4.3.4/client/dhclient.c
143 --- dhcp-4.3.4/client/dhclient.c.options 2016-03-22 14:16:51.000000000 +0100
144 +++ dhcp-4.3.4/client/dhclient.c 2016-04-29 12:12:14.182364093 +0200
146 #include <isc/file.h>
147 #include <dns/result.h>
150 + * Defined in stdio.h when _GNU_SOURCE is set, but we don't want to define
151 + * that when building ISC code.
153 +extern int asprintf(char **strp, const char *fmt, ...);
155 TIME default_lease_time = 43200; /* 12 hours... */
156 TIME max_lease_time = 86400; /* 24 hours... */
158 @@ -100,6 +106,10 @@ char *mockup_relay = NULL;
160 char *progname = NULL;
162 +int bootp_broadcast_always = 0;
164 +extern struct option *default_requested_options[];
166 void run_stateless(int exit_mode, u_int16_t port);
168 static isc_result_t write_duid(struct data_string *duid);
169 @@ -177,7 +187,11 @@ usage(const char *sfmt, const char *sarg
170 " [-s server-addr] [-cf config-file]\n"
171 " [-df duid-file] [-lf lease-file]\n"
172 " [-pf pid-file] [--no-pid] [-e VAR=val]\n"
173 - " [-sf script-file] [interface]*",
174 + " [-sf script-file] [interface]*\n"
175 + " [-C <dhcp-client-identifier>] [-B]\n"
176 + " [-H <host-name> | -F <fqdn.fqdn>] [--timeout <timeout>]\n"
177 + " [-V <vendor-class-identifier>]\n"
178 + " [--request-options <request option list>]",
179 isc_file_basename(progname));
182 @@ -214,6 +228,16 @@ main(int argc, char **argv) {
186 + char *dhcp_client_identifier_arg = NULL;
187 + char *dhcp_host_name_arg = NULL;
188 + char *dhcp_fqdn_arg = NULL;
189 + char *dhcp_vendor_class_identifier_arg = NULL;
190 + char *dhclient_request_options = NULL;
192 + int timeout_arg = 0;
193 + char *arg_conf = NULL;
194 + int arg_conf_len = 0;
196 /* Initialize client globals. */
197 memset(&default_duid, 0, sizeof(default_duid));
199 @@ -431,6 +455,88 @@ main(int argc, char **argv) {
200 strlen(PACKAGE_VERSION)));
201 IGNORE_RET(write(STDERR_FILENO, "\n", 1));
203 + } else if (!strcmp(argv[i], "-C")) {
204 + if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
205 + usage(use_noarg, argv[i-1]);
209 + if (strlen(argv[i]) >= DHCP_MAX_OPTION_LEN) {
210 + log_error("-C option dhcp-client-identifier string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_MAX_OPTION_LEN-1);
214 + dhcp_client_identifier_arg = argv[i];
215 + } else if (!strcmp(argv[i], "-B")) {
216 + bootp_broadcast_always = 1;
217 + } else if (!strcmp(argv[i], "-H")) {
218 + if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
219 + usage(use_noarg, argv[i-1]);
223 + if (strlen(argv[i]) >= DHCP_MAX_OPTION_LEN) {
224 + log_error("-H option host-name string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_MAX_OPTION_LEN-1);
228 + if (dhcp_host_name_arg != NULL) {
229 + log_error("The -H <host-name> and -F <fqdn> arguments are mutually exclusive");
233 + dhcp_host_name_arg = argv[i];
234 + } else if (!strcmp(argv[i], "-F")) {
235 + if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
236 + usage(use_noarg, argv[i-1]);
240 + if (strlen(argv[i]) >= DHCP_MAX_OPTION_LEN) {
241 + log_error("-F option fqdn.fqdn string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_MAX_OPTION_LEN-1);
245 + if (dhcp_fqdn_arg != NULL) {
246 + log_error("Only one -F <fqdn> argument can be specified");
250 + if (dhcp_host_name_arg != NULL) {
251 + log_error("The -F <fqdn> and -H <host-name> arguments are mutually exclusive");
255 + dhcp_fqdn_arg = argv[i];
256 + } else if (!strcmp(argv[i], "--timeout")) {
257 + if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
258 + usage(use_noarg, argv[i-1]);
262 + if ((timeout_arg = atoi(argv[i])) <= 0) {
263 + log_error("timeout option must be > 0 - bad value: %s",argv[i]);
266 + } else if (!strcmp(argv[i], "-V")) {
267 + if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
268 + usage(use_noarg, argv[i-1]);
272 + if (strlen(argv[i]) >= DHCP_MAX_OPTION_LEN) {
273 + log_error("-V option vendor-class-identifier string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_MAX_OPTION_LEN-1);
277 + dhcp_vendor_class_identifier_arg = argv[i];
278 + } else if (!strcmp(argv[i], "--request-options")) {
279 + if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
280 + usage(use_noarg, argv[i-1]);
284 + dhclient_request_options = argv[i];
285 } else if (argv[i][0] == '-') {
286 usage("Unknown command: %s", argv[i]);
287 } else if (interfaces_requested < 0) {
288 @@ -630,6 +736,156 @@ main(int argc, char **argv) {
289 /* Parse the dhclient.conf file. */
292 + /* Parse any extra command line configuration arguments: */
293 + if ((dhcp_client_identifier_arg != NULL) && (*dhcp_client_identifier_arg != '\0')) {
294 + arg_conf_len = asprintf(&arg_conf, "send dhcp-client-identifier \"%s\";", dhcp_client_identifier_arg);
296 + if ((arg_conf == 0) || (arg_conf_len <= 0))
297 + log_fatal("Unable to send -C option dhcp-client-identifier");
300 + if ((dhcp_host_name_arg != NULL) && (*dhcp_host_name_arg != '\0')) {
301 + if (arg_conf == 0) {
302 + arg_conf_len = asprintf(&arg_conf, "send host-name \"%s\";", dhcp_host_name_arg);
304 + if ((arg_conf == 0) || (arg_conf_len <= 0))
305 + log_fatal("Unable to send -H option host-name");
307 + char *last_arg_conf = arg_conf;
309 + arg_conf_len = asprintf(&arg_conf, "%s\nsend host-name \"%s\";", last_arg_conf, dhcp_host_name_arg);
311 + if ((arg_conf == 0) || (arg_conf_len <= 0))
312 + log_fatal("Unable to send -H option host-name");
314 + free(last_arg_conf);
318 + if ((dhcp_fqdn_arg != NULL) && (*dhcp_fqdn_arg != '\0')) {
319 + if (arg_conf == 0) {
320 + arg_conf_len = asprintf(&arg_conf, "send fqdn.fqdn \"%s\";", dhcp_fqdn_arg);
322 + if ((arg_conf == 0) || (arg_conf_len <= 0))
323 + log_fatal("Unable to send -F option fqdn.fqdn");
325 + char *last_arg_conf = arg_conf;
327 + arg_conf_len = asprintf(&arg_conf, "%s\nsend fqdn.fqdn \"%s\";", last_arg_conf, dhcp_fqdn_arg);
329 + if ((arg_conf == 0) || (arg_conf_len <= 0))
330 + log_fatal("Unable to send -F option fqdn.fqdn");
332 + free(last_arg_conf);
337 + if (arg_conf == 0) {
338 + arg_conf_len = asprintf(&arg_conf, "timeout %d;", timeout_arg);
340 + if ((arg_conf == 0) || (arg_conf_len <= 0))
341 + log_fatal("Unable to process --timeout timeout argument");
343 + char *last_arg_conf = arg_conf;
345 + arg_conf_len = asprintf(&arg_conf, "%s\ntimeout %d;", last_arg_conf, timeout_arg);
347 + if ((arg_conf == 0) || (arg_conf_len == 0))
348 + log_fatal("Unable to process --timeout timeout argument");
350 + free(last_arg_conf);
354 + if ((dhcp_vendor_class_identifier_arg != NULL) && (*dhcp_vendor_class_identifier_arg != '\0')) {
355 + if (arg_conf == 0) {
356 + arg_conf_len = asprintf(&arg_conf, "send vendor-class-identifier \"%s\";", dhcp_vendor_class_identifier_arg);
358 + if ((arg_conf == 0) || (arg_conf_len <= 0))
359 + log_fatal("Unable to send -V option vendor-class-identifier");
361 + char *last_arg_conf = arg_conf;
363 + arg_conf_len = asprintf(&arg_conf, "%s\nsend vendor-class-identifier \"%s\";", last_arg_conf, dhcp_vendor_class_identifier_arg);
365 + if ((arg_conf == 0) || (arg_conf_len <= 0))
366 + log_fatal("Unable to send -V option vendor-class-identifier");
368 + free(last_arg_conf);
372 + if (dhclient_request_options != NULL) {
373 + if (arg_conf == 0) {
374 + arg_conf_len = asprintf(&arg_conf, "request %s;", dhclient_request_options);
376 + if ((arg_conf == 0) || (arg_conf_len <= 0))
377 + log_fatal("Unable to parse --request-options <request options list> argument");
379 + char *last_arg_conf = arg_conf;
381 + arg_conf_len = asprintf(&arg_conf, "%s\nrequest %s;", last_arg_conf, dhclient_request_options);
383 + if ((arg_conf == 0) || (arg_conf_len <= 0))
384 + log_fatal("Unable to parse --request-options <request options list> argument");
386 + free(last_arg_conf);
391 + if (arg_conf_len == 0)
392 + if ((arg_conf_len = strlen(arg_conf)) == 0)
393 + /* huh ? cannot happen ! */
394 + log_fatal("Unable to process -C/-H/-F/--timeout/-V/--request-options configuration arguments");
396 + /* parse the extra dhclient.conf configuration arguments
397 + * into top level config: */
398 + struct parse *cfile = (struct parse *)0;
399 + const char *val = NULL;
402 + status = new_parse(&cfile, -1, arg_conf, arg_conf_len, "extra dhclient -C/-H/-F/--timeout/-V/--request-options configuration arguments", 0);
404 + if ((status != ISC_R_SUCCESS) || (cfile -> warnings_occurred))
405 + log_fatal("Cannot parse -C/-H/-F/--timeout/-V/--request-options configuration arguments !");
406 + /* more detailed parse failures will be logged */
409 + token = peek_token(&val, (unsigned *)0, cfile);
410 + if (token == END_OF_FILE)
413 + parse_client_statement(cfile, (struct interface_info *)0, &top_level_config);
416 + if (cfile -> warnings_occurred)
417 + log_fatal("Cannot parse -C/-H/-F/--timeout/-V/--request-options configuration arguments !");
421 + /* we just set the toplevel timeout, but per-client
422 + * timeouts may still be at defaults.
424 + for (ip=interfaces; ip; ip = ip->next) {
425 + if (ip->client->config->timeout == 60)
426 + ip->client->config->timeout = timeout_arg;
430 + if ((dhclient_request_options != 0) && (top_level_config.requested_options != default_requested_options)) {
431 + for (ip=interfaces; ip; ip = ip->next) {
432 + if (ip->client->config->requested_options == default_requested_options)
433 + ip->client->config->requested_options = top_level_config.requested_options;
442 /* Parse the lease database. */
443 read_client_leases();
445 @@ -3067,7 +3323,8 @@ void make_discover (client, lease)
446 client -> packet.xid = random ();
447 client -> packet.secs = 0; /* filled in by send_discover. */
449 - if (can_receive_unicast_unconfigured (client -> interface))
450 + if ((!(bootp_broadcast_always || client->config->bootp_broadcast_always))
451 + && can_receive_unicast_unconfigured(client->interface))
452 client -> packet.flags = 0;
454 client -> packet.flags = htons (BOOTP_BROADCAST);
455 @@ -3152,7 +3409,9 @@ void make_request (client, lease)
457 memset (&client -> packet.ciaddr, 0,
458 sizeof client -> packet.ciaddr);
459 - if (can_receive_unicast_unconfigured (client -> interface))
460 + if ((!(bootp_broadcast_always ||
461 + client ->config->bootp_broadcast_always)) &&
462 + can_receive_unicast_unconfigured (client -> interface))
463 client -> packet.flags = 0;
465 client -> packet.flags = htons (BOOTP_BROADCAST);
466 @@ -3215,7 +3474,8 @@ void make_decline (client, lease)
467 client -> packet.hops = 0;
468 client -> packet.xid = client -> xid;
469 client -> packet.secs = 0; /* Filled in by send_request. */
470 - if (can_receive_unicast_unconfigured (client -> interface))
471 + if ((!(bootp_broadcast_always || client->config-> bootp_broadcast_always))
472 + && can_receive_unicast_unconfigured (client->interface))
473 client -> packet.flags = 0;
475 client -> packet.flags = htons (BOOTP_BROADCAST);
476 diff -up dhcp-4.3.4/common/conflex.c.options dhcp-4.3.4/common/conflex.c
477 --- dhcp-4.3.4/common/conflex.c.options 2016-04-29 11:59:50.448590077 +0200
478 +++ dhcp-4.3.4/common/conflex.c 2016-04-29 12:13:23.637342420 +0200
479 @@ -832,6 +832,8 @@ intern(char *atom, enum dhcp_token dfv)
480 if (!strcasecmp(atom+1, "ig-endian")) {
481 return TOKEN_BIG_ENDIAN;
483 + if (!strcasecmp (atom + 1, "ootp-broadcast-always"))
484 + return BOOTP_BROADCAST_ALWAYS;
487 if (!strcasecmp(atom + 1, "ase"))
488 diff -up dhcp-4.3.4/includes/dhcpd.h.options dhcp-4.3.4/includes/dhcpd.h
489 --- dhcp-4.3.4/includes/dhcpd.h.options 2016-04-29 11:59:50.448590077 +0200
490 +++ dhcp-4.3.4/includes/dhcpd.h 2016-04-29 12:14:05.361329401 +0200
491 @@ -1246,6 +1246,9 @@ struct client_config {
493 int lease_id_format; /* format for IDs in lease file,
494 TOKEN_OCTAL or TOKEN_HEX */
496 + int bootp_broadcast_always; /* If nonzero, always set the BOOTP_BROADCAST
497 + flag in requests */
500 /* Per-interface state used in the dhcp client... */
501 diff -up dhcp-4.3.4/includes/dhctoken.h.options dhcp-4.3.4/includes/dhctoken.h
502 --- dhcp-4.3.4/includes/dhctoken.h.options 2016-04-29 11:59:50.449590076 +0200
503 +++ dhcp-4.3.4/includes/dhctoken.h 2016-04-29 12:15:03.073300846 +0200
504 @@ -373,7 +373,8 @@ enum dhcp_token {
505 TOKEN_BIG_ENDIAN = 675,
506 LEASE_ID_FORMAT = 676,
510 + BOOTP_BROADCAST_ALWAYS = 679
513 #define is_identifier(x) ((x) >= FIRST_TOKEN && \