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/libiproute/ll_map.c

    r1765 r2725  
    11/* vi: set sw=4 ts=4: */
    22/*
    3  * ll_map.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.
    47 *
    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>
    11  *
     8 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
    129 */
    1310
    14 #include <net/if.h> /* struct ifreq and co. */
     11#include <net/if.h>  /* struct ifreq and co. */
    1512
    1613#include "libbb.h"
     
    2825};
    2926
    30 static struct idxmap *idxmap[16];
     27static struct idxmap **idxmap; /* treat as *idxmap[16] */
    3128
    3229static struct idxmap *find_by_index(int idx)
     
    3431    struct idxmap *im;
    3532
    36     for (im = idxmap[idx & 0xF]; im; im = im->next)
    37         if (im->index == idx)
    38             return im;
     33    if (idxmap)
     34        for (im = idxmap[idx & 0xF]; im; im = im->next)
     35            if (im->index == idx)
     36                return im;
    3937    return NULL;
    4038}
    4139
    42 int ll_remember_index(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
     40int FAST_FUNC ll_remember_index(const struct sockaddr_nl *who UNUSED_PARAM,
     41        struct nlmsghdr *n,
     42        void *arg UNUSED_PARAM)
    4343{
    4444    int h;
     
    5858        return 0;
    5959
     60    if (!idxmap)
     61        idxmap = xzalloc(sizeof(idxmap[0]) * 16);
     62
    6063    h = ifi->ifi_index & 0xF;
    61 
    6264    for (imp = &idxmap[h]; (im = *imp) != NULL; imp = &im->next)
    6365        if (im->index == ifi->ifi_index)
     
    7476        int alen;
    7577        im->alen = alen = RTA_PAYLOAD(tb[IFLA_ADDRESS]);
    76         if (alen > sizeof(im->addr))
     78        if (alen > (int)sizeof(im->addr))
    7779            alen = sizeof(im->addr);
    7880        memcpy(im->addr, RTA_DATA(tb[IFLA_ADDRESS]), alen);
     
    8587}
    8688
    87 const char *ll_idx_n2a(int idx, char *buf)
     89const char FAST_FUNC *ll_idx_n2a(int idx, char *buf)
    8890{
    8991    struct idxmap *im;
     
    99101
    100102
    101 const char *ll_index_to_name(int idx)
     103const char FAST_FUNC *ll_index_to_name(int idx)
    102104{
    103105    static char nbuf[16];
     
    120122#endif
    121123
    122 unsigned ll_index_to_flags(int idx)
     124unsigned FAST_FUNC ll_index_to_flags(int idx)
    123125{
    124126    struct idxmap *im;
     
    132134}
    133135
    134 int xll_name_to_index(const char *const name)
     136int FAST_FUNC xll_name_to_index(const char *name)
    135137{
    136138    int ret = 0;
     
    151153        goto out;
    152154    }
    153     for (i = 0; i < 16; i++) {
    154         for (im = idxmap[i]; im; im = im->next) {
    155             if (strcmp(im->name, name) == 0) {
    156                 icache = im->index;
    157                 strcpy(ncache, name);
    158                 ret = im->index;
    159                 goto out;
     155    if (idxmap) {
     156        for (i = 0; i < 16; i++) {
     157            for (im = idxmap[i]; im; im = im->next) {
     158                if (strcmp(im->name, name) == 0) {
     159                    icache = im->index;
     160                    strcpy(ncache, name);
     161                    ret = im->index;
     162                    goto out;
     163                }
    160164            }
    161165        }
     
    171175
    172176    sock_fd = socket(AF_INET, SOCK_DGRAM, 0);
    173     if (sock_fd) {
     177    if (sock_fd >= 0) {
    174178        struct ifreq ifr;
    175179        int tmp;
    176180
    177         strncpy(ifr.ifr_name, name, IFNAMSIZ);
     181        strncpy_IFNAMSIZ(ifr.ifr_name, name);
    178182        ifr.ifr_ifindex = -1;
    179183        tmp = ioctl(sock_fd, SIOCGIFINDEX, &ifr);
     
    187191/* out:*/
    188192    if (ret <= 0)
    189         bb_error_msg_and_die("cannot find device \"%s\"", name);
     193        bb_error_msg_and_die("can't find device '%s'", name);
    190194    return ret;
    191195}
    192196
    193 int ll_init_map(struct rtnl_handle *rth)
     197int FAST_FUNC ll_init_map(struct rtnl_handle *rth)
    194198{
    195199    xrtnl_wilddump_request(rth, AF_UNSPEC, RTM_GETLINK);
    196     xrtnl_dump_filter(rth, ll_remember_index, &idxmap);
     200    xrtnl_dump_filter(rth, ll_remember_index, NULL);
    197201    return 0;
    198202}
Note: See TracChangeset for help on using the changeset viewer.