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

    r1765 r2725  
    1111 *              (derived from FvK's 'route.c     1.70    01/04/94')
    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 *
     
    2626 */
    2727
    28 #include <getopt.h>
    2928#include <net/route.h>
    3029#include <net/if.h>
     
    153152/* Add or delete a route, depending on action. */
    154153
    155 static void INET_setroute(int action, char **args)
     154static NOINLINE void INET_setroute(int action, char **args)
    156155{
    157156    struct rtentry rt;
     
    180179
    181180            prefix_len = xatoul_range(prefix+1, 0, 32);
    182             mask_in_addr(rt) = htonl( ~ (0xffffffffUL >> prefix_len));
     181            mask_in_addr(rt) = htonl( ~(0xffffffffUL >> prefix_len));
    183182            *prefix = '\0';
    184183#if HAVE_NEW_ADDRT
     
    187186        } else {
    188187            /* Default netmask. */
    189             netmask = bb_str_default;
     188            netmask = "default";
    190189        }
    191190        /* Prefer hostname lookup is -host flag (xflag==1) was given. */
     
    304303    /* sanity checks.. */
    305304    if (mask_in_addr(rt)) {
    306         unsigned long mask = mask_in_addr(rt);
     305        uint32_t mask = mask_in_addr(rt);
    307306
    308307        mask = ~ntohl(mask);
     
    315314        }
    316315        mask = ((struct sockaddr_in *) &rt.rt_dst)->sin_addr.s_addr;
    317         if (mask & ~mask_in_addr(rt)) {
     316        if (mask & ~(uint32_t)mask_in_addr(rt)) {
    318317            bb_error_msg_and_die("netmask and route address conflict");
    319318        }
     
    338337#if ENABLE_FEATURE_IPV6
    339338
    340 static void INET6_setroute(int action, char **args)
     339static NOINLINE void INET6_setroute(int action, char **args)
    341340{
    342341    struct sockaddr_in6 sa6;
     
    348347        const char *target = *args++;
    349348
    350         if (strcmp(target, bb_str_default) == 0) {
     349        if (strcmp(target, "default") == 0) {
    351350            prefix_len = 0;
    352351            memset(&sa6, 0, sizeof(sa6));
    353352        } else {
    354353            char *cp;
    355             if ((cp = strchr(target, '/'))) { /* Yes... const to non is ok. */
    356                 *cp = 0;
    357                 prefix_len = xatoul_range(cp+1, 0, 128);
     354            cp = strchr(target, '/'); /* Yes... const to non is ok. */
     355            if (cp) {
     356                *cp = '\0';
     357                prefix_len = xatoul_range(cp + 1, 0, 128);
    358358            } else {
    359359                prefix_len = 128;
     
    424424        struct ifreq ifr;
    425425        memset(&ifr, 0, sizeof(ifr));
    426         strncpy(ifr.ifr_name, devname, sizeof(ifr.ifr_name));
     426        strncpy_IFNAMSIZ(ifr.ifr_name, devname);
    427427        xioctl(skfd, SIOGIFINDEX, &ifr);
    428428        rt.rtmsg_ifindex = ifr.ifr_ifindex;
     
    477477
    478478/* also used in netstat */
    479 void bb_displayroutes(int noresolve, int netstatfmt)
     479void FAST_FUNC bb_displayroutes(int noresolve, int netstatfmt)
    480480{
    481481    char devname[64], flags[16], *sdest, *sgw;
     
    485485    struct in_addr mask;
    486486
    487     FILE *fp = xfopen("/proc/net/route", "r");
     487    FILE *fp = xfopen_for_read("/proc/net/route");
    488488
    489489    printf("Kernel IP routing table\n"
     
    539539#if ENABLE_FEATURE_IPV6
    540540
    541 static void INET6_displayroutes(int noresolve)
     541static void INET6_displayroutes(void)
    542542{
    543543    char addr6[128], *naddr6;
     
    553553    struct sockaddr_in6 snaddr6;
    554554
    555     FILE *fp = xfopen("/proc/net/ipv6_route", "r");
     555    FILE *fp = xfopen_for_read("/proc/net/ipv6_route");
    556556
    557557    printf("Kernel IPv6 routing table\n%-44s%-40s"
     
    562562        int r;
    563563        r = fscanf(fp, "%32s%x%*s%x%32s%x%x%x%x%s\n",
    564                    addr6x+14, &prefix_len, &slen, addr6x+40+7,
    565                    &metric, &use, &refcnt, &iflags, iface);
     564                addr6x+14, &prefix_len, &slen, addr6x+40+7,
     565                &metric, &use, &refcnt, &iflags, iface);
    566566        if (r != 9) {
    567567            if ((r < 0) && feof(fp)) { /* EOF with no (nonspace) chars read. */
     
    641641;
    642642
    643 int route_main(int argc, char **argv);
    644 int route_main(int argc, char **argv)
     643int route_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
     644int route_main(int argc UNUSED_PARAM, char **argv)
    645645{
    646646    unsigned opt;
     
    675675#if ENABLE_FEATURE_IPV6
    676676        if (opt & ROUTE_OPT_INET6)
    677             INET6_displayroutes(noresolve);
     677            INET6_displayroutes();
    678678        else
    679679#endif
Note: See TracChangeset for help on using the changeset viewer.