2010-05-14 00:27:05 +02:00
|
|
|
diff --git a/client/dhclient.8 b/client/dhclient.8
|
2011-03-30 17:58:00 +02:00
|
|
|
index 7a3c154..e284210 100644
|
2010-05-14 00:27:05 +02:00
|
|
|
--- a/client/dhclient.8
|
|
|
|
+++ b/client/dhclient.8
|
2011-03-30 17:58:00 +02:00
|
|
|
@@ -64,6 +64,10 @@ dhclient - Dynamic Host Configuration Protocol Client
|
2007-01-10 17:39:58 +01:00
|
|
|
.I port
|
|
|
|
]
|
|
|
|
[
|
2011-03-30 17:58:00 +02:00
|
|
|
+.B -H
|
|
|
|
+.I hostname
|
2007-01-10 17:39:58 +01:00
|
|
|
+]
|
|
|
|
+[
|
|
|
|
.B -d
|
|
|
|
]
|
|
|
|
[
|
2011-03-30 17:58:00 +02:00
|
|
|
@@ -305,6 +309,10 @@ If a different port is specified on which the client should listen and
|
|
|
|
transmit, the client will also use a different destination port -
|
2008-09-13 00:24:42 +02:00
|
|
|
one less than the specified port.
|
2011-03-30 17:58:00 +02:00
|
|
|
.TP
|
|
|
|
+.BI \-H \ hostname
|
|
|
|
+This flag may be used to specify a client hostname that should be sent to
|
2010-05-14 00:27:05 +02:00
|
|
|
+the DHCP server. Note, that this option is a SUSE/Novell extension.
|
2011-03-30 17:58:00 +02:00
|
|
|
+.TP
|
|
|
|
.BI \-s \ server
|
|
|
|
Specify the server IP address or fully qualified domain name to use as
|
|
|
|
a destination for DHCP protocol messages before
|
2010-05-14 00:27:05 +02:00
|
|
|
diff --git a/client/dhclient.c b/client/dhclient.c
|
2011-03-30 17:58:00 +02:00
|
|
|
index dc19e8b..bd02cc9 100644
|
2010-05-14 00:27:05 +02:00
|
|
|
--- a/client/dhclient.c
|
|
|
|
+++ b/client/dhclient.c
|
2011-03-30 17:58:00 +02:00
|
|
|
@@ -110,6 +110,7 @@ main(int argc, char **argv) {
|
2007-01-10 17:39:58 +01:00
|
|
|
int no_dhclient_db = 0;
|
|
|
|
int no_dhclient_pid = 0;
|
|
|
|
int no_dhclient_script = 0;
|
|
|
|
+ char *dhclient_hostname = NULL;
|
2010-05-14 00:27:05 +02:00
|
|
|
#ifdef DHCPv6
|
|
|
|
int local_family_set = 0;
|
|
|
|
#endif /* DHCPv6 */
|
2011-03-30 17:58:00 +02:00
|
|
|
@@ -220,6 +221,16 @@ main(int argc, char **argv) {
|
2007-01-10 17:39:58 +01:00
|
|
|
if (++i == argc)
|
2010-05-14 00:27:05 +02:00
|
|
|
usage();
|
|
|
|
mockup_relay = argv[i];
|
|
|
|
+ } else if (!strcmp (argv[i], "-H")) {
|
2007-01-10 17:39:58 +01:00
|
|
|
+ if (++i == argc || !argv[i] || *(argv[i]) == '\0')
|
|
|
|
+ usage ();
|
2008-08-23 00:17:43 +02:00
|
|
|
+ if (strlen (argv[i]) > HOST_NAME_MAX) {
|
2007-01-10 17:39:58 +01:00
|
|
|
+ log_error("-H option host-name string \"%s\" is too long:"
|
2010-05-14 00:27:05 +02:00
|
|
|
+ "maximum length is %d characters",
|
|
|
|
+ argv[i], HOST_NAME_MAX);
|
2007-01-10 17:39:58 +01:00
|
|
|
+ exit(1);
|
|
|
|
+ }
|
|
|
|
+ dhclient_hostname = argv [i];
|
2010-05-14 00:27:05 +02:00
|
|
|
} else if (!strcmp(argv[i], "-nw")) {
|
2007-01-10 17:39:58 +01:00
|
|
|
nowait = 1;
|
2010-05-14 00:27:05 +02:00
|
|
|
} else if (!strcmp(argv[i], "-n")) {
|
2011-03-30 17:58:00 +02:00
|
|
|
@@ -468,6 +479,32 @@ main(int argc, char **argv) {
|
2007-01-10 17:39:58 +01:00
|
|
|
/* Parse the dhclient.conf file. */
|
2010-05-14 00:27:05 +02:00
|
|
|
read_client_conf();
|
2007-01-10 17:39:58 +01:00
|
|
|
|
|
|
|
+ /* If the user specified a hostname, send it here and now */
|
2008-09-13 00:24:42 +02:00
|
|
|
+ if ((dhclient_hostname != NULL) && (*dhclient_hostname != '\0') ) {
|
2007-01-10 17:39:58 +01:00
|
|
|
+ struct parse *cfile = NULL;
|
2008-08-23 00:17:43 +02:00
|
|
|
+ char buf[HOST_NAME_MAX + 40];
|
2007-01-10 17:39:58 +01:00
|
|
|
+ int len;
|
|
|
|
+
|
2008-09-13 00:24:42 +02:00
|
|
|
+ snprintf (buf, sizeof(buf), "send host-name \"%s\";", dhclient_hostname);
|
|
|
|
+ len = strlen(buf);
|
2007-01-10 17:39:58 +01:00
|
|
|
+
|
|
|
|
+ status = new_parse (&cfile, -1, buf, len, "host-name option", 0);
|
|
|
|
+ if (status != ISC_R_SUCCESS)
|
2008-08-23 00:17:43 +02:00
|
|
|
+ log_fatal ("Cannot parse send host-name statement!");
|
2007-01-10 17:39:58 +01:00
|
|
|
+
|
|
|
|
+ for (;;) {
|
|
|
|
+ const char *val = NULL;
|
|
|
|
+ int token;
|
|
|
|
+
|
|
|
|
+ token = peek_token (&val, (unsigned *)0, cfile);
|
|
|
|
+ if (token == END_OF_FILE)
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ parse_client_statement (cfile, NULL, &top_level_config);
|
|
|
|
+ }
|
|
|
|
+ end_parse (&cfile);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
/* Parse the lease database. */
|
2010-05-14 00:27:05 +02:00
|
|
|
read_client_leases();
|
2007-01-10 17:39:58 +01:00
|
|
|
|
2011-03-30 17:58:00 +02:00
|
|
|
@@ -676,12 +713,12 @@ static void usage()
|
2007-01-10 17:39:58 +01:00
|
|
|
|
2010-05-14 00:27:05 +02:00
|
|
|
log_error("Usage: dhclient %s %s",
|
|
|
|
#ifdef DHCPv6
|
2010-11-26 15:57:47 +01:00
|
|
|
- "[-4|-6] [-SNTP1dvrx] [-nw] [-p <port>] [-D LL|LLT]",
|
|
|
|
+ "[-4|-6] [-SNTP1dvrx] [-nw] [-H <hostname>] [-p <port>] [-D LL|LLT]",
|
2010-05-14 00:27:05 +02:00
|
|
|
#else /* DHCPv6 */
|
2010-11-26 15:57:47 +01:00
|
|
|
- "[-1dvrx] [-nw] [-p <port>]",
|
|
|
|
+ "[-1dvrx] [-nw] [-H <hostname>] [-p <port>]",
|
2010-05-14 00:27:05 +02:00
|
|
|
#endif /* DHCPv6 */
|
|
|
|
"[-s server]");
|
|
|
|
- log_error(" [-cf config-file] [-lf lease-file]%s",
|
|
|
|
+ log_error(" [-cf config-file] [-lf lease-file] %s",
|
|
|
|
"[-pf pid-file] [-e VAR=val]");
|
|
|
|
log_fatal(" [-sf script-file] [interface]");
|
2008-09-13 00:24:42 +02:00
|
|
|
}
|