Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/networking/arp.c


Ignore:
Timestamp:
Dec 20, 2016, 4:07:32 PM (7 years ago)
Author:
Bruno Cornec
Message:

New 3?3 banch for incorporation of latest busybox 1.25. Changing minor version to handle potential incompatibilities.

Location:
branches/3.3
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi-busybox/networking/arp.c

    r3232 r3621  
    2323//usage:       "Manipulate ARP cache\n"
    2424//usage:       "\n  -a      Display (all) hosts"
    25 //usage:       "\n  -s      Set new ARP entry"
    26 //usage:       "\n  -d      Delete a specified entry"
     25//usage:       "\n  -d      Delete ARP entry"
     26//usage:       "\n  -s      Set new entry"
    2727//usage:       "\n  -v      Verbose"
    2828//usage:       "\n  -n      Don't resolve names"
    2929//usage:       "\n  -i IF       Network interface"
    30 //usage:       "\n  -D      Read <hwaddr> from given device"
     30//usage:       "\n  -D      Read HWADDR from IFACE"
    3131//usage:       "\n  -A,-p AF    Protocol family"
    3232//usage:       "\n  -H HWTYPE   Hardware address type"
    3333
    3434#include "libbb.h"
     35#include "common_bufsiz.h"
    3536#include "inet_common.h"
    3637
     
    6970    const char *device;      /* current device */
    7071    smallint hw_set;         /* flag if hw-type was set (-H) */
    71 
    7272} FIX_ALIASING;
    73 #define G (*(struct globals*)&bb_common_bufsiz1)
     73#define G (*(struct globals*)bb_common_bufsiz1)
    7474#define ap         (G.ap        )
    7575#define hw         (G.hw        )
     
    7777#define hw_set     (G.hw_set    )
    7878#define INIT_G() do { \
     79    setup_common_bufsiz(); \
    7980    device = ""; \
    8081} while (0)
     
    214215
    215216/* Get the hardware address to a specified interface name */
    216 static void arp_getdevhw(char *ifname, struct sockaddr *sa,
    217                         const struct hwtype *hwt)
     217static void arp_getdevhw(char *ifname, struct sockaddr *sa)
    218218{
    219219    struct ifreq ifr;
     
    222222    strcpy(ifr.ifr_name, ifname);
    223223    ioctl_or_perror_and_die(sockfd, SIOCGIFHWADDR, &ifr,
    224                     "cant get HW-Address for '%s'", ifname);
    225     if (hwt && (ifr.ifr_hwaddr.sa_family != hw->type)) {
     224                    "can't get HW-Address for '%s'", ifname);
     225    if (hw_set && (ifr.ifr_hwaddr.sa_family != hw->type)) {
    226226        bb_error_msg_and_die("protocol type mismatch");
    227227    }
     
    234234        }
    235235        bb_error_msg("device '%s' has HW address %s '%s'",
    236                     ifname, xhw->name,
    237                     xhw->print((unsigned char *) &ifr.ifr_hwaddr.sa_data));
     236                ifname, xhw->name,
     237                xhw->print((unsigned char *) &ifr.ifr_hwaddr.sa_data));
    238238    }
    239239}
     
    262262    }
    263263    if (option_mask32 & ARP_OPT_D) {
    264         arp_getdevhw(*args++, &req.arp_ha, hw_set ? hw : NULL);
     264        arp_getdevhw(*args++, &req.arp_ha);
    265265    } else {
    266266        if (hw->input(*args++, &req.arp_ha) < 0) {
     
    461461    }
    462462    if (option_mask32 & ARP_OPT_v)
    463         printf("Entries: %d\tSkipped: %d\tFound: %d\n",
     463        printf("Entries: %u\tSkipped: %u\tFound: %u\n",
    464464                entries, entries - shown, shown);
    465465
    466466    if (!shown) {
    467467        if (hw_set || host || device[0])
    468             printf("No match found in %d entries\n", entries);
     468            printf("No match found in %u entries\n", entries);
    469469    }
    470470    if (ENABLE_FEATURE_CLEAN_UP) {
     
    478478int arp_main(int argc UNUSED_PARAM, char **argv)
    479479{
    480     const char *hw_type = "ether";
     480    const char *hw_type;
    481481    const char *protocol;
    482482    unsigned opts;
     
    485485
    486486    xmove_fd(xsocket(AF_INET, SOCK_DGRAM, 0), sockfd);
     487
    487488    ap = get_aftype(DFLT_AF);
    488     if (!ap)
    489         bb_error_msg_and_die("%s: %s not supported", DFLT_AF, "address family");
     489    /* Defaults are always supported */
     490    //if (!ap)
     491    //  bb_error_msg_and_die("%s: %s not supported", DFLT_AF, "address family");
     492    hw = get_hwtype(DFLT_HW);
     493    //if (!hw)
     494    //  bb_error_msg_and_die("%s: %s not supported", DFLT_HW, "hardware type");
    490495
    491496    opts = getopt32(argv, "A:p:H:t:i:adnDsv", &protocol, &protocol,
     
    494499    if (opts & (ARP_OPT_A | ARP_OPT_p)) {
    495500        ap = get_aftype(protocol);
    496         if (ap == NULL)
     501        if (!ap)
    497502            bb_error_msg_and_die("%s: unknown %s", protocol, "address family");
    498503    }
    499     if (opts & (ARP_OPT_A | ARP_OPT_p)) {
     504    if (opts & (ARP_OPT_H | ARP_OPT_t)) {
    500505        hw = get_hwtype(hw_type);
    501         if (hw == NULL)
     506        if (!hw)
    502507            bb_error_msg_and_die("%s: unknown %s", hw_type, "hardware type");
    503508        hw_set = 1;
     
    508513        bb_error_msg_and_die("%s: kernel only supports 'inet'", ap->name);
    509514    }
    510 
    511     /* If no hw type specified get default */
    512     if (!hw) {
    513         hw = get_hwtype(DFLT_HW);
    514         if (!hw)
    515             bb_error_msg_and_die("%s: %s not supported", DFLT_HW, "hardware type");
    516     }
    517 
    518515    if (hw->alen <= 0) {
    519516        bb_error_msg_and_die("%s: %s without ARP support",
     
    529526        return arp_del(argv);
    530527    }
     528
    531529    //if (opts & ARP_OPT_a) - default
    532530    return arp_show(argv[0]);
Note: See TracChangeset for help on using the changeset viewer.