1 /* vi: set sw=4 ts=4: */
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.
8 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
15 #include <netinet/if_ether.h>
20 /* Before re-enabling this, please (1) conditionalize exotic protocols
21 * on CONFIG_something, and (2) decouple strings and numbers
22 * (use llproto_ids[] = n,n,n..; and llproto_names[] = "loop\0" "pup\0" ...;)
25 #define __PF(f,n) { ETH_P_##f, #n },
42 #ifdef ETH_P_IEEEPUPAT
43 __PF(IEEEPUPAT,ieeepupat)
59 __PF(PPP_DISC,ppp_disc)
79 __PF(LOCALTALK,localtalk)
81 __PF(TR_802_2,tr_802_2)
95 const char* FAST_FUNC ll_proto_n2a(unsigned short id, char *buf, int len)
99 for (i = 0; i < ARRAY_SIZE(llproto_names); i++) {
100 if (llproto_names[i].id == id)
101 return llproto_names[i].name;
103 snprintf(buf, len, "[%d]", id);
107 int FAST_FUNC ll_proto_a2n(unsigned short *id, char *buf)
110 for (i = 0; i < ARRAY_SIZE(llproto_names); i++) {
111 if (strcasecmp(llproto_names[i].name, buf) == 0) {
112 i = llproto_names[i].id;
116 i = bb_strtou(buf, NULL, 0);
117 if (errno || i > 0xffff)