| 1 |
/* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 |
/* |
| 3 |
* ll_types.c |
| 4 |
* |
| 5 |
* Authors: Alexey Kuznetsov, <[email protected]> |
| 6 |
*/ |
| 7 |
|
| 8 |
#include <stdio.h> |
| 9 |
#include <stdlib.h> |
| 10 |
#include <unistd.h> |
| 11 |
#include <fcntl.h> |
| 12 |
#include <sys/ioctl.h> |
| 13 |
#include <sys/socket.h> |
| 14 |
#include <netinet/in.h> |
| 15 |
#include <arpa/inet.h> |
| 16 |
#include <string.h> |
| 17 |
|
| 18 |
#include <linux/netdevice.h> |
| 19 |
#include <linux/if_arp.h> |
| 20 |
#include <linux/sockios.h> |
| 21 |
|
| 22 |
#include "rt_names.h" |
| 23 |
#include "utils.h" |
| 24 |
|
| 25 |
const char *ll_type_n2a(int type, char *buf, int len) |
| 26 |
{ |
| 27 |
#define __PF(f,n) { ARPHRD_##f, #n }, |
| 28 |
static const struct { |
| 29 |
int type; |
| 30 |
const char *name; |
| 31 |
} arphrd_names[] = { |
| 32 |
__PF(NETROM, netrom) |
| 33 |
__PF(ETHER, ether) |
| 34 |
__PF(EETHER, eether) |
| 35 |
__PF(AX25, ax25) |
| 36 |
__PF(PRONET, pronet) |
| 37 |
__PF(CHAOS, chaos) |
| 38 |
__PF(IEEE802, ieee802) |
| 39 |
__PF(ARCNET, arcnet) |
| 40 |
__PF(APPLETLK, atalk) |
| 41 |
__PF(DLCI, dlci) |
| 42 |
__PF(ATM, atm) |
| 43 |
__PF(METRICOM, metricom) |
| 44 |
__PF(IEEE1394, ieee1394) |
| 45 |
__PF(INFINIBAND, infiniband) |
| 46 |
__PF(SLIP, slip) |
| 47 |
__PF(CSLIP, cslip) |
| 48 |
__PF(SLIP6, slip6) |
| 49 |
__PF(CSLIP6, cslip6) |
| 50 |
__PF(RSRVD, rsrvd) |
| 51 |
__PF(ADAPT, adapt) |
| 52 |
__PF(ROSE, rose) |
| 53 |
__PF(X25, x25) |
| 54 |
__PF(HWX25, hwx25) |
| 55 |
__PF(CAN, can) |
| 56 |
__PF(PPP, ppp) |
| 57 |
__PF(HDLC, hdlc) |
| 58 |
__PF(LAPB, lapb) |
| 59 |
__PF(DDCMP, ddcmp) |
| 60 |
__PF(RAWHDLC, rawhdlc) |
| 61 |
__PF(TUNNEL, ipip) |
| 62 |
__PF(TUNNEL6, tunnel6) |
| 63 |
__PF(FRAD, frad) |
| 64 |
__PF(SKIP, skip) |
| 65 |
__PF(LOOPBACK, loopback) |
| 66 |
__PF(LOCALTLK, ltalk) |
| 67 |
__PF(FDDI, fddi) |
| 68 |
__PF(BIF, bif) |
| 69 |
__PF(SIT, sit) |
| 70 |
__PF(IPDDP, ip/ddp) |
| 71 |
__PF(IPGRE, gre) |
| 72 |
__PF(PIMREG, pimreg) |
| 73 |
__PF(HIPPI, hippi) |
| 74 |
__PF(ASH, ash) |
| 75 |
__PF(ECONET, econet) |
| 76 |
__PF(IRDA, irda) |
| 77 |
__PF(FCPP, fcpp) |
| 78 |
__PF(FCAL, fcal) |
| 79 |
__PF(FCPL, fcpl) |
| 80 |
__PF(FCFABRIC, fcfb0) |
| 81 |
__PF(FCFABRIC+1, fcfb1) |
| 82 |
__PF(FCFABRIC+2, fcfb2) |
| 83 |
__PF(FCFABRIC+3, fcfb3) |
| 84 |
__PF(FCFABRIC+4, fcfb4) |
| 85 |
__PF(FCFABRIC+5, fcfb5) |
| 86 |
__PF(FCFABRIC+6, fcfb6) |
| 87 |
__PF(FCFABRIC+7, fcfb7) |
| 88 |
__PF(FCFABRIC+8, fcfb8) |
| 89 |
__PF(FCFABRIC+9, fcfb9) |
| 90 |
__PF(FCFABRIC+10, fcfb10) |
| 91 |
__PF(FCFABRIC+11, fcfb11) |
| 92 |
__PF(FCFABRIC+12, fcfb12) |
| 93 |
__PF(IEEE802_TR, tr) |
| 94 |
__PF(IEEE80211, ieee802.11) |
| 95 |
__PF(IEEE80211_PRISM, ieee802.11/prism) |
| 96 |
__PF(IEEE80211_RADIOTAP, ieee802.11/radiotap) |
| 97 |
__PF(IEEE802154, ieee802.15.4) |
| 98 |
__PF(IEEE802154_MONITOR, ieee802.15.4/monitor) |
| 99 |
__PF(PHONET, phonet) |
| 100 |
__PF(PHONET_PIPE, phonet_pipe) |
| 101 |
__PF(CAIF, caif) |
| 102 |
__PF(IP6GRE, gre6) |
| 103 |
__PF(NETLINK, netlink) |
| 104 |
__PF(6LOWPAN, 6lowpan) |
| 105 |
__PF(NONE, none) |
| 106 |
__PF(VOID, void) |
| 107 |
}; |
| 108 |
#undef __PF |
| 109 |
|
| 110 |
unsigned int i; |
| 111 |
for (i = 0; !numeric && i < ARRAY_SIZE(arphrd_names); i++) { |
| 112 |
if (arphrd_names[i].type == type) |
| 113 |
return arphrd_names[i].name; |
| 114 |
} |
| 115 |
snprintf(buf, len, "[%d]", type); |
| 116 |
return buf; |
| 117 |
} |