aboutsummaryrefslogtreecommitdiff
path: root/networking/interface.c
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2008-05-16 16:10:31 +0000
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2008-05-16 16:10:31 +0000
commitf3b778a4dcfe49dbb294365e7f026674a91f9a32 (patch)
treed68b08af40a70399b5027949541d1f08696d4925 /networking/interface.c
parent825968f92c603357e2e1e1d73c3ec26d89004381 (diff)
downloadbusybox-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
Diffstat (limited to 'networking/interface.c')
-rw-r--r--networking/interface.c82
1 files changed, 82 insertions, 0 deletions
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
816static 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
809static const struct hwtype *const hwtypes[] = { 827static 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. */
1218int 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
1269fprintf(stderr, "in_ib(%s): %s\n", orig, UNSPEC_print(sap->sa_data));
1270#endif
1271 return (0);
1272}
1273#endif
1274
1275
1276
1195int display_interfaces(char *ifname) 1277int display_interfaces(char *ifname)
1196{ 1278{
1197 int status; 1279 int status;