2 #include <linux/sockios.h>
10 u32
wireless_bitrate(const char *ifname
)
12 int sock
, ret
, rate_in_mbit
;
15 sock
= af_socket(AF_INET
);
17 memset(&iwr
, 0, sizeof(iwr
));
18 strlcpy(iwr
.ifr_name
, ifname
, IFNAMSIZ
);
20 ret
= ioctl(sock
, SIOCGIWRATE
, &iwr
);
22 rate_in_mbit
= iwr
.u
.bitrate
.value
/ 1000000;
31 int wireless_sigqual(const char *ifname
, struct iw_statistics
*stats
)
36 sock
= af_socket(AF_INET
);
38 memset(&iwr
, 0, sizeof(iwr
));
39 strlcpy(iwr
.ifr_name
, ifname
, IFNAMSIZ
);
41 iwr
.u
.data
.pointer
= (caddr_t
) stats
;
42 iwr
.u
.data
.length
= sizeof(*stats
);
45 ret
= ioctl(sock
, SIOCGIWSTATS
, &iwr
);
52 int wireless_rangemax_sigqual(const char *ifname
)
54 int ret
, sock
, sigqual
;
56 struct iw_range iwrange
;
58 sock
= af_socket(AF_INET
);
60 memset(&iwrange
, 0, sizeof(iwrange
));
62 memset(&iwr
, 0, sizeof(iwr
));
63 strlcpy(iwr
.ifr_name
, ifname
, IFNAMSIZ
);
65 iwr
.u
.data
.pointer
= (caddr_t
) &iwrange
;
66 iwr
.u
.data
.length
= sizeof(iwrange
);
69 ret
= ioctl(sock
, SIOCGIWRANGE
, &iwr
);
71 sigqual
= iwrange
.max_qual
.qual
;
80 u32
ethtool_bitrate(const char *ifname
)
82 int ret
, sock
, bitrate
;
84 struct ethtool_cmd ecmd
;
86 sock
= af_socket(AF_INET
);
88 memset(&ecmd
, 0, sizeof(ecmd
));
90 memset(&ifr
, 0, sizeof(ifr
));
91 strlcpy(ifr
.ifr_name
, ifname
, IFNAMSIZ
);
93 ecmd
.cmd
= ETHTOOL_GSET
;
94 ifr
.ifr_data
= (char *) &ecmd
;
96 ret
= ioctl(sock
, SIOCETHTOOL
, &ifr
);
102 switch (ecmd
.speed
) {
108 bitrate
= ecmd
.speed
;
120 int ethtool_link(const char *ifname
)
124 struct ethtool_value ecmd
;
126 sock
= af_socket(AF_INET
);
128 memset(&ecmd
, 0, sizeof(ecmd
));
130 memset(&ifr
, 0, sizeof(ifr
));
131 strlcpy(ifr
.ifr_name
, ifname
, IFNAMSIZ
);
133 ecmd
.cmd
= ETHTOOL_GLINK
;
134 ifr
.ifr_data
= (char *) &ecmd
;
136 ret
= ioctl(sock
, SIOCETHTOOL
, &ifr
);
146 int ethtool_drvinf(const char *ifname
, struct ethtool_drvinfo
*drvinf
)
151 sock
= af_socket(AF_INET
);
153 memset(drvinf
, 0, sizeof(*drvinf
));
155 memset(&ifr
, 0, sizeof(ifr
));
156 strlcpy(ifr
.ifr_name
, ifname
, IFNAMSIZ
);
158 drvinf
->cmd
= ETHTOOL_GDRVINFO
;
159 ifr
.ifr_data
= (char *) drvinf
;
161 ret
= ioctl(sock
, SIOCETHTOOL
, &ifr
);