ifupdown: mke it possible to use DHCP clients different from udhcp.
This commit is contained in:
parent
d01ff13454
commit
eda43d7f45
@ -266,7 +266,7 @@ config FEATURE_IFUPDOWN_IPV4
|
|||||||
default y
|
default y
|
||||||
depends on IFUPDOWN
|
depends on IFUPDOWN
|
||||||
help
|
help
|
||||||
If you want busybox to talk IPv4, leave this on.
|
If you want ifup/ifdown to talk IPv4, leave this on.
|
||||||
|
|
||||||
config FEATURE_IFUPDOWN_IPV6
|
config FEATURE_IFUPDOWN_IPV6
|
||||||
bool "Enable support for IPv6"
|
bool "Enable support for IPv6"
|
||||||
@ -275,13 +275,14 @@ config FEATURE_IFUPDOWN_IPV6
|
|||||||
help
|
help
|
||||||
If you need support for IPv6, turn this option on.
|
If you need support for IPv6, turn this option on.
|
||||||
|
|
||||||
config FEATURE_IFUPDOWN_IPX
|
### UNUSED
|
||||||
bool "Enable support for IPX"
|
### config FEATURE_IFUPDOWN_IPX
|
||||||
default n
|
### bool "Enable support for IPX"
|
||||||
depends on IFUPDOWN
|
### default n
|
||||||
help
|
### depends on IFUPDOWN
|
||||||
If this option is selected you can use busybox to work with IPX
|
### help
|
||||||
networks.
|
### If this option is selected you can use busybox to work with IPX
|
||||||
|
### networks.
|
||||||
|
|
||||||
config FEATURE_IFUPDOWN_MAPPING
|
config FEATURE_IFUPDOWN_MAPPING
|
||||||
bool "Enable mapping support"
|
bool "Enable mapping support"
|
||||||
@ -291,6 +292,16 @@ config FEATURE_IFUPDOWN_MAPPING
|
|||||||
This enables support for the "mapping" stanza, unless you have
|
This enables support for the "mapping" stanza, unless you have
|
||||||
a weird network setup you don't need it.
|
a weird network setup you don't need it.
|
||||||
|
|
||||||
|
config FEATURE_IFUPDOWN_EXTERNAL_DHCP
|
||||||
|
bool "Enable support for external dhcp clients"
|
||||||
|
default n
|
||||||
|
depends on IFUPDOWN
|
||||||
|
help
|
||||||
|
This enables support for the external dhcp clients. Clients are
|
||||||
|
tried in the following order: dhcpcd, dhclient, pump and udhcpc.
|
||||||
|
Otherwise, if udhcpc applet is enabled, it is used.
|
||||||
|
Otherwise, ifup/ifdown will have no support for DHCP.
|
||||||
|
|
||||||
config INETD
|
config INETD
|
||||||
bool "inetd"
|
bool "inetd"
|
||||||
default n
|
default n
|
||||||
|
@ -439,7 +439,7 @@ static int static_down(struct interface_defn_t *ifd, execfn *exec)
|
|||||||
return ((result == 2) ? 2 : 0);
|
return ((result == 2) ? 2 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !ENABLE_APP_UDHCPC
|
#if ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCP
|
||||||
struct dhcp_client_t
|
struct dhcp_client_t
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
@ -448,32 +448,28 @@ struct dhcp_client_t
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const struct dhcp_client_t ext_dhcp_clients[] = {
|
static const struct dhcp_client_t ext_dhcp_clients[] = {
|
||||||
{ "udhcpc",
|
{ "dhcpcd",
|
||||||
"udhcpc -R -n -p /var/run/udhcpc.%iface%.pid -i %iface%[[ -H %hostname%]][[ -c %clientid%]][[ -s %script%]]",
|
"dhcpcd[[ -h %hostname%]][[ -i %vendor%]][[ -I %clientid%]][[ -l %leasetime%]] %iface%",
|
||||||
"kill -TERM `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null",
|
"dhcpcd -k %iface%",
|
||||||
},
|
|
||||||
{ "pump",
|
|
||||||
"pump -i %iface%[[ -h %hostname%]][[ -l %leasehours%]]",
|
|
||||||
"pump -i %iface% -k",
|
|
||||||
},
|
},
|
||||||
{ "dhclient",
|
{ "dhclient",
|
||||||
"dhclient -pf /var/run/dhclient.%iface%.pid %iface%",
|
"dhclient -pf /var/run/dhclient.%iface%.pid %iface%",
|
||||||
"kill -9 `cat /var/run/dhclient.%iface%.pid` 2>/dev/null",
|
"kill -9 `cat /var/run/dhclient.%iface%.pid` 2>/dev/null",
|
||||||
},
|
},
|
||||||
{ "dhcpcd",
|
{ "pump",
|
||||||
"dhcpcd[[ -h %hostname%]][[ -i %vendor%]][[ -I %clientid%]][[ -l %leasetime%]] %iface%",
|
"pump -i %iface%[[ -h %hostname%]][[ -l %leasehours%]]",
|
||||||
"dhcpcd -k %iface%",
|
"pump -i %iface% -k",
|
||||||
|
},
|
||||||
|
{ "udhcpc",
|
||||||
|
"udhcpc -R -n -p /var/run/udhcpc.%iface%.pid -i %iface%[[ -H %hostname%]][[ -c %clientid%]][[ -s %script%]]",
|
||||||
|
"kill -TERM `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
#endif
|
#endif /* ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCPC */
|
||||||
|
|
||||||
static int dhcp_up(struct interface_defn_t *ifd, execfn *exec)
|
static int dhcp_up(struct interface_defn_t *ifd, execfn *exec)
|
||||||
{
|
{
|
||||||
#if ENABLE_APP_UDHCPC
|
#if ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCP
|
||||||
return execute("udhcpc -R -n -p /var/run/udhcpc.%iface%.pid "
|
|
||||||
"-i %iface%[[ -H %hostname%]][[ -c %clientid%]][[ -s %script%]]",
|
|
||||||
ifd, exec);
|
|
||||||
#else
|
|
||||||
int i, nclients = sizeof(ext_dhcp_clients) / sizeof(ext_dhcp_clients[0]);
|
int i, nclients = sizeof(ext_dhcp_clients) / sizeof(ext_dhcp_clients[0]);
|
||||||
for (i = 0; i < nclients; i++) {
|
for (i = 0; i < nclients; i++) {
|
||||||
if (exists_execable(ext_dhcp_clients[i].name))
|
if (exists_execable(ext_dhcp_clients[i].name))
|
||||||
@ -481,15 +477,18 @@ static int dhcp_up(struct interface_defn_t *ifd, execfn *exec)
|
|||||||
}
|
}
|
||||||
bb_error_msg("no dhcp clients found");
|
bb_error_msg("no dhcp clients found");
|
||||||
return 0;
|
return 0;
|
||||||
|
#elif ENABLE_APP_UDHCPC
|
||||||
|
return execute("udhcpc -R -n -p /var/run/udhcpc.%iface%.pid "
|
||||||
|
"-i %iface%[[ -H %hostname%]][[ -c %clientid%]][[ -s %script%]]",
|
||||||
|
ifd, exec);
|
||||||
|
#else
|
||||||
|
return 0; /* no dhcp support */
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dhcp_down(struct interface_defn_t *ifd, execfn *exec)
|
static int dhcp_down(struct interface_defn_t *ifd, execfn *exec)
|
||||||
{
|
{
|
||||||
#if ENABLE_APP_UDHCPC
|
#if ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCP
|
||||||
return execute("kill -TERM "
|
|
||||||
"`cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", ifd, exec);
|
|
||||||
#else
|
|
||||||
int i, nclients = sizeof(ext_dhcp_clients) / sizeof(ext_dhcp_clients[0]);
|
int i, nclients = sizeof(ext_dhcp_clients) / sizeof(ext_dhcp_clients[0]);
|
||||||
for (i = 0; i < nclients; i++) {
|
for (i = 0; i < nclients; i++) {
|
||||||
if (exists_execable(ext_dhcp_clients[i].name))
|
if (exists_execable(ext_dhcp_clients[i].name))
|
||||||
@ -497,6 +496,11 @@ static int dhcp_down(struct interface_defn_t *ifd, execfn *exec)
|
|||||||
}
|
}
|
||||||
bb_error_msg("no dhcp clients found, using static interface shutdown");
|
bb_error_msg("no dhcp clients found, using static interface shutdown");
|
||||||
return static_down(ifd, exec);
|
return static_down(ifd, exec);
|
||||||
|
#elif ENABLE_APP_UDHCPC
|
||||||
|
return execute("kill -TERM "
|
||||||
|
"`cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", ifd, exec);
|
||||||
|
#else
|
||||||
|
return 0; /* no support for dhcp */
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -546,7 +550,7 @@ static const struct method_t methods[] = {
|
|||||||
|
|
||||||
static const struct address_family_t addr_inet = {
|
static const struct address_family_t addr_inet = {
|
||||||
"inet",
|
"inet",
|
||||||
sizeof(methods) / sizeof(struct method_t),
|
sizeof(methods) / sizeof(methods[0]),
|
||||||
methods
|
methods
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1074,8 +1078,8 @@ static llist_t *find_iface_state(llist_t *state_list, const char *iface)
|
|||||||
llist_t *search = state_list;
|
llist_t *search = state_list;
|
||||||
|
|
||||||
while (search) {
|
while (search) {
|
||||||
if ((strncmp(search->data, iface, iface_len) == 0) &&
|
if ((strncmp(search->data, iface, iface_len) == 0)
|
||||||
(search->data[iface_len] == '=')) {
|
&& (search->data[iface_len] == '=')) {
|
||||||
return search;
|
return search;
|
||||||
}
|
}
|
||||||
search = search->link;
|
search = search->link;
|
||||||
|
Loading…
Reference in New Issue
Block a user