]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
pull up rt19436: client -D option
authorPaul Selkirk <pselkirk@isc.org>
Wed, 27 May 2009 20:11:38 +0000 (20:11 +0000)
committerPaul Selkirk <pselkirk@isc.org>
Wed, 27 May 2009 20:11:38 +0000 (20:11 +0000)
RELNOTES
client/dhc6.c
client/dhclient.8
client/dhclient.c
includes/dhcpd.h

index 466a5dbf8c03ba7132dddefea12f9cf411a50041..6a67baa0a8d9832d379ab44b8823347b6c0bef1b 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -49,6 +49,8 @@ work on other platforms. Please report any problems and suggested fixes to
 - Added client support for setting interface MTU and metric, thanks to
   Roy "UberLord" Marples <roy@marples.name>.
 
+- Added client -D option to specify DUID type to send.
+
                        Changes since 4.1.0 (bug fixes)
 
 - Remove infinite loop in token_print_indent_concat().
index b9f79af78abbe2a43c9516f35665dd7b6580c15f..dc48c4654986f243a74e775298af210952b2079f 100644 (file)
@@ -143,15 +143,18 @@ form_duid(struct data_string *duid, const char *file, int line)
            (ip->hw_address.hlen > sizeof(ip->hw_address.hbuf)))
                log_fatal("Impossible hardware address length at %s:%d.", MDL);
 
+       if (duid_type == 0)
+               duid_type = stateless ? DUID_LL : DUID_LLT;
+
        /*
         * 2 bytes for the 'duid type' field.
         * 2 bytes for the 'htype' field.
-        * (not stateless) 4 bytes for the 'current time'.
+        * (DUID_LLT) 4 bytes for the 'current time'.
         * enough bytes for the hardware address (note that hw_address has
         * the 'htype' on byte zero).
         */
        len = 4 + (ip->hw_address.hlen - 1);
-       if (!stateless)
+       if (duid_type == DUID_LLT)
                len += 4;
        if (!buffer_allocate(&duid->buffer, len, MDL))
                log_fatal("no memory for default DUID!");
@@ -159,7 +162,7 @@ form_duid(struct data_string *duid, const char *file, int line)
        duid->len = len;
 
        /* Basic Link Local Address type of DUID. */
-       if (!stateless) {
+       if (duid_type == DUID_LLT) {
                putUShort(duid->buffer->data, DUID_LLT);
                putUShort(duid->buffer->data + 2, ip->hw_address.hbuf[0]);
                putULong(duid->buffer->data + 4, cur_time - DUID_TIME_EPOCH);
index 4437b9b4cd66b071afd45f4fece8f4d7628b5af1..cdd6c9ba92e2a598335d9564cf1f7bb41fa585e3 100644 (file)
@@ -1,4 +1,4 @@
-.\"    $Id: dhclient.8,v 1.30 2008/11/20 14:55:14 jreed Exp $
+.\"    $Id: dhclient.8,v 1.31 2009/05/27 20:11:38 pselkirk Exp $
 .\"
 .\" Copyright (c) 2004,2007-2008 by Internet Systems Consortium, Inc. ("ISC")
 .\" Copyright (c) 1996-2003 by Internet Software Consortium
@@ -56,6 +56,10 @@ dhclient - Dynamic Host Configuration Protocol Client
 ]
 ]
 [
+.B -D
+.I LL|LLT
+]
+[
 .B -p
 .I port
 ]
@@ -138,10 +142,14 @@ important details about the network to which it is attached, such as
 the location of a default router, the location of a name server, and
 so on.
 .PP
-If given the -4 command line argument (default), dhclient will use the
+If given the 
+.B -4
+command line argument (default), dhclient will use the
 DHCPv4 protocol to obtain an IPv4 address and configuration parameters.
 .PP
-If given the -6 command line argument, dhclient will use the DHCPv6
+If given the
+.B -6
+command line argument, dhclient will use the DHCPv6
 protocol to obtain whatever IPv6 addresses are available along with
 configuration parameters. But with
 .B -S
@@ -161,7 +169,17 @@ address query,
 restores it. Note it is not recommended to mix queries of different types
 together, or even to share the lease file between them.
 .PP
-If given the --version command line argument, dhclient will print its
+By default, DHCPv6 dhclient creates an identifier based on the
+link-layer address (DUID-LL) if it is running in stateless mode (with
+-S, not requesting an address), or it creates an identifier based on
+the link-layer address plus a timestamp (DUID-LLT) if it is running in
+stateful mode (without -S, requesting an address).
+.B -D
+overrides this default, with a value of either "LL" or "LLT".
+.PP
+If given the 
+.B --version
+command line argument, dhclient will print its
 version number and exit.
 .PP
 On startup, dhclient reads the
index dcd294a8ce6d167e1d1cbf0b33bad4e76687fb8a..580c71268521ec0791c2d0fb84640ee09b715e63 100644 (file)
@@ -57,6 +57,7 @@ struct in_addr inaddr_any;
 struct sockaddr_in sockaddr_broadcast;
 struct in_addr giaddr;
 struct data_string default_duid;
+int duid_type = 0;
 
 /* ASSERT_STATE() does nothing now; it used to be
    assert (state_is == state_shouldbe). */
@@ -268,6 +269,21 @@ main(int argc, char **argv) {
                                wanted_ia_na = 0;
                        }
                        wanted_ia_pd++;
+               } else if (!strcmp(argv[i], "-D")) {
+                       if (local_family_set && (local_family == AF_INET)) {
+                               usage();
+                       }
+                       local_family_set = 1;
+                       local_family = AF_INET6;
+                       if (++i == argc)
+                               usage();
+                       if (!strcasecmp(argv[i], "LL")) {
+                               duid_type = DUID_LL;
+                       } else if (!strcasecmp(argv[i], "LLT")) {
+                               duid_type = DUID_LLT;
+                       } else {
+                               usage();
+                       }
 #endif /* DHCPv6 */
                } else if (!strcmp(argv[i], "-v")) {
                        quiet = 0;
@@ -651,7 +667,7 @@ static void usage()
 
        log_error("Usage: dhclient %s %s",
 #ifdef DHCPv6
-                 "[-4|-6] [-SNTP1dvrx] [-nw] [-p <port>]",
+                 "[-4|-6] [-SNTP1dvrx] [-nw] [-p <port>] [-D LL|LLT]",
 #else /* DHCPv6 */
                  "[-1dvrx] [-nw] [-p <port>]",
 #endif /* DHCPv6 */
index 22db8aeaf2aa6486d266c0a15ab35d9616813a73..b0c4969d6ea2ef2d159e872d39987aacdf6cb6a3 100644 (file)
@@ -2471,6 +2471,7 @@ extern const char *path_dhclient_pid;
 extern char *path_dhclient_script;
 extern int interfaces_requested;
 extern struct data_string default_duid;
+extern int duid_type;
 
 extern struct client_config top_level_config;