summaryrefslogtreecommitdiff
blob: ae8292dc17ace4e2a508f46556b8eb559db42136 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
--- a/src/interface.c
+++ b/src/interface.c
@@ -89,6 +89,10 @@
 
 interface_status_t interface_detect_beat_mii(int fd, char *iface) {
     struct ifreq ifr;
+    union {
+      caddr_t *data;
+      unsigned short *usz;
+    } ifd;
     
     if (interface_auto_up)
         interface_up(fd, iface);
@@ -103,7 +107,8 @@
         return IFSTATUS_ERR;
     }
 
-    ((unsigned short*) &ifr.ifr_data)[1] = 1;
+    ifd.data = &ifr.ifr_data;
+    *++ifd.usz = 1;
 
     if (ioctl(fd, SIOCGMIIREG, &ifr) == -1) {
         if (interface_do_message)
@@ -112,12 +117,17 @@
         return IFSTATUS_ERR;
     }
 
-    return (((unsigned short*) &ifr.ifr_data)[3] & 0x0004) ? IFSTATUS_UP : IFSTATUS_DOWN;
+    ifd.usz += 2;
+    return (*ifd.usz & 0x0004) ? IFSTATUS_UP : IFSTATUS_DOWN;
 }
 
 interface_status_t interface_detect_beat_priv(int fd, char *iface) {
     struct ifreq ifr;
-    
+    union {
+      caddr_t *data;
+      unsigned short *usz;
+    } ifd;
+   
     if (interface_auto_up)
         interface_up(fd, iface);
     
@@ -131,7 +141,8 @@
         return IFSTATUS_ERR;
     }
 
-    ((unsigned short*) &ifr.ifr_data)[1] = 1;
+    ifd.data = &ifr.ifr_data;
+    *++ifd.usz = 1;
 
     if (ioctl(fd, SIOCDEVPRIVATE+1, &ifr) == -1) {
         if (interface_do_message)
@@ -140,7 +151,8 @@
         return IFSTATUS_ERR;
     }
 
-    return (((unsigned short*) &ifr.ifr_data)[3] & 0x0004) ? IFSTATUS_UP : IFSTATUS_DOWN;
+    ifd.usz += 2;
+    return (*ifd.usz & 0x0004) ? IFSTATUS_UP : IFSTATUS_DOWN;
 }
 
 interface_status_t interface_detect_beat_ethtool(int fd, char *iface) {