#define BROADCAST_FLAG 0x8000 /* "I need broadcast replies" */
uint32_t ciaddr; /* client IP (if client is in BOUND, RENEW or REBINDING state) */
uint32_t yiaddr; /* 'your' (client) IP address */
- uint32_t siaddr; /* IP address of next server to use in bootstrap,
- * returned in DHCPOFFER, DHCPACK by server */
+ /* IP address of next server to use in bootstrap, returned in DHCPOFFER, DHCPACK by server */
+ uint32_t siaddr_nip;
uint32_t gateway_nip; /* relay agent IP address */
- uint8_t chaddr[16];/* link-layer client hardware address (MAC) */
- uint8_t sname[64]; /* server host name (ASCIZ) */
- uint8_t file[128]; /* boot file name (ASCIZ) */
- uint32_t cookie; /* fixed first four option bytes (99,130,83,99 dec) */
+ uint8_t chaddr[16]; /* link-layer client hardware address (MAC) */
+ uint8_t sname[64]; /* server host name (ASCIZ) */
+ uint8_t file[128]; /* boot file name (ASCIZ) */
+ uint32_t cookie; /* fixed first four option bytes (99,130,83,99 dec) */
uint8_t options[DHCP_OPTIONS_BUFSIZE + CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS];
} PACKED;
char *interface; /* The name of the interface to use */
int ifindex; /* Index number of the interface to use */
uint8_t arp[6]; /* Our arp address */
-// disabled: dumpleases has no way of knowing this value,
-// and will break if it's off. Now it's on always.
-// char remaining; /* Should the lease time in lease file
-// * be written as lease time remaining, or
-// * as the absolute time the lease expires */
uint32_t lease; /* lease time in seconds (host order) */
uint32_t max_leases; /* maximum number of leases (including reserved address) */
uint32_t auto_time; /* how long should udhcpd wait before writing a config file.
uint32_t conflict_time; /* how long an arp conflict offender is leased for */
uint32_t offer_time; /* how long an offered address is reserved */
uint32_t min_lease; /* minimum lease time a client can request */
- uint32_t siaddr; /* next server bootp option */
+ uint32_t siaddr_nip; /* next server bootp option */
char *lease_file;
char *pidfile;
char *notify_file; /* What to run whenever leases are written */
uint8_t lease_mac16[16];
/* "nip": IP in network order */
uint32_t lease_nip;
- /* Unix time when lease expires, regardless of value of
- * server_config.remaining. Kept in memory in host order.
+ /* Unix time when lease expires. Kept in memory in host order.
* When written to file, converted to network order
- * and optionally adjusted (current time subtracted)
- * if server_config.remaining = 1 */
+ * and adjusted (current time subtracted) */
leasetime_t expires;
uint8_t hostname[20]; /* (size is a multiply of 4) */
};
/* on these functions, make sure your datatype matches */
-static int FAST_FUNC read_ip(const char *line, void *arg)
+static int FAST_FUNC read_nip(const char *line, void *arg)
{
len_and_sockaddr *lsa;
opt = buffer; /* new meaning for variable opt */
switch (option->flags & TYPE_MASK) {
case OPTION_IP:
- retval = read_ip(val, buffer);
+ retval = read_nip(val, buffer);
break;
case OPTION_IP_PAIR:
- retval = read_ip(val, buffer);
+ retval = read_nip(val, buffer);
val = strtok(NULL, ", \t/-");
if (!val)
retval = 0;
if (retval)
- retval = read_ip(val, buffer + 4);
+ retval = read_nip(val, buffer + 4);
break;
case OPTION_STRING:
#if ENABLE_FEATURE_UDHCP_RFC3397
/* Read ip */
ip_string = strtok_r(NULL, " \t", &line);
- read_ip(ip_string, &ip);
+ read_nip(ip_string, &ip);
addStaticLease(arg, (uint8_t*) &mac_bytes, ip);
static const struct config_keyword keywords[] = {
/* keyword handler variable address default */
- {"start", read_ip, &(server_config.start_ip), "192.168.0.20"},
- {"end", read_ip, &(server_config.end_ip), "192.168.0.254"},
+ {"start", read_nip, &(server_config.start_ip), "192.168.0.20"},
+ {"end", read_nip, &(server_config.end_ip), "192.168.0.254"},
{"interface", read_str, &(server_config.interface), "eth0"},
/* Avoid "max_leases value not sane" warning by setting default
* to default_end_ip - default_start_ip + 1: */
{"max_leases", read_u32, &(server_config.max_leases), "235"},
-// {"remaining", read_yn, &(server_config.remaining), "yes"},
{"auto_time", read_u32, &(server_config.auto_time), "7200"},
{"decline_time", read_u32, &(server_config.decline_time), "3600"},
{"conflict_time",read_u32, &(server_config.conflict_time),"3600"},
{"min_lease", read_u32, &(server_config.min_lease), "60"},
{"lease_file", read_str, &(server_config.lease_file), LEASES_FILE},
{"pidfile", read_str, &(server_config.pidfile), "/var/run/udhcpd.pid"},
- {"siaddr", read_ip, &(server_config.siaddr), "0.0.0.0"},
+ {"siaddr", read_nip, &(server_config.siaddr_nip), "0.0.0.0"},
/* keywords with no defaults must be last! */
{"option", read_opt, &(server_config.options), ""},
{"opt", read_opt, &(server_config.options), ""},
}
-static int sprintip(char *dest, const char *pre, const uint8_t *ip)
+/* note: ip is a pointer to an IP in network order, possibly misaliged */
+static int sprint_nip(char *dest, const char *pre, const uint8_t *ip)
{
return sprintf(dest, "%s%d.%d.%d.%d", pre, ip[0], ip[1], ip[2], ip[3]);
}
for (;;) {
switch (type) {
case OPTION_IP_PAIR:
- dest += sprintip(dest, "", option);
+ dest += sprint_nip(dest, "", option);
*dest++ = '/';
option += 4;
optlen = 4;
case OPTION_IP: /* Works regardless of host byte order. */
- dest += sprintip(dest, "", option);
+ dest += sprint_nip(dest, "", option);
break;
case OPTION_BOOLEAN:
dest += sprintf(dest, *option ? "yes" : "no");
num_options++; /* for mton */
}
}
- if (packet->siaddr)
+ if (packet->siaddr_nip)
num_options++;
temp = get_option(packet, DHCP_OPTION_OVERLOAD);
if (temp)
return envp;
*curr = xmalloc(sizeof("ip=255.255.255.255"));
- sprintip(*curr, "ip=", (uint8_t *) &packet->yiaddr);
+ sprint_nip(*curr, "ip=", (uint8_t *) &packet->yiaddr);
putenv(*curr++);
opt_name = dhcp_option_strings;
opt_name += strlen(opt_name) + 1;
i++;
}
- if (packet->siaddr) {
+ if (packet->siaddr_nip) {
*curr = xmalloc(sizeof("siaddr=255.255.255.255"));
- sprintip(*curr, "siaddr=", (uint8_t *) &packet->siaddr);
+ sprint_nip(*curr, "siaddr=", (uint8_t *) &packet->siaddr_nip);
putenv(*curr++);
}
if (!(over & FILE_FIELD) && packet->file[0]) {
/* add in the bootp options */
static void add_bootp_options(struct dhcpMessage *packet)
{
- packet->siaddr = server_config.siaddr;
+ packet->siaddr_nip = server_config.siaddr_nip;
if (server_config.sname)
strncpy((char*)packet->sname, server_config.sname, sizeof(packet->sname) - 1);
if (server_config.boot_file)