Changeset 2725 in MondoRescue for branches/2.2.9/mindi-busybox/networking/libiproute/ll_proto.c
- Timestamp:
- Feb 25, 2011, 9:26:54 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mindi-busybox/networking/libiproute/ll_proto.c
r1765 r2725 1 1 /* vi: set sw=4 ts=4: */ 2 2 /* 3 * ll_proto.c 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. 4 7 * 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. 9 * 10 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> 8 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> 11 9 */ 12 10 … … 20 18 #include <linux/if_ether.h> 21 19 #endif 20 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 */ 22 28 23 29 #define __PF(f,n) { ETH_P_##f, #n }, … … 91 97 92 98 93 const char *ll_proto_n2a(unsigned short id, char *buf, int len)99 const char* FAST_FUNC ll_proto_n2a(unsigned short id, char *buf, int len) 94 100 { 95 int i; 96 101 unsigned i; 97 102 id = ntohs(id); 98 99 for (i=0; i < ARRAY_SIZE(llproto_names); i++) { 103 for (i = 0; i < ARRAY_SIZE(llproto_names); i++) { 100 104 if (llproto_names[i].id == id) 101 105 return llproto_names[i].name; … … 105 109 } 106 110 107 int ll_proto_a2n(unsigned short *id, char *buf)111 int FAST_FUNC ll_proto_a2n(unsigned short *id, char *buf) 108 112 { 109 inti;110 for (i =0; i < ARRAY_SIZE(llproto_names); i++) {113 unsigned i; 114 for (i = 0; i < ARRAY_SIZE(llproto_names); i++) { 111 115 if (strcasecmp(llproto_names[i].name, buf) == 0) { 112 *id = htons(llproto_names[i].id);113 return 0;116 i = llproto_names[i].id; 117 goto good; 114 118 } 115 119 } 116 if (get_u16(id, buf, 0)) 120 i = bb_strtou(buf, NULL, 0); 121 if (errno || i > 0xffff) 117 122 return -1; 118 *id = htons(*id); 123 good: 124 *id = htons(i); 119 125 return 0; 120 126 }
Note:
See TracChangeset
for help on using the changeset viewer.