Ignore:
Timestamp:
Feb 25, 2011, 9:26:54 PM (13 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mindi-busybox/networking/interface.c

    r1765 r2725  
    2020 *              and others.  Copyright 1993 MicroWalt Corporation
    2121 *
    22  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
     22 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    2323 *
    2424 * Patched to support 'add' and 'del' keywords for INET(4) addresses
     
    3131 *          (default AF was wrong)
    3232 */
    33 
    3433#include <net/if.h>
    3534#include <net/if_arp.h>
     35#if (defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1) || defined(_NEWLIB_VERSION)
     36# include <net/ethernet.h>
     37#else
     38# include <linux/if_ether.h>
     39#endif
     40#include "libbb.h"
    3641#include "inet_common.h"
    37 #include "libbb.h"
     42
     43#if ENABLE_FEATURE_HWIB
     44/* #include <linux/if_infiniband.h> */
     45# undef INFINIBAND_ALEN
     46# define INFINIBAND_ALEN 20
     47#endif
    3848
    3949#if ENABLE_FEATURE_IPV6
     
    4757
    4858#ifdef HAVE_AFINET6
    49 
    50 #ifndef _LINUX_IN6_H
     59# ifndef _LINUX_IN6_H
    5160/*
    52  *    This is in linux/include/net/ipv6.h.
     61 * This is from linux/include/net/ipv6.h
    5362 */
    54 
    5563struct in6_ifreq {
    5664    struct in6_addr ifr6_addr;
     
    5866    unsigned int ifr6_ifindex;
    5967};
    60 
    61 #endif
    62 
     68# endif
    6369#endif /* HAVE_AFINET6 */
    6470
    6571/* Defines for glibc2.0 users. */
    6672#ifndef SIOCSIFTXQLEN
    67 #define SIOCSIFTXQLEN      0x8943
    68 #define SIOCGIFTXQLEN      0x8942
     73# define SIOCSIFTXQLEN      0x8943
     74# define SIOCGIFTXQLEN      0x8942
    6975#endif
    7076
    7177/* ifr_qlen is ifru_ivalue, but it isn't present in 2.0 kernel headers */
    7278#ifndef ifr_qlen
    73 #define ifr_qlen        ifr_ifru.ifru_mtu
     79# define ifr_qlen        ifr_ifru.ifru_mtu
    7480#endif
    7581
    7682#ifndef HAVE_TXQUEUELEN
    77 #define HAVE_TXQUEUELEN 1
     83# define HAVE_TXQUEUELEN 1
    7884#endif
    7985
    8086#ifndef IFF_DYNAMIC
    81 #define IFF_DYNAMIC     0x8000  /* dialup device with changing addresses */
     87# define IFF_DYNAMIC     0x8000 /* dialup device with changing addresses */
    8288#endif
    8389
    8490/* Display an Internet socket address. */
    85 static const char *INET_sprint(struct sockaddr *sap, int numeric)
    86 {
    87     static char *buff;
     91static const char* FAST_FUNC INET_sprint(struct sockaddr *sap, int numeric)
     92{
     93    static char *buff; /* defaults to NULL */
    8894
    8995    free(buff);
     
    137143#endif
    138144
    139 static int INET_input(/*int type,*/ const char *bufp, struct sockaddr *sap)
     145static int FAST_FUNC INET_input(/*int type,*/ const char *bufp, struct sockaddr *sap)
    140146{
    141147    return INET_resolve(bufp, (struct sockaddr_in *) sap, 0);
     
    153159
    154160static const struct aftype inet_aftype = {
    155     .name =     "inet",
    156     .title =    "DARPA Internet",
    157     .af =       AF_INET,
    158     .alen =     4,
    159     .sprint =   INET_sprint,
    160     .input =    INET_input,
     161    .name   = "inet",
     162    .title  = "DARPA Internet",
     163    .af     = AF_INET,
     164    .alen   = 4,
     165    .sprint = INET_sprint,
     166    .input  = INET_input,
    161167};
    162168
     
    165171/* Display an Internet socket address. */
    166172/* dirty! struct sockaddr usually doesn't suffer for inet6 addresses, fst. */
    167 static const char *INET6_sprint(struct sockaddr *sap, int numeric)
     173static const char* FAST_FUNC INET6_sprint(struct sockaddr *sap, int numeric)
    168174{
    169175    static char *buff;
     
    192198#endif
    193199
    194 static int INET6_input(/*int type,*/ const char *bufp, struct sockaddr *sap)
     200static int FAST_FUNC INET6_input(/*int type,*/ const char *bufp, struct sockaddr *sap)
    195201{
    196202    return INET6_resolve(bufp, (struct sockaddr_in6 *) sap);
     
    206212
    207213static const struct aftype inet6_aftype = {
    208     .name =     "inet6",
    209     .title =    "IPv6",
    210     .af =       AF_INET6,
    211     .alen =     sizeof(struct in6_addr),
    212     .sprint =   INET6_sprint,
    213     .input =    INET6_input,
     214    .name   = "inet6",
     215    .title  = "IPv6",
     216    .af     = AF_INET6,
     217    .alen   = sizeof(struct in6_addr),
     218    .sprint = INET6_sprint,
     219    .input  = INET6_input,
    214220};
    215221
     
    217223
    218224/* Display an UNSPEC address. */
    219 static char *UNSPEC_print(unsigned char *ptr)
     225static char* FAST_FUNC UNSPEC_print(unsigned char *ptr)
    220226{
    221227    static char *buff;
     
    224230    unsigned int i;
    225231
    226     if (!buff);
     232    if (!buff)
    227233        buff = xmalloc(sizeof(struct sockaddr) * 3 + 1);
    228234    pos = buff;
     
    238244
    239245/* Display an UNSPEC socket address. */
    240 static const char *UNSPEC_sprint(struct sockaddr *sap, int numeric)
     246static const char* FAST_FUNC UNSPEC_sprint(struct sockaddr *sap, int numeric UNUSED_PARAM)
    241247{
    242248    if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
     
    249255    .title  = "UNSPEC",
    250256    .af     = AF_UNSPEC,
    251     .alen    = 0,
     257    .alen   = 0,
    252258    .print  = UNSPEC_print,
    253259    .sprint = UNSPEC_sprint,
     
    264270
    265271/* Check our protocol family table for this family. */
    266 const struct aftype *get_aftype(const char *name)
     272const struct aftype* FAST_FUNC get_aftype(const char *name)
    267273{
    268274    const struct aftype *const *afp;
     
    322328struct interface {
    323329    struct interface *next, *prev;
    324     char name[IFNAMSIZ];    /* interface name        */
    325     short type;         /* if type               */
    326     short flags;        /* various flags         */
    327     int metric;         /* routing metric        */
    328     int mtu;            /* MTU value             */
    329     int tx_queue_len;   /* transmit queue length */
    330     struct ifmap map;   /* hardware setup        */
    331     struct sockaddr addr;   /* IP address            */
    332     struct sockaddr dstaddr;    /* P-P IP address        */
    333     struct sockaddr broadaddr;  /* IP broadcast address  */
    334     struct sockaddr netmask;    /* IP network mask       */
     330    char name[IFNAMSIZ];                    /* interface name        */
     331    short type;                             /* if type               */
     332    short flags;                            /* various flags         */
     333    int metric;                             /* routing metric        */
     334    int mtu;                                /* MTU value             */
     335    int tx_queue_len;                       /* transmit queue length */
     336    struct ifmap map;                       /* hardware setup        */
     337    struct sockaddr addr;                   /* IP address            */
     338    struct sockaddr dstaddr;                /* P-P IP address        */
     339    struct sockaddr broadaddr;              /* IP broadcast address  */
     340    struct sockaddr netmask;                /* IP network mask       */
    335341    int has_ip;
    336     char hwaddr[32];    /* HW address            */
     342    char hwaddr[32];                        /* HW address            */
    337343    int statistics_valid;
    338     struct user_net_device_stats stats; /* statistics            */
    339     int keepalive;      /* keepalive value for SLIP */
    340     int outfill;        /* outfill value for SLIP */
     344    struct user_net_device_stats stats;     /* statistics            */
     345    int keepalive;                          /* keepalive value for SLIP */
     346    int outfill;                            /* outfill value for SLIP */
    341347};
    342348
     
    389395
    390396    new = xzalloc(sizeof(*new));
    391     safe_strncpy(new->name, name, IFNAMSIZ);
     397    strncpy_IFNAMSIZ(new->name, name);
    392398    nextp = ife ? &ife->next : &int_list;
    393399    new->prev = ife;
     
    404410{
    405411    /* Extract <name> from nul-terminated p where p matches
    406        <name>: after leading whitespace.
    407        If match is not made, set name empty and return unchanged p */
    408     int namestart=0, nameend=0;
    409     while (isspace(p[namestart]))
    410         namestart++;
    411     nameend=namestart;
    412     while (p[nameend] && p[nameend]!=':' && !isspace(p[nameend]))
     412     * <name>: after leading whitespace.
     413     * If match is not made, set name empty and return unchanged p
     414     */
     415    char *nameend;
     416    char *namestart = skip_whitespace(p);
     417
     418    nameend = namestart;
     419    while (*nameend && *nameend != ':' && !isspace(*nameend))
    413420        nameend++;
    414     if (p[nameend]==':') {
    415         if ((nameend-namestart)<IFNAMSIZ) {
    416             memcpy(name,&p[namestart],nameend-namestart);
    417             name[nameend-namestart]='\0';
    418             p=&p[nameend];
     421    if (*nameend == ':') {
     422        if ((nameend - namestart) < IFNAMSIZ) {
     423            memcpy(name, namestart, nameend - namestart);
     424            name[nameend - namestart] = '\0';
     425            p = nameend;
    419426        } else {
    420427            /* Interface name too large */
    421             name[0]='\0';
     428            name[0] = '\0';
    422429        }
    423430    } else {
    424431        /* trailing ':' not found - return empty */
    425         name[0]='\0';
     432        name[0] = '\0';
    426433    }
    427434    return p + 1;
     
    491498}
    492499
    493 static inline int procnetdev_version(char *buf)
     500static int procnetdev_version(char *buf)
    494501{
    495502    if (strstr(buf, "compressed"))
     
    525532            goto out;
    526533        }
    527         if (ifc.ifc_len == sizeof(struct ifreq) * numreqs) {
     534        if (ifc.ifc_len == (int)(sizeof(struct ifreq) * numreqs)) {
    528535            /* assume it overflowed and try again */
    529536            numreqs += 10;
     
    560567        proc_read = 1;
    561568
    562     fh = fopen(_PATH_PROCNET_DEV, "r");
     569    fh = fopen_or_warn(_PATH_PROCNET_DEV, "r");
    563570    if (!fh) {
    564         bb_perror_msg("warning: cannot open %s, limiting output", _PATH_PROCNET_DEV);
    565571        return if_readconf();
    566572    }
     
    608614    skfd = xsocket(AF_INET, SOCK_DGRAM, 0);
    609615
    610     strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
     616    strncpy_IFNAMSIZ(ifr.ifr_name, ifname);
    611617    if (ioctl(skfd, SIOCGIFFLAGS, &ifr) < 0) {
    612618        close(skfd);
     
    615621    ife->flags = ifr.ifr_flags;
    616622
    617     strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
     623    strncpy_IFNAMSIZ(ifr.ifr_name, ifname);
    618624    memset(ife->hwaddr, 0, 32);
    619625    if (ioctl(skfd, SIOCGIFHWADDR, &ifr) >= 0)
     
    622628    ife->type = ifr.ifr_hwaddr.sa_family;
    623629
    624     strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
     630    strncpy_IFNAMSIZ(ifr.ifr_name, ifname);
    625631    ife->metric = 0;
    626632    if (ioctl(skfd, SIOCGIFMETRIC, &ifr) >= 0)
    627633        ife->metric = ifr.ifr_metric;
    628634
    629     strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
     635    strncpy_IFNAMSIZ(ifr.ifr_name, ifname);
    630636    ife->mtu = 0;
    631637    if (ioctl(skfd, SIOCGIFMTU, &ifr) >= 0)
     
    634640    memset(&ife->map, 0, sizeof(struct ifmap));
    635641#ifdef SIOCGIFMAP
    636     strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
     642    strncpy_IFNAMSIZ(ifr.ifr_name, ifname);
    637643    if (ioctl(skfd, SIOCGIFMAP, &ifr) == 0)
    638644        ife->map = ifr.ifr_map;
     
    640646
    641647#ifdef HAVE_TXQUEUELEN
    642     strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
     648    strncpy_IFNAMSIZ(ifr.ifr_name, ifname);
    643649    ife->tx_queue_len = -1; /* unknown value */
    644650    if (ioctl(skfd, SIOCGIFTXQLEN, &ifr) >= 0)
     
    648654#endif
    649655
    650     strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
     656    strncpy_IFNAMSIZ(ifr.ifr_name, ifname);
    651657    ifr.ifr_addr.sa_family = AF_INET;
    652658    memset(&ife->addr, 0, sizeof(struct sockaddr));
     
    654660        ife->has_ip = 1;
    655661        ife->addr = ifr.ifr_addr;
    656         strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
     662        strncpy_IFNAMSIZ(ifr.ifr_name, ifname);
    657663        memset(&ife->dstaddr, 0, sizeof(struct sockaddr));
    658664        if (ioctl(skfd, SIOCGIFDSTADDR, &ifr) >= 0)
    659665            ife->dstaddr = ifr.ifr_dstaddr;
    660666
    661         strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
     667        strncpy_IFNAMSIZ(ifr.ifr_name, ifname);
    662668        memset(&ife->broadaddr, 0, sizeof(struct sockaddr));
    663669        if (ioctl(skfd, SIOCGIFBRDADDR, &ifr) >= 0)
    664670            ife->broadaddr = ifr.ifr_broadaddr;
    665671
    666         strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
     672        strncpy_IFNAMSIZ(ifr.ifr_name, ifname);
    667673        memset(&ife->netmask, 0, sizeof(struct sockaddr));
    668674        if (ioctl(skfd, SIOCGIFNETMASK, &ifr) >= 0)
     
    673679    return 0;
    674680}
    675 
    676681
    677682static int do_if_fetch(struct interface *ife)
     
    706711};
    707712
    708 #include <net/if_arp.h>
    709 
    710 #if (defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1) || defined(_NEWLIB_VERSION)
    711 #include <net/ethernet.h>
    712 #else
    713 #include <linux/if_ether.h>
    714 #endif
    715 
    716713/* Display an Ethernet address in readable format. */
    717 static char *pr_ether(unsigned char *ptr)
     714static char* FAST_FUNC ether_print(unsigned char *ptr)
    718715{
    719716    static char *buff;
     
    727724}
    728725
    729 static int in_ether(const char *bufp, struct sockaddr *sap);
     726static int FAST_FUNC ether_input(const char *bufp, struct sockaddr *sap);
    730727
    731728static const struct hwtype ether_hwtype = {
    732     .name =     "ether",
    733     .title =    "Ethernet",
    734     .type =     ARPHRD_ETHER,
    735     .alen =     ETH_ALEN,
    736     .print =    pr_ether,
    737     .input =    in_ether
     729    .name  = "ether",
     730    .title = "Ethernet",
     731    .type  = ARPHRD_ETHER,
     732    .alen  = ETH_ALEN,
     733    .print = ether_print,
     734    .input = ether_input
    738735};
    739736
     
    749746
    750747/* Input an Ethernet address and convert to binary. */
    751 static int in_ether(const char *bufp, struct sockaddr *sap)
     748static int FAST_FUNC ether_input(const char *bufp, struct sockaddr *sap)
    752749{
    753750    unsigned char *ptr;
     
    789786}
    790787
    791 #include <net/if_arp.h>
    792 
    793788static const struct hwtype ppp_hwtype = {
    794789    .name =     "ppp",
     
    806801};
    807802#endif
     803#if ENABLE_FEATURE_HWIB
     804static const struct hwtype ib_hwtype = {
     805    .name  = "infiniband",
     806    .title = "InfiniBand",
     807    .type  = ARPHRD_INFINIBAND,
     808    .alen  = INFINIBAND_ALEN,
     809    .print = UNSPEC_print,
     810    .input = in_ib,
     811};
     812#endif
     813
    808814
    809815static const struct hwtype *const hwtypes[] = {
     
    814820#if ENABLE_FEATURE_IPV6
    815821    &sit_hwtype,
     822#endif
     823#if ENABLE_FEATURE_HWIB
     824    &ib_hwtype,
    816825#endif
    817826    NULL
     
    833842
    834843/* Check our hardware type table for this type. */
    835 const struct hwtype *get_hwtype(const char *name)
     844const struct hwtype* FAST_FUNC get_hwtype(const char *name)
    836845{
    837846    const struct hwtype *const *hwp;
     
    847856
    848857/* Check our hardware type table for this type. */
    849 const struct hwtype *get_hwntype(int type)
     858const struct hwtype* FAST_FUNC get_hwntype(int type)
    850859{
    851860    const struct hwtype *const *hwp;
     
    863872static int hw_null_address(const struct hwtype *hw, void *ap)
    864873{
    865     unsigned int i;
     874    int i;
    866875    unsigned char *address = (unsigned char *) ap;
    867876
     
    897906}
    898907
    899 static void ife_print(struct interface *ptr)
    900 {
    901     const struct aftype *ap;
    902     const struct hwtype *hw;
    903     int hf;
    904     int can_compress = 0;
    905908
    906909#ifdef HAVE_AFINET6
     910#define IPV6_ADDR_ANY           0x0000U
     911
     912#define IPV6_ADDR_UNICAST       0x0001U
     913#define IPV6_ADDR_MULTICAST     0x0002U
     914#define IPV6_ADDR_ANYCAST       0x0004U
     915
     916#define IPV6_ADDR_LOOPBACK      0x0010U
     917#define IPV6_ADDR_LINKLOCAL     0x0020U
     918#define IPV6_ADDR_SITELOCAL     0x0040U
     919
     920#define IPV6_ADDR_COMPATv4      0x0080U
     921
     922#define IPV6_ADDR_SCOPE_MASK    0x00f0U
     923
     924#define IPV6_ADDR_MAPPED        0x1000U
     925#define IPV6_ADDR_RESERVED      0x2000U /* reserved address space */
     926
     927
     928static void ife_print6(struct interface *ptr)
     929{
    907930    FILE *f;
    908931    char addr6[40], devname[20];
     
    910933    int plen, scope, dad_status, if_idx;
    911934    char addr6p[8][5];
    912 #endif
     935
     936    f = fopen_for_read(_PATH_PROCNET_IFINET6);
     937    if (f == NULL)
     938        return;
     939
     940    while (fscanf
     941           (f, "%4s%4s%4s%4s%4s%4s%4s%4s %08x %02x %02x %02x %20s\n",
     942            addr6p[0], addr6p[1], addr6p[2], addr6p[3], addr6p[4],
     943            addr6p[5], addr6p[6], addr6p[7], &if_idx, &plen, &scope,
     944            &dad_status, devname) != EOF
     945    ) {
     946        if (!strcmp(devname, ptr->name)) {
     947            sprintf(addr6, "%s:%s:%s:%s:%s:%s:%s:%s",
     948                    addr6p[0], addr6p[1], addr6p[2], addr6p[3],
     949                    addr6p[4], addr6p[5], addr6p[6], addr6p[7]);
     950            inet_pton(AF_INET6, addr6,
     951                      (struct sockaddr *) &sap.sin6_addr);
     952            sap.sin6_family = AF_INET6;
     953            printf("          inet6 addr: %s/%d",
     954                   INET6_sprint((struct sockaddr *) &sap, 1),
     955                   plen);
     956            printf(" Scope:");
     957            switch (scope & IPV6_ADDR_SCOPE_MASK) {
     958            case 0:
     959                puts("Global");
     960                break;
     961            case IPV6_ADDR_LINKLOCAL:
     962                puts("Link");
     963                break;
     964            case IPV6_ADDR_SITELOCAL:
     965                puts("Site");
     966                break;
     967            case IPV6_ADDR_COMPATv4:
     968                puts("Compat");
     969                break;
     970            case IPV6_ADDR_LOOPBACK:
     971                puts("Host");
     972                break;
     973            default:
     974                puts("Unknown");
     975            }
     976        }
     977    }
     978    fclose(f);
     979}
     980#else
     981#define ife_print6(a) ((void)0)
     982#endif
     983
     984static void ife_print(struct interface *ptr)
     985{
     986    const struct aftype *ap;
     987    const struct hwtype *hw;
     988    int hf;
     989    int can_compress = 0;
    913990
    914991    ap = get_afntype(ptr->addr.sa_family);
     
    9251002        hw = get_hwntype(-1);
    9261003
    927     printf("%-9.9s Link encap:%s  ", ptr->name, hw->title);
     1004    printf("%-9s Link encap:%s  ", ptr->name, hw->title);
    9281005    /* For some hardware types (eg Ash, ATM) we don't print the
    9291006       hardware address if it's null.  */
    930     if (hw->print != NULL && (!(hw_null_address(hw, ptr->hwaddr) &&
    931                                 hw->suppress_null_addr)))
     1007    if (hw->print != NULL
     1008     && !(hw_null_address(hw, ptr->hwaddr) && hw->suppress_null_addr)
     1009    ) {
    9321010        printf("HWaddr %s  ", hw->print((unsigned char *)ptr->hwaddr));
     1011    }
    9331012#ifdef IFF_PORTSEL
    9341013    if (ptr->flags & IFF_PORTSEL) {
     
    9381017    }
    9391018#endif
    940     puts("");
     1019    bb_putchar('\n');
    9411020
    9421021    if (ptr->has_ip) {
     
    9521031    }
    9531032
    954 #ifdef HAVE_AFINET6
    955 
    956 #define IPV6_ADDR_ANY           0x0000U
    957 
    958 #define IPV6_ADDR_UNICAST       0x0001U
    959 #define IPV6_ADDR_MULTICAST     0x0002U
    960 #define IPV6_ADDR_ANYCAST       0x0004U
    961 
    962 #define IPV6_ADDR_LOOPBACK      0x0010U
    963 #define IPV6_ADDR_LINKLOCAL     0x0020U
    964 #define IPV6_ADDR_SITELOCAL     0x0040U
    965 
    966 #define IPV6_ADDR_COMPATv4      0x0080U
    967 
    968 #define IPV6_ADDR_SCOPE_MASK    0x00f0U
    969 
    970 #define IPV6_ADDR_MAPPED        0x1000U
    971 #define IPV6_ADDR_RESERVED      0x2000U /* reserved address space */
    972 
    973     f = fopen(_PATH_PROCNET_IFINET6, "r");
    974     if (f != NULL) {
    975         while (fscanf
    976                (f, "%4s%4s%4s%4s%4s%4s%4s%4s %08x %02x %02x %02x %20s\n",
    977                 addr6p[0], addr6p[1], addr6p[2], addr6p[3], addr6p[4],
    978                 addr6p[5], addr6p[6], addr6p[7], &if_idx, &plen, &scope,
    979                 &dad_status, devname) != EOF
    980         ) {
    981             if (!strcmp(devname, ptr->name)) {
    982                 sprintf(addr6, "%s:%s:%s:%s:%s:%s:%s:%s",
    983                         addr6p[0], addr6p[1], addr6p[2], addr6p[3],
    984                         addr6p[4], addr6p[5], addr6p[6], addr6p[7]);
    985                 inet_pton(AF_INET6, addr6,
    986                           (struct sockaddr *) &sap.sin6_addr);
    987                 sap.sin6_family = AF_INET6;
    988                 printf("          inet6 addr: %s/%d",
    989                        INET6_sprint((struct sockaddr *) &sap, 1),
    990                        plen);
    991                 printf(" Scope:");
    992                 switch (scope & IPV6_ADDR_SCOPE_MASK) {
    993                 case 0:
    994                     puts("Global");
    995                     break;
    996                 case IPV6_ADDR_LINKLOCAL:
    997                     puts("Link");
    998                     break;
    999                 case IPV6_ADDR_SITELOCAL:
    1000                     puts("Site");
    1001                     break;
    1002                 case IPV6_ADDR_COMPATv4:
    1003                     puts("Compat");
    1004                     break;
    1005                 case IPV6_ADDR_LOOPBACK:
    1006                     puts("Host");
    1007                     break;
    1008                 default:
    1009                     puts("Unknown");
    1010                 }
    1011             }
    1012         }
    1013         fclose(f);
    1014     }
    1015 #endif
     1033    ife_print6(ptr);
    10161034
    10171035    printf("          ");
     
    10741092        printf("  Outfill:%d  Keepalive:%d", ptr->outfill, ptr->keepalive);
    10751093#endif
    1076     puts("");
     1094    bb_putchar('\n');
    10771095
    10781096    /* If needed, display the interface statistics. */
     
    11051123        print_bytes_scaled(ptr->stats.rx_bytes, "  T");
    11061124        print_bytes_scaled(ptr->stats.tx_bytes, "\n");
    1107 
    1108     }
    1109 
    1110     if ((ptr->map.irq || ptr->map.mem_start || ptr->map.dma ||
    1111          ptr->map.base_addr)) {
     1125    }
     1126
     1127    if (ptr->map.irq || ptr->map.mem_start
     1128     || ptr->map.dma || ptr->map.base_addr
     1129    ) {
    11121130        printf("          ");
    11131131        if (ptr->map.irq)
     
    11231141        if (ptr->map.dma)
    11241142            printf("DMA chan:%x ", ptr->map.dma);
    1125         puts("");
    1126     }
    1127     puts("");
    1128 }
    1129 
     1143        bb_putchar('\n');
     1144    }
     1145    bb_putchar('\n');
     1146}
    11301147
    11311148static int do_if_print(struct interface *ife) /*, int *opt_a)*/
     
    11611178    for (ife = int_list; ife; ife = ife->next) {
    11621179        int err = doit(ife, cookie);
    1163 
    11641180        if (err)
    11651181            return err;
     
    11931209}
    11941210
    1195 int display_interfaces(char *ifname)
     1211#if ENABLE_FEATURE_HWIB
     1212/* Input an Infiniband address and convert to binary. */
     1213int FAST_FUNC in_ib(const char *bufp, struct sockaddr *sap)
     1214{
     1215    sap->sa_family = ib_hwtype.type;
     1216//TODO: error check?
     1217    hex2bin((char*)sap->sa_data, bufp, INFINIBAND_ALEN);
     1218# ifdef HWIB_DEBUG
     1219    fprintf(stderr, "in_ib(%s): %s\n", bufp, UNSPEC_print(sap->sa_data));
     1220# endif
     1221    return 0;
     1222}
     1223#endif
     1224
     1225int FAST_FUNC display_interfaces(char *ifname)
    11961226{
    11971227    int status;
Note: See TracChangeset for help on using the changeset viewer.