This commit was manufactured by cvs2svn to create tag 'busybox_1_00'.
[oweals/busybox.git] / busybox / 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 #ifdef ARPHRD_ATM
38 __PF(ATM,atm)
39 #endif
40 __PF(METRICOM,metricom)
41 #ifdef ARPHRD_IEEE1394
42 __PF(IEEE1394,ieee1394)
43 #endif
44
45 __PF(SLIP,slip)
46 __PF(CSLIP,cslip)
47 __PF(SLIP6,slip6)
48 __PF(CSLIP6,cslip6)
49 __PF(RSRVD,rsrvd)
50 __PF(ADAPT,adapt)
51 __PF(ROSE,rose)
52 __PF(X25,x25)
53 #ifdef ARPHRD_HWX25
54 __PF(HWX25,hwx25)
55 #endif
56 __PF(PPP,ppp)
57 __PF(HDLC,hdlc)
58 __PF(LAPB,lapb)
59 #ifdef ARPHRD_DDCMP
60 __PF(DDCMP,ddcmp)
61 __PF(RAWHDLC,rawhdlc)
62 #endif
63
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 #ifdef ARPHRD_IEEE802_TR
97 __PF(IEEE802_TR,tr)
98 #endif
99 #ifdef ARPHRD_IEEE80211
100 __PF(IEEE80211,ieee802.11)
101 #endif
102 #ifdef ARPHRD_VOID
103 __PF(VOID,void)
104 #endif
105 };
106 #undef __PF
107
108         int i;
109         for (i=0; i<sizeof(arphrd_names)/sizeof(arphrd_names[0]); i++) {
110                  if (arphrd_names[i].type == type)
111                         return arphrd_names[i].name;
112         }
113         snprintf(buf, len, "[%d]", type);
114         return buf;
115 }