whitespace cleanup
[oweals/busybox.git] / networking / libiproute / ll_types.c
1 /* vi: set sw=4 ts=4: */
2 /*
3  * This program is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU General Public License
5  * as published by the Free Software Foundation; either version
6  * 2 of the License, or (at your option) any later version.
7  *
8  * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
9  */
10 #include <arpa/inet.h>
11 #include <linux/if_arp.h>
12
13 #include "libbb.h"
14 #include "rt_names.h"
15
16 const char* FAST_FUNC ll_type_n2a(int type, char *buf)
17 {
18         static const char arphrd_name[] =
19         /* 0,                  */ "generic" "\0"
20         /* ARPHRD_LOOPBACK,    */ "loopback" "\0"
21         /* ARPHRD_ETHER,       */ "ether" "\0"
22 #ifdef ARPHRD_INFINIBAND
23         /* ARPHRD_INFINIBAND,  */ "infiniband" "\0"
24 #endif
25 #ifdef ARPHRD_IEEE802_TR
26         /* ARPHRD_IEEE802,     */ "ieee802" "\0"
27         /* ARPHRD_IEEE802_TR,  */ "tr" "\0"
28 #else
29         /* ARPHRD_IEEE802,     */ "tr" "\0"
30 #endif
31 #ifdef ARPHRD_IEEE80211
32         /* ARPHRD_IEEE80211,   */ "ieee802.11" "\0"
33 #endif
34 #ifdef ARPHRD_IEEE1394
35         /* ARPHRD_IEEE1394,    */ "ieee1394" "\0"
36 #endif
37         /* ARPHRD_IRDA,        */ "irda" "\0"
38         /* ARPHRD_SLIP,        */ "slip" "\0"
39         /* ARPHRD_CSLIP,       */ "cslip" "\0"
40         /* ARPHRD_SLIP6,       */ "slip6" "\0"
41         /* ARPHRD_CSLIP6,      */ "cslip6" "\0"
42         /* ARPHRD_PPP,         */ "ppp" "\0"
43         /* ARPHRD_TUNNEL,      */ "ipip" "\0"
44         /* ARPHRD_TUNNEL6,     */ "tunnel6" "\0"
45         /* ARPHRD_SIT,         */ "sit" "\0"
46         /* ARPHRD_IPGRE,       */ "gre" "\0"
47 #ifdef ARPHRD_VOID
48         /* ARPHRD_VOID,        */ "void" "\0"
49 #endif
50
51 #if ENABLE_FEATURE_IP_RARE_PROTOCOLS
52         /* ARPHRD_EETHER,      */ "eether" "\0"
53         /* ARPHRD_AX25,        */ "ax25" "\0"
54         /* ARPHRD_PRONET,      */ "pronet" "\0"
55         /* ARPHRD_CHAOS,       */ "chaos" "\0"
56         /* ARPHRD_ARCNET,      */ "arcnet" "\0"
57         /* ARPHRD_APPLETLK,    */ "atalk" "\0"
58         /* ARPHRD_DLCI,        */ "dlci" "\0"
59 #ifdef ARPHRD_ATM
60         /* ARPHRD_ATM,         */ "atm" "\0"
61 #endif
62         /* ARPHRD_METRICOM,    */ "metricom" "\0"
63         /* ARPHRD_RSRVD,       */ "rsrvd" "\0"
64         /* ARPHRD_ADAPT,       */ "adapt" "\0"
65         /* ARPHRD_ROSE,        */ "rose" "\0"
66         /* ARPHRD_X25,         */ "x25" "\0"
67 #ifdef ARPHRD_HWX25
68         /* ARPHRD_HWX25,       */ "hwx25" "\0"
69 #endif
70         /* ARPHRD_HDLC,        */ "hdlc" "\0"
71         /* ARPHRD_LAPB,        */ "lapb" "\0"
72 #ifdef ARPHRD_DDCMP
73         /* ARPHRD_DDCMP,       */ "ddcmp" "\0"
74         /* ARPHRD_RAWHDLC,     */ "rawhdlc" "\0"
75 #endif
76         /* ARPHRD_FRAD,        */ "frad" "\0"
77         /* ARPHRD_SKIP,        */ "skip" "\0"
78         /* ARPHRD_LOCALTLK,    */ "ltalk" "\0"
79         /* ARPHRD_FDDI,        */ "fddi" "\0"
80         /* ARPHRD_BIF,         */ "bif" "\0"
81         /* ARPHRD_IPDDP,       */ "ip/ddp" "\0"
82         /* ARPHRD_PIMREG,      */ "pimreg" "\0"
83         /* ARPHRD_HIPPI,       */ "hippi" "\0"
84         /* ARPHRD_ASH,         */ "ash" "\0"
85         /* ARPHRD_ECONET,      */ "econet" "\0"
86         /* ARPHRD_FCPP,        */ "fcpp" "\0"
87         /* ARPHRD_FCAL,        */ "fcal" "\0"
88         /* ARPHRD_FCPL,        */ "fcpl" "\0"
89         /* ARPHRD_FCFABRIC,    */ "fcfb0" "\0"
90         /* ARPHRD_FCFABRIC+1,  */ "fcfb1" "\0"
91         /* ARPHRD_FCFABRIC+2,  */ "fcfb2" "\0"
92         /* ARPHRD_FCFABRIC+3,  */ "fcfb3" "\0"
93         /* ARPHRD_FCFABRIC+4,  */ "fcfb4" "\0"
94         /* ARPHRD_FCFABRIC+5,  */ "fcfb5" "\0"
95         /* ARPHRD_FCFABRIC+6,  */ "fcfb6" "\0"
96         /* ARPHRD_FCFABRIC+7,  */ "fcfb7" "\0"
97         /* ARPHRD_FCFABRIC+8,  */ "fcfb8" "\0"
98         /* ARPHRD_FCFABRIC+9,  */ "fcfb9" "\0"
99         /* ARPHRD_FCFABRIC+10, */ "fcfb10" "\0"
100         /* ARPHRD_FCFABRIC+11, */ "fcfb11" "\0"
101         /* ARPHRD_FCFABRIC+12, */ "fcfb12" "\0"
102 #endif /* FEATURE_IP_RARE_PROTOCOLS */
103         ;
104
105         /* Keep these arrays in sync! */
106
107         static const uint16_t arphrd_type[] = {
108         0,                  /* "generic" "\0" */
109         ARPHRD_LOOPBACK,    /* "loopback" "\0" */
110         ARPHRD_ETHER,       /* "ether" "\0" */
111 #ifdef ARPHRD_INFINIBAND
112         ARPHRD_INFINIBAND,  /* "infiniband" "\0" */
113 #endif
114 #ifdef ARPHRD_IEEE802_TR
115         ARPHRD_IEEE802,     /* "ieee802" "\0" */
116         ARPHRD_IEEE802_TR,  /* "tr" "\0" */
117 #else
118         ARPHRD_IEEE802,     /* "tr" "\0" */
119 #endif
120 #ifdef ARPHRD_IEEE80211
121         ARPHRD_IEEE80211,   /* "ieee802.11" "\0" */
122 #endif
123 #ifdef ARPHRD_IEEE1394
124         ARPHRD_IEEE1394,    /* "ieee1394" "\0" */
125 #endif
126         ARPHRD_IRDA,        /* "irda" "\0" */
127         ARPHRD_SLIP,        /* "slip" "\0" */
128         ARPHRD_CSLIP,       /* "cslip" "\0" */
129         ARPHRD_SLIP6,       /* "slip6" "\0" */
130         ARPHRD_CSLIP6,      /* "cslip6" "\0" */
131         ARPHRD_PPP,         /* "ppp" "\0" */
132         ARPHRD_TUNNEL,      /* "ipip" "\0" */
133         ARPHRD_TUNNEL6,     /* "tunnel6" "\0" */
134         ARPHRD_SIT,         /* "sit" "\0" */
135         ARPHRD_IPGRE,       /* "gre" "\0" */
136 #ifdef ARPHRD_VOID
137         ARPHRD_VOID,        /* "void" "\0" */
138 #endif
139
140 #if ENABLE_FEATURE_IP_RARE_PROTOCOLS
141         ARPHRD_EETHER,      /* "eether" "\0" */
142         ARPHRD_AX25,        /* "ax25" "\0" */
143         ARPHRD_PRONET,      /* "pronet" "\0" */
144         ARPHRD_CHAOS,       /* "chaos" "\0" */
145         ARPHRD_ARCNET,      /* "arcnet" "\0" */
146         ARPHRD_APPLETLK,    /* "atalk" "\0" */
147         ARPHRD_DLCI,        /* "dlci" "\0" */
148 #ifdef ARPHRD_ATM
149         ARPHRD_ATM,         /* "atm" "\0" */
150 #endif
151         ARPHRD_METRICOM,    /* "metricom" "\0" */
152         ARPHRD_RSRVD,       /* "rsrvd" "\0" */
153         ARPHRD_ADAPT,       /* "adapt" "\0" */
154         ARPHRD_ROSE,        /* "rose" "\0" */
155         ARPHRD_X25,         /* "x25" "\0" */
156 #ifdef ARPHRD_HWX25
157         ARPHRD_HWX25,       /* "hwx25" "\0" */
158 #endif
159         ARPHRD_HDLC,        /* "hdlc" "\0" */
160         ARPHRD_LAPB,        /* "lapb" "\0" */
161 #ifdef ARPHRD_DDCMP
162         ARPHRD_DDCMP,       /* "ddcmp" "\0" */
163         ARPHRD_RAWHDLC,     /* "rawhdlc" "\0" */
164 #endif
165         ARPHRD_FRAD,        /* "frad" "\0" */
166         ARPHRD_SKIP,        /* "skip" "\0" */
167         ARPHRD_LOCALTLK,    /* "ltalk" "\0" */
168         ARPHRD_FDDI,        /* "fddi" "\0" */
169         ARPHRD_BIF,         /* "bif" "\0" */
170         ARPHRD_IPDDP,       /* "ip/ddp" "\0" */
171         ARPHRD_PIMREG,      /* "pimreg" "\0" */
172         ARPHRD_HIPPI,       /* "hippi" "\0" */
173         ARPHRD_ASH,         /* "ash" "\0" */
174         ARPHRD_ECONET,      /* "econet" "\0" */
175         ARPHRD_FCPP,        /* "fcpp" "\0" */
176         ARPHRD_FCAL,        /* "fcal" "\0" */
177         ARPHRD_FCPL,        /* "fcpl" "\0" */
178         ARPHRD_FCFABRIC,    /* "fcfb0" "\0" */
179         ARPHRD_FCFABRIC+1,  /* "fcfb1" "\0" */
180         ARPHRD_FCFABRIC+2,  /* "fcfb2" "\0" */
181         ARPHRD_FCFABRIC+3,  /* "fcfb3" "\0" */
182         ARPHRD_FCFABRIC+4,  /* "fcfb4" "\0" */
183         ARPHRD_FCFABRIC+5,  /* "fcfb5" "\0" */
184         ARPHRD_FCFABRIC+6,  /* "fcfb6" "\0" */
185         ARPHRD_FCFABRIC+7,  /* "fcfb7" "\0" */
186         ARPHRD_FCFABRIC+8,  /* "fcfb8" "\0" */
187         ARPHRD_FCFABRIC+9,  /* "fcfb9" "\0" */
188         ARPHRD_FCFABRIC+10, /* "fcfb10" "\0" */
189         ARPHRD_FCFABRIC+11, /* "fcfb11" "\0" */
190         ARPHRD_FCFABRIC+12, /* "fcfb12" "\0" */
191 #endif /* FEATURE_IP_RARE_PROTOCOLS */
192         };
193
194         unsigned i;
195         const char *aname = arphrd_name;
196         for (i = 0; i < ARRAY_SIZE(arphrd_type); i++) {
197                 if (arphrd_type[i] == type)
198                         return aname;
199                 aname += strlen(aname) + 1;
200         }
201         sprintf(buf, "[%d]", type);
202         return buf;
203 }