summaryrefslogtreecommitdiff
path: root/networking/ifupdown.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-05-02 22:04:38 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-05-02 22:04:38 +0000
commiteda43d7f454cd122d8dd2a029f48b87ab477c949 (patch)
treeb6f7c44f0e65330e2260ef3caa7ab04252790b5a /networking/ifupdown.c
parentd01ff13454ebfe93e3df79eb184818a63f3f5a1c (diff)
downloadbusybox-w32-eda43d7f454cd122d8dd2a029f48b87ab477c949.tar.gz
busybox-w32-eda43d7f454cd122d8dd2a029f48b87ab477c949.tar.bz2
busybox-w32-eda43d7f454cd122d8dd2a029f48b87ab477c949.zip
ifupdown: mke it possible to use DHCP clients different from udhcp.
Diffstat (limited to '')
-rw-r--r--networking/ifupdown.c54
1 files changed, 29 insertions, 25 deletions
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index ff4f7855b..0c822e2a1 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -439,7 +439,7 @@ static int static_down(struct interface_defn_t *ifd, execfn *exec)
439 return ((result == 2) ? 2 : 0); 439 return ((result == 2) ? 2 : 0);
440} 440}
441 441
442#if !ENABLE_APP_UDHCPC 442#if ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCP
443struct dhcp_client_t 443struct dhcp_client_t
444{ 444{
445 const char *name; 445 const char *name;
@@ -448,32 +448,28 @@ struct dhcp_client_t
448}; 448};
449 449
450static const struct dhcp_client_t ext_dhcp_clients[] = { 450static const struct dhcp_client_t ext_dhcp_clients[] = {
451 { "udhcpc", 451 { "dhcpcd",
452 "udhcpc -R -n -p /var/run/udhcpc.%iface%.pid -i %iface%[[ -H %hostname%]][[ -c %clientid%]][[ -s %script%]]", 452 "dhcpcd[[ -h %hostname%]][[ -i %vendor%]][[ -I %clientid%]][[ -l %leasetime%]] %iface%",
453 "kill -TERM `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", 453 "dhcpcd -k %iface%",
454 },
455 { "pump",
456 "pump -i %iface%[[ -h %hostname%]][[ -l %leasehours%]]",
457 "pump -i %iface% -k",
458 }, 454 },
459 { "dhclient", 455 { "dhclient",
460 "dhclient -pf /var/run/dhclient.%iface%.pid %iface%", 456 "dhclient -pf /var/run/dhclient.%iface%.pid %iface%",
461 "kill -9 `cat /var/run/dhclient.%iface%.pid` 2>/dev/null", 457 "kill -9 `cat /var/run/dhclient.%iface%.pid` 2>/dev/null",
462 }, 458 },
463 { "dhcpcd", 459 { "pump",
464 "dhcpcd[[ -h %hostname%]][[ -i %vendor%]][[ -I %clientid%]][[ -l %leasetime%]] %iface%", 460 "pump -i %iface%[[ -h %hostname%]][[ -l %leasehours%]]",
465 "dhcpcd -k %iface%", 461 "pump -i %iface% -k",
462 },
463 { "udhcpc",
464 "udhcpc -R -n -p /var/run/udhcpc.%iface%.pid -i %iface%[[ -H %hostname%]][[ -c %clientid%]][[ -s %script%]]",
465 "kill -TERM `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null",
466 }, 466 },
467}; 467};
468#endif 468#endif /* ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCPC */
469 469
470static int dhcp_up(struct interface_defn_t *ifd, execfn *exec) 470static int dhcp_up(struct interface_defn_t *ifd, execfn *exec)
471{ 471{
472#if ENABLE_APP_UDHCPC 472#if ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCP
473 return execute("udhcpc -R -n -p /var/run/udhcpc.%iface%.pid "
474 "-i %iface%[[ -H %hostname%]][[ -c %clientid%]][[ -s %script%]]",
475 ifd, exec);
476#else
477 int i, nclients = sizeof(ext_dhcp_clients) / sizeof(ext_dhcp_clients[0]); 473 int i, nclients = sizeof(ext_dhcp_clients) / sizeof(ext_dhcp_clients[0]);
478 for (i = 0; i < nclients; i++) { 474 for (i = 0; i < nclients; i++) {
479 if (exists_execable(ext_dhcp_clients[i].name)) 475 if (exists_execable(ext_dhcp_clients[i].name))
@@ -481,15 +477,18 @@ static int dhcp_up(struct interface_defn_t *ifd, execfn *exec)
481 } 477 }
482 bb_error_msg("no dhcp clients found"); 478 bb_error_msg("no dhcp clients found");
483 return 0; 479 return 0;
484#endif 480#elif ENABLE_APP_UDHCPC
481 return execute("udhcpc -R -n -p /var/run/udhcpc.%iface%.pid "
482 "-i %iface%[[ -H %hostname%]][[ -c %clientid%]][[ -s %script%]]",
483 ifd, exec);
484#else
485 return 0; /* no dhcp support */
486#endif
485} 487}
486 488
487static int dhcp_down(struct interface_defn_t *ifd, execfn *exec) 489static int dhcp_down(struct interface_defn_t *ifd, execfn *exec)
488{ 490{
489#if ENABLE_APP_UDHCPC 491#if ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCP
490 return execute("kill -TERM "
491 "`cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", ifd, exec);
492#else
493 int i, nclients = sizeof(ext_dhcp_clients) / sizeof(ext_dhcp_clients[0]); 492 int i, nclients = sizeof(ext_dhcp_clients) / sizeof(ext_dhcp_clients[0]);
494 for (i = 0; i < nclients; i++) { 493 for (i = 0; i < nclients; i++) {
495 if (exists_execable(ext_dhcp_clients[i].name)) 494 if (exists_execable(ext_dhcp_clients[i].name))
@@ -497,6 +496,11 @@ static int dhcp_down(struct interface_defn_t *ifd, execfn *exec)
497 } 496 }
498 bb_error_msg("no dhcp clients found, using static interface shutdown"); 497 bb_error_msg("no dhcp clients found, using static interface shutdown");
499 return static_down(ifd, exec); 498 return static_down(ifd, exec);
499#elif ENABLE_APP_UDHCPC
500 return execute("kill -TERM "
501 "`cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", ifd, exec);
502#else
503 return 0; /* no support for dhcp */
500#endif 504#endif
501} 505}
502 506
@@ -546,7 +550,7 @@ static const struct method_t methods[] = {
546 550
547static const struct address_family_t addr_inet = { 551static const struct address_family_t addr_inet = {
548 "inet", 552 "inet",
549 sizeof(methods) / sizeof(struct method_t), 553 sizeof(methods) / sizeof(methods[0]),
550 methods 554 methods
551}; 555};
552 556
@@ -1074,8 +1078,8 @@ static llist_t *find_iface_state(llist_t *state_list, const char *iface)
1074 llist_t *search = state_list; 1078 llist_t *search = state_list;
1075 1079
1076 while (search) { 1080 while (search) {
1077 if ((strncmp(search->data, iface, iface_len) == 0) && 1081 if ((strncmp(search->data, iface, iface_len) == 0)
1078 (search->data[iface_len] == '=')) { 1082 && (search->data[iface_len] == '=')) {
1079 return search; 1083 return search;
1080 } 1084 }
1081 search = search->link; 1085 search = search->link;