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