1 diff -up dhcp-3.1.0/common/conflex.c.options dhcp-3.1.0/common/conflex.c
2 --- dhcp-3.1.0/common/conflex.c.options 2007-10-22 15:46:24.000000000 -0400
3 +++ dhcp-3.1.0/common/conflex.c 2007-10-22 15:48:07.000000000 -0400
4 @@ -599,6 +599,8 @@ static enum dhcp_token intern (atom, 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-3.1.0/includes/dhcpd.h.options dhcp-3.1.0/includes/dhcpd.h
14 --- dhcp-3.1.0/includes/dhcpd.h.options 2007-10-22 15:46:24.000000000 -0400
15 +++ dhcp-3.1.0/includes/dhcpd.h 2007-10-22 15:48:21.000000000 -0400
16 @@ -912,6 +912,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-3.1.0/includes/dhctoken.h.options dhcp-3.1.0/includes/dhctoken.h
27 --- dhcp-3.1.0/includes/dhctoken.h.options 2006-07-31 18:19:51.000000000 -0400
28 +++ dhcp-3.1.0/includes/dhctoken.h 2007-10-22 15:49:24.000000000 -0400
29 @@ -325,7 +325,8 @@ enum dhcp_token {
35 + BOOTP_BROADCAST_ALWAYS = 633
38 #define is_identifier(x) ((x) >= FIRST_TOKEN && \
39 diff -up dhcp-3.1.0/client/dhclient.c.options dhcp-3.1.0/client/dhclient.c
40 --- dhcp-3.1.0/client/dhclient.c.options 2007-05-22 16:37:04.000000000 -0400
41 +++ dhcp-3.1.0/client/dhclient.c 2007-10-22 15:47:51.000000000 -0400
42 @@ -38,6 +38,12 @@ static char ocopyright[] =
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 @@ -74,6 +80,9 @@ int client_env_count=0;
59 +int bootp_broadcast_always = 0;
61 +extern u_int32_t default_requested_options[];
62 #ifdef EXTENDED_NEW_OPTION_INFO
63 int extended_option_environment = 0;
65 @@ -101,6 +110,15 @@ int main (argc, argv, envp)
66 int no_dhclient_pid = 0;
67 int no_dhclient_script = 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 /* Make sure that file descriptors 0 (stdin), 1, (stdout), and
80 2 (stderr) are open. To do this, we assume that when we
81 @@ -211,6 +229,88 @@ int main (argc, argv, envp)
82 } else if (!strcmp (argv [i], "--version")) {
83 log_info ("isc-dhclient-%s", DHCP_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_OPTION_LEN) {
92 + log_error("-I option dhcp-client-identifier string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_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_OPTION_LEN) {
106 + log_error("-H option host-name string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_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_OPTION_LEN) {
123 + log_error("-F option fqdn.fqdn string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_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_OPTION_LEN) {
155 + log_error("-V option vendor-class-identifier string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_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 #ifdef EXTENDED_NEW_OPTION_INFO
168 } else if (!strcmp (argv [i], "-y")) {
169 extended_option_environment = 1;
170 @@ -347,6 +447,167 @@ int main (argc, argv, envp)
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;
318 + if ((ip->client->config->backoff_cutoff == 15) && (ip->client->config->backoff_cutoff > top_level_config.backoff_cutoff))
319 + ip->client->config->backoff_cutoff = top_level_config.backoff_cutoff;
323 + if ((dhclient_request_options != 0) && (top_level_config.requested_options != default_requested_options)) {
324 + for (ip = interfaces; ip; ip = ip -> next) {
325 + if (ip->client->config->requested_options == default_requested_options)
326 + ip->client->config->requested_options = top_level_config.requested_options;
335 /* Parse the lease database. */
336 read_client_leases ();
338 @@ -1978,7 +2239,8 @@ void make_discover (client, lease)
339 client -> packet.xid = random ();
340 client -> packet.secs = 0; /* filled in by send_discover. */
342 - if (can_receive_unicast_unconfigured (client -> interface))
343 + if ((!(bootp_broadcast_always || client->config->bootp_broadcast_always))
344 + && can_receive_unicast_unconfigured(client->interface))
345 client -> packet.flags = 0;
347 client -> packet.flags = htons (BOOTP_BROADCAST);
348 @@ -2065,7 +2327,9 @@ void make_request (client, lease)
350 memset (&client -> packet.ciaddr, 0,
351 sizeof client -> packet.ciaddr);
352 - if (can_receive_unicast_unconfigured (client -> interface))
353 + if ((!(bootp_broadcast_always ||
354 + client ->config->bootp_broadcast_always)) &&
355 + can_receive_unicast_unconfigured (client -> interface))
356 client -> packet.flags = 0;
358 client -> packet.flags = htons (BOOTP_BROADCAST);
359 @@ -2125,7 +2389,8 @@ void make_decline (client, lease)
360 client -> packet.hops = 0;
361 client -> packet.xid = client -> xid;
362 client -> packet.secs = 0; /* Filled in by send_request. */
363 - if (can_receive_unicast_unconfigured (client -> interface))
364 + if ((!(bootp_broadcast_always || client->config-> bootp_broadcast_always))
365 + && can_receive_unicast_unconfigured (client->interface))
366 client -> packet.flags = 0;
368 client -> packet.flags = htons (BOOTP_BROADCAST);
369 diff -up dhcp-3.1.0/client/clparse.c.options dhcp-3.1.0/client/clparse.c
370 --- dhcp-3.1.0/client/clparse.c.options 2007-02-14 17:41:22.000000000 -0500
371 +++ dhcp-3.1.0/client/clparse.c 2007-10-22 15:47:12.000000000 -0400
372 @@ -84,6 +84,7 @@ isc_result_t read_client_conf ()
373 top_level_config.requested_options = default_requested_options;
374 top_level_config.omapi_port = -1;
375 top_level_config.do_forward_update = 1;
376 + top_level_config.bootp_broadcast_always = 0;
378 group_allocate (&top_level_config.on_receipt, MDL);
379 if (!top_level_config.on_receipt)
380 @@ -230,7 +231,8 @@ void read_client_leases ()
381 interface-declaration |
382 LEASE client-lease-statement |
383 ALIAS client-lease-statement |
384 - KEY key-definition */
385 + KEY key-definition |
386 + BOOTP_BROADCAST_ALWAYS */
388 void parse_client_statement (cfile, ip, config)
390 @@ -554,6 +556,12 @@ void parse_client_statement (cfile, ip,
391 parse_reject_statement (cfile, config);
394 + case BOOTP_BROADCAST_ALWAYS:
395 + token = next_token(&val, (unsigned*)0, cfile);
396 + config -> bootp_broadcast_always = 1;
397 + parse_semi (cfile);
402 stmt = (struct executable_statement *)0;