diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2008-05-16 16:10:31 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2008-05-16 16:10:31 +0000 |
commit | f3b778a4dcfe49dbb294365e7f026674a91f9a32 (patch) | |
tree | d68b08af40a70399b5027949541d1f08696d4925 | |
parent | 825968f92c603357e2e1e1d73c3ec26d89004381 (diff) | |
download | busybox-w32-f3b778a4dcfe49dbb294365e7f026674a91f9a32.tar.gz busybox-w32-f3b778a4dcfe49dbb294365e7f026674a91f9a32.tar.bz2 busybox-w32-f3b778a4dcfe49dbb294365e7f026674a91f9a32.zip |
- fix bug where we incorrectly rejected ifconfig eth0 hw ether $whatever
- add support for printing ipoib to ifconfig
-rw-r--r-- | include/libbb.h | 3 | ||||
-rw-r--r-- | include/usage.h | 2 | ||||
-rw-r--r-- | libbb/Config.in | 7 | ||||
-rw-r--r-- | networking/ifconfig.c | 14 | ||||
-rw-r--r-- | networking/interface.c | 82 | ||||
-rw-r--r-- | scripts/defconfig | 1 |
6 files changed, 105 insertions, 4 deletions
diff --git a/include/libbb.h b/include/libbb.h index 216b3eca3..6f41184a9 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -924,6 +924,9 @@ struct hwtype { | |||
924 | }; | 924 | }; |
925 | extern smallint interface_opt_a; | 925 | extern smallint interface_opt_a; |
926 | int display_interfaces(char *ifname); | 926 | int display_interfaces(char *ifname); |
927 | #if ENABLE_FEATURE_HWIB | ||
928 | int in_ib(const char *bufp, struct sockaddr *sap); | ||
929 | #endif | ||
927 | const struct aftype *get_aftype(const char *name); | 930 | const struct aftype *get_aftype(const char *name); |
928 | const struct hwtype *get_hwtype(const char *name); | 931 | const struct hwtype *get_hwtype(const char *name); |
929 | const struct hwtype *get_hwntype(int type); | 932 | const struct hwtype *get_hwntype(int type); |
diff --git a/include/usage.h b/include/usage.h index efba0924a..f912d7b88 100644 --- a/include/usage.h +++ b/include/usage.h | |||
@@ -1628,7 +1628,7 @@ | |||
1628 | " [netmask ADDRESS] [dstaddr ADDRESS]\n" \ | 1628 | " [netmask ADDRESS] [dstaddr ADDRESS]\n" \ |
1629 | USE_FEATURE_IFCONFIG_SLIP( \ | 1629 | USE_FEATURE_IFCONFIG_SLIP( \ |
1630 | " [outfill NN] [keepalive NN]\n") \ | 1630 | " [outfill NN] [keepalive NN]\n") \ |
1631 | " " USE_FEATURE_IFCONFIG_HW("[hw ether ADDRESS] ") "[metric NN] [mtu NN]\n" \ | 1631 | " " USE_FEATURE_IFCONFIG_HW("[hw ether" USE_FEATURE_HWIB("|infiniband")" ADDRESS] ") "[metric NN] [mtu NN]\n" \ |
1632 | " [[-]trailers] [[-]arp] [[-]allmulti]\n" \ | 1632 | " [[-]trailers] [[-]arp] [[-]allmulti]\n" \ |
1633 | " [multicast] [[-]promisc] [txqueuelen NN] [[-]dynamic]\n" \ | 1633 | " [multicast] [[-]promisc] [txqueuelen NN] [[-]dynamic]\n" \ |
1634 | USE_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ( \ | 1634 | USE_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ( \ |
diff --git a/libbb/Config.in b/libbb/Config.in index 842dd1f74..5bf0d2ea2 100644 --- a/libbb/Config.in +++ b/libbb/Config.in | |||
@@ -144,4 +144,11 @@ config IOCTL_HEX2STR_ERROR | |||
144 | Use ioctl names rather than hex values in error messages | 144 | Use ioctl names rather than hex values in error messages |
145 | (e.g. VT_DISALLOCATE rather than 0x5608). If disabled this | 145 | (e.g. VT_DISALLOCATE rather than 0x5608). If disabled this |
146 | saves about 1400 bytes. | 146 | saves about 1400 bytes. |
147 | |||
148 | config FEATURE_HWIB | ||
149 | bool "Support infiniband HW" | ||
150 | default y | ||
151 | help | ||
152 | Support for printing infiniband addresses in | ||
153 | network applets. | ||
147 | endmenu | 154 | endmenu |
diff --git a/networking/ifconfig.c b/networking/ifconfig.c index 9e95533cc..d02175783 100644 --- a/networking/ifconfig.c +++ b/networking/ifconfig.c | |||
@@ -220,7 +220,7 @@ static const struct options OptArray[] = { | |||
220 | { "netmask", N_ARG, ARG_NETMASK, 0 }, | 220 | { "netmask", N_ARG, ARG_NETMASK, 0 }, |
221 | { "broadcast", N_ARG | M_CLR, ARG_BROADCAST, IFF_BROADCAST }, | 221 | { "broadcast", N_ARG | M_CLR, ARG_BROADCAST, IFF_BROADCAST }, |
222 | #if ENABLE_FEATURE_IFCONFIG_HW | 222 | #if ENABLE_FEATURE_IFCONFIG_HW |
223 | { "hw", N_ARG, ARG_HW, 0 }, | 223 | { "hw", N_ARG, ARG_HW, 0 }, |
224 | #endif | 224 | #endif |
225 | { "pointopoint", N_ARG | M_CLR, ARG_POINTOPOINT, IFF_POINTOPOINT }, | 225 | { "pointopoint", N_ARG | M_CLR, ARG_POINTOPOINT, IFF_POINTOPOINT }, |
226 | #ifdef SIOCSKEEPALIVE | 226 | #ifdef SIOCSKEEPALIVE |
@@ -255,6 +255,11 @@ static const struct options OptArray[] = { | |||
255 | 255 | ||
256 | #if ENABLE_FEATURE_IFCONFIG_HW | 256 | #if ENABLE_FEATURE_IFCONFIG_HW |
257 | static int in_ether(const char *bufp, struct sockaddr *sap); | 257 | static int in_ether(const char *bufp, struct sockaddr *sap); |
258 | # if ENABLE_FEATURE_HWIB | ||
259 | extern int in_ib(const char *bufp, struct sockaddr *sap); | ||
260 | # else | ||
261 | # define in_ib(a, b) 1 /* fail */ | ||
262 | # endif | ||
258 | #endif | 263 | #endif |
259 | 264 | ||
260 | /* | 265 | /* |
@@ -425,11 +430,14 @@ int ifconfig_main(int argc, char **argv) | |||
425 | #if ENABLE_FEATURE_IFCONFIG_HW | 430 | #if ENABLE_FEATURE_IFCONFIG_HW |
426 | } else { /* A_CAST_HOST_COPY_IN_ETHER */ | 431 | } else { /* A_CAST_HOST_COPY_IN_ETHER */ |
427 | /* This is the "hw" arg case. */ | 432 | /* This is the "hw" arg case. */ |
428 | if (strcmp("ether", *argv) || !*++argv) | 433 | smalluint hw_class= index_in_substrings("ether\0" |
434 | USE_FEATURE_HWIB("infiniband\0"), *argv) + 1; | ||
435 | if (!hw_class || !*++argv) | ||
429 | bb_show_usage(); | 436 | bb_show_usage(); |
430 | /*safe_strncpy(host, *argv, sizeof(host));*/ | 437 | /*safe_strncpy(host, *argv, sizeof(host));*/ |
431 | host = *argv; | 438 | host = *argv; |
432 | if (in_ether(host, &sa)) | 439 | if (hw_class == 1 ? in_ether(host, &sa) |
440 | : in_ib(host, &sa)) | ||
433 | bb_error_msg_and_die("invalid hw-addr %s", host); | 441 | bb_error_msg_and_die("invalid hw-addr %s", host); |
434 | p = (char *) &sa; | 442 | p = (char *) &sa; |
435 | } | 443 | } |
diff --git a/networking/interface.c b/networking/interface.c index a24ab01fe..dff6add20 100644 --- a/networking/interface.c +++ b/networking/interface.c | |||
@@ -36,6 +36,13 @@ | |||
36 | #include "inet_common.h" | 36 | #include "inet_common.h" |
37 | #include "libbb.h" | 37 | #include "libbb.h" |
38 | 38 | ||
39 | |||
40 | #if ENABLE_FEATURE_HWIB | ||
41 | /* #include <linux/if_infiniband.h> */ | ||
42 | #undef INFINIBAND_ALEN | ||
43 | #define INFINIBAND_ALEN 20 | ||
44 | #endif | ||
45 | |||
39 | #if ENABLE_FEATURE_IPV6 | 46 | #if ENABLE_FEATURE_IPV6 |
40 | # define HAVE_AFINET6 1 | 47 | # define HAVE_AFINET6 1 |
41 | #else | 48 | #else |
@@ -805,6 +812,17 @@ static const struct hwtype sit_hwtype = { | |||
805 | .suppress_null_addr = 1 | 812 | .suppress_null_addr = 1 |
806 | }; | 813 | }; |
807 | #endif | 814 | #endif |
815 | #if ENABLE_FEATURE_HWIB | ||
816 | static const struct hwtype ib_hwtype = { | ||
817 | .name = "infiniband", | ||
818 | .title = "InfiniBand", | ||
819 | .type = ARPHRD_INFINIBAND, | ||
820 | .alen = INFINIBAND_ALEN, | ||
821 | .print = UNSPEC_print, | ||
822 | .input = in_ib, | ||
823 | }; | ||
824 | #endif | ||
825 | |||
808 | 826 | ||
809 | static const struct hwtype *const hwtypes[] = { | 827 | static const struct hwtype *const hwtypes[] = { |
810 | &loop_hwtype, | 828 | &loop_hwtype, |
@@ -814,6 +832,9 @@ static const struct hwtype *const hwtypes[] = { | |||
814 | #if ENABLE_FEATURE_IPV6 | 832 | #if ENABLE_FEATURE_IPV6 |
815 | &sit_hwtype, | 833 | &sit_hwtype, |
816 | #endif | 834 | #endif |
835 | #if ENABLE_FEATURE_HWIB | ||
836 | &ib_hwtype, | ||
837 | #endif | ||
817 | NULL | 838 | NULL |
818 | }; | 839 | }; |
819 | 840 | ||
@@ -1192,6 +1213,67 @@ static int if_print(char *ifname) | |||
1192 | return res; | 1213 | return res; |
1193 | } | 1214 | } |
1194 | 1215 | ||
1216 | #if ENABLE_FEATURE_HWIB | ||
1217 | /* Input an Infiniband address and convert to binary. */ | ||
1218 | int in_ib(const char *bufp, struct sockaddr *sap) | ||
1219 | { | ||
1220 | unsigned char *ptr; | ||
1221 | char c; | ||
1222 | const char *orig; | ||
1223 | int i; | ||
1224 | unsigned val; | ||
1225 | |||
1226 | sap->sa_family = ib_hwtype.type; | ||
1227 | ptr = sap->sa_data; | ||
1228 | |||
1229 | i = 0; | ||
1230 | orig = bufp; | ||
1231 | while ((*bufp != '\0') && (i < INFINIBAND_ALEN)) { | ||
1232 | val = 0; | ||
1233 | c = *bufp++; | ||
1234 | if (isdigit(c)) | ||
1235 | val = c - '0'; | ||
1236 | else if (c >= 'a' && c <= 'f') | ||
1237 | val = c - 'a' + 10; | ||
1238 | else if (c >= 'A' && c <= 'F') | ||
1239 | val = c - 'A' + 10; | ||
1240 | else { | ||
1241 | errno = EINVAL; | ||
1242 | return (-1); | ||
1243 | } | ||
1244 | val <<= 4; | ||
1245 | c = *bufp; | ||
1246 | if (isdigit(c)) | ||
1247 | val |= c - '0'; | ||
1248 | else if (c >= 'a' && c <= 'f') | ||
1249 | val |= c - 'a' + 10; | ||
1250 | else if (c >= 'A' && c <= 'F') | ||
1251 | val |= c - 'A' + 10; | ||
1252 | else if (c == ':' || c == 0) | ||
1253 | val >>= 4; | ||
1254 | else { | ||
1255 | errno = EINVAL; | ||
1256 | return (-1); | ||
1257 | } | ||
1258 | if (c != 0) | ||
1259 | bufp++; | ||
1260 | *ptr++ = (unsigned char) (val & 0377); | ||
1261 | i++; | ||
1262 | |||
1263 | /* We might get a semicolon here - not required. */ | ||
1264 | if (*bufp == ':') { | ||
1265 | bufp++; | ||
1266 | } | ||
1267 | } | ||
1268 | #ifdef DEBUG | ||
1269 | fprintf(stderr, "in_ib(%s): %s\n", orig, UNSPEC_print(sap->sa_data)); | ||
1270 | #endif | ||
1271 | return (0); | ||
1272 | } | ||
1273 | #endif | ||
1274 | |||
1275 | |||
1276 | |||
1195 | int display_interfaces(char *ifname) | 1277 | int display_interfaces(char *ifname) |
1196 | { | 1278 | { |
1197 | int status; | 1279 | int status; |
diff --git a/scripts/defconfig b/scripts/defconfig index 007c7609b..93b71667a 100644 --- a/scripts/defconfig +++ b/scripts/defconfig | |||
@@ -86,6 +86,7 @@ CONFIG_FEATURE_TAB_COMPLETION=y | |||
86 | CONFIG_FEATURE_COPYBUF_KB=4 | 86 | CONFIG_FEATURE_COPYBUF_KB=4 |
87 | # CONFIG_MONOTONIC_SYSCALL is not set | 87 | # CONFIG_MONOTONIC_SYSCALL is not set |
88 | CONFIG_IOCTL_HEX2STR_ERROR=y | 88 | CONFIG_IOCTL_HEX2STR_ERROR=y |
89 | CONFIG_FEATURE_HWIB=y | ||
89 | 90 | ||
90 | # | 91 | # |
91 | # Applets | 92 | # Applets |