1 /* vi: set sw=4 ts=4: */
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
10 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
17 #if defined(__GLIBC__) && __GLIBC__ >=2 && __GLIBC_MINOR__ >= 1
18 #include <net/ethernet.h>
20 #include <linux/if_ether.h>
26 /* Before re-enabling this, please (1) conditionalize exotic protocols
27 * on CONFIG_something, and (2) decouple strings and numbers
28 * (use llproto_ids[] = n,n,n..; and llproto_names[] = "loop\0" "pup\0" ...;)
31 #define __PF(f,n) { ETH_P_##f, #n },
48 #ifdef ETH_P_IEEEPUPAT
49 __PF(IEEEPUPAT,ieeepupat)
65 __PF(PPP_DISC,ppp_disc)
85 __PF(LOCALTALK,localtalk)
87 __PF(TR_802_2,tr_802_2)
101 const char *ll_proto_n2a(unsigned short id, char *buf, int len)
105 for (i = 0; i < ARRAY_SIZE(llproto_names); i++) {
106 if (llproto_names[i].id == id)
107 return llproto_names[i].name;
109 snprintf(buf, len, "[%d]", id);
113 int ll_proto_a2n(unsigned short *id, char *buf)
116 for (i = 0; i < ARRAY_SIZE(llproto_names); i++) {
117 if (strcasecmp(llproto_names[i].name, buf) == 0) {
118 i = llproto_names[i].id;
122 i = bb_strtou(buf, NULL, 0);
123 if (errno || i > 0xffff)