summaryrefslogtreecommitdiff
path: root/release/src/router/busybox/networking/libiproute/ll_types.c
blob: d5d2a1f39ecd401a02cf7b0b69e4ee786a476642 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/* vi: set sw=4 ts=4: */
/*
 * ll_types.c
 *
 *		This program is free software; you can redistribute it and/or
 *		modify it under the terms of the GNU General Public License
 *		as published by the Free Software Foundation; either version
 *		2 of the License, or (at your option) any later version.
 *
 * Authors:	Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
 */
#include <arpa/inet.h>
#include <linux/if_arp.h>

#include "libbb.h"
#include "rt_names.h"

const char *ll_type_n2a(int type, char *buf, int len)
{
	static const char arphrd_name[] =
	/* 0,                  */ "generic" "\0"
	/* ARPHRD_LOOPBACK,    */ "loopback" "\0"
	/* ARPHRD_ETHER,       */ "ether" "\0"
#ifdef ARPHRD_INFINIBAND
	/* ARPHRD_INFINIBAND,  */ "infiniband" "\0"
#endif
#ifdef ARPHRD_IEEE802_TR
	/* ARPHRD_IEEE802,     */ "ieee802" "\0"
	/* ARPHRD_IEEE802_TR,  */ "tr" "\0"
#else
	/* ARPHRD_IEEE802,     */ "tr" "\0"
#endif
#ifdef ARPHRD_IEEE80211
	/* ARPHRD_IEEE80211,   */ "ieee802.11" "\0"
#endif
#ifdef ARPHRD_IEEE1394
	/* ARPHRD_IEEE1394,    */ "ieee1394" "\0"
#endif
	/* ARPHRD_IRDA,        */ "irda" "\0"
	/* ARPHRD_SLIP,        */ "slip" "\0"
	/* ARPHRD_CSLIP,       */ "cslip" "\0"
	/* ARPHRD_SLIP6,       */ "slip6" "\0"
	/* ARPHRD_CSLIP6,      */ "cslip6" "\0"
	/* ARPHRD_PPP,         */ "ppp" "\0"
	/* ARPHRD_TUNNEL,      */ "ipip" "\0"
	/* ARPHRD_TUNNEL6,     */ "tunnel6" "\0"
	/* ARPHRD_SIT,         */ "sit" "\0"
	/* ARPHRD_IPGRE,       */ "gre" "\0"
#ifdef ARPHRD_VOID
	/* ARPHRD_VOID,        */ "void" "\0"
#endif

#if ENABLE_FEATURE_IP_RARE_PROTOCOLS
	/* ARPHRD_EETHER,      */ "eether" "\0"
	/* ARPHRD_AX25,        */ "ax25" "\0"
	/* ARPHRD_PRONET,      */ "pronet" "\0"
	/* ARPHRD_CHAOS,       */ "chaos" "\0"
	/* ARPHRD_ARCNET,      */ "arcnet" "\0"
	/* ARPHRD_APPLETLK,    */ "atalk" "\0"
	/* ARPHRD_DLCI,        */ "dlci" "\0"
#ifdef ARPHRD_ATM
	/* ARPHRD_ATM,         */ "atm" "\0"
#endif
	/* ARPHRD_METRICOM,    */ "metricom" "\0"
	/* ARPHRD_RSRVD,       */ "rsrvd" "\0"
	/* ARPHRD_ADAPT,       */ "adapt" "\0"
	/* ARPHRD_ROSE,        */ "rose" "\0"
	/* ARPHRD_X25,         */ "x25" "\0"
#ifdef ARPHRD_HWX25
	/* ARPHRD_HWX25,       */ "hwx25" "\0"
#endif
	/* ARPHRD_HDLC,        */ "hdlc" "\0"
	/* ARPHRD_LAPB,        */ "lapb" "\0"
#ifdef ARPHRD_DDCMP
	/* ARPHRD_DDCMP,       */ "ddcmp" "\0"
	/* ARPHRD_RAWHDLC,     */ "rawhdlc" "\0"
#endif
	/* ARPHRD_FRAD,        */ "frad" "\0"
	/* ARPHRD_SKIP,        */ "skip" "\0"
	/* ARPHRD_LOCALTLK,    */ "ltalk" "\0"
	/* ARPHRD_FDDI,        */ "fddi" "\0"
	/* ARPHRD_BIF,         */ "bif" "\0"
	/* ARPHRD_IPDDP,       */ "ip/ddp" "\0"
	/* ARPHRD_PIMREG,      */ "pimreg" "\0"
	/* ARPHRD_HIPPI,       */ "hippi" "\0"
	/* ARPHRD_ASH,         */ "ash" "\0"
	/* ARPHRD_ECONET,      */ "econet" "\0"
	/* ARPHRD_FCPP,        */ "fcpp" "\0"
	/* ARPHRD_FCAL,        */ "fcal" "\0"
	/* ARPHRD_FCPL,        */ "fcpl" "\0"
	/* ARPHRD_FCFABRIC,    */ "fcfb0" "\0"
	/* ARPHRD_FCFABRIC+1,  */ "fcfb1" "\0"
	/* ARPHRD_FCFABRIC+2,  */ "fcfb2" "\0"
	/* ARPHRD_FCFABRIC+3,  */ "fcfb3" "\0"
	/* ARPHRD_FCFABRIC+4,  */ "fcfb4" "\0"
	/* ARPHRD_FCFABRIC+5,  */ "fcfb5" "\0"
	/* ARPHRD_FCFABRIC+6,  */ "fcfb6" "\0"
	/* ARPHRD_FCFABRIC+7,  */ "fcfb7" "\0"
	/* ARPHRD_FCFABRIC+8,  */ "fcfb8" "\0"
	/* ARPHRD_FCFABRIC+9,  */ "fcfb9" "\0"
	/* ARPHRD_FCFABRIC+10, */ "fcfb10" "\0"
	/* ARPHRD_FCFABRIC+11, */ "fcfb11" "\0"
	/* ARPHRD_FCFABRIC+12, */ "fcfb12" "\0"
#endif /* FEATURE_IP_RARE_PROTOCOLS */
	;

	/* Keep these arrays in sync! */

	static const uint16_t arphrd_type[] = {
	0,                  /* "generic" "\0" */
	ARPHRD_LOOPBACK,    /* "loopback" "\0" */
	ARPHRD_ETHER,       /* "ether" "\0" */
#ifdef ARPHRD_INFINIBAND
	ARPHRD_INFINIBAND,  /* "infiniband" "\0" */
#endif
#ifdef ARPHRD_IEEE802_TR
	ARPHRD_IEEE802,     /* "ieee802" "\0" */
	ARPHRD_IEEE802_TR,  /* "tr" "\0" */
#else
	ARPHRD_IEEE802,     /* "tr" "\0" */
#endif
#ifdef ARPHRD_IEEE80211
	ARPHRD_IEEE80211,   /* "ieee802.11" "\0" */
#endif
#ifdef ARPHRD_IEEE1394
	ARPHRD_IEEE1394,    /* "ieee1394" "\0" */
#endif
	ARPHRD_IRDA,        /* "irda" "\0" */
	ARPHRD_SLIP,        /* "slip" "\0" */
	ARPHRD_CSLIP,       /* "cslip" "\0" */
	ARPHRD_SLIP6,       /* "slip6" "\0" */
	ARPHRD_CSLIP6,      /* "cslip6" "\0" */
	ARPHRD_PPP,         /* "ppp" "\0" */
	ARPHRD_TUNNEL,      /* "ipip" "\0" */
	ARPHRD_TUNNEL6,     /* "tunnel6" "\0" */
	ARPHRD_SIT,         /* "sit" "\0" */
	ARPHRD_IPGRE,       /* "gre" "\0" */
#ifdef ARPHRD_VOID
	ARPHRD_VOID,        /* "void" "\0" */
#endif

#if ENABLE_FEATURE_IP_RARE_PROTOCOLS
	ARPHRD_EETHER,      /* "eether" "\0" */
	ARPHRD_AX25,        /* "ax25" "\0" */
	ARPHRD_PRONET,      /* "pronet" "\0" */
	ARPHRD_CHAOS,       /* "chaos" "\0" */
	ARPHRD_ARCNET,      /* "arcnet" "\0" */
	ARPHRD_APPLETLK,    /* "atalk" "\0" */
	ARPHRD_DLCI,        /* "dlci" "\0" */
#ifdef ARPHRD_ATM
	ARPHRD_ATM,         /* "atm" "\0" */
#endif
	ARPHRD_METRICOM,    /* "metricom" "\0" */
	ARPHRD_RSRVD,       /* "rsrvd" "\0" */
	ARPHRD_ADAPT,       /* "adapt" "\0" */
	ARPHRD_ROSE,        /* "rose" "\0" */
	ARPHRD_X25,         /* "x25" "\0" */
#ifdef ARPHRD_HWX25
	ARPHRD_HWX25,       /* "hwx25" "\0" */
#endif
	ARPHRD_HDLC,        /* "hdlc" "\0" */
	ARPHRD_LAPB,        /* "lapb" "\0" */
#ifdef ARPHRD_DDCMP
	ARPHRD_DDCMP,       /* "ddcmp" "\0" */
	ARPHRD_RAWHDLC,     /* "rawhdlc" "\0" */
#endif
	ARPHRD_FRAD,        /* "frad" "\0" */
	ARPHRD_SKIP,        /* "skip" "\0" */
	ARPHRD_LOCALTLK,    /* "ltalk" "\0" */
	ARPHRD_FDDI,        /* "fddi" "\0" */
	ARPHRD_BIF,         /* "bif" "\0" */
	ARPHRD_IPDDP,       /* "ip/ddp" "\0" */
	ARPHRD_PIMREG,      /* "pimreg" "\0" */
	ARPHRD_HIPPI,       /* "hippi" "\0" */
	ARPHRD_ASH,         /* "ash" "\0" */
	ARPHRD_ECONET,      /* "econet" "\0" */
	ARPHRD_FCPP,        /* "fcpp" "\0" */
	ARPHRD_FCAL,        /* "fcal" "\0" */
	ARPHRD_FCPL,        /* "fcpl" "\0" */
	ARPHRD_FCFABRIC,    /* "fcfb0" "\0" */
	ARPHRD_FCFABRIC+1,  /* "fcfb1" "\0" */
	ARPHRD_FCFABRIC+2,  /* "fcfb2" "\0" */
	ARPHRD_FCFABRIC+3,  /* "fcfb3" "\0" */
	ARPHRD_FCFABRIC+4,  /* "fcfb4" "\0" */
	ARPHRD_FCFABRIC+5,  /* "fcfb5" "\0" */
	ARPHRD_FCFABRIC+6,  /* "fcfb6" "\0" */
	ARPHRD_FCFABRIC+7,  /* "fcfb7" "\0" */
	ARPHRD_FCFABRIC+8,  /* "fcfb8" "\0" */
	ARPHRD_FCFABRIC+9,  /* "fcfb9" "\0" */
	ARPHRD_FCFABRIC+10, /* "fcfb10" "\0" */
	ARPHRD_FCFABRIC+11, /* "fcfb11" "\0" */
	ARPHRD_FCFABRIC+12, /* "fcfb12" "\0" */
#endif /* FEATURE_IP_RARE_PROTOCOLS */
	};

	unsigned i;
	const char *aname = arphrd_name;
	for (i = 0; i < ARRAY_SIZE(arphrd_type); i++) {
		if (arphrd_type[i] == type)
			return aname;
		aname += strlen(aname) + 1;
	}
	snprintf(buf, len, "[%d]", type);
	return buf;
}