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 & IWINFO_KMGMT_SAE)
93 pos += sprintf(pos, "SAE/");
95 if (suites & IWINFO_KMGMT_OWE)
96 pos += sprintf(pos, "OWE/");
98 if (!suites || (suites & IWINFO_KMGMT_NONE))
99 pos += sprintf(pos, "NONE/");
106 static char * iwinfo_crypto_desc(struct iwinfo_crypto_entry *c)
108 static char desc[512] = { 0 };
117 if (c->auth_algs && !c->wpa_version)
119 if ((c->auth_algs & IWINFO_AUTH_OPEN) &&
120 (c->auth_algs & IWINFO_AUTH_SHARED))
122 sprintf(desc, "WEP Open/Shared (%s)",
123 iwinfo_crypto_print_ciphers(c->pair_ciphers));
125 else if (c->auth_algs & IWINFO_AUTH_OPEN)
127 sprintf(desc, "WEP Open System (%s)",
128 iwinfo_crypto_print_ciphers(c->pair_ciphers));
130 else if (c->auth_algs & IWINFO_AUTH_SHARED)
132 sprintf(desc, "WEP Shared Auth (%s)",
133 iwinfo_crypto_print_ciphers(c->pair_ciphers));
138 else if (c->wpa_version)
140 for (i = 0, n = 0; i < 3; i++)
141 if (c->wpa_version & (1 << i))
145 pos += sprintf(pos, "mixed ");
147 for (i = 0; i < 3; i++)
148 if (c->wpa_version & (1 << i))
150 pos += sprintf(pos, "WPA%d/", i + 1);
152 pos += sprintf(pos, "WPA/");
156 sprintf(pos, " %s (%s)",
157 iwinfo_crypto_print_suites(c->auth_suites),
158 iwinfo_crypto_print_ciphers(
159 c->pair_ciphers | c->group_ciphers));
163 sprintf(desc, "None");
168 sprintf(desc, "None");
173 sprintf(desc, "Unknown");
179 /* Build Lua table from crypto data */
180 static void iwinfo_L_cryptotable(lua_State *L, struct iwinfo_crypto_entry *c)
186 lua_pushboolean(L, c->enabled);
187 lua_setfield(L, -2, "enabled");
189 lua_pushstring(L, iwinfo_crypto_desc(c));
190 lua_setfield(L, -2, "description");
192 lua_pushboolean(L, (c->enabled && !c->wpa_version));
193 lua_setfield(L, -2, "wep");
195 lua_pushinteger(L, c->wpa_version);
196 lua_setfield(L, -2, "wpa");
199 for (i = 0, j = 1; i < ARRAY_SIZE(IWINFO_CIPHER_NAMES); i++)
201 if (c->pair_ciphers & (1 << i))
203 lua_pushstring(L, IWINFO_CIPHER_NAMES[i]);
204 lua_rawseti(L, -2, j++);
207 lua_setfield(L, -2, "pair_ciphers");
210 for (i = 0, j = 1; i < ARRAY_SIZE(IWINFO_CIPHER_NAMES); i++)
212 if (c->group_ciphers & (1 << i))
214 lua_pushstring(L, IWINFO_CIPHER_NAMES[i]);
215 lua_rawseti(L, -2, j++);
218 lua_setfield(L, -2, "group_ciphers");
221 for (i = 0, j = 1; i < ARRAY_SIZE(IWINFO_KMGMT_NAMES); i++)
223 if (c->auth_suites & (1 << i))
225 lua_pushstring(L, IWINFO_KMGMT_NAMES[i]);
226 lua_rawseti(L, -2, j++);
229 lua_setfield(L, -2, "auth_suites");
232 for (i = 0, j = 1; i < ARRAY_SIZE(IWINFO_AUTH_NAMES); i++)
234 if (c->auth_algs & (1 << i))
236 lua_pushstring(L, IWINFO_AUTH_NAMES[i]);
237 lua_rawseti(L, -2, j++);
240 lua_setfield(L, -2, "auth_algs");
244 /* Wrapper for mode */
245 static int iwinfo_L_mode(lua_State *L, int (*func)(const char *, int *))
248 const char *ifname = luaL_checkstring(L, 1);
250 if ((*func)(ifname, &mode))
251 mode = IWINFO_OPMODE_UNKNOWN;
253 lua_pushstring(L, IWINFO_OPMODE_NAMES[mode]);
257 static void set_rateinfo(lua_State *L, struct iwinfo_rate_entry *r, bool rx)
259 lua_pushnumber(L, r->rate);
260 lua_setfield(L, -2, rx ? "rx_rate" : "tx_rate");
262 lua_pushboolean(L, r->is_ht);
263 lua_setfield(L, -2, rx ? "rx_ht" : "tx_ht");
265 lua_pushboolean(L, r->is_vht);
266 lua_setfield(L, -2, rx ? "rx_vht" : "tx_vht");
268 lua_pushnumber(L, r->mhz);
269 lua_setfield(L, -2, rx ? "rx_mhz" : "tx_mhz");
273 lua_pushboolean(L, r->is_40mhz);
274 lua_setfield(L, -2, rx ? "rx_40mhz" : "tx_40mhz");
276 lua_pushnumber(L, r->mcs);
277 lua_setfield(L, -2, rx ? "rx_mcs" : "tx_mcs");
279 lua_pushboolean(L, r->is_short_gi);
280 lua_setfield(L, -2, rx ? "rx_short_gi" : "tx_short_gi");
284 lua_pushnumber(L, r->mcs);
285 lua_setfield(L, -2, rx ? "rx_mcs" : "tx_mcs");
287 lua_pushnumber(L, r->nss);
288 lua_setfield(L, -2, rx ? "rx_nss" : "tx_nss");
290 lua_pushboolean(L, r->is_short_gi);
291 lua_setfield(L, -2, rx ? "rx_short_gi" : "tx_short_gi");
295 /* Wrapper for assoclist */
296 static int iwinfo_L_assoclist(lua_State *L, int (*func)(const char *, char *, int *))
299 char rv[IWINFO_BUFSIZE];
301 const char *ifname = luaL_checkstring(L, 1);
302 struct iwinfo_assoclist_entry *e;
305 memset(rv, 0, sizeof(rv));
307 if (!(*func)(ifname, rv, &len))
309 for (i = 0; i < len; i += sizeof(struct iwinfo_assoclist_entry))
311 e = (struct iwinfo_assoclist_entry *) &rv[i];
313 sprintf(macstr, "%02X:%02X:%02X:%02X:%02X:%02X",
314 e->mac[0], e->mac[1], e->mac[2],
315 e->mac[3], e->mac[4], e->mac[5]);
319 lua_pushnumber(L, e->signal);
320 lua_setfield(L, -2, "signal");
322 lua_pushnumber(L, e->noise);
323 lua_setfield(L, -2, "noise");
325 lua_pushnumber(L, e->inactive);
326 lua_setfield(L, -2, "inactive");
328 lua_pushnumber(L, e->rx_packets);
329 lua_setfield(L, -2, "rx_packets");
331 lua_pushnumber(L, e->tx_packets);
332 lua_setfield(L, -2, "tx_packets");
334 set_rateinfo(L, &e->rx_rate, true);
335 set_rateinfo(L, &e->tx_rate, false);
338 lua_pushnumber(L, e->thr);
339 lua_setfield(L, -2, "expected_throughput");
342 lua_setfield(L, -2, macstr);
349 /* Wrapper for tx power list */
350 static int iwinfo_L_txpwrlist(lua_State *L, int (*func)(const char *, char *, int *))
353 char rv[IWINFO_BUFSIZE];
354 const char *ifname = luaL_checkstring(L, 1);
355 struct iwinfo_txpwrlist_entry *e;
357 memset(rv, 0, sizeof(rv));
359 if (!(*func)(ifname, rv, &len))
363 for (i = 0, x = 1; i < len; i += sizeof(struct iwinfo_txpwrlist_entry), x++)
365 e = (struct iwinfo_txpwrlist_entry *) &rv[i];
369 lua_pushnumber(L, e->mw);
370 lua_setfield(L, -2, "mw");
372 lua_pushnumber(L, e->dbm);
373 lua_setfield(L, -2, "dbm");
375 lua_rawseti(L, -2, x);
384 /* Wrapper for scan list */
385 static int iwinfo_L_scanlist(lua_State *L, int (*func)(const char *, char *, int *))
388 char rv[IWINFO_BUFSIZE];
390 const char *ifname = luaL_checkstring(L, 1);
391 struct iwinfo_scanlist_entry *e;
394 memset(rv, 0, sizeof(rv));
396 if (!(*func)(ifname, rv, &len))
398 for (i = 0, x = 1; i < len; i += sizeof(struct iwinfo_scanlist_entry), x++)
400 e = (struct iwinfo_scanlist_entry *) &rv[i];
405 sprintf(macstr, "%02X:%02X:%02X:%02X:%02X:%02X",
406 e->mac[0], e->mac[1], e->mac[2],
407 e->mac[3], e->mac[4], e->mac[5]);
409 lua_pushstring(L, macstr);
410 lua_setfield(L, -2, "bssid");
415 lua_pushstring(L, (char *) e->ssid);
416 lua_setfield(L, -2, "ssid");
420 lua_pushinteger(L, e->channel);
421 lua_setfield(L, -2, "channel");
424 lua_pushstring(L, IWINFO_OPMODE_NAMES[e->mode]);
425 lua_setfield(L, -2, "mode");
427 /* Quality, Signal */
428 lua_pushinteger(L, e->quality);
429 lua_setfield(L, -2, "quality");
431 lua_pushinteger(L, e->quality_max);
432 lua_setfield(L, -2, "quality_max");
434 lua_pushnumber(L, (e->signal - 0x100));
435 lua_setfield(L, -2, "signal");
438 iwinfo_L_cryptotable(L, &e->crypto);
439 lua_setfield(L, -2, "encryption");
441 lua_rawseti(L, -2, x);
448 /* Wrapper for frequency list */
449 static int iwinfo_L_freqlist(lua_State *L, int (*func)(const char *, char *, int *))
452 char rv[IWINFO_BUFSIZE];
453 const char *ifname = luaL_checkstring(L, 1);
454 struct iwinfo_freqlist_entry *e;
457 memset(rv, 0, sizeof(rv));
459 if (!(*func)(ifname, rv, &len))
461 for (i = 0, x = 1; i < len; i += sizeof(struct iwinfo_freqlist_entry), x++)
463 e = (struct iwinfo_freqlist_entry *) &rv[i];
468 lua_pushinteger(L, e->mhz);
469 lua_setfield(L, -2, "mhz");
472 lua_pushinteger(L, e->channel);
473 lua_setfield(L, -2, "channel");
475 /* Restricted (DFS/TPC/Radar) */
476 lua_pushboolean(L, e->restricted);
477 lua_setfield(L, -2, "restricted");
479 lua_rawseti(L, -2, x);
486 /* Wrapper for crypto settings */
487 static int iwinfo_L_encryption(lua_State *L, int (*func)(const char *, char *))
489 const char *ifname = luaL_checkstring(L, 1);
490 struct iwinfo_crypto_entry c = { 0 };
492 if (!(*func)(ifname, (char *)&c))
494 iwinfo_L_cryptotable(L, &c);
502 /* Wrapper for hwmode list */
503 static int iwinfo_L_hwmodelist(lua_State *L, int (*func)(const char *, int *))
505 const char *ifname = luaL_checkstring(L, 1);
508 if (!(*func)(ifname, &hwmodes))
512 lua_pushboolean(L, hwmodes & IWINFO_80211_A);
513 lua_setfield(L, -2, "a");
515 lua_pushboolean(L, hwmodes & IWINFO_80211_B);
516 lua_setfield(L, -2, "b");
518 lua_pushboolean(L, hwmodes & IWINFO_80211_G);
519 lua_setfield(L, -2, "g");
521 lua_pushboolean(L, hwmodes & IWINFO_80211_N);
522 lua_setfield(L, -2, "n");
524 lua_pushboolean(L, hwmodes & IWINFO_80211_AC);
525 lua_setfield(L, -2, "ac");
527 lua_pushboolean(L, hwmodes & IWINFO_80211_AD);
528 lua_setfield(L, -2, "ad");
537 /* Wrapper for htmode list */
538 static int iwinfo_L_htmodelist(lua_State *L, int (*func)(const char *, int *))
540 const char *ifname = luaL_checkstring(L, 1);
543 if (!(*func)(ifname, &htmodes))
547 for (i = 0; i < ARRAY_SIZE(IWINFO_HTMODE_NAMES); i++)
549 lua_pushboolean(L, htmodes & (1 << i));
550 lua_setfield(L, -2, IWINFO_HTMODE_NAMES[i]);
560 /* Wrapper for mbssid_support */
561 static int iwinfo_L_mbssid_support(lua_State *L, int (*func)(const char *, int *))
563 const char *ifname = luaL_checkstring(L, 1);
566 if (!(*func)(ifname, &support))
568 lua_pushboolean(L, support);
576 /* Wrapper for hardware_id */
577 static int iwinfo_L_hardware_id(lua_State *L, int (*func)(const char *, char *))
579 const char *ifname = luaL_checkstring(L, 1);
580 struct iwinfo_hardware_id ids;
582 if (!(*func)(ifname, (char *)&ids))
586 lua_pushnumber(L, ids.vendor_id);
587 lua_setfield(L, -2, "vendor_id");
589 lua_pushnumber(L, ids.device_id);
590 lua_setfield(L, -2, "device_id");
592 lua_pushnumber(L, ids.subsystem_vendor_id);
593 lua_setfield(L, -2, "subsystem_vendor_id");
595 lua_pushnumber(L, ids.subsystem_device_id);
596 lua_setfield(L, -2, "subsystem_device_id");
606 /* Wrapper for country list */
607 static char * iwinfo_L_country_lookup(char *buf, int len, int iso3166)
610 struct iwinfo_country_entry *c;
612 for (i = 0; i < len; i += sizeof(struct iwinfo_country_entry))
614 c = (struct iwinfo_country_entry *) &buf[i];
616 if (c->iso3166 == iso3166)
623 static int iwinfo_L_countrylist(lua_State *L, int (*func)(const char *, char *, int *))
626 char rv[IWINFO_BUFSIZE], alpha2[3];
628 const char *ifname = luaL_checkstring(L, 1);
629 const struct iwinfo_iso3166_label *l;
632 memset(rv, 0, sizeof(rv));
634 if (!(*func)(ifname, rv, &len))
636 for (l = IWINFO_ISO3166_NAMES, i = 1; l->iso3166; l++)
638 if ((ccode = iwinfo_L_country_lookup(rv, len, l->iso3166)) != NULL)
640 sprintf(alpha2, "%c%c",
641 (l->iso3166 / 256), (l->iso3166 % 256));
645 lua_pushstring(L, alpha2);
646 lua_setfield(L, -2, "alpha2");
648 lua_pushstring(L, ccode);
649 lua_setfield(L, -2, "ccode");
651 lua_pushstring(L, l->name);
652 lua_setfield(L, -2, "name");
654 lua_rawseti(L, -2, i++);
665 LUA_WRAP_INT_OP(wl,channel)
666 LUA_WRAP_INT_OP(wl,frequency)
667 LUA_WRAP_INT_OP(wl,frequency_offset)
668 LUA_WRAP_INT_OP(wl,txpower)
669 LUA_WRAP_INT_OP(wl,txpower_offset)
670 LUA_WRAP_INT_OP(wl,bitrate)
671 LUA_WRAP_INT_OP(wl,signal)
672 LUA_WRAP_INT_OP(wl,noise)
673 LUA_WRAP_INT_OP(wl,quality)
674 LUA_WRAP_INT_OP(wl,quality_max)
675 LUA_WRAP_STRING_OP(wl,ssid)
676 LUA_WRAP_STRING_OP(wl,bssid)
677 LUA_WRAP_STRING_OP(wl,country)
678 LUA_WRAP_STRING_OP(wl,hardware_name)
679 LUA_WRAP_STRING_OP(wl,phyname)
680 LUA_WRAP_STRUCT_OP(wl,mode)
681 LUA_WRAP_STRUCT_OP(wl,assoclist)
682 LUA_WRAP_STRUCT_OP(wl,txpwrlist)
683 LUA_WRAP_STRUCT_OP(wl,scanlist)
684 LUA_WRAP_STRUCT_OP(wl,freqlist)
685 LUA_WRAP_STRUCT_OP(wl,countrylist)
686 LUA_WRAP_STRUCT_OP(wl,hwmodelist)
687 LUA_WRAP_STRUCT_OP(wl,htmodelist)
688 LUA_WRAP_STRUCT_OP(wl,encryption)
689 LUA_WRAP_STRUCT_OP(wl,mbssid_support)
690 LUA_WRAP_STRUCT_OP(wl,hardware_id)
695 LUA_WRAP_INT_OP(madwifi,channel)
696 LUA_WRAP_INT_OP(madwifi,frequency)
697 LUA_WRAP_INT_OP(madwifi,frequency_offset)
698 LUA_WRAP_INT_OP(madwifi,txpower)
699 LUA_WRAP_INT_OP(madwifi,txpower_offset)
700 LUA_WRAP_INT_OP(madwifi,bitrate)
701 LUA_WRAP_INT_OP(madwifi,signal)
702 LUA_WRAP_INT_OP(madwifi,noise)
703 LUA_WRAP_INT_OP(madwifi,quality)
704 LUA_WRAP_INT_OP(madwifi,quality_max)
705 LUA_WRAP_STRING_OP(madwifi,ssid)
706 LUA_WRAP_STRING_OP(madwifi,bssid)
707 LUA_WRAP_STRING_OP(madwifi,country)
708 LUA_WRAP_STRING_OP(madwifi,hardware_name)
709 LUA_WRAP_STRING_OP(madwifi,phyname)
710 LUA_WRAP_STRUCT_OP(madwifi,mode)
711 LUA_WRAP_STRUCT_OP(madwifi,assoclist)
712 LUA_WRAP_STRUCT_OP(madwifi,txpwrlist)
713 LUA_WRAP_STRUCT_OP(madwifi,scanlist)
714 LUA_WRAP_STRUCT_OP(madwifi,freqlist)
715 LUA_WRAP_STRUCT_OP(madwifi,countrylist)
716 LUA_WRAP_STRUCT_OP(madwifi,hwmodelist)
717 LUA_WRAP_STRUCT_OP(madwifi,htmodelist)
718 LUA_WRAP_STRUCT_OP(madwifi,encryption)
719 LUA_WRAP_STRUCT_OP(madwifi,mbssid_support)
720 LUA_WRAP_STRUCT_OP(madwifi,hardware_id)
725 LUA_WRAP_INT_OP(nl80211,channel)
726 LUA_WRAP_INT_OP(nl80211,frequency)
727 LUA_WRAP_INT_OP(nl80211,frequency_offset)
728 LUA_WRAP_INT_OP(nl80211,txpower)
729 LUA_WRAP_INT_OP(nl80211,txpower_offset)
730 LUA_WRAP_INT_OP(nl80211,bitrate)
731 LUA_WRAP_INT_OP(nl80211,signal)
732 LUA_WRAP_INT_OP(nl80211,noise)
733 LUA_WRAP_INT_OP(nl80211,quality)
734 LUA_WRAP_INT_OP(nl80211,quality_max)
735 LUA_WRAP_STRING_OP(nl80211,ssid)
736 LUA_WRAP_STRING_OP(nl80211,bssid)
737 LUA_WRAP_STRING_OP(nl80211,country)
738 LUA_WRAP_STRING_OP(nl80211,hardware_name)
739 LUA_WRAP_STRING_OP(nl80211,phyname)
740 LUA_WRAP_STRUCT_OP(nl80211,mode)
741 LUA_WRAP_STRUCT_OP(nl80211,assoclist)
742 LUA_WRAP_STRUCT_OP(nl80211,txpwrlist)
743 LUA_WRAP_STRUCT_OP(nl80211,scanlist)
744 LUA_WRAP_STRUCT_OP(nl80211,freqlist)
745 LUA_WRAP_STRUCT_OP(nl80211,countrylist)
746 LUA_WRAP_STRUCT_OP(nl80211,hwmodelist)
747 LUA_WRAP_STRUCT_OP(nl80211,htmodelist)
748 LUA_WRAP_STRUCT_OP(nl80211,encryption)
749 LUA_WRAP_STRUCT_OP(nl80211,mbssid_support)
750 LUA_WRAP_STRUCT_OP(nl80211,hardware_id)
754 LUA_WRAP_INT_OP(wext,channel)
755 LUA_WRAP_INT_OP(wext,frequency)
756 LUA_WRAP_INT_OP(wext,frequency_offset)
757 LUA_WRAP_INT_OP(wext,txpower)
758 LUA_WRAP_INT_OP(wext,txpower_offset)
759 LUA_WRAP_INT_OP(wext,bitrate)
760 LUA_WRAP_INT_OP(wext,signal)
761 LUA_WRAP_INT_OP(wext,noise)
762 LUA_WRAP_INT_OP(wext,quality)
763 LUA_WRAP_INT_OP(wext,quality_max)
764 LUA_WRAP_STRING_OP(wext,ssid)
765 LUA_WRAP_STRING_OP(wext,bssid)
766 LUA_WRAP_STRING_OP(wext,country)
767 LUA_WRAP_STRING_OP(wext,hardware_name)
768 LUA_WRAP_STRING_OP(wext,phyname)
769 LUA_WRAP_STRUCT_OP(wext,mode)
770 LUA_WRAP_STRUCT_OP(wext,assoclist)
771 LUA_WRAP_STRUCT_OP(wext,txpwrlist)
772 LUA_WRAP_STRUCT_OP(wext,scanlist)
773 LUA_WRAP_STRUCT_OP(wext,freqlist)
774 LUA_WRAP_STRUCT_OP(wext,countrylist)
775 LUA_WRAP_STRUCT_OP(wext,hwmodelist)
776 LUA_WRAP_STRUCT_OP(wext,htmodelist)
777 LUA_WRAP_STRUCT_OP(wext,encryption)
778 LUA_WRAP_STRUCT_OP(wext,mbssid_support)
779 LUA_WRAP_STRUCT_OP(wext,hardware_id)
783 static const luaL_reg R_wl[] = {
785 LUA_REG(wl,frequency),
786 LUA_REG(wl,frequency_offset),
788 LUA_REG(wl,txpower_offset),
793 LUA_REG(wl,quality_max),
798 LUA_REG(wl,assoclist),
799 LUA_REG(wl,txpwrlist),
800 LUA_REG(wl,scanlist),
801 LUA_REG(wl,freqlist),
802 LUA_REG(wl,countrylist),
803 LUA_REG(wl,hwmodelist),
804 LUA_REG(wl,htmodelist),
805 LUA_REG(wl,encryption),
806 LUA_REG(wl,mbssid_support),
807 LUA_REG(wl,hardware_id),
808 LUA_REG(wl,hardware_name),
816 static const luaL_reg R_madwifi[] = {
817 LUA_REG(madwifi,channel),
818 LUA_REG(madwifi,frequency),
819 LUA_REG(madwifi,frequency_offset),
820 LUA_REG(madwifi,txpower),
821 LUA_REG(madwifi,txpower_offset),
822 LUA_REG(madwifi,bitrate),
823 LUA_REG(madwifi,signal),
824 LUA_REG(madwifi,noise),
825 LUA_REG(madwifi,quality),
826 LUA_REG(madwifi,quality_max),
827 LUA_REG(madwifi,mode),
828 LUA_REG(madwifi,ssid),
829 LUA_REG(madwifi,bssid),
830 LUA_REG(madwifi,country),
831 LUA_REG(madwifi,assoclist),
832 LUA_REG(madwifi,txpwrlist),
833 LUA_REG(madwifi,scanlist),
834 LUA_REG(madwifi,freqlist),
835 LUA_REG(madwifi,countrylist),
836 LUA_REG(madwifi,hwmodelist),
837 LUA_REG(madwifi,htmodelist),
838 LUA_REG(madwifi,encryption),
839 LUA_REG(madwifi,mbssid_support),
840 LUA_REG(madwifi,hardware_id),
841 LUA_REG(madwifi,hardware_name),
842 LUA_REG(madwifi,phyname),
849 static const luaL_reg R_nl80211[] = {
850 LUA_REG(nl80211,channel),
851 LUA_REG(nl80211,frequency),
852 LUA_REG(nl80211,frequency_offset),
853 LUA_REG(nl80211,txpower),
854 LUA_REG(nl80211,txpower_offset),
855 LUA_REG(nl80211,bitrate),
856 LUA_REG(nl80211,signal),
857 LUA_REG(nl80211,noise),
858 LUA_REG(nl80211,quality),
859 LUA_REG(nl80211,quality_max),
860 LUA_REG(nl80211,mode),
861 LUA_REG(nl80211,ssid),
862 LUA_REG(nl80211,bssid),
863 LUA_REG(nl80211,country),
864 LUA_REG(nl80211,assoclist),
865 LUA_REG(nl80211,txpwrlist),
866 LUA_REG(nl80211,scanlist),
867 LUA_REG(nl80211,freqlist),
868 LUA_REG(nl80211,countrylist),
869 LUA_REG(nl80211,hwmodelist),
870 LUA_REG(nl80211,htmodelist),
871 LUA_REG(nl80211,encryption),
872 LUA_REG(nl80211,mbssid_support),
873 LUA_REG(nl80211,hardware_id),
874 LUA_REG(nl80211,hardware_name),
875 LUA_REG(nl80211,phyname),
881 static const luaL_reg R_wext[] = {
882 LUA_REG(wext,channel),
883 LUA_REG(wext,frequency),
884 LUA_REG(wext,frequency_offset),
885 LUA_REG(wext,txpower),
886 LUA_REG(wext,txpower_offset),
887 LUA_REG(wext,bitrate),
888 LUA_REG(wext,signal),
890 LUA_REG(wext,quality),
891 LUA_REG(wext,quality_max),
895 LUA_REG(wext,country),
896 LUA_REG(wext,assoclist),
897 LUA_REG(wext,txpwrlist),
898 LUA_REG(wext,scanlist),
899 LUA_REG(wext,freqlist),
900 LUA_REG(wext,countrylist),
901 LUA_REG(wext,hwmodelist),
902 LUA_REG(wext,htmodelist),
903 LUA_REG(wext,encryption),
904 LUA_REG(wext,mbssid_support),
905 LUA_REG(wext,hardware_id),
906 LUA_REG(wext,hardware_name),
907 LUA_REG(wext,phyname),
912 static const luaL_reg R_common[] = {
913 { "type", iwinfo_L_type },
914 { "__gc", iwinfo_L__gc },
919 LUALIB_API int luaopen_iwinfo(lua_State *L) {
920 luaL_register(L, IWINFO_META, R_common);
923 luaL_newmetatable(L, IWINFO_WL_META);
924 luaL_register(L, NULL, R_common);
925 luaL_register(L, NULL, R_wl);
926 lua_pushvalue(L, -1);
927 lua_setfield(L, -2, "__index");
928 lua_setfield(L, -2, "wl");
932 luaL_newmetatable(L, IWINFO_MADWIFI_META);
933 luaL_register(L, NULL, R_common);
934 luaL_register(L, NULL, R_madwifi);
935 lua_pushvalue(L, -1);
936 lua_setfield(L, -2, "__index");
937 lua_setfield(L, -2, "madwifi");
941 luaL_newmetatable(L, IWINFO_NL80211_META);
942 luaL_register(L, NULL, R_common);
943 luaL_register(L, NULL, R_nl80211);
944 lua_pushvalue(L, -1);
945 lua_setfield(L, -2, "__index");
946 lua_setfield(L, -2, "nl80211");
949 luaL_newmetatable(L, IWINFO_WEXT_META);
950 luaL_register(L, NULL, R_common);
951 luaL_register(L, NULL, R_wext);
952 lua_pushvalue(L, -1);
953 lua_setfield(L, -2, "__index");
954 lua_setfield(L, -2, "wext");