Ignore:
Timestamp:
Jan 1, 2014, 12:47:38 AM (5 years ago)
Author:
bruno
Message:
  • Update mindi-busybox to 1.21.1
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mindi-busybox/networking/ifplugd.c

    r2725 r3232  
    77 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    88 */
     9
     10//usage:#define ifplugd_trivial_usage
     11//usage:       "[OPTIONS]"
     12//usage:#define ifplugd_full_usage "\n\n"
     13//usage:       "Network interface plug detection daemon\n"
     14//usage:     "\n    -n      Don't daemonize"
     15//usage:     "\n    -s      Don't log to syslog"
     16//usage:     "\n    -i IFACE    Interface"
     17//usage:     "\n    -f/-F       Treat link detection error as link down/link up"
     18//usage:     "\n            (otherwise exit on error)"
     19//usage:     "\n    -a      Don't up interface at each link probe"
     20//usage:     "\n    -M      Monitor creation/destruction of interface"
     21//usage:     "\n            (otherwise it must exist)"
     22//usage:     "\n    -r PROG     Script to run"
     23//usage:     "\n    -x ARG      Extra argument for script"
     24//usage:     "\n    -I      Don't exit on nonzero exit code from script"
     25//usage:     "\n    -p      Don't run \"up\" script on startup"
     26//usage:     "\n    -q      Don't run \"down\" script on exit"
     27//usage:     "\n    -l      Always run script on startup"
     28//usage:     "\n    -t SECS     Poll time in seconds"
     29//usage:     "\n    -u SECS     Delay before running script after link up"
     30//usage:     "\n    -d SECS     Delay after link down"
     31//usage:     "\n    -m MODE     API mode (mii, priv, ethtool, wlan, iff, auto)"
     32//usage:     "\n    -k      Kill running daemon"
     33
    934#include "libbb.h"
    1035
     
    1338#include <linux/mii.h>
    1439#include <linux/ethtool.h>
    15 #include <net/ethernet.h>
     40#ifdef HAVE_NET_ETHERNET_H
     41# include <net/ethernet.h>
     42#endif
    1643#include <linux/netlink.h>
    1744#include <linux/rtnetlink.h>
     
    132159static smallint detect_link_mii(void)
    133160{
    134     struct ifreq ifreq;
    135     struct mii_ioctl_data *mii = (void *)&ifreq.ifr_data;
    136 
    137     set_ifreq_to_ifname(&ifreq);
    138 
    139     if (network_ioctl(SIOCGMIIPHY, &ifreq, "SIOCGMIIPHY") < 0) {
     161    /* char buffer instead of bona-fide struct avoids aliasing warning */
     162    char buf[sizeof(struct ifreq)];
     163    struct ifreq *const ifreq = (void *)buf;
     164
     165    struct mii_ioctl_data *mii = (void *)&ifreq->ifr_data;
     166
     167    set_ifreq_to_ifname(ifreq);
     168
     169    if (network_ioctl(SIOCGMIIPHY, ifreq, "SIOCGMIIPHY") < 0) {
    140170        return IFSTATUS_ERR;
    141171    }
     
    143173    mii->reg_num = 1;
    144174
    145     if (network_ioctl(SIOCGMIIREG, &ifreq, "SIOCGMIIREG") < 0) {
     175    if (network_ioctl(SIOCGMIIREG, ifreq, "SIOCGMIIREG") < 0) {
    146176        return IFSTATUS_ERR;
    147177    }
     
    152182static smallint detect_link_priv(void)
    153183{
    154     struct ifreq ifreq;
    155     struct mii_ioctl_data *mii = (void *)&ifreq.ifr_data;
    156 
    157     set_ifreq_to_ifname(&ifreq);
    158 
    159     if (network_ioctl(SIOCDEVPRIVATE, &ifreq, "SIOCDEVPRIVATE") < 0) {
     184    /* char buffer instead of bona-fide struct avoids aliasing warning */
     185    char buf[sizeof(struct ifreq)];
     186    struct ifreq *const ifreq = (void *)buf;
     187
     188    struct mii_ioctl_data *mii = (void *)&ifreq->ifr_data;
     189
     190    set_ifreq_to_ifname(ifreq);
     191
     192    if (network_ioctl(SIOCDEVPRIVATE, ifreq, "SIOCDEVPRIVATE") < 0) {
    160193        return IFSTATUS_ERR;
    161194    }
     
    163196    mii->reg_num = 1;
    164197
    165     if (network_ioctl(SIOCDEVPRIVATE+1, &ifreq, "SIOCDEVPRIVATE+1") < 0) {
     198    if (network_ioctl(SIOCDEVPRIVATE+1, ifreq, "SIOCDEVPRIVATE+1") < 0) {
    166199        return IFSTATUS_ERR;
    167200    }
     
    519552
    520553#if ENABLE_FEATURE_PIDFILE
    521     pidfile_name = xasprintf(_PATH_VARRUN"ifplugd.%s.pid", G.iface);
     554    pidfile_name = xasprintf(CONFIG_PID_FILE_PATH "/ifplugd.%s.pid", G.iface);
    522555    pid_from_pidfile = read_pid(pidfile_name);
    523556
Note: See TracChangeset for help on using the changeset viewer.