Ignore:
Timestamp:
Nov 6, 2007, 11:01:53 AM (12 years ago)
Author:
Bruno Cornec
Message:
  • Better output for mindi-busybox revision
  • Remove dummy file created on NFS - report from Arnaud Tiger <arnaud.tiger_at_hp.com>
  • strace useful for debug
  • fix new versions for pb (2.0.0 for mindi and 1.7.2 for mindi-busybox)
  • fix build process for mindi-busybox + options used in that version (dd for label-partitions-as-necessary)
  • fix typo in label-partitions-as-necessary which doesn't seem to work
  • Update to busybox 1.7.2
  • perl is now required at restore time to support uuid swap partitions (and will be used for many other thigs

in the future for sure)

  • next mindi version will be 2.0.0 due to all the changes made in it (udev may break working distros)
  • small optimization in mindi on keyboard handling (one single find instead of multiple)
  • better interaction for USB device when launching mindi manually
  • attempt to automatically guess block disk size for ramdisk
  • fix typos in bkphw
  • Fix the remaining problem with UUID support for swap partitions
  • Updates mondoarchive man page for USB support
  • Adds preliminary Hardware support to mindi (Proliant SSSTK)
  • Tries to add udev support also for rhel4
  • Fix UUID support which was still broken.
  • Be conservative in test for the start-nfs script
  • Update config file for mindi-busybox for 1.7.2 migration
  • Try to run around a busybox bug (1.2.2 pb on inexistant links)
  • Add build content for mindi-busybox in pb
  • Remove distributions content for mindi-busybox
  • Fix a warning on inexistant raidtab
  • Solve problem on tmpfs in restore init (Problem of inexistant symlink and busybox)
  • Create MONDO_CACHE and use it everywhere + creation at start
  • Really never try to eject a USB device
  • Fix a issue with &> usage (replaced with 1> and 2>)
  • Adds magic file to depllist in order to have file working + ldd which helps for debugging issues
  • tty modes correct to avoid sh error messages
  • Use ext3 normally and not ext2 instead
  • USB device should be corrected after reading (take 1st part)
  • Adds a mount_USB_here function derived from mount_CDROM_here
  • usb detection place before /dev detection in device name at restore time
  • Fix when restoring from USB: media is asked in interactive mode
  • Adds USB support for mondorestore
  • mount_cdrom => mount_media
  • elilo.efi is now searched throughout /boot/efi and not in a fixed place as there is no standard
  • untar-and-softlink => untar (+ interface change)
  • suppress useless softlinks creation/removal in boot process
  • avoids udevd messages on groups
  • Increase # of disks to 99 as in mindi at restore time (should be a conf file parameter)
  • skip existing big file creation
  • seems to work correctly for USB mindi boot
  • Adds group and tty link to udev conf
  • Always load usb-torage (even 2.6) to initiate USB bus discovery
  • Better printing of messages
  • Attempt to fix a bug in supporting OpenSusE 10.3 kernel for initramfs (mindi may now use multiple regex for kernel initrd detection)
  • Links were not correctly done as non relative for modules in mindi
  • exclusion of modules denied now works
  • Also create modules in their ordinary place, so that classical modprobe works + copy modules.dep
  • Fix bugs for DENY_MODS handling
  • Add device /dev/console for udev
  • ide-generic should now really be excluded
  • Fix a bug in major number for tty
  • If udev then adds modprobe/insmod to rootfs
  • tty0 is also cretaed with udev
  • ide-generic put rather in DENY_MODS
  • udevd remove from deplist s handled in mindi directly
  • better default for mindi when using --usb
  • Handles dynamically linked busybox (in case we want to use it soon ;-)
  • Adds fixed devices to create for udev
  • ide-generic should not be part of the initrd when using libata v2
  • support a dynamically linked udev (case on Ubuntu 7.10 and Mandriva 2008.0 so should be quite generic) This will give incitation to move to dyn. linked binaries in the initrd which will help for other tasks (ia6 4)
  • Improvement in udev support (do not use cl options not available in busybox)
  • Udev in mindi
    • auto creation of the right links at boot time with udev-links.conf(from Mandriva 2008.0)
    • rework startup of udev as current makes kernel crash (from Mandriva 2008.0)
    • add support for 64 bits udev
  • Try to render MyInsmod? silent at boot time
  • Adds udev support (mandatory for newest distributions to avoid remapping of devices in a different way as on the original system)
  • We also need vaft format support for USB boot
  • Adds libusual support (Ubuntu 7.10 needs it for USB)
  • Improve Ubuntu/Debian? keyboard detection and support
  • pbinit adapted to new pb (0.8.10). Filtering of docs done in it
  • Suppress some mondo warnings and errors on USB again
  • Tries to fix lack of files in deb mindi package
  • Verify should now work for USB devices
  • More log/mesages improvement for USB support
  • - Supress g_erase_tmpdir_and_scratchdir
  • Improve some log messages for USB support
  • Try to improve install in mindi to avoid issues with isolinux.cfg not installed vene if in the pkg :-(
  • Improve mindi-busybox build
  • In conformity with pb 0.8.9
  • Add support for Ubuntu 7.10 in build process
  • Add USB Key button to Menu UI (CD streamer removed)
  • Attempt to fix error messages on tmp/scratch files at the end by removing those dir at the latest possible.
  • Fix a bug linked to the size of the -E param which could be used (Arnaud Tiger/René? Ribaud).
  • Integrate ~/.pbrc content into mondorescue.pb (required project-builder >= 0.8.7)
  • Put mondorescue in conformity with new pb filtering rules
  • Add USB support at restore time (no test done yet). New start-usb script PB varibale added where useful
  • Unmounting USB device before removal of temporary scratchdir
  • Stil refining USB copy back to mondo (one command was not executed)
  • No need to have the image subdor in the csratchdir when USB.
  • umount the USB partition before attempting to use it
  • Remove useless copy from mindi to mondo at end of USB handling

(risky merge, we are raising the limits of 2 diverging branches. The status of stable is not completely sure as such. Will need lots of tests, but it's not yet done :-()
(merge -r1692:1769 $SVN_M/branches/2.2.5)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mindi-busybox/networking/route.c

    r821 r1770  
    1313 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
    1414 *
    15  * $Id: route.c,v 1.26 2004/03/19 23:27:08 mjn3 Exp $
    1615 *
    1716 * displayroute() code added by Vladimir N. Oleynik <dzo@simtreas.ru>
     
    2726 */
    2827
    29 #include <stdio.h>
    30 #include <stdlib.h>
    31 #include <string.h>
    32 #include <errno.h>
    33 #include <assert.h>
    34 #include <unistd.h>
    35 #include <fcntl.h>
    3628#include <getopt.h>
    37 #include <sys/types.h>
    38 #include <sys/ioctl.h>
    3929#include <net/route.h>
    4030#include <net/if.h>
    41 #include "busybox.h"
     31
     32#include "libbb.h"
    4233#include "inet_common.h"
     34
    4335
    4436#ifndef RTF_UP
     
    5951#endif
    6052
    61 #if defined (SIOCADDRTOLD) || defined (RTF_IRTT)    /* route */
     53#if defined(SIOCADDRTOLD) || defined(RTF_IRTT)  /* route */
    6254#define HAVE_NEW_ADDRT 1
    6355#endif
     
    7264
    7365/* The RTACTION entries must agree with tbl_verb[] below! */
    74 #define RTACTION_ADD        1
    75 #define RTACTION_DEL        2
     66#define RTACTION_ADD 1
     67#define RTACTION_DEL 2
    7668
    7769/* For the various tbl_*[] arrays, the 1st byte is the offset to
    7870 * the next entry and the 2nd byte is return value. */
    7971
    80 #define NET_FLAG            1
    81 #define HOST_FLAG           2
     72#define NET_FLAG  1
     73#define HOST_FLAG 2
    8274
    8375/* We remap '-' to '#' to avoid problems with getopt. */
    84 static const char tbl_hash_net_host[] =
     76static const char tbl_hash_net_host[] ALIGN1 =
    8577    "\007\001#net\0"
    8678/*  "\010\002#host\0" */
     
    8880;
    8981
    90 #define KW_TAKES_ARG        020
    91 #define KW_SETS_FLAG        040
    92 
    93 #define KW_IPVx_METRIC      020
    94 #define KW_IPVx_NETMASK     021
    95 #define KW_IPVx_GATEWAY     022
    96 #define KW_IPVx_MSS         023
    97 #define KW_IPVx_WINDOW      024
    98 #define KW_IPVx_IRTT        025
    99 #define KW_IPVx_DEVICE      026
    100 
    101 #define KW_IPVx_FLAG_ONLY   040
    102 #define KW_IPVx_REJECT      040
    103 #define KW_IPVx_MOD         041
    104 #define KW_IPVx_DYN         042
    105 #define KW_IPVx_REINSTATE   043
    106 
    107 static const char tbl_ipvx[] =
     82#define KW_TAKES_ARG            020
     83#define KW_SETS_FLAG            040
     84
     85#define KW_IPVx_METRIC          020
     86#define KW_IPVx_NETMASK         021
     87#define KW_IPVx_GATEWAY         022
     88#define KW_IPVx_MSS             023
     89#define KW_IPVx_WINDOW          024
     90#define KW_IPVx_IRTT            025
     91#define KW_IPVx_DEVICE          026
     92
     93#define KW_IPVx_FLAG_ONLY       040
     94#define KW_IPVx_REJECT          040
     95#define KW_IPVx_MOD             041
     96#define KW_IPVx_DYN             042
     97#define KW_IPVx_REINSTATE       043
     98
     99static const char tbl_ipvx[] ALIGN1 =
    108100    /* 020 is the "takes an arg" bit */
    109101#if HAVE_NEW_ADDRT
     
    167159    int skfd, isnet, xflag;
    168160
    169     assert((action == RTACTION_ADD) || (action == RTACTION_DEL));
    170 
    171161    /* Grab the -net or -host options.  Remember they were transformed. */
    172162    xflag = kw_lookup(tbl_hash_net_host, &args);
     
    178168
    179169    /* Clean out the RTREQ structure. */
    180     memset((char *) &rt, 0, sizeof(struct rtentry));
     170    memset(&rt, 0, sizeof(rt));
    181171
    182172    {
     
    186176        /* recognize x.x.x.x/mask format. */
    187177        prefix = strchr(target, '/');
    188         if(prefix) {
     178        if (prefix) {
    189179            int prefix_len;
    190180
    191             prefix_len = bb_xgetularg10_bnd(prefix+1, 0, 32);
     181            prefix_len = xatoul_range(prefix+1, 0, 32);
    192182            mask_in_addr(rt) = htonl( ~ (0xffffffffUL >> prefix_len));
    193183            *prefix = '\0';
     
    197187        } else {
    198188            /* Default netmask. */
    199             netmask = bb_INET_default;
     189            netmask = bb_str_default;
    200190        }
    201191        /* Prefer hostname lookup is -host flag (xflag==1) was given. */
     
    205195            bb_error_msg_and_die("resolving %s", target);
    206196        }
    207         if(prefix) {
     197        if (prefix) {
    208198            /* do not destroy prefix for process args */
    209199            *prefix = '/';
     
    229219#if HAVE_NEW_ADDRT
    230220        if (k == KW_IPVx_METRIC) {
    231             rt.rt_metric = bb_xgetularg10(args_m1) + 1;
     221            rt.rt_metric = xatoul(args_m1) + 1;
    232222            continue;
    233223        }
     
    270260        if (k == KW_IPVx_MSS) { /* Check valid MSS bounds. */
    271261            rt.rt_flags |= RTF_MSS;
    272             rt.rt_mss = bb_xgetularg10_bnd(args_m1, 64, 32768);
     262            rt.rt_mss = xatoul_range(args_m1, 64, 32768);
    273263            continue;
    274264        }
     
    276266        if (k == KW_IPVx_WINDOW) {  /* Check valid window bounds. */
    277267            rt.rt_flags |= RTF_WINDOW;
    278             rt.rt_window = bb_xgetularg10_bnd(args_m1, 128, INT_MAX);
     268            rt.rt_window = xatoul_range(args_m1, 128, INT_MAX);
    279269            continue;
    280270        }
     
    283273        if (k == KW_IPVx_IRTT) {
    284274            rt.rt_flags |= RTF_IRTT;
    285             rt.rt_irtt = bb_xgetularg10(args_m1);
     275            rt.rt_irtt = xatoul(args_m1);
    286276            rt.rt_irtt *= (sysconf(_SC_CLK_TCK) / 100); /* FIXME */
    287277#if 0                   /* FIXME: do we need to check anything of this? */
     
    308298#ifdef RTF_REJECT
    309299    if ((rt.rt_flags & RTF_REJECT) && !rt.rt_dev) {
    310         rt.rt_dev = "lo";
     300        rt.rt_dev = (char*)"lo";
    311301    }
    312302#endif
     
    336326
    337327    /* Create a socket to the INET kernel. */
    338     skfd = bb_xsocket(AF_INET, SOCK_DGRAM, 0);
    339 
    340     if (ioctl(skfd, ((action==RTACTION_ADD) ? SIOCADDRT : SIOCDELRT), &rt)<0) {
    341         bb_perror_msg_and_die("SIOC[ADD|DEL]RT");
    342     }
     328    skfd = xsocket(AF_INET, SOCK_DGRAM, 0);
     329
     330    if (action == RTACTION_ADD)
     331        xioctl(skfd, SIOCADDRT, &rt);
     332    else
     333        xioctl(skfd, SIOCDELRT, &rt);
    343334
    344335    if (ENABLE_FEATURE_CLEAN_UP) close(skfd);
    345336}
    346337
    347 #ifdef CONFIG_FEATURE_IPV6
     338#if ENABLE_FEATURE_IPV6
    348339
    349340static void INET6_setroute(int action, char **args)
     
    354345    const char *devname;
    355346
    356     assert((action == RTACTION_ADD) || (action == RTACTION_DEL));
    357 
    358     {
    359347        /* We know args isn't NULL from the check in route_main. */
    360348        const char *target = *args++;
    361349
    362         if (strcmp(target, bb_INET_default) == 0) {
     350        if (strcmp(target, bb_str_default) == 0) {
    363351            prefix_len = 0;
    364352            memset(&sa6, 0, sizeof(sa6));
     
    367355            if ((cp = strchr(target, '/'))) { /* Yes... const to non is ok. */
    368356                *cp = 0;
    369                 prefix_len = bb_xgetularg10_bnd(cp+1, 0, 128);
     357                prefix_len = xatoul_range(cp+1, 0, 128);
    370358            } else {
    371359                prefix_len = 128;
     
    375363            }
    376364        }
    377     }
    378365
    379366    /* Clean out the RTREQ structure. */
    380     memset((char *) &rt, 0, sizeof(struct in6_rtmsg));
     367    memset(&rt, 0, sizeof(rt));
    381368
    382369    memcpy(&rt.rtmsg_dst, sa6.sin6_addr.s6_addr, sizeof(struct in6_addr));
     
    399386
    400387        if (k == KW_IPVx_METRIC) {
    401             rt.rtmsg_metric = bb_xgetularg10(args_m1);
     388            rt.rtmsg_metric = xatoul(args_m1);
    402389            continue;
    403390        }
     
    430417
    431418    /* Create a socket to the INET6 kernel. */
    432     skfd = bb_xsocket(AF_INET6, SOCK_DGRAM, 0);
     419    skfd = xsocket(AF_INET6, SOCK_DGRAM, 0);
    433420
    434421    rt.rtmsg_ifindex = 0;
     
    437424        struct ifreq ifr;
    438425        memset(&ifr, 0, sizeof(ifr));
    439         strcpy(ifr.ifr_name, devname);
    440 
    441         if (ioctl(skfd, SIOGIFINDEX, &ifr) < 0) {
    442             bb_perror_msg_and_die("SIOGIFINDEX");
    443         }
     426        strncpy(ifr.ifr_name, devname, sizeof(ifr.ifr_name));
     427        xioctl(skfd, SIOGIFINDEX, &ifr);
    444428        rt.rtmsg_ifindex = ifr.ifr_ifindex;
    445429    }
    446430
    447431    /* Tell the kernel to accept this route. */
    448     if (ioctl(skfd, ((action==RTACTION_ADD) ? SIOCADDRT : SIOCDELRT), &rt)<0) {
    449         bb_perror_msg_and_die("SIOC[ADD|DEL]RT");
    450     }
     432    if (action == RTACTION_ADD)
     433        xioctl(skfd, SIOCADDRT, &rt);
     434    else
     435        xioctl(skfd, SIOCDELRT, &rt);
    451436
    452437    if (ENABLE_FEATURE_CLEAN_UP) close(skfd);
     
    454439#endif
    455440
    456 static const unsigned int flagvals[] = { /* Must agree with flagchars[]. */
     441static const unsigned flagvals[] = { /* Must agree with flagchars[]. */
    457442    RTF_GATEWAY,
    458443    RTF_HOST,
     
    460445    RTF_DYNAMIC,
    461446    RTF_MODIFIED,
    462 #ifdef CONFIG_FEATURE_IPV6
     447#if ENABLE_FEATURE_IPV6
    463448    RTF_DEFAULT,
    464449    RTF_ADDRCONF,
     
    470455#define IPV6_MASK (RTF_GATEWAY|RTF_HOST|RTF_DEFAULT|RTF_ADDRCONF|RTF_CACHE)
    471456
    472 static const char flagchars[] =     /* Must agree with flagvals[]. */
     457/* Must agree with flagvals[]. */
     458static const char flagchars[] ALIGN1 =
    473459    "GHRDM"
    474 #ifdef CONFIG_FEATURE_IPV6
     460#if ENABLE_FEATURE_IPV6
    475461    "DAC"
    476462#endif
    477463;
    478464
    479 static
    480 #ifndef CONFIG_FEATURE_IPV6
    481 __inline
    482 #endif
    483 void set_flags(char *flagstr, int flags)
     465static void set_flags(char *flagstr, int flags)
    484466{
    485467    int i;
     
    487469    *flagstr++ = 'U';
    488470
    489     for (i=0 ; (*flagstr = flagchars[i]) != 0 ; i++) {
     471    for (i = 0; (*flagstr = flagchars[i]) != 0; i++) {
    490472        if (flags & flagvals[i]) {
    491473            ++flagstr;
     
    495477
    496478/* also used in netstat */
    497 void displayroutes(int noresolve, int netstatfmt);
    498 void displayroutes(int noresolve, int netstatfmt)
     479void bb_displayroutes(int noresolve, int netstatfmt)
    499480{
    500     char devname[64], flags[16], sdest[16], sgw[16];
    501     unsigned long int d, g, m;
     481    char devname[64], flags[16], *sdest, *sgw;
     482    unsigned long d, g, m;
    502483    int flgs, ref, use, metric, mtu, win, ir;
    503484    struct sockaddr_in s_addr;
    504485    struct in_addr mask;
    505486
    506     FILE *fp = bb_xfopen("/proc/net/route", "r");
    507 
    508     bb_printf("Kernel IP routing table\n"
    509               "Destination     Gateway         Genmask"
    510               "         Flags %s Iface\n",
    511               netstatfmt ? "  MSS Window  irtt" : "Metric Ref    Use");
     487    FILE *fp = xfopen("/proc/net/route", "r");
     488
     489    printf("Kernel IP routing table\n"
     490           "Destination     Gateway         Genmask         Flags %s Iface\n",
     491            netstatfmt ? "  MSS Window  irtt" : "Metric Ref    Use");
    512492
    513493    if (fscanf(fp, "%*[^\n]\n") < 0) { /* Skip the first line. */
     
    523503                break;
    524504            }
    525         ERROR:
     505 ERROR:
    526506            bb_error_msg_and_die("fscanf");
    527507        }
     
    541521        s_addr.sin_family = AF_INET;
    542522        s_addr.sin_addr.s_addr = d;
    543         INET_rresolve(sdest, sizeof(sdest), &s_addr,
    544                       (noresolve | 0x8000), m); /* Default instead of *. */
    545 
     523        sdest = INET_rresolve(&s_addr, (noresolve | 0x8000), m); /* 'default' instead of '*' */
    546524        s_addr.sin_addr.s_addr = g;
    547         INET_rresolve(sgw, sizeof(sgw), &s_addr,
    548                       (noresolve | 0x4000), m); /* Host instead of net. */
    549 
     525        sgw = INET_rresolve(&s_addr, (noresolve | 0x4000), m); /* Host instead of net */
    550526        mask.s_addr = m;
    551         bb_printf("%-16s%-16s%-16s%-6s", sdest, sgw, inet_ntoa(mask), flags);
     527        /* "%15.15s" truncates hostnames, do we really want that? */
     528        printf("%-15.15s %-15.15s %-16s%-6s", sdest, sgw, inet_ntoa(mask), flags);
     529        free(sdest);
     530        free(sgw);
    552531        if (netstatfmt) {
    553             bb_printf("%5d %-5d %6d %s\n", mtu, win, ir, devname);
     532            printf("%5d %-5d %6d %s\n", mtu, win, ir, devname);
    554533        } else {
    555             bb_printf("%-6d %-2d %7d %s\n", metric, ref, use, devname);
     534            printf("%-6d %-2d %7d %s\n", metric, ref, use, devname);
    556535        }
    557536    }
    558537}
    559538
    560 #ifdef CONFIG_FEATURE_IPV6
     539#if ENABLE_FEATURE_IPV6
    561540
    562541static void INET6_displayroutes(int noresolve)
    563542{
    564     char addr6[128], naddr6[128];
     543    char addr6[128], *naddr6;
    565544    /* In addr6x, we store both 40-byte ':'-delimited ipv6 addresses.
    566545     * We read the non-delimited strings into the tail of the buffer
     
    574553    struct sockaddr_in6 snaddr6;
    575554
    576     FILE *fp = bb_xfopen("/proc/net/ipv6_route", "r");
    577 
    578     bb_printf("Kernel IPv6 routing table\n%-44s%-40s"
     555    FILE *fp = xfopen("/proc/net/ipv6_route", "r");
     556
     557    printf("Kernel IPv6 routing table\n%-44s%-40s"
    579558              "Flags Metric Ref    Use Iface\n",
    580559              "Destination", "Next Hop");
     
    589568                break;
    590569            }
    591         ERROR:
     570 ERROR:
    592571            bb_error_msg_and_die("fscanf");
    593572        }
     
    602581            do {
    603582                if (!*p) {
    604                     if (i==40) { /* nul terminator for 1st address? */
     583                    if (i == 40) { /* nul terminator for 1st address? */
    605584                        addr6x[39] = 0; /* Fixup... need 0 instead of ':'. */
    606585                        ++p;    /* Skip and continue. */
     
    610589                }
    611590                addr6x[i++] = *p++;
    612                 if (!((i+1)%5)) {
     591                if (!((i+1) % 5)) {
    613592                    addr6x[i++] = ':';
    614593                }
     
    627606                      (struct sockaddr *) &snaddr6.sin6_addr);
    628607            snaddr6.sin6_family = AF_INET6;
    629             INET6_rresolve(naddr6, sizeof(naddr6),
    630                            (struct sockaddr_in6 *) &snaddr6,
    631 #if 0
    632                            (noresolve | 0x8000) /* Default instead of *. */
    633 #else
     608            naddr6 = INET6_rresolve((struct sockaddr_in6 *) &snaddr6,
    634609                           0x0fff /* Apparently, upstream never resolves. */
    635 #endif
    636610                           );
    637611
     
    639613                snprintf(addr6, sizeof(addr6), "%s/%d", naddr6, prefix_len);
    640614                r += 40;
     615                free(naddr6);
    641616            } else {            /* 2nd pass */
    642617                /* Print the info. */
    643                 bb_printf("%-43s %-39s %-5s %-6d %-2d %7d %-8s\n",
    644                           addr6, naddr6, flags, metric, refcnt, use, iface);
     618                printf("%-43s %-39s %-5s %-6d %-2d %7d %-8s\n",
     619                        addr6, naddr6, flags, metric, refcnt, use, iface);
     620                free(naddr6);
    645621                break;
    646622            }
     
    651627#endif
    652628
    653 #define ROUTE_OPT_A         0x01
    654 #define ROUTE_OPT_n         0x02
    655 #define ROUTE_OPT_e         0x04
    656 #define ROUTE_OPT_INET6     0x08 /* Not an actual option. See below. */
     629#define ROUTE_OPT_A     0x01
     630#define ROUTE_OPT_n     0x02
     631#define ROUTE_OPT_e     0x04
     632#define ROUTE_OPT_INET6 0x08 /* Not an actual option. See below. */
    657633
    658634/* 1st byte is offset to next entry offset.  2nd byte is return value. */
    659 static const char tbl_verb[] =  /* 2nd byte matches RTACTION_* code */
     635/* 2nd byte matches RTACTION_* code */
     636static const char tbl_verb[] ALIGN1 =
    660637    "\006\001add\0"
    661638    "\006\002del\0"
    662639/*  "\011\002delete\0" */
    663     "\010\002delete"            /* Since last, we can save a byte. */
     640    "\010\002delete"  /* Since it's last, we can save a byte. */
    664641;
    665642
     643int route_main(int argc, char **argv);
    666644int route_main(int argc, char **argv)
    667645{
    668     unsigned long opt;
     646    unsigned opt;
    669647    int what;
    670648    char *family;
     649    char **p;
    671650
    672651    /* First, remap '-net' and '-host' to avoid getopt problems. */
    673     {
    674         char **p = argv;
    675 
    676         while (*++p) {
    677             if ((strcmp(*p, "-net") == 0) || (strcmp(*p, "-host") == 0)) {
    678                 p[0][0] = '#';
    679             }
    680         }
    681     }
    682 
    683     opt = bb_getopt_ulflags(argc, argv, "A:ne", &family);
    684 
    685     if ((opt & ROUTE_OPT_A) && strcmp(family, "inet")) {
    686 #ifdef CONFIG_FEATURE_IPV6
     652    p = argv;
     653    while (*++p) {
     654        if (strcmp(*p, "-net") == 0 || strcmp(*p, "-host") == 0) {
     655            p[0][0] = '#';
     656        }
     657    }
     658
     659    opt = getopt32(argv, "A:ne", &family);
     660
     661    if ((opt & ROUTE_OPT_A) && strcmp(family, "inet") != 0) {
     662#if ENABLE_FEATURE_IPV6
    687663        if (strcmp(family, "inet6") == 0) {
    688664            opt |= ROUTE_OPT_INET6; /* Set flag for ipv6. */
     
    697673    if (!*argv) {
    698674        int noresolve = (opt & ROUTE_OPT_n) ? 0x0fff : 0;
    699 #ifdef CONFIG_FEATURE_IPV6
     675#if ENABLE_FEATURE_IPV6
    700676        if (opt & ROUTE_OPT_INET6)
    701677            INET6_displayroutes(noresolve);
    702678        else
    703679#endif
    704             displayroutes(noresolve, opt & ROUTE_OPT_e);
    705 
    706         bb_xferror_stdout();
    707         bb_fflush_stdout_and_exit(EXIT_SUCCESS);
     680            bb_displayroutes(noresolve, opt & ROUTE_OPT_e);
     681
     682        fflush_stdout_and_exit(EXIT_SUCCESS);
    708683    }
    709684
     
    714689    }
    715690
    716 #ifdef CONFIG_FEATURE_IPV6
     691#if ENABLE_FEATURE_IPV6
    717692    if (opt & ROUTE_OPT_INET6)
    718693        INET6_setroute(what, argv);
Note: See TracChangeset for help on using the changeset viewer.