1 diff -up dhcp-4.0.0/common/conflex.c.options dhcp-4.0.0/common/conflex.c
2 --- dhcp-4.0.0/common/conflex.c.options 2007-12-29 11:13:51.000000000 -1000
3 +++ dhcp-4.0.0/common/conflex.c 2007-12-29 11:13:51.000000000 -1000
4 @@ -769,6 +769,8 @@ intern(char *atom, enum dhcp_token dfv)
6 if (!strcasecmp (atom + 1, "ound"))
8 + if (!strcasecmp (atom + 1, "ootp-broadcast-always"))
9 + return BOOTP_BROADCAST_ALWAYS;
12 if (!strcasecmp (atom + 1, "ase"))
13 diff -up dhcp-4.0.0/includes/dhcpd.h.options dhcp-4.0.0/includes/dhcpd.h
14 --- dhcp-4.0.0/includes/dhcpd.h.options 2007-12-29 11:13:51.000000000 -1000
15 +++ dhcp-4.0.0/includes/dhcpd.h 2007-12-29 11:13:51.000000000 -1000
16 @@ -1055,6 +1055,9 @@ struct client_config {
17 int do_forward_update; /* If nonzero, and if we have the
18 information we need, update the
19 A record for the address we get. */
21 + int bootp_broadcast_always; /* If nonzero, always set the BOOTP_BROADCAST
25 /* Per-interface state used in the dhcp client... */
26 diff -up dhcp-4.0.0/includes/dhctoken.h.options dhcp-4.0.0/includes/dhctoken.h
27 --- dhcp-4.0.0/includes/dhctoken.h.options 2007-10-31 09:13:33.000000000 -1000
28 +++ dhcp-4.0.0/includes/dhctoken.h 2007-12-29 11:13:51.000000000 -1000
29 @@ -345,7 +345,8 @@ enum dhcp_token {
35 + BOOTP_BROADCAST_ALWAYS = 652
38 #define is_identifier(x) ((x) >= FIRST_TOKEN && \
39 diff -up dhcp-4.0.0/client/dhclient.c.options dhcp-4.0.0/client/dhclient.c
40 --- dhcp-4.0.0/client/dhclient.c.options 2007-11-30 11:51:42.000000000 -1000
41 +++ dhcp-4.0.0/client/dhclient.c 2007-12-29 11:14:15.000000000 -1000
47 + * Defined in stdio.h when _GNU_SOURCE is set, but we don't want to define
48 + * that when building ISC code.
50 +extern int asprintf(char **strp, const char *fmt, ...);
52 TIME default_lease_time = 43200; /* 12 hours... */
53 TIME max_lease_time = 86400; /* 24 hours... */
55 @@ -75,6 +81,9 @@ int onetry=0;
58 char *mockup_relay = NULL;
59 +int bootp_broadcast_always = 0;
61 +extern u_int32_t default_requested_options[];
63 static void usage PROTO ((void));
65 @@ -100,6 +109,15 @@ main(int argc, char **argv) {
66 int no_dhclient_script = 0;
67 int local_family_set = 0;
69 + char *dhcp_client_identifier_arg = NULL;
70 + char *dhcp_host_name_arg = NULL;
71 + char *dhcp_fqdn_arg = NULL;
72 + char *dhcp_vendor_class_identifier_arg = NULL;
73 + char *dhclient_request_options = NULL;
75 + int timeout_arg = 0;
76 + char *arg_conf = NULL;
77 + int arg_conf_len = 0;
79 /* Initialize client globals. */
80 memset(&default_duid, 0, sizeof(default_duid));
81 @@ -224,6 +242,88 @@ main(int argc, char **argv) {
82 } else if (!strcmp (argv [i], "--version")) {
83 log_info ("isc-dhclient-%s", PACKAGE_VERSION);
85 + } else if (!strcmp (argv [i], "-I")) {
86 + if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
88 + return EXIT_FAILURE;
91 + if (strlen(argv[i]) >= DHCP_MAX_OPTION_LEN) {
92 + log_error("-I option dhcp-client-identifier string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_MAX_OPTION_LEN-1);
96 + dhcp_client_identifier_arg = argv[i];
97 + } else if (!strcmp (argv [i], "-B")) {
98 + bootp_broadcast_always = 1;
99 + } else if (!strcmp (argv [i], "-H")) {
100 + if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
102 + return EXIT_FAILURE;
105 + if (strlen(argv[i]) >= DHCP_MAX_OPTION_LEN) {
106 + log_error("-H option host-name string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_MAX_OPTION_LEN-1);
110 + if (dhcp_host_name_arg != NULL) {
111 + log_error("The -H <host-name> and -F <fqdn> arguments are mutually exclusive");
115 + dhcp_host_name_arg = argv[i];
116 + } else if (!strcmp (argv [i], "-F")) {
117 + if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
119 + return EXIT_FAILURE;
122 + if (strlen(argv[i]) >= DHCP_MAX_OPTION_LEN) {
123 + log_error("-F option fqdn.fqdn string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_MAX_OPTION_LEN-1);
127 + if (dhcp_fqdn_arg != NULL) {
128 + log_error("Only one -F <fqdn> argument can be specified");
132 + if (dhcp_host_name_arg != NULL) {
133 + log_error("The -F <fqdn> and -H <host-name> arguments are mutually exclusive");
137 + dhcp_fqdn_arg = argv[i];
138 + } else if (!strcmp (argv [i], "-T")) {
139 + if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
141 + return EXIT_FAILURE;
144 + if ((timeout_arg = atoi(argv[i])) <= 0) {
145 + log_error("-T timeout option must be > 0 - bad value: %s",argv[i]);
148 + } else if (!strcmp (argv [i], "-V")) {
149 + if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
151 + return EXIT_FAILURE;
154 + if (strlen(argv[i]) >= DHCP_MAX_OPTION_LEN) {
155 + log_error("-V option vendor-class-identifier string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_MAX_OPTION_LEN-1);
159 + dhcp_vendor_class_identifier_arg = argv[i];
160 + } else if (!strcmp (argv [i], "-R")) {
161 + if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
163 + return EXIT_FAILURE;
166 + dhclient_request_options=argv[i];
167 } else if (argv [i][0] == '-') {
170 @@ -370,6 +470,166 @@ main(int argc, char **argv) {
171 /* Parse the dhclient.conf file. */
174 + /* Parse any extra command line configuration arguments: */
175 + if ((dhcp_client_identifier_arg != NULL) && (*dhcp_client_identifier_arg != '\0')) {
176 + arg_conf_len = asprintf(&arg_conf, "send dhcp-client-identifier \"%s\";", dhcp_client_identifier_arg);
178 + if ((arg_conf == 0) || (arg_conf_len <= 0))
179 + log_fatal("Unable to send -I option dhcp-client-identifier");
182 + if ((dhcp_host_name_arg != NULL) && (*dhcp_host_name_arg != '\0')) {
183 + if (arg_conf == 0) {
184 + arg_conf_len = asprintf(&arg_conf, "send host-name \"%s\";", dhcp_host_name_arg);
186 + if ((arg_conf == 0) || (arg_conf_len <= 0))
187 + log_fatal("Unable to send -H option host-name");
189 + char *last_arg_conf = arg_conf;
191 + arg_conf_len = asprintf( &arg_conf, "%s\nsend host-name \"%s\";", last_arg_conf, dhcp_host_name_arg);
193 + if ((arg_conf == 0) || (arg_conf_len <= 0))
194 + log_fatal("Unable to send -H option host-name");
196 + free(last_arg_conf);
200 + if ((dhcp_fqdn_arg != NULL) && (*dhcp_fqdn_arg != '\0')) {
201 + if (arg_conf == 0) {
202 + arg_conf_len = asprintf(&arg_conf, "send fqdn.fqdn \"%s\";", dhcp_fqdn_arg);
204 + if ((arg_conf == 0) || (arg_conf_len <= 0))
205 + log_fatal("Unable to send -F option fqdn.fqdn");
207 + char *last_arg_conf = arg_conf;
209 + arg_conf_len = asprintf( &arg_conf, "%s\nsend fqdn.fqdn \"%s\";", last_arg_conf, dhcp_fqdn_arg);
211 + if ((arg_conf == 0) || (arg_conf_len <= 0))
212 + log_fatal("Unable to send -F option fqdn.fqdn");
214 + free(last_arg_conf);
219 + if (arg_conf == 0) {
220 + arg_conf_len = asprintf(&arg_conf, "timeout %d;", timeout_arg);
222 + if ((arg_conf == 0) || (arg_conf_len <= 0))
223 + log_fatal("Unable to process -T timeout argument");
225 + char *last_arg_conf = arg_conf;
227 + arg_conf_len = asprintf( &arg_conf, "%s\ntimeout %d;", last_arg_conf, timeout_arg);
229 + if ((arg_conf == 0) || (arg_conf_len == 0))
230 + log_fatal("Unable to process -T timeout argument");
232 + free(last_arg_conf);
236 + if ((dhcp_vendor_class_identifier_arg != NULL) && (*dhcp_vendor_class_identifier_arg != '\0')) {
237 + if (arg_conf == 0) {
238 + arg_conf_len = asprintf(&arg_conf, "send vendor-class-identifier \"%s\";", dhcp_vendor_class_identifier_arg);
240 + if ((arg_conf == 0) || (arg_conf_len <= 0))
241 + log_fatal("Unable to send -V option vendor-class-identifier");
243 + char *last_arg_conf = arg_conf;
245 + arg_conf_len = asprintf(&arg_conf, "%s\nsend vendor-class-identifier \"%s\";", last_arg_conf, dhcp_vendor_class_identifier_arg);
247 + if ((arg_conf == 0) || (arg_conf_len <= 0))
248 + log_fatal("Unable to send -V option vendor-class-identifier");
250 + free(last_arg_conf);
254 + if (dhclient_request_options != NULL) {
255 + if (arg_conf == 0) {
256 + arg_conf_len = asprintf(&arg_conf, "request %s;", dhclient_request_options);
258 + if ((arg_conf == 0) || (arg_conf_len <= 0))
259 + log_fatal("Unable to parse -R <request options list> argument");
261 + char *last_arg_conf = arg_conf;
263 + arg_conf_len = asprintf(&arg_conf, "%s\nrequest %s;", last_arg_conf, dhclient_request_options);
265 + if ((arg_conf == 0) || (arg_conf_len <= 0))
266 + log_fatal("Unable to parse -R <request options list> argument");
268 + free(last_arg_conf);
273 + if (arg_conf_len == 0)
274 + if ((arg_conf_len = strlen(arg_conf)) == 0)
275 + /* huh ? cannot happen ! */
276 + log_fatal("Unable to process -I/-H/-F/-T/-V/-R configuration arguments");
278 + /* parse the extra dhclient.conf configuration arguments
279 + * into top level config: */
280 + struct parse *cfile = (struct parse *)0;
281 + const char *val = NULL;
284 + status = new_parse (&cfile, -1, arg_conf, arg_conf_len, "extra dhclient -I/-H/-F/-T/-V/-R configuration arguments", 0);
286 + if ((status != ISC_R_SUCCESS) || (cfile -> warnings_occurred))
287 + log_fatal("Cannot parse -I/-H/-F/-T/-V/-R configuration arguments !");
288 + /* more detailed parse failures will be logged */
291 + token = peek_token (&val, (unsigned *)0, cfile);
292 + if (token == END_OF_FILE)
295 + parse_client_statement (cfile, (struct interface_info *)0, &top_level_config);
298 + if (cfile -> warnings_occurred)
299 + log_fatal ("Cannot parse -I/-H/-F/-T/-V/-R configuration arguments !");
300 + end_parse (&cfile);
303 + /* we just set the toplevel timeout, but per-client
304 + * timeouts may still be at defaults. Also, it makes no
305 + * sense having the reboot_timeout or backoff_cutoff
306 + * greater than the timeout:
308 + if ((top_level_config.backoff_cutoff == 15) && (top_level_config.backoff_cutoff > (timeout_arg / 2)))
309 + top_level_config.backoff_cutoff = (((unsigned long)(timeout_arg / 2)) == 0) ? timeout_arg : (unsigned long)(timeout_arg / 2);
311 + for (ip = interfaces; ip; ip = ip -> next) {
312 + if (ip->client->config->timeout == 60)
313 + ip->client->config->timeout = timeout_arg;
315 + if ((ip->client->config->reboot_timeout == 10) && (ip->client->config->reboot_timeout > ip->client->config->timeout))
316 + ip->client->config->reboot_timeout = ip->client->config->timeout;
317 + if ((ip->client->config->backoff_cutoff == 15) && (ip->client->config->backoff_cutoff > top_level_config.backoff_cutoff))
318 + ip->client->config->backoff_cutoff = top_level_config.backoff_cutoff;
322 + if ((dhclient_request_options != 0) && (top_level_config.requested_options != default_requested_options)) {
323 + for (ip = interfaces; ip; ip = ip -> next) {
324 + if (ip->client->config->requested_options == default_requested_options)
325 + ip->client->config->requested_options = top_level_config.requested_options;
334 /* Parse the lease database. */
335 read_client_leases ();
337 @@ -2105,7 +2365,8 @@ void make_discover (client, lease)
338 client -> packet.xid = random ();
339 client -> packet.secs = 0; /* filled in by send_discover. */
341 - if (can_receive_unicast_unconfigured (client -> interface))
342 + if ((!(bootp_broadcast_always || client->config->bootp_broadcast_always))
343 + && can_receive_unicast_unconfigured(client->interface))
344 client -> packet.flags = 0;
346 client -> packet.flags = htons (BOOTP_BROADCAST);
347 @@ -2189,7 +2450,9 @@ void make_request (client, lease)
349 memset (&client -> packet.ciaddr, 0,
350 sizeof client -> packet.ciaddr);
351 - if (can_receive_unicast_unconfigured (client -> interface))
352 + if ((!(bootp_broadcast_always ||
353 + client ->config->bootp_broadcast_always)) &&
354 + can_receive_unicast_unconfigured (client -> interface))
355 client -> packet.flags = 0;
357 client -> packet.flags = htons (BOOTP_BROADCAST);
358 @@ -2248,7 +2511,8 @@ void make_decline (client, lease)
359 client -> packet.hops = 0;
360 client -> packet.xid = client -> xid;
361 client -> packet.secs = 0; /* Filled in by send_request. */
362 - if (can_receive_unicast_unconfigured (client -> interface))
363 + if ((!(bootp_broadcast_always || client->config-> bootp_broadcast_always))
364 + && can_receive_unicast_unconfigured (client->interface))
365 client -> packet.flags = 0;
367 client -> packet.flags = htons (BOOTP_BROADCAST);
368 diff -up dhcp-4.0.0/client/clparse.c.options dhcp-4.0.0/client/clparse.c
369 --- dhcp-4.0.0/client/clparse.c.options 2007-12-08 09:36:00.000000000 -1000
370 +++ dhcp-4.0.0/client/clparse.c 2007-12-29 11:13:51.000000000 -1000
371 @@ -132,6 +132,7 @@ isc_result_t read_client_conf ()
372 /* Requested lease time, used by DHCPv6 (DHCPv4 uses the option cache)
374 top_level_config.requested_lease = 7200;
375 + top_level_config.bootp_broadcast_always = 0;
377 group_allocate (&top_level_config.on_receipt, MDL);
378 if (!top_level_config.on_receipt)
379 @@ -295,7 +296,8 @@ void read_client_leases ()
380 interface-declaration |
381 LEASE client-lease-statement |
382 ALIAS client-lease-statement |
383 - KEY key-definition */
384 + KEY key-definition |
385 + BOOTP_BROADCAST_ALWAYS */
387 void parse_client_statement (cfile, ip, config)
389 @@ -685,6 +687,12 @@ void parse_client_statement (cfile, ip,
390 parse_reject_statement (cfile, config);
393 + case BOOTP_BROADCAST_ALWAYS:
394 + token = next_token(&val, (unsigned*)0, cfile);
395 + config -> bootp_broadcast_always = 1;
396 + parse_semi (cfile);
401 stmt = (struct executable_statement *)0;