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 bitrate
= ethtool_cmd_speed(&ecmd
);
103 if (bitrate
== SPEED_UNKNOWN
)
111 int ethtool_link(const char *ifname
)
115 struct ethtool_value ecmd
;
117 sock
= af_socket(AF_INET
);
119 memset(&ecmd
, 0, sizeof(ecmd
));
121 memset(&ifr
, 0, sizeof(ifr
));
122 strlcpy(ifr
.ifr_name
, ifname
, IFNAMSIZ
);
124 ecmd
.cmd
= ETHTOOL_GLINK
;
125 ifr
.ifr_data
= (char *) &ecmd
;
127 ret
= ioctl(sock
, SIOCETHTOOL
, &ifr
);
137 int ethtool_drvinf(const char *ifname
, struct ethtool_drvinfo
*drvinf
)
142 sock
= af_socket(AF_INET
);
144 memset(drvinf
, 0, sizeof(*drvinf
));
146 memset(&ifr
, 0, sizeof(ifr
));
147 strlcpy(ifr
.ifr_name
, ifname
, IFNAMSIZ
);
149 drvinf
->cmd
= ETHTOOL_GDRVINFO
;
150 ifr
.ifr_data
= (char *) drvinf
;
152 ret
= ioctl(sock
, SIOCETHTOOL
, &ifr
);