af708b
diff --git a/client/clparse.c b/client/clparse.c
af708b
index 03190c3..2033427 100644
af708b
--- a/client/clparse.c
af708b
+++ b/client/clparse.c
8173a6
@@ -189,6 +189,7 @@ isc_result_t read_client_conf ()
e83fb1
 	/* Requested lease time, used by DHCPv6 (DHCPv4 uses the option cache)
e83fb1
 	 */
e83fb1
 	top_level_config.requested_lease = 7200;
e83fb1
+	top_level_config.bootp_broadcast_always = 0;
e83fb1
 
e83fb1
 	group_allocate (&top_level_config.on_receipt, MDL);
e83fb1
 	if (!top_level_config.on_receipt)
8173a6
@@ -394,7 +395,8 @@ void read_client_leases ()
e83fb1
 	interface-declaration |
e83fb1
 	LEASE client-lease-statement |
e83fb1
 	ALIAS client-lease-statement |
e83fb1
-	KEY key-definition */
e83fb1
+	KEY key-definition |
e83fb1
+	BOOTP_BROADCAST_ALWAYS */
e83fb1
 
e83fb1
 void parse_client_statement (cfile, ip, config)
e83fb1
 	struct parse *cfile;
af708b
@@ -817,6 +819,12 @@ void parse_client_statement (cfile, ip, config)
8173a6
 		parse_lease_id_format(cfile);
8173a6
 		break;
e83fb1
 
e83fb1
+	      case BOOTP_BROADCAST_ALWAYS:
e83fb1
+		token = next_token(&val, (unsigned*)0, cfile);
e83fb1
+		config -> bootp_broadcast_always = 1;
e83fb1
+		parse_semi (cfile);
e83fb1
+		return;
e83fb1
+
8173a6
 
e83fb1
 	      default:
e83fb1
 		lose = 0;
af708b
diff --git a/client/dhclient.8 b/client/dhclient.8
af708b
index 24f8f12..aa2238d 100644
af708b
--- a/client/dhclient.8
af708b
+++ b/client/dhclient.8
af708b
@@ -134,6 +134,33 @@ dhclient - Dynamic Host Configuration Protocol Client
d8c679
 .B -w
d8c679
 ]
d8c679
 [
d8c679
+.B -B
d8c679
+]
d8c679
+[
2ade8d
+.B -C
d8c679
+.I dhcp-client-identifier
d8c679
+]
d8c679
+[
d8c679
+.B -H
d8c679
+.I host-name
d8c679
+]
d8c679
+[
d8c679
+.B -F
d8c679
+.I fqdn.fqdn
d8c679
+]
d8c679
+[
d8c679
+.B -V
d8c679
+.I vendor-class-identifier
d8c679
+]
d8c679
+[
a11c0d
+.B --request-options
d8c679
+.I request-option-list
d8c679
+]
d8c679
+[
e98359
+.B --timeout
d8c679
+.I timeout
d8c679
+]
d8c679
+[
af708b
 .B --dad-wait-time
af708b
 .I seconds
d8c679
 ]
af708b
diff --git a/client/dhclient.c b/client/dhclient.c
af708b
index dcf3f1a..270a960 100644
af708b
--- a/client/dhclient.c
af708b
+++ b/client/dhclient.c
8173a6
@@ -40,6 +40,12 @@
8173a6
 #include <isc file.h="">
5a3797
 #include <dns result.h="">
203b45
 
203b45
+/*
203b45
+ * Defined in stdio.h when _GNU_SOURCE is set, but we don't want to define
203b45
+ * that when building ISC code.
203b45
+ */
203b45
+extern int asprintf(char **strp, const char *fmt, ...);
203b45
+
203b45
 TIME default_lease_time = 43200; /* 12 hours... */
203b45
 TIME max_lease_time = 86400; /* 24 hours... */
203b45
 
af708b
@@ -101,6 +107,10 @@ char *mockup_relay = NULL;
8173a6
 
8173a6
 char *progname = NULL;
8173a6
 
203b45
+int bootp_broadcast_always = 0;
203b45
+
943825
+extern struct option *default_requested_options[];
8173a6
+
8173a6
 void run_stateless(int exit_mode, u_int16_t port);
8173a6
 
8173a6
 static isc_result_t write_duid(struct data_string *duid);
af708b
@@ -179,7 +189,11 @@ usage(const char *sfmt, const char *sarg)
8173a6
 		  "                [-s server-addr] [-cf config-file]\n"
8173a6
 		  "                [-df duid-file] [-lf lease-file]\n"
8173a6
 		  "                [-pf pid-file] [--no-pid] [-e VAR=val]\n"
8173a6
-		  "                [-sf script-file] [interface]*",
8173a6
+		  "                [-sf script-file] [interface]*\n"
8173a6
+		  "                [-C <dhcp-client-identifier>] [-B]\n"
e98359
+		  "                [-H <host-name> | -F <fqdn.fqdn>] [--timeout <timeout>]\n"
8173a6
+		  "                [-V <vendor-class-identifier>]\n"
a11c0d
+		  "                [--request-options <request option="" list="">]",
8173a6
 		  isc_file_basename(progname));
8173a6
 }
203b45
 
af708b
@@ -216,6 +230,16 @@ main(int argc, char **argv) {
8173a6
 	progname = argv[0];
8173a6
 #endif
203b45
 
203b45
+	char *dhcp_client_identifier_arg = NULL;
203b45
+	char *dhcp_host_name_arg = NULL;
203b45
+	char *dhcp_fqdn_arg = NULL;
203b45
+	char *dhcp_vendor_class_identifier_arg = NULL;
203b45
+	char *dhclient_request_options = NULL;
203b45
+
203b45
+	int timeout_arg = 0;
203b45
+	char *arg_conf = NULL;
203b45
+	int arg_conf_len = 0;
8173a6
+
82186f
 	/* Initialize client globals. */
82186f
 	memset(&default_duid, 0, sizeof(default_duid));
8173a6
 
af708b
@@ -442,6 +466,88 @@ main(int argc, char **argv) {
7b69e5
 					 strlen(PACKAGE_VERSION)));
7b69e5
 			IGNORE_RET(write(STDERR_FILENO, "\n", 1));
4bf24c
 			exit(0);
2ade8d
+		} else if (!strcmp(argv[i], "-C")) {
203b45
+			if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
8173a6
+				usage(use_noarg, argv[i-1]);
4bf24c
+				exit(1);
203b45
+			}
203b45
+
82186f
+			if (strlen(argv[i]) >= DHCP_MAX_OPTION_LEN) {
2ade8d
+				log_error("-C option dhcp-client-identifier string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_MAX_OPTION_LEN-1);
203b45
+				exit(1);
203b45
+			}
203b45
+
203b45
+			dhcp_client_identifier_arg = argv[i];
4bf24c
+		} else if (!strcmp(argv[i], "-B")) {
203b45
+			bootp_broadcast_always = 1;
4bf24c
+		} else if (!strcmp(argv[i], "-H")) {
203b45
+			if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
8173a6
+				usage(use_noarg, argv[i-1]);
4bf24c
+				exit(1);
203b45
+			}
203b45
+
82186f
+			if (strlen(argv[i]) >= DHCP_MAX_OPTION_LEN) {
4bf24c
+				log_error("-H option host-name string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_MAX_OPTION_LEN-1);
203b45
+				exit(1);
203b45
+			}
203b45
+
203b45
+			if (dhcp_host_name_arg != NULL) {
203b45
+				log_error("The -H <host-name> and -F <fqdn> arguments are mutually exclusive");
203b45
+				exit(1);
203b45
+			}
203b45
+
203b45
+			dhcp_host_name_arg = argv[i];
4bf24c
+		} else if (!strcmp(argv[i], "-F")) {
203b45
+			if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
8173a6
+				usage(use_noarg, argv[i-1]);
4bf24c
+				exit(1);
203b45
+			}
203b45
+
82186f
+			if (strlen(argv[i]) >= DHCP_MAX_OPTION_LEN) {
4bf24c
+				log_error("-F option fqdn.fqdn string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_MAX_OPTION_LEN-1);
203b45
+				exit(1);
203b45
+			}
203b45
+
203b45
+			if (dhcp_fqdn_arg != NULL) {
203b45
+				log_error("Only one -F <fqdn> argument can be specified");
203b45
+				exit(1);
203b45
+			}
203b45
+
203b45
+			if (dhcp_host_name_arg != NULL) {
203b45
+				log_error("The -F <fqdn> and -H <host-name> arguments are mutually exclusive");
203b45
+				exit(1);
203b45
+			}
203b45
+
203b45
+			dhcp_fqdn_arg = argv[i];
e98359
+		} else if (!strcmp(argv[i], "--timeout")) {
203b45
+			if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
8173a6
+				usage(use_noarg, argv[i-1]);
4bf24c
+				exit(1);
203b45
+			}
203b45
+
203b45
+			if ((timeout_arg = atoi(argv[i])) <= 0) {
663dce
+				log_error("timeout option must be > 0 - bad value: %s",argv[i]);
203b45
+				exit(1);
203b45
+			}
4bf24c
+		} else if (!strcmp(argv[i], "-V")) {
203b45
+			if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
8173a6
+				usage(use_noarg, argv[i-1]);
4bf24c
+				exit(1);
203b45
+			}
203b45
+
82186f
+			if (strlen(argv[i]) >= DHCP_MAX_OPTION_LEN) {
4bf24c
+				log_error("-V option vendor-class-identifier string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_MAX_OPTION_LEN-1);
203b45
+				exit(1);
203b45
+			}
203b45
+
203b45
+			dhcp_vendor_class_identifier_arg = argv[i];
a11c0d
+		} else if (!strcmp(argv[i], "--request-options")) {
203b45
+			if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
8173a6
+				usage(use_noarg, argv[i-1]);
4bf24c
+				exit(1);
203b45
+			}
203b45
+
4bf24c
+			dhclient_request_options = argv[i];
4bf24c
 		} else if (argv[i][0] == '-') {
8173a6
 			usage("Unknown command: %s", argv[i]);
4bf24c
 		} else if (interfaces_requested < 0) {
af708b
@@ -641,6 +747,156 @@ main(int argc, char **argv) {
203b45
 	/* Parse the dhclient.conf file. */
4bf24c
 	read_client_conf();
203b45
 
203b45
+	/* Parse any extra command line configuration arguments: */
203b45
+	if ((dhcp_client_identifier_arg != NULL) && (*dhcp_client_identifier_arg != '\0')) {
203b45
+		arg_conf_len = asprintf(&arg_conf, "send dhcp-client-identifier \"%s\";", dhcp_client_identifier_arg);
203b45
+
203b45
+		if ((arg_conf == 0) || (arg_conf_len <= 0))
2ade8d
+			log_fatal("Unable to send -C option dhcp-client-identifier");
203b45
+	}
203b45
+
203b45
+	if ((dhcp_host_name_arg != NULL) && (*dhcp_host_name_arg != '\0')) {
203b45
+		if (arg_conf == 0) {
203b45
+			arg_conf_len = asprintf(&arg_conf, "send host-name \"%s\";", dhcp_host_name_arg);
203b45
+
203b45
+			if ((arg_conf == 0) || (arg_conf_len <= 0))
203b45
+				log_fatal("Unable to send -H option host-name");
203b45
+		} else {
203b45
+			char *last_arg_conf = arg_conf;
203b45
+			arg_conf = NULL;
4bf24c
+			arg_conf_len = asprintf(&arg_conf, "%s\nsend host-name \"%s\";", last_arg_conf, dhcp_host_name_arg);
203b45
+
203b45
+			if ((arg_conf == 0) || (arg_conf_len <= 0))
203b45
+				log_fatal("Unable to send -H option host-name");
203b45
+
203b45
+			free(last_arg_conf);
203b45
+		}
203b45
+	}
203b45
+
203b45
+	if ((dhcp_fqdn_arg != NULL) && (*dhcp_fqdn_arg != '\0')) {
203b45
+		if (arg_conf == 0) {
203b45
+			arg_conf_len = asprintf(&arg_conf,  "send fqdn.fqdn \"%s\";", dhcp_fqdn_arg);
203b45
+
203b45
+			if ((arg_conf == 0) || (arg_conf_len <= 0))
203b45
+				log_fatal("Unable to send -F option fqdn.fqdn");
203b45
+		} else {
203b45
+			char *last_arg_conf = arg_conf;
203b45
+			arg_conf = NULL;
4bf24c
+			arg_conf_len = asprintf(&arg_conf, "%s\nsend fqdn.fqdn \"%s\";", last_arg_conf, dhcp_fqdn_arg);
203b45
+
203b45
+			if ((arg_conf == 0)  || (arg_conf_len <= 0))
203b45
+				log_fatal("Unable to send -F option fqdn.fqdn");
203b45
+
203b45
+			free(last_arg_conf);
203b45
+		}
203b45
+	}
203b45
+
203b45
+	if (timeout_arg) {
203b45
+		if (arg_conf == 0) {
203b45
+			arg_conf_len = asprintf(&arg_conf,  "timeout %d;", timeout_arg);
203b45
+
203b45
+			if ((arg_conf == 0) || (arg_conf_len <= 0))
e98359
+				log_fatal("Unable to process --timeout timeout argument");
203b45
+		} else {
203b45
+			char *last_arg_conf = arg_conf;
203b45
+			arg_conf = NULL;
4bf24c
+			arg_conf_len = asprintf(&arg_conf, "%s\ntimeout %d;", last_arg_conf, timeout_arg);
203b45
+
203b45
+			if ((arg_conf == 0) || (arg_conf_len == 0))
e98359
+				log_fatal("Unable to process --timeout timeout argument");
203b45
+
203b45
+			free(last_arg_conf);
203b45
+		}
203b45
+	}
203b45
+
203b45
+	if ((dhcp_vendor_class_identifier_arg != NULL) && (*dhcp_vendor_class_identifier_arg != '\0')) {
203b45
+		if (arg_conf == 0) {
203b45
+			arg_conf_len = asprintf(&arg_conf,  "send vendor-class-identifier \"%s\";", dhcp_vendor_class_identifier_arg);
203b45
+
203b45
+			if ((arg_conf == 0) || (arg_conf_len <= 0))
203b45
+				log_fatal("Unable to send -V option vendor-class-identifier");
203b45
+		} else {
203b45
+			char *last_arg_conf = arg_conf;
203b45
+			arg_conf = NULL;
203b45
+			arg_conf_len = asprintf(&arg_conf, "%s\nsend vendor-class-identifier \"%s\";", last_arg_conf, dhcp_vendor_class_identifier_arg);
203b45
+
203b45
+			if ((arg_conf == 0) || (arg_conf_len <= 0))
203b45
+				log_fatal("Unable to send -V option vendor-class-identifier");
203b45
+
203b45
+			free(last_arg_conf);
203b45
+		}
203b45
+	}
203b45
+
203b45
+	if (dhclient_request_options != NULL) {
203b45
+		if (arg_conf == 0) {
203b45
+			arg_conf_len = asprintf(&arg_conf,  "request %s;", dhclient_request_options);
203b45
+
203b45
+			if ((arg_conf == 0) || (arg_conf_len <= 0))
a11c0d
+				log_fatal("Unable to parse --request-options <request options="" list=""> argument");
203b45
+		} else {
203b45
+			char *last_arg_conf = arg_conf;
203b45
+			arg_conf = NULL;
203b45
+			arg_conf_len = asprintf(&arg_conf, "%s\nrequest %s;", last_arg_conf, dhclient_request_options);
203b45
+
203b45
+			if ((arg_conf == 0)  || (arg_conf_len <= 0))
a11c0d
+				log_fatal("Unable to parse --request-options <request options="" list=""> argument");
203b45
+
203b45
+			free(last_arg_conf);
203b45
+		}
203b45
+	}
203b45
+
203b45
+	if (arg_conf) {
203b45
+		if (arg_conf_len == 0)
203b45
+			if ((arg_conf_len = strlen(arg_conf)) == 0)
203b45
+				/* huh ? cannot happen ! */
e98359
+				log_fatal("Unable to process -C/-H/-F/--timeout/-V/--request-options configuration arguments");
203b45
+
203b45
+		/* parse the extra dhclient.conf configuration arguments
203b45
+		 * into top level config: */
203b45
+		struct parse *cfile = (struct parse *)0;
203b45
+		const char *val = NULL;
203b45
+		int token;
203b45
+
e98359
+		status = new_parse(&cfile, -1, arg_conf, arg_conf_len, "extra dhclient -C/-H/-F/--timeout/-V/--request-options configuration arguments", 0);
203b45
+
203b45
+		if ((status != ISC_R_SUCCESS) || (cfile -> warnings_occurred))
e98359
+			log_fatal("Cannot parse -C/-H/-F/--timeout/-V/--request-options configuration arguments !");
203b45
+		/* more detailed parse failures will be logged */
203b45
+
203b45
+		do {
4bf24c
+			token = peek_token(&val, (unsigned *)0, cfile);
203b45
+			if (token == END_OF_FILE)
203b45
+				break;
203b45
+
4bf24c
+			parse_client_statement(cfile, (struct interface_info *)0, &top_level_config);
203b45
+		} while (1);
203b45
+
203b45
+		if (cfile -> warnings_occurred)
e98359
+			log_fatal("Cannot parse -C/-H/-F/--timeout/-V/--request-options configuration arguments !");
4bf24c
+		end_parse(&cfile);
203b45
+
203b45
+		if (timeout_arg) {
203b45
+			/* we just set the toplevel timeout, but per-client
663dce
+			 * timeouts may still be at defaults.
203b45
+			 */
4bf24c
+			for (ip=interfaces; ip; ip = ip->next) {
203b45
+				if (ip->client->config->timeout == 60)
203b45
+					ip->client->config->timeout = timeout_arg;
203b45
+			}
203b45
+		}
203b45
+
203b45
+		if ((dhclient_request_options != 0) && (top_level_config.requested_options != default_requested_options)) {
4bf24c
+			for (ip=interfaces; ip; ip = ip->next) {
203b45
+				if (ip->client->config->requested_options == default_requested_options)
203b45
+					ip->client->config->requested_options = top_level_config.requested_options;
203b45
+			}
203b45
+		}
203b45
+
203b45
+		free(arg_conf);
203b45
+		arg_conf = NULL;
203b45
+		arg_conf_len = 0;
203b45
+	}
203b45
+
203b45
 	/* Parse the lease database. */
4bf24c
 	read_client_leases();
203b45
 
af708b
@@ -3092,7 +3348,8 @@ void make_discover (client, lease)
203b45
 	client -> packet.xid = random ();
203b45
 	client -> packet.secs = 0; /* filled in by send_discover. */
203b45
 
203b45
-	if (can_receive_unicast_unconfigured (client -> interface))
203b45
+	if ((!(bootp_broadcast_always || client->config->bootp_broadcast_always))
203b45
+	    && can_receive_unicast_unconfigured(client->interface))
203b45
 		client -> packet.flags = 0;
203b45
 	else
203b45
 		client -> packet.flags = htons (BOOTP_BROADCAST);
af708b
@@ -3177,7 +3434,9 @@ void make_request (client, lease)
203b45
 	} else {
203b45
 		memset (&client -> packet.ciaddr, 0,
203b45
 			sizeof client -> packet.ciaddr);
203b45
-		if (can_receive_unicast_unconfigured (client -> interface))
203b45
+		if ((!(bootp_broadcast_always ||
203b45
+		    client ->config->bootp_broadcast_always)) &&
203b45
+		    can_receive_unicast_unconfigured (client -> interface))
203b45
 			client -> packet.flags = 0;
203b45
 		else
203b45
 			client -> packet.flags = htons (BOOTP_BROADCAST);
af708b
@@ -3240,7 +3499,8 @@ void make_decline (client, lease)
203b45
 	client -> packet.hops = 0;
203b45
 	client -> packet.xid = client -> xid;
203b45
 	client -> packet.secs = 0; /* Filled in by send_request. */
203b45
-	if (can_receive_unicast_unconfigured (client -> interface))
203b45
+	if ((!(bootp_broadcast_always || client->config-> bootp_broadcast_always))
203b45
+	    && can_receive_unicast_unconfigured (client->interface))
203b45
 		client -> packet.flags = 0;
203b45
 	else
203b45
 		client -> packet.flags = htons (BOOTP_BROADCAST);
af708b
diff --git a/common/conflex.c b/common/conflex.c
af708b
index fe994ac..bdb4a52 100644
af708b
--- a/common/conflex.c
af708b
+++ b/common/conflex.c
af708b
@@ -832,6 +832,8 @@ intern(char *atom, enum dhcp_token dfv) {
8173a6
 		if (!strcasecmp(atom+1, "ig-endian")) {
8173a6
 			return TOKEN_BIG_ENDIAN;
8173a6
 		}
4bf24c
+		if (!strcasecmp (atom + 1, "ootp-broadcast-always"))
4bf24c
+			return BOOTP_BROADCAST_ALWAYS;
4bf24c
 		break;
4bf24c
 	      case 'c':
9538db
 		if (!strcasecmp(atom + 1, "ase"))
af708b
diff --git a/includes/dhcpd.h b/includes/dhcpd.h
af708b
index eab09a6..cfdac23 100644
af708b
--- a/includes/dhcpd.h
af708b
+++ b/includes/dhcpd.h
af708b
@@ -1251,6 +1251,9 @@ struct client_config {
8173a6
 
8173a6
 	int lease_id_format;		/* format for IDs in lease file,
8173a6
 					   TOKEN_OCTAL or TOKEN_HEX */
4bf24c
+
4bf24c
+	int bootp_broadcast_always;	/* If nonzero, always set the BOOTP_BROADCAST
4bf24c
+					   flag in requests */
4bf24c
 };
203b45
 
4bf24c
 /* Per-interface state used in the dhcp client... */
af708b
diff --git a/includes/dhctoken.h b/includes/dhctoken.h
af708b
index 15bbd1c..b312e7a 100644
af708b
--- a/includes/dhctoken.h
af708b
+++ b/includes/dhctoken.h
8173a6
@@ -373,7 +373,8 @@ enum dhcp_token {
8173a6
 	TOKEN_BIG_ENDIAN = 675,
8173a6
 	LEASE_ID_FORMAT = 676,
8173a6
 	TOKEN_HEX = 677,
8173a6
-	TOKEN_OCTAL = 678
8173a6
+	TOKEN_OCTAL = 678,
8173a6
+	BOOTP_BROADCAST_ALWAYS = 679
4bf24c
 };
203b45
 
5a3797
 #define is_identifier(x)	((x) >= FIRST_TOKEN &&	\