Allow ClassID to be configured.

This commit is contained in:
Roy Marples 2008-06-30 16:35:41 +00:00
parent 413724d05e
commit d65fd32df0
4 changed files with 19 additions and 0 deletions

View File

@ -39,6 +39,9 @@
# ifndef DISABLE_ARP
# define DISABLE_ARP
# endif
# ifndef DISABLE_CLASSID
# define DISABLE_CLASSID
# endif
# ifndef DISABLE_CLIENTID
# define DISABLE_CLIENTID
# endif
@ -61,6 +64,11 @@
# define ENABLE_ARP
#endif
/* Allow dhcpcd to send a ClassID */
#ifndef DISABLE_CLASSID
# define ENABLE_CLASSID
#endif
/* Send a ClientID in all messages. */
#ifndef DISABLE_CLIENTID
# define ENABLE_CLIENTID

2
dhcp.c
View File

@ -790,11 +790,13 @@ make_message(struct dhcp_message **message,
}
#endif
#ifdef ENABLE_CLASSID
if (options->classid[0]) {
*p++ = DHCP_CLASSID;
memcpy(p, options->classid, options->classid[0] + 1);
p += options->classid[0] + 1;
}
#endif
}
if (type == DHCP_DISCOVER || type == DHCP_REQUEST) {

View File

@ -238,6 +238,7 @@ parse_option(int opt, char *oarg, struct options *options)
sizeof(options->hostname));
break;
case 'i':
#ifdef ENABLE_CLASSID
if (!oarg) {
*options->classid = '\0';
} else if (olen >= CLASSID_MAX_LEN) {
@ -250,6 +251,7 @@ parse_option(int opt, char *oarg, struct options *options)
strlcpy((char *)options->classid + 1, oarg,
sizeof(options->classid));
}
#endif
break;
case 'l':
if (*oarg == '-') {
@ -520,8 +522,10 @@ main(int argc, char **argv)
options = xzalloc(sizeof(*options));
strlcpy(options->script, SCRIPT, sizeof(options->script));
#ifdef ENABLE_CLASSID
options->classid[0] = snprintf((char *)options->classid + 1, CLASSID_MAX_LEN,
"%s %s", PACKAGE, VERSION);
#endif
options->options |= DHCPCD_GATEWAY | DHCPCD_DAEMONISE;
#ifdef ENABLE_ARP
@ -596,6 +600,9 @@ main(int argc, char **argv)
#ifdef ENABLE_ARP
" ARP"
#endif
#ifdef ENABLE_CLASSID
" CLASSID"
#endif
#ifdef ENABLE_CLIENTID
" CLIENTID"
#endif

View File

@ -73,7 +73,9 @@ struct options {
char interface[IF_NAMESIZE];
char hostname[MAXHOSTNAMELEN];
int fqdn;
#ifdef ENABLE_CLASSID
uint8_t classid[CLASSID_MAX_LEN + 1];
#endif
#ifdef ENABLE_CLIENTID
char clientid[CLIENTID_MAX_LEN + 1];
#endif