* This code is based on the wlc.c utility published by OpenWrt.org .
*/
-#include "iwinfo/wl.h"
-#include "iwinfo/wext.h"
+#include "iwinfo.h"
+#include "api/broadcom.h"
static int wl_ioctl(const char *name, int cmd, void *buf, int len)
{
struct wl_maclist *macs;
int maclen = 4 + WL_MAX_STA_COUNT * 6;
+ if (strstr(ifname, "wds"))
+ return NULL;
+
if ((macs = (struct wl_maclist *) malloc(maclen)) != NULL)
{
memset(macs, 0, maclen);
}
-int wl_probe(const char *ifname)
+static int wl_probe(const char *ifname)
{
int magic;
return (!wl_ioctl(ifname, WLC_GET_MAGIC, &magic, sizeof(magic)) &&
(magic == WLC_IOCTL_MAGIC));
}
-void wl_close(void)
+static void wl_close(void)
{
/* Nop */
}
-int wl_get_mode(const char *ifname, int *buf)
+static int wl_get_mode(const char *ifname, int *buf)
{
int ret = -1;
int ap, infra, passive;
return 0;
}
-int wl_get_ssid(const char *ifname, char *buf)
+static int wl_get_ssid(const char *ifname, char *buf)
{
int ret = -1;
wlc_ssid_t ssid;
return ret;
}
-int wl_get_bssid(const char *ifname, char *buf)
+static int wl_get_bssid(const char *ifname, char *buf)
{
int ret = -1;
char bssid[6];
return ret;
}
-int wl_get_channel(const char *ifname, int *buf)
+static int wl_get_channel(const char *ifname, int *buf)
{
return wl_ioctl(ifname, WLC_GET_CHANNEL, buf, sizeof(buf));
}
-int wl_get_frequency(const char *ifname, int *buf)
+static int wl_get_frequency(const char *ifname, int *buf)
{
- return wext_get_frequency(ifname, buf);
+ return wext_ops.frequency(ifname, buf);
}
-int wl_get_txpower(const char *ifname, int *buf)
+static int wl_get_txpower(const char *ifname, int *buf)
{
/* WLC_GET_VAR "qtxpower" */
- return wext_get_txpower(ifname, buf);
+ return wext_ops.txpower(ifname, buf);
}
-int wl_get_bitrate(const char *ifname, int *buf)
+static int wl_get_bitrate(const char *ifname, int *buf)
{
int ret = -1;
int rate = 0;
return ret;
}
-int wl_get_signal(const char *ifname, int *buf)
+static int wl_get_signal(const char *ifname, int *buf)
{
unsigned int ap, rssi, i, rssi_count;
int ioctl_req_version = 0x2000;
return 0;
}
-int wl_get_noise(const char *ifname, int *buf)
+static int wl_get_noise(const char *ifname, int *buf)
{
unsigned int ap, noise;
int ioctl_req_version = 0x2000;
return 0;
}
-int wl_get_quality(const char *ifname, int *buf)
+static int wl_get_quality(const char *ifname, int *buf)
{
- return wext_get_quality(ifname, buf);
+ return wext_ops.quality(ifname, buf);
}
-int wl_get_quality_max(const char *ifname, int *buf)
+static int wl_get_quality_max(const char *ifname, int *buf)
{
- return wext_get_quality_max(ifname, buf);
+ return wext_ops.quality_max(ifname, buf);
}
-int wl_get_encryption(const char *ifname, char *buf)
+static int wl_get_encryption(const char *ifname, char *buf)
{
uint32_t wsec, wauth, wpa;
struct iwinfo_crypto_entry *c = (struct iwinfo_crypto_entry *)buf;
return 0;
}
-int wl_get_enctype(const char *ifname, char *buf)
+static int wl_get_phyname(const char *ifname, char *buf)
+{
+ char *p;
+
+ strcpy(buf, ifname);
+
+ if ((p = strchr(buf, '.')) != NULL)
+ *p = 0;
+
+ return 0;
+}
+
+static int wl_get_enctype(const char *ifname, char *buf)
{
uint32_t wsec, wpa;
char algo[11];
}
}
-int wl_get_assoclist(const char *ifname, char *buf, int *len)
+static int wl_get_assoclist(const char *ifname, char *buf, int *len)
{
int i, j, noise;
int ap, infra, passive;
return -1;
}
-int wl_get_txpwrlist(const char *ifname, char *buf, int *len)
+static int wl_get_txpwrlist(const char *ifname, char *buf, int *len)
{
struct iwinfo_txpwrlist_entry entry;
uint8_t dbm[11] = { 0, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24 };
return 0;
}
-int wl_get_scanlist(const char *ifname, char *buf, int *len)
+static int wl_get_scanlist(const char *ifname, char *buf, int *len)
{
- return wext_get_scanlist(ifname, buf, len);
+ return wext_ops.scanlist(ifname, buf, len);
}
-int wl_get_freqlist(const char *ifname, char *buf, int *len)
+static int wl_get_freqlist(const char *ifname, char *buf, int *len)
{
- return wext_get_freqlist(ifname, buf, len);
+ return wext_ops.freqlist(ifname, buf, len);
}
-int wl_get_country(const char *ifname, char *buf)
+static int wl_get_country(const char *ifname, char *buf)
{
char ccode[WLC_CNTRY_BUF_SZ];
return -1;
}
-int wl_get_countrylist(const char *ifname, char *buf, int *len)
+static int wl_get_countrylist(const char *ifname, char *buf, int *len)
{
int i, count;
char cdata[WLC_IOCTL_MAXLEN];
{
for (i = 0, count = 0; i < cl->count; i++, c++)
{
- sprintf(c->ccode, &cl->country_abbrev[i * WLC_CNTRY_BUF_SZ]);
+ snprintf(c->ccode, sizeof(c->ccode), "%s", &cl->country_abbrev[i * WLC_CNTRY_BUF_SZ]);
c->iso3166 = c->ccode[0] * 256 + c->ccode[1];
/* IL0 -> World */
return -1;
}
-int wl_get_hwmodelist(const char *ifname, int *buf)
+static int wl_get_hwmodelist(const char *ifname, int *buf)
{
- return wext_get_hwmodelist(ifname, buf);
+ int phytype;
+ uint i, band[WLC_BAND_ALL], bands;
+
+ if (!wl_ioctl(ifname, WLC_GET_PHYTYPE, &phytype, sizeof(phytype)) &&
+ !wl_ioctl(ifname, WLC_GET_BANDLIST, band, sizeof(band)))
+ {
+ *buf = 0;
+ switch (phytype)
+ {
+ case WLC_PHY_TYPE_A:
+ *buf = IWINFO_80211_A;
+ break;
+ case WLC_PHY_TYPE_B:
+ *buf = IWINFO_80211_B;
+ break;
+ case WLC_PHY_TYPE_AC:
+ *buf |= IWINFO_80211_AC;
+ case WLC_PHY_TYPE_HT:
+ case WLC_PHY_TYPE_N:
+ *buf |= IWINFO_80211_N;
+ case WLC_PHY_TYPE_LP:
+ case WLC_PHY_TYPE_G:
+ bands = 0;
+ for (i = 1; i <= band[0]; i++)
+ {
+ bands |= band[i];
+ }
+ if (bands & WLC_BAND_5G)
+ *buf |= IWINFO_80211_A;
+ if (bands & WLC_BAND_2G)
+ {
+ *buf |= IWINFO_80211_B;
+ *buf |= IWINFO_80211_G;
+ }
+ break;
+ default:
+ return -1;
+ break;
+ }
+ return 0;
+ }
+ return -1;
}
-int wl_get_mbssid_support(const char *ifname, int *buf)
+static int wl_get_mbssid_support(const char *ifname, int *buf)
{
wlc_rev_info_t revinfo;
return -1;
}
-int wl_get_hardware_id(const char *ifname, char *buf)
+static int wl_get_hardware_id(const char *ifname, char *buf)
{
wlc_rev_info_t revinfo;
struct iwinfo_hardware_id *ids = (struct iwinfo_hardware_id *)buf;
return 0;
}
-int wl_get_hardware_name(const char *ifname, char *buf)
+static int wl_get_hardware_name(const char *ifname, char *buf)
{
struct iwinfo_hardware_id ids;
return 0;
}
-int wl_get_txpower_offset(const char *ifname, int *buf)
+static int wl_get_txpower_offset(const char *ifname, int *buf)
{
FILE *p;
char off[8];
return 0;
}
-int wl_get_frequency_offset(const char *ifname, int *buf)
+static int wl_get_frequency_offset(const char *ifname, int *buf)
{
/* Stub */
*buf = 0;
return -1;
}
+
+const struct iwinfo_ops wl_ops = {
+ .name = "wl",
+ .probe = wl_probe,
+ .channel = wl_get_channel,
+ .frequency = wl_get_frequency,
+ .frequency_offset = wl_get_frequency_offset,
+ .txpower = wl_get_txpower,
+ .txpower_offset = wl_get_txpower_offset,
+ .bitrate = wl_get_bitrate,
+ .signal = wl_get_signal,
+ .noise = wl_get_noise,
+ .quality = wl_get_quality,
+ .quality_max = wl_get_quality_max,
+ .mbssid_support = wl_get_mbssid_support,
+ .hwmodelist = wl_get_hwmodelist,
+ .mode = wl_get_mode,
+ .ssid = wl_get_ssid,
+ .bssid = wl_get_bssid,
+ .country = wl_get_country,
+ .hardware_id = wl_get_hardware_id,
+ .hardware_name = wl_get_hardware_name,
+ .encryption = wl_get_encryption,
+ .phyname = wl_get_phyname,
+ .assoclist = wl_get_assoclist,
+ .txpwrlist = wl_get_txpwrlist,
+ .scanlist = wl_get_scanlist,
+ .freqlist = wl_get_freqlist,
+ .countrylist = wl_get_countrylist,
+ .close = wl_close
+};