Only included headers that are used.
[platform/upstream/busybox.git] / networking / libiproute / ll_types.c
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 #include <stdio.h>
12 #include <arpa/inet.h>
13
14 #include <linux/if_arp.h>
15
16 char * ll_type_n2a(int type, char *buf, int len)
17 {
18 #define __PF(f,n) { ARPHRD_##f, #n },
19 static struct {
20         int type;
21         char *name;
22 } arphrd_names[] = {
23 { 0, "generic" },
24 __PF(ETHER,ether)
25 __PF(EETHER,eether)
26 __PF(AX25,ax25)
27 __PF(PRONET,pronet)
28 __PF(CHAOS,chaos)
29 #ifdef ARPHRD_IEEE802_TR
30 __PF(IEEE802,ieee802)
31 #else
32 __PF(IEEE802,tr)
33 #endif
34 __PF(ARCNET,arcnet)
35 __PF(APPLETLK,atalk)
36 __PF(DLCI,dlci)
37 __PF(ATM,atm)
38 __PF(METRICOM,metricom)
39 #ifdef ARPHRD_IEEE1394
40 __PF(IEEE1394,ieee1394)
41 #endif
42
43 __PF(SLIP,slip)
44 __PF(CSLIP,cslip)
45 __PF(SLIP6,slip6)
46 __PF(CSLIP6,cslip6)
47 __PF(RSRVD,rsrvd)
48 __PF(ADAPT,adapt)
49 __PF(ROSE,rose)
50 __PF(X25,x25)
51 __PF(HWX25,hwx25)
52 __PF(PPP,ppp)
53 __PF(HDLC,hdlc)
54 __PF(LAPB,lapb)
55 __PF(DDCMP,ddcmp)
56 __PF(RAWHDLC,rawhdlc)
57
58 __PF(TUNNEL,ipip)
59 __PF(TUNNEL6,tunnel6)
60 __PF(FRAD,frad)
61 __PF(SKIP,skip)
62 __PF(LOOPBACK,loopback)
63 __PF(LOCALTLK,ltalk)
64 __PF(FDDI,fddi)
65 __PF(BIF,bif)
66 __PF(SIT,sit)
67 __PF(IPDDP,ip/ddp)
68 __PF(IPGRE,gre)
69 __PF(PIMREG,pimreg)
70 __PF(HIPPI,hippi)
71 __PF(ASH,ash)
72 __PF(ECONET,econet)
73 __PF(IRDA,irda)
74 __PF(FCPP,fcpp)
75 __PF(FCAL,fcal)
76 __PF(FCPL,fcpl)
77 __PF(FCFABRIC,fcfb0)
78 __PF(FCFABRIC+1,fcfb1)
79 __PF(FCFABRIC+2,fcfb2)
80 __PF(FCFABRIC+3,fcfb3)
81 __PF(FCFABRIC+4,fcfb4)
82 __PF(FCFABRIC+5,fcfb5)
83 __PF(FCFABRIC+6,fcfb6)
84 __PF(FCFABRIC+7,fcfb7)
85 __PF(FCFABRIC+8,fcfb8)
86 __PF(FCFABRIC+9,fcfb9)
87 __PF(FCFABRIC+10,fcfb10)
88 __PF(FCFABRIC+11,fcfb11)
89 __PF(FCFABRIC+12,fcfb12)
90 #ifdef ARPHRD_IEEE802_TR
91 __PF(IEEE802_TR,tr)
92 #endif
93 #ifdef ARPHRD_IEEE80211
94 __PF(IEEE80211,ieee802.11)
95 #endif
96 #ifdef ARPHRD_VOID
97 __PF(VOID,void)
98 #endif
99 };
100 #undef __PF
101
102         int i;
103         for (i=0; i<sizeof(arphrd_names)/sizeof(arphrd_names[0]); i++) {
104                  if (arphrd_names[i].type == type)
105                         return arphrd_names[i].name;
106         }
107         snprintf(buf, len, "[%d]", type);
108         return buf;
109 }