to fix an alignment issue on SGI MIPS.
Thanks to Tim McIntosh.
return;
lease->addr.s_addr = dhcp->yiaddr;
- if (get_option_addr(&lease->net.s_addr, dhcp, DHO_SUBNETMASK) == -1)
+ if (get_option_addr(&lease->net, dhcp, DHO_SUBNETMASK) == -1)
lease->net.s_addr = get_netmask(dhcp->yiaddr);
if (get_option_uint32(&lease->leasetime, dhcp, DHO_LEASETIME) == 0) {
/* Ensure that we can use the lease */
addr.s_addr = dhcp->yiaddr;
a = xstrdup(inet_ntoa(addr));
}
- r = get_option_addr(&addr.s_addr, dhcp, DHO_SERVERID);
+ r = get_option_addr(&addr, dhcp, DHO_SERVERID);
if (dhcp->servername[0] && r == 0)
logger(lvl, "%s %s from %s `%s'", msg, a,
inet_ntoa(addr), dhcp->servername);
return 0;
}
/* Every DHCP message should include ServerID */
- if (get_option_addr(&addr.s_addr, dhcp, DHO_SERVERID) == -1) {
+ if (get_option_addr(&addr, dhcp, DHO_SERVERID) == -1) {
logger(LOG_ERR, "ignoring message; no Server ID");
return 0;
}
* We should expand this to check IP and/or hardware address
* at the packet level. */
if (options->blacklist_len != 0 &&
- get_option_addr(&addr.s_addr, dhcp, DHO_SERVERID) == 0)
+ get_option_addr(&addr, dhcp, DHO_SERVERID) == 0)
{
for (i = 0; i < options->blacklist_len; i++) {
if (options->blacklist[i] != addr.s_addr)
if (type == DHCP_OFFER && state->state == STATE_DISCOVERING) {
lease->addr.s_addr = dhcp->yiaddr;
- get_option_addr(&lease->server.s_addr, dhcp, DHO_SERVERID);
+ get_option_addr(&lease->server, dhcp, DHO_SERVERID);
log_dhcp(LOG_INFO, "offered", dhcp);
if (state->options & DHCPCD_TEST) {
run_script(options, iface->name, "TEST", dhcp, NULL);
case STATE_RENEWING:
case STATE_REBINDING:
if (!(state->options & DHCPCD_INFORM)) {
- get_option_addr(&lease->server.s_addr,
+ get_option_addr(&lease->server,
dhcp, DHO_SERVERID);
log_dhcp(LOG_INFO, "acknowledged", dhcp);
}
if (addr.s_addr == 0)
addr.s_addr = lease->addr.s_addr;
/* Ensure we have all the needed values */
- if (get_option_addr(&net.s_addr, dhcp, DHO_SUBNETMASK) == -1)
+ if (get_option_addr(&net, dhcp, DHO_SUBNETMASK) == -1)
net.s_addr = get_netmask(addr.s_addr);
- if (get_option_addr(&brd.s_addr, dhcp, DHO_BROADCAST) == -1)
+ if (get_option_addr(&brd, dhcp, DHO_BROADCAST) == -1)
brd.s_addr = addr.s_addr | ~net.s_addr;
}
}
int
-get_option_addr(uint32_t *a, const struct dhcp_message *dhcp, uint8_t option)
+get_option_addr(struct in_addr *a, const struct dhcp_message *dhcp,
+ uint8_t option)
{
const uint8_t *p = get_option_raw(dhcp, option);
if (!p)
return -1;
- memcpy(a, p, sizeof(*a));
+ memcpy(&a->s_addr, p, sizeof(a->s_addr));
return 0;
}
int
get_option_uint32(uint32_t *i, const struct dhcp_message *dhcp, uint8_t option)
{
- uint32_t a;
+ const uint8_t *p = get_option_raw(dhcp, option);
+ uint32_t d;
- if (get_option_addr(&a, dhcp, option) == -1)
+ if (!p)
return -1;
-
- *i = ntohl(a);
+ memcpy(&d, p, sizeof(d));
+ *i = ntohl(d);
return 0;
}
* message but are not necessarily in the options */
addr.s_addr = dhcp->yiaddr;
setvar(&ep, prefix, "ip_address", inet_ntoa(addr));
- if (get_option_addr(&net.s_addr, dhcp, DHO_SUBNETMASK) == -1) {
+ if (get_option_addr(&net, dhcp, DHO_SUBNETMASK) == -1) {
net.s_addr = get_netmask(addr.s_addr);
setvar(&ep, prefix, "subnet_mask", inet_ntoa(net));
}
i = inet_ntocidr(net);
snprintf(cidr, sizeof(cidr), "%d", inet_ntocidr(net));
setvar(&ep, prefix, "subnet_cidr", cidr);
- if (get_option_addr(&brd.s_addr, dhcp, DHO_BROADCAST) == -1) {
+ if (get_option_addr(&brd, dhcp, DHO_BROADCAST) == -1) {
brd.s_addr = addr.s_addr | ~net.s_addr;
setvar(&ep, prefix, "broadcast_address", inet_ntoa(brd));
}
int make_option_mask(uint8_t *, char **, int);
void print_options(void);
char *get_option_string(const struct dhcp_message *, uint8_t);
-int get_option_addr(uint32_t *, const struct dhcp_message *, uint8_t);
+int get_option_addr(struct in_addr *, const struct dhcp_message *, uint8_t);
int get_option_uint32(uint32_t *, const struct dhcp_message *, uint8_t);
int get_option_uint16(uint16_t *, const struct dhcp_message *, uint8_t);
int get_option_uint8(uint8_t *, const struct dhcp_message *, uint8_t);