From 89d48861e000a60cc6bd411c3a94ee6fdc3896d2 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Fri, 2 Dec 2011 20:48:08 +0000 Subject: [PATCH] libiwinfo: major changes - move own headers to include/iwinfo/ and shipped ones to include/iwinfo/api/ - split into libiwinfo and libiwinfo-lua which contains only the binding - provide a public api for libiwinfo - install development headers and shared objects --- contrib/package/iwinfo/Makefile | 39 +- contrib/package/iwinfo/src/Makefile | 22 +- .../package/iwinfo/src/{ => include}/iwinfo.h | 66 ++- .../src/include/{ => iwinfo/api}/broadcom.h | 0 .../src/include/{ => iwinfo/api}/madwifi.h | 0 .../src/include/{ => iwinfo/api}/nl80211.h | 0 .../src/include/{ => iwinfo/api}/wext.h | 0 .../iwinfo/lualib.h} | 25 +- .../iwinfo/madwifi.h} | 28 +- .../iwinfo/nl80211.h} | 28 +- .../iwinfo/utils.h} | 0 .../{iwinfo_wext.h => include/iwinfo/wext.h} | 28 +- .../iwinfo/wext_scan.h} | 4 +- .../src/{iwinfo_wl.h => include/iwinfo/wl.h} | 28 +- contrib/package/iwinfo/src/iwinfo_lib.c | 376 +++++++++++++++++ contrib/package/iwinfo/src/iwinfo_lualib.c | 388 +++--------------- contrib/package/iwinfo/src/iwinfo_madwifi.c | 4 +- contrib/package/iwinfo/src/iwinfo_nl80211.c | 9 +- contrib/package/iwinfo/src/iwinfo_utils.c | 2 +- contrib/package/iwinfo/src/iwinfo_wext.c | 2 +- contrib/package/iwinfo/src/iwinfo_wext_scan.c | 2 +- contrib/package/iwinfo/src/iwinfo_wl.c | 4 +- 22 files changed, 644 insertions(+), 411 deletions(-) rename contrib/package/iwinfo/src/{ => include}/iwinfo.h (57%) rename contrib/package/iwinfo/src/include/{ => iwinfo/api}/broadcom.h (100%) rename contrib/package/iwinfo/src/include/{ => iwinfo/api}/madwifi.h (100%) rename contrib/package/iwinfo/src/include/{ => iwinfo/api}/nl80211.h (100%) rename contrib/package/iwinfo/src/include/{ => iwinfo/api}/wext.h (100%) rename contrib/package/iwinfo/src/{iwinfo_lualib.h => include/iwinfo/lualib.h} (88%) rename contrib/package/iwinfo/src/{iwinfo_madwifi.h => include/iwinfo/madwifi.h} (68%) rename contrib/package/iwinfo/src/{iwinfo_nl80211.h => include/iwinfo/nl80211.h} (73%) rename contrib/package/iwinfo/src/{iwinfo_utils.h => include/iwinfo/utils.h} (100%) rename contrib/package/iwinfo/src/{iwinfo_wext.h => include/iwinfo/wext.h} (69%) rename contrib/package/iwinfo/src/{iwinfo_wext_scan.h => include/iwinfo/wext_scan.h} (99%) rename contrib/package/iwinfo/src/{iwinfo_wl.h => include/iwinfo/wl.h} (70%) create mode 100644 contrib/package/iwinfo/src/iwinfo_lib.c diff --git a/contrib/package/iwinfo/Makefile b/contrib/package/iwinfo/Makefile index 011f122c52..a8990294da 100644 --- a/contrib/package/iwinfo/Makefile +++ b/contrib/package/iwinfo/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=libiwinfo -PKG_RELEASE:=16 +PKG_RELEASE:=17 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) @@ -15,12 +15,10 @@ include $(INCLUDE_DIR)/package.mk define Package/libiwinfo - SECTION:=luci - CATEGORY:=LuCI - SUBMENU:=8. Libraries + SECTION:=libs + CATEGORY:=Libraries TITLE:=Generalized Wireless Information Library (iwinfo) - DEPENDS:=+PACKAGE_kmod-mac80211:libnl-tiny +liblua +lua - DEFAULT:=PACKAGE_luci-lib-sys + DEPENDS:=+PACKAGE_kmod-mac80211:libnl-tiny endef define Package/libiwinfo/description @@ -28,6 +26,19 @@ define Package/libiwinfo/description madwifi, nl80211 and wext driver interfaces. endef +define Package/libiwinfo-lua + SUBMENU:=Lua + SECTION:=lang + CATEGORY:=Languages + TITLE:=libiwinfo Lua binding + DEPENDS:=+libiwinfo +liblua +lua +endef + +define Package/libiwinfo-lua/description + This is the Lua binding for the iwinfo library. It provides access to all enabled + backends. +endef + define Build/Prepare mkdir -p $(PKG_BUILD_DIR) $(CP) ./src/* $(PKG_BUILD_DIR)/ @@ -54,7 +65,22 @@ MAKE_FLAGS += \ LDFLAGS="$(TARGET_LDFLAGS)" \ BACKENDS="$(IWINFO_BACKENDS)" +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include/iwinfo + $(CP) $(PKG_BUILD_DIR)/include/iwinfo.h $(1)/usr/include/ + $(CP) $(PKG_BUILD_DIR)/include/iwinfo/* $(1)/usr/include/iwinfo/ + $(INSTALL_DIR) $(1)/usr/lib + $(INSTALL_BIN) $(PKG_BUILD_DIR)/libiwinfo.so $(1)/usr/lib/libiwinfo.so + $(INSTALL_DIR) $(1)/usr/lib/lua + $(INSTALL_BIN) $(PKG_BUILD_DIR)/iwinfo.so $(1)/usr/lib/lua/iwinfo.so +endef + define Package/libiwinfo/install + $(INSTALL_DIR) $(1)/usr/lib + $(INSTALL_BIN) $(PKG_BUILD_DIR)/libiwinfo.so $(1)/usr/lib/libiwinfo.so +endef + +define Package/libiwinfo-lua/install $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) $(PKG_BUILD_DIR)/iwinfo.lua $(1)/usr/bin/iwinfo $(INSTALL_DIR) $(1)/usr/lib/lua @@ -62,3 +88,4 @@ define Package/libiwinfo/install endef $(eval $(call BuildPackage,libiwinfo)) +$(eval $(call BuildPackage,libiwinfo-lua)) diff --git a/contrib/package/iwinfo/src/Makefile b/contrib/package/iwinfo/src/Makefile index a7a7b9a581..07857ca378 100644 --- a/contrib/package/iwinfo/src/Makefile +++ b/contrib/package/iwinfo/src/Makefile @@ -1,8 +1,13 @@ -IWINFO_BACKENDS = $(BACKENDS) -IWINFO_LDFLAGS = $(LDFLAGS) -shared -llua -IWINFO_CFLAGS = $(CFLAGS) -std=gnu99 -fstrict-aliasing -IWINFO_SO = iwinfo.so -IWINFO_OBJ = iwinfo_utils.o iwinfo_wext.o iwinfo_wext_scan.o iwinfo_lualib.o +IWINFO_BACKENDS = $(BACKENDS) +IWINFO_CFLAGS = $(CFLAGS) -std=gnu99 -fstrict-aliasing -Iinclude + +IWINFO_LDFLAGS = $(LDFLAGS) -shared +IWINFO_SO = libiwinfo.so +IWINFO_OBJ = iwinfo_utils.o iwinfo_wext.o iwinfo_wext_scan.o iwinfo_lib.o + +IWINFO_LUA_LDFLAGS = $(LDFLAGS) -shared -L. -liwinfo -llua +IWINFO_LUA_SO = iwinfo.so +IWINFO_LUA_OBJ = iwinfo_lualib.o ifneq ($(filter wl,$(IWINFO_BACKENDS)),) IWINFO_CFLAGS += -DUSE_WL @@ -22,10 +27,11 @@ endif %.o: %.c - $(CC) $(IWINFO_CFLAGS) $(LUA_CFLAGS) $(FPIC) -c -o $@ $< + $(CC) $(IWINFO_CFLAGS) $(FPIC) -c -o $@ $< -compile: clean $(IWINFO_OBJ) +compile: clean $(IWINFO_OBJ) $(IWINFO_LUA_OBJ) $(LD) $(IWINFO_LDFLAGS) -o $(IWINFO_SO) $(IWINFO_OBJ) + $(LD) $(IWINFO_LUA_LDFLAGS) -o $(IWINFO_LUA_SO) $(IWINFO_LUA_OBJ) clean: - rm -f *.o $(IWINFO_SO) + rm -f *.o $(IWINFO_SO) $(IWINFO_LUA_SO) diff --git a/contrib/package/iwinfo/src/iwinfo.h b/contrib/package/iwinfo/src/include/iwinfo.h similarity index 57% rename from contrib/package/iwinfo/src/iwinfo.h rename to contrib/package/iwinfo/src/include/iwinfo.h index aa2f8335a1..824b945365 100644 --- a/contrib/package/iwinfo/src/iwinfo.h +++ b/contrib/package/iwinfo/src/include/iwinfo.h @@ -18,22 +18,9 @@ #include #include -#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 - #define IWINFO_BUFSIZE 24 * 1024 +#define IWINFO_ESSID_MAX_SIZE 32 #define IWINFO_80211_A (1 << 0) #define IWINFO_80211_B (1 << 1) @@ -56,6 +43,10 @@ #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]; @@ -85,7 +76,7 @@ struct iwinfo_crypto_entry { struct iwinfo_scanlist_entry { uint8_t mac[6]; - uint8_t ssid[IW_ESSID_MAX_SIZE+1]; + uint8_t ssid[IWINFO_ESSID_MAX_SIZE+1]; uint8_t mode[8]; uint8_t channel; uint8_t signal; @@ -104,4 +95,49 @@ struct iwinfo_iso3166_label { 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 diff --git a/contrib/package/iwinfo/src/include/broadcom.h b/contrib/package/iwinfo/src/include/iwinfo/api/broadcom.h similarity index 100% rename from contrib/package/iwinfo/src/include/broadcom.h rename to contrib/package/iwinfo/src/include/iwinfo/api/broadcom.h diff --git a/contrib/package/iwinfo/src/include/madwifi.h b/contrib/package/iwinfo/src/include/iwinfo/api/madwifi.h similarity index 100% rename from contrib/package/iwinfo/src/include/madwifi.h rename to contrib/package/iwinfo/src/include/iwinfo/api/madwifi.h diff --git a/contrib/package/iwinfo/src/include/nl80211.h b/contrib/package/iwinfo/src/include/iwinfo/api/nl80211.h similarity index 100% rename from contrib/package/iwinfo/src/include/nl80211.h rename to contrib/package/iwinfo/src/include/iwinfo/api/nl80211.h diff --git a/contrib/package/iwinfo/src/include/wext.h b/contrib/package/iwinfo/src/include/iwinfo/api/wext.h similarity index 100% rename from contrib/package/iwinfo/src/include/wext.h rename to contrib/package/iwinfo/src/include/iwinfo/api/wext.h diff --git a/contrib/package/iwinfo/src/iwinfo_lualib.h b/contrib/package/iwinfo/src/include/iwinfo/lualib.h similarity index 88% rename from contrib/package/iwinfo/src/iwinfo_lualib.h rename to contrib/package/iwinfo/src/include/iwinfo/lualib.h index 43b80cc912..65a3a5cb91 100644 --- a/contrib/package/iwinfo/src/iwinfo_lualib.h +++ b/contrib/package/iwinfo/src/include/iwinfo/lualib.h @@ -24,30 +24,7 @@ #include #include "iwinfo.h" -#include "iwinfo_wext_scan.h" - - -const char *IWINFO_CIPHER_NAMES[] = { - "NONE", - "WEP40", - "TKIP", - "WRAP", - "CCMP", - "WEP104", - "AES-OCB", - "CKIP", -}; - -const char *IWINFO_KMGMT_NAMES[] = { - "NONE", - "802.1X", - "PSK", -}; - -const char *IWINFO_AUTH_NAMES[] = { - "OPEN", - "SHARED", -}; +#include "iwinfo/wext_scan.h" #define IWINFO_META "iwinfo" diff --git a/contrib/package/iwinfo/src/iwinfo_madwifi.h b/contrib/package/iwinfo/src/include/iwinfo/madwifi.h similarity index 68% rename from contrib/package/iwinfo/src/iwinfo_madwifi.h rename to contrib/package/iwinfo/src/include/iwinfo/madwifi.h index 690177f50d..4de48557d4 100644 --- a/contrib/package/iwinfo/src/iwinfo_madwifi.h +++ b/contrib/package/iwinfo/src/include/iwinfo/madwifi.h @@ -22,8 +22,8 @@ #include #include "iwinfo.h" -#include "iwinfo_utils.h" -#include "include/madwifi.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); @@ -48,4 +48,28 @@ 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 diff --git a/contrib/package/iwinfo/src/iwinfo_nl80211.h b/contrib/package/iwinfo/src/include/iwinfo/nl80211.h similarity index 73% rename from contrib/package/iwinfo/src/iwinfo_nl80211.h rename to contrib/package/iwinfo/src/include/iwinfo/nl80211.h index 4231c94359..dce508cf0a 100644 --- a/contrib/package/iwinfo/src/iwinfo_nl80211.h +++ b/contrib/package/iwinfo/src/include/iwinfo/nl80211.h @@ -32,8 +32,8 @@ #include #include "iwinfo.h" -#include "iwinfo_utils.h" -#include "include/nl80211.h" +#include "iwinfo/utils.h" +#include "iwinfo/api/nl80211.h" struct nl80211_state { struct nl_sock *nl_sock; @@ -79,4 +79,28 @@ 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 diff --git a/contrib/package/iwinfo/src/iwinfo_utils.h b/contrib/package/iwinfo/src/include/iwinfo/utils.h similarity index 100% rename from contrib/package/iwinfo/src/iwinfo_utils.h rename to contrib/package/iwinfo/src/include/iwinfo/utils.h diff --git a/contrib/package/iwinfo/src/iwinfo_wext.h b/contrib/package/iwinfo/src/include/iwinfo/wext.h similarity index 69% rename from contrib/package/iwinfo/src/iwinfo_wext.h rename to contrib/package/iwinfo/src/include/iwinfo/wext.h index db213fccc6..69b7a8e3d0 100644 --- a/contrib/package/iwinfo/src/iwinfo_wext.h +++ b/contrib/package/iwinfo/src/include/iwinfo/wext.h @@ -22,8 +22,8 @@ #include #include "iwinfo.h" -#include "iwinfo_utils.h" -#include "include/wext.h" +#include "iwinfo/utils.h" +#include "iwinfo/api/wext.h" int wext_probe(const char *ifname); @@ -49,4 +49,28 @@ 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 diff --git a/contrib/package/iwinfo/src/iwinfo_wext_scan.h b/contrib/package/iwinfo/src/include/iwinfo/wext_scan.h similarity index 99% rename from contrib/package/iwinfo/src/iwinfo_wext_scan.h rename to contrib/package/iwinfo/src/include/iwinfo/wext_scan.h index 5193902fe6..085c65310f 100644 --- a/contrib/package/iwinfo/src/iwinfo_wext_scan.h +++ b/contrib/package/iwinfo/src/include/iwinfo/wext_scan.h @@ -22,8 +22,8 @@ #include #include "iwinfo.h" -#include "iwinfo_utils.h" -#include "include/wext.h" +#include "iwinfo/utils.h" +#include "iwinfo/api/wext.h" typedef struct stream_descr diff --git a/contrib/package/iwinfo/src/iwinfo_wl.h b/contrib/package/iwinfo/src/include/iwinfo/wl.h similarity index 70% rename from contrib/package/iwinfo/src/iwinfo_wl.h rename to contrib/package/iwinfo/src/include/iwinfo/wl.h index 95d4961432..e931f7c6e3 100644 --- a/contrib/package/iwinfo/src/iwinfo_wl.h +++ b/contrib/package/iwinfo/src/include/iwinfo/wl.h @@ -22,8 +22,8 @@ #include #include "iwinfo.h" -#include "iwinfo_utils.h" -#include "include/broadcom.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); @@ -49,4 +49,28 @@ 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 diff --git a/contrib/package/iwinfo/src/iwinfo_lib.c b/contrib/package/iwinfo/src/iwinfo_lib.c new file mode 100644 index 0000000000..a7160417d2 --- /dev/null +++ b/contrib/package/iwinfo/src/iwinfo_lib.c @@ -0,0 +1,376 @@ +/* + * iwinfo - Wireless Information Library - Lua Bindings + * + * Copyright (C) 2009 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/. + */ + +#include "iwinfo.h" + + +/* + * name constants + */ +const char *IWINFO_CIPHER_NAMES[] = { + "NONE", + "WEP40", + "TKIP", + "WRAP", + "CCMP", + "WEP104", + "AES-OCB", + "CKIP", +}; + +const char *IWINFO_KMGMT_NAMES[] = { + "NONE", + "802.1X", + "PSK", +}; + +const char *IWINFO_AUTH_NAMES[] = { + "OPEN", + "SHARED", +}; + + +/* + * ISO3166 country labels + */ + +const struct iwinfo_iso3166_label IWINFO_ISO3166_NAMES[] = { + { 0x3030 /* 00 */, "World" }, + { 0x4144 /* AD */, "Andorra" }, + { 0x4145 /* AE */, "United Arab Emirates" }, + { 0x4146 /* AF */, "Afghanistan" }, + { 0x4147 /* AG */, "Antigua and Barbuda" }, + { 0x4149 /* AI */, "Anguilla" }, + { 0x414C /* AL */, "Albania" }, + { 0x414D /* AM */, "Armenia" }, + { 0x414E /* AN */, "Netherlands Antilles" }, + { 0x414F /* AO */, "Angola" }, + { 0x4151 /* AQ */, "Antarctica" }, + { 0x4152 /* AR */, "Argentina" }, + { 0x4153 /* AS */, "American Samoa" }, + { 0x4154 /* AT */, "Austria" }, + { 0x4155 /* AU */, "Australia" }, + { 0x4157 /* AW */, "Aruba" }, + { 0x4158 /* AX */, "Aland Islands" }, + { 0x415A /* AZ */, "Azerbaijan" }, + { 0x4241 /* BA */, "Bosnia and Herzegovina" }, + { 0x4242 /* BB */, "Barbados" }, + { 0x4244 /* BD */, "Bangladesh" }, + { 0x4245 /* BE */, "Belgium" }, + { 0x4246 /* BF */, "Burkina Faso" }, + { 0x4247 /* BG */, "Bulgaria" }, + { 0x4248 /* BH */, "Bahrain" }, + { 0x4249 /* BI */, "Burundi" }, + { 0x424A /* BJ */, "Benin" }, + { 0x424C /* BL */, "Saint Barthelemy" }, + { 0x424D /* BM */, "Bermuda" }, + { 0x424E /* BN */, "Brunei Darussalam" }, + { 0x424F /* BO */, "Bolivia" }, + { 0x4252 /* BR */, "Brazil" }, + { 0x4253 /* BS */, "Bahamas" }, + { 0x4254 /* BT */, "Bhutan" }, + { 0x4256 /* BV */, "Bouvet Island" }, + { 0x4257 /* BW */, "Botswana" }, + { 0x4259 /* BY */, "Belarus" }, + { 0x425A /* BZ */, "Belize" }, + { 0x4341 /* CA */, "Canada" }, + { 0x4343 /* CC */, "Cocos (Keeling) Islands" }, + { 0x4344 /* CD */, "Congo" }, + { 0x4346 /* CF */, "Central African Republic" }, + { 0x4347 /* CG */, "Congo" }, + { 0x4348 /* CH */, "Switzerland" }, + { 0x4349 /* CI */, "Cote d'Ivoire" }, + { 0x434B /* CK */, "Cook Islands" }, + { 0x434C /* CL */, "Chile" }, + { 0x434D /* CM */, "Cameroon" }, + { 0x434E /* CN */, "China" }, + { 0x434F /* CO */, "Colombia" }, + { 0x4352 /* CR */, "Costa Rica" }, + { 0x4355 /* CU */, "Cuba" }, + { 0x4356 /* CV */, "Cape Verde" }, + { 0x4358 /* CX */, "Christmas Island" }, + { 0x4359 /* CY */, "Cyprus" }, + { 0x435A /* CZ */, "Czech Republic" }, + { 0x4445 /* DE */, "Germany" }, + { 0x444A /* DJ */, "Djibouti" }, + { 0x444B /* DK */, "Denmark" }, + { 0x444D /* DM */, "Dominica" }, + { 0x444F /* DO */, "Dominican Republic" }, + { 0x445A /* DZ */, "Algeria" }, + { 0x4543 /* EC */, "Ecuador" }, + { 0x4545 /* EE */, "Estonia" }, + { 0x4547 /* EG */, "Egypt" }, + { 0x4548 /* EH */, "Western Sahara" }, + { 0x4552 /* ER */, "Eritrea" }, + { 0x4553 /* ES */, "Spain" }, + { 0x4554 /* ET */, "Ethiopia" }, + { 0x4649 /* FI */, "Finland" }, + { 0x464A /* FJ */, "Fiji" }, + { 0x464B /* FK */, "Falkland Islands" }, + { 0x464D /* FM */, "Micronesia" }, + { 0x464F /* FO */, "Faroe Islands" }, + { 0x4652 /* FR */, "France" }, + { 0x4741 /* GA */, "Gabon" }, + { 0x4742 /* GB */, "United Kingdom" }, + { 0x4744 /* GD */, "Grenada" }, + { 0x4745 /* GE */, "Georgia" }, + { 0x4746 /* GF */, "French Guiana" }, + { 0x4747 /* GG */, "Guernsey" }, + { 0x4748 /* GH */, "Ghana" }, + { 0x4749 /* GI */, "Gibraltar" }, + { 0x474C /* GL */, "Greenland" }, + { 0x474D /* GM */, "Gambia" }, + { 0x474E /* GN */, "Guinea" }, + { 0x4750 /* GP */, "Guadeloupe" }, + { 0x4751 /* GQ */, "Equatorial Guinea" }, + { 0x4752 /* GR */, "Greece" }, + { 0x4753 /* GS */, "South Georgia" }, + { 0x4754 /* GT */, "Guatemala" }, + { 0x4755 /* GU */, "Guam" }, + { 0x4757 /* GW */, "Guinea-Bissau" }, + { 0x4759 /* GY */, "Guyana" }, + { 0x484B /* HK */, "Hong Kong" }, + { 0x484D /* HM */, "Heard and McDonald Islands" }, + { 0x484E /* HN */, "Honduras" }, + { 0x4852 /* HR */, "Croatia" }, + { 0x4854 /* HT */, "Haiti" }, + { 0x4855 /* HU */, "Hungary" }, + { 0x4944 /* ID */, "Indonesia" }, + { 0x4945 /* IE */, "Ireland" }, + { 0x494C /* IL */, "Israel" }, + { 0x494D /* IM */, "Isle of Man" }, + { 0x494E /* IN */, "India" }, + { 0x494F /* IO */, "Chagos Islands" }, + { 0x4951 /* IQ */, "Iraq" }, + { 0x4952 /* IR */, "Iran" }, + { 0x4953 /* IS */, "Iceland" }, + { 0x4954 /* IT */, "Italy" }, + { 0x4A45 /* JE */, "Jersey" }, + { 0x4A4D /* JM */, "Jamaica" }, + { 0x4A4F /* JO */, "Jordan" }, + { 0x4A50 /* JP */, "Japan" }, + { 0x4B45 /* KE */, "Kenya" }, + { 0x4B47 /* KG */, "Kyrgyzstan" }, + { 0x4B48 /* KH */, "Cambodia" }, + { 0x4B49 /* KI */, "Kiribati" }, + { 0x4B4D /* KM */, "Comoros" }, + { 0x4B4E /* KN */, "Saint Kitts and Nevis" }, + { 0x4B50 /* KP */, "North Korea" }, + { 0x4B52 /* KR */, "South Korea" }, + { 0x4B57 /* KW */, "Kuwait" }, + { 0x4B59 /* KY */, "Cayman Islands" }, + { 0x4B5A /* KZ */, "Kazakhstan" }, + { 0x4C41 /* LA */, "Laos" }, + { 0x4C42 /* LB */, "Lebanon" }, + { 0x4C43 /* LC */, "Saint Lucia" }, + { 0x4C49 /* LI */, "Liechtenstein" }, + { 0x4C4B /* LK */, "Sri Lanka" }, + { 0x4C52 /* LR */, "Liberia" }, + { 0x4C53 /* LS */, "Lesotho" }, + { 0x4C54 /* LT */, "Lithuania" }, + { 0x4C55 /* LU */, "Luxembourg" }, + { 0x4C56 /* LV */, "Latvia" }, + { 0x4C59 /* LY */, "Libyan Arab Jamahiriya" }, + { 0x4D41 /* MA */, "Morocco" }, + { 0x4D43 /* MC */, "Monaco" }, + { 0x4D44 /* MD */, "Moldova" }, + { 0x4D45 /* ME */, "Montenegro" }, + { 0x4D46 /* MF */, "Saint Martin (French part)" }, + { 0x4D47 /* MG */, "Madagascar" }, + { 0x4D48 /* MH */, "Marshall Islands" }, + { 0x4D4B /* MK */, "Macedonia" }, + { 0x4D4C /* ML */, "Mali" }, + { 0x4D4D /* MM */, "Myanmar" }, + { 0x4D4E /* MN */, "Mongolia" }, + { 0x4D4F /* MO */, "Macao" }, + { 0x4D50 /* MP */, "Northern Mariana Islands" }, + { 0x4D51 /* MQ */, "Martinique" }, + { 0x4D52 /* MR */, "Mauritania" }, + { 0x4D53 /* MS */, "Montserrat" }, + { 0x4D54 /* MT */, "Malta" }, + { 0x4D55 /* MU */, "Mauritius" }, + { 0x4D56 /* MV */, "Maldives" }, + { 0x4D57 /* MW */, "Malawi" }, + { 0x4D58 /* MX */, "Mexico" }, + { 0x4D59 /* MY */, "Malaysia" }, + { 0x4D5A /* MZ */, "Mozambique" }, + { 0x4E41 /* NA */, "Namibia" }, + { 0x4E43 /* NC */, "New Caledonia" }, + { 0x4E45 /* NE */, "Niger" }, + { 0x4E46 /* NF */, "Norfolk Island" }, + { 0x4E47 /* NG */, "Nigeria" }, + { 0x4E49 /* NI */, "Nicaragua" }, + { 0x4E4C /* NL */, "Netherlands" }, + { 0x4E4F /* NO */, "Norway" }, + { 0x4E50 /* NP */, "Nepal" }, + { 0x4E52 /* NR */, "Nauru" }, + { 0x4E55 /* NU */, "Niue" }, + { 0x4E5A /* NZ */, "New Zealand" }, + { 0x4F4D /* OM */, "Oman" }, + { 0x5041 /* PA */, "Panama" }, + { 0x5045 /* PE */, "Peru" }, + { 0x5046 /* PF */, "French Polynesia" }, + { 0x5047 /* PG */, "Papua New Guinea" }, + { 0x5048 /* PH */, "Philippines" }, + { 0x504B /* PK */, "Pakistan" }, + { 0x504C /* PL */, "Poland" }, + { 0x504D /* PM */, "Saint Pierre and Miquelon" }, + { 0x504E /* PN */, "Pitcairn" }, + { 0x5052 /* PR */, "Puerto Rico" }, + { 0x5053 /* PS */, "Palestinian Territory" }, + { 0x5054 /* PT */, "Portugal" }, + { 0x5057 /* PW */, "Palau" }, + { 0x5059 /* PY */, "Paraguay" }, + { 0x5141 /* QA */, "Qatar" }, + { 0x5245 /* RE */, "Reunion" }, + { 0x524F /* RO */, "Romania" }, + { 0x5253 /* RS */, "Serbia" }, + { 0x5255 /* RU */, "Russian Federation" }, + { 0x5257 /* RW */, "Rwanda" }, + { 0x5341 /* SA */, "Saudi Arabia" }, + { 0x5342 /* SB */, "Solomon Islands" }, + { 0x5343 /* SC */, "Seychelles" }, + { 0x5344 /* SD */, "Sudan" }, + { 0x5345 /* SE */, "Sweden" }, + { 0x5347 /* SG */, "Singapore" }, + { 0x5348 /* SH */, "St. Helena and Dependencies" }, + { 0x5349 /* SI */, "Slovenia" }, + { 0x534A /* SJ */, "Svalbard and Jan Mayen" }, + { 0x534B /* SK */, "Slovakia" }, + { 0x534C /* SL */, "Sierra Leone" }, + { 0x534D /* SM */, "San Marino" }, + { 0x534E /* SN */, "Senegal" }, + { 0x534F /* SO */, "Somalia" }, + { 0x5352 /* SR */, "Suriname" }, + { 0x5354 /* ST */, "Sao Tome and Principe" }, + { 0x5356 /* SV */, "El Salvador" }, + { 0x5359 /* SY */, "Syrian Arab Republic" }, + { 0x535A /* SZ */, "Swaziland" }, + { 0x5443 /* TC */, "Turks and Caicos Islands" }, + { 0x5444 /* TD */, "Chad" }, + { 0x5446 /* TF */, "French Southern Territories" }, + { 0x5447 /* TG */, "Togo" }, + { 0x5448 /* TH */, "Thailand" }, + { 0x544A /* TJ */, "Tajikistan" }, + { 0x544B /* TK */, "Tokelau" }, + { 0x544C /* TL */, "Timor-Leste" }, + { 0x544D /* TM */, "Turkmenistan" }, + { 0x544E /* TN */, "Tunisia" }, + { 0x544F /* TO */, "Tonga" }, + { 0x5452 /* TR */, "Turkey" }, + { 0x5454 /* TT */, "Trinidad and Tobago" }, + { 0x5456 /* TV */, "Tuvalu" }, + { 0x5457 /* TW */, "Taiwan" }, + { 0x545A /* TZ */, "Tanzania" }, + { 0x5541 /* UA */, "Ukraine" }, + { 0x5547 /* UG */, "Uganda" }, + { 0x554D /* UM */, "U.S. Minor Outlying Islands" }, + { 0x5553 /* US */, "United States" }, + { 0x5559 /* UY */, "Uruguay" }, + { 0x555A /* UZ */, "Uzbekistan" }, + { 0x5641 /* VA */, "Vatican City State" }, + { 0x5643 /* VC */, "St. Vincent and Grenadines" }, + { 0x5645 /* VE */, "Venezuela" }, + { 0x5647 /* VG */, "Virgin Islands, British" }, + { 0x5649 /* VI */, "Virgin Islands, U.S." }, + { 0x564E /* VN */, "Viet Nam" }, + { 0x5655 /* VU */, "Vanuatu" }, + { 0x5746 /* WF */, "Wallis and Futuna" }, + { 0x5753 /* WS */, "Samoa" }, + { 0x5945 /* YE */, "Yemen" }, + { 0x5954 /* YT */, "Mayotte" }, + { 0x5A41 /* ZA */, "South Africa" }, + { 0x5A4D /* ZM */, "Zambia" }, + { 0x5A57 /* ZW */, "Zimbabwe" }, + { 0, "" } +}; + + +const char * iwinfo_type(const char *ifname) +{ +#ifdef USE_NL80211 + if (nl80211_probe(ifname)) + return "nl80211"; + else +#endif + +#ifdef USE_MADWIFI + if (madwifi_probe(ifname)) + return "madwifi"; + else +#endif + +#ifdef USE_WL + if (wl_probe(ifname)) + return "wl"; + else +#endif + + if (wext_probe(ifname)) + return "wext"; + + return NULL; +} + +const struct iwinfo_ops * iwinfo_backend(const char *ifname) +{ + const char *type; + struct iwinfo_ops *ops; + + type = iwinfo_type(ifname); + if (!type) + return NULL; + +#ifdef USE_NL80211 + if (!strcmp(type, "nl80211")) + return &nl80211_ops; + else +#endif + +#ifdef USE_MADWIFI + if (!strcmp(type, "madwifi")) + return &madwifi_ops; + else +#endif + +#ifdef USE_WL + if (!strcmp(type, "wl")) + return &wl_ops; + else +#endif + + if (!strcmp(type, "wext")) + return &wext_ops; + + return NULL; +} + +void iwinfo_finish(void) +{ +#ifdef USE_WL + wl_close(); +#endif +#ifdef USE_MADWIFI + madwifi_close(); +#endif +#ifdef USE_NL80211 + nl80211_close(); +#endif + wext_close(); + iwinfo_close(); +} diff --git a/contrib/package/iwinfo/src/iwinfo_lualib.c b/contrib/package/iwinfo/src/iwinfo_lualib.c index 516b11fffc..dfc2d285fb 100644 --- a/contrib/package/iwinfo/src/iwinfo_lualib.c +++ b/contrib/package/iwinfo/src/iwinfo_lualib.c @@ -16,292 +16,17 @@ * with the iwinfo library. If not, see http://www.gnu.org/licenses/. */ -#include "iwinfo_lualib.h" - - -/* - * ISO3166 country labels - */ - -struct iwinfo_iso3166_label ISO3166_Names[] = { - { 0x3030 /* 00 */, "World" }, - { 0x4144 /* AD */, "Andorra" }, - { 0x4145 /* AE */, "United Arab Emirates" }, - { 0x4146 /* AF */, "Afghanistan" }, - { 0x4147 /* AG */, "Antigua and Barbuda" }, - { 0x4149 /* AI */, "Anguilla" }, - { 0x414C /* AL */, "Albania" }, - { 0x414D /* AM */, "Armenia" }, - { 0x414E /* AN */, "Netherlands Antilles" }, - { 0x414F /* AO */, "Angola" }, - { 0x4151 /* AQ */, "Antarctica" }, - { 0x4152 /* AR */, "Argentina" }, - { 0x4153 /* AS */, "American Samoa" }, - { 0x4154 /* AT */, "Austria" }, - { 0x4155 /* AU */, "Australia" }, - { 0x4157 /* AW */, "Aruba" }, - { 0x4158 /* AX */, "Aland Islands" }, - { 0x415A /* AZ */, "Azerbaijan" }, - { 0x4241 /* BA */, "Bosnia and Herzegovina" }, - { 0x4242 /* BB */, "Barbados" }, - { 0x4244 /* BD */, "Bangladesh" }, - { 0x4245 /* BE */, "Belgium" }, - { 0x4246 /* BF */, "Burkina Faso" }, - { 0x4247 /* BG */, "Bulgaria" }, - { 0x4248 /* BH */, "Bahrain" }, - { 0x4249 /* BI */, "Burundi" }, - { 0x424A /* BJ */, "Benin" }, - { 0x424C /* BL */, "Saint Barthelemy" }, - { 0x424D /* BM */, "Bermuda" }, - { 0x424E /* BN */, "Brunei Darussalam" }, - { 0x424F /* BO */, "Bolivia" }, - { 0x4252 /* BR */, "Brazil" }, - { 0x4253 /* BS */, "Bahamas" }, - { 0x4254 /* BT */, "Bhutan" }, - { 0x4256 /* BV */, "Bouvet Island" }, - { 0x4257 /* BW */, "Botswana" }, - { 0x4259 /* BY */, "Belarus" }, - { 0x425A /* BZ */, "Belize" }, - { 0x4341 /* CA */, "Canada" }, - { 0x4343 /* CC */, "Cocos (Keeling) Islands" }, - { 0x4344 /* CD */, "Congo" }, - { 0x4346 /* CF */, "Central African Republic" }, - { 0x4347 /* CG */, "Congo" }, - { 0x4348 /* CH */, "Switzerland" }, - { 0x4349 /* CI */, "Cote d'Ivoire" }, - { 0x434B /* CK */, "Cook Islands" }, - { 0x434C /* CL */, "Chile" }, - { 0x434D /* CM */, "Cameroon" }, - { 0x434E /* CN */, "China" }, - { 0x434F /* CO */, "Colombia" }, - { 0x4352 /* CR */, "Costa Rica" }, - { 0x4355 /* CU */, "Cuba" }, - { 0x4356 /* CV */, "Cape Verde" }, - { 0x4358 /* CX */, "Christmas Island" }, - { 0x4359 /* CY */, "Cyprus" }, - { 0x435A /* CZ */, "Czech Republic" }, - { 0x4445 /* DE */, "Germany" }, - { 0x444A /* DJ */, "Djibouti" }, - { 0x444B /* DK */, "Denmark" }, - { 0x444D /* DM */, "Dominica" }, - { 0x444F /* DO */, "Dominican Republic" }, - { 0x445A /* DZ */, "Algeria" }, - { 0x4543 /* EC */, "Ecuador" }, - { 0x4545 /* EE */, "Estonia" }, - { 0x4547 /* EG */, "Egypt" }, - { 0x4548 /* EH */, "Western Sahara" }, - { 0x4552 /* ER */, "Eritrea" }, - { 0x4553 /* ES */, "Spain" }, - { 0x4554 /* ET */, "Ethiopia" }, - { 0x4649 /* FI */, "Finland" }, - { 0x464A /* FJ */, "Fiji" }, - { 0x464B /* FK */, "Falkland Islands" }, - { 0x464D /* FM */, "Micronesia" }, - { 0x464F /* FO */, "Faroe Islands" }, - { 0x4652 /* FR */, "France" }, - { 0x4741 /* GA */, "Gabon" }, - { 0x4742 /* GB */, "United Kingdom" }, - { 0x4744 /* GD */, "Grenada" }, - { 0x4745 /* GE */, "Georgia" }, - { 0x4746 /* GF */, "French Guiana" }, - { 0x4747 /* GG */, "Guernsey" }, - { 0x4748 /* GH */, "Ghana" }, - { 0x4749 /* GI */, "Gibraltar" }, - { 0x474C /* GL */, "Greenland" }, - { 0x474D /* GM */, "Gambia" }, - { 0x474E /* GN */, "Guinea" }, - { 0x4750 /* GP */, "Guadeloupe" }, - { 0x4751 /* GQ */, "Equatorial Guinea" }, - { 0x4752 /* GR */, "Greece" }, - { 0x4753 /* GS */, "South Georgia" }, - { 0x4754 /* GT */, "Guatemala" }, - { 0x4755 /* GU */, "Guam" }, - { 0x4757 /* GW */, "Guinea-Bissau" }, - { 0x4759 /* GY */, "Guyana" }, - { 0x484B /* HK */, "Hong Kong" }, - { 0x484D /* HM */, "Heard and McDonald Islands" }, - { 0x484E /* HN */, "Honduras" }, - { 0x4852 /* HR */, "Croatia" }, - { 0x4854 /* HT */, "Haiti" }, - { 0x4855 /* HU */, "Hungary" }, - { 0x4944 /* ID */, "Indonesia" }, - { 0x4945 /* IE */, "Ireland" }, - { 0x494C /* IL */, "Israel" }, - { 0x494D /* IM */, "Isle of Man" }, - { 0x494E /* IN */, "India" }, - { 0x494F /* IO */, "Chagos Islands" }, - { 0x4951 /* IQ */, "Iraq" }, - { 0x4952 /* IR */, "Iran" }, - { 0x4953 /* IS */, "Iceland" }, - { 0x4954 /* IT */, "Italy" }, - { 0x4A45 /* JE */, "Jersey" }, - { 0x4A4D /* JM */, "Jamaica" }, - { 0x4A4F /* JO */, "Jordan" }, - { 0x4A50 /* JP */, "Japan" }, - { 0x4B45 /* KE */, "Kenya" }, - { 0x4B47 /* KG */, "Kyrgyzstan" }, - { 0x4B48 /* KH */, "Cambodia" }, - { 0x4B49 /* KI */, "Kiribati" }, - { 0x4B4D /* KM */, "Comoros" }, - { 0x4B4E /* KN */, "Saint Kitts and Nevis" }, - { 0x4B50 /* KP */, "North Korea" }, - { 0x4B52 /* KR */, "South Korea" }, - { 0x4B57 /* KW */, "Kuwait" }, - { 0x4B59 /* KY */, "Cayman Islands" }, - { 0x4B5A /* KZ */, "Kazakhstan" }, - { 0x4C41 /* LA */, "Laos" }, - { 0x4C42 /* LB */, "Lebanon" }, - { 0x4C43 /* LC */, "Saint Lucia" }, - { 0x4C49 /* LI */, "Liechtenstein" }, - { 0x4C4B /* LK */, "Sri Lanka" }, - { 0x4C52 /* LR */, "Liberia" }, - { 0x4C53 /* LS */, "Lesotho" }, - { 0x4C54 /* LT */, "Lithuania" }, - { 0x4C55 /* LU */, "Luxembourg" }, - { 0x4C56 /* LV */, "Latvia" }, - { 0x4C59 /* LY */, "Libyan Arab Jamahiriya" }, - { 0x4D41 /* MA */, "Morocco" }, - { 0x4D43 /* MC */, "Monaco" }, - { 0x4D44 /* MD */, "Moldova" }, - { 0x4D45 /* ME */, "Montenegro" }, - { 0x4D46 /* MF */, "Saint Martin (French part)" }, - { 0x4D47 /* MG */, "Madagascar" }, - { 0x4D48 /* MH */, "Marshall Islands" }, - { 0x4D4B /* MK */, "Macedonia" }, - { 0x4D4C /* ML */, "Mali" }, - { 0x4D4D /* MM */, "Myanmar" }, - { 0x4D4E /* MN */, "Mongolia" }, - { 0x4D4F /* MO */, "Macao" }, - { 0x4D50 /* MP */, "Northern Mariana Islands" }, - { 0x4D51 /* MQ */, "Martinique" }, - { 0x4D52 /* MR */, "Mauritania" }, - { 0x4D53 /* MS */, "Montserrat" }, - { 0x4D54 /* MT */, "Malta" }, - { 0x4D55 /* MU */, "Mauritius" }, - { 0x4D56 /* MV */, "Maldives" }, - { 0x4D57 /* MW */, "Malawi" }, - { 0x4D58 /* MX */, "Mexico" }, - { 0x4D59 /* MY */, "Malaysia" }, - { 0x4D5A /* MZ */, "Mozambique" }, - { 0x4E41 /* NA */, "Namibia" }, - { 0x4E43 /* NC */, "New Caledonia" }, - { 0x4E45 /* NE */, "Niger" }, - { 0x4E46 /* NF */, "Norfolk Island" }, - { 0x4E47 /* NG */, "Nigeria" }, - { 0x4E49 /* NI */, "Nicaragua" }, - { 0x4E4C /* NL */, "Netherlands" }, - { 0x4E4F /* NO */, "Norway" }, - { 0x4E50 /* NP */, "Nepal" }, - { 0x4E52 /* NR */, "Nauru" }, - { 0x4E55 /* NU */, "Niue" }, - { 0x4E5A /* NZ */, "New Zealand" }, - { 0x4F4D /* OM */, "Oman" }, - { 0x5041 /* PA */, "Panama" }, - { 0x5045 /* PE */, "Peru" }, - { 0x5046 /* PF */, "French Polynesia" }, - { 0x5047 /* PG */, "Papua New Guinea" }, - { 0x5048 /* PH */, "Philippines" }, - { 0x504B /* PK */, "Pakistan" }, - { 0x504C /* PL */, "Poland" }, - { 0x504D /* PM */, "Saint Pierre and Miquelon" }, - { 0x504E /* PN */, "Pitcairn" }, - { 0x5052 /* PR */, "Puerto Rico" }, - { 0x5053 /* PS */, "Palestinian Territory" }, - { 0x5054 /* PT */, "Portugal" }, - { 0x5057 /* PW */, "Palau" }, - { 0x5059 /* PY */, "Paraguay" }, - { 0x5141 /* QA */, "Qatar" }, - { 0x5245 /* RE */, "Reunion" }, - { 0x524F /* RO */, "Romania" }, - { 0x5253 /* RS */, "Serbia" }, - { 0x5255 /* RU */, "Russian Federation" }, - { 0x5257 /* RW */, "Rwanda" }, - { 0x5341 /* SA */, "Saudi Arabia" }, - { 0x5342 /* SB */, "Solomon Islands" }, - { 0x5343 /* SC */, "Seychelles" }, - { 0x5344 /* SD */, "Sudan" }, - { 0x5345 /* SE */, "Sweden" }, - { 0x5347 /* SG */, "Singapore" }, - { 0x5348 /* SH */, "St. Helena and Dependencies" }, - { 0x5349 /* SI */, "Slovenia" }, - { 0x534A /* SJ */, "Svalbard and Jan Mayen" }, - { 0x534B /* SK */, "Slovakia" }, - { 0x534C /* SL */, "Sierra Leone" }, - { 0x534D /* SM */, "San Marino" }, - { 0x534E /* SN */, "Senegal" }, - { 0x534F /* SO */, "Somalia" }, - { 0x5352 /* SR */, "Suriname" }, - { 0x5354 /* ST */, "Sao Tome and Principe" }, - { 0x5356 /* SV */, "El Salvador" }, - { 0x5359 /* SY */, "Syrian Arab Republic" }, - { 0x535A /* SZ */, "Swaziland" }, - { 0x5443 /* TC */, "Turks and Caicos Islands" }, - { 0x5444 /* TD */, "Chad" }, - { 0x5446 /* TF */, "French Southern Territories" }, - { 0x5447 /* TG */, "Togo" }, - { 0x5448 /* TH */, "Thailand" }, - { 0x544A /* TJ */, "Tajikistan" }, - { 0x544B /* TK */, "Tokelau" }, - { 0x544C /* TL */, "Timor-Leste" }, - { 0x544D /* TM */, "Turkmenistan" }, - { 0x544E /* TN */, "Tunisia" }, - { 0x544F /* TO */, "Tonga" }, - { 0x5452 /* TR */, "Turkey" }, - { 0x5454 /* TT */, "Trinidad and Tobago" }, - { 0x5456 /* TV */, "Tuvalu" }, - { 0x5457 /* TW */, "Taiwan" }, - { 0x545A /* TZ */, "Tanzania" }, - { 0x5541 /* UA */, "Ukraine" }, - { 0x5547 /* UG */, "Uganda" }, - { 0x554D /* UM */, "U.S. Minor Outlying Islands" }, - { 0x5553 /* US */, "United States" }, - { 0x5559 /* UY */, "Uruguay" }, - { 0x555A /* UZ */, "Uzbekistan" }, - { 0x5641 /* VA */, "Vatican City State" }, - { 0x5643 /* VC */, "St. Vincent and Grenadines" }, - { 0x5645 /* VE */, "Venezuela" }, - { 0x5647 /* VG */, "Virgin Islands, British" }, - { 0x5649 /* VI */, "Virgin Islands, U.S." }, - { 0x564E /* VN */, "Viet Nam" }, - { 0x5655 /* VU */, "Vanuatu" }, - { 0x5746 /* WF */, "Wallis and Futuna" }, - { 0x5753 /* WS */, "Samoa" }, - { 0x5945 /* YE */, "Yemen" }, - { 0x5954 /* YT */, "Mayotte" }, - { 0x5A41 /* ZA */, "South Africa" }, - { 0x5A4D /* ZM */, "Zambia" }, - { 0x5A57 /* ZW */, "Zimbabwe" }, - { 0, "" } -}; - +#include "iwinfo/lualib.h" /* Determine type */ static int iwinfo_L_type(lua_State *L) { const char *ifname = luaL_checkstring(L, 1); + const char *type = iwinfo_type(ifname); -#ifdef USE_NL80211 - if( nl80211_probe(ifname) ) - lua_pushstring(L, "nl80211"); - else -#endif - -#ifdef USE_MADWIFI - if( madwifi_probe(ifname) ) - lua_pushstring(L, "madwifi"); - else -#endif - -#ifdef USE_WL - if( wl_probe(ifname) ) - lua_pushstring(L, "wl"); - else -#endif - - if( wext_probe(ifname) ) - lua_pushstring(L, "wext"); - + if (type) + lua_pushstring(L, type); else lua_pushnil(L); @@ -311,17 +36,8 @@ static int iwinfo_L_type(lua_State *L) /* Shutdown backends */ static int iwinfo_L__gc(lua_State *L) { -#ifdef USE_WL - wl_close(); -#endif -#ifdef USE_MADWIFI - madwifi_close(); -#endif -#ifdef USE_NL80211 - nl80211_close(); -#endif - wext_close(); - iwinfo_close(); + iwinfo_finish(); + return 0; } /* @@ -333,28 +49,28 @@ static char * iwinfo_crypto_print_ciphers(int ciphers) static char str[128] = { 0 }; char *pos = str; - if( ciphers & IWINFO_CIPHER_WEP40 ) + if (ciphers & IWINFO_CIPHER_WEP40) pos += sprintf(pos, "WEP-40, "); - if( ciphers & IWINFO_CIPHER_WEP104 ) + if (ciphers & IWINFO_CIPHER_WEP104) pos += sprintf(pos, "WEP-104, "); - if( ciphers & IWINFO_CIPHER_TKIP ) + if (ciphers & IWINFO_CIPHER_TKIP) pos += sprintf(pos, "TKIP, "); - if( ciphers & IWINFO_CIPHER_CCMP ) + if (ciphers & IWINFO_CIPHER_CCMP) pos += sprintf(pos, "CCMP, "); - if( ciphers & IWINFO_CIPHER_WRAP ) + if (ciphers & IWINFO_CIPHER_WRAP) pos += sprintf(pos, "WRAP, "); - if( ciphers & IWINFO_CIPHER_AESOCB ) + if (ciphers & IWINFO_CIPHER_AESOCB) pos += sprintf(pos, "AES-OCB, "); - if( ciphers & IWINFO_CIPHER_CKIP ) + if (ciphers & IWINFO_CIPHER_CKIP) pos += sprintf(pos, "CKIP, "); - if( !ciphers || (ciphers & IWINFO_CIPHER_NONE) ) + if (!ciphers || (ciphers & IWINFO_CIPHER_NONE)) pos += sprintf(pos, "NONE, "); *(pos - 2) = 0; @@ -367,13 +83,13 @@ static char * iwinfo_crypto_print_suites(int suites) static char str[64] = { 0 }; char *pos = str; - if( suites & IWINFO_KMGMT_PSK ) + if (suites & IWINFO_KMGMT_PSK) pos += sprintf(pos, "PSK/"); - if( suites & IWINFO_KMGMT_8021x ) + if (suites & IWINFO_KMGMT_8021x) pos += sprintf(pos, "802.1X/"); - if( !suites || (suites & IWINFO_KMGMT_NONE) ) + if (!suites || (suites & IWINFO_KMGMT_NONE)) pos += sprintf(pos, "NONE/"); *(pos - 1) = 0; @@ -385,25 +101,25 @@ static char * iwinfo_crypto_desc(struct iwinfo_crypto_entry *c) { static char desc[512] = { 0 }; - if( c ) + if (c) { - if( c->enabled ) + if (c->enabled) { /* WEP */ - if( c->auth_algs && !c->wpa_version ) + if (c->auth_algs && !c->wpa_version) { - if( (c->auth_algs & IWINFO_AUTH_OPEN) && - (c->auth_algs & IWINFO_AUTH_SHARED) ) + if ((c->auth_algs & IWINFO_AUTH_OPEN) && + (c->auth_algs & IWINFO_AUTH_SHARED)) { sprintf(desc, "WEP Open/Shared (%s)", iwinfo_crypto_print_ciphers(c->pair_ciphers)); } - else if( c->auth_algs & IWINFO_AUTH_OPEN ) + else if (c->auth_algs & IWINFO_AUTH_OPEN) { sprintf(desc, "WEP Open System (%s)", iwinfo_crypto_print_ciphers(c->pair_ciphers)); } - else if( c->auth_algs & IWINFO_AUTH_SHARED ) + else if (c->auth_algs & IWINFO_AUTH_SHARED) { sprintf(desc, "WEP Shared Auth (%s)", iwinfo_crypto_print_ciphers(c->pair_ciphers)); @@ -411,9 +127,9 @@ static char * iwinfo_crypto_desc(struct iwinfo_crypto_entry *c) } /* WPA */ - else if( c->wpa_version ) + else if (c->wpa_version) { - switch(c->wpa_version) { + switch (c->wpa_version) { case 3: sprintf(desc, "mixed WPA/WPA2 %s (%s)", iwinfo_crypto_print_suites(c->auth_suites), @@ -474,9 +190,9 @@ static void iwinfo_L_cryptotable(lua_State *L, struct iwinfo_crypto_entry *c) lua_setfield(L, -2, "wpa"); lua_newtable(L); - for( i = 0, j = 1; i < 8; i++ ) + for (i = 0, j = 1; i < 8; i++) { - if( c->pair_ciphers & (1 << i) ) + if (c->pair_ciphers & (1 << i)) { lua_pushstring(L, IWINFO_CIPHER_NAMES[i]); lua_rawseti(L, -2, j++); @@ -485,9 +201,9 @@ static void iwinfo_L_cryptotable(lua_State *L, struct iwinfo_crypto_entry *c) lua_setfield(L, -2, "pair_ciphers"); lua_newtable(L); - for( i = 0, j = 1; i < 8; i++ ) + for (i = 0, j = 1; i < 8; i++) { - if( c->group_ciphers & (1 << i) ) + if (c->group_ciphers & (1 << i)) { lua_pushstring(L, IWINFO_CIPHER_NAMES[i]); lua_rawseti(L, -2, j++); @@ -496,9 +212,9 @@ static void iwinfo_L_cryptotable(lua_State *L, struct iwinfo_crypto_entry *c) lua_setfield(L, -2, "group_ciphers"); lua_newtable(L); - for( i = 0, j = 1; i < 8; i++ ) + for (i = 0, j = 1; i < 8; i++) { - if( c->auth_suites & (1 << i) ) + if (c->auth_suites & (1 << i)) { lua_pushstring(L, IWINFO_KMGMT_NAMES[i]); lua_rawseti(L, -2, j++); @@ -507,9 +223,9 @@ static void iwinfo_L_cryptotable(lua_State *L, struct iwinfo_crypto_entry *c) lua_setfield(L, -2, "auth_suites"); lua_newtable(L); - for( i = 0, j = 1; i < 8; i++ ) + for (i = 0, j = 1; i < 8; i++) { - if( c->auth_algs & (1 << i) ) + if (c->auth_algs & (1 << i)) { lua_pushstring(L, IWINFO_AUTH_NAMES[i]); lua_rawseti(L, -2, j++); @@ -531,9 +247,9 @@ static int iwinfo_L_assoclist(lua_State *L, int (*func)(const char *, char *, in lua_newtable(L); memset(rv, 0, sizeof(rv)); - if( !(*func)(ifname, rv, &len) ) + if (!(*func)(ifname, rv, &len)) { - for( i = 0; i < len; i += sizeof(struct iwinfo_assoclist_entry) ) + for (i = 0; i < len; i += sizeof(struct iwinfo_assoclist_entry)) { e = (struct iwinfo_assoclist_entry *) &rv[i]; @@ -567,9 +283,9 @@ static int iwinfo_L_txpwrlist(lua_State *L, int (*func)(const char *, char *, in lua_newtable(L); memset(rv, 0, sizeof(rv)); - if( !(*func)(ifname, rv, &len) ) + if (!(*func)(ifname, rv, &len)) { - for( i = 0, x = 1; i < len; i += sizeof(struct iwinfo_txpwrlist_entry), x++ ) + for (i = 0, x = 1; i < len; i += sizeof(struct iwinfo_txpwrlist_entry), x++) { e = (struct iwinfo_txpwrlist_entry *) &rv[i]; @@ -600,9 +316,9 @@ static int iwinfo_L_scanlist(lua_State *L, int (*func)(const char *, char *, int lua_newtable(L); memset(rv, 0, sizeof(rv)); - if( !(*func)(ifname, rv, &len) ) + if (!(*func)(ifname, rv, &len)) { - for( i = 0, x = 1; i < len; i += sizeof(struct iwinfo_scanlist_entry), x++ ) + for (i = 0, x = 1; i < len; i += sizeof(struct iwinfo_scanlist_entry), x++) { e = (struct iwinfo_scanlist_entry *) &rv[i]; @@ -617,7 +333,7 @@ static int iwinfo_L_scanlist(lua_State *L, int (*func)(const char *, char *, int lua_setfield(L, -2, "bssid"); /* ESSID */ - if( e->ssid[0] ) + if (e->ssid[0]) { lua_pushstring(L, (char *) e->ssid); lua_setfield(L, -2, "ssid"); @@ -663,9 +379,9 @@ static int iwinfo_L_freqlist(lua_State *L, int (*func)(const char *, char *, int lua_newtable(L); memset(rv, 0, sizeof(rv)); - if( !(*func)(ifname, rv, &len) ) + if (!(*func)(ifname, rv, &len)) { - for( i = 0, x = 1; i < len; i += sizeof(struct iwinfo_freqlist_entry), x++ ) + for (i = 0, x = 1; i < len; i += sizeof(struct iwinfo_freqlist_entry), x++) { e = (struct iwinfo_freqlist_entry *) &rv[i]; @@ -696,7 +412,7 @@ static int iwinfo_L_encryption(lua_State *L, int (*func)(const char *, char *)) const char *ifname = luaL_checkstring(L, 1); struct iwinfo_crypto_entry c = { 0 }; - if( !(*func)(ifname, (char *)&c) ) + if (!(*func)(ifname, (char *)&c)) { iwinfo_L_cryptotable(L, &c); return 1; @@ -712,7 +428,7 @@ static int iwinfo_L_hwmodelist(lua_State *L, int (*func)(const char *, int *)) const char *ifname = luaL_checkstring(L, 1); int hwmodes = 0; - if( !(*func)(ifname, &hwmodes) ) + if (!(*func)(ifname, &hwmodes)) { lua_newtable(L); @@ -741,7 +457,7 @@ static int iwinfo_L_mbssid_support(lua_State *L, int (*func)(const char *, int * const char *ifname = luaL_checkstring(L, 1); int support = 0; - if( !(*func)(ifname, &support) ) + if (!(*func)(ifname, &support)) { lua_pushboolean(L, support); return 1; @@ -757,11 +473,11 @@ static char * iwinfo_L_country_lookup(char *buf, int len, int iso3166) int i; struct iwinfo_country_entry *c; - for( i = 0; i < len; i += sizeof(struct iwinfo_country_entry) ) + for (i = 0; i < len; i += sizeof(struct iwinfo_country_entry)) { c = (struct iwinfo_country_entry *) &buf[i]; - if( c->iso3166 == iso3166 ) + if (c->iso3166 == iso3166) return c->ccode; } @@ -774,16 +490,16 @@ static int iwinfo_L_countrylist(lua_State *L, int (*func)(const char *, char *, char rv[IWINFO_BUFSIZE], alpha2[3]; char *ccode; const char *ifname = luaL_checkstring(L, 1); - struct iwinfo_iso3166_label *l; + const struct iwinfo_iso3166_label *l; lua_newtable(L); memset(rv, 0, sizeof(rv)); - if( !(*func)(ifname, rv, &len) ) + if (!(*func)(ifname, rv, &len)) { - for( l = ISO3166_Names, j = 1; l->iso3166; l++ ) + for (l = IWINFO_ISO3166_NAMES, j = 1; l->iso3166; l++) { - if( (ccode = iwinfo_L_country_lookup(rv, len, l->iso3166)) != NULL ) + if ((ccode = iwinfo_L_country_lookup(rv, len, l->iso3166)) != NULL) { sprintf(alpha2, "%c%c", (l->iso3166 / 256), (l->iso3166 % 256)); diff --git a/contrib/package/iwinfo/src/iwinfo_madwifi.c b/contrib/package/iwinfo/src/iwinfo_madwifi.c index be89978999..54082c7371 100644 --- a/contrib/package/iwinfo/src/iwinfo_madwifi.c +++ b/contrib/package/iwinfo/src/iwinfo_madwifi.c @@ -20,8 +20,8 @@ * inspired by the hostapd madwifi driver. */ -#include "iwinfo_madwifi.h" -#include "iwinfo_wext.h" +#include "iwinfo/madwifi.h" +#include "iwinfo/wext.h" /* diff --git a/contrib/package/iwinfo/src/iwinfo_nl80211.c b/contrib/package/iwinfo/src/iwinfo_nl80211.c index 83665ccc8d..b3da8384e7 100644 --- a/contrib/package/iwinfo/src/iwinfo_nl80211.c +++ b/contrib/package/iwinfo/src/iwinfo_nl80211.c @@ -22,12 +22,11 @@ * Parts of this code are derived from the Linux iw utility. */ -#include "iwinfo_nl80211.h" -#include "iwinfo_wext.h" +#include "iwinfo/nl80211.h" +#include "iwinfo/wext.h" #define min(x, y) ((x) < (y)) ? (x) : (y) -extern struct iwinfo_iso3166_label ISO3166_Names[]; static struct nl80211_state *nls = NULL; static int nl80211_init(void) @@ -1533,10 +1532,10 @@ int nl80211_get_country(const char *ifname, char *buf) int nl80211_get_countrylist(const char *ifname, char *buf, int *len) { int i, count; - struct iwinfo_iso3166_label *l; struct iwinfo_country_entry *e = (struct iwinfo_country_entry *)buf; + const struct iwinfo_iso3166_label *l; - for( l = ISO3166_Names, count = 0; l->iso3166; l++, e++, count++ ) + for( l = IWINFO_ISO3166_NAMES, count = 0; l->iso3166; l++, e++, count++ ) { e->iso3166 = l->iso3166; e->ccode[0] = (l->iso3166 / 256); diff --git a/contrib/package/iwinfo/src/iwinfo_utils.c b/contrib/package/iwinfo/src/iwinfo_utils.c index edd431e003..081464aafa 100644 --- a/contrib/package/iwinfo/src/iwinfo_utils.c +++ b/contrib/package/iwinfo/src/iwinfo_utils.c @@ -20,7 +20,7 @@ * inspired by the hostapd madwifi driver. */ -#include "iwinfo_utils.h" +#include "iwinfo/utils.h" static int ioctl_socket = -1; diff --git a/contrib/package/iwinfo/src/iwinfo_wext.c b/contrib/package/iwinfo/src/iwinfo_wext.c index 5b942ea33a..314882ad91 100644 --- a/contrib/package/iwinfo/src/iwinfo_wext.c +++ b/contrib/package/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) { diff --git a/contrib/package/iwinfo/src/iwinfo_wext_scan.c b/contrib/package/iwinfo/src/iwinfo_wext_scan.c index 93dd887422..11725c9385 100644 --- a/contrib/package/iwinfo/src/iwinfo_wext_scan.c +++ b/contrib/package/iwinfo/src/iwinfo_wext_scan.c @@ -20,7 +20,7 @@ */ #include "iwinfo.h" -#include "iwinfo_wext_scan.h" +#include "iwinfo/wext_scan.h" static int wext_ioctl(const char *ifname, int cmd, struct iwreq *wrq) diff --git a/contrib/package/iwinfo/src/iwinfo_wl.c b/contrib/package/iwinfo/src/iwinfo_wl.c index 1691e4b358..b3227918d4 100644 --- a/contrib/package/iwinfo/src/iwinfo_wl.c +++ b/contrib/package/iwinfo/src/iwinfo_wl.c @@ -18,8 +18,8 @@ * This code is based on the wlc.c utility published by OpenWrt.org . */ -#include "iwinfo_wl.h" -#include "iwinfo_wext.h" +#include "iwinfo/wl.h" +#include "iwinfo/wext.h" static int wl_ioctl(const char *name, int cmd, void *buf, int len) { -- 2.30.2