From: Roy Marples Date: Mon, 30 Jun 2008 16:27:15 +0000 (+0000) Subject: Allow clientid to be configured. X-Git-Tag: v4.0.2~257 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=413724d05e63d58a28a9a26d415d30e01c8b749d;p=thirdparty%2Fdhcpcd.git Allow clientid to be configured. --- diff --git a/client.c b/client.c index 756c9b81..d71561c3 100644 --- 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; } diff --git a/config.h b/config.h index 68846f51..39c0310d 100644 --- 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 @@ -58,6 +61,23 @@ # 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 @@ -75,16 +95,6 @@ */ // #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 diff --git a/dhcpcd.c b/dhcpcd.c index 40f4f5c0..76ab3dfc 100644 --- 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 diff --git a/dhcpcd.h b/dhcpcd.h index ea0769b8..5b72eae9 100644 --- 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