3 #include <linux/sockios.h>
11 u32
wireless_bitrate(const char *ifname
)
13 int sock
, ret
, rate_in_mbit
;
16 sock
= af_socket(AF_INET
);
18 memset(&iwr
, 0, sizeof(iwr
));
19 strlcpy(iwr
.ifr_name
, ifname
, IFNAMSIZ
);
21 ret
= ioctl(sock
, SIOCGIWRATE
, &iwr
);
23 rate_in_mbit
= iwr
.u
.bitrate
.value
/ 1000000;
32 int wireless_sigqual(const char *ifname
, struct iw_statistics
*stats
)
37 sock
= af_socket(AF_INET
);
39 memset(&iwr
, 0, sizeof(iwr
));
40 strlcpy(iwr
.ifr_name
, ifname
, IFNAMSIZ
);
42 iwr
.u
.data
.pointer
= (caddr_t
) stats
;
43 iwr
.u
.data
.length
= sizeof(*stats
);
46 ret
= ioctl(sock
, SIOCGIWSTATS
, &iwr
);
53 int wireless_rangemax_sigqual(const char *ifname
)
55 int ret
, sock
, sigqual
;
57 struct iw_range iwrange
;
59 sock
= af_socket(AF_INET
);
61 memset(&iwrange
, 0, sizeof(iwrange
));
63 memset(&iwr
, 0, sizeof(iwr
));
64 strlcpy(iwr
.ifr_name
, ifname
, IFNAMSIZ
);
66 iwr
.u
.data
.pointer
= (caddr_t
) &iwrange
;
67 iwr
.u
.data
.length
= sizeof(iwrange
);
70 ret
= ioctl(sock
, SIOCGIWRANGE
, &iwr
);
72 sigqual
= iwrange
.max_qual
.qual
;
81 u32
ethtool_bitrate(const char *ifname
)
83 int ret
, sock
, bitrate
;
85 struct ethtool_cmd ecmd
;
87 sock
= af_socket(AF_INET
);
89 memset(&ecmd
, 0, sizeof(ecmd
));
91 memset(&ifr
, 0, sizeof(ifr
));
92 strlcpy(ifr
.ifr_name
, ifname
, IFNAMSIZ
);
94 ecmd
.cmd
= ETHTOOL_GSET
;
95 ifr
.ifr_data
= (char *) &ecmd
;
97 ret
= ioctl(sock
, SIOCETHTOOL
, &ifr
);
103 bitrate
= ethtool_cmd_speed(&ecmd
);
104 if (bitrate
== SPEED_UNKNOWN
)
112 int ethtool_link(const char *ifname
)
116 struct ethtool_value ecmd
;
118 sock
= af_socket(AF_INET
);
120 memset(&ecmd
, 0, sizeof(ecmd
));
122 memset(&ifr
, 0, sizeof(ifr
));
123 strlcpy(ifr
.ifr_name
, ifname
, IFNAMSIZ
);
125 ecmd
.cmd
= ETHTOOL_GLINK
;
126 ifr
.ifr_data
= (char *) &ecmd
;
128 ret
= ioctl(sock
, SIOCETHTOOL
, &ifr
);
138 int ethtool_drvinf(const char *ifname
, struct ethtool_drvinfo
*drvinf
)
143 sock
= af_socket(AF_INET
);
145 memset(drvinf
, 0, sizeof(*drvinf
));
147 memset(&ifr
, 0, sizeof(ifr
));
148 strlcpy(ifr
.ifr_name
, ifname
, IFNAMSIZ
);
150 drvinf
->cmd
= ETHTOOL_GDRVINFO
;
151 ifr
.ifr_data
= (char *) drvinf
;
153 ret
= ioctl(sock
, SIOCETHTOOL
, &ifr
);