mirror of
https://github.com/sheumann/hush.git
synced 2024-08-14 11:28:58 +00:00
function old new delta ll_addr_a2n 181 178 -3 rtnl_rtntype_a2n 198 194 -4 ipaddr_modify 1309 1305 -4 print_addrinfo 1303 1298 -5 do_iplink 1137 1132 -5 print_route 1609 1603 -6 parse_args 1440 1434 -6 iproute_list_or_flush 1261 1254 -7 rtnl_rttable_a2n 39 31 -8 rtnl_rtscope_a2n 39 31 -8 rtnl_rtrealm_a2n 39 31 -8 rtnl_rtprot_a2n 39 31 -8 rtnl_dsfield_a2n 39 31 -8 ll_type_n2a 78 70 -8 get_rt_realms 115 107 -8 print_tunnel 656 647 -9 rtnl_rttable_n2a 63 53 -10 rtnl_rtscope_n2a 63 53 -10 rtnl_rtrealm_n2a 63 53 -10 rtnl_rtntype_n2a 128 118 -10 rtnl_dsfield_n2a 71 61 -10 print_linkinfo 815 805 -10 ipaddr_list_or_flush 1246 1235 -11 iproute_modify 1048 1036 -12 iprule_modify 866 851 -15 print_rule 765 738 -27 ll_addr_n2a 182 150 -32 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/27 up/down: 0/-262) Total: -262 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
130 lines
2.5 KiB
C
130 lines
2.5 KiB
C
/* vi: set sw=4 ts=4: */
|
|
/*
|
|
* ll_proto.c
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version
|
|
* 2 of the License, or (at your option) any later version.
|
|
*
|
|
* Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
|
|
*/
|
|
|
|
#include "libbb.h"
|
|
#include "rt_names.h"
|
|
#include "utils.h"
|
|
|
|
#if defined(__GLIBC__) && __GLIBC__ >=2 && __GLIBC_MINOR__ >= 1
|
|
#include <net/ethernet.h>
|
|
#else
|
|
#include <linux/if_ether.h>
|
|
#endif
|
|
|
|
#if !ENABLE_WERROR
|
|
#warning de-bloat
|
|
#endif
|
|
/* Before re-enabling this, please (1) conditionalize exotic protocols
|
|
* on CONFIG_something, and (2) decouple strings and numbers
|
|
* (use llproto_ids[] = n,n,n..; and llproto_names[] = "loop\0" "pup\0" ...;)
|
|
*/
|
|
|
|
#define __PF(f,n) { ETH_P_##f, #n },
|
|
static struct {
|
|
int id;
|
|
const char *name;
|
|
} llproto_names[] = {
|
|
__PF(LOOP,loop)
|
|
__PF(PUP,pup)
|
|
#ifdef ETH_P_PUPAT
|
|
__PF(PUPAT,pupat)
|
|
#endif
|
|
__PF(IP,ip)
|
|
__PF(X25,x25)
|
|
__PF(ARP,arp)
|
|
__PF(BPQ,bpq)
|
|
#ifdef ETH_P_IEEEPUP
|
|
__PF(IEEEPUP,ieeepup)
|
|
#endif
|
|
#ifdef ETH_P_IEEEPUPAT
|
|
__PF(IEEEPUPAT,ieeepupat)
|
|
#endif
|
|
__PF(DEC,dec)
|
|
__PF(DNA_DL,dna_dl)
|
|
__PF(DNA_RC,dna_rc)
|
|
__PF(DNA_RT,dna_rt)
|
|
__PF(LAT,lat)
|
|
__PF(DIAG,diag)
|
|
__PF(CUST,cust)
|
|
__PF(SCA,sca)
|
|
__PF(RARP,rarp)
|
|
__PF(ATALK,atalk)
|
|
__PF(AARP,aarp)
|
|
__PF(IPX,ipx)
|
|
__PF(IPV6,ipv6)
|
|
#ifdef ETH_P_PPP_DISC
|
|
__PF(PPP_DISC,ppp_disc)
|
|
#endif
|
|
#ifdef ETH_P_PPP_SES
|
|
__PF(PPP_SES,ppp_ses)
|
|
#endif
|
|
#ifdef ETH_P_ATMMPOA
|
|
__PF(ATMMPOA,atmmpoa)
|
|
#endif
|
|
#ifdef ETH_P_ATMFATE
|
|
__PF(ATMFATE,atmfate)
|
|
#endif
|
|
|
|
__PF(802_3,802_3)
|
|
__PF(AX25,ax25)
|
|
__PF(ALL,all)
|
|
__PF(802_2,802_2)
|
|
__PF(SNAP,snap)
|
|
__PF(DDCMP,ddcmp)
|
|
__PF(WAN_PPP,wan_ppp)
|
|
__PF(PPP_MP,ppp_mp)
|
|
__PF(LOCALTALK,localtalk)
|
|
__PF(PPPTALK,ppptalk)
|
|
__PF(TR_802_2,tr_802_2)
|
|
__PF(MOBITEX,mobitex)
|
|
__PF(CONTROL,control)
|
|
__PF(IRDA,irda)
|
|
#ifdef ETH_P_ECONET
|
|
__PF(ECONET,econet)
|
|
#endif
|
|
|
|
{ 0x8100, "802.1Q" },
|
|
{ ETH_P_IP, "ipv4" },
|
|
};
|
|
#undef __PF
|
|
|
|
|
|
const char* FAST_FUNC ll_proto_n2a(unsigned short id, char *buf, int len)
|
|
{
|
|
unsigned i;
|
|
id = ntohs(id);
|
|
for (i = 0; i < ARRAY_SIZE(llproto_names); i++) {
|
|
if (llproto_names[i].id == id)
|
|
return llproto_names[i].name;
|
|
}
|
|
snprintf(buf, len, "[%d]", id);
|
|
return buf;
|
|
}
|
|
|
|
int FAST_FUNC ll_proto_a2n(unsigned short *id, char *buf)
|
|
{
|
|
unsigned i;
|
|
for (i = 0; i < ARRAY_SIZE(llproto_names); i++) {
|
|
if (strcasecmp(llproto_names[i].name, buf) == 0) {
|
|
i = llproto_names[i].id;
|
|
goto good;
|
|
}
|
|
}
|
|
i = bb_strtou(buf, NULL, 0);
|
|
if (errno || i > 0xffff)
|
|
return -1;
|
|
good:
|
|
*id = htons(i);
|
|
return 0;
|
|
}
|
|
|