PATCH: ifupdown.c, udhcpc, and standalone shell

Gabriel L. Somlo somlo at cmu.edu
Thu Sep 28 16:34:38 UTC 2006


Here's my proposal:

static int dhcp_up(struct interface_defn_t *ifd, execfn *exec)
{
    int i;

    for (i = 0; i < ifd->n_options; i++) {
        if (strcmp(ifd->option[i].name, "dhcp-start-cmd") == 0) {
            return execute(ifd->option[i].value, ifd, exec);
        }
    }

    /* old calls for "blessed" clients may or may not go here for
       backward compatibility */

    return 0;
}

static int dhcp_down(struct interface_defn_t *ifd, execfn *exec)
{
    int i;

    for (i = 0; i < ifd->n_options; i++) {
        if (strcmp(ifd->option[i].name, "dhcp-stop-cmd") == 0) {
            return execute(ifd->option[i].value, ifd, exec);
        }
    }

    /* old calls for "blessed" clients may or may not go here for
       backward compatibility */

    return static_down(ifd, exec);
}

My /etc/network/interfaces file looks like this:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp
  dhcp-start-cmd udhcpc -s /etc/network/udhcpc.script -n -p /var/run/udhcpc.%iface%.pid -i %iface% [[-H %hostname%]] [[-c %clientid%]]
  dhcp-stop-cmd kill -USR2 `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null ; sleep 2 ; kill -TERM `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null

This also solves my other problem (that I hate having udhcpc look for
its script in /usr/share/udhcpc/default.script). Now I can simply pass
'-s path/to/script' in /etc/network/interfaces...

The old 'Let's all go down the list of blessed clients' code may or
may not be included for backward compatibility...

I've attached my version of ifupdown.c.gz, check it out and let me
know if it's palatable :)

Cheers,
Gabriel

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


More information about the busybox mailing list