From: Roy Marples Date: Tue, 9 Oct 2012 13:20:50 +0000 (+0000) Subject: Move the default vendor string to a global variable. X-Git-Tag: v5.99.3~62 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=27805e96f6257a79e3f343c302e3c744262c0455;p=thirdparty%2Fdhcpcd.git Move the default vendor string to a global variable. When an interface starts, it assigns this by default instead of generating it each time. --- diff --git a/dhcpcd.c b/dhcpcd.c index bd1d9353..6933b9fa 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -33,6 +33,7 @@ const char copyright[] = "Copyright (c) 2006-2012 Roy Marples"; #include #include #include +#include #include #include @@ -82,6 +83,7 @@ const char copyright[] = "Copyright (c) 2006-2012 Roy Marples"; #define RELEASE_DELAY_S 0 #define RELEASE_DELAY_NS 10000000 +char vendor[VENDORCLASSID_MAX_LEN]; int pidfd = -1; struct interface *ifaces = NULL; int ifac = 0; @@ -1773,6 +1775,8 @@ main(int argc, char **argv) size_t len; pid_t pid; struct timespec ts; + struct utsname utn; + const char *platform; closefrom(3); openlog(PACKAGE, LOG_PERROR | LOG_PID, LOG_DAEMON); @@ -1789,6 +1793,16 @@ main(int argc, char **argv) } } + platform = hardware_platform(); + if (uname(&utn) == 0) + snprintf(vendor, VENDORCLASSID_MAX_LEN, + "%s-%s:%s-%s:%s%s%s", PACKAGE, VERSION, + utn.sysname, utn.release, utn.machine, + platform ? ":" : "", platform ? platform : ""); + else + snprintf(vendor, VENDORCLASSID_MAX_LEN, + "%s-%s", PACKAGE, VERSION); + i = 0; while ((opt = getopt_long(argc, argv, IF_OPTS, cf_options, &oi)) != -1) { diff --git a/dhcpcd.h b/dhcpcd.h index 008eb475..a04b7a81 100644 --- a/dhcpcd.h +++ b/dhcpcd.h @@ -119,6 +119,7 @@ struct interface { struct interface *next; }; +extern char vendor[VENDORCLASSID_MAX_LEN]; extern int pidfd; extern int ifac; extern char **ifav; diff --git a/if-options.c b/if-options.c index 36e99658..5b517979 100644 --- a/if-options.c +++ b/if-options.c @@ -26,7 +26,6 @@ */ #include -#include #include @@ -804,9 +803,8 @@ read_config(const char *file, { struct if_options *ifo; FILE *f; - char *line, *option, *p, *platform; + char *line, *option, *p; int skip = 0, have_profile = 0; - struct utsname utn; /* Seed our default options */ ifo = xzalloc(sizeof(*ifo)); @@ -824,16 +822,8 @@ read_config(const char *file, strcmp(ifo->hostname, "localhost") == 0) ifo->hostname[0] = '\0'; - platform = hardware_platform(); - if (uname(&utn) == 0) - ifo->vendorclassid[0] = snprintf((char *)ifo->vendorclassid + 1, - VENDORCLASSID_MAX_LEN, - "%s-%s:%s-%s:%s%s%s", PACKAGE, VERSION, - utn.sysname, utn.release, utn.machine, - platform ? ":" : "", platform ? platform : ""); - else - ifo->vendorclassid[0] = snprintf((char *)ifo->vendorclassid + 1, - VENDORCLASSID_MAX_LEN, "%s-%s", PACKAGE, VERSION); + ifo->vendorclassid[0] = strlen(vendor); + memcpy(ifo->vendorclassid + 1, vendor, ifo->vendorclassid[0]); /* Parse our options file */ f = fopen(file ? file : CONFIG, "r");