non-busybox dhcp clients (was: PATCH: ifupdown.c, udhcpc, and standalone shell)

Gabriel L. Somlo somlo at cmu.edu
Sun Oct 1 02:41:20 UTC 2006


Denis, Eric:

I've added the 'manual' method to ifupdown.c, which works exactly like
the one in Debian (i.e., does nothing by default, and one has to
provide explicit up and down commands for anything to happen).

I've added '-R' to the udhcpc startup command line, which then allows
it to be killed by dhcp_down() with a single 'kill -TERM', which will
also cause it to relinguish the lease before dying.

I've added a 'script' option to 'iface foo inet dhcp', which, if
present, passes a '-s /path/to/script' to udhcpc. This solves my
problem with udhcpc looking for its script in a place I don't like.

The relevant bits are below, and the entire ifupdown.c.gz file is
attached.

Denis, please apply if there are no objections :)

Thanks,
Gabriel

...

static int dhcp_up(struct interface_defn_t *ifd, execfn *exec)
{
    if (execute("udhcpc -R -n -p /var/run/udhcpc.%iface%.pid -i %iface% "
            "[[-H %hostname%]] [[-c %clientid%]] [[-s %script%]]", ifd, exec))
        return 1;

    /* 2006-09-30: The following are deprecated, and should eventually be
     * removed. For non-busybox (i.e., other than udhcpc) clients, use
     * 'iface foo inet manual' in /etc/network/interfaces, and supply
     * start/stop commands explicitly via up/down. */

    if (execute("pump -i %iface% [[-h %hostname%]] [[-l %leasehours%]]",
            ifd, exec)) return 1;
    if (execute("dhclient -pf /var/run/dhclient.%iface%.pid %iface%",
            ifd, exec)) return 1;
    if (execute("dhcpcd [[-h %hostname%]] [[-i %vendor%]] [[-I %clientid%]] "
            "[[-l %leasetime%]] %iface%", ifd, exec)) return 1;

    return 0;
}

static int dhcp_down(struct interface_defn_t *ifd, execfn *exec)
{
    if (execute("kill -TERM `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null",
            ifd, exec)) return 1;

    /* 2006-09-30: The following are deprecated, and should eventually be
     * removed. For non-busybox (i.e., other than udhcpc) clients, use
     * 'iface foo inet manual' in /etc/network/interfaces, and supply
     * start/stop commands explicitly via up/down. */

    if (execute("pump -i %iface% -k", ifd, exec)) return 1;
    if (execute("kill -9 `cat /var/run/dhclient.%iface%.pid` 2>/dev/null",
            ifd, exec)) return 1;
    if (execute("dhcpcd -k %iface%", ifd, exec)) return 1;

    return static_down(ifd, exec);
}

static int manual_up_down(struct interface_defn_t *ifd, execfn *exec)
{
    return 1;
}

...

static const struct method_t methods[] = {
    { "manual", manual_up_down, manual_up_down, },
    { "wvdial", wvdial_up, wvdial_down, },
    { "ppp", ppp_up, ppp_down, },
    { "static", static_up, static_down, },
    { "bootp", bootp_up, static_down, },
    { "dhcp", dhcp_up, dhcp_down, },
    { "loopback", loopback_up, loopback_down, },
};

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ifupdown.c.gz
Type: application/x-gzip
Size: 8181 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20060930/e4f25d9f/attachment-0002.bin 


More information about the busybox mailing list