aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-10-02 20:57:10 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-10-02 20:57:10 +0000
commit1c3577f91dc2a2df0f5b229aa8063365d8756efe (patch)
tree310b97bd20d2f8bb84bebb87a825ce1ef832f345
parent2e864cd21938eae6365b925dac1e1c29a94a0d20 (diff)
downloadbusybox-w32-1c3577f91dc2a2df0f5b229aa8063365d8756efe.tar.gz
busybox-w32-1c3577f91dc2a2df0f5b229aa8063365d8756efe.tar.bz2
busybox-w32-1c3577f91dc2a2df0f5b229aa8063365d8756efe.zip
ifupdown: Debian users contributed improvement to it
-rw-r--r--networking/ifupdown.c50
1 files changed, 27 insertions, 23 deletions
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index fae0684b5..9dd1c9926 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -452,45 +452,48 @@ static int static_down(struct interface_defn_t *ifd, execfn *exec)
452 452
453static int dhcp_up(struct interface_defn_t *ifd, execfn *exec) 453static int dhcp_up(struct interface_defn_t *ifd, execfn *exec)
454{ 454{
455 int i; 455 if (execute("udhcpc -R -n -p /var/run/udhcpc.%iface%.pid -i %iface% "
456 "[[-H %hostname%]] [[-c %clientid%]] [[-s %script%]]", ifd, exec))
457 return 1;
456 458
457 for (i = 0; i < ifd->n_options; i++) { 459 /* 2006-09-30: The following are deprecated, and should eventually be
458 if (strcmp(ifd->option[i].name, "dhcp-start-cmd") == 0) { 460 * removed. For non-busybox (i.e., other than udhcpc) clients, use
459 return execute(ifd->option[i].value, ifd, exec); 461 * 'iface foo inet manual' in /etc/network/interfaces, and supply
460 } 462 * start/stop commands explicitly via up/down. */
461 }
462 463
463 if (execute("udhcpc -n -p /var/run/udhcpc.%iface%.pid -i " 464 if (execute("pump -i %iface% [[-h %hostname%]] [[-l %leasehours%]]",
464 "%iface% [[-H %hostname%]] [[-c %clientid%]]", ifd, exec)) return 1; 465 ifd, exec)) return 1;
465 if (execute("pump -i %iface% [[-h %hostname%]] [[-l %leasehours%]]", ifd, exec)) return 1; 466 if (execute("dhclient -pf /var/run/dhclient.%iface%.pid %iface%",
466 if (execute("dhclient -pf /var/run/dhclient.%iface%.pid %iface%", ifd, exec)) return 1; 467 ifd, exec)) return 1;
467 if (execute("dhcpcd [[-h %hostname%]] [[-i %vendor%]] [[-I %clientid%]] " 468 if (execute("dhcpcd [[-h %hostname%]] [[-i %vendor%]] [[-I %clientid%]] "
468 "[[-l %leasetime%]] %iface%", ifd, exec)) return 1; 469 "[[-l %leasetime%]] %iface%", ifd, exec)) return 1;
470
469 return 0; 471 return 0;
470} 472}
471 473
472static int dhcp_down(struct interface_defn_t *ifd, execfn *exec) 474static int dhcp_down(struct interface_defn_t *ifd, execfn *exec)
473{ 475{
474 int i; 476 if (execute("kill -TERM `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null",
477 ifd, exec)) return 1;
475 478
476 for (i = 0; i < ifd->n_options; i++) { 479 /* 2006-09-30: The following are deprecated, and should eventually be
477 if (strcmp(ifd->option[i].name, "dhcp-stop-cmd") == 0) { 480 * removed. For non-busybox (i.e., other than udhcpc) clients, use
478 return execute(ifd->option[i].value, ifd, exec); 481 * 'iface foo inet manual' in /etc/network/interfaces, and supply
479 } 482 * start/stop commands explicitly via up/down. */
480 }
481 483
482 /* SIGUSR2 forces udhcpc to release the current lease and go inactive,
483 * and SIGTERM causes udhcpc to exit. Signals are queued and processed
484 * sequentially so we don't need to sleep */
485 if (execute("kill -USR2 `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", ifd, exec)
486 || execute("kill -TERM `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", ifd, exec))
487 return 1;
488 if (execute("pump -i %iface% -k", ifd, exec)) return 1; 484 if (execute("pump -i %iface% -k", ifd, exec)) return 1;
489 if (execute("kill -9 `cat /var/run/dhclient.%iface%.pid` 2>/dev/null", ifd, exec)) return 1; 485 if (execute("kill -9 `cat /var/run/dhclient.%iface%.pid` 2>/dev/null",
486 ifd, exec)) return 1;
490 if (execute("dhcpcd -k %iface%", ifd, exec)) return 1; 487 if (execute("dhcpcd -k %iface%", ifd, exec)) return 1;
488
491 return static_down(ifd, exec); 489 return static_down(ifd, exec);
492} 490}
493 491
492static int manual_up_down(struct interface_defn_t *ifd, execfn *exec)
493{
494 return 1;
495}
496
494static int bootp_up(struct interface_defn_t *ifd, execfn *exec) 497static int bootp_up(struct interface_defn_t *ifd, execfn *exec)
495{ 498{
496 return execute("bootpc [[--bootfile %bootfile%]] --dev %iface% " 499 return execute("bootpc [[--bootfile %bootfile%]] --dev %iface% "
@@ -521,6 +524,7 @@ static int wvdial_down(struct interface_defn_t *ifd, execfn *exec)
521} 524}
522 525
523static const struct method_t methods[] = { 526static const struct method_t methods[] = {
527 { "manual", manual_up_down, manual_up_down, },
524 { "wvdial", wvdial_up, wvdial_down, }, 528 { "wvdial", wvdial_up, wvdial_down, },
525 { "ppp", ppp_up, ppp_down, }, 529 { "ppp", ppp_up, ppp_down, },
526 { "static", static_up, static_down, }, 530 { "static", static_up, static_down, },