Ignore:
Timestamp:
Jan 1, 2014, 12:47:38 AM (10 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.21.1
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mindi-busybox/networking/libiproute/ll_proto.c

    r2725 r3232  
    1313#include "utils.h"
    1414
    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>
    2016
    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 */
    2818
    29 #define __PF(f,n) { ETH_P_##f, #n },
    30 static struct {
    31     int id;
    32     const char *name;
    33 } llproto_names[] = {
     19static const uint16_t llproto_ids[] = {
     20#define __PF(f,n) ETH_P_##f,
    3421__PF(LOOP,loop)
    3522__PF(PUP,pup)
     
    9178#endif
    9279
    93 { 0x8100, "802.1Q" },
    94 { ETH_P_IP, "ipv4" },
     800x8100,
     81ETH_P_IP
    9582};
     83#undef __PF
     84
     85/* Keep declarations above and below in sync! */
     86
     87static 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;
    96151#undef __PF
    97152
     
    101156    unsigned i;
    102157    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);
    106161    }
    107     snprintf(buf, len, "[%d]", id);
     162    snprintf(buf, len, "[%u]", id);
    108163    return buf;
    109164}
     
    112167{
    113168    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;
    119176    }
     177    errno = 0;
    120178    i = bb_strtou(buf, NULL, 0);
    121179    if (errno || i > 0xffff)
Note: See TracChangeset for help on using the changeset viewer.