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