From: Felix Fietkau Date: Wed, 21 May 2014 12:33:15 +0000 (+0000) Subject: iwinfo: move wext_ops to iwinfo_wext.c, make functions static X-Git-Tag: reboot~7231 X-Git-Url: http://git.openwrt.org/?p=openwrt%2Fopenwrt.git;a=commitdiff_plain;h=6e27ecbac756c6e934ea3d59437d2d6c631ac2e0;ds=sidebyside iwinfo: move wext_ops to iwinfo_wext.c, make functions static Signed-off-by: Felix Fietkau SVN-Revision: 40810 --- diff --git a/package/network/utils/iwinfo/src/include/iwinfo.h b/package/network/utils/iwinfo/src/include/iwinfo.h index 1302d159b9..072688c7bc 100644 --- a/package/network/utils/iwinfo/src/include/iwinfo.h +++ b/package/network/utils/iwinfo/src/include/iwinfo.h @@ -183,7 +183,7 @@ const char * iwinfo_type(const char *ifname); const struct iwinfo_ops * iwinfo_backend(const char *ifname); void iwinfo_finish(void); -#include "iwinfo/wext.h" +extern const struct iwinfo_ops wext_ops; #ifdef USE_WL #include "iwinfo/wl.h" diff --git a/package/network/utils/iwinfo/src/include/iwinfo/lua.h b/package/network/utils/iwinfo/src/include/iwinfo/lua.h index d976c0cf46..ad79897260 100644 --- a/package/network/utils/iwinfo/src/include/iwinfo/lua.h +++ b/package/network/utils/iwinfo/src/include/iwinfo/lua.h @@ -24,7 +24,6 @@ #include #include "iwinfo.h" -#include "iwinfo/wext_scan.h" #define IWINFO_META "iwinfo" @@ -58,6 +57,18 @@ return 1; \ } +#define LUA_WRAP_INT_OP(type,op) \ + static int iwinfo_L_##type##_##op(lua_State *L) \ + { \ + const char *ifname = luaL_checkstring(L, 1); \ + int rv; \ + if( !type##_ops.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) \ { \ @@ -71,10 +82,29 @@ return 1; \ } +#define LUA_WRAP_STRING_OP(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##_ops.op(ifname, rv) ) \ + lua_pushstring(L, rv); \ + else \ + lua_pushnil(L); \ + return 1; \ + } + #define LUA_WRAP_STRUCT(type,op) \ static int iwinfo_L_##type##_##op(lua_State *L) \ { \ return iwinfo_L_##op(L, type##_get_##op); \ } +#define LUA_WRAP_STRUCT_OP(type,op) \ + static int iwinfo_L_##type##_##op(lua_State *L) \ + { \ + return iwinfo_L_##op(L, type##_ops.op); \ + } + #endif diff --git a/package/network/utils/iwinfo/src/include/iwinfo/wext.h b/package/network/utils/iwinfo/src/include/iwinfo/wext.h deleted file mode 100644 index 22016c69ac..0000000000 --- a/package/network/utils/iwinfo/src/include/iwinfo/wext.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * iwinfo - Wireless Information Library - Linux Wireless Extension Headers - * - * Copyright (C) 2009-2010 Jo-Philipp Wich - * - * 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 - -#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, int *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_frequency_offset(const char *ifname, int *buf); -int wext_get_txpower(const char *ifname, int *buf); -int wext_get_txpower_offset(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_phyname(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); -int wext_get_hardware_id(const char *ifname, char *buf); -int wext_get_hardware_name(const char *ifname, char *buf); -void wext_close(void); - -static const struct iwinfo_ops wext_ops = { - .name = "wext", - .probe = wext_probe, - .channel = wext_get_channel, - .frequency = wext_get_frequency, - .frequency_offset = wext_get_frequency_offset, - .txpower = wext_get_txpower, - .txpower_offset = wext_get_txpower_offset, - .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, - .hardware_id = wext_get_hardware_id, - .hardware_name = wext_get_hardware_name, - .encryption = wext_get_encryption, - .phyname = wext_get_phyname, - .assoclist = wext_get_assoclist, - .txpwrlist = wext_get_txpwrlist, - .scanlist = wext_get_scanlist, - .freqlist = wext_get_freqlist, - .countrylist = wext_get_countrylist, - .close = wext_close -}; - -#endif diff --git a/package/network/utils/iwinfo/src/include/iwinfo/wext_scan.h b/package/network/utils/iwinfo/src/include/iwinfo/wext_scan.h deleted file mode 100644 index 085c65310f..0000000000 --- a/package/network/utils/iwinfo/src/include/iwinfo/wext_scan.h +++ /dev/null @@ -1,380 +0,0 @@ -/* - * iwinfo - Wireless Information Library - Linux Wireless Extension Headers - * - * Copyright (C) 2009-2010 Jo-Philipp Wich - * - * 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 - -#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 diff --git a/package/network/utils/iwinfo/src/iwinfo_lua.c b/package/network/utils/iwinfo/src/iwinfo_lua.c index 3f1f2061ca..541156b400 100644 --- a/package/network/utils/iwinfo/src/iwinfo_lua.c +++ b/package/network/utils/iwinfo/src/iwinfo_lua.c @@ -697,31 +697,31 @@ LUA_WRAP_STRUCT(nl80211,hardware_id) #endif /* Wext */ -LUA_WRAP_INT(wext,channel) -LUA_WRAP_INT(wext,frequency) -LUA_WRAP_INT(wext,frequency_offset) -LUA_WRAP_INT(wext,txpower) -LUA_WRAP_INT(wext,txpower_offset) -LUA_WRAP_INT(wext,bitrate) -LUA_WRAP_INT(wext,signal) -LUA_WRAP_INT(wext,noise) -LUA_WRAP_INT(wext,quality) -LUA_WRAP_INT(wext,quality_max) -LUA_WRAP_STRING(wext,ssid) -LUA_WRAP_STRING(wext,bssid) -LUA_WRAP_STRING(wext,country) -LUA_WRAP_STRING(wext,hardware_name) -LUA_WRAP_STRING(wext,phyname) -LUA_WRAP_STRUCT(wext,mode) -LUA_WRAP_STRUCT(wext,assoclist) -LUA_WRAP_STRUCT(wext,txpwrlist) -LUA_WRAP_STRUCT(wext,scanlist) -LUA_WRAP_STRUCT(wext,freqlist) -LUA_WRAP_STRUCT(wext,countrylist) -LUA_WRAP_STRUCT(wext,hwmodelist) -LUA_WRAP_STRUCT(wext,encryption) -LUA_WRAP_STRUCT(wext,mbssid_support) -LUA_WRAP_STRUCT(wext,hardware_id) +LUA_WRAP_INT_OP(wext,channel) +LUA_WRAP_INT_OP(wext,frequency) +LUA_WRAP_INT_OP(wext,frequency_offset) +LUA_WRAP_INT_OP(wext,txpower) +LUA_WRAP_INT_OP(wext,txpower_offset) +LUA_WRAP_INT_OP(wext,bitrate) +LUA_WRAP_INT_OP(wext,signal) +LUA_WRAP_INT_OP(wext,noise) +LUA_WRAP_INT_OP(wext,quality) +LUA_WRAP_INT_OP(wext,quality_max) +LUA_WRAP_STRING_OP(wext,ssid) +LUA_WRAP_STRING_OP(wext,bssid) +LUA_WRAP_STRING_OP(wext,country) +LUA_WRAP_STRING_OP(wext,hardware_name) +LUA_WRAP_STRING_OP(wext,phyname) +LUA_WRAP_STRUCT_OP(wext,mode) +LUA_WRAP_STRUCT_OP(wext,assoclist) +LUA_WRAP_STRUCT_OP(wext,txpwrlist) +LUA_WRAP_STRUCT_OP(wext,scanlist) +LUA_WRAP_STRUCT_OP(wext,freqlist) +LUA_WRAP_STRUCT_OP(wext,countrylist) +LUA_WRAP_STRUCT_OP(wext,hwmodelist) +LUA_WRAP_STRUCT_OP(wext,encryption) +LUA_WRAP_STRUCT_OP(wext,mbssid_support) +LUA_WRAP_STRUCT_OP(wext,hardware_id) #ifdef USE_WL /* Broadcom table */ diff --git a/package/network/utils/iwinfo/src/iwinfo_madwifi.c b/package/network/utils/iwinfo/src/iwinfo_madwifi.c index 293c28e7d1..be41c50951 100644 --- a/package/network/utils/iwinfo/src/iwinfo_madwifi.c +++ b/package/network/utils/iwinfo/src/iwinfo_madwifi.c @@ -21,7 +21,7 @@ */ #include "iwinfo/madwifi.h" -#include "iwinfo/wext.h" +#include "iwinfo_wext.h" /* @@ -349,17 +349,17 @@ void madwifi_close(void) int madwifi_get_mode(const char *ifname, int *buf) { - return wext_get_mode(ifname, buf); + return wext_ops.mode(ifname, buf); } int madwifi_get_ssid(const char *ifname, char *buf) { - return wext_get_ssid(ifname, buf); + return wext_ops.ssid(ifname, buf); } int madwifi_get_bssid(const char *ifname, char *buf) { - return wext_get_bssid(ifname, buf); + return wext_ops.bssid(ifname, buf); } int madwifi_get_channel(const char *ifname, int *buf) @@ -409,7 +409,7 @@ int madwifi_get_frequency(const char *ifname, int *buf) int madwifi_get_txpower(const char *ifname, int *buf) { - return wext_get_txpower(ifname, buf); + return wext_ops.txpower(ifname, buf); } int madwifi_get_bitrate(const char *ifname, int *buf) @@ -452,7 +452,7 @@ int madwifi_get_bitrate(const char *ifname, int *buf) } /* Return whatever wext tells us ... */ - return wext_get_bitrate(ifname, buf); + return wext_ops.bitrate(ifname, buf); } return -1; @@ -498,7 +498,7 @@ int madwifi_get_signal(const char *ifname, int *buf) } /* Return whatever wext tells us ... */ - return wext_get_signal(ifname, buf); + return wext_ops.signal(ifname, buf); } return -1; @@ -506,7 +506,7 @@ int madwifi_get_signal(const char *ifname, int *buf) int madwifi_get_noise(const char *ifname, int *buf) { - return wext_get_noise(ifname, buf); + return wext_ops.noise(ifname, buf); } int madwifi_get_quality(const char *ifname, int *buf) @@ -549,7 +549,7 @@ int madwifi_get_quality(const char *ifname, int *buf) } /* Return whatever wext tells us ... */ - return wext_get_quality(ifname, buf); + return wext_ops.quality(ifname, buf); } return -1; @@ -557,7 +557,7 @@ int madwifi_get_quality(const char *ifname, int *buf) int madwifi_get_quality_max(const char *ifname, int *buf) { - return wext_get_quality_max(ifname, buf); + return wext_ops.quality_max(ifname, buf); } int madwifi_get_encryption(const char *ifname, char *buf) @@ -807,7 +807,7 @@ int madwifi_get_txpwrlist(const char *ifname, char *buf, int *len) { if( (res = madwifi_ifadd(ifname)) != NULL ) { - rc = wext_get_txpwrlist(res, buf, len); + rc = wext_ops.txpwrlist(res, buf, len); madwifi_ifdel(res); } } @@ -815,7 +815,7 @@ int madwifi_get_txpwrlist(const char *ifname, char *buf, int *len) /* Its an athX ... */ else if( !!madwifi_isvap(ifname, NULL) ) { - rc = wext_get_txpwrlist(ifname, buf, len); + rc = wext_ops.txpwrlist(ifname, buf, len); } return rc; @@ -841,7 +841,7 @@ int madwifi_get_scanlist(const char *ifname, char *buf, int *len) { if( iwinfo_ifup(e->d_name) ) { - ret = wext_get_scanlist(e->d_name, buf, len); + ret = wext_ops.scanlist(e->d_name, buf, len); break; } } @@ -857,13 +857,13 @@ int madwifi_get_scanlist(const char *ifname, char *buf, int *len) { if( iwinfo_ifup(res) ) { - wext_get_scanlist(res, buf, len); + wext_ops.scanlist(res, buf, len); sleep(1); - wext_get_scanlist(res, buf, len); + wext_ops.scanlist(res, buf, len); sleep(1); - ret = wext_get_scanlist(res, buf, len); + ret = wext_ops.scanlist(res, buf, len); } iwinfo_ifdown(res); @@ -875,7 +875,7 @@ int madwifi_get_scanlist(const char *ifname, char *buf, int *len) /* Got athX device? */ else if( !!madwifi_isvap(ifname, NULL) ) { - ret = wext_get_scanlist(ifname, buf, len); + ret = wext_ops.scanlist(ifname, buf, len); } return ret; @@ -1050,7 +1050,7 @@ int madwifi_get_hardware_id(const char *ifname, char *buf) struct iwinfo_hardware_entry *e; const char *phy = madwifi_phyname(ifname); - if (wext_get_hardware_id(phy, buf)) + if (wext_ops.hardware_id(phy, buf)) return iwinfo_hardware_id_from_mtd((struct iwinfo_hardware_id *)buf); return 0; diff --git a/package/network/utils/iwinfo/src/iwinfo_nl80211.c b/package/network/utils/iwinfo/src/iwinfo_nl80211.c index 854be6bbf8..17d95515ee 100644 --- a/package/network/utils/iwinfo/src/iwinfo_nl80211.c +++ b/package/network/utils/iwinfo/src/iwinfo_nl80211.c @@ -23,7 +23,6 @@ */ #include "iwinfo/nl80211.h" -#include "iwinfo/wext.h" #define min(x, y) ((x) < (y)) ? (x) : (y) @@ -1032,7 +1031,7 @@ int nl80211_get_txpower(const char *ifname, int *buf) return 0; #endif - return wext_get_txpower(ifname, buf); + return wext_ops.txpower(ifname, buf); } @@ -2295,19 +2294,19 @@ int nl80211_get_hardware_id(const char *ifname, char *buf) /* Reuse existing interface */ if ((res = nl80211_phy2ifname(ifname)) != NULL) { - rv = wext_get_hardware_id(res, buf); + rv = wext_ops.hardware_id(res, buf); } /* Need to spawn a temporary iface for finding IDs */ else if ((res = nl80211_ifadd(ifname)) != NULL) { - rv = wext_get_hardware_id(res, buf); + rv = wext_ops.hardware_id(res, buf); nl80211_ifdel(res); } } else { - rv = wext_get_hardware_id(ifname, buf); + rv = wext_ops.hardware_id(ifname, buf); } /* Failed to obtain hardware IDs, search board config */ diff --git a/package/network/utils/iwinfo/src/iwinfo_wext.c b/package/network/utils/iwinfo/src/iwinfo_wext.c index 890a36d2f0..a6cc516823 100644 --- a/package/network/utils/iwinfo/src/iwinfo_wext.c +++ b/package/network/utils/iwinfo/src/iwinfo_wext.c @@ -20,7 +20,7 @@ */ #include "iwinfo.h" -#include "iwinfo/wext.h" +#include "iwinfo_wext.h" static double wext_freq2float(const struct iw_freq *in) { @@ -55,7 +55,7 @@ static inline int wext_ioctl(const char *ifname, int cmd, struct iwreq *wrq) } -int wext_probe(const char *ifname) +static int wext_probe(const char *ifname) { struct iwreq wrq; @@ -65,12 +65,12 @@ int wext_probe(const char *ifname) return 0; } -void wext_close(void) +static void wext_close(void) { /* Nop */ } -int wext_get_mode(const char *ifname, int *buf) +static int wext_get_mode(const char *ifname, int *buf) { struct iwreq wrq; @@ -105,7 +105,7 @@ int wext_get_mode(const char *ifname, int *buf) return -1; } -int wext_get_ssid(const char *ifname, char *buf) +static int wext_get_ssid(const char *ifname, char *buf) { struct iwreq wrq; @@ -119,7 +119,7 @@ int wext_get_ssid(const char *ifname, char *buf) return -1; } -int wext_get_bssid(const char *ifname, char *buf) +static int wext_get_bssid(const char *ifname, char *buf) { struct iwreq wrq; @@ -136,7 +136,7 @@ int wext_get_bssid(const char *ifname, char *buf) return -1; } -int wext_get_bitrate(const char *ifname, int *buf) +static int wext_get_bitrate(const char *ifname, int *buf) { struct iwreq wrq; @@ -149,7 +149,7 @@ int wext_get_bitrate(const char *ifname, int *buf) return -1; } -int wext_get_channel(const char *ifname, int *buf) +static int wext_get_channel(const char *ifname, int *buf) { struct iwreq wrq; struct iw_range range; @@ -187,7 +187,7 @@ int wext_get_channel(const char *ifname, int *buf) return -1; } -int wext_get_frequency(const char *ifname, int *buf) +static int wext_get_frequency(const char *ifname, int *buf) { struct iwreq wrq; struct iw_range range; @@ -225,7 +225,7 @@ int wext_get_frequency(const char *ifname, int *buf) return -1; } -int wext_get_txpower(const char *ifname, int *buf) +static int wext_get_txpower(const char *ifname, int *buf) { struct iwreq wrq; @@ -244,7 +244,7 @@ int wext_get_txpower(const char *ifname, int *buf) return -1; } -int wext_get_signal(const char *ifname, int *buf) +static int wext_get_signal(const char *ifname, int *buf) { struct iwreq wrq; struct iw_statistics stats; @@ -264,7 +264,7 @@ int wext_get_signal(const char *ifname, int *buf) return -1; } -int wext_get_noise(const char *ifname, int *buf) +static int wext_get_noise(const char *ifname, int *buf) { struct iwreq wrq; struct iw_statistics stats; @@ -284,7 +284,7 @@ int wext_get_noise(const char *ifname, int *buf) return -1; } -int wext_get_quality(const char *ifname, int *buf) +static int wext_get_quality(const char *ifname, int *buf) { struct iwreq wrq; struct iw_statistics stats; @@ -302,7 +302,7 @@ int wext_get_quality(const char *ifname, int *buf) return -1; } -int wext_get_quality_max(const char *ifname, int *buf) +static int wext_get_quality_max(const char *ifname, int *buf) { struct iwreq wrq; struct iw_range range; @@ -320,13 +320,13 @@ int wext_get_quality_max(const char *ifname, int *buf) return -1; } -int wext_get_assoclist(const char *ifname, char *buf, int *len) +static int wext_get_assoclist(const char *ifname, char *buf, int *len) { /* Stub */ return -1; } -int wext_get_txpwrlist(const char *ifname, char *buf, int *len) +static int wext_get_txpwrlist(const char *ifname, char *buf, int *len) { struct iwreq wrq; struct iw_range range; @@ -367,7 +367,7 @@ int wext_get_txpwrlist(const char *ifname, char *buf, int *len) return -1; } -int wext_get_freqlist(const char *ifname, char *buf, int *len) +static int wext_get_freqlist(const char *ifname, char *buf, int *len) { struct iwreq wrq; struct iw_range range; @@ -399,19 +399,19 @@ int wext_get_freqlist(const char *ifname, char *buf, int *len) return -1; } -int wext_get_country(const char *ifname, char *buf) +static int wext_get_country(const char *ifname, char *buf) { sprintf(buf, "00"); return 0; } -int wext_get_countrylist(const char *ifname, char *buf, int *len) +static int wext_get_countrylist(const char *ifname, char *buf, int *len) { /* Stub */ return -1; } -int wext_get_hwmodelist(const char *ifname, int *buf) +static int wext_get_hwmodelist(const char *ifname, int *buf) { char chans[IWINFO_BUFSIZE] = { 0 }; struct iwinfo_freqlist_entry *e = NULL; @@ -440,20 +440,20 @@ int wext_get_hwmodelist(const char *ifname, int *buf) return -1; } -int wext_get_encryption(const char *ifname, char *buf) +static int wext_get_encryption(const char *ifname, char *buf) { /* No reliable crypto info in wext */ return -1; } -int wext_get_phyname(const char *ifname, char *buf) +static int wext_get_phyname(const char *ifname, char *buf) { /* No suitable api in wext */ strcpy(buf, ifname); return 0; } -int wext_get_mbssid_support(const char *ifname, int *buf) +static int wext_get_mbssid_support(const char *ifname, int *buf) { /* No multi bssid support atm */ return -1; @@ -480,7 +480,7 @@ static char * wext_sysfs_ifname_file(const char *ifname, const char *path) return rv; } -int wext_get_hardware_id(const char *ifname, char *buf) +static int wext_get_hardware_id(const char *ifname, char *buf) { char *data; struct iwinfo_hardware_id *id = (struct iwinfo_hardware_id *)buf; @@ -506,22 +506,53 @@ int wext_get_hardware_id(const char *ifname, char *buf) return (id->vendor_id > 0 && id->device_id > 0) ? 0 : -1; } -int wext_get_hardware_name(const char *ifname, char *buf) +static int wext_get_hardware_name(const char *ifname, char *buf) { sprintf(buf, "Generic WEXT"); return 0; } -int wext_get_txpower_offset(const char *ifname, int *buf) +static int wext_get_txpower_offset(const char *ifname, int *buf) { /* Stub */ *buf = 0; return -1; } -int wext_get_frequency_offset(const char *ifname, int *buf) +static int wext_get_frequency_offset(const char *ifname, int *buf) { /* Stub */ *buf = 0; return -1; } + +const struct iwinfo_ops wext_ops = { + .name = "wext", + .probe = wext_probe, + .channel = wext_get_channel, + .frequency = wext_get_frequency, + .frequency_offset = wext_get_frequency_offset, + .txpower = wext_get_txpower, + .txpower_offset = wext_get_txpower_offset, + .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, + .hardware_id = wext_get_hardware_id, + .hardware_name = wext_get_hardware_name, + .encryption = wext_get_encryption, + .phyname = wext_get_phyname, + .assoclist = wext_get_assoclist, + .txpwrlist = wext_get_txpwrlist, + .scanlist = wext_get_scanlist, + .freqlist = wext_get_freqlist, + .countrylist = wext_get_countrylist, + .close = wext_close +}; diff --git a/package/network/utils/iwinfo/src/iwinfo_wext.h b/package/network/utils/iwinfo/src/iwinfo_wext.h new file mode 100644 index 0000000000..48f58d888c --- /dev/null +++ b/package/network/utils/iwinfo/src/iwinfo_wext.h @@ -0,0 +1,382 @@ +/* + * iwinfo - Wireless Information Library - Linux Wireless Extension Headers + * + * Copyright (C) 2009-2010 Jo-Philipp Wich + * + * 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 + +#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 + +int wext_get_scanlist(const char *ifname, char *buf, int *len); + +#endif diff --git a/package/network/utils/iwinfo/src/iwinfo_wext_scan.c b/package/network/utils/iwinfo/src/iwinfo_wext_scan.c index ecd40d71e2..a06672147f 100644 --- a/package/network/utils/iwinfo/src/iwinfo_wext_scan.c +++ b/package/network/utils/iwinfo/src/iwinfo_wext_scan.c @@ -20,7 +20,7 @@ */ #include "iwinfo.h" -#include "iwinfo/wext_scan.h" +#include "iwinfo_wext.h" static int wext_ioctl(const char *ifname, int cmd, struct iwreq *wrq) diff --git a/package/network/utils/iwinfo/src/iwinfo_wl.c b/package/network/utils/iwinfo/src/iwinfo_wl.c index 1adceb071c..d5a2793aa5 100644 --- a/package/network/utils/iwinfo/src/iwinfo_wl.c +++ b/package/network/utils/iwinfo/src/iwinfo_wl.c @@ -19,7 +19,6 @@ */ #include "iwinfo/wl.h" -#include "iwinfo/wext.h" static int wl_ioctl(const char *name, int cmd, void *buf, int len) { @@ -143,13 +142,13 @@ int wl_get_channel(const char *ifname, int *buf) 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) { /* 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) @@ -235,12 +234,12 @@ int wl_get_noise(const char *ifname, int *buf) 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) { - return wext_get_quality_max(ifname, buf); + return wext_ops.quality_max(ifname, buf); } int wl_get_encryption(const char *ifname, char *buf) @@ -521,12 +520,12 @@ int wl_get_txpwrlist(const char *ifname, char *buf, int *len) 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) { - return wext_get_freqlist(ifname, buf, len); + return wext_ops.freqlist(ifname, buf, len); } int wl_get_country(const char *ifname, char *buf)