1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2025-04-21 12:27:27 +03:00

[package] add libiwinfo (moved from LuCI trunk)

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@29403 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
jow
2011-12-03 13:57:38 +00:00
parent f688ec4123
commit 60e9be7f19
24 changed files with 10947 additions and 0 deletions

View File

@@ -0,0 +1,143 @@
#ifndef __IWINFO_H_
#define __IWINFO_H_
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <glob.h>
#include <ctype.h>
#include <dirent.h>
#include <stdint.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <errno.h>
#define IWINFO_BUFSIZE 24 * 1024
#define IWINFO_ESSID_MAX_SIZE 32
#define IWINFO_80211_A (1 << 0)
#define IWINFO_80211_B (1 << 1)
#define IWINFO_80211_G (1 << 2)
#define IWINFO_80211_N (1 << 3)
#define IWINFO_CIPHER_NONE (1 << 0)
#define IWINFO_CIPHER_WEP40 (1 << 1)
#define IWINFO_CIPHER_TKIP (1 << 2)
#define IWINFO_CIPHER_WRAP (1 << 3)
#define IWINFO_CIPHER_CCMP (1 << 4)
#define IWINFO_CIPHER_WEP104 (1 << 5)
#define IWINFO_CIPHER_AESOCB (1 << 6)
#define IWINFO_CIPHER_CKIP (1 << 7)
#define IWINFO_KMGMT_NONE (1 << 0)
#define IWINFO_KMGMT_8021x (1 << 1)
#define IWINFO_KMGMT_PSK (1 << 2)
#define IWINFO_AUTH_OPEN (1 << 0)
#define IWINFO_AUTH_SHARED (1 << 1)
extern const char *IWINFO_CIPHER_NAMES[];
extern const char *IWINFO_KMGMT_NAMES[];
extern const char *IWINFO_AUTH_NAMES[];
struct iwinfo_assoclist_entry {
uint8_t mac[6];
int8_t signal;
int8_t noise;
};
struct iwinfo_txpwrlist_entry {
uint8_t dbm;
uint16_t mw;
};
struct iwinfo_freqlist_entry {
uint8_t channel;
uint32_t mhz;
uint8_t restricted;
};
struct iwinfo_crypto_entry {
uint8_t enabled;
uint8_t wpa_version;
uint8_t group_ciphers;
uint8_t pair_ciphers;
uint8_t auth_suites;
uint8_t auth_algs;
};
struct iwinfo_scanlist_entry {
uint8_t mac[6];
uint8_t ssid[IWINFO_ESSID_MAX_SIZE+1];
uint8_t mode[8];
uint8_t channel;
uint8_t signal;
uint8_t quality;
uint8_t quality_max;
struct iwinfo_crypto_entry crypto;
};
struct iwinfo_country_entry {
uint16_t iso3166;
uint8_t ccode[4];
};
struct iwinfo_iso3166_label {
uint16_t iso3166;
uint8_t name[28];
};
extern const struct iwinfo_iso3166_label IWINFO_ISO3166_NAMES[];
struct iwinfo_ops {
int (*channel)(const char *, int *);
int (*frequency)(const char *, int *);
int (*txpower)(const char *, int *);
int (*bitrate)(const char *, int *);
int (*signal)(const char *, int *);
int (*noise)(const char *, int *);
int (*quality)(const char *, int *);
int (*quality_max)(const char *, int *);
int (*mbssid_support)(const char *, int *);
int (*hwmodelist)(const char *, int *);
int (*mode)(const char *, char *);
int (*ssid)(const char *, char *);
int (*bssid)(const char *, char *);
int (*country)(const char *, char *);
int (*encryption)(const char *, char *);
int (*assoclist)(const char *, char *, int *);
int (*txpwrlist)(const char *, char *, int *);
int (*scanlist)(const char *, char *, int *);
int (*freqlist)(const char *, char *, int *);
int (*countrylist)(const char *, char *, int *);
void (*close)(void);
};
const char * iwinfo_type(const char *ifname);
const struct iwinfo_ops * iwinfo_backend(const char *ifname);
void iwinfo_finish(void);
#include "iwinfo/wext.h"
#ifdef USE_WL
#include "iwinfo/wl.h"
#endif
#ifdef USE_MADWIFI
#include "iwinfo/madwifi.h"
#endif
#ifdef USE_NL80211
#include "iwinfo/nl80211.h"
#endif
#endif

View File

@@ -0,0 +1,107 @@
/*
* Custom OID/ioctl definitions for
* Broadcom 802.11abg Networking Device Driver
*
* Definitions subject to change without notice.
*
* Copyright 2006, Broadcom Corporation
* All Rights Reserved.
*
* THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
* KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
* SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
*
*/
#ifndef _BROADCOM_H
#define _BROADCOM_H
#define WL_MCSSET_LEN 16
#define WL_MAX_STA_COUNT 32
#define WL_BSS_RSSI_OFFSET 82
#define WL_BSS_NOISE_OFFSET 84
#define WLC_IOCTL_MAGIC 0x14e46c77
#define WLC_IOCTL_MAXLEN 8192
#define WLC_CNTRY_BUF_SZ 4
#define WLC_GET_MAGIC 0
#define WLC_GET_RATE 12
#define WLC_GET_INFRA 19
#define WLC_GET_AUTH 21
#define WLC_GET_BSSID 23
#define WLC_GET_SSID 25
#define WLC_GET_CHANNEL 29
#define WLC_GET_PASSIVE 48
#define WLC_GET_COUNTRY 83
#define WLC_GET_REVINFO 98
#define WLC_GET_AP 117
#define WLC_GET_RSSI 127
#define WLC_GET_WSEC 133
#define WLC_GET_PHY_NOISE 135
#define WLC_GET_BSS_INFO 136
#define WLC_GET_ASSOCLIST 159
#define WLC_GET_WPA_AUTH 164
#define WLC_GET_COUNTRY_LIST 261
#define WLC_GET_VAR 262
struct wl_ether_addr {
uint8_t octet[6];
};
struct wl_maclist {
uint count;
struct wl_ether_addr ea[1];
};
typedef struct wl_sta_rssi {
int rssi;
char mac[6];
uint16_t foo;
} wl_sta_rssi_t;
typedef struct wlc_ssid {
uint32_t ssid_len;
unsigned char ssid[32];
} wlc_ssid_t;
/* Linux network driver ioctl encoding */
typedef struct wl_ioctl {
uint32_t cmd; /* common ioctl definition */
void *buf; /* pointer to user buffer */
uint32_t len; /* length of user buffer */
uint8_t set; /* get or set request (optional) */
uint32_t used; /* bytes read or written (optional) */
uint32_t needed; /* bytes needed (optional) */
} wl_ioctl_t;
/* Revision info */
typedef struct wlc_rev_info {
uint vendorid; /* PCI vendor id */
uint deviceid; /* device id of chip */
uint radiorev; /* radio revision */
uint chiprev; /* chip revision */
uint corerev; /* core revision */
uint boardid; /* board identifier (usu. PCI sub-device id) */
uint boardvendor; /* board vendor (usu. PCI sub-vendor id) */
uint boardrev; /* board revision */
uint driverrev; /* driver version */
uint ucoderev; /* microcode version */
uint bus; /* bus type */
uint chipnum; /* chip number */
} wlc_rev_info_t;
typedef struct wl_country_list {
uint32_t buflen;
uint32_t band_set;
uint32_t band;
uint32_t count;
char country_abbrev[1];
} wl_country_list_t;
#endif

View File

@@ -0,0 +1,158 @@
/*
* Header bits derived from MadWifi source:
* Copyright (c) 2001 Atsushi Onoe
* Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
* All rights reserved.
*
* Distributed under the terms of the GPLv2 license.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _MADWIFI_H
#define _MADWIFI_H
/* ieee80211.h */
#define IEEE80211_ADDR_LEN 6
#define IEEE80211_RATE_VAL 0x7f
/* ieee80211_crypto.h */
#define IEEE80211_KEYBUF_SIZE 16
#define IEEE80211_MICBUF_SIZE 16
#define IEEE80211_TID_SIZE 17
#define IEEE80211_CIPHER_WEP 0
#define IEEE80211_CIPHER_TKIP 1
#define IEEE80211_CIPHER_AES_OCB 2
#define IEEE80211_CIPHER_AES_CCM 3
#define IEEE80211_CIPHER_CKIP 5
#define IEEE80211_CIPHER_NONE 6
#define IEEE80211_CIPHER_MAX (IEEE80211_CIPHER_NONE + 1)
/* ieee80211_ioctl.h */
#define IEEE80211_KEY_DEFAULT 0x80
#define IEEE80211_CHAN_MAX 255
#define IEEE80211_CHAN_BYTES 32
#define IEEE80211_RATE_MAXSIZE 15
#define IEEE80211_IOCTL_GETKEY (SIOCDEVPRIVATE+3)
#define IEEE80211_IOCTL_STA_STATS (SIOCDEVPRIVATE+5)
#define IEEE80211_IOCTL_STA_INFO (SIOCDEVPRIVATE+6)
#define IEEE80211_IOCTL_GETPARAM (SIOCIWFIRSTPRIV+1)
#define IEEE80211_IOCTL_GETMODE (SIOCIWFIRSTPRIV+3)
#define IEEE80211_IOCTL_GETCHANLIST (SIOCIWFIRSTPRIV+7)
#define IEEE80211_IOCTL_GETCHANINFO (SIOCIWFIRSTPRIV+13)
#define SIOC80211IFCREATE (SIOCDEVPRIVATE+7)
#define SIOC80211IFDESTROY (SIOCDEVPRIVATE+8)
#define IEEE80211_CLONE_BSSID 0x0001 /* allocate unique mac/bssid */
#define IEEE80211_NO_STABEACONS 0x0002 /* Do not setup the station beacon timers */
struct ieee80211_clone_params {
char icp_name[IFNAMSIZ]; /* device name */
u_int16_t icp_opmode; /* operating mode */
u_int16_t icp_flags; /* see below */
};
enum ieee80211_opmode {
IEEE80211_M_STA = 1, /* infrastructure station */
IEEE80211_M_IBSS = 0, /* IBSS (adhoc) station */
IEEE80211_M_AHDEMO = 3, /* Old lucent compatible adhoc demo */
IEEE80211_M_HOSTAP = 6, /* Software Access Point */
IEEE80211_M_MONITOR = 8, /* Monitor mode */
IEEE80211_M_WDS = 2, /* WDS link */
};
enum {
IEEE80211_PARAM_AUTHMODE = 3, /* authentication mode */
IEEE80211_PARAM_MCASTCIPHER = 5, /* multicast/default cipher */
IEEE80211_PARAM_MCASTKEYLEN = 6, /* multicast key length */
IEEE80211_PARAM_UCASTCIPHERS = 7, /* unicast cipher suites */
IEEE80211_PARAM_WPA = 10, /* WPA mode (0,1,2) */
};
/*
* Authentication mode.
*/
enum ieee80211_authmode {
IEEE80211_AUTH_NONE = 0,
IEEE80211_AUTH_OPEN = 1, /* open */
IEEE80211_AUTH_SHARED = 2, /* shared-key */
IEEE80211_AUTH_8021X = 3, /* 802.1x */
IEEE80211_AUTH_AUTO = 4, /* auto-select/accept */
/* NB: these are used only for ioctls */
IEEE80211_AUTH_WPA = 5, /* WPA/RSN w/ 802.1x/PSK */
};
struct ieee80211_channel {
u_int16_t ic_freq; /* setting in MHz */
u_int16_t ic_flags; /* see below */
u_int8_t ic_ieee; /* IEEE channel number */
int8_t ic_maxregpower; /* maximum regulatory tx power in dBm */
int8_t ic_maxpower; /* maximum tx power in dBm */
int8_t ic_minpower; /* minimum tx power in dBm */
u_int8_t ic_scanflags;
u_int8_t ic_idletime; /* phy idle time in % */
};
struct ieee80211req_key {
u_int8_t ik_type; /* key/cipher type */
u_int8_t ik_pad;
u_int16_t ik_keyix; /* key index */
u_int8_t ik_keylen; /* key length in bytes */
u_int8_t ik_flags;
u_int8_t ik_macaddr[IEEE80211_ADDR_LEN];
u_int64_t ik_keyrsc; /* key receive sequence counter */
u_int64_t ik_keytsc; /* key transmit sequence counter */
u_int8_t ik_keydata[IEEE80211_KEYBUF_SIZE+IEEE80211_MICBUF_SIZE];
};
struct ieee80211req_chanlist {
u_int8_t ic_channels[IEEE80211_CHAN_BYTES];
};
struct ieee80211req_chaninfo {
u_int ic_nchans;
struct ieee80211_channel ic_chans[IEEE80211_CHAN_MAX];
};
struct ieee80211req_sta_info {
u_int16_t isi_len; /* length (mult of 4) */
u_int16_t isi_freq; /* MHz */
u_int16_t isi_flags; /* channel flags */
u_int16_t isi_state; /* state flags */
u_int8_t isi_authmode; /* authentication algorithm */
u_int8_t isi_rssi;
int8_t isi_noise;
u_int16_t isi_capinfo; /* capabilities */
u_int8_t isi_athflags; /* Atheros capabilities */
u_int8_t isi_erp; /* ERP element */
u_int8_t isi_macaddr[IEEE80211_ADDR_LEN];
u_int8_t isi_nrates; /* negotiated rates */
u_int8_t isi_rates[IEEE80211_RATE_MAXSIZE];
u_int8_t isi_txrate; /* index to isi_rates[] */
u_int16_t isi_ie_len; /* IE length */
u_int16_t isi_associd; /* assoc response */
u_int16_t isi_txpower; /* current tx power */
u_int16_t isi_vlan; /* vlan tag */
u_int16_t isi_txseqs[17]; /* seq to be transmitted */
u_int16_t isi_rxseqs[17]; /* seq previous for qos frames*/
u_int16_t isi_inact; /* inactivity timer */
u_int8_t isi_uapsd; /* UAPSD queues */
u_int8_t isi_opmode; /* sta operating mode */
};
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,81 @@
/*
* iwinfo - Wireless Information Library - Lua Headers
*
* Copyright (C) 2009 Jo-Philipp Wich <xm@subsignal.org>
*
* The iwinfo library is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* The iwinfo library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with the iwinfo library. If not, see http://www.gnu.org/licenses/.
*/
#ifndef __IWINFO_LUALUB_H_
#define __IWINFO_LUALIB_H_
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#include "iwinfo.h"
#include "iwinfo/wext_scan.h"
#define IWINFO_META "iwinfo"
#define IWINFO_WEXT_META "iwinfo.wext"
#ifdef USE_WL
#define IWINFO_WL_META "iwinfo.wl"
#endif
#ifdef USE_MADWIFI
#define IWINFO_MADWIFI_META "iwinfo.madwifi"
#endif
#ifdef USE_NL80211
#define IWINFO_NL80211_META "iwinfo.nl80211"
#endif
#define LUA_REG(type,op) \
{ #op, iwinfo_L_##type##_##op }
#define LUA_WRAP_INT(type,op) \
static int iwinfo_L_##type##_##op(lua_State *L) \
{ \
const char *ifname = luaL_checkstring(L, 1); \
int rv; \
if( !type##_get_##op(ifname, &rv) ) \
lua_pushnumber(L, rv); \
else \
lua_pushnil(L); \
return 1; \
}
#define LUA_WRAP_STRING(type,op) \
static int iwinfo_L_##type##_##op(lua_State *L) \
{ \
const char *ifname = luaL_checkstring(L, 1); \
char rv[IWINFO_BUFSIZE]; \
memset(rv, 0, IWINFO_BUFSIZE); \
if( !type##_get_##op(ifname, rv) ) \
lua_pushstring(L, rv); \
else \
lua_pushnil(L); \
return 1; \
}
#define LUA_WRAP_LIST(type,op) \
static int iwinfo_L_##type##_##op(lua_State *L) \
{ \
return iwinfo_L_##op(L, type##_get_##op); \
}
#endif

View File

@@ -0,0 +1,75 @@
/*
* iwinfo - Wireless Information Library - Madwifi Headers
*
* Copyright (C) 2009 Jo-Philipp Wich <xm@subsignal.org>
*
* The iwinfo library is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* The iwinfo library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with the iwinfo library. If not, see http://www.gnu.org/licenses/.
*/
#ifndef __IWINFO_MADWIFI_H_
#define __IWINFO_MADWIFI_H_
#include <fcntl.h>
#include "iwinfo.h"
#include "iwinfo/utils.h"
#include "iwinfo/api/madwifi.h"
int madwifi_probe(const char *ifname);
int madwifi_get_mode(const char *ifname, char *buf);
int madwifi_get_ssid(const char *ifname, char *buf);
int madwifi_get_bssid(const char *ifname, char *buf);
int madwifi_get_country(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_txpower(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);
int madwifi_get_quality(const char *ifname, int *buf);
int madwifi_get_quality_max(const char *ifname, int *buf);
int madwifi_get_encryption(const char *ifname, char *buf);
int madwifi_get_assoclist(const char *ifname, char *buf, int *len);
int madwifi_get_txpwrlist(const char *ifname, char *buf, int *len);
int madwifi_get_scanlist(const char *ifname, char *buf, int *len);
int madwifi_get_freqlist(const char *ifname, char *buf, int *len);
int madwifi_get_countrylist(const char *ifname, char *buf, int *len);
int madwifi_get_hwmodelist(const char *ifname, int *buf);
int madwifi_get_mbssid_support(const char *ifname, int *buf);
void madwifi_close(void);
static const struct iwinfo_ops madwifi_ops = {
.channel = madwifi_get_channel,
.frequency = madwifi_get_frequency,
.txpower = madwifi_get_txpower,
.bitrate = madwifi_get_bitrate,
.signal = madwifi_get_signal,
.noise = madwifi_get_noise,
.quality = madwifi_get_quality,
.quality_max = madwifi_get_quality_max,
.mbssid_support = madwifi_get_mbssid_support,
.hwmodelist = madwifi_get_hwmodelist,
.mode = madwifi_get_mode,
.ssid = madwifi_get_ssid,
.bssid = madwifi_get_bssid,
.country = madwifi_get_country,
.encryption = madwifi_get_encryption,
.assoclist = madwifi_get_assoclist,
.txpwrlist = madwifi_get_txpwrlist,
.scanlist = madwifi_get_scanlist,
.freqlist = madwifi_get_freqlist,
.countrylist = madwifi_get_countrylist,
.close = madwifi_close
};
#endif

View File

@@ -0,0 +1,106 @@
/*
* iwinfo - Wireless Information Library - NL80211 Headers
*
* Copyright (C) 2010 Jo-Philipp Wich <xm@subsignal.org>
*
* The iwinfo library is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* The iwinfo library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with the iwinfo library. If not, see http://www.gnu.org/licenses/.
*/
#ifndef __IWINFO_NL80211_H_
#define __IWINFO_NL80211_H_
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <dirent.h>
#include <signal.h>
#include <sys/un.h>
#include <netlink/netlink.h>
#include <netlink/genl/genl.h>
#include <netlink/genl/family.h>
#include <netlink/genl/ctrl.h>
#include "iwinfo.h"
#include "iwinfo/utils.h"
#include "iwinfo/api/nl80211.h"
struct nl80211_state {
struct nl_sock *nl_sock;
struct nl_cache *nl_cache;
struct genl_family *nl80211;
};
struct nl80211_msg_conveyor {
struct nl_msg *msg;
struct nl_cb *cb;
};
struct nl80211_rssi_rate {
int16_t rate;
int8_t rssi;
};
struct nl80211_array_buf {
void *buf;
int count;
};
int nl80211_probe(const char *ifname);
int nl80211_get_mode(const char *ifname, char *buf);
int nl80211_get_ssid(const char *ifname, char *buf);
int nl80211_get_bssid(const char *ifname, char *buf);
int nl80211_get_country(const char *ifname, char *buf);
int nl80211_get_channel(const char *ifname, int *buf);
int nl80211_get_frequency(const char *ifname, int *buf);
int nl80211_get_txpower(const char *ifname, int *buf);
int nl80211_get_bitrate(const char *ifname, int *buf);
int nl80211_get_signal(const char *ifname, int *buf);
int nl80211_get_noise(const char *ifname, int *buf);
int nl80211_get_quality(const char *ifname, int *buf);
int nl80211_get_quality_max(const char *ifname, int *buf);
int nl80211_get_encryption(const char *ifname, char *buf);
int nl80211_get_assoclist(const char *ifname, char *buf, int *len);
int nl80211_get_txpwrlist(const char *ifname, char *buf, int *len);
int nl80211_get_scanlist(const char *ifname, char *buf, int *len);
int nl80211_get_freqlist(const char *ifname, char *buf, int *len);
int nl80211_get_countrylist(const char *ifname, char *buf, int *len);
int nl80211_get_hwmodelist(const char *ifname, int *buf);
int nl80211_get_mbssid_support(const char *ifname, int *buf);
void nl80211_close(void);
static const struct iwinfo_ops nl80211_ops = {
.channel = nl80211_get_channel,
.frequency = nl80211_get_frequency,
.txpower = nl80211_get_txpower,
.bitrate = nl80211_get_bitrate,
.signal = nl80211_get_signal,
.noise = nl80211_get_noise,
.quality = nl80211_get_quality,
.quality_max = nl80211_get_quality_max,
.mbssid_support = nl80211_get_mbssid_support,
.hwmodelist = nl80211_get_hwmodelist,
.mode = nl80211_get_mode,
.ssid = nl80211_get_ssid,
.bssid = nl80211_get_bssid,
.country = nl80211_get_country,
.encryption = nl80211_get_encryption,
.assoclist = nl80211_get_assoclist,
.txpwrlist = nl80211_get_txpwrlist,
.scanlist = nl80211_get_scanlist,
.freqlist = nl80211_get_freqlist,
.countrylist = nl80211_get_countrylist,
.close = nl80211_close
};
#endif

View File

@@ -0,0 +1,40 @@
/*
* iwinfo - Wireless Information Library - Utility Headers
*
* Copyright (C) 2010 Jo-Philipp Wich <xm@subsignal.org>
*
* The iwinfo library is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* The iwinfo library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with the iwinfo library. If not, see http://www.gnu.org/licenses/.
*/
#ifndef __IWINFO_UTILS_H_
#define __IWINFO_UTILS_H_
#include <sys/socket.h>
#include <net/if.h>
#include "iwinfo.h"
#define LOG10_MAGIC 1.25892541179
int iwinfo_ioctl(int cmd, void *ifr);
int iwinfo_dbm2mw(int in);
int iwinfo_mw2dbm(int in);
int iwinfo_ifup(const char *ifname);
int iwinfo_ifdown(const char *ifname);
int iwinfo_ifmac(const char *ifname);
void iwinfo_close(void);
#endif

View File

@@ -0,0 +1,76 @@
/*
* iwinfo - Wireless Information Library - Linux Wireless Extension Headers
*
* Copyright (C) 2009-2010 Jo-Philipp Wich <xm@subsignal.org>
*
* The iwinfo library is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* The iwinfo library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with the iwinfo library. If not, see http://www.gnu.org/licenses/.
*/
#ifndef __IWINFO_WEXT_H_
#define __IWINFO_WEXT_H_
#include <fcntl.h>
#include "iwinfo.h"
#include "iwinfo/utils.h"
#include "iwinfo/api/wext.h"
int wext_probe(const char *ifname);
int wext_get_mode(const char *ifname, char *buf);
int wext_get_ssid(const char *ifname, char *buf);
int wext_get_bssid(const char *ifname, char *buf);
int wext_get_country(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_txpower(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);
int wext_get_quality(const char *ifname, int *buf);
int wext_get_quality_max(const char *ifname, int *buf);
int wext_get_encryption(const char *ifname, char *buf);
int wext_get_assoclist(const char *ifname, char *buf, int *len);
int wext_get_txpwrlist(const char *ifname, char *buf, int *len);
int wext_get_scanlist(const char *ifname, char *buf, int *len);
int wext_get_freqlist(const char *ifname, char *buf, int *len);
int wext_get_countrylist(const char *ifname, char *buf, int *len);
int wext_get_hwmodelist(const char *ifname, int *buf);
int wext_get_mbssid_support(const char *ifname, int *buf);
void wext_close(void);
static const struct iwinfo_ops wext_ops = {
.channel = wext_get_channel,
.frequency = wext_get_frequency,
.txpower = wext_get_txpower,
.bitrate = wext_get_bitrate,
.signal = wext_get_signal,
.noise = wext_get_noise,
.quality = wext_get_quality,
.quality_max = wext_get_quality_max,
.mbssid_support = wext_get_mbssid_support,
.hwmodelist = wext_get_hwmodelist,
.mode = wext_get_mode,
.ssid = wext_get_ssid,
.bssid = wext_get_bssid,
.country = wext_get_country,
.encryption = wext_get_encryption,
.assoclist = wext_get_assoclist,
.txpwrlist = wext_get_txpwrlist,
.scanlist = wext_get_scanlist,
.freqlist = wext_get_freqlist,
.countrylist = wext_get_countrylist,
.close = wext_close
};
#endif

View File

@@ -0,0 +1,380 @@
/*
* iwinfo - Wireless Information Library - Linux Wireless Extension Headers
*
* Copyright (C) 2009-2010 Jo-Philipp Wich <xm@subsignal.org>
*
* The iwinfo library is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* The iwinfo library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with the iwinfo library. If not, see http://www.gnu.org/licenses/.
*/
#ifndef __IWINFO_WEXT_SCAN_H_
#define __IWINFO_WEXT_SCAN_H_
#include <fcntl.h>
#include "iwinfo.h"
#include "iwinfo/utils.h"
#include "iwinfo/api/wext.h"
typedef struct stream_descr
{
char * end; /* End of the stream */
char * current; /* Current event in stream of events */
char * value; /* Current value in event */
} stream_descr;
/*
* Describe how a standard IOCTL looks like.
*/
struct iw_ioctl_description
{
uint8_t header_type; /* NULL, iw_point or other */
uint8_t token_type; /* Future */
uint16_t token_size; /* Granularity of payload */
uint16_t min_tokens; /* Min acceptable token number */
uint16_t max_tokens; /* Max acceptable token number */
uint32_t flags; /* Special handling of the request */
};
/* Type of headers we know about (basically union iwreq_data) */
#define IW_HEADER_TYPE_NULL 0 /* Not available */
#define IW_HEADER_TYPE_CHAR 2 /* char [IFNAMSIZ] */
#define IW_HEADER_TYPE_UINT 4 /* __u32 */
#define IW_HEADER_TYPE_FREQ 5 /* struct iw_freq */
#define IW_HEADER_TYPE_ADDR 6 /* struct sockaddr */
#define IW_HEADER_TYPE_POINT 8 /* struct iw_point */
#define IW_HEADER_TYPE_PARAM 9 /* struct iw_param */
#define IW_HEADER_TYPE_QUAL 10 /* struct iw_quality */
/* Handling flags */
/* Most are not implemented. I just use them as a reminder of some
* cool features we might need one day ;-) */
#define IW_DESCR_FLAG_NONE 0x0000 /* Obvious */
/* Wrapper level flags */
#define IW_DESCR_FLAG_DUMP 0x0001 /* Not part of the dump command */
#define IW_DESCR_FLAG_EVENT 0x0002 /* Generate an event on SET */
#define IW_DESCR_FLAG_RESTRICT 0x0004 /* GET : request is ROOT only */
/* SET : Omit payload from generated iwevent */
#define IW_DESCR_FLAG_NOMAX 0x0008 /* GET : no limit on request size */
/* Driver level flags */
#define IW_DESCR_FLAG_WAIT 0x0100 /* Wait for driver event */
/*
* Meta-data about all the standard Wireless Extension request we
* know about.
*/
static const struct iw_ioctl_description standard_ioctl_descr[] = {
[SIOCSIWCOMMIT - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_NULL,
},
[SIOCGIWNAME - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_CHAR,
.flags = IW_DESCR_FLAG_DUMP,
},
[SIOCSIWNWID - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_PARAM,
.flags = IW_DESCR_FLAG_EVENT,
},
[SIOCGIWNWID - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_PARAM,
.flags = IW_DESCR_FLAG_DUMP,
},
[SIOCSIWFREQ - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_FREQ,
.flags = IW_DESCR_FLAG_EVENT,
},
[SIOCGIWFREQ - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_FREQ,
.flags = IW_DESCR_FLAG_DUMP,
},
[SIOCSIWMODE - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_UINT,
.flags = IW_DESCR_FLAG_EVENT,
},
[SIOCGIWMODE - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_UINT,
.flags = IW_DESCR_FLAG_DUMP,
},
[SIOCSIWSENS - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_PARAM,
},
[SIOCGIWSENS - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_PARAM,
},
[SIOCSIWRANGE - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_NULL,
},
[SIOCGIWRANGE - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_POINT,
.token_size = 1,
.max_tokens = sizeof(struct iw_range),
.flags = IW_DESCR_FLAG_DUMP,
},
[SIOCSIWPRIV - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_NULL,
},
[SIOCGIWPRIV - SIOCIWFIRST] = { /* (handled directly by us) */
.header_type = IW_HEADER_TYPE_NULL,
},
[SIOCSIWSTATS - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_NULL,
},
[SIOCGIWSTATS - SIOCIWFIRST] = { /* (handled directly by us) */
.header_type = IW_HEADER_TYPE_NULL,
.flags = IW_DESCR_FLAG_DUMP,
},
[SIOCSIWSPY - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_POINT,
.token_size = sizeof(struct sockaddr),
.max_tokens = IW_MAX_SPY,
},
[SIOCGIWSPY - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_POINT,
.token_size = sizeof(struct sockaddr) +
sizeof(struct iw_quality),
.max_tokens = IW_MAX_SPY,
},
[SIOCSIWTHRSPY - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_POINT,
.token_size = sizeof(struct iw_thrspy),
.min_tokens = 1,
.max_tokens = 1,
},
[SIOCGIWTHRSPY - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_POINT,
.token_size = sizeof(struct iw_thrspy),
.min_tokens = 1,
.max_tokens = 1,
},
[SIOCSIWAP - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_ADDR,
},
[SIOCGIWAP - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_ADDR,
.flags = IW_DESCR_FLAG_DUMP,
},
[SIOCSIWMLME - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_POINT,
.token_size = 1,
.min_tokens = sizeof(struct iw_mlme),
.max_tokens = sizeof(struct iw_mlme),
},
[SIOCGIWAPLIST - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_POINT,
.token_size = sizeof(struct sockaddr) +
sizeof(struct iw_quality),
.max_tokens = IW_MAX_AP,
.flags = IW_DESCR_FLAG_NOMAX,
},
[SIOCSIWSCAN - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_POINT,
.token_size = 1,
.min_tokens = 0,
.max_tokens = sizeof(struct iw_scan_req),
},
[SIOCGIWSCAN - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_POINT,
.token_size = 1,
.max_tokens = IW_SCAN_MAX_DATA,
.flags = IW_DESCR_FLAG_NOMAX,
},
[SIOCSIWESSID - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_POINT,
.token_size = 1,
.max_tokens = IW_ESSID_MAX_SIZE + 1,
.flags = IW_DESCR_FLAG_EVENT,
},
[SIOCGIWESSID - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_POINT,
.token_size = 1,
.max_tokens = IW_ESSID_MAX_SIZE + 1,
.flags = IW_DESCR_FLAG_DUMP,
},
[SIOCSIWNICKN - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_POINT,
.token_size = 1,
.max_tokens = IW_ESSID_MAX_SIZE + 1,
},
[SIOCGIWNICKN - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_POINT,
.token_size = 1,
.max_tokens = IW_ESSID_MAX_SIZE + 1,
},
[SIOCSIWRATE - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_PARAM,
},
[SIOCGIWRATE - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_PARAM,
},
[SIOCSIWRTS - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_PARAM,
},
[SIOCGIWRTS - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_PARAM,
},
[SIOCSIWFRAG - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_PARAM,
},
[SIOCGIWFRAG - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_PARAM,
},
[SIOCSIWTXPOW - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_PARAM,
},
[SIOCGIWTXPOW - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_PARAM,
},
[SIOCSIWRETRY - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_PARAM,
},
[SIOCGIWRETRY - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_PARAM,
},
[SIOCSIWENCODE - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_POINT,
.token_size = 1,
.max_tokens = IW_ENCODING_TOKEN_MAX,
.flags = IW_DESCR_FLAG_EVENT | IW_DESCR_FLAG_RESTRICT,
},
[SIOCGIWENCODE - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_POINT,
.token_size = 1,
.max_tokens = IW_ENCODING_TOKEN_MAX,
.flags = IW_DESCR_FLAG_DUMP | IW_DESCR_FLAG_RESTRICT,
},
[SIOCSIWPOWER - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_PARAM,
},
[SIOCGIWPOWER - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_PARAM,
},
[SIOCSIWMODUL - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_PARAM,
},
[SIOCGIWMODUL - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_PARAM,
},
[SIOCSIWGENIE - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_POINT,
.token_size = 1,
.max_tokens = IW_GENERIC_IE_MAX,
},
[SIOCGIWGENIE - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_POINT,
.token_size = 1,
.max_tokens = IW_GENERIC_IE_MAX,
},
[SIOCSIWAUTH - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_PARAM,
},
[SIOCGIWAUTH - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_PARAM,
},
[SIOCSIWENCODEEXT - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_POINT,
.token_size = 1,
.min_tokens = sizeof(struct iw_encode_ext),
.max_tokens = sizeof(struct iw_encode_ext) +
IW_ENCODING_TOKEN_MAX,
},
[SIOCGIWENCODEEXT - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_POINT,
.token_size = 1,
.min_tokens = sizeof(struct iw_encode_ext),
.max_tokens = sizeof(struct iw_encode_ext) +
IW_ENCODING_TOKEN_MAX,
},
[SIOCSIWPMKSA - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_POINT,
.token_size = 1,
.min_tokens = sizeof(struct iw_pmksa),
.max_tokens = sizeof(struct iw_pmksa),
},
};
/*
* Meta-data about all the additional standard Wireless Extension events
* we know about.
*/
static const struct iw_ioctl_description standard_event_descr[] = {
[IWEVTXDROP - IWEVFIRST] = {
.header_type = IW_HEADER_TYPE_ADDR,
},
[IWEVQUAL - IWEVFIRST] = {
.header_type = IW_HEADER_TYPE_QUAL,
},
[IWEVCUSTOM - IWEVFIRST] = {
.header_type = IW_HEADER_TYPE_POINT,
.token_size = 1,
.max_tokens = IW_CUSTOM_MAX,
},
[IWEVREGISTERED - IWEVFIRST] = {
.header_type = IW_HEADER_TYPE_ADDR,
},
[IWEVEXPIRED - IWEVFIRST] = {
.header_type = IW_HEADER_TYPE_ADDR,
},
[IWEVGENIE - IWEVFIRST] = {
.header_type = IW_HEADER_TYPE_POINT,
.token_size = 1,
.max_tokens = IW_GENERIC_IE_MAX,
},
[IWEVMICHAELMICFAILURE - IWEVFIRST] = {
.header_type = IW_HEADER_TYPE_POINT,
.token_size = 1,
.max_tokens = sizeof(struct iw_michaelmicfailure),
},
[IWEVASSOCREQIE - IWEVFIRST] = {
.header_type = IW_HEADER_TYPE_POINT,
.token_size = 1,
.max_tokens = IW_GENERIC_IE_MAX,
},
[IWEVASSOCRESPIE - IWEVFIRST] = {
.header_type = IW_HEADER_TYPE_POINT,
.token_size = 1,
.max_tokens = IW_GENERIC_IE_MAX,
},
[IWEVPMKIDCAND - IWEVFIRST] = {
.header_type = IW_HEADER_TYPE_POINT,
.token_size = 1,
.max_tokens = sizeof(struct iw_pmkid_cand),
},
};
/* Size (in bytes) of various events */
static const int event_type_size[] = {
IW_EV_LCP_PK_LEN, /* IW_HEADER_TYPE_NULL */
0,
IW_EV_CHAR_PK_LEN, /* IW_HEADER_TYPE_CHAR */
0,
IW_EV_UINT_PK_LEN, /* IW_HEADER_TYPE_UINT */
IW_EV_FREQ_PK_LEN, /* IW_HEADER_TYPE_FREQ */
IW_EV_ADDR_PK_LEN, /* IW_HEADER_TYPE_ADDR */
0,
IW_EV_POINT_PK_LEN, /* Without variable payload */
IW_EV_PARAM_PK_LEN, /* IW_HEADER_TYPE_PARAM */
IW_EV_QUAL_PK_LEN, /* IW_HEADER_TYPE_QUAL */
};
static const unsigned int standard_ioctl_num =
(sizeof(standard_ioctl_descr) / sizeof(struct iw_ioctl_description));
static const unsigned int standard_event_num =
(sizeof(standard_event_descr) / sizeof(struct iw_ioctl_description));
#define IW_IE_CYPHER_NUM 8
#define IW_IE_KEY_MGMT_NUM 3
#endif

View File

@@ -0,0 +1,76 @@
/*
* iwinfo - Wireless Information Library - Broadcom wl.o Headers
*
* Copyright (C) 2009-2010 Jo-Philipp Wich <xm@subsignal.org>
*
* The iwinfo library is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* The iwinfo library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with the iwinfo library. If not, see http://www.gnu.org/licenses/.
*/
#ifndef __IWINFO_WL_H_
#define __IWINFO_WL_H_
#include <fcntl.h>
#include "iwinfo.h"
#include "iwinfo/utils.h"
#include "iwinfo/api/broadcom.h"
int wl_probe(const char *ifname);
int wl_get_mode(const char *ifname, char *buf);
int wl_get_ssid(const char *ifname, char *buf);
int wl_get_bssid(const char *ifname, char *buf);
int wl_get_country(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_txpower(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);
int wl_get_quality(const char *ifname, int *buf);
int wl_get_quality_max(const char *ifname, int *buf);
int wl_get_enctype(const char *ifname, char *buf);
int wl_get_encryption(const char *ifname, char *buf);
int wl_get_assoclist(const char *ifname, char *buf, int *len);
int wl_get_txpwrlist(const char *ifname, char *buf, int *len);
int wl_get_scanlist(const char *ifname, char *buf, int *len);
int wl_get_freqlist(const char *ifname, char *buf, int *len);
int wl_get_countrylist(const char *ifname, char *buf, int *len);
int wl_get_hwmodelist(const char *ifname, int *buf);
int wl_get_mbssid_support(const char *ifname, int *buf);
void wl_close(void);
static const struct iwinfo_ops wl_ops = {
.channel = wl_get_channel,
.frequency = wl_get_frequency,
.txpower = wl_get_txpower,
.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,
.encryption = wl_get_encryption,
.assoclist = wl_get_assoclist,
.txpwrlist = wl_get_txpwrlist,
.scanlist = wl_get_scanlist,
.freqlist = wl_get_freqlist,
.countrylist = wl_get_countrylist,
.close = wl_close
};
#endif