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/ifconfig.c

    r1765 r2725  
    1111 *              Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
    1212 *
    13  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
     13 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    1414 */
    1515
     
    3737#include <netinet/if_ether.h>
    3838#endif
     39#include "libbb.h"
    3940#include "inet_common.h"
    40 #include "libbb.h"
    4141
    4242#if ENABLE_FEATURE_IFCONFIG_SLIP
     
    165165struct arg1opt {
    166166    const char *name;
    167     int selector;
     167    unsigned short selector;
    168168    unsigned short ifr_offset;
    169169};
     
    184184
    185185static const struct arg1opt Arg1Opt[] = {
    186     {"SIOCSIFMETRIC",  SIOCSIFMETRIC,  ifreq_offsetof(ifr_metric)},
    187     {"SIOCSIFMTU",     SIOCSIFMTU,     ifreq_offsetof(ifr_mtu)},
    188     {"SIOCSIFTXQLEN",  SIOCSIFTXQLEN,  ifreq_offsetof(ifr_qlen)},
    189     {"SIOCSIFDSTADDR", SIOCSIFDSTADDR, ifreq_offsetof(ifr_dstaddr)},
    190     {"SIOCSIFNETMASK", SIOCSIFNETMASK, ifreq_offsetof(ifr_netmask)},
    191     {"SIOCSIFBRDADDR", SIOCSIFBRDADDR, ifreq_offsetof(ifr_broadaddr)},
    192 #if ENABLE_FEATURE_IFCONFIG_HW
    193     {"SIOCSIFHWADDR",  SIOCSIFHWADDR,  ifreq_offsetof(ifr_hwaddr)},
    194 #endif
    195     {"SIOCSIFDSTADDR", SIOCSIFDSTADDR, ifreq_offsetof(ifr_dstaddr)},
     186    { "SIFMETRIC",  SIOCSIFMETRIC,  ifreq_offsetof(ifr_metric) },
     187    { "SIFMTU",     SIOCSIFMTU,     ifreq_offsetof(ifr_mtu) },
     188    { "SIFTXQLEN",  SIOCSIFTXQLEN,  ifreq_offsetof(ifr_qlen) },
     189    { "SIFDSTADDR", SIOCSIFDSTADDR, ifreq_offsetof(ifr_dstaddr) },
     190    { "SIFNETMASK", SIOCSIFNETMASK, ifreq_offsetof(ifr_netmask) },
     191    { "SIFBRDADDR", SIOCSIFBRDADDR, ifreq_offsetof(ifr_broadaddr) },
     192#if ENABLE_FEATURE_IFCONFIG_HW
     193    { "SIFHWADDR",  SIOCSIFHWADDR,  ifreq_offsetof(ifr_hwaddr) },
     194#endif
     195    { "SIFDSTADDR", SIOCSIFDSTADDR, ifreq_offsetof(ifr_dstaddr) },
    196196#ifdef SIOCSKEEPALIVE
    197     {"SIOCSKEEPALIVE", SIOCSKEEPALIVE, ifreq_offsetof(ifr_data)},
     197    { "SKEEPALIVE", SIOCSKEEPALIVE, ifreq_offsetof(ifr_data) },
    198198#endif
    199199#ifdef SIOCSOUTFILL
    200     {"SIOCSOUTFILL",   SIOCSOUTFILL,   ifreq_offsetof(ifr_data)},
     200    { "SOUTFILL",   SIOCSOUTFILL,   ifreq_offsetof(ifr_data) },
    201201#endif
    202202#if ENABLE_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
    203     {"SIOCSIFMAP",     SIOCSIFMAP,     ifreq_offsetof(ifr_map.mem_start)},
    204     {"SIOCSIFMAP",     SIOCSIFMAP,     ifreq_offsetof(ifr_map.base_addr)},
    205     {"SIOCSIFMAP",     SIOCSIFMAP,     ifreq_offsetof(ifr_map.irq)},
     203    { "SIFMAP",     SIOCSIFMAP,     ifreq_offsetof(ifr_map.mem_start) },
     204    { "SIFMAP",     SIOCSIFMAP,     ifreq_offsetof(ifr_map.base_addr) },
     205    { "SIFMAP",     SIOCSIFMAP,     ifreq_offsetof(ifr_map.irq) },
    206206#endif
    207207    /* Last entry if for unmatched (possibly hostname) arg. */
    208208#if ENABLE_FEATURE_IPV6
    209     {"SIOCSIFADDR",    SIOCSIFADDR,    ifreq_offsetof(ifr_addr)}, /* IPv6 version ignores the offset */
    210     {"SIOCDIFADDR",    SIOCDIFADDR,    ifreq_offsetof(ifr_addr)}, /* IPv6 version ignores the offset */
    211 #endif
    212     {"SIOCSIFADDR",    SIOCSIFADDR,    ifreq_offsetof(ifr_addr)},
     209    { "SIFADDR",    SIOCSIFADDR,    ifreq_offsetof(ifr_addr) }, /* IPv6 version ignores the offset */
     210    { "DIFADDR",    SIOCDIFADDR,    ifreq_offsetof(ifr_addr) }, /* IPv6 version ignores the offset */
     211#endif
     212    { "SIFADDR",    SIOCSIFADDR,    ifreq_offsetof(ifr_addr) },
    213213};
    214214
    215215static const struct options OptArray[] = {
    216     {"metric",      N_ARG,         ARG_METRIC,      0},
    217     {"mtu",         N_ARG,         ARG_MTU,         0},
    218     {"txqueuelen",  N_ARG,         ARG_TXQUEUELEN,  0},
    219     {"dstaddr",     N_ARG,         ARG_DSTADDR,     0},
    220     {"netmask",     N_ARG,         ARG_NETMASK,     0},
    221     {"broadcast",   N_ARG | M_CLR, ARG_BROADCAST,   IFF_BROADCAST},
    222 #if ENABLE_FEATURE_IFCONFIG_HW
    223     {"hw",          N_ARG, ARG_HW,                  0},
    224 #endif
    225     {"pointopoint", N_ARG | M_CLR, ARG_POINTOPOINT, IFF_POINTOPOINT},
     216    { "metric",      N_ARG,         ARG_METRIC,      0 },
     217    { "mtu",         N_ARG,         ARG_MTU,         0 },
     218    { "txqueuelen",  N_ARG,         ARG_TXQUEUELEN,  0 },
     219    { "dstaddr",     N_ARG,         ARG_DSTADDR,     0 },
     220    { "netmask",     N_ARG,         ARG_NETMASK,     0 },
     221    { "broadcast",   N_ARG | M_CLR, ARG_BROADCAST,   IFF_BROADCAST },
     222#if ENABLE_FEATURE_IFCONFIG_HW
     223    { "hw",          N_ARG,         ARG_HW,          0 },
     224#endif
     225    { "pointopoint", N_ARG | M_CLR, ARG_POINTOPOINT, IFF_POINTOPOINT },
    226226#ifdef SIOCSKEEPALIVE
    227     {"keepalive",   N_ARG,         ARG_KEEPALIVE,   0},
     227    { "keepalive",   N_ARG,         ARG_KEEPALIVE,   0 },
    228228#endif
    229229#ifdef SIOCSOUTFILL
    230     {"outfill",     N_ARG,         ARG_OUTFILL,     0},
     230    { "outfill",     N_ARG,         ARG_OUTFILL,     0 },
    231231#endif
    232232#if ENABLE_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
    233     {"mem_start",   N_ARG,         ARG_MEM_START,   0},
    234     {"io_addr",     N_ARG,         ARG_IO_ADDR,     0},
    235     {"irq",         N_ARG,         ARG_IRQ,         0},
     233    { "mem_start",   N_ARG,         ARG_MEM_START,   0 },
     234    { "io_addr",     N_ARG,         ARG_IO_ADDR,     0 },
     235    { "irq",         N_ARG,         ARG_IRQ,         0 },
    236236#endif
    237237#if ENABLE_FEATURE_IPV6
    238     {"add",         N_ARG,         ARG_ADD_DEL,     0},
    239     {"del",         N_ARG,         ARG_ADD_DEL,     0},
    240 #endif
    241     {"arp",         N_CLR | M_SET, 0,               IFF_NOARP},
    242     {"trailers",    N_CLR | M_SET, 0,               IFF_NOTRAILERS},
    243     {"promisc",     N_SET | M_CLR, 0,               IFF_PROMISC},
    244     {"multicast",   N_SET | M_CLR, 0,               IFF_MULTICAST},
    245     {"allmulti",    N_SET | M_CLR, 0,               IFF_ALLMULTI},
    246     {"dynamic",     N_SET | M_CLR, 0,               IFF_DYNAMIC},
    247     {"up",          N_SET,         0,               (IFF_UP | IFF_RUNNING)},
    248     {"down",        N_CLR,         0,               IFF_UP},
    249     {NULL,          0,             ARG_HOSTNAME,    (IFF_UP | IFF_RUNNING)}
     238    { "add",         N_ARG,         ARG_ADD_DEL,     0 },
     239    { "del",         N_ARG,         ARG_ADD_DEL,     0 },
     240#endif
     241    { "arp",         N_CLR | M_SET, 0,               IFF_NOARP },
     242    { "trailers",    N_CLR | M_SET, 0,               IFF_NOTRAILERS },
     243    { "promisc",     N_SET | M_CLR, 0,               IFF_PROMISC },
     244    { "multicast",   N_SET | M_CLR, 0,               IFF_MULTICAST },
     245    { "allmulti",    N_SET | M_CLR, 0,               IFF_ALLMULTI },
     246    { "dynamic",     N_SET | M_CLR, 0,               IFF_DYNAMIC },
     247    { "up",          N_SET,         0,               (IFF_UP | IFF_RUNNING) },
     248    { "down",        N_CLR,         0,               IFF_UP },
     249    { NULL,          0,             ARG_HOSTNAME,    (IFF_UP | IFF_RUNNING) }
    250250};
    251251
     
    253253 * A couple of prototypes.
    254254 */
    255 
    256255#if ENABLE_FEATURE_IFCONFIG_HW
    257256static int in_ether(const char *bufp, struct sockaddr *sap);
     
    261260 * Our main function.
    262261 */
    263 
    264 int ifconfig_main(int argc, char **argv);
    265 int ifconfig_main(int argc, char **argv)
     262int ifconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
     263int ifconfig_main(int argc UNUSED_PARAM, char **argv)
    266264{
    267265    struct ifreq ifr;
     
    294292    /* skip argv[0] */
    295293    ++argv;
    296     --argc;
    297294
    298295#if ENABLE_FEATURE_IFCONFIG_STATUS
    299     if (argc > 0 && (argv[0][0] == '-' && argv[0][1] == 'a' && !argv[0][2])) {
     296    if (argv[0] && (argv[0][0] == '-' && argv[0][1] == 'a' && !argv[0][2])) {
    300297        interface_opt_a = 1;
    301         --argc;
    302298        ++argv;
    303299    }
    304300#endif
    305301
    306     if (argc <= 1) {
     302    if (!argv[0] || !argv[1]) { /* one or no args */
    307303#if ENABLE_FEATURE_IFCONFIG_STATUS
    308         return display_interfaces(argc ? *argv : NULL);
     304        return display_interfaces(argv[0] /* can be NULL */);
    309305#else
    310306        bb_error_msg_and_die("no support for status display");
     
    316312
    317313    /* get interface name */
    318     safe_strncpy(ifr.ifr_name, *argv, IFNAMSIZ);
     314    strncpy_IFNAMSIZ(ifr.ifr_name, *argv);
    319315
    320316    /* Process the remaining arguments. */
     
    375371                        sai.sin_family = AF_INET;
    376372                        sai.sin_port = 0;
    377                         if (!strcmp(host, bb_str_default)) {
     373                        if (strcmp(host, "default") == 0) {
    378374                            /* Default is special, meaning 0.0.0.0. */
    379375                            sai.sin_addr.s_addr = INADDR_ANY;
     
    393389                            lsa = xhost2sockaddr(host, 0);
    394390#if ENABLE_FEATURE_IPV6
    395                             if (lsa->sa.sa_family == AF_INET6) {
     391                            if (lsa->u.sa.sa_family == AF_INET6) {
    396392                                int sockfd6;
    397393                                struct in6_ifreq ifr6;
    398394
    399395                                memcpy((char *) &ifr6.ifr6_addr,
    400                                         (char *) &(lsa->sin6.sin6_addr),
     396                                        (char *) &(lsa->u.sin6.sin6_addr),
    401397                                        sizeof(struct in6_addr));
    402398
     
    406402                                ifr6.ifr6_ifindex = ifr.ifr_ifindex;
    407403                                ifr6.ifr6_prefixlen = prefix_len;
    408                                 ioctl_or_perror_and_die(sockfd6, a1op->selector, &ifr6, "%s", a1op->name);
     404                                ioctl_or_perror_and_die(sockfd6, a1op->selector, &ifr6, "SIOC%s", a1op->name);
    409405                                if (ENABLE_FEATURE_CLEAN_UP)
    410406                                    free(lsa);
     
    412408                            }
    413409#endif
    414                             sai.sin_addr = lsa->sin.sin_addr;
     410                            sai.sin_addr = lsa->u.sin.sin_addr;
    415411                            if (ENABLE_FEATURE_CLEAN_UP)
    416412                                free(lsa);
     
    426422                    } else {    /* A_CAST_HOST_COPY_IN_ETHER */
    427423                        /* This is the "hw" arg case. */
    428                         if (strcmp("ether", *argv) || !*++argv)
     424                        smalluint hw_class= index_in_substrings("ether\0"
     425                                IF_FEATURE_HWIB("infiniband\0"), *argv) + 1;
     426                        if (!hw_class || !*++argv)
    429427                            bb_show_usage();
    430428                        /*safe_strncpy(host, *argv, sizeof(host));*/
    431429                        host = *argv;
    432                         if (in_ether(host, &sa))
     430                        if (hw_class == 1 ? in_ether(host, &sa) : in_ib(host, &sa))
    433431                            bb_error_msg_and_die("invalid hw-addr %s", host);
    434432                        p = (char *) &sa;
     
    458456                }
    459457
    460                 ioctl_or_perror_and_die(sockfd, a1op->selector, &ifr, "%s", a1op->name);
     458                ioctl_or_perror_and_die(sockfd, a1op->selector, &ifr, "SIOC%s", a1op->name);
    461459#ifdef QUESTIONABLE_ALIAS_CASE
    462460                if (mask & A_COLON_CHK) {
     
    507505
    508506    sap->sa_family = ARPHRD_ETHER;
    509     ptr = sap->sa_data;
     507    ptr = (char *) sap->sa_data;
    510508
    511509    i = 0;
Note: See TracChangeset for help on using the changeset viewer.