2 * iwinfo - Wireless Information Library - Lua Bindings
4 * Copyright (C) 2009 Jo-Philipp Wich <xm@subsignal.org>
6 * The iwinfo library is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version 2
8 * as published by the Free Software Foundation.
10 * The iwinfo library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with the iwinfo library. If not, see http://www.gnu.org/licenses/.
19 #include "iwinfo/lua.h"
23 static int iwinfo_L_type(lua_State *L)
25 const char *ifname = luaL_checkstring(L, 1);
26 const char *type = iwinfo_type(ifname);
29 lua_pushstring(L, type);
36 /* Shutdown backends */
37 static int iwinfo_L__gc(lua_State *L)
44 * Build a short textual description of the crypto info
47 static char * iwinfo_crypto_print_ciphers(int ciphers)
49 static char str[128] = { 0 };
52 if (ciphers & IWINFO_CIPHER_WEP40)
53 pos += sprintf(pos, "WEP-40, ");
55 if (ciphers & IWINFO_CIPHER_WEP104)
56 pos += sprintf(pos, "WEP-104, ");
58 if (ciphers & IWINFO_CIPHER_TKIP)
59 pos += sprintf(pos, "TKIP, ");
61 if (ciphers & IWINFO_CIPHER_CCMP)
62 pos += sprintf(pos, "CCMP, ");
64 if (ciphers & IWINFO_CIPHER_WRAP)
65 pos += sprintf(pos, "WRAP, ");
67 if (ciphers & IWINFO_CIPHER_AESOCB)
68 pos += sprintf(pos, "AES-OCB, ");
70 if (ciphers & IWINFO_CIPHER_CKIP)
71 pos += sprintf(pos, "CKIP, ");
73 if (!ciphers || (ciphers & IWINFO_CIPHER_NONE))
74 pos += sprintf(pos, "NONE, ");
81 static char * iwinfo_crypto_print_suites(int suites)
83 static char str[64] = { 0 };
86 if (suites & IWINFO_KMGMT_PSK)
87 pos += sprintf(pos, "PSK/");
89 if (suites & IWINFO_KMGMT_8021x)
90 pos += sprintf(pos, "802.1X/");
92 if (!suites || (suites & IWINFO_KMGMT_NONE))
93 pos += sprintf(pos, "NONE/");
100 static char * iwinfo_crypto_desc(struct iwinfo_crypto_entry *c)
102 static char desc[512] = { 0 };
109 if (c->auth_algs && !c->wpa_version)
111 if ((c->auth_algs & IWINFO_AUTH_OPEN) &&
112 (c->auth_algs & IWINFO_AUTH_SHARED))
114 sprintf(desc, "WEP Open/Shared (%s)",
115 iwinfo_crypto_print_ciphers(c->pair_ciphers));
117 else if (c->auth_algs & IWINFO_AUTH_OPEN)
119 sprintf(desc, "WEP Open System (%s)",
120 iwinfo_crypto_print_ciphers(c->pair_ciphers));
122 else if (c->auth_algs & IWINFO_AUTH_SHARED)
124 sprintf(desc, "WEP Shared Auth (%s)",
125 iwinfo_crypto_print_ciphers(c->pair_ciphers));
130 else if (c->wpa_version)
132 switch (c->wpa_version) {
134 sprintf(desc, "mixed WPA/WPA2 %s (%s)",
135 iwinfo_crypto_print_suites(c->auth_suites),
136 iwinfo_crypto_print_ciphers(
137 c->pair_ciphers | c->group_ciphers));
141 sprintf(desc, "WPA2 %s (%s)",
142 iwinfo_crypto_print_suites(c->auth_suites),
143 iwinfo_crypto_print_ciphers(
144 c->pair_ciphers | c->group_ciphers));
148 sprintf(desc, "WPA %s (%s)",
149 iwinfo_crypto_print_suites(c->auth_suites),
150 iwinfo_crypto_print_ciphers(
151 c->pair_ciphers | c->group_ciphers));
157 sprintf(desc, "None");
162 sprintf(desc, "None");
167 sprintf(desc, "Unknown");
173 /* Build Lua table from crypto data */
174 static void iwinfo_L_cryptotable(lua_State *L, struct iwinfo_crypto_entry *c)
180 lua_pushboolean(L, c->enabled);
181 lua_setfield(L, -2, "enabled");
183 lua_pushstring(L, iwinfo_crypto_desc(c));
184 lua_setfield(L, -2, "description");
186 lua_pushboolean(L, (c->enabled && !c->wpa_version));
187 lua_setfield(L, -2, "wep");
189 lua_pushinteger(L, c->wpa_version);
190 lua_setfield(L, -2, "wpa");
193 for (i = 0, j = 1; i < ARRAY_SIZE(IWINFO_CIPHER_NAMES); i++)
195 if (c->pair_ciphers & (1 << i))
197 lua_pushstring(L, IWINFO_CIPHER_NAMES[i]);
198 lua_rawseti(L, -2, j++);
201 lua_setfield(L, -2, "pair_ciphers");
204 for (i = 0, j = 1; i < ARRAY_SIZE(IWINFO_CIPHER_NAMES); i++)
206 if (c->group_ciphers & (1 << i))
208 lua_pushstring(L, IWINFO_CIPHER_NAMES[i]);
209 lua_rawseti(L, -2, j++);
212 lua_setfield(L, -2, "group_ciphers");
215 for (i = 0, j = 1; i < ARRAY_SIZE(IWINFO_KMGMT_NAMES); i++)
217 if (c->auth_suites & (1 << i))
219 lua_pushstring(L, IWINFO_KMGMT_NAMES[i]);
220 lua_rawseti(L, -2, j++);
223 lua_setfield(L, -2, "auth_suites");
226 for (i = 0, j = 1; i < ARRAY_SIZE(IWINFO_AUTH_NAMES); i++)
228 if (c->auth_algs & (1 << i))
230 lua_pushstring(L, IWINFO_AUTH_NAMES[i]);
231 lua_rawseti(L, -2, j++);
234 lua_setfield(L, -2, "auth_algs");
238 /* Wrapper for mode */
239 static int iwinfo_L_mode(lua_State *L, int (*func)(const char *, int *))
242 const char *ifname = luaL_checkstring(L, 1);
244 if ((*func)(ifname, &mode))
245 mode = IWINFO_OPMODE_UNKNOWN;
247 lua_pushstring(L, IWINFO_OPMODE_NAMES[mode]);
251 static void set_rateinfo(lua_State *L, struct iwinfo_rate_entry *r, bool rx)
253 lua_pushnumber(L, r->rate);
254 lua_setfield(L, -2, rx ? "rx_rate" : "tx_rate");
256 lua_pushboolean(L, r->is_ht);
257 lua_setfield(L, -2, rx ? "rx_ht" : "tx_ht");
259 lua_pushboolean(L, r->is_vht);
260 lua_setfield(L, -2, rx ? "rx_vht" : "tx_vht");
262 lua_pushnumber(L, r->mhz);
263 lua_setfield(L, -2, rx ? "rx_mhz" : "tx_mhz");
267 lua_pushboolean(L, r->is_40mhz);
268 lua_setfield(L, -2, rx ? "rx_40mhz" : "tx_40mhz");
270 lua_pushnumber(L, r->mcs);
271 lua_setfield(L, -2, rx ? "rx_mcs" : "tx_mcs");
273 lua_pushboolean(L, r->is_short_gi);
274 lua_setfield(L, -2, rx ? "rx_short_gi" : "tx_short_gi");
278 lua_pushnumber(L, r->mcs);
279 lua_setfield(L, -2, rx ? "rx_mcs" : "tx_mcs");
281 lua_pushnumber(L, r->nss);
282 lua_setfield(L, -2, rx ? "rx_nss" : "tx_nss");
284 lua_pushboolean(L, r->is_short_gi);
285 lua_setfield(L, -2, rx ? "rx_short_gi" : "tx_short_gi");
289 /* Wrapper for assoclist */
290 static int iwinfo_L_assoclist(lua_State *L, int (*func)(const char *, char *, int *))
293 char rv[IWINFO_BUFSIZE];
295 const char *ifname = luaL_checkstring(L, 1);
296 struct iwinfo_assoclist_entry *e;
299 memset(rv, 0, sizeof(rv));
301 if (!(*func)(ifname, rv, &len))
303 for (i = 0; i < len; i += sizeof(struct iwinfo_assoclist_entry))
305 e = (struct iwinfo_assoclist_entry *) &rv[i];
307 sprintf(macstr, "%02X:%02X:%02X:%02X:%02X:%02X",
308 e->mac[0], e->mac[1], e->mac[2],
309 e->mac[3], e->mac[4], e->mac[5]);
313 lua_pushnumber(L, e->signal);
314 lua_setfield(L, -2, "signal");
316 lua_pushnumber(L, e->noise);
317 lua_setfield(L, -2, "noise");
319 lua_pushnumber(L, e->inactive);
320 lua_setfield(L, -2, "inactive");
322 lua_pushnumber(L, e->rx_packets);
323 lua_setfield(L, -2, "rx_packets");
325 lua_pushnumber(L, e->tx_packets);
326 lua_setfield(L, -2, "tx_packets");
328 set_rateinfo(L, &e->rx_rate, true);
329 set_rateinfo(L, &e->tx_rate, false);
332 lua_pushnumber(L, e->thr);
333 lua_setfield(L, -2, "expected_throughput");
336 lua_setfield(L, -2, macstr);
343 /* Wrapper for tx power list */
344 static int iwinfo_L_txpwrlist(lua_State *L, int (*func)(const char *, char *, int *))
347 char rv[IWINFO_BUFSIZE];
348 const char *ifname = luaL_checkstring(L, 1);
349 struct iwinfo_txpwrlist_entry *e;
351 memset(rv, 0, sizeof(rv));
353 if (!(*func)(ifname, rv, &len))
357 for (i = 0, x = 1; i < len; i += sizeof(struct iwinfo_txpwrlist_entry), x++)
359 e = (struct iwinfo_txpwrlist_entry *) &rv[i];
363 lua_pushnumber(L, e->mw);
364 lua_setfield(L, -2, "mw");
366 lua_pushnumber(L, e->dbm);
367 lua_setfield(L, -2, "dbm");
369 lua_rawseti(L, -2, x);
378 /* Wrapper for scan list */
379 static int iwinfo_L_scanlist(lua_State *L, int (*func)(const char *, char *, int *))
382 char rv[IWINFO_BUFSIZE];
384 const char *ifname = luaL_checkstring(L, 1);
385 struct iwinfo_scanlist_entry *e;
388 memset(rv, 0, sizeof(rv));
390 if (!(*func)(ifname, rv, &len))
392 for (i = 0, x = 1; i < len; i += sizeof(struct iwinfo_scanlist_entry), x++)
394 e = (struct iwinfo_scanlist_entry *) &rv[i];
399 sprintf(macstr, "%02X:%02X:%02X:%02X:%02X:%02X",
400 e->mac[0], e->mac[1], e->mac[2],
401 e->mac[3], e->mac[4], e->mac[5]);
403 lua_pushstring(L, macstr);
404 lua_setfield(L, -2, "bssid");
409 lua_pushstring(L, (char *) e->ssid);
410 lua_setfield(L, -2, "ssid");
414 lua_pushinteger(L, e->channel);
415 lua_setfield(L, -2, "channel");
418 lua_pushstring(L, IWINFO_OPMODE_NAMES[e->mode]);
419 lua_setfield(L, -2, "mode");
421 /* Quality, Signal */
422 lua_pushinteger(L, e->quality);
423 lua_setfield(L, -2, "quality");
425 lua_pushinteger(L, e->quality_max);
426 lua_setfield(L, -2, "quality_max");
428 lua_pushnumber(L, (e->signal - 0x100));
429 lua_setfield(L, -2, "signal");
432 iwinfo_L_cryptotable(L, &e->crypto);
433 lua_setfield(L, -2, "encryption");
435 lua_rawseti(L, -2, x);
442 /* Wrapper for frequency list */
443 static int iwinfo_L_freqlist(lua_State *L, int (*func)(const char *, char *, int *))
446 char rv[IWINFO_BUFSIZE];
447 const char *ifname = luaL_checkstring(L, 1);
448 struct iwinfo_freqlist_entry *e;
451 memset(rv, 0, sizeof(rv));
453 if (!(*func)(ifname, rv, &len))
455 for (i = 0, x = 1; i < len; i += sizeof(struct iwinfo_freqlist_entry), x++)
457 e = (struct iwinfo_freqlist_entry *) &rv[i];
462 lua_pushinteger(L, e->mhz);
463 lua_setfield(L, -2, "mhz");
466 lua_pushinteger(L, e->channel);
467 lua_setfield(L, -2, "channel");
469 /* Restricted (DFS/TPC/Radar) */
470 lua_pushboolean(L, e->restricted);
471 lua_setfield(L, -2, "restricted");
473 lua_rawseti(L, -2, x);
480 /* Wrapper for crypto settings */
481 static int iwinfo_L_encryption(lua_State *L, int (*func)(const char *, char *))
483 const char *ifname = luaL_checkstring(L, 1);
484 struct iwinfo_crypto_entry c = { 0 };
486 if (!(*func)(ifname, (char *)&c))
488 iwinfo_L_cryptotable(L, &c);
496 /* Wrapper for hwmode list */
497 static int iwinfo_L_hwmodelist(lua_State *L, int (*func)(const char *, int *))
499 const char *ifname = luaL_checkstring(L, 1);
502 if (!(*func)(ifname, &hwmodes))
506 lua_pushboolean(L, hwmodes & IWINFO_80211_A);
507 lua_setfield(L, -2, "a");
509 lua_pushboolean(L, hwmodes & IWINFO_80211_B);
510 lua_setfield(L, -2, "b");
512 lua_pushboolean(L, hwmodes & IWINFO_80211_G);
513 lua_setfield(L, -2, "g");
515 lua_pushboolean(L, hwmodes & IWINFO_80211_N);
516 lua_setfield(L, -2, "n");
518 lua_pushboolean(L, hwmodes & IWINFO_80211_AC);
519 lua_setfield(L, -2, "ac");
521 lua_pushboolean(L, hwmodes & IWINFO_80211_AD);
522 lua_setfield(L, -2, "ad");
531 /* Wrapper for htmode list */
532 static int iwinfo_L_htmodelist(lua_State *L, int (*func)(const char *, int *))
534 const char *ifname = luaL_checkstring(L, 1);
537 if (!(*func)(ifname, &htmodes))
541 for (i = 0; i < ARRAY_SIZE(IWINFO_HTMODE_NAMES); i++)
543 lua_pushboolean(L, htmodes & (1 << i));
544 lua_setfield(L, -2, IWINFO_HTMODE_NAMES[i]);
554 /* Wrapper for mbssid_support */
555 static int iwinfo_L_mbssid_support(lua_State *L, int (*func)(const char *, int *))
557 const char *ifname = luaL_checkstring(L, 1);
560 if (!(*func)(ifname, &support))
562 lua_pushboolean(L, support);
570 /* Wrapper for hardware_id */
571 static int iwinfo_L_hardware_id(lua_State *L, int (*func)(const char *, char *))
573 const char *ifname = luaL_checkstring(L, 1);
574 struct iwinfo_hardware_id ids;
576 if (!(*func)(ifname, (char *)&ids))
580 lua_pushnumber(L, ids.vendor_id);
581 lua_setfield(L, -2, "vendor_id");
583 lua_pushnumber(L, ids.device_id);
584 lua_setfield(L, -2, "device_id");
586 lua_pushnumber(L, ids.subsystem_vendor_id);
587 lua_setfield(L, -2, "subsystem_vendor_id");
589 lua_pushnumber(L, ids.subsystem_device_id);
590 lua_setfield(L, -2, "subsystem_device_id");
600 /* Wrapper for country list */
601 static char * iwinfo_L_country_lookup(char *buf, int len, int iso3166)
604 struct iwinfo_country_entry *c;
606 for (i = 0; i < len; i += sizeof(struct iwinfo_country_entry))
608 c = (struct iwinfo_country_entry *) &buf[i];
610 if (c->iso3166 == iso3166)
617 static int iwinfo_L_countrylist(lua_State *L, int (*func)(const char *, char *, int *))
620 char rv[IWINFO_BUFSIZE], alpha2[3];
622 const char *ifname = luaL_checkstring(L, 1);
623 const struct iwinfo_iso3166_label *l;
626 memset(rv, 0, sizeof(rv));
628 if (!(*func)(ifname, rv, &len))
630 for (l = IWINFO_ISO3166_NAMES, i = 1; l->iso3166; l++)
632 if ((ccode = iwinfo_L_country_lookup(rv, len, l->iso3166)) != NULL)
634 sprintf(alpha2, "%c%c",
635 (l->iso3166 / 256), (l->iso3166 % 256));
639 lua_pushstring(L, alpha2);
640 lua_setfield(L, -2, "alpha2");
642 lua_pushstring(L, ccode);
643 lua_setfield(L, -2, "ccode");
645 lua_pushstring(L, l->name);
646 lua_setfield(L, -2, "name");
648 lua_rawseti(L, -2, i++);
659 LUA_WRAP_INT_OP(wl,channel)
660 LUA_WRAP_INT_OP(wl,frequency)
661 LUA_WRAP_INT_OP(wl,frequency_offset)
662 LUA_WRAP_INT_OP(wl,txpower)
663 LUA_WRAP_INT_OP(wl,txpower_offset)
664 LUA_WRAP_INT_OP(wl,bitrate)
665 LUA_WRAP_INT_OP(wl,signal)
666 LUA_WRAP_INT_OP(wl,noise)
667 LUA_WRAP_INT_OP(wl,quality)
668 LUA_WRAP_INT_OP(wl,quality_max)
669 LUA_WRAP_STRING_OP(wl,ssid)
670 LUA_WRAP_STRING_OP(wl,bssid)
671 LUA_WRAP_STRING_OP(wl,country)
672 LUA_WRAP_STRING_OP(wl,hardware_name)
673 LUA_WRAP_STRING_OP(wl,phyname)
674 LUA_WRAP_STRUCT_OP(wl,mode)
675 LUA_WRAP_STRUCT_OP(wl,assoclist)
676 LUA_WRAP_STRUCT_OP(wl,txpwrlist)
677 LUA_WRAP_STRUCT_OP(wl,scanlist)
678 LUA_WRAP_STRUCT_OP(wl,freqlist)
679 LUA_WRAP_STRUCT_OP(wl,countrylist)
680 LUA_WRAP_STRUCT_OP(wl,hwmodelist)
681 LUA_WRAP_STRUCT_OP(wl,htmodelist)
682 LUA_WRAP_STRUCT_OP(wl,encryption)
683 LUA_WRAP_STRUCT_OP(wl,mbssid_support)
684 LUA_WRAP_STRUCT_OP(wl,hardware_id)
689 LUA_WRAP_INT_OP(madwifi,channel)
690 LUA_WRAP_INT_OP(madwifi,frequency)
691 LUA_WRAP_INT_OP(madwifi,frequency_offset)
692 LUA_WRAP_INT_OP(madwifi,txpower)
693 LUA_WRAP_INT_OP(madwifi,txpower_offset)
694 LUA_WRAP_INT_OP(madwifi,bitrate)
695 LUA_WRAP_INT_OP(madwifi,signal)
696 LUA_WRAP_INT_OP(madwifi,noise)
697 LUA_WRAP_INT_OP(madwifi,quality)
698 LUA_WRAP_INT_OP(madwifi,quality_max)
699 LUA_WRAP_STRING_OP(madwifi,ssid)
700 LUA_WRAP_STRING_OP(madwifi,bssid)
701 LUA_WRAP_STRING_OP(madwifi,country)
702 LUA_WRAP_STRING_OP(madwifi,hardware_name)
703 LUA_WRAP_STRING_OP(madwifi,phyname)
704 LUA_WRAP_STRUCT_OP(madwifi,mode)
705 LUA_WRAP_STRUCT_OP(madwifi,assoclist)
706 LUA_WRAP_STRUCT_OP(madwifi,txpwrlist)
707 LUA_WRAP_STRUCT_OP(madwifi,scanlist)
708 LUA_WRAP_STRUCT_OP(madwifi,freqlist)
709 LUA_WRAP_STRUCT_OP(madwifi,countrylist)
710 LUA_WRAP_STRUCT_OP(madwifi,hwmodelist)
711 LUA_WRAP_STRUCT_OP(madwifi,htmodelist)
712 LUA_WRAP_STRUCT_OP(madwifi,encryption)
713 LUA_WRAP_STRUCT_OP(madwifi,mbssid_support)
714 LUA_WRAP_STRUCT_OP(madwifi,hardware_id)
719 LUA_WRAP_INT_OP(nl80211,channel)
720 LUA_WRAP_INT_OP(nl80211,frequency)
721 LUA_WRAP_INT_OP(nl80211,frequency_offset)
722 LUA_WRAP_INT_OP(nl80211,txpower)
723 LUA_WRAP_INT_OP(nl80211,txpower_offset)
724 LUA_WRAP_INT_OP(nl80211,bitrate)
725 LUA_WRAP_INT_OP(nl80211,signal)
726 LUA_WRAP_INT_OP(nl80211,noise)
727 LUA_WRAP_INT_OP(nl80211,quality)
728 LUA_WRAP_INT_OP(nl80211,quality_max)
729 LUA_WRAP_STRING_OP(nl80211,ssid)
730 LUA_WRAP_STRING_OP(nl80211,bssid)
731 LUA_WRAP_STRING_OP(nl80211,country)
732 LUA_WRAP_STRING_OP(nl80211,hardware_name)
733 LUA_WRAP_STRING_OP(nl80211,phyname)
734 LUA_WRAP_STRUCT_OP(nl80211,mode)
735 LUA_WRAP_STRUCT_OP(nl80211,assoclist)
736 LUA_WRAP_STRUCT_OP(nl80211,txpwrlist)
737 LUA_WRAP_STRUCT_OP(nl80211,scanlist)
738 LUA_WRAP_STRUCT_OP(nl80211,freqlist)
739 LUA_WRAP_STRUCT_OP(nl80211,countrylist)
740 LUA_WRAP_STRUCT_OP(nl80211,hwmodelist)
741 LUA_WRAP_STRUCT_OP(nl80211,htmodelist)
742 LUA_WRAP_STRUCT_OP(nl80211,encryption)
743 LUA_WRAP_STRUCT_OP(nl80211,mbssid_support)
744 LUA_WRAP_STRUCT_OP(nl80211,hardware_id)
748 LUA_WRAP_INT_OP(wext,channel)
749 LUA_WRAP_INT_OP(wext,frequency)
750 LUA_WRAP_INT_OP(wext,frequency_offset)
751 LUA_WRAP_INT_OP(wext,txpower)
752 LUA_WRAP_INT_OP(wext,txpower_offset)
753 LUA_WRAP_INT_OP(wext,bitrate)
754 LUA_WRAP_INT_OP(wext,signal)
755 LUA_WRAP_INT_OP(wext,noise)
756 LUA_WRAP_INT_OP(wext,quality)
757 LUA_WRAP_INT_OP(wext,quality_max)
758 LUA_WRAP_STRING_OP(wext,ssid)
759 LUA_WRAP_STRING_OP(wext,bssid)
760 LUA_WRAP_STRING_OP(wext,country)
761 LUA_WRAP_STRING_OP(wext,hardware_name)
762 LUA_WRAP_STRING_OP(wext,phyname)
763 LUA_WRAP_STRUCT_OP(wext,mode)
764 LUA_WRAP_STRUCT_OP(wext,assoclist)
765 LUA_WRAP_STRUCT_OP(wext,txpwrlist)
766 LUA_WRAP_STRUCT_OP(wext,scanlist)
767 LUA_WRAP_STRUCT_OP(wext,freqlist)
768 LUA_WRAP_STRUCT_OP(wext,countrylist)
769 LUA_WRAP_STRUCT_OP(wext,hwmodelist)
770 LUA_WRAP_STRUCT_OP(wext,htmodelist)
771 LUA_WRAP_STRUCT_OP(wext,encryption)
772 LUA_WRAP_STRUCT_OP(wext,mbssid_support)
773 LUA_WRAP_STRUCT_OP(wext,hardware_id)
777 static const luaL_reg R_wl[] = {
779 LUA_REG(wl,frequency),
780 LUA_REG(wl,frequency_offset),
782 LUA_REG(wl,txpower_offset),
787 LUA_REG(wl,quality_max),
792 LUA_REG(wl,assoclist),
793 LUA_REG(wl,txpwrlist),
794 LUA_REG(wl,scanlist),
795 LUA_REG(wl,freqlist),
796 LUA_REG(wl,countrylist),
797 LUA_REG(wl,hwmodelist),
798 LUA_REG(wl,htmodelist),
799 LUA_REG(wl,encryption),
800 LUA_REG(wl,mbssid_support),
801 LUA_REG(wl,hardware_id),
802 LUA_REG(wl,hardware_name),
810 static const luaL_reg R_madwifi[] = {
811 LUA_REG(madwifi,channel),
812 LUA_REG(madwifi,frequency),
813 LUA_REG(madwifi,frequency_offset),
814 LUA_REG(madwifi,txpower),
815 LUA_REG(madwifi,txpower_offset),
816 LUA_REG(madwifi,bitrate),
817 LUA_REG(madwifi,signal),
818 LUA_REG(madwifi,noise),
819 LUA_REG(madwifi,quality),
820 LUA_REG(madwifi,quality_max),
821 LUA_REG(madwifi,mode),
822 LUA_REG(madwifi,ssid),
823 LUA_REG(madwifi,bssid),
824 LUA_REG(madwifi,country),
825 LUA_REG(madwifi,assoclist),
826 LUA_REG(madwifi,txpwrlist),
827 LUA_REG(madwifi,scanlist),
828 LUA_REG(madwifi,freqlist),
829 LUA_REG(madwifi,countrylist),
830 LUA_REG(madwifi,hwmodelist),
831 LUA_REG(madwifi,htmodelist),
832 LUA_REG(madwifi,encryption),
833 LUA_REG(madwifi,mbssid_support),
834 LUA_REG(madwifi,hardware_id),
835 LUA_REG(madwifi,hardware_name),
836 LUA_REG(madwifi,phyname),
843 static const luaL_reg R_nl80211[] = {
844 LUA_REG(nl80211,channel),
845 LUA_REG(nl80211,frequency),
846 LUA_REG(nl80211,frequency_offset),
847 LUA_REG(nl80211,txpower),
848 LUA_REG(nl80211,txpower_offset),
849 LUA_REG(nl80211,bitrate),
850 LUA_REG(nl80211,signal),
851 LUA_REG(nl80211,noise),
852 LUA_REG(nl80211,quality),
853 LUA_REG(nl80211,quality_max),
854 LUA_REG(nl80211,mode),
855 LUA_REG(nl80211,ssid),
856 LUA_REG(nl80211,bssid),
857 LUA_REG(nl80211,country),
858 LUA_REG(nl80211,assoclist),
859 LUA_REG(nl80211,txpwrlist),
860 LUA_REG(nl80211,scanlist),
861 LUA_REG(nl80211,freqlist),
862 LUA_REG(nl80211,countrylist),
863 LUA_REG(nl80211,hwmodelist),
864 LUA_REG(nl80211,htmodelist),
865 LUA_REG(nl80211,encryption),
866 LUA_REG(nl80211,mbssid_support),
867 LUA_REG(nl80211,hardware_id),
868 LUA_REG(nl80211,hardware_name),
869 LUA_REG(nl80211,phyname),
875 static const luaL_reg R_wext[] = {
876 LUA_REG(wext,channel),
877 LUA_REG(wext,frequency),
878 LUA_REG(wext,frequency_offset),
879 LUA_REG(wext,txpower),
880 LUA_REG(wext,txpower_offset),
881 LUA_REG(wext,bitrate),
882 LUA_REG(wext,signal),
884 LUA_REG(wext,quality),
885 LUA_REG(wext,quality_max),
889 LUA_REG(wext,country),
890 LUA_REG(wext,assoclist),
891 LUA_REG(wext,txpwrlist),
892 LUA_REG(wext,scanlist),
893 LUA_REG(wext,freqlist),
894 LUA_REG(wext,countrylist),
895 LUA_REG(wext,hwmodelist),
896 LUA_REG(wext,htmodelist),
897 LUA_REG(wext,encryption),
898 LUA_REG(wext,mbssid_support),
899 LUA_REG(wext,hardware_id),
900 LUA_REG(wext,hardware_name),
901 LUA_REG(wext,phyname),
906 static const luaL_reg R_common[] = {
907 { "type", iwinfo_L_type },
908 { "__gc", iwinfo_L__gc },
913 LUALIB_API int luaopen_iwinfo(lua_State *L) {
914 luaL_register(L, IWINFO_META, R_common);
917 luaL_newmetatable(L, IWINFO_WL_META);
918 luaL_register(L, NULL, R_common);
919 luaL_register(L, NULL, R_wl);
920 lua_pushvalue(L, -1);
921 lua_setfield(L, -2, "__index");
922 lua_setfield(L, -2, "wl");
926 luaL_newmetatable(L, IWINFO_MADWIFI_META);
927 luaL_register(L, NULL, R_common);
928 luaL_register(L, NULL, R_madwifi);
929 lua_pushvalue(L, -1);
930 lua_setfield(L, -2, "__index");
931 lua_setfield(L, -2, "madwifi");
935 luaL_newmetatable(L, IWINFO_NL80211_META);
936 luaL_register(L, NULL, R_common);
937 luaL_register(L, NULL, R_nl80211);
938 lua_pushvalue(L, -1);
939 lua_setfield(L, -2, "__index");
940 lua_setfield(L, -2, "nl80211");
943 luaL_newmetatable(L, IWINFO_WEXT_META);
944 luaL_register(L, NULL, R_common);
945 luaL_register(L, NULL, R_wext);
946 lua_pushvalue(L, -1);
947 lua_setfield(L, -2, "__index");
948 lua_setfield(L, -2, "wext");