/* vi: set sw=4 ts=4: */
/*
- * ll_types.c
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
+ * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
*/
+#include <sys/socket.h> /* linux/if_arp.h needs it on some systems */
#include <arpa/inet.h>
#include <linux/if_arp.h>
#include "libbb.h"
#include "rt_names.h"
-const char *ll_type_n2a(int type, char *buf, int len)
+const char* FAST_FUNC ll_type_n2a(int type, char *buf)
{
- static const char arphrd_name[] =
+ static const char arphrd_name[] ALIGN1 =
/* 0, */ "generic" "\0"
/* ARPHRD_LOOPBACK, */ "loopback" "\0"
/* ARPHRD_ETHER, */ "ether" "\0"
+#ifdef ARPHRD_INFINIBAND
+ /* ARPHRD_INFINIBAND, */ "infiniband" "\0"
+#endif
#ifdef ARPHRD_IEEE802_TR
/* ARPHRD_IEEE802, */ "ieee802" "\0"
/* ARPHRD_IEEE802_TR, */ "tr" "\0"
/* Keep these arrays in sync! */
- static const uint16_t arphrd_type[] = {
+ static const uint16_t arphrd_type[] ALIGN2 = {
0, /* "generic" "\0" */
ARPHRD_LOOPBACK, /* "loopback" "\0" */
ARPHRD_ETHER, /* "ether" "\0" */
+#ifdef ARPHRD_INFINIBAND
+ ARPHRD_INFINIBAND, /* "infiniband" "\0" */
+#endif
#ifdef ARPHRD_IEEE802_TR
ARPHRD_IEEE802, /* "ieee802" "\0" */
ARPHRD_IEEE802_TR, /* "tr" "\0" */
#endif /* FEATURE_IP_RARE_PROTOCOLS */
};
- int i;
+ unsigned i;
const char *aname = arphrd_name;
for (i = 0; i < ARRAY_SIZE(arphrd_type); i++) {
if (arphrd_type[i] == type)
return aname;
aname += strlen(aname) + 1;
}
- snprintf(buf, len, "[%d]", type);
+ sprintf(buf, "[%d]", type);
return buf;
}