]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Make init request for an address work off the command line again.
authorRoy Marples <roy@marples.name>
Sat, 18 Oct 2008 10:02:36 +0000 (10:02 +0000)
committerRoy Marples <roy@marples.name>
Sat, 18 Oct 2008 10:02:36 +0000 (10:02 +0000)
dhcpcd.c

index 39af2ce7443deab1f310da737f1f9b172610be6e..249c76283be16725b6f7baac8f84d6f9bb1b1938 100644 (file)
--- 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))) {