Changeset 3232 in MondoRescue for branches/3.2/mindi-busybox/networking/libiproute/ll_proto.c
- Timestamp:
- Jan 1, 2014, 12:47:38 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi-busybox/networking/libiproute/ll_proto.c
r2725 r3232 13 13 #include "utils.h" 14 14 15 #if defined(__GLIBC__) && __GLIBC__ >=2 && __GLIBC_MINOR__ >= 1 16 #include <net/ethernet.h> 17 #else 18 #include <linux/if_ether.h> 19 #endif 15 #include <netinet/if_ether.h> 20 16 21 #if !ENABLE_WERROR 22 #warning de-bloat 23 #endif 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" ...;) 27 */ 17 /* Please conditionalize exotic protocols on CONFIG_something */ 28 18 29 #define __PF(f,n) { ETH_P_##f, #n }, 30 static struct { 31 int id; 32 const char *name; 33 } llproto_names[] = { 19 static const uint16_t llproto_ids[] = { 20 #define __PF(f,n) ETH_P_##f, 34 21 __PF(LOOP,loop) 35 22 __PF(PUP,pup) … … 91 78 #endif 92 79 93 { 0x8100, "802.1Q" },94 { ETH_P_IP, "ipv4" }, 80 0x8100, 81 ETH_P_IP 95 82 }; 83 #undef __PF 84 85 /* Keep declarations above and below in sync! */ 86 87 static const char llproto_names[] = 88 #define __PF(f,n) #n "\0" 89 __PF(LOOP,loop) 90 __PF(PUP,pup) 91 #ifdef ETH_P_PUPAT 92 __PF(PUPAT,pupat) 93 #endif 94 __PF(IP,ip) 95 __PF(X25,x25) 96 __PF(ARP,arp) 97 __PF(BPQ,bpq) 98 #ifdef ETH_P_IEEEPUP 99 __PF(IEEEPUP,ieeepup) 100 #endif 101 #ifdef ETH_P_IEEEPUPAT 102 __PF(IEEEPUPAT,ieeepupat) 103 #endif 104 __PF(DEC,dec) 105 __PF(DNA_DL,dna_dl) 106 __PF(DNA_RC,dna_rc) 107 __PF(DNA_RT,dna_rt) 108 __PF(LAT,lat) 109 __PF(DIAG,diag) 110 __PF(CUST,cust) 111 __PF(SCA,sca) 112 __PF(RARP,rarp) 113 __PF(ATALK,atalk) 114 __PF(AARP,aarp) 115 __PF(IPX,ipx) 116 __PF(IPV6,ipv6) 117 #ifdef ETH_P_PPP_DISC 118 __PF(PPP_DISC,ppp_disc) 119 #endif 120 #ifdef ETH_P_PPP_SES 121 __PF(PPP_SES,ppp_ses) 122 #endif 123 #ifdef ETH_P_ATMMPOA 124 __PF(ATMMPOA,atmmpoa) 125 #endif 126 #ifdef ETH_P_ATMFATE 127 __PF(ATMFATE,atmfate) 128 #endif 129 130 __PF(802_3,802_3) 131 __PF(AX25,ax25) 132 __PF(ALL,all) 133 __PF(802_2,802_2) 134 __PF(SNAP,snap) 135 __PF(DDCMP,ddcmp) 136 __PF(WAN_PPP,wan_ppp) 137 __PF(PPP_MP,ppp_mp) 138 __PF(LOCALTALK,localtalk) 139 __PF(PPPTALK,ppptalk) 140 __PF(TR_802_2,tr_802_2) 141 __PF(MOBITEX,mobitex) 142 __PF(CONTROL,control) 143 __PF(IRDA,irda) 144 #ifdef ETH_P_ECONET 145 __PF(ECONET,econet) 146 #endif 147 148 "802.1Q" "\0" 149 "ipv4" "\0" 150 ; 96 151 #undef __PF 97 152 … … 101 156 unsigned i; 102 157 id = ntohs(id); 103 for (i = 0; i < ARRAY_SIZE(llproto_ names); i++) {104 if (llproto_names[i].id== id)105 return llproto_names[i].name;158 for (i = 0; i < ARRAY_SIZE(llproto_ids); i++) { 159 if (llproto_ids[i] == id) 160 return nth_string(llproto_names, i); 106 161 } 107 snprintf(buf, len, "[% d]", id);162 snprintf(buf, len, "[%u]", id); 108 163 return buf; 109 164 } … … 112 167 { 113 168 unsigned i; 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; 117 goto good; 118 } 169 const char *name = llproto_names; 170 for (i = 0; i < ARRAY_SIZE(llproto_ids); i++) { 171 if (strcasecmp(name, buf) == 0) { 172 i = llproto_ids[i]; 173 goto good; 174 } 175 name += strlen(name) + 1; 119 176 } 177 errno = 0; 120 178 i = bb_strtou(buf, NULL, 0); 121 179 if (errno || i > 0xffff)
Note:
See TracChangeset
for help on using the changeset viewer.