summaryrefslogtreecommitdiff
path: root/networking
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
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 'networking')
-rw-r--r--networking/Config.in27
-rw-r--r--networking/ifupdown.c54
2 files changed, 48 insertions, 33 deletions
diff --git a/networking/Config.in b/networking/Config.in
index a40770540..f389fe9d4 100644
--- a/networking/Config.in
+++ b/networking/Config.in
@@ -266,7 +266,7 @@ config FEATURE_IFUPDOWN_IPV4
266 default y 266 default y
267 depends on IFUPDOWN 267 depends on IFUPDOWN
268 help 268 help
269 If you want busybox to talk IPv4, leave this on. 269 If you want ifup/ifdown to talk IPv4, leave this on.
270 270
271config FEATURE_IFUPDOWN_IPV6 271config FEATURE_IFUPDOWN_IPV6
272 bool "Enable support for IPv6" 272 bool "Enable support for IPv6"
@@ -275,13 +275,14 @@ config FEATURE_IFUPDOWN_IPV6
275 help 275 help
276 If you need support for IPv6, turn this option on. 276 If you need support for IPv6, turn this option on.
277 277
278config FEATURE_IFUPDOWN_IPX 278### UNUSED
279 bool "Enable support for IPX" 279### config FEATURE_IFUPDOWN_IPX
280 default n 280### bool "Enable support for IPX"
281 depends on IFUPDOWN 281### default n
282 help 282### depends on IFUPDOWN
283 If this option is selected you can use busybox to work with IPX 283### help
284 networks. 284### If this option is selected you can use busybox to work with IPX
285### networks.
285 286
286config FEATURE_IFUPDOWN_MAPPING 287config FEATURE_IFUPDOWN_MAPPING
287 bool "Enable mapping support" 288 bool "Enable mapping support"
@@ -291,6 +292,16 @@ config FEATURE_IFUPDOWN_MAPPING
291 This enables support for the "mapping" stanza, unless you have 292 This enables support for the "mapping" stanza, unless you have
292 a weird network setup you don't need it. 293 a weird network setup you don't need it.
293 294
295config FEATURE_IFUPDOWN_EXTERNAL_DHCP
296 bool "Enable support for external dhcp clients"
297 default n
298 depends on IFUPDOWN
299 help
300 This enables support for the external dhcp clients. Clients are
301 tried in the following order: dhcpcd, dhclient, pump and udhcpc.
302 Otherwise, if udhcpc applet is enabled, it is used.
303 Otherwise, ifup/ifdown will have no support for DHCP.
304
294config INETD 305config INETD
295 bool "inetd" 306 bool "inetd"
296 default n 307 default n
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;