]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Allow clientid to be configured.
authorRoy Marples <roy@marples.name>
Mon, 30 Jun 2008 16:27:15 +0000 (16:27 +0000)
committerRoy Marples <roy@marples.name>
Mon, 30 Jun 2008 16:27:15 +0000 (16:27 +0000)
client.c
config.h
dhcpcd.c
dhcpcd.h

index 756c9b812e9ff5c9732a758f6c0d9d386753928c..d71561c3166efe17b024b59831d3c1f190a2774a 100644 (file)
--- a/client.c
+++ b/client.c
@@ -465,7 +465,9 @@ client_setup(struct if_state *state, const struct options *options)
        struct interface *iface = state->interface;
        struct dhcp_lease *lease = &state->lease;
        struct in_addr addr;
+#ifdef ENABLE_CLIENTID
        size_t len = 0;
+#endif
 #ifdef ENABLE_DUID
        unsigned char *duid = NULL;
        uint32_t ul;
@@ -522,6 +524,7 @@ client_setup(struct if_state *state, const struct options *options)
                iface->net.s_addr = lease->net.s_addr;
        }
 
+#ifdef ENABLE_CLIENTID
        if (*options->clientid) {
                /* Attempt to see if the ClientID is a hardware address */
                if ((len = hwaddr_aton(NULL, options->clientid))) {
@@ -575,6 +578,7 @@ client_setup(struct if_state *state, const struct options *options)
                        memcpy(iface->clientid + 2, iface->hwaddr, iface->hwlen);
                }
        }
+#endif
 
        return 0;
 }
index 68846f513b85bc8f70b5da94a687e31dbdd741c6..39c0310d2e6df12c7f7db59988dd2a0ae80e3c5b 100644 (file)
--- a/config.h
+++ b/config.h
@@ -39,6 +39,9 @@
 # ifndef DISABLE_ARP
 #  define DISABLE_ARP
 # endif
+# ifndef DISABLE_CLIENTID
+#  define DISABLE_CLIENTID
+# endif
 # ifndef DISABLE_IPV4LL
 #  define DISABLE_IPV4LL
 # endif
 # define ENABLE_ARP
 #endif
 
+/* Send a ClientID in all messages. */
+#ifndef DISABLE_CLIENTID
+# define ENABLE_CLIENTID
+#endif
+
+/* Allow dhcpcd to create a DUID (LLT) and use it to make an IAID for the
+ * ClientID. Even enabled here, we need a config directive to actually use it
+ * so this toggle is just to remove it from dhcpcd to make the binary smaller.
+ * You can always create your own DUID file that just contains the
+ * hex string that represents the DUID.
+ * See RFC 3315 for details on this. */
+#ifndef DISABLE_DUID
+# ifdef ENABLE_CLIENTID
+#  define ENABLE_DUID
+# endif
+#endif
+
 /* IPV4LL, aka ZeroConf, aka APIPA, aka RFC 3927.
  * Needs ARP. */
 #ifndef DISABLE_IPV4LL
  */
 // #define ENABLE_IPV4LL_ALWAYSROUTE 
 
-/* Allow dhcpcd to create a DUID (LLT) and use it to make an IAID for the
- * ClientID. Even enabled here, we need a config directive to actually use it
- * so this toggle is just to remove it from dhcpcd to make the binary smaller.
- * You can always create your own DUID file that just contains the
- * hex string that represents the DUID.
- * See RFC 3315 for details on this. */
-#ifndef DISABLE_DUID
-# define ENABLE_DUID
-#endif
-
 /* Allow dhcpcd to send user class options. */
 #ifndef DISABLE_USERCLASS
 # define ENABLE_USERCLASS
index 40f4f5c0c76733bccf415d16bf96007010668451..76ab3dfcbef780efa103cb13e73ab75a355071c5 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -435,6 +435,7 @@ parse_option(int opt, char *oarg, struct options *options)
                options->options &= ~DHCPCD_GATEWAY;
                break;
        case 'I':
+#ifdef ENABLE_CLIENTID
                if (oarg) {
                        if (olen >= CLIENTID_MAX_LEN) {
                                logger(LOG_ERR, "`%s' is too long for"
@@ -455,6 +456,7 @@ parse_option(int opt, char *oarg, struct options *options)
                        options->options &= ~DHCPCD_DUID;
                        options->options &= ~DHCPCD_CLIENTID;
                }
+#endif
                break;
        case 'K':
                options->options &= ~DHCPCD_DAEMONISE;
@@ -521,14 +523,16 @@ main(int argc, char **argv)
        options->classid[0] = snprintf((char *)options->classid + 1, CLASSID_MAX_LEN,
                                       "%s %s", PACKAGE, VERSION);
 
-       options->options |= DHCPCD_GATEWAY | DHCPCD_DAEMONISE | DHCPCD_CLIENTID;
+       options->options |= DHCPCD_GATEWAY | DHCPCD_DAEMONISE;
 #ifdef ENABLE_ARP
        options->options |= DHCPCD_ARP;
  #ifdef ENABLE_IPV4LL
        options->options |= DHCPCD_IPV4LL;
  #endif
 #endif
-
+#ifdef ENABLE_CLIENTID
+       options->options |= DHCPCD_CLIENTID;
+#endif
        options->timeout = DEFAULT_TIMEOUT;
 
 #ifdef CMDLINE_COMPAT
@@ -592,12 +596,18 @@ main(int argc, char **argv)
 #ifdef ENABLE_ARP
                       " ARP"
 #endif
+#ifdef ENABLE_CLIENTID
+                      " CLIENTID"
+#endif
 #ifdef ENABLE_DUID
                       " DUID"
 #endif
 #ifdef ENABLE_IPV4LL
                       " IPV4LL"
 #endif
+#ifdef ENABLE_USERCLASS
+                      " USERCLASS"
+#endif
 #ifdef ENABLE_VENDOR
                       " VENDOR"
 #endif
index ea0769b82caadccba55bf221df3bb4e4246e2814..5b72eae999bdb4a241729a05d4459c9e6847a033 100644 (file)
--- a/dhcpcd.h
+++ b/dhcpcd.h
@@ -74,7 +74,9 @@ struct options {
        char hostname[MAXHOSTNAMELEN];
        int fqdn;
        uint8_t classid[CLASSID_MAX_LEN + 1];
+#ifdef ENABLE_CLIENTID
        char clientid[CLIENTID_MAX_LEN + 1];
+#endif
 #ifdef ENABLE_USERCLASS
        uint8_t userclass[USERCLASS_MAX_LEN + 1];
 #endif