diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-11-01 00:10:51 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-11-01 00:10:51 +0000 |
| commit | 44d5dcebc6d3d896e8a5de07cb57913d961067c8 (patch) | |
| tree | 41dd0bcbc7569f16f3964b09bc5ebeb5f9176024 | |
| parent | 64974793b9fe0921c43e604de747caf7d32f671c (diff) | |
| download | busybox-w32-44d5dcebc6d3d896e8a5de07cb57913d961067c8.tar.gz busybox-w32-44d5dcebc6d3d896e8a5de07cb57913d961067c8.tar.bz2 busybox-w32-44d5dcebc6d3d896e8a5de07cb57913d961067c8.zip | |
iplink: accept shorthands for "address" keyword here:
"ip link set address 00:11:22:33:44:55"
ifupdown: use "addr" instead of "address"
| -rw-r--r-- | networking/ifupdown.c | 8 | ||||
| -rw-r--r-- | networking/libiproute/iplink.c | 11 |
2 files changed, 11 insertions, 8 deletions
diff --git a/networking/ifupdown.c b/networking/ifupdown.c index c232d86a6..d7cb40f32 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c | |||
| @@ -349,7 +349,7 @@ static int static_up6(struct interface_defn_t *ifd, execfn *exec) | |||
| 349 | int result; | 349 | int result; |
| 350 | #if ENABLE_FEATURE_IFUPDOWN_IP | 350 | #if ENABLE_FEATURE_IFUPDOWN_IP |
| 351 | result = execute("ip addr add %address%/%netmask% dev %iface%[[ label %label%]]", ifd, exec); | 351 | result = execute("ip addr add %address%/%netmask% dev %iface%[[ label %label%]]", ifd, exec); |
| 352 | result += execute("ip link set[[ mtu %mtu%]][[ address %hwaddress%]] %iface% up", ifd, exec); | 352 | result += execute("ip link set[[ mtu %mtu%]][[ addr %hwaddress%]] %iface% up", ifd, exec); |
| 353 | /* Was: "[[ ip ....%gateway% ]]". Removed extra spaces w/o checking */ | 353 | /* Was: "[[ ip ....%gateway% ]]". Removed extra spaces w/o checking */ |
| 354 | result += execute("[[ip route add ::/0 via %gateway%]]", ifd, exec); | 354 | result += execute("[[ip route add ::/0 via %gateway%]]", ifd, exec); |
| 355 | #else | 355 | #else |
| @@ -433,7 +433,7 @@ static int static_up(struct interface_defn_t *ifd, execfn *exec) | |||
| 433 | #if ENABLE_FEATURE_IFUPDOWN_IP | 433 | #if ENABLE_FEATURE_IFUPDOWN_IP |
| 434 | result = execute("ip addr add %address%/%bnmask%[[ broadcast %broadcast%]] " | 434 | result = execute("ip addr add %address%/%bnmask%[[ broadcast %broadcast%]] " |
| 435 | "dev %iface%[[ peer %pointopoint%]][[ label %label%]]", ifd, exec); | 435 | "dev %iface%[[ peer %pointopoint%]][[ label %label%]]", ifd, exec); |
| 436 | result += execute("ip link set[[ mtu %mtu%]][[ address %hwaddress%]] %iface% up", ifd, exec); | 436 | result += execute("ip link set[[ mtu %mtu%]][[ addr %hwaddress%]] %iface% up", ifd, exec); |
| 437 | result += execute("[[ip route add default via %gateway% dev %iface%]]", ifd, exec); | 437 | result += execute("[[ip route add default via %gateway% dev %iface%]]", ifd, exec); |
| 438 | return ((result == 3) ? 3 : 0); | 438 | return ((result == 3) ? 3 : 0); |
| 439 | #else | 439 | #else |
| @@ -500,7 +500,7 @@ static int dhcp_up(struct interface_defn_t *ifd, execfn *exec) | |||
| 500 | unsigned i; | 500 | unsigned i; |
| 501 | #if ENABLE_FEATURE_IFUPDOWN_IP | 501 | #if ENABLE_FEATURE_IFUPDOWN_IP |
| 502 | /* ip doesn't up iface when it configures it (unlike ifconfig) */ | 502 | /* ip doesn't up iface when it configures it (unlike ifconfig) */ |
| 503 | if (!execute("ip link set[[ address %hwaddress%]] %iface% up", ifd, exec)) | 503 | if (!execute("ip link set[[ addr %hwaddress%]] %iface% up", ifd, exec)) |
| 504 | return 0; | 504 | return 0; |
| 505 | #else | 505 | #else |
| 506 | /* needed if we have hwaddress on dhcp iface */ | 506 | /* needed if we have hwaddress on dhcp iface */ |
| @@ -519,7 +519,7 @@ static int dhcp_up(struct interface_defn_t *ifd, execfn *exec) | |||
| 519 | { | 519 | { |
| 520 | #if ENABLE_FEATURE_IFUPDOWN_IP | 520 | #if ENABLE_FEATURE_IFUPDOWN_IP |
| 521 | /* ip doesn't up iface when it configures it (unlike ifconfig) */ | 521 | /* ip doesn't up iface when it configures it (unlike ifconfig) */ |
| 522 | if (!execute("ip link set[[ address %hwaddress%]] %iface% up", ifd, exec)) | 522 | if (!execute("ip link set[[ addr %hwaddress%]] %iface% up", ifd, exec)) |
| 523 | return 0; | 523 | return 0; |
| 524 | #else | 524 | #else |
| 525 | /* needed if we have hwaddress on dhcp iface */ | 525 | /* needed if we have hwaddress on dhcp iface */ |
diff --git a/networking/libiproute/iplink.c b/networking/libiproute/iplink.c index dc936bdc5..8de17bfc6 100644 --- a/networking/libiproute/iplink.c +++ b/networking/libiproute/iplink.c | |||
| @@ -174,15 +174,18 @@ static int do_set(char **argv) | |||
| 174 | char *newname = NULL; | 174 | char *newname = NULL; |
| 175 | int htype, halen; | 175 | int htype, halen; |
| 176 | static const char keywords[] ALIGN1 = | 176 | static const char keywords[] ALIGN1 = |
| 177 | "up\0""down\0""name\0""mtu\0""multicast\0""arp\0""address\0""dev\0"; | 177 | "up\0""down\0""name\0""mtu\0""multicast\0" |
| 178 | enum { ARG_up = 0, ARG_down, ARG_name, ARG_mtu, ARG_multicast, ARG_arp, | 178 | "arp\0""address\0""dev\0"; |
| 179 | ARG_addr, ARG_dev }; | 179 | enum { ARG_up = 0, ARG_down, ARG_name, ARG_mtu, ARG_multicast, |
| 180 | ARG_arp, ARG_addr, ARG_dev }; | ||
| 180 | static const char str_on_off[] ALIGN1 = "on\0""off\0"; | 181 | static const char str_on_off[] ALIGN1 = "on\0""off\0"; |
| 181 | enum { PARM_on = 0, PARM_off }; | 182 | enum { PARM_on = 0, PARM_off }; |
| 182 | smalluint key; | 183 | smalluint key; |
| 183 | 184 | ||
| 184 | while (*argv) { | 185 | while (*argv) { |
| 185 | key = index_in_strings(keywords, *argv); | 186 | /* substring search ensures that e.g. "addr" and "address" |
| 187 | * are both accepted */ | ||
| 188 | key = index_in_substrings(keywords, *argv); | ||
| 186 | if (key == ARG_up) { | 189 | if (key == ARG_up) { |
| 187 | mask |= IFF_UP; | 190 | mask |= IFF_UP; |
| 188 | flags |= IFF_UP; | 191 | flags |= IFF_UP; |
