#include "libbb.h"
#include <linux/if.h>
+#include <linux/mii.h>
#include <linux/ethtool.h>
#include <net/ethernet.h>
#include <linux/netlink.h>
static smallint detect_link_mii(void)
{
struct ifreq ifreq;
+ struct mii_ioctl_data *mii = (void *)&ifreq.ifr_data;
set_ifreq_to_ifname(&ifreq);
return IFSTATUS_ERR;
}
- ((unsigned short*)&ifreq.ifr_data)[1] = 1;
+ mii->reg_num = 1;
if (network_ioctl(SIOCGMIIREG, &ifreq) < 0) {
bb_perror_msg("SIOCGMIIREG failed");
return IFSTATUS_ERR;
}
- return (((unsigned short*)&ifreq.ifr_data)[3] & 0x0004) ?
- IFSTATUS_UP : IFSTATUS_DOWN;
+ return (mii->val_out & 0x0004) ? IFSTATUS_UP : IFSTATUS_DOWN;
}
static smallint detect_link_priv(void)
{
struct ifreq ifreq;
+ struct mii_ioctl_data *mii = (void *)&ifreq.ifr_data;
set_ifreq_to_ifname(&ifreq);
return IFSTATUS_ERR;
}
- ((unsigned short*) &ifreq.ifr_data)[1] = 1;
+ mii->reg_num = 1;
if (network_ioctl(SIOCDEVPRIVATE+1, &ifreq) < 0) {
bb_perror_msg("SIOCDEVPRIVATE+1 failed");
return IFSTATUS_ERR;
}
- return (((unsigned short*)&ifreq.ifr_data)[3] & 0x0004) ?
- IFSTATUS_UP : IFSTATUS_DOWN;
+ return (mii->val_out & 0x0004) ? IFSTATUS_UP : IFSTATUS_DOWN;
}
static smallint detect_link_ethtool(void)
return fd;
}
+#if ENABLE_FEATURE_PIDFILE
static NOINLINE pid_t read_pid(const char *filename)
{
int len;
}
return 0;
}
+#endif
int ifplugd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int ifplugd_main(int argc UNUSED_PARAM, char **argv)