/* This also changes netmask */
if (!(iface->state->options->options & DHCPCD_INFORM) ||
- !has_address(iface->name, &addr, &net)) {
+ !has_address(iface->name, &addr, &net))
+ {
syslog(LOG_DEBUG, "%s: adding IP address %s/%d",
iface->name, inet_ntoa(addr), inet_ntocidr(net));
if (add_address(iface, &addr, &net, &brd) == -1 &&
build_routes();
if (arp_flush() == -1)
syslog(LOG_ERR, "arp_flush: %m");
- if (!iface->state->lease.frominfo)
+ if (!iface->state->lease.frominfo &&
+ !(iface->state->options->options & DHCPCD_INFORM))
if (write_lease(iface, dhcp) == -1)
syslog(LOG_ERR, "write_lease: %m");
run_script(iface, reason);
}
}
+static void
+send_inform(void *arg)
+{
+ send_message((struct interface *)arg, DHCP_INFORM, send_inform);
+}
+
static void
send_discover(void *arg)
{
start_discover(iface);
return;
}
- syslog(LOG_INFO, "%s: rebinding lease of %s",
- iface->name, inet_ntoa(iface->state->lease.addr));
+ if (ifo->options & DHCPCD_INFORM) {
+ syslog(LOG_INFO, "%s: informing address of %s",
+ iface->name, inet_ntoa(iface->state->lease.addr));
+ } else {
+ syslog(LOG_INFO, "%s: rebinding lease of %s",
+ iface->name, inet_ntoa(iface->state->lease.addr));
+ }
iface->state->state = DHS_REBOOT;
iface->state->xid = arc4random();
iface->state->lease.server.s_addr = 0;
{
iface->state->probes = 0;
send_arp_probe(iface);
- } else
+ } else if (ifo->options & DHCPCD_INFORM)
+ send_inform(iface);
+ else
send_request(iface);
}
iface->start_uptime = uptime();
if (ifo->request_address.s_addr) {
+ /* This also changes netmask */
+ if (iface->state->options->options & DHCPCD_INFORM &&
+ !has_address(iface->name, &ifo->request_address,
+ &ifo->request_netmask))
+ {
+ syslog(LOG_DEBUG, "%s: adding IP address %s/%d",
+ iface->name, inet_ntoa(ifo->request_address),
+ inet_ntocidr(ifo->request_netmask));
+ if (add_address(iface, &ifo->request_address,
+ &ifo->request_netmask, NULL) == -1 &&
+ errno != EEXIST)
+ {
+ syslog(LOG_ERR, "add_address: %m");
+ }
+ }
iface->state->offer = xzalloc(sizeof(*iface->state->offer));
iface->state->offer->yiaddr = ifo->request_address.s_addr;
- ifo->request_address.s_addr = 0;
+ if (ifo->options & DHCPCD_REQUEST)
+ ifo->request_address.s_addr = 0;
} else
iface->state->offer = read_lease(iface);
/* if (iface->state->offer) {
memcpy(iface->clientid + 2, iface->name, ifl);
if (ifl < 4)
memset(iface->clientid + 2 + ifl,
- 0, 4 - ifl);
+ 0, 4 - ifl);
} else {
ifl = htonl(if_nametoindex(iface->name));
memcpy(iface->clientid + 2, &ifl, 4);
iface->clientid = xmalloc(len + 1);
iface->clientid[0] = len;
iface->clientid[1] = iface->family;
- memcpy(iface->clientid + 2, iface->hwaddr, iface->hwlen);
+ memcpy(iface->clientid + 2, iface->hwaddr,
+ iface->hwlen);
}
}
break;
if (do_release || ifl->state->options->options & DHCPCD_RELEASE)
send_release(ifl);
- if (!(ifl->state->options->options & DHCPCD_PERSISTENT))
+ if ((ifl->state->options->options & DHCPCD_PERSISTENT)) {
+ free(ifl->state->new);
+ ifl->state->new = NULL;
+ } else {
drop_config(ifl, do_release ? "RELEASE" : "STOP");
+ }
if (do_release || ifl->state->options->options & DHCPCD_RELEASE)
unlink(ifl->leasefile);
}
char *buffer;
struct ifreq *ifr;
} ifreqs;
- struct sockaddr_in address;
+ in_addr_t address, netmask;
struct ifreq *ifr;
- struct sockaddr_in netmask;
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
return -1;
continue;
memcpy(&netmask, &ifr->ifr_addr, sizeof(netmask));
if (act == 1) {
- addr->s_addr = address.sin_addr.s_addr;
- net->s_addr = netmask.sin_addr.s_addr;
+ addr->s_addr = address;
+ net->s_addr = netmask;
retval = 1;
break;
} else {
- if (address.sin_addr.s_addr == addr->s_addr &&
- (!net ||
- netmask.sin_addr.s_addr == net->s_addr))
+ if (address == addr->s_addr &&
+ (!net || netmask == net->s_addr))
{
retval = 1;
break;