]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
-w, --wait forces dhcpcd to wait for an ip address or timeout when
authorRoy Marples <roy@marples.name>
Wed, 7 Oct 2009 21:11:14 +0000 (21:11 +0000)
committerRoy Marples <roy@marples.name>
Wed, 7 Oct 2009 21:11:14 +0000 (21:11 +0000)
running on more than one interface.

dhcpcd.8.in
dhcpcd.c
dhcpcd.conf.5.in
if-options.c
if-options.h

index b9697bca054a475889ceaf67313e71b684af8b9a..50997a09af15961d9fd3fb09efbfa392547999d5 100644 (file)
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd September 16, 2009
+.Dd October 7, 2009
 .Dt DHCPCD 8 SMM
 .Os
 .Sh NAME
@@ -30,7 +30,7 @@
 .Nd an RFC 2131 compliant DHCP client
 .Sh SYNOPSIS
 .Nm
-.Op Fl bdgknpqABDEGKLTV
+.Op Fl bdgknpqwABDEGKLTV
 .Op Fl c , -script Ar script
 .Op Fl e , -env Ar value
 .Op Fl f , -config Ar file
@@ -339,6 +339,8 @@ Set the vendor option 03 with an IP address as a string.
 .D1 dhcpcd \-v 03,\e"192.168.0.2\e" eth0
 Set un-encapulated vendor option to hello world.
 .D1 dhcpcd \-v ,"hello world" eth0
+.It Fl w , -wait
+Wait for an address to be assigned before forking to the background.
 .It Fl x , -exit
 This will signal an existing
 .Nm
index 875b47e0e2ee9f40da44965d2e61e685b4a3cf9c..7d2d5b12386bf7e77ab759944d593567e4f83bd7 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -137,7 +137,7 @@ read_pid(void)
 static void
 usage(void)
 {
-       printf("usage: "PACKAGE" [-dgknpqxyADEGHKLOTV] [-c script] [-f file]"
+       printf("usage: "PACKAGE" [-dgknpqwxyADEGHKLOTV] [-c script] [-f file]"
            " [-e var=val]\n"
            "              [-h hostname] [-i classID ] [-l leasetime]"
            " [-m metric] [-o option]\n"
@@ -1545,7 +1545,7 @@ main(int argc, char **argv)
 {
        struct if_options *ifo;
        struct interface *iface;
-       int opt, oi = 0, signal_fd, sig = 0, i, control_fd;
+       int opt, oi = 0, signal_fd, sig = 0, i, control_fd, wflag = 0;
        size_t len;
        pid_t pid;
        struct timespec ts;
@@ -1581,6 +1581,9 @@ main(int argc, char **argv)
                case 'n':
                        sig = SIGALRM;
                        break;
+               case 'w':
+                       wflag = 1;
+                       break;
                case 'x':
                        sig = SIGTERM;
                        break;
@@ -1610,6 +1613,8 @@ main(int argc, char **argv)
                options |= DHCPCD_TEST | DHCPCD_PERSISTENT;
                options &= ~DHCPCD_DAEMONISE;
        }
+       if (wflag != 0)
+               options |= DHCPCD_WAITIP;
        
 #ifdef THERE_IS_NO_FORK
        options &= ~DHCPCD_DAEMONISE;
@@ -1754,7 +1759,10 @@ main(int argc, char **argv)
        ifc = argc - optind;
        ifv = argv + optind;
        if (options & DHCPCD_BACKGROUND ||
-           (ifc == 0 && options & DHCPCD_LINK && options & DHCPCD_DAEMONISE))
+           (ifc == 0 &&
+               options & DHCPCD_LINK &&
+               options & DHCPCD_DAEMONISE &&
+               !(options & DHCPCD_WAITIP)))
        {
                daemonise();
        } else if (options & DHCPCD_DAEMONISE && ifo->timeout > 0) {
index a9497889c6682a975e1731a618d3f10c382f63a4..8a1f94b968697c1edd7df61eefe1a405df9b2ddd 100644 (file)
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd September 2, 2009
+.Dd October 7, 2009
 .Dt DHCPCD.CONF 5 SMM
 .Os
 .Sh NAME
@@ -272,6 +272,8 @@ Set un-encapulated vendor option to hello world.
 .It Ic vendorclassid Ar string
 Change the default vendorclassid sent from dhcpcd-version.
 If not set then none is sent.
+.It Ic wait
+Wait for an address to be assigned before forking to the background.
 .El
 .Sh SEE ALSO
 .Xr dhcpcd-run-hooks 8 ,
index 53bb1a18261ffb8aef0db7b76ef636e806f09a51..15669d7e0d91be9d528b9d380bf9c604c5a52441 100644 (file)
@@ -72,6 +72,7 @@ const struct option cf_options[] = {
        {"timeout",         required_argument, NULL, 't'},
        {"userclass",       required_argument, NULL, 'u'},
        {"vendor",          required_argument, NULL, 'v'},
+       {"wait",            no_argument,       NULL, 'w'},
        {"exit",            no_argument,       NULL, 'x'},
        {"allowinterfaces", required_argument, NULL, 'z'},
        {"reboot",          required_argument, NULL, 'y'},
@@ -329,6 +330,7 @@ parse_option(struct if_options *ifo, int opt, const char *arg)
        case 'f': /* FALLTHROUGH */
        case 'g': /* FALLTHROUGH */
        case 'n': /* FALLTHROUGH */
+       case 'w': /* FALLTHROUGH */
        case 'x': /* FALLTHROUGH */
        case 'T': /* We need to handle non interface options */
                break;
index 0c2818fd81a14c24c0bef88836c895b3b1a410c8..ee40f8a84d224ae0bea9cbf25a1c35fea7c5ddcf 100644 (file)
@@ -37,7 +37,7 @@
 
 /* Don't set any optional arguments here so we retain POSIX
  * compatibility with getopt */
-#define IF_OPTS "bc:de:f:gh:i:kl:m:no:pqr:s:t:u:v:xy:z:ABC:DEF:GI:KLN:O:Q:TVW:X:Z:"
+#define IF_OPTS "bc:de:f:gh:i:kl:m:no:pqr:s:t:u:v:wxy:z:ABC:DEF:GI:KLN:O:Q:TVW:X:Z:"
 
 #define DEFAULT_TIMEOUT                30
 #define DEFAULT_REBOOT         10
@@ -70,6 +70,7 @@
 #define DHCPCD_QUIET           (1 << 21) 
 #define DHCPCD_BACKGROUND      (1 << 22)
 #define DHCPCD_VENDORRAW       (1 << 23)
+#define DHCPCD_WAITIP          (1 << 24)
 
 extern const struct option cf_options[];