Magellan Linux

Diff of /trunk/mkinitrd-magellan/busybox/networking/libiproute/ll_proto.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 815 by niro, Sat Sep 1 22:45:15 2007 UTC revision 816 by niro, Fri Apr 24 18:33:46 2009 UTC
# Line 11  Line 11 
11   */   */
12    
13  #include "libbb.h"  #include "libbb.h"
   
14  #include "rt_names.h"  #include "rt_names.h"
15  #include "utils.h"  #include "utils.h"
16    
# Line 21  Line 20 
20  #include <linux/if_ether.h>  #include <linux/if_ether.h>
21  #endif  #endif
22    
23    #if !ENABLE_WERROR
24    #warning de-bloat
25    #endif
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" ...;)
29     */
30    
31  #define __PF(f,n) { ETH_P_##f, #n },  #define __PF(f,n) { ETH_P_##f, #n },
32  static struct {  static struct {
33   int id;   int id;
34   char *name;   const char *name;
35  } llproto_names[] = {  } llproto_names[] = {
36  __PF(LOOP,loop)  __PF(LOOP,loop)
37  __PF(PUP,pup)  __PF(PUP,pup)
# Line 91  __PF(ECONET,econet) Line 98  __PF(ECONET,econet)
98  #undef __PF  #undef __PF
99    
100    
101  const char * ll_proto_n2a(unsigned short id, char *buf, int len)  const char *ll_proto_n2a(unsigned short id, char *buf, int len)
102  {  {
103   int i;   unsigned i;
   
104   id = ntohs(id);   id = ntohs(id);
105     for (i = 0; i < ARRAY_SIZE(llproto_names); i++) {
  for (i=0; i<sizeof(llproto_names)/sizeof(llproto_names[0]); i++) {  
106   if (llproto_names[i].id == id)   if (llproto_names[i].id == id)
107   return llproto_names[i].name;   return llproto_names[i].name;
108   }   }
# Line 107  const char * ll_proto_n2a(unsigned short Line 112  const char * ll_proto_n2a(unsigned short
112    
113  int ll_proto_a2n(unsigned short *id, char *buf)  int ll_proto_a2n(unsigned short *id, char *buf)
114  {  {
115   int i;   unsigned i;
116   for (i=0; i<sizeof(llproto_names)/sizeof(llproto_names[0]); i++) {   for (i = 0; i < ARRAY_SIZE(llproto_names); i++) {
117   if (strcasecmp(llproto_names[i].name, buf) == 0) {   if (strcasecmp(llproto_names[i].name, buf) == 0) {
118   *id = htons(llproto_names[i].id);   *id = htons(llproto_names[i].id);
119   return 0;   return 0;
# Line 119  int ll_proto_a2n(unsigned short *id, cha Line 124  int ll_proto_a2n(unsigned short *id, cha
124   *id = htons(*id);   *id = htons(*id);
125   return 0;   return 0;
126  }  }
127    

Legend:
Removed from v.815  
changed lines
  Added in v.816