diff options
-rw-r--r-- | networking/ifplugd.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/networking/ifplugd.c b/networking/ifplugd.c index c9f603f2c..62bc9d6d5 100644 --- a/networking/ifplugd.c +++ b/networking/ifplugd.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include "libbb.h" | 9 | #include "libbb.h" |
10 | 10 | ||
11 | #include <linux/if.h> | 11 | #include <linux/if.h> |
12 | #include <linux/mii.h> | ||
12 | #include <linux/ethtool.h> | 13 | #include <linux/ethtool.h> |
13 | #include <net/ethernet.h> | 14 | #include <net/ethernet.h> |
14 | #include <linux/netlink.h> | 15 | #include <linux/netlink.h> |
@@ -310,6 +311,7 @@ static void maybe_up_new_iface(void) | |||
310 | static smallint detect_link_mii(void) | 311 | static smallint detect_link_mii(void) |
311 | { | 312 | { |
312 | struct ifreq ifreq; | 313 | struct ifreq ifreq; |
314 | struct mii_ioctl_data *mii = (void *)&ifreq.ifr_data; | ||
313 | 315 | ||
314 | set_ifreq_to_ifname(&ifreq); | 316 | set_ifreq_to_ifname(&ifreq); |
315 | 317 | ||
@@ -318,20 +320,20 @@ static smallint detect_link_mii(void) | |||
318 | return IFSTATUS_ERR; | 320 | return IFSTATUS_ERR; |
319 | } | 321 | } |
320 | 322 | ||
321 | ((unsigned short*)&ifreq.ifr_data)[1] = 1; | 323 | mii->reg_num = 1; |
322 | 324 | ||
323 | if (network_ioctl(SIOCGMIIREG, &ifreq) < 0) { | 325 | if (network_ioctl(SIOCGMIIREG, &ifreq) < 0) { |
324 | bb_perror_msg("SIOCGMIIREG failed"); | 326 | bb_perror_msg("SIOCGMIIREG failed"); |
325 | return IFSTATUS_ERR; | 327 | return IFSTATUS_ERR; |
326 | } | 328 | } |
327 | 329 | ||
328 | return (((unsigned short*)&ifreq.ifr_data)[3] & 0x0004) ? | 330 | return (mii->val_out & 0x0004) ? IFSTATUS_UP : IFSTATUS_DOWN; |
329 | IFSTATUS_UP : IFSTATUS_DOWN; | ||
330 | } | 331 | } |
331 | 332 | ||
332 | static smallint detect_link_priv(void) | 333 | static smallint detect_link_priv(void) |
333 | { | 334 | { |
334 | struct ifreq ifreq; | 335 | struct ifreq ifreq; |
336 | struct mii_ioctl_data *mii = (void *)&ifreq.ifr_data; | ||
335 | 337 | ||
336 | set_ifreq_to_ifname(&ifreq); | 338 | set_ifreq_to_ifname(&ifreq); |
337 | 339 | ||
@@ -340,15 +342,14 @@ static smallint detect_link_priv(void) | |||
340 | return IFSTATUS_ERR; | 342 | return IFSTATUS_ERR; |
341 | } | 343 | } |
342 | 344 | ||
343 | ((unsigned short*) &ifreq.ifr_data)[1] = 1; | 345 | mii->reg_num = 1; |
344 | 346 | ||
345 | if (network_ioctl(SIOCDEVPRIVATE+1, &ifreq) < 0) { | 347 | if (network_ioctl(SIOCDEVPRIVATE+1, &ifreq) < 0) { |
346 | bb_perror_msg("SIOCDEVPRIVATE+1 failed"); | 348 | bb_perror_msg("SIOCDEVPRIVATE+1 failed"); |
347 | return IFSTATUS_ERR; | 349 | return IFSTATUS_ERR; |
348 | } | 350 | } |
349 | 351 | ||
350 | return (((unsigned short*)&ifreq.ifr_data)[3] & 0x0004) ? | 352 | return (mii->val_out & 0x0004) ? IFSTATUS_UP : IFSTATUS_DOWN; |
351 | IFSTATUS_UP : IFSTATUS_DOWN; | ||
352 | } | 353 | } |
353 | 354 | ||
354 | static smallint detect_link_ethtool(void) | 355 | static smallint detect_link_ethtool(void) |
@@ -591,6 +592,7 @@ static NOINLINE int netlink_open(void) | |||
591 | return fd; | 592 | return fd; |
592 | } | 593 | } |
593 | 594 | ||
595 | #if ENABLE_FEATURE_PIDFILE | ||
594 | static NOINLINE pid_t read_pid(const char *filename) | 596 | static NOINLINE pid_t read_pid(const char *filename) |
595 | { | 597 | { |
596 | int len; | 598 | int len; |
@@ -604,6 +606,7 @@ static NOINLINE pid_t read_pid(const char *filename) | |||
604 | } | 606 | } |
605 | return 0; | 607 | return 0; |
606 | } | 608 | } |
609 | #endif | ||
607 | 610 | ||
608 | int ifplugd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 611 | int ifplugd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
609 | int ifplugd_main(int argc UNUSED_PARAM, char **argv) | 612 | int ifplugd_main(int argc UNUSED_PARAM, char **argv) |