summaryrefslogtreecommitdiffhomepage
path: root/contrib/package
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/package')
-rw-r--r--contrib/package/iwinfo/Makefile2
-rw-r--r--contrib/package/iwinfo/src/include/broadcom.h16
-rw-r--r--contrib/package/iwinfo/src/include/madwifi.h168
-rw-r--r--contrib/package/iwinfo/src/iwinfo.h11
-rwxr-xr-xcontrib/package/iwinfo/src/iwinfo.lua23
-rw-r--r--contrib/package/iwinfo/src/iwinfo_lualib.c339
-rw-r--r--contrib/package/iwinfo/src/iwinfo_madwifi.c267
-rw-r--r--contrib/package/iwinfo/src/iwinfo_madwifi.h2
-rw-r--r--contrib/package/iwinfo/src/iwinfo_nl80211.c45
-rw-r--r--contrib/package/iwinfo/src/iwinfo_nl80211.h2
-rw-r--r--contrib/package/iwinfo/src/iwinfo_wext.c23
-rw-r--r--contrib/package/iwinfo/src/iwinfo_wext.h2
-rw-r--r--contrib/package/iwinfo/src/iwinfo_wl.c43
-rw-r--r--contrib/package/iwinfo/src/iwinfo_wl.h2
14 files changed, 745 insertions, 200 deletions
diff --git a/contrib/package/iwinfo/Makefile b/contrib/package/iwinfo/Makefile
index 4ea94028b..5a39dc5cf 100644
--- a/contrib/package/iwinfo/Makefile
+++ b/contrib/package/iwinfo/Makefile
@@ -7,7 +7,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=libiwinfo
-PKG_RELEASE:=1
+PKG_RELEASE:=2
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
diff --git a/contrib/package/iwinfo/src/include/broadcom.h b/contrib/package/iwinfo/src/include/broadcom.h
index 9652d7433..bee9faf25 100644
--- a/contrib/package/iwinfo/src/include/broadcom.h
+++ b/contrib/package/iwinfo/src/include/broadcom.h
@@ -6,7 +6,7 @@
*
* Copyright 2006, Broadcom Corporation
* All Rights Reserved.
- *
+ *
* THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
* KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
* SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
@@ -26,6 +26,8 @@
#define WLC_IOCTL_MAGIC 0x14e46c77
#define WLC_IOCTL_MAXLEN 8192
+#define WLC_CNTRY_BUF_SZ 4
+
#define WLC_GET_MAGIC 0
#define WLC_GET_RATE 12
#define WLC_GET_INFRA 19
@@ -34,6 +36,7 @@
#define WLC_GET_SSID 25
#define WLC_GET_CHANNEL 29
#define WLC_GET_PASSIVE 48
+#define WLC_GET_COUNTRY 83
#define WLC_GET_REVINFO 98
#define WLC_GET_AP 117
#define WLC_GET_RSSI 127
@@ -42,6 +45,8 @@
#define WLC_GET_BSS_INFO 136
#define WLC_GET_ASSOCLIST 159
#define WLC_GET_WPA_AUTH 164
+//#define WLC_GET_CHANNELS_IN_COUNTRY 260
+#define WLC_GET_COUNTRY_LIST 261
#define WLC_GET_VAR 262
@@ -91,4 +96,13 @@ typedef struct wlc_rev_info {
uint chipnum; /* chip number */
} wlc_rev_info_t;
+typedef struct wl_country_list {
+ uint32_t buflen;
+ uint32_t band_set;
+ uint32_t band;
+ uint32_t count;
+ char country_abbrev[1];
+} wl_country_list_t;
+
+
#endif
diff --git a/contrib/package/iwinfo/src/include/madwifi.h b/contrib/package/iwinfo/src/include/madwifi.h
index d90e43d1e..ff90b2251 100644
--- a/contrib/package/iwinfo/src/include/madwifi.h
+++ b/contrib/package/iwinfo/src/include/madwifi.h
@@ -134,172 +134,4 @@ struct ieee80211req_sta_info {
u_int8_t isi_opmode; /* sta operating mode */
};
-/*
- * Country/Region Codes from MS WINNLS.H
- * Numbering from ISO 3166
- * XXX belongs elsewhere
- */
-
-enum CountryCode {
- CTRY_ALBANIA = 8, /* Albania */
- CTRY_ALGERIA = 12, /* Algeria */
- CTRY_ARGENTINA = 32, /* Argentina */
- CTRY_ARMENIA = 51, /* Armenia */
- CTRY_AUSTRALIA = 36, /* Australia */
- CTRY_AUSTRIA = 40, /* Austria */
- CTRY_AZERBAIJAN = 31, /* Azerbaijan */
- CTRY_BAHRAIN = 48, /* Bahrain */
- CTRY_BELARUS = 112, /* Belarus */
- CTRY_BELGIUM = 56, /* Belgium */
- CTRY_BELIZE = 84, /* Belize */
- CTRY_BOLIVIA = 68, /* Bolivia */
- CTRY_BRAZIL = 76, /* Brazil */
- CTRY_BRUNEI_DARUSSALAM = 96, /* Brunei Darussalam */
- CTRY_BULGARIA = 100, /* Bulgaria */
- CTRY_CANADA = 124, /* Canada */
- CTRY_CHILE = 152, /* Chile */
- CTRY_CHINA = 156, /* People's Republic of China */
- CTRY_COLOMBIA = 170, /* Colombia */
- CTRY_COSTA_RICA = 188, /* Costa Rica */
- CTRY_CROATIA = 191, /* Croatia */
- CTRY_CYPRUS = 196,
- CTRY_CZECH = 203, /* Czech Republic */
- CTRY_DENMARK = 208, /* Denmark */
- CTRY_DOMINICAN_REPUBLIC = 214, /* Dominican Republic */
- CTRY_ECUADOR = 218, /* Ecuador */
- CTRY_EGYPT = 818, /* Egypt */
- CTRY_EL_SALVADOR = 222, /* El Salvador */
- CTRY_ESTONIA = 233, /* Estonia */
- CTRY_FAEROE_ISLANDS = 234, /* Faeroe Islands */
- CTRY_FINLAND = 246, /* Finland */
- CTRY_FRANCE = 250, /* France */
- CTRY_FRANCE2 = 255, /* France2 */
- CTRY_GEORGIA = 268, /* Georgia */
- CTRY_GERMANY = 276, /* Germany */
- CTRY_GREECE = 300, /* Greece */
- CTRY_GUATEMALA = 320, /* Guatemala */
- CTRY_HONDURAS = 340, /* Honduras */
- CTRY_HONG_KONG = 344, /* Hong Kong S.A.R., P.R.C. */
- CTRY_HUNGARY = 348, /* Hungary */
- CTRY_ICELAND = 352, /* Iceland */
- CTRY_INDIA = 356, /* India */
- CTRY_INDONESIA = 360, /* Indonesia */
- CTRY_IRAN = 364, /* Iran */
- CTRY_IRAQ = 368, /* Iraq */
- CTRY_IRELAND = 372, /* Ireland */
- CTRY_ISRAEL = 376, /* Israel */
- CTRY_ITALY = 380, /* Italy */
- CTRY_JAMAICA = 388, /* Jamaica */
- CTRY_JAPAN = 392, /* Japan */
- CTRY_JAPAN1 = 393, /* Japan (JP1) */
- CTRY_JAPAN2 = 394, /* Japan (JP0) */
- CTRY_JAPAN3 = 395, /* Japan (JP1-1) */
- CTRY_JAPAN4 = 396, /* Japan (JE1) */
- CTRY_JAPAN5 = 397, /* Japan (JE2) */
- CTRY_JAPAN6 = 399, /* Japan (JP6) */
- CTRY_JAPAN7 = 900, /* Japan */
- CTRY_JAPAN8 = 901, /* Japan */
- CTRY_JAPAN9 = 902, /* Japan */
- CTRY_JAPAN10 = 903, /* Japan */
- CTRY_JAPAN11 = 904, /* Japan */
- CTRY_JAPAN12 = 905, /* Japan */
- CTRY_JAPAN13 = 906, /* Japan */
- CTRY_JAPAN14 = 907, /* Japan */
- CTRY_JAPAN15 = 908, /* Japan */
- CTRY_JAPAN16 = 909, /* Japan */
- CTRY_JAPAN17 = 910, /* Japan */
- CTRY_JAPAN18 = 911, /* Japan */
- CTRY_JAPAN19 = 912, /* Japan */
- CTRY_JAPAN20 = 913, /* Japan */
- CTRY_JAPAN21 = 914, /* Japan */
- CTRY_JAPAN22 = 915, /* Japan */
- CTRY_JAPAN23 = 916, /* Japan */
- CTRY_JAPAN24 = 917, /* Japan */
- CTRY_JAPAN25 = 918, /* Japan */
- CTRY_JAPAN26 = 919, /* Japan */
- CTRY_JAPAN27 = 920, /* Japan */
- CTRY_JAPAN28 = 921, /* Japan */
- CTRY_JAPAN29 = 922, /* Japan */
- CTRY_JAPAN30 = 923, /* Japan */
- CTRY_JAPAN31 = 924, /* Japan */
- CTRY_JAPAN32 = 925, /* Japan */
- CTRY_JAPAN33 = 926, /* Japan */
- CTRY_JAPAN34 = 927, /* Japan */
- CTRY_JAPAN35 = 928, /* Japan */
- CTRY_JAPAN36 = 929, /* Japan */
- CTRY_JAPAN37 = 930, /* Japan */
- CTRY_JAPAN38 = 931, /* Japan */
- CTRY_JAPAN39 = 932, /* Japan */
- CTRY_JAPAN40 = 933, /* Japan */
- CTRY_JAPAN41 = 934, /* Japan */
- CTRY_JAPAN42 = 935, /* Japan */
- CTRY_JAPAN43 = 936, /* Japan */
- CTRY_JAPAN44 = 937, /* Japan */
- CTRY_JAPAN45 = 938, /* Japan */
- CTRY_JAPAN46 = 939, /* Japan */
- CTRY_JAPAN47 = 940, /* Japan */
- CTRY_JAPAN48 = 941, /* Japan */
- CTRY_JORDAN = 400, /* Jordan */
- CTRY_KAZAKHSTAN = 398, /* Kazakhstan */
- CTRY_KENYA = 404, /* Kenya */
- CTRY_KOREA_NORTH = 408, /* North Korea */
- CTRY_KOREA_ROC = 410, /* South Korea */
- CTRY_KOREA_ROC2 = 411, /* South Korea */
- CTRY_KUWAIT = 414, /* Kuwait */
- CTRY_LATVIA = 428, /* Latvia */
- CTRY_LEBANON = 422, /* Lebanon */
- CTRY_LIBYA = 434, /* Libya */
- CTRY_LIECHTENSTEIN = 438, /* Liechtenstein */
- CTRY_LITHUANIA = 440, /* Lithuania */
- CTRY_LUXEMBOURG = 442, /* Luxembourg */
- CTRY_MACAU = 446, /* Macau */
- CTRY_MACEDONIA = 807, /* the Former Yugoslav Republic of Macedonia */
- CTRY_MALAYSIA = 458, /* Malaysia */
- CTRY_MEXICO = 484, /* Mexico */
- CTRY_MONACO = 492, /* Principality of Monaco */
- CTRY_MOROCCO = 504, /* Morocco */
- CTRY_NETHERLANDS = 528, /* Netherlands */
- CTRY_NEW_ZEALAND = 554, /* New Zealand */
- CTRY_NICARAGUA = 558, /* Nicaragua */
- CTRY_NORWAY = 578, /* Norway */
- CTRY_OMAN = 512, /* Oman */
- CTRY_PAKISTAN = 586, /* Islamic Republic of Pakistan */
- CTRY_PANAMA = 591, /* Panama */
- CTRY_PARAGUAY = 600, /* Paraguay */
- CTRY_PERU = 604, /* Peru */
- CTRY_PHILIPPINES = 608, /* Republic of the Philippines */
- CTRY_POLAND = 616, /* Poland */
- CTRY_PORTUGAL = 620, /* Portugal */
- CTRY_PUERTO_RICO = 630, /* Puerto Rico */
- CTRY_QATAR = 634, /* Qatar */
- CTRY_ROMANIA = 642, /* Romania */
- CTRY_RUSSIA = 643, /* Russia */
- CTRY_SAUDI_ARABIA = 682, /* Saudi Arabia */
- CTRY_SINGAPORE = 702, /* Singapore */
- CTRY_SLOVAKIA = 703, /* Slovak Republic */
- CTRY_SLOVENIA = 705, /* Slovenia */
- CTRY_SOUTH_AFRICA = 710, /* South Africa */
- CTRY_SPAIN = 724, /* Spain */
- CTRY_SWEDEN = 752, /* Sweden */
- CTRY_SWITZERLAND = 756, /* Switzerland */
- CTRY_SYRIA = 760, /* Syria */
- CTRY_TAIWAN = 158, /* Taiwan */
- CTRY_THAILAND = 764, /* Thailand */
- CTRY_TRINIDAD_Y_TOBAGO = 780, /* Trinidad y Tobago */
- CTRY_TUNISIA = 788, /* Tunisia */
- CTRY_TURKEY = 792, /* Turkey */
- CTRY_UAE = 784, /* U.A.E. */
- CTRY_UKRAINE = 804, /* Ukraine */
- CTRY_UNITED_KINGDOM = 826, /* United Kingdom */
- CTRY_UNITED_STATES = 840, /* United States */
- CTRY_UNITED_STATES_FCC49 = 842, /* United States (Public Safety)*/
- CTRY_URUGUAY = 858, /* Uruguay */
- CTRY_UZBEKISTAN = 860, /* Uzbekistan */
- CTRY_VENEZUELA = 862, /* Venezuela */
- CTRY_VIET_NAM = 704, /* Viet Nam */
- CTRY_YEMEN = 887, /* Yemen */
- CTRY_ZIMBABWE = 716 /* Zimbabwe */
-};
-
-
#endif
diff --git a/contrib/package/iwinfo/src/iwinfo.h b/contrib/package/iwinfo/src/iwinfo.h
index 9684b0995..448655057 100644
--- a/contrib/package/iwinfo/src/iwinfo.h
+++ b/contrib/package/iwinfo/src/iwinfo.h
@@ -88,5 +88,14 @@ struct iwinfo_scanlist_entry {
struct iwinfo_crypto_entry crypto;
};
-#endif
+struct iwinfo_country_entry {
+ uint16_t iso3166;
+ uint8_t ccode[4];
+};
+struct iwinfo_iso3166_label {
+ uint16_t iso3166;
+ uint8_t name[28];
+};
+
+#endif
diff --git a/contrib/package/iwinfo/src/iwinfo.lua b/contrib/package/iwinfo/src/iwinfo.lua
index caa2816fe..f7dbf42fd 100755
--- a/contrib/package/iwinfo/src/iwinfo.lua
+++ b/contrib/package/iwinfo/src/iwinfo.lua
@@ -132,6 +132,25 @@ function print_assoclist(api, dev)
print("")
end
+function print_countrylist(api, dev)
+ local iw = iwinfo[api]
+ local cl = iw.countrylist(dev)
+ local cc = iw.country(dev)
+ local ce
+
+ if cl and #cl > 0 then
+ for _, ce in ipairs(cl) do
+ printf("%s %4s %s",
+ (cc == ce.alpha2) and "*" or " ",
+ ce.ccode, ce.name)
+ end
+ else
+ print("No country code information available")
+ end
+
+ print("")
+end
+
if #arg ~= 2 then
print("Usage:")
@@ -140,6 +159,7 @@ if #arg ~= 2 then
print(" iwinfo <device> txpowerlist")
print(" iwinfo <device> freqlist")
print(" iwinfo <device> assoclist")
+ print(" iwinfo <device> countrylist")
os.exit(1)
end
@@ -166,6 +186,9 @@ elseif arg[2]:match("^f") then
elseif arg[2]:match("^a") then
print_assoclist(api, dev)
+elseif arg[2]:match("^c") then
+ print_countrylist(api, dev)
+
else
print("Unknown command: " .. arg[2])
end
diff --git a/contrib/package/iwinfo/src/iwinfo_lualib.c b/contrib/package/iwinfo/src/iwinfo_lualib.c
index a7b8ace71..29706e370 100644
--- a/contrib/package/iwinfo/src/iwinfo_lualib.c
+++ b/contrib/package/iwinfo/src/iwinfo_lualib.c
@@ -18,6 +18,264 @@
#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 Barthélemy" },
+ { 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, "" }
+};
+
+
+
/* Determine type */
static int iwinfo_L_type(lua_State *L)
{
@@ -50,8 +308,8 @@ static int iwinfo_L_type(lua_State *L)
return 1;
}
-/*
- * Build a short textual description of the crypto info
+/*
+ * Build a short textual description of the crypto info
*/
static char * iwinfo_crypto_print_ciphers(int ciphers)
@@ -224,7 +482,7 @@ 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++ )
{
@@ -234,7 +492,7 @@ static void iwinfo_L_cryptotable(lua_State *L, struct iwinfo_crypto_entry *c)
lua_rawseti(L, -2, j++);
}
}
- lua_setfield(L, -2, "auth_algs");
+ lua_setfield(L, -2, "auth_algs");
}
@@ -420,6 +678,62 @@ static int iwinfo_L_encryption(lua_State *L, int (*func)(const char *, char *))
return 0;
}
+/* Wrapper for country list */
+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) )
+ {
+ c = (struct iwinfo_country_entry *) &buf[i];
+
+ if( c->iso3166 == iso3166 )
+ return c->ccode;
+ }
+
+ return NULL;
+}
+
+static int iwinfo_L_countrylist(lua_State *L, int (*func)(const char *, char *, int *))
+{
+ int len, i, j;
+ char rv[IWINFO_BUFSIZE], alpha2[3];
+ char *ccode;
+ const char *ifname = luaL_checkstring(L, 1);
+ struct iwinfo_iso3166_label *l;
+
+ lua_newtable(L);
+ memset(rv, 0, sizeof(rv));
+
+ if( !(*func)(ifname, rv, &len) )
+ {
+ for( l = ISO3166_Names, j = 1; l->iso3166; l++ )
+ {
+ if( (ccode = iwinfo_L_country_lookup(rv, len, l->iso3166)) != NULL )
+ {
+ sprintf(alpha2, "%c%c",
+ (l->iso3166 / 256), (l->iso3166 % 256));
+
+ lua_newtable(L);
+
+ lua_pushstring(L, alpha2);
+ lua_setfield(L, -2, "alpha2");
+
+ lua_pushstring(L, ccode);
+ lua_setfield(L, -2, "ccode");
+
+ lua_pushstring(L, l->name);
+ lua_setfield(L, -2, "name");
+
+ lua_rawseti(L, -2, j++);
+ }
+ }
+ }
+
+ return 1;
+}
+
#ifdef USE_WL
/* Broadcom */
@@ -435,10 +749,12 @@ LUA_WRAP_INT(wl,mbssid_support)
LUA_WRAP_STRING(wl,mode)
LUA_WRAP_STRING(wl,ssid)
LUA_WRAP_STRING(wl,bssid)
+LUA_WRAP_STRING(wl,country)
LUA_WRAP_LIST(wl,assoclist)
LUA_WRAP_LIST(wl,txpwrlist)
LUA_WRAP_LIST(wl,scanlist)
LUA_WRAP_LIST(wl,freqlist)
+LUA_WRAP_LIST(wl,countrylist)
LUA_WRAP_LIST(wl,encryption)
#endif
@@ -456,10 +772,12 @@ LUA_WRAP_INT(madwifi,mbssid_support)
LUA_WRAP_STRING(madwifi,mode)
LUA_WRAP_STRING(madwifi,ssid)
LUA_WRAP_STRING(madwifi,bssid)
+LUA_WRAP_STRING(madwifi,country)
LUA_WRAP_LIST(madwifi,assoclist)
LUA_WRAP_LIST(madwifi,txpwrlist)
LUA_WRAP_LIST(madwifi,scanlist)
LUA_WRAP_LIST(madwifi,freqlist)
+LUA_WRAP_LIST(madwifi,countrylist)
LUA_WRAP_LIST(madwifi,encryption)
#endif
@@ -477,10 +795,12 @@ LUA_WRAP_INT(nl80211,mbssid_support)
LUA_WRAP_STRING(nl80211,mode)
LUA_WRAP_STRING(nl80211,ssid)
LUA_WRAP_STRING(nl80211,bssid)
+LUA_WRAP_STRING(nl80211,country)
LUA_WRAP_LIST(nl80211,assoclist)
LUA_WRAP_LIST(nl80211,txpwrlist)
LUA_WRAP_LIST(nl80211,scanlist)
LUA_WRAP_LIST(nl80211,freqlist)
+LUA_WRAP_LIST(nl80211,countrylist)
LUA_WRAP_LIST(nl80211,encryption)
#endif
@@ -497,10 +817,12 @@ LUA_WRAP_INT(wext,mbssid_support)
LUA_WRAP_STRING(wext,mode)
LUA_WRAP_STRING(wext,ssid)
LUA_WRAP_STRING(wext,bssid)
+LUA_WRAP_STRING(wext,country)
LUA_WRAP_LIST(wext,assoclist)
LUA_WRAP_LIST(wext,txpwrlist)
LUA_WRAP_LIST(wext,scanlist)
LUA_WRAP_LIST(wext,freqlist)
+LUA_WRAP_LIST(wext,countrylist)
LUA_WRAP_LIST(wext,encryption)
#ifdef USE_WL
@@ -517,10 +839,12 @@ static const luaL_reg R_wl[] = {
LUA_REG(wl,mode),
LUA_REG(wl,ssid),
LUA_REG(wl,bssid),
+ LUA_REG(wl,country),
LUA_REG(wl,assoclist),
LUA_REG(wl,txpwrlist),
LUA_REG(wl,scanlist),
LUA_REG(wl,freqlist),
+ LUA_REG(wl,countrylist),
LUA_REG(wl,encryption),
LUA_REG(wl,mbssid_support),
{ NULL, NULL }
@@ -541,10 +865,12 @@ static const luaL_reg R_madwifi[] = {
LUA_REG(madwifi,mode),
LUA_REG(madwifi,ssid),
LUA_REG(madwifi,bssid),
+ LUA_REG(madwifi,country),
LUA_REG(madwifi,assoclist),
LUA_REG(madwifi,txpwrlist),
LUA_REG(madwifi,scanlist),
LUA_REG(madwifi,freqlist),
+ LUA_REG(madwifi,countrylist),
LUA_REG(madwifi,encryption),
LUA_REG(madwifi,mbssid_support),
{ NULL, NULL }
@@ -565,10 +891,12 @@ static const luaL_reg R_nl80211[] = {
LUA_REG(nl80211,mode),
LUA_REG(nl80211,ssid),
LUA_REG(nl80211,bssid),
+ LUA_REG(nl80211,country),
LUA_REG(nl80211,assoclist),
LUA_REG(nl80211,txpwrlist),
LUA_REG(nl80211,scanlist),
LUA_REG(nl80211,freqlist),
+ LUA_REG(nl80211,countrylist),
LUA_REG(nl80211,encryption),
LUA_REG(nl80211,mbssid_support),
{ NULL, NULL }
@@ -588,10 +916,12 @@ static const luaL_reg R_wext[] = {
LUA_REG(wext,mode),
LUA_REG(wext,ssid),
LUA_REG(wext,bssid),
+ LUA_REG(wext,country),
LUA_REG(wext,assoclist),
LUA_REG(wext,txpwrlist),
LUA_REG(wext,scanlist),
LUA_REG(wext,freqlist),
+ LUA_REG(wext,countrylist),
LUA_REG(wext,encryption),
LUA_REG(wext,mbssid_support),
{ NULL, NULL }
@@ -639,4 +969,3 @@ LUALIB_API int luaopen_iwinfo(lua_State *L) {
return 1;
}
-
diff --git a/contrib/package/iwinfo/src/iwinfo_madwifi.c b/contrib/package/iwinfo/src/iwinfo_madwifi.c
index 1c4368799..9b761edfa 100644
--- a/contrib/package/iwinfo/src/iwinfo_madwifi.c
+++ b/contrib/package/iwinfo/src/iwinfo_madwifi.c
@@ -23,6 +23,179 @@
#include "iwinfo_madwifi.h"
#include "iwinfo_wext.h"
+
+/*
+ * Madwifi ISO 3166 to Country/Region Code mapping.
+ */
+
+static struct ISO3166_to_CCode
+{
+ u_int16_t iso3166;
+ u_int16_t ccode;
+} CountryCodes[] = {
+ { 0x3030 /* 00 */, 0 }, /* World */
+ { 0x4145 /* AE */, 784 }, /* U.A.E. */
+ { 0x414C /* AL */, 8 }, /* Albania */
+ { 0x414D /* AM */, 51 }, /* Armenia */
+ { 0x4152 /* AR */, 32 }, /* Argentina */
+ { 0x4154 /* AT */, 40 }, /* Austria */
+ { 0x4155 /* AU */, 36 }, /* Australia */
+ { 0x415A /* AZ */, 31 }, /* Azerbaijan */
+ { 0x4245 /* BE */, 56 }, /* Belgium */
+ { 0x4247 /* BG */, 100 }, /* Bulgaria */
+ { 0x4248 /* BH */, 48 }, /* Bahrain */
+ { 0x424E /* BN */, 96 }, /* Brunei Darussalam */
+ { 0x424F /* BO */, 68 }, /* Bolivia */
+ { 0x4252 /* BR */, 76 }, /* Brazil */
+ { 0x4259 /* BY */, 112 }, /* Belarus */
+ { 0x425A /* BZ */, 84 }, /* Belize */
+ { 0x4341 /* CA */, 124 }, /* Canada */
+ { 0x4348 /* CH */, 756 }, /* Switzerland */
+ { 0x434C /* CL */, 152 }, /* Chile */
+ { 0x434E /* CN */, 156 }, /* People's Republic of China */
+ { 0x434F /* CO */, 170 }, /* Colombia */
+ { 0x4352 /* CR */, 188 }, /* Costa Rica */
+ { 0x4359 /* CY */, 196 }, /* Cyprus */
+ { 0x435A /* CZ */, 203 }, /* Czech Republic */
+ { 0x4445 /* DE */, 276 }, /* Germany */
+ { 0x444B /* DK */, 208 }, /* Denmark */
+ { 0x444F /* DO */, 214 }, /* Dominican Republic */
+ { 0x445A /* DZ */, 12 }, /* Algeria */
+ { 0x4543 /* EC */, 218 }, /* Ecuador */
+ { 0x4545 /* EE */, 233 }, /* Estonia */
+ { 0x4547 /* EG */, 818 }, /* Egypt */
+ { 0x4553 /* ES */, 724 }, /* Spain */
+ { 0x4649 /* FI */, 246 }, /* Finland */
+ { 0x464F /* FO */, 234 }, /* Faeroe Islands */
+ { 0x4652 /* FR */, 250 }, /* France */
+ { 0x4652 /* FR */, 255 }, /* France2 */
+ { 0x4742 /* GB */, 826 }, /* United Kingdom */
+ { 0x4745 /* GE */, 268 }, /* Georgia */
+ { 0x4752 /* GR */, 300 }, /* Greece */
+ { 0x4754 /* GT */, 320 }, /* Guatemala */
+ { 0x484B /* HK */, 344 }, /* Hong Kong S.A.R., P.R.C. */
+ { 0x484E /* HN */, 340 }, /* Honduras */
+ { 0x4852 /* HR */, 191 }, /* Croatia */
+ { 0x4855 /* HU */, 348 }, /* Hungary */
+ { 0x4944 /* ID */, 360 }, /* Indonesia */
+ { 0x4945 /* IE */, 372 }, /* Ireland */
+ { 0x494C /* IL */, 376 }, /* Israel */
+ { 0x494E /* IN */, 356 }, /* India */
+ { 0x4951 /* IQ */, 368 }, /* Iraq */
+ { 0x4952 /* IR */, 364 }, /* Iran */
+ { 0x4953 /* IS */, 352 }, /* Iceland */
+ { 0x4954 /* IT */, 380 }, /* Italy */
+ { 0x4A4D /* JM */, 388 }, /* Jamaica */
+ { 0x4A4F /* JO */, 400 }, /* Jordan */
+ { 0x4A50 /* JP */, 392 }, /* Japan */
+ { 0x4A50 /* JP */, 393 }, /* Japan (JP1) */
+ { 0x4A50 /* JP */, 394 }, /* Japan (JP0) */
+ { 0x4A50 /* JP */, 395 }, /* Japan (JP1-1) */
+ { 0x4A50 /* JP */, 396 }, /* Japan (JE1) */
+ { 0x4A50 /* JP */, 397 }, /* Japan (JE2) */
+ { 0x4A50 /* JP */, 399 }, /* Japan (JP6) */
+ { 0x4A50 /* JP */, 900 }, /* Japan */
+ { 0x4A50 /* JP */, 901 }, /* Japan */
+ { 0x4A50 /* JP */, 902 }, /* Japan */
+ { 0x4A50 /* JP */, 903 }, /* Japan */
+ { 0x4A50 /* JP */, 904 }, /* Japan */
+ { 0x4A50 /* JP */, 905 }, /* Japan */
+ { 0x4A50 /* JP */, 906 }, /* Japan */
+ { 0x4A50 /* JP */, 907 }, /* Japan */
+ { 0x4A50 /* JP */, 908 }, /* Japan */
+ { 0x4A50 /* JP */, 909 }, /* Japan */
+ { 0x4A50 /* JP */, 910 }, /* Japan */
+ { 0x4A50 /* JP */, 911 }, /* Japan */
+ { 0x4A50 /* JP */, 912 }, /* Japan */
+ { 0x4A50 /* JP */, 913 }, /* Japan */
+ { 0x4A50 /* JP */, 914 }, /* Japan */
+ { 0x4A50 /* JP */, 915 }, /* Japan */
+ { 0x4A50 /* JP */, 916 }, /* Japan */
+ { 0x4A50 /* JP */, 917 }, /* Japan */
+ { 0x4A50 /* JP */, 918 }, /* Japan */
+ { 0x4A50 /* JP */, 919 }, /* Japan */
+ { 0x4A50 /* JP */, 920 }, /* Japan */
+ { 0x4A50 /* JP */, 921 }, /* Japan */
+ { 0x4A50 /* JP */, 922 }, /* Japan */
+ { 0x4A50 /* JP */, 923 }, /* Japan */
+ { 0x4A50 /* JP */, 924 }, /* Japan */
+ { 0x4A50 /* JP */, 925 }, /* Japan */
+ { 0x4A50 /* JP */, 926 }, /* Japan */
+ { 0x4A50 /* JP */, 927 }, /* Japan */
+ { 0x4A50 /* JP */, 928 }, /* Japan */
+ { 0x4A50 /* JP */, 929 }, /* Japan */
+ { 0x4A50 /* JP */, 930 }, /* Japan */
+ { 0x4A50 /* JP */, 931 }, /* Japan */
+ { 0x4A50 /* JP */, 932 }, /* Japan */
+ { 0x4A50 /* JP */, 933 }, /* Japan */
+ { 0x4A50 /* JP */, 934 }, /* Japan */
+ { 0x4A50 /* JP */, 935 }, /* Japan */
+ { 0x4A50 /* JP */, 936 }, /* Japan */
+ { 0x4A50 /* JP */, 937 }, /* Japan */
+ { 0x4A50 /* JP */, 938 }, /* Japan */
+ { 0x4A50 /* JP */, 939 }, /* Japan */
+ { 0x4A50 /* JP */, 940 }, /* Japan */
+ { 0x4A50 /* JP */, 941 }, /* Japan */
+ { 0x4B45 /* KE */, 404 }, /* Kenya */
+ { 0x4B50 /* KP */, 408 }, /* North Korea */
+ { 0x4B52 /* KR */, 410 }, /* South Korea */
+ { 0x4B52 /* KR */, 411 }, /* South Korea */
+ { 0x4B57 /* KW */, 414 }, /* Kuwait */
+ { 0x4B5A /* KZ */, 398 }, /* Kazakhstan */
+ { 0x4C42 /* LB */, 422 }, /* Lebanon */
+ { 0x4C49 /* LI */, 438 }, /* Liechtenstein */
+ { 0x4C54 /* LT */, 440 }, /* Lithuania */
+ { 0x4C55 /* LU */, 442 }, /* Luxembourg */
+ { 0x4C56 /* LV */, 428 }, /* Latvia */
+ { 0x4C59 /* LY */, 434 }, /* Libya */
+ { 0x4D41 /* MA */, 504 }, /* Morocco */
+ { 0x4D43 /* MC */, 492 }, /* Principality of Monaco */
+ { 0x4D4B /* MK */, 807 }, /* the Former Yugoslav Republic of Macedonia */
+ { 0x4D4F /* MO */, 446 }, /* Macau */
+ { 0x4D58 /* MX */, 484 }, /* Mexico */
+ { 0x4D59 /* MY */, 458 }, /* Malaysia */
+ { 0x4E49 /* NI */, 558 }, /* Nicaragua */
+ { 0x4E4C /* NL */, 528 }, /* Netherlands */
+ { 0x4E4F /* NO */, 578 }, /* Norway */
+ { 0x4E5A /* NZ */, 554 }, /* New Zealand */
+ { 0x4F4D /* OM */, 512 }, /* Oman */
+ { 0x5041 /* PA */, 591 }, /* Panama */
+ { 0x5045 /* PE */, 604 }, /* Peru */
+ { 0x5048 /* PH */, 608 }, /* Republic of the Philippines */
+ { 0x504B /* PK */, 586 }, /* Islamic Republic of Pakistan */
+ { 0x504C /* PL */, 616 }, /* Poland */
+ { 0x5052 /* PR */, 630 }, /* Puerto Rico */
+ { 0x5054 /* PT */, 620 }, /* Portugal */
+ { 0x5059 /* PY */, 600 }, /* Paraguay */
+ { 0x5141 /* QA */, 634 }, /* Qatar */
+ { 0x524F /* RO */, 642 }, /* Romania */
+ { 0x5255 /* RU */, 643 }, /* Russia */
+ { 0x5341 /* SA */, 682 }, /* Saudi Arabia */
+ { 0x5345 /* SE */, 752 }, /* Sweden */
+ { 0x5347 /* SG */, 702 }, /* Singapore */
+ { 0x5349 /* SI */, 705 }, /* Slovenia */
+ { 0x534B /* SK */, 703 }, /* Slovak Republic */
+ { 0x5356 /* SV */, 222 }, /* El Salvador */
+ { 0x5359 /* SY */, 760 }, /* Syria */
+ { 0x5448 /* TH */, 764 }, /* Thailand */
+ { 0x544E /* TN */, 788 }, /* Tunisia */
+ { 0x5452 /* TR */, 792 }, /* Turkey */
+ { 0x5454 /* TT */, 780 }, /* Trinidad y Tobago */
+ { 0x5457 /* TW */, 158 }, /* Taiwan */
+ { 0x5541 /* UA */, 804 }, /* Ukraine */
+ { 0x554B /* UK */, 826 }, /* United Kingdom */
+ { 0x5553 /* US */, 840 }, /* United States */
+ { 0x5553 /* US */, 842 }, /* United States (Public Safety)*/
+ { 0x5559 /* UY */, 858 }, /* Uruguay */
+ { 0x555A /* UZ */, 860 }, /* Uzbekistan */
+ { 0x5645 /* VE */, 862 }, /* Venezuela */
+ { 0x564E /* VN */, 704 }, /* Viet Nam */
+ { 0x5945 /* YE */, 887 }, /* Yemen */
+ { 0x5A41 /* ZA */, 710 }, /* South Africa */
+ { 0x5A57 /* ZW */, 716 }, /* Zimbabwe */
+};
+
+
static int ioctl_socket = -1;
static int madwifi_ioctl(struct iwreq *wrq, const char *ifname, int cmd, void *data, size_t len)
@@ -59,13 +232,12 @@ static int get80211priv(const char *ifname, int op, void *data, size_t len)
return iwr.u.data.length;
}
-static int madwifi_isvap(const char *ifname, const char *wifiname)
+static char * madwifi_isvap(const char *ifname, const char *wifiname)
{
- int fd, ret;
+ int fd, ln;
char path[32];
- char name[IFNAMSIZ];
-
- ret = 0;
+ char *ret = NULL;
+ static char name[IFNAMSIZ];
if( strlen(ifname) <= 9 )
{
@@ -76,11 +248,13 @@ static int madwifi_isvap(const char *ifname, const char *wifiname)
if( wifiname != NULL )
{
if( read(fd, name, strlen(wifiname)) == strlen(wifiname) )
- ret = strncmp(name, wifiname, strlen(wifiname)) ? 0 : 1;
+ ret = strncmp(name, wifiname, strlen(wifiname))
+ ? NULL : name;
}
- else if( read(fd, name, 4) == 4 )
+ else if( (ln = read(fd, name, IFNAMSIZ)) >= 4 )
{
- ret = strncmp(name, "wifi", 4) ? 0 : 1;
+ name[ln-1] = 0;
+ ret = name;
}
(void) close(fd);
@@ -112,7 +286,7 @@ static int madwifi_iswifi(const char *ifname)
int madwifi_probe(const char *ifname)
{
- return ( madwifi_isvap(ifname, NULL) || madwifi_iswifi(ifname) );
+ return ( !!madwifi_isvap(ifname, NULL) || madwifi_iswifi(ifname) );
}
int madwifi_get_mode(const char *ifname, char *buf)
@@ -523,7 +697,7 @@ int madwifi_get_txpwrlist(const char *ifname, char *buf, int *len)
}
/* Its an athX ... */
- else if( madwifi_isvap(ifname, NULL) )
+ else if( !!madwifi_isvap(ifname, NULL) )
{
rc = wext_get_txpwrlist(ifname, buf, len);
}
@@ -547,7 +721,7 @@ int madwifi_get_scanlist(const char *ifname, char *buf, int *len)
{
while( (e = readdir(proc)) != NULL )
{
- if( madwifi_isvap(e->d_name, ifname) )
+ if( !!madwifi_isvap(e->d_name, ifname) )
{
sprintf(cmd, "ifconfig %s up", e->d_name);
@@ -579,7 +753,7 @@ int madwifi_get_scanlist(const char *ifname, char *buf, int *len)
}
/* Got athX device? */
- else if( madwifi_isvap(ifname, NULL) )
+ else if( !!madwifi_isvap(ifname, NULL) )
{
ret = wext_get_scanlist(ifname, buf, len);
}
@@ -609,7 +783,7 @@ int madwifi_get_freqlist(const char *ifname, char *buf, int *len)
}
/* Its an athX ... */
- else if( madwifi_isvap(ifname, NULL) )
+ else if( !!madwifi_isvap(ifname, NULL) )
{
rc = get80211priv(ifname, IEEE80211_IOCTL_GETCHANINFO, &chans, sizeof(chans));
}
@@ -636,10 +810,75 @@ int madwifi_get_freqlist(const char *ifname, char *buf, int *len)
return -1;
}
+int madwifi_get_country(const char *ifname, char *buf)
+{
+ int i, fd, ccode = -1;
+ char buffer[34];
+ char *wifi = madwifi_iswifi(ifname)
+ ? (char *)ifname : madwifi_isvap(ifname, NULL);
+
+ struct ISO3166_to_CCode *e;
+
+ if( wifi )
+ {
+ snprintf(buffer, sizeof(buffer), "/proc/sys/dev/%s/countrycode", wifi);
+
+ if( (fd = open(buffer, O_RDONLY)) > -1 )
+ {
+ memset(buffer, 0, sizeof(buffer));
+
+ if( read(fd, buffer, sizeof(buffer)-1) > 0 )
+ ccode = atoi(buffer);
+
+ close(fd);
+ }
+ }
+
+ for( i = 0; i < (sizeof(CountryCodes)/sizeof(CountryCodes[0])); i++ )
+ {
+ e = &CountryCodes[i];
+
+ if( e->ccode == ccode )
+ {
+ sprintf(buf, "%c%c", e->iso3166 / 256, e->iso3166 % 256);
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+int madwifi_get_countrylist(const char *ifname, char *buf, int *len)
+{
+ int i, count;
+ struct ISO3166_to_CCode *e, *p = NULL;
+ struct iwinfo_country_entry *c = (struct iwinfo_country_entry *)buf;
+
+ count = 0;
+
+ for( int i = 0; i < (sizeof(CountryCodes)/sizeof(CountryCodes[0])); i++ )
+ {
+ e = &CountryCodes[i];
+
+ if( !p || (e->iso3166 != p->iso3166) )
+ {
+ c->iso3166 = e->iso3166;
+ snprintf(c->ccode, sizeof(c->ccode), "%i", e->ccode);
+
+ c++;
+ count++;
+ }
+
+ p = e;
+ }
+
+ *len = (count * sizeof(struct iwinfo_country_entry));
+ return 0;
+}
+
int madwifi_get_mbssid_support(const char *ifname, int *buf)
{
/* We assume that multi bssid is always possible */
*buf = 1;
return 0;
}
-
diff --git a/contrib/package/iwinfo/src/iwinfo_madwifi.h b/contrib/package/iwinfo/src/iwinfo_madwifi.h
index a6a44af3d..9f9ffe5d8 100644
--- a/contrib/package/iwinfo/src/iwinfo_madwifi.h
+++ b/contrib/package/iwinfo/src/iwinfo_madwifi.h
@@ -26,6 +26,7 @@ int madwifi_probe(const char *ifname);
int madwifi_get_mode(const char *ifname, char *buf);
int madwifi_get_ssid(const char *ifname, char *buf);
int madwifi_get_bssid(const char *ifname, char *buf);
+int madwifi_get_country(const char *ifname, char *buf);
int madwifi_get_channel(const char *ifname, int *buf);
int madwifi_get_frequency(const char *ifname, int *buf);
int madwifi_get_txpower(const char *ifname, int *buf);
@@ -39,6 +40,7 @@ int madwifi_get_assoclist(const char *ifname, char *buf, int *len);
int madwifi_get_txpwrlist(const char *ifname, char *buf, int *len);
int madwifi_get_scanlist(const char *ifname, char *buf, int *len);
int madwifi_get_freqlist(const char *ifname, char *buf, int *len);
+int madwifi_get_countrylist(const char *ifname, char *buf, int *len);
int madwifi_get_mbssid_support(const char *ifname, int *buf);
#endif
diff --git a/contrib/package/iwinfo/src/iwinfo_nl80211.c b/contrib/package/iwinfo/src/iwinfo_nl80211.c
index 3e0e7dd52..a643efbdc 100644
--- a/contrib/package/iwinfo/src/iwinfo_nl80211.c
+++ b/contrib/package/iwinfo/src/iwinfo_nl80211.c
@@ -27,6 +27,7 @@
#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)
@@ -937,7 +938,7 @@ int nl80211_get_txpwrlist(const char *ifname, char *buf, int *len)
break;
}
}
- }
+ }
nl80211_free(res);
}
@@ -1155,10 +1156,50 @@ int nl80211_get_freqlist(const char *ifname, char *buf, int *len)
return wext_get_freqlist(ifname, buf, len);
}
+int nl80211_get_country(const char *ifname, char *buf)
+{
+ int rv = -1;
+ struct nl80211_msg_conveyor *req, *res;
+
+ req = nl80211_msg(ifname, NL80211_CMD_GET_REG, 0);
+ if( req )
+ {
+ res = nl80211_send(req);
+ if( res )
+ {
+ if( res->attr[NL80211_ATTR_REG_ALPHA2] )
+ {
+ memcpy(buf, nla_data(res->attr[NL80211_ATTR_REG_ALPHA2]), 2);
+ rv = 0;
+ }
+ nl80211_free(res);
+ }
+ nl80211_free(req);
+ }
+
+ return rv;
+}
+
+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;
+
+ for( l = ISO3166_Names, count = 0; l->iso3166; l++, e++, count++ )
+ {
+ e->iso3166 = l->iso3166;
+ e->ccode[0] = (l->iso3166 / 256);
+ e->ccode[1] = (l->iso3166 % 256);
+ }
+
+ *len = (count * sizeof(struct iwinfo_country_entry));
+ return 0;
+}
+
int nl80211_get_mbssid_support(const char *ifname, int *buf)
{
/* We assume that multi bssid is always possible */
*buf = 1;
return 0;
}
-
diff --git a/contrib/package/iwinfo/src/iwinfo_nl80211.h b/contrib/package/iwinfo/src/iwinfo_nl80211.h
index 5ef11ceb6..dd38b960f 100644
--- a/contrib/package/iwinfo/src/iwinfo_nl80211.h
+++ b/contrib/package/iwinfo/src/iwinfo_nl80211.h
@@ -62,6 +62,7 @@ int nl80211_probe(const char *ifname);
int nl80211_get_mode(const char *ifname, char *buf);
int nl80211_get_ssid(const char *ifname, char *buf);
int nl80211_get_bssid(const char *ifname, char *buf);
+int nl80211_get_country(const char *ifname, char *buf);
int nl80211_get_channel(const char *ifname, int *buf);
int nl80211_get_frequency(const char *ifname, int *buf);
int nl80211_get_txpower(const char *ifname, int *buf);
@@ -75,6 +76,7 @@ int nl80211_get_assoclist(const char *ifname, char *buf, int *len);
int nl80211_get_txpwrlist(const char *ifname, char *buf, int *len);
int nl80211_get_scanlist(const char *ifname, char *buf, int *len);
int nl80211_get_freqlist(const char *ifname, char *buf, int *len);
+int nl80211_get_countrylist(const char *ifname, char *buf, int *len);
int nl80211_get_mbssid_support(const char *ifname, int *buf);
#endif
diff --git a/contrib/package/iwinfo/src/iwinfo_wext.c b/contrib/package/iwinfo/src/iwinfo_wext.c
index 8ea380204..8fe0305f1 100644
--- a/contrib/package/iwinfo/src/iwinfo_wext.c
+++ b/contrib/package/iwinfo/src/iwinfo_wext.c
@@ -184,7 +184,7 @@ int wext_get_bssid(const char *ifname, char *buf)
return 0;
}
- return -1;
+ return -1;
}
int wext_get_bitrate(const char *ifname, int *buf)
@@ -197,7 +197,7 @@ int wext_get_bitrate(const char *ifname, int *buf)
return 0;
}
- return -1;
+ return -1;
}
int wext_get_channel(const char *ifname, int *buf)
@@ -235,7 +235,7 @@ int wext_get_channel(const char *ifname, int *buf)
}
}
- return -1;
+ return -1;
}
int wext_get_frequency(const char *ifname, int *buf)
@@ -273,7 +273,7 @@ int wext_get_frequency(const char *ifname, int *buf)
}
}
- return -1;
+ return -1;
}
int wext_get_txpower(const char *ifname, int *buf)
@@ -413,7 +413,7 @@ int wext_get_txpwrlist(const char *ifname, char *buf, int *len)
return 0;
}
- return -1;
+ return -1;
}
int wext_get_freqlist(const char *ifname, char *buf, int *len)
@@ -447,6 +447,18 @@ int wext_get_freqlist(const char *ifname, char *buf, int *len)
return -1;
}
+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)
+{
+ /* Stub */
+ return -1;
+}
+
int wext_get_encryption(const char *ifname, char *buf)
{
/* No reliable crypto info in wext */
@@ -458,4 +470,3 @@ int wext_get_mbssid_support(const char *ifname, int *buf)
/* No multi bssid support atm */
return -1;
}
-
diff --git a/contrib/package/iwinfo/src/iwinfo_wext.h b/contrib/package/iwinfo/src/iwinfo_wext.h
index 579b3e81c..eb2df4f0f 100644
--- a/contrib/package/iwinfo/src/iwinfo_wext.h
+++ b/contrib/package/iwinfo/src/iwinfo_wext.h
@@ -30,6 +30,7 @@ int wext_probe(const char *ifname);
int wext_get_mode(const char *ifname, char *buf);
int wext_get_ssid(const char *ifname, char *buf);
int wext_get_bssid(const char *ifname, char *buf);
+int wext_get_country(const char *ifname, char *buf);
int wext_get_channel(const char *ifname, int *buf);
int wext_get_frequency(const char *ifname, int *buf);
int wext_get_txpower(const char *ifname, int *buf);
@@ -43,6 +44,7 @@ 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_mbssid_support(const char *ifname, int *buf);
#endif
diff --git a/contrib/package/iwinfo/src/iwinfo_wl.c b/contrib/package/iwinfo/src/iwinfo_wl.c
index 7c1904bf1..1a7d586d9 100644
--- a/contrib/package/iwinfo/src/iwinfo_wl.c
+++ b/contrib/package/iwinfo/src/iwinfo_wl.c
@@ -15,7 +15,7 @@
* 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/.
*
- * This code is based on the wlc.c utility published by OpenWrt.org .
+ * This code is based on the wlc.c utility published by OpenWrt.org .
*/
#include "iwinfo_wl.h"
@@ -480,6 +480,46 @@ int wl_get_freqlist(const char *ifname, char *buf, int *len)
return wext_get_freqlist(ifname, buf, len);
}
+int wl_get_country(const char *ifname, char *buf)
+{
+ if( !wl_ioctl(ifname, WLC_GET_COUNTRY, buf, WLC_CNTRY_BUF_SZ) )
+ return 0;
+
+ return -1;
+}
+
+int wl_get_countrylist(const char *ifname, char *buf, int *len)
+{
+ int i, count;
+ char cdata[WLC_IOCTL_MAXLEN];
+ struct iwinfo_country_entry *c = (struct iwinfo_country_entry *)buf;
+ wl_country_list_t *cl = (wl_country_list_t *)cdata;
+
+ cl->buflen = sizeof(cdata);
+
+ if( !wl_ioctl(ifname, WLC_GET_COUNTRY_LIST, cl, cl->buflen) )
+ {
+ for( i = 0, count = 0; i < cl->count; i++, c++ )
+ {
+ sprintf(c->ccode, &cl->country_abbrev[i * WLC_CNTRY_BUF_SZ]);
+ c->iso3166 = c->ccode[0] * 256 + c->ccode[1];
+
+ /* IL0 -> World */
+ if( !strcmp(c->ccode, "IL0") )
+ c->iso3166 = 0x3030;
+
+ /* YU -> RS */
+ else if( !strcmp(c->ccode, "YU") )
+ c->iso3166 = 0x5253;
+ }
+
+ *len = (i * sizeof(struct iwinfo_country_entry));
+ return 0;
+ }
+
+ return -1;
+}
+
int wl_get_mbssid_support(const char *ifname, int *buf)
{
wlc_rev_info_t revinfo;
@@ -496,4 +536,3 @@ int wl_get_mbssid_support(const char *ifname, int *buf)
return -1;
}
-
diff --git a/contrib/package/iwinfo/src/iwinfo_wl.h b/contrib/package/iwinfo/src/iwinfo_wl.h
index 758c0b1c2..f22f1f317 100644
--- a/contrib/package/iwinfo/src/iwinfo_wl.h
+++ b/contrib/package/iwinfo/src/iwinfo_wl.h
@@ -26,6 +26,7 @@ int wl_probe(const char *ifname);
int wl_get_mode(const char *ifname, char *buf);
int wl_get_ssid(const char *ifname, char *buf);
int wl_get_bssid(const char *ifname, char *buf);
+int wl_get_country(const char *ifname, char *buf);
int wl_get_channel(const char *ifname, int *buf);
int wl_get_frequency(const char *ifname, int *buf);
int wl_get_txpower(const char *ifname, int *buf);
@@ -40,6 +41,7 @@ int wl_get_assoclist(const char *ifname, char *buf, int *len);
int wl_get_txpwrlist(const char *ifname, char *buf, int *len);
int wl_get_scanlist(const char *ifname, char *buf, int *len);
int wl_get_freqlist(const char *ifname, char *buf, int *len);
+int wl_get_countrylist(const char *ifname, char *buf, int *len);
int wl_get_mbssid_support(const char *ifname, int *buf);
#endif