summaryrefslogtreecommitdiff
path: root/networking/ifupdown.c
diff options
context:
space:
mode:
authorDenis Vlasenko2006-10-02 20:57:10 +0000
committerDenis Vlasenko2006-10-02 20:57:10 +0000
commit1c3577f91dc2a2df0f5b229aa8063365d8756efe (patch)
tree310b97bd20d2f8bb84bebb87a825ce1ef832f345 /networking/ifupdown.c
parent2e864cd21938eae6365b925dac1e1c29a94a0d20 (diff)
downloadbusybox-1c3577f91dc2a2df0f5b229aa8063365d8756efe.zip
busybox-1c3577f91dc2a2df0f5b229aa8063365d8756efe.tar.gz
ifupdown: Debian users contributed improvement to it
Diffstat (limited to 'networking/ifupdown.c')
-rw-r--r--networking/ifupdown.c50
1 files changed, 27 insertions, 23 deletions
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index fae0684..9dd1c99 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -452,45 +452,48 @@ static int static_down(struct interface_defn_t *ifd, execfn *exec)
static int dhcp_up(struct interface_defn_t *ifd, execfn *exec)
{
- int i;
+ if (execute("udhcpc -R -n -p /var/run/udhcpc.%iface%.pid -i %iface% "
+ "[[-H %hostname%]] [[-c %clientid%]] [[-s %script%]]", ifd, exec))
+ return 1;
- 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);
- }
- }
+ /* 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("udhcpc -n -p /var/run/udhcpc.%iface%.pid -i "
- "%iface% [[-H %hostname%]] [[-c %clientid%]]", ifd, exec)) return 1;
- 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("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)
{
- int i;
+ if (execute("kill -TERM `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null",
+ ifd, exec)) return 1;
- 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);
- }
- }
+ /* 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. */
- /* SIGUSR2 forces udhcpc to release the current lease and go inactive,
- * and SIGTERM causes udhcpc to exit. Signals are queued and processed
- * sequentially so we don't need to sleep */
- if (execute("kill -USR2 `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", ifd, exec)
- || execute("kill -TERM `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", ifd, exec))
- return 1;
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("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 int bootp_up(struct interface_defn_t *ifd, execfn *exec)
{
return execute("bootpc [[--bootfile %bootfile%]] --dev %iface% "
@@ -521,6 +524,7 @@ static int wvdial_down(struct interface_defn_t *ifd, execfn *exec)
}
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, },