From: Roy Marples Date: Sat, 18 Oct 2008 10:02:36 +0000 (+0000) Subject: Make init request for an address work off the command line again. X-Git-Tag: v5.0.0~217 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49c0efdadb6fa4a27bf0405302945403d4d62ef8;p=thirdparty%2Fdhcpcd.git Make init request for an address work off the command line again. --- diff --git a/dhcpcd.c b/dhcpcd.c index 39af2ce7..249c7628 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -746,6 +746,27 @@ start_reboot(struct interface *iface) send_request(iface); } +static void +start_request(struct interface *iface) +{ + struct if_options *ifo = iface->state->options; + + syslog(LOG_INFO, "%s: requesting lease of %s", + iface->name, inet_ntoa(ifo->request_address)); + iface->state->state = DHS_REQUEST; + iface->state->xid = arc4random(); + open_sockets(iface); + delete_timeout(NULL, iface); + iface->state->offer = xzalloc(sizeof(*iface->state->offer)); + iface->state->offer->yiaddr = ifo->request_address.s_addr; + get_lease(&iface->state->lease, iface->state->offer); + iface->state->lease.frominfo = 1; + /* We should only go into this request loop once */ + ifo->request_address.s_addr = 0; + add_timeout_sec(10, start_discover, iface); + send_request(iface); +} + void start_interface(void *arg) { @@ -760,6 +781,10 @@ start_interface(void *arg) } iface->start_uptime = uptime(); + if (iface->state->options->request_address.s_addr) { + start_request(iface); + return; + } iface->state->offer = read_lease(iface); /* if (iface->state->offer) { if (IN_LINKLOCAL(htonl(iface->state->offer->yiaddr))) {