* SUCH DAMAGE.
*/
+#include <sys/utsname.h>
+
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include "common.h"
#include "dhcp-common.h"
#include "dhcp.h"
+#include "platform.h"
/* DHCP Enterprise options, RFC3925 */
struct dhcp_opt *vivso = NULL;
return NULL;
}
+size_t
+dhcp_vendor(char *str, size_t strlen)
+{
+ struct utsname utn;
+ char *p;
+
+ if (uname(&utn) != 0)
+ return snprintf(str, strlen, "%s-%s", PACKAGE, VERSION);
+ p = str;
+ p += snprintf(str, strlen,
+ "%s-%s:%s-%s:%s", PACKAGE, VERSION,
+ utn.sysname, utn.release, utn.machine);
+ p += hardware_platform(p, strlen - (p - str));
+ return p - str;
+}
+
int
make_option_mask(const struct dhcp_opt *dopts, size_t dopts_len,
uint8_t *mask, const char *opts, int add)
struct dhcp_opt *vivso_find(uint16_t, const void *);
+size_t dhcp_vendor(char *, size_t);
+
#define add_option_mask(var, val) (var[val >> 3] |= 1 << (val & 7))
#define del_option_mask(var, val) (var[val >> 3] &= ~(1 << (val & 7)))
#define has_option_mask(var, val) (var[val >>3] & (1 << (val & 7)))
uint32_t u32;
size_t vlen, i;
const struct vivco *vivco;
+ char vendor[VENDORCLASSID_MAX_LEN];
ifo = ifp->options;
len = sizeof(uint32_t); /* IANA PEN */
len += sizeof(uint16_t) + vivco->len;
vlen = 0; /* silence bogus gcc warning */
} else {
- vlen = strlen(vendor);
+ vlen = dhcp_vendor(vendor, sizeof(vendor));
len += sizeof(uint16_t) + vlen;
}
#include <sys/time.h>
#include <sys/types.h>
#include <sys/uio.h>
-#include <sys/utsname.h>
#include <ctype.h>
#include <errno.h>
#include "script.h"
struct if_head *ifaces = NULL;
-char vendor[VENDORCLASSID_MAX_LEN];
struct if_options *if_options = NULL;
int ifac = 0;
char **ifav = NULL;
int
main(int argc, char **argv)
{
- char *pidfile, *p;
+ char *pidfile;
struct interface *ifp;
uint16_t family = 0;
int opt, oi = 0, sig = 0, i;
size_t len;
pid_t pid;
struct timespec ts;
- struct utsname utn;
struct control_ctx control_ctx;
pidfile = NULL;
}
}
- if (uname(&utn) == 0) {
- p = vendor;
- p += snprintf(vendor, VENDORCLASSID_MAX_LEN,
- "%s-%s:%s-%s:%s", PACKAGE, VERSION,
- utn.sysname, utn.release, utn.machine);
- hardware_platform(p, VENDORCLASSID_MAX_LEN - (p - vendor));
- } else
- snprintf(vendor, VENDORCLASSID_MAX_LEN,
- "%s-%s", PACKAGE, VERSION);
-
i = 0;
while ((opt = getopt_long(argc, argv, IF_OPTS, cf_options, &oi)) != -1)
{
};
extern TAILQ_HEAD(if_head, interface) *ifaces;
-extern char vendor[VENDORCLASSID_MAX_LEN];
extern sigset_t dhcpcd_sigset;
extern int ifac;
extern char **ifav;
TAILQ_INIT(&ifo->auth.tokens);
strlcpy(ifo->script, SCRIPT, sizeof(ifo->script));
- ifo->vendorclassid[0] = strlen(vendor);
- memcpy(ifo->vendorclassid + 1, vendor, ifo->vendorclassid[0]);
+ ifo->vendorclassid[0] = dhcp_vendor((char *)ifo->vendorclassid + 1,
+ sizeof(ifo->vendorclassid) - 1);
buf = NULL;
buflen = 0;