return -1;
}
-#ifdef ENABLE_DUID
+#ifndef MINIMAL
#define THIRTY_YEARS_IN_SECONDS 946707779
static size_t
get_duid(unsigned char *duid, const struct interface *iface)
struct interface *iface = state->interface;
struct dhcp_lease *lease = &state->lease;
struct in_addr addr;
+#ifndef MINIMAL
size_t len = 0;
-#ifdef ENABLE_DUID
unsigned char *duid = NULL;
uint32_t ul;
#endif
iface->net.s_addr = lease->net.s_addr;
}
+#ifndef MINIMAL
if (*options->clientid) {
iface->clientid = xmalloc(options->clientid[0] + 1);
memcpy(iface->clientid,
options->clientid, options->clientid[0] + 1);
} else if (options->options & DHCPCD_CLIENTID) {
-#ifdef ENABLE_DUID
if (options->options & DHCPCD_DUID) {
duid = xmalloc(DUID_LEN);
if ((len = get_duid(duid, iface)) == 0)
memcpy(iface->clientid + 6, duid, len);
free(duid);
}
-#endif
if (len == 0) {
len = iface->hwlen + 1;
iface->clientid = xmalloc(len + 1);
memcpy(iface->clientid + 2, iface->hwaddr, iface->hwlen);
}
}
+#endif
return 0;
}
uint32_t xid, uint8_t type, const struct options *options)
{
struct dhcp_message *dhcp;
- uint8_t *d, *m, *p;
- const char *c;
+ uint8_t *m, *p;
uint8_t *n_params = NULL;
time_t up = uptime() - iface->start_uptime;
uint32_t ul;
uint16_t sz;
const struct dhcp_opt *opt;
+#ifndef MINIMAL
+ uint8_t *d;
+ const char *c;
+#endif
dhcp = xzalloc(sizeof (*dhcp));
m = (uint8_t *)dhcp;
p += 2;
}
+#ifndef MINIMAL
if (iface->clientid) {
*p++ = DHCP_CLIENTID;
memcpy(p, iface->clientid, iface->clientid[0] + 1);
p += options->classid[0] + 1;
}
}
+#endif
if (type == DHCP_DISCOVER || type == DHCP_REQUEST) {
#define PUTADDR(_type, _val) \
type == DHCP_INFORM ||
type == DHCP_REQUEST)
{
+#ifndef MINIMAL
if (options->hostname[0]) {
if (options->fqdn == FQDN_DISABLE) {
*p++ = DHCP_HOSTNAME;
memcpy(p, options->vendor, options->vendor[0] + 1);
p += options->vendor[0] + 1;
}
+#endif
*p++ = DHCP_PARAMETERREQUESTLIST;
n_params = p;
static void
usage(void)
{
+#ifndef MINIMAL
printf("usage: "PACKAGE" [-dknpqxADEGHKLOTV] [-c script] [-f file ] [-h hostname]\n"
" [-i classID ] [-l leasetime] [-m metric] [-o option] [-r ipaddr]\n"
" [-s ipaddr] [-t timeout] [-u userclass] [-F none|ptr|both]\n"
" [-I clientID] [-C hookscript] <interface>\n");
+#endif
}
static char *
return newlist[i];
}
+#ifndef MINIMAL
#define parse_string(buf, len, arg) parse_string_hwaddr(buf, len, arg, 0)
static ssize_t
parse_string_hwaddr(char *sbuf, ssize_t slen, char *str, int clid)
}
return l;
}
+#endif
static int
parse_option(int opt, char *oarg, struct options *options)
int i;
char *p;
ssize_t s;
+#ifndef MINIMAL
struct in_addr addr;
+#endif
switch(opt) {
case 'c':
strlcpy(options->script, oarg, sizeof(options->script));
break;
case 'h':
+#ifndef MINIMAL
if (oarg)
s = parse_string(options->hostname + 1,
MAXHOSTNAMELEN, oarg);
return -1;
}
options->hostname[0] = (uint8_t)s;
+#endif
break;
case 'i':
+#ifndef MINIMAL
if (oarg)
s = parse_string((char *)options->classid + 1,
CLASSID_MAX_LEN, oarg);
return -1;
}
*options->classid = (uint8_t)s;
+#endif
break;
case 'l':
+#ifndef MINIMAL
if (*oarg == '-') {
logger(LOG_ERR,
"leasetime must be a positive value");
logger(LOG_ERR, "`%s' out of range", oarg);
return -1;
}
+#endif
break;
case 'm':
options->metric = atoint(oarg);
}
break;
case 'u':
+#ifndef MINIMAL
s = USERCLASS_MAX_LEN - options->userclass[0] - 1;
s = parse_string((char *)options->userclass + options->userclass[0] + 2,
s, oarg);
options->userclass[options->userclass[0] + 1] = s;
options->userclass[0] += s + 1;
}
+#endif
break;
case 'v':
+#ifndef MINIMAL
p = strchr(oarg, ',');
if (!p || !p[1]) {
logger(LOG_ERR, "invalid vendor format");
options->vendor[options->vendor[0] + 2] = s;
options->vendor[0] += s + 2;
}
+#endif
break;
case 'A':
options->options &= ~DHCPCD_ARP;
options->options |= DHCPCD_LASTLEASE;
break;
case 'F':
+#ifndef MINIMAL
if (!oarg) {
options->fqdn = FQDN_BOTH;
break;
oarg);
return -1;
}
+#endif
break;
case 'G':
options->options &= ~DHCPCD_GATEWAY;
break;
case 'I':
+#ifndef MINIMAL
/* Strings have a type of 0 */;
options->classid[1] = 0;
if (oarg)
options->options &= ~DHCPCD_DUID;
options->options &= ~DHCPCD_CLIENTID;
}
+#endif
break;
case 'K':
options->options &= ~DHCPCD_DAEMONISE;
openlog(PACKAGE, LOG_PID, LOG_LOCAL0);
options = xzalloc(sizeof(*options));
+ options->options |= DHCPCD_GATEWAY | DHCPCD_DAEMONISE;
+#ifndef MINIMAL
+ options->options |= DHCPCD_CLIENTID;
strlcpy(options->script, SCRIPT, sizeof(options->script));
options->classid[0] = snprintf((char *)options->classid + 1, CLASSID_MAX_LEN,
"%s %s", PACKAGE, VERSION);
- options->options |= DHCPCD_CLIENTID | DHCPCD_GATEWAY | DHCPCD_DAEMONISE;
+#endif
#ifdef ENABLE_ARP
options->options |= DHCPCD_ARP;
#ifdef ENABLE_IPV4LL
/* If the duid file exists, then enable duid by default
* This means we don't break existing clients that easily :) */
-# ifdef ENABLE_DUID
if ((f = fopen(DUID, "r"))) {
options->options |= DHCPCD_DUID;
fclose(f);
}
-# endif
#endif
#ifdef THERE_IS_NO_FORK
}
#endif
+#ifndef MINIMAL
gethostname(options->hostname + 1, sizeof(options->hostname));
if (strcmp(options->hostname + 1, "(none)") == 0 ||
strcmp(options->hostname + 1, "localhost") == 0)
options->hostname[1] = '\0';
*options->hostname = strlen(options->hostname + 1);
+#endif
while ((opt = getopt_long(argc, argv, OPTS EXTRA_OPTS,
longopts, &option_index)) != -1)
#ifdef ENABLE_ARP
" ARP"
#endif
-#ifdef ENABLE_DUID
- " DUID"
-#endif
#ifdef ENABLE_IPV4LL
" IPV4LL"
#endif
+#ifdef MINIMAL
+ " MINIMAL"
+#endif
#ifdef THERE_IS_NO_FORK
" THERE_IS_NO_FORK"
#endif
}
}
+#ifndef MINIMAL
if ((p = strchr(options->hostname, '.'))) {
if (options->fqdn == FQDN_DISABLE)
*p = '\0';
}
if (options->fqdn != FQDN_DISABLE)
del_reqmask(options->reqmask, DHCP_HOSTNAME);
+#endif
if (options->request_address.s_addr == 0 &&
(options->options & DHCPCD_INFORM ||
logger(LOG_INFO, PACKAGE " " VERSION " starting");
}
+#ifndef MINIMAL
/* Terminate the encapsulated options */
if (options->vendor[0]) {
options->vendor[0]++;
options->vendor[options->vendor[0]] = DHCP_END;
}
+#endif
if (dhcp_run(options, &pid_fd) == 0)
retval = EXIT_SUCCESS;