]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/src/cmd/ip/ipconfig/dhcp.c
ip/ipconfig: ODtftpserver (dhcp option 66) is of type string
[plan9front.git] / sys / src / cmd / ip / ipconfig / dhcp.c
index 7bd8141bad275a381674bd04710ebabda9325848..44badcf8a2c25e0476871d2aebf86ef034c81cd8 100644 (file)
@@ -106,7 +106,7 @@ static Option option[256] =
 [ODrebindingtime]      { "rebindingtime",      Tulong },
 [ODvendorclass]                { "vendorclass",        Tvec },
 [ODclientid]           { "clientid",           Tvec },
-[ODtftpserver]         { "tftp",               Taddr },
+[ODtftpserver]         { "tftp",               Tstr },
 [ODbootfile]           { "bootfile",           Tstr },
 [ODdnsdomain]          { "dnsdomain",          Tnames },
 };
@@ -155,11 +155,25 @@ dhcpinit(void)
        memcpy(requested, defrequested, nrequested);
 }
 
+static void
+removenulladdr(void)
+{
+       fprint(conf.cfd, "remove %I %M", IPnoaddr, IPnoaddr);
+       atexitdont(removenulladdr);
+}
+
+static void
+addnulladdr(void)
+{
+       atexit(removenulladdr);
+       fprint(conf.cfd, "add %I %M", IPnoaddr, IPnoaddr);
+}
+
 void
 dhcpquery(int needconfig, int startstate)
 {
        if(needconfig)
-               fprint(conf.cfd, "add %I %M", IPnoaddr, IPnoaddr);
+               addnulladdr();
 
        conf.fd = openlisten();
        if(conf.fd < 0){
@@ -192,8 +206,7 @@ dhcpquery(int needconfig, int startstate)
        close(conf.fd);
 
        if(needconfig)
-               fprint(conf.cfd, "remove %I %M", IPnoaddr, IPnoaddr);
-
+               removenulladdr();
 }
 
 enum {
@@ -264,8 +277,7 @@ dhcpwatch(int needconfig)
                         * leave everything we've learned somewhere that
                         * other procs can find it.
                         */
-                       if(beprimary)
-                               putndb();
+                       putndb();
                        refresh();
                }
        }