/* Broadcom */
LUA_WRAP_INT(wl,channel)
+LUA_WRAP_INT(wl,frequency)
LUA_WRAP_INT(wl,bitrate)
LUA_WRAP_INT(wl,signal)
LUA_WRAP_INT(wl,noise)
/* Madwifi */
LUA_WRAP_INT(madwifi,channel)
+LUA_WRAP_INT(madwifi,frequency)
LUA_WRAP_INT(madwifi,bitrate)
LUA_WRAP_INT(madwifi,signal)
LUA_WRAP_INT(madwifi,noise)
/* Wext */
LUA_WRAP_INT(wext,channel)
+LUA_WRAP_INT(wext,frequency)
LUA_WRAP_INT(wext,bitrate)
LUA_WRAP_INT(wext,signal)
LUA_WRAP_INT(wext,noise)
/* Broadcom table */
static const luaL_reg R_wl[] = {
LUA_REG(wl,channel),
+ LUA_REG(wl,frequency),
LUA_REG(wl,bitrate),
LUA_REG(wl,signal),
LUA_REG(wl,noise),
/* Madwifi table */
static const luaL_reg R_madwifi[] = {
LUA_REG(madwifi,channel),
+ LUA_REG(madwifi,frequency),
LUA_REG(madwifi,bitrate),
LUA_REG(madwifi,signal),
LUA_REG(madwifi,noise),
/* Wext table */
static const luaL_reg R_wext[] = {
LUA_REG(wext,channel),
+ LUA_REG(wext,frequency),
LUA_REG(wext,bitrate),
LUA_REG(wext,signal),
LUA_REG(wext,noise),
return -1;
}
+int madwifi_get_frequency(const char *ifname, int *buf)
+{
+ struct iwreq wrq;
+
+ if( madwifi_ioctl(&wrq, ifname, SIOCGIWFREQ, NULL, 0) >= 0 )
+ {
+ *buf = (uint16_t)(wrq.u.freq.m / 100000);
+ return 0;
+ }
+
+ return -1;
+}
+
int madwifi_get_bitrate(const char *ifname, int *buf)
{
unsigned int mode, len, rate, rate_count;
int madwifi_get_ssid(const char *ifname, char *buf);
int madwifi_get_bssid(const char *ifname, char *buf);
int madwifi_get_channel(const char *ifname, int *buf);
+int madwifi_get_frequency(const char *ifname, int *buf);
int madwifi_get_bitrate(const char *ifname, int *buf);
int madwifi_get_signal(const char *ifname, int *buf);
int madwifi_get_noise(const char *ifname, int *buf);
return res;
}
+static int wext_freq2mhz(const struct iw_freq *in)
+{
+ int i, mhz;
+
+ if( in->e == 6 )
+ {
+ return in->m;
+ }
+ else
+ {
+ mhz = in->m;
+ for(i = 0; i < in->e; i++)
+ mhz *= 10;
+
+ return (int)(mhz / 100000);
+ }
+}
+
static int wext_ioctl(const char *ifname, int cmd, struct iwreq *wrq)
{
/* prepare socket */
return -1;
}
+int wext_get_frequency(const char *ifname, int *buf)
+{
+ struct iwreq wrq;
+ struct iw_range range;
+ int i, channel;
+
+ if(wext_ioctl(ifname, SIOCGIWFREQ, &wrq) >= 0)
+ {
+ /* We got a channel number instead ... */
+ if( wrq.u.freq.m < 1000 )
+ {
+ channel = wrq.u.freq.m;
+ wrq.u.data.pointer = (caddr_t) ⦥
+ wrq.u.data.length = sizeof(struct iw_range);
+ wrq.u.data.flags = 0;
+
+ if(wext_ioctl(ifname, SIOCGIWRANGE, &wrq) >= 0)
+ {
+ for(i = 0; i < range.num_frequency; i++)
+ {
+ if( range.freq[i].i == channel )
+ {
+ *buf = wext_freq2mhz(&range.freq[i]);
+ return 0;
+ }
+ }
+ }
+ }
+ else
+ {
+ *buf = wext_freq2mhz(&wrq.u.freq);
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
int wext_get_signal(const char *ifname, int *buf)
{
struct iwreq wrq;
#ifndef __IWINFO_WEXT_H_
#define __IWINFO_WEXT_H_
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <glob.h>
-#include <ctype.h>
-#include <stdint.h>
-
-#include <sys/ioctl.h>
-#include <net/if.h>
-#include <errno.h>
-
+#include "iwinfo.h"
#include "include/wext.h"
int wext_probe(const char *ifname);
int wext_get_ssid(const char *ifname, char *buf);
int wext_get_bssid(const char *ifname, char *buf);
int wext_get_channel(const char *ifname, int *buf);
+int wext_get_frequency(const char *ifname, int *buf);
int wext_get_bitrate(const char *ifname, int *buf);
int wext_get_signal(const char *ifname, int *buf);
int wext_get_noise(const char *ifname, int *buf);
return wl_ioctl(ifname, WLC_GET_CHANNEL, buf, sizeof(buf));
}
+int wl_get_frequency(const char *ifname, int *buf)
+{
+ return wext_get_frequency(ifname, buf);
+}
+
int wl_get_bitrate(const char *ifname, int *buf)
{
int ret = -1;
int wl_get_ssid(const char *ifname, char *buf);
int wl_get_bssid(const char *ifname, char *buf);
int wl_get_channel(const char *ifname, int *buf);
+int wl_get_frequency(const char *ifname, int *buf);
int wl_get_bitrate(const char *ifname, int *buf);
int wl_get_signal(const char *ifname, int *buf);
int wl_get_noise(const char *ifname, int *buf);