Marius Tomaschewski
1a182da2e9
OBS-URL: https://build.opensuse.org/package/show/network:dhcp/dhcp?expand=0&rev=42
105 lines
3.2 KiB
Diff
105 lines
3.2 KiB
Diff
diff --git a/client/dhclient.8 b/client/dhclient.8
|
|
index b805528..d31fa8d 100644
|
|
--- a/client/dhclient.8
|
|
+++ b/client/dhclient.8
|
|
@@ -60,6 +60,9 @@ dhclient - Dynamic Host Configuration Protocol Client
|
|
.I port
|
|
]
|
|
[
|
|
+.B -H hostname
|
|
+]
|
|
+[
|
|
.B -d
|
|
]
|
|
[
|
|
@@ -227,6 +230,11 @@ If a different port is specified for the client to listen on and
|
|
transmit on, the client will also use a different destination port -
|
|
one less than the specified port.
|
|
.PP
|
|
+The
|
|
+.B -H
|
|
+flag may be used to specify a client hostname that should be sent to
|
|
+the DHCP server. Note, that this option is a SUSE/Novell extension.
|
|
+.PP
|
|
The DHCP client normally transmits any protocol messages it sends
|
|
before acquiring an IP address to, 255.255.255.255, the IP limited
|
|
broadcast address. For debugging purposes, it may be useful to have
|
|
diff --git a/client/dhclient.c b/client/dhclient.c
|
|
index 15c31a5..65e9c23 100644
|
|
--- a/client/dhclient.c
|
|
+++ b/client/dhclient.c
|
|
@@ -108,6 +108,7 @@ main(int argc, char **argv) {
|
|
int no_dhclient_db = 0;
|
|
int no_dhclient_pid = 0;
|
|
int no_dhclient_script = 0;
|
|
+ char *dhclient_hostname = NULL;
|
|
#ifdef DHCPv6
|
|
int local_family_set = 0;
|
|
#endif /* DHCPv6 */
|
|
@@ -212,6 +213,16 @@ main(int argc, char **argv) {
|
|
if (++i == argc)
|
|
usage();
|
|
mockup_relay = argv[i];
|
|
+ } else if (!strcmp (argv[i], "-H")) {
|
|
+ if (++i == argc || !argv[i] || *(argv[i]) == '\0')
|
|
+ usage ();
|
|
+ if (strlen (argv[i]) > HOST_NAME_MAX) {
|
|
+ log_error("-H option host-name string \"%s\" is too long:"
|
|
+ "maximum length is %d characters",
|
|
+ argv[i], HOST_NAME_MAX);
|
|
+ exit(1);
|
|
+ }
|
|
+ dhclient_hostname = argv [i];
|
|
} else if (!strcmp(argv[i], "-nw")) {
|
|
nowait = 1;
|
|
} else if (!strcmp(argv[i], "-n")) {
|
|
@@ -445,6 +456,32 @@ main(int argc, char **argv) {
|
|
/* Parse the dhclient.conf file. */
|
|
read_client_conf();
|
|
|
|
+ /* If the user specified a hostname, send it here and now */
|
|
+ if ((dhclient_hostname != NULL) && (*dhclient_hostname != '\0') ) {
|
|
+ struct parse *cfile = NULL;
|
|
+ char buf[HOST_NAME_MAX + 40];
|
|
+ int len;
|
|
+
|
|
+ snprintf (buf, sizeof(buf), "send host-name \"%s\";", dhclient_hostname);
|
|
+ len = strlen(buf);
|
|
+
|
|
+ status = new_parse (&cfile, -1, buf, len, "host-name option", 0);
|
|
+ if (status != ISC_R_SUCCESS)
|
|
+ log_fatal ("Cannot parse send host-name statement!");
|
|
+
|
|
+ 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. */
|
|
read_client_leases();
|
|
|
|
@@ -674,12 +711,12 @@ static void usage()
|
|
|
|
log_error("Usage: dhclient %s %s",
|
|
#ifdef DHCPv6
|
|
- "[-4|-6] [-SNTP1dvrx] [-nw] [-p <port>] [-D LL|LLT]",
|
|
+ "[-4|-6] [-SNTP1dvrx] [-nw] [-H <hostname>] [-p <port>] [-D LL|LLT]",
|
|
#else /* DHCPv6 */
|
|
- "[-1dvrx] [-nw] [-p <port>]",
|
|
+ "[-1dvrx] [-nw] [-H <hostname>] [-p <port>]",
|
|
#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]");
|
|
}
|