401 lines
13 KiB
Diff
401 lines
13 KiB
Diff
|
--- dhcp-3.0.5/client/dhclient.c.options 2007-03-29 16:33:14.000000000 -0400
|
||
|
+++ dhcp-3.0.5/client/dhclient.c 2007-03-30 15:15:59.000000000 -0400
|
||
|
@@ -38,6 +38,12 @@
|
||
|
#include "dhcpd.h"
|
||
|
#include "version.h"
|
||
|
|
||
|
+/*
|
||
|
+ * Defined in stdio.h when _GNU_SOURCE is set, but we don't want to define
|
||
|
+ * that when building ISC code.
|
||
|
+ */
|
||
|
+extern int asprintf(char **strp, const char *fmt, ...);
|
||
|
+
|
||
|
TIME default_lease_time = 43200; /* 12 hours... */
|
||
|
TIME max_lease_time = 86400; /* 24 hours... */
|
||
|
|
||
|
@@ -77,6 +83,9 @@
|
||
|
#ifdef EXTENDED_NEW_OPTION_INFO
|
||
|
int extended_option_environment = 0;
|
||
|
#endif
|
||
|
+int bootp_broadcast_always = 0;
|
||
|
+
|
||
|
+extern u_int32_t default_requested_options[];
|
||
|
|
||
|
static void usage PROTO ((void));
|
||
|
|
||
|
@@ -103,6 +112,15 @@
|
||
|
int no_dhclient_pid = 0;
|
||
|
int no_dhclient_script = 0;
|
||
|
char *s;
|
||
|
+ char *dhcp_client_identifier_arg = NULL;
|
||
|
+ char *dhcp_host_name_arg = NULL;
|
||
|
+ char *dhcp_fqdn_arg = NULL;
|
||
|
+ char *dhcp_vendor_class_identifier_arg = NULL;
|
||
|
+ char *dhclient_request_options = NULL;
|
||
|
+
|
||
|
+ int timeout_arg = 0;
|
||
|
+ char *arg_conf = NULL;
|
||
|
+ int arg_conf_len = 0;
|
||
|
|
||
|
/* Make sure we have stdin, stdout and stderr. */
|
||
|
i = open ("/dev/null", O_RDWR);
|
||
|
@@ -211,6 +229,88 @@
|
||
|
extended_option_environment = 1;
|
||
|
new_option_info_tree = GENERATE_NEW_OPTION_INFO;
|
||
|
#endif
|
||
|
+ } else if (!strcmp (argv [i], "-I")) {
|
||
|
+ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
|
||
|
+ usage ();
|
||
|
+ return EXIT_FAILURE;
|
||
|
+ }
|
||
|
+
|
||
|
+ if (strlen(argv[i]) >= DHCP_OPTION_LEN) {
|
||
|
+ log_error("-I option dhcp-client-identifier string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_OPTION_LEN-1);
|
||
|
+ exit(1);
|
||
|
+ }
|
||
|
+
|
||
|
+ dhcp_client_identifier_arg = argv[i];
|
||
|
+ } else if (!strcmp (argv [i], "-B")) {
|
||
|
+ bootp_broadcast_always = 1;
|
||
|
+ } else if (!strcmp (argv [i], "-H")) {
|
||
|
+ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
|
||
|
+ usage ();
|
||
|
+ return EXIT_FAILURE;
|
||
|
+ }
|
||
|
+
|
||
|
+ if (strlen(argv[i]) >= DHCP_OPTION_LEN) {
|
||
|
+ log_error("-H option host-name string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_OPTION_LEN-1);
|
||
|
+ exit(1);
|
||
|
+ }
|
||
|
+
|
||
|
+ if (dhcp_host_name_arg != NULL) {
|
||
|
+ log_error("The -H <host-name> and -F <fqdn> arguments are mutually exclusive");
|
||
|
+ exit(1);
|
||
|
+ }
|
||
|
+
|
||
|
+ dhcp_host_name_arg = argv[i];
|
||
|
+ } else if (!strcmp (argv [i], "-F")) {
|
||
|
+ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
|
||
|
+ usage ();
|
||
|
+ return EXIT_FAILURE;
|
||
|
+ }
|
||
|
+
|
||
|
+ if (strlen(argv[i]) >= DHCP_OPTION_LEN) {
|
||
|
+ log_error("-F option fqdn.fqdn string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_OPTION_LEN-1);
|
||
|
+ exit(1);
|
||
|
+ }
|
||
|
+
|
||
|
+ if (dhcp_fqdn_arg != NULL) {
|
||
|
+ log_error("Only one -F <fqdn> argument can be specified");
|
||
|
+ exit(1);
|
||
|
+ }
|
||
|
+
|
||
|
+ if (dhcp_host_name_arg != NULL) {
|
||
|
+ log_error("The -F <fqdn> and -H <host-name> arguments are mutually exclusive");
|
||
|
+ exit(1);
|
||
|
+ }
|
||
|
+
|
||
|
+ dhcp_fqdn_arg = argv[i];
|
||
|
+ } else if (!strcmp (argv [i], "-T")) {
|
||
|
+ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
|
||
|
+ usage ();
|
||
|
+ return EXIT_FAILURE;
|
||
|
+ }
|
||
|
+
|
||
|
+ if ((timeout_arg = atoi(argv[i])) <= 0) {
|
||
|
+ log_error("-T timeout option must be > 0 - bad value: %s",argv[i]);
|
||
|
+ exit(1);
|
||
|
+ }
|
||
|
+ } else if (!strcmp (argv [i], "-V")) {
|
||
|
+ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
|
||
|
+ usage ();
|
||
|
+ return EXIT_FAILURE;
|
||
|
+ }
|
||
|
+
|
||
|
+ if (strlen(argv[i]) >= DHCP_OPTION_LEN) {
|
||
|
+ log_error("-V option vendor-class-identifier string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_OPTION_LEN-1);
|
||
|
+ exit(1);
|
||
|
+ }
|
||
|
+
|
||
|
+ dhcp_vendor_class_identifier_arg = argv[i];
|
||
|
+ } else if (!strcmp (argv [i], "-R")) {
|
||
|
+ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
|
||
|
+ usage ();
|
||
|
+ return EXIT_FAILURE;
|
||
|
+ }
|
||
|
+
|
||
|
+ dhclient_request_options=argv[i];
|
||
|
} else if (argv [i][0] == '-') {
|
||
|
usage ();
|
||
|
} else {
|
||
|
@@ -347,6 +447,170 @@
|
||
|
/* Parse the dhclient.conf file. */
|
||
|
read_client_conf ();
|
||
|
|
||
|
+ /* Parse any extra command line configuration arguments: */
|
||
|
+ if ((dhcp_client_identifier_arg != NULL) && (*dhcp_client_identifier_arg != '\0')) {
|
||
|
+ arg_conf_len = asprintf(&arg_conf, "send dhcp-client-identifier \"%s\";", dhcp_client_identifier_arg);
|
||
|
+
|
||
|
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
||
|
+ log_fatal("Unable to send -I option dhcp-client-identifier");
|
||
|
+ }
|
||
|
+
|
||
|
+ if ((dhcp_host_name_arg != NULL) && (*dhcp_host_name_arg != '\0')) {
|
||
|
+ if (arg_conf == 0) {
|
||
|
+ arg_conf_len = asprintf(&arg_conf, "send host-name \"%s\";", dhcp_host_name_arg);
|
||
|
+
|
||
|
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
||
|
+ log_fatal("Unable to send -H option host-name");
|
||
|
+ } else {
|
||
|
+ char *last_arg_conf = arg_conf;
|
||
|
+ arg_conf = NULL;
|
||
|
+ arg_conf_len = asprintf( &arg_conf, "%s\nsend host-name \"%s\";", last_arg_conf, dhcp_host_name_arg);
|
||
|
+
|
||
|
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
||
|
+ log_fatal("Unable to send -H option host-name");
|
||
|
+
|
||
|
+ free(last_arg_conf);
|
||
|
+ }
|
||
|
+ }
|
||
|
+
|
||
|
+ if ((dhcp_fqdn_arg != NULL) && (*dhcp_fqdn_arg != '\0')) {
|
||
|
+ if (arg_conf == 0) {
|
||
|
+ arg_conf_len = asprintf(&arg_conf, "send fqdn.fqdn \"%s\";", dhcp_fqdn_arg);
|
||
|
+
|
||
|
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
||
|
+ log_fatal("Unable to send -F option fqdn.fqdn");
|
||
|
+ } else {
|
||
|
+ char *last_arg_conf = arg_conf;
|
||
|
+ arg_conf = NULL;
|
||
|
+ arg_conf_len = asprintf( &arg_conf, "%s\nsend fqdn.fqdn \"%s\";", last_arg_conf, dhcp_fqdn_arg);
|
||
|
+
|
||
|
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
||
|
+ log_fatal("Unable to send -F option fqdn.fqdn");
|
||
|
+
|
||
|
+ free(last_arg_conf);
|
||
|
+ }
|
||
|
+ }
|
||
|
+
|
||
|
+ if (timeout_arg) {
|
||
|
+ if( arg_conf == 0 )
|
||
|
+ {
|
||
|
+ arg_conf_len = asprintf(&arg_conf, "timeout %d;", timeout_arg);
|
||
|
+
|
||
|
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
||
|
+ log_fatal("Unable to process -T timeout argument");
|
||
|
+ } else {
|
||
|
+ char *last_arg_conf = arg_conf;
|
||
|
+ arg_conf = NULL;
|
||
|
+ arg_conf_len = asprintf( &arg_conf, "%s\ntimeout %d;", last_arg_conf, timeout_arg);
|
||
|
+
|
||
|
+ if ((arg_conf == 0) || (arg_conf_len == 0))
|
||
|
+ log_fatal("Unable to process -T timeout argument");
|
||
|
+
|
||
|
+ free(last_arg_conf);
|
||
|
+ }
|
||
|
+ }
|
||
|
+
|
||
|
+ if ((dhcp_vendor_class_identifier_arg != NULL) && (*dhcp_vendor_class_identifier_arg != '\0')) {
|
||
|
+ if (arg_conf == 0) {
|
||
|
+ arg_conf_len = asprintf(&arg_conf, "send vendor-class-identifier \"%s\";", dhcp_vendor_class_identifier_arg);
|
||
|
+
|
||
|
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
||
|
+ log_fatal("Unable to send -V option vendor-class-identifier");
|
||
|
+ } else {
|
||
|
+ char *last_arg_conf = arg_conf;
|
||
|
+ arg_conf = NULL;
|
||
|
+ arg_conf_len = asprintf(&arg_conf, "%s\nsend vendor-class-identifier \"%s\";", last_arg_conf, dhcp_vendor_class_identifier_arg);
|
||
|
+
|
||
|
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
||
|
+ log_fatal("Unable to send -V option vendor-class-identifier");
|
||
|
+
|
||
|
+ free(last_arg_conf);
|
||
|
+ }
|
||
|
+ }
|
||
|
+
|
||
|
+ if (dhclient_request_options != NULL) {
|
||
|
+ if (arg_conf == 0) {
|
||
|
+ arg_conf_len = asprintf(&arg_conf, "request %s;", dhclient_request_options);
|
||
|
+
|
||
|
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
||
|
+ log_fatal("Unable to parse -R <request options list> argument");
|
||
|
+ } else {
|
||
|
+ char *last_arg_conf = arg_conf;
|
||
|
+ arg_conf = NULL;
|
||
|
+ arg_conf_len = asprintf(&arg_conf, "%s\nrequest %s;", last_arg_conf, dhclient_request_options);
|
||
|
+
|
||
|
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
||
|
+ log_fatal("Unable to parse -R <request options list> argument");
|
||
|
+
|
||
|
+ free(last_arg_conf);
|
||
|
+ }
|
||
|
+ }
|
||
|
+
|
||
|
+ if (arg_conf) {
|
||
|
+ if( arg_conf_len == 0 )
|
||
|
+ if( (arg_conf_len = strlen(arg_conf)) == 0 )
|
||
|
+ /* huh ? cannot happen ! */
|
||
|
+ log_fatal("Unable to process -I/-H/-F/-T/-V/-R configuration arguments");
|
||
|
+
|
||
|
+ /* parse the extra dhclient.conf configuration arguments
|
||
|
+ * into top level config: */
|
||
|
+ struct parse *cfile = (struct parse *)0;
|
||
|
+ const char *val = NULL;
|
||
|
+ int token;
|
||
|
+
|
||
|
+ status = new_parse (&cfile, -1, arg_conf, arg_conf_len, "extra dhclient -I/-H/-F/-T/-V/-R configuration arguments", 0);
|
||
|
+
|
||
|
+ if ((status != ISC_R_SUCCESS) || (cfile -> warnings_occurred))
|
||
|
+ log_fatal("Cannot parse -I/-H/-F/-T/-V/-R configuration arguments !");
|
||
|
+ /* more detailed parse failures will be logged */
|
||
|
+
|
||
|
+ do {
|
||
|
+ token = peek_token (&val, (unsigned *)0, cfile);
|
||
|
+ if (token == END_OF_FILE)
|
||
|
+ break;
|
||
|
+
|
||
|
+ parse_client_statement (cfile, (struct interface_info *)0, &top_level_config);
|
||
|
+
|
||
|
+
|
||
|
+ } while (1);
|
||
|
+
|
||
|
+ if (cfile -> warnings_occurred)
|
||
|
+ log_fatal ("Cannot parse -I/-H/-F/-T/-V/-R configuration arguments !");
|
||
|
+ end_parse (&cfile);
|
||
|
+
|
||
|
+ if (timeout_arg) {
|
||
|
+ /* we just set the toplevel timeout, but per-client
|
||
|
+ * timeouts may still be at defaults. Also, it makes no
|
||
|
+ * sense having the reboot_timeout or backoff_cutoff
|
||
|
+ * greater than the timeout:
|
||
|
+ */
|
||
|
+ if ((top_level_config.backoff_cutoff == 15) && (top_level_config.backoff_cutoff > (timeout_arg / 2)))
|
||
|
+ top_level_config.backoff_cutoff = (((unsigned long)(timeout_arg / 2)) == 0) ? timeout_arg : (unsigned long)(timeout_arg / 2);
|
||
|
+
|
||
|
+ for (ip = interfaces; ip; ip = ip -> next) {
|
||
|
+ if (ip->client->config->timeout == 60)
|
||
|
+ ip->client->config->timeout = timeout_arg;
|
||
|
+
|
||
|
+ if ((ip->client->config->reboot_timeout == 10) && (ip->client->config->reboot_timeout > ip->client->config->timeout))
|
||
|
+ ip->client->config->reboot_timeout = ip->client->config->timeout;
|
||
|
+
|
||
|
+ if ((ip->client->config->backoff_cutoff == 15) && (ip->client->config->backoff_cutoff > top_level_config.backoff_cutoff))
|
||
|
+ ip->client->config->backoff_cutoff = top_level_config.backoff_cutoff;
|
||
|
+ }
|
||
|
+ }
|
||
|
+
|
||
|
+ if ((dhclient_request_options != 0) && (top_level_config.requested_options != default_requested_options)) {
|
||
|
+ for (ip = interfaces; ip; ip = ip -> next) {
|
||
|
+ if (ip->client->config->requested_options == default_requested_options)
|
||
|
+ ip->client->config->requested_options = top_level_config.requested_options;
|
||
|
+ }
|
||
|
+ }
|
||
|
+
|
||
|
+ free(arg_conf);
|
||
|
+ arg_conf = NULL;
|
||
|
+ arg_conf_len = 0;
|
||
|
+ }
|
||
|
+
|
||
|
/* Parse the lease database. */
|
||
|
read_client_leases ();
|
||
|
|
||
|
@@ -1924,7 +2188,8 @@
|
||
|
client -> packet.xid = random ();
|
||
|
client -> packet.secs = 0; /* filled in by send_discover. */
|
||
|
|
||
|
- if (can_receive_unicast_unconfigured (client -> interface))
|
||
|
+ if ((!(bootp_broadcast_always || client->config->bootp_broadcast_always))
|
||
|
+ && can_receive_unicast_unconfigured(client->interface))
|
||
|
client -> packet.flags = 0;
|
||
|
else
|
||
|
client -> packet.flags = htons (BOOTP_BROADCAST);
|
||
|
@@ -2008,7 +2273,9 @@
|
||
|
} else {
|
||
|
memset (&client -> packet.ciaddr, 0,
|
||
|
sizeof client -> packet.ciaddr);
|
||
|
- if (can_receive_unicast_unconfigured (client -> interface))
|
||
|
+ if ((!(bootp_broadcast_always ||
|
||
|
+ client ->config->bootp_broadcast_always)) &&
|
||
|
+ can_receive_unicast_unconfigured (client -> interface))
|
||
|
client -> packet.flags = 0;
|
||
|
else
|
||
|
client -> packet.flags = htons (BOOTP_BROADCAST);
|
||
|
@@ -2067,7 +2334,8 @@
|
||
|
client -> packet.hops = 0;
|
||
|
client -> packet.xid = client -> xid;
|
||
|
client -> packet.secs = 0; /* Filled in by send_request. */
|
||
|
- if (can_receive_unicast_unconfigured (client -> interface))
|
||
|
+ if ((!(bootp_broadcast_always || client->config-> bootp_broadcast_always))
|
||
|
+ && can_receive_unicast_unconfigured (client->interface))
|
||
|
client -> packet.flags = 0;
|
||
|
else
|
||
|
client -> packet.flags = htons (BOOTP_BROADCAST);
|
||
|
--- dhcp-3.0.5/client/clparse.c.options 2007-03-29 16:33:14.000000000 -0400
|
||
|
+++ dhcp-3.0.5/client/clparse.c 2007-03-29 16:33:29.000000000 -0400
|
||
|
@@ -81,6 +81,7 @@
|
||
|
top_level_config.requested_options = default_requested_options;
|
||
|
top_level_config.omapi_port = -1;
|
||
|
top_level_config.do_forward_update = 1;
|
||
|
+ top_level_config.bootp_broadcast_always = 0;
|
||
|
|
||
|
group_allocate (&top_level_config.on_receipt, MDL);
|
||
|
if (!top_level_config.on_receipt)
|
||
|
@@ -227,7 +228,8 @@
|
||
|
interface-declaration |
|
||
|
LEASE client-lease-statement |
|
||
|
ALIAS client-lease-statement |
|
||
|
- KEY key-definition */
|
||
|
+ KEY key-definition |
|
||
|
+ BOOTP_BROADCAST_ALWAYS */
|
||
|
|
||
|
void parse_client_statement (cfile, ip, config)
|
||
|
struct parse *cfile;
|
||
|
@@ -549,6 +551,12 @@
|
||
|
parse_reject_statement (cfile, config);
|
||
|
return;
|
||
|
|
||
|
+ case BOOTP_BROADCAST_ALWAYS:
|
||
|
+ token = next_token(&val, (unsigned*)0, cfile);
|
||
|
+ config -> bootp_broadcast_always = 1;
|
||
|
+ parse_semi (cfile);
|
||
|
+ return;
|
||
|
+
|
||
|
default:
|
||
|
lose = 0;
|
||
|
stmt = (struct executable_statement *)0;
|
||
|
--- dhcp-3.0.5/common/conflex.c.options 2007-03-29 16:33:14.000000000 -0400
|
||
|
+++ dhcp-3.0.5/common/conflex.c 2007-03-29 16:33:29.000000000 -0400
|
||
|
@@ -599,6 +599,8 @@
|
||
|
return BALANCE;
|
||
|
if (!strcasecmp (atom + 1, "ound"))
|
||
|
return BOUND;
|
||
|
+ if (!strcasecmp (atom + 1, "ootp-broadcast-always"))
|
||
|
+ return BOOTP_BROADCAST_ALWAYS;
|
||
|
break;
|
||
|
case 'c':
|
||
|
if (!strcasecmp (atom + 1, "ase"))
|
||
|
--- dhcp-3.0.5/includes/dhcpd.h.options 2007-03-29 16:33:14.000000000 -0400
|
||
|
+++ dhcp-3.0.5/includes/dhcpd.h 2007-03-30 15:14:56.000000000 -0400
|
||
|
@@ -767,6 +767,9 @@
|
||
|
int do_forward_update; /* If nonzero, and if we have the
|
||
|
information we need, update the
|
||
|
A record for the address we get. */
|
||
|
+
|
||
|
+ int bootp_broadcast_always; /* If nonzero, always set the BOOTP_BROADCAST
|
||
|
+ flag in requests */
|
||
|
};
|
||
|
|
||
|
/* Per-interface state used in the dhcp client... */
|
||
|
--- dhcp-3.0.5/includes/dhctoken.h.options 2005-09-22 12:19:57.000000000 -0400
|
||
|
+++ dhcp-3.0.5/includes/dhctoken.h 2007-03-29 16:33:29.000000000 -0400
|
||
|
@@ -309,7 +309,8 @@
|
||
|
DOMAIN_NAME = 613,
|
||
|
DO_FORWARD_UPDATE = 614,
|
||
|
KNOWN_CLIENTS = 615,
|
||
|
- ATSFP = 616
|
||
|
+ ATSFP = 616,
|
||
|
+ BOOTP_BROADCAST_ALWAYS = 616
|
||
|
};
|
||
|
|
||
|
#define is_identifier(x) ((x) >= FIRST_TOKEN && \
|