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 #if defined(__GLIBC__) && __GLIBC__ >=2 && __GLIBC_MINOR__ >= 1
16 #include <net/ethernet.h>
18 #include <linux/if_ether.h>
24 /* Before re-enabling this, please (1) conditionalize exotic protocols
25 * on CONFIG_something, and (2) decouple strings and numbers
26 * (use llproto_ids[] = n,n,n..; and llproto_names[] = "loop\0" "pup\0" ...;)
29 #define __PF(f,n) { ETH_P_##f, #n },
46 #ifdef ETH_P_IEEEPUPAT
47 __PF(IEEEPUPAT,ieeepupat)
63 __PF(PPP_DISC,ppp_disc)
83 __PF(LOCALTALK,localtalk)
85 __PF(TR_802_2,tr_802_2)
99 const char* FAST_FUNC ll_proto_n2a(unsigned short id, char *buf, int len)
103 for (i = 0; i < ARRAY_SIZE(llproto_names); i++) {
104 if (llproto_names[i].id == id)
105 return llproto_names[i].name;
107 snprintf(buf, len, "[%d]", id);
111 int FAST_FUNC ll_proto_a2n(unsigned short *id, char *buf)
114 for (i = 0; i < ARRAY_SIZE(llproto_names); i++) {
115 if (strcasecmp(llproto_names[i].name, buf) == 0) {
116 i = llproto_names[i].id;
120 i = bb_strtou(buf, NULL, 0);
121 if (errno || i > 0xffff)