3 #include <linux/sockios.h>
12 u32
wireless_bitrate(const char *ifname
)
14 int sock
, ret
, rate_in_mbit
;
17 sock
= af_socket(AF_INET
);
19 memset(&iwr
, 0, sizeof(iwr
));
20 strlcpy(iwr
.ifr_name
, ifname
, IFNAMSIZ
);
22 ret
= ioctl(sock
, SIOCGIWRATE
, &iwr
);
24 rate_in_mbit
= iwr
.u
.bitrate
.value
/ 1000000;
33 int wireless_sigqual(const char *ifname
, struct iw_statistics
*stats
)
38 sock
= af_socket(AF_INET
);
40 memset(&iwr
, 0, sizeof(iwr
));
41 strlcpy(iwr
.ifr_name
, ifname
, IFNAMSIZ
);
43 iwr
.u
.data
.pointer
= (caddr_t
) stats
;
44 iwr
.u
.data
.length
= sizeof(*stats
);
47 ret
= ioctl(sock
, SIOCGIWSTATS
, &iwr
);
54 int wireless_rangemax_sigqual(const char *ifname
)
56 int ret
, sock
, sigqual
;
58 struct iw_range iwrange
;
60 sock
= af_socket(AF_INET
);
62 memset(&iwrange
, 0, sizeof(iwrange
));
64 memset(&iwr
, 0, sizeof(iwr
));
65 strlcpy(iwr
.ifr_name
, ifname
, IFNAMSIZ
);
67 iwr
.u
.data
.pointer
= (caddr_t
) &iwrange
;
68 iwr
.u
.data
.length
= sizeof(iwrange
);
71 ret
= ioctl(sock
, SIOCGIWRANGE
, &iwr
);
73 sigqual
= iwrange
.max_qual
.qual
;
82 u32
ethtool_bitrate(const char *ifname
)
84 int ret
, sock
, bitrate
;
86 struct ethtool_cmd ecmd
;
88 sock
= af_socket(AF_INET
);
90 memset(&ecmd
, 0, sizeof(ecmd
));
92 memset(&ifr
, 0, sizeof(ifr
));
93 strlcpy(ifr
.ifr_name
, ifname
, IFNAMSIZ
);
95 ecmd
.cmd
= ETHTOOL_GSET
;
96 ifr
.ifr_data
= (char *) &ecmd
;
98 ret
= ioctl(sock
, SIOCETHTOOL
, &ifr
);
104 bitrate
= ethtool_cmd_speed(&ecmd
);
105 if (bitrate
== SPEED_UNKNOWN
)
113 int ethtool_link(const char *ifname
)
117 struct ethtool_value ecmd
;
119 sock
= af_socket(AF_INET
);
121 memset(&ecmd
, 0, sizeof(ecmd
));
123 memset(&ifr
, 0, sizeof(ifr
));
124 strlcpy(ifr
.ifr_name
, ifname
, IFNAMSIZ
);
126 ecmd
.cmd
= ETHTOOL_GLINK
;
127 ifr
.ifr_data
= (char *) &ecmd
;
129 ret
= ioctl(sock
, SIOCETHTOOL
, &ifr
);
139 int ethtool_drvinf(const char *ifname
, struct ethtool_drvinfo
*drvinf
)
144 sock
= af_socket(AF_INET
);
146 memset(drvinf
, 0, sizeof(*drvinf
));
148 memset(&ifr
, 0, sizeof(ifr
));
149 strlcpy(ifr
.ifr_name
, ifname
, IFNAMSIZ
);
151 drvinf
->cmd
= ETHTOOL_GDRVINFO
;
152 ifr
.ifr_data
= (char *) drvinf
;
154 ret
= ioctl(sock
, SIOCETHTOOL
, &ifr
);