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 if (e->has_bss_load) {
439 lua_pushnumber(L, e->station_count);
440 lua_setfield(L, -2, "station_count");
442 lua_pushnumber(L, e->channel_utilization);
443 lua_setfield(L, -2, "channel_utilization");
445 lua_pushnumber(L, e->admission_capacity);
446 lua_setfield(L, -2, "admission_capacity");
450 iwinfo_L_cryptotable(L, &e->crypto);
451 lua_setfield(L, -2, "encryption");
453 lua_rawseti(L, -2, x);
460 /* Wrapper for frequency list */
461 static int iwinfo_L_freqlist(lua_State *L, int (*func)(const char *, char *, int *))
464 char rv[IWINFO_BUFSIZE];
465 const char *ifname = luaL_checkstring(L, 1);
466 struct iwinfo_freqlist_entry *e;
469 memset(rv, 0, sizeof(rv));
471 if (!(*func)(ifname, rv, &len))
473 for (i = 0, x = 1; i < len; i += sizeof(struct iwinfo_freqlist_entry), x++)
475 e = (struct iwinfo_freqlist_entry *) &rv[i];
480 lua_pushinteger(L, e->mhz);
481 lua_setfield(L, -2, "mhz");
484 lua_pushinteger(L, e->channel);
485 lua_setfield(L, -2, "channel");
487 /* Restricted (DFS/TPC/Radar) */
488 lua_pushboolean(L, e->restricted);
489 lua_setfield(L, -2, "restricted");
491 lua_rawseti(L, -2, x);
498 /* Wrapper for crypto settings */
499 static int iwinfo_L_encryption(lua_State *L, int (*func)(const char *, char *))
501 const char *ifname = luaL_checkstring(L, 1);
502 struct iwinfo_crypto_entry c = { 0 };
504 if (!(*func)(ifname, (char *)&c))
506 iwinfo_L_cryptotable(L, &c);
514 /* Wrapper for hwmode list */
515 static int iwinfo_L_hwmodelist(lua_State *L, int (*func)(const char *, int *))
517 const char *ifname = luaL_checkstring(L, 1);
520 if (!(*func)(ifname, &hwmodes))
524 lua_pushboolean(L, hwmodes & IWINFO_80211_A);
525 lua_setfield(L, -2, "a");
527 lua_pushboolean(L, hwmodes & IWINFO_80211_B);
528 lua_setfield(L, -2, "b");
530 lua_pushboolean(L, hwmodes & IWINFO_80211_G);
531 lua_setfield(L, -2, "g");
533 lua_pushboolean(L, hwmodes & IWINFO_80211_N);
534 lua_setfield(L, -2, "n");
536 lua_pushboolean(L, hwmodes & IWINFO_80211_AC);
537 lua_setfield(L, -2, "ac");
539 lua_pushboolean(L, hwmodes & IWINFO_80211_AD);
540 lua_setfield(L, -2, "ad");
549 /* Wrapper for htmode list */
550 static int iwinfo_L_htmodelist(lua_State *L, int (*func)(const char *, int *))
552 const char *ifname = luaL_checkstring(L, 1);
555 if (!(*func)(ifname, &htmodes))
559 for (i = 0; i < ARRAY_SIZE(IWINFO_HTMODE_NAMES); i++)
561 lua_pushboolean(L, htmodes & (1 << i));
562 lua_setfield(L, -2, IWINFO_HTMODE_NAMES[i]);
572 /* Wrapper for mbssid_support */
573 static int iwinfo_L_mbssid_support(lua_State *L, int (*func)(const char *, int *))
575 const char *ifname = luaL_checkstring(L, 1);
578 if (!(*func)(ifname, &support))
580 lua_pushboolean(L, support);
588 /* Wrapper for hardware_id */
589 static int iwinfo_L_hardware_id(lua_State *L, int (*func)(const char *, char *))
591 const char *ifname = luaL_checkstring(L, 1);
592 struct iwinfo_hardware_id ids;
594 if (!(*func)(ifname, (char *)&ids))
598 lua_pushnumber(L, ids.vendor_id);
599 lua_setfield(L, -2, "vendor_id");
601 lua_pushnumber(L, ids.device_id);
602 lua_setfield(L, -2, "device_id");
604 lua_pushnumber(L, ids.subsystem_vendor_id);
605 lua_setfield(L, -2, "subsystem_vendor_id");
607 lua_pushnumber(L, ids.subsystem_device_id);
608 lua_setfield(L, -2, "subsystem_device_id");
618 /* Wrapper for country list */
619 static char * iwinfo_L_country_lookup(char *buf, int len, int iso3166)
622 struct iwinfo_country_entry *c;
624 for (i = 0; i < len; i += sizeof(struct iwinfo_country_entry))
626 c = (struct iwinfo_country_entry *) &buf[i];
628 if (c->iso3166 == iso3166)
635 static int iwinfo_L_countrylist(lua_State *L, int (*func)(const char *, char *, int *))
638 char rv[IWINFO_BUFSIZE], alpha2[3];
640 const char *ifname = luaL_checkstring(L, 1);
641 const struct iwinfo_iso3166_label *l;
644 memset(rv, 0, sizeof(rv));
646 if (!(*func)(ifname, rv, &len))
648 for (l = IWINFO_ISO3166_NAMES, i = 1; l->iso3166; l++)
650 if ((ccode = iwinfo_L_country_lookup(rv, len, l->iso3166)) != NULL)
652 sprintf(alpha2, "%c%c",
653 (l->iso3166 / 256), (l->iso3166 % 256));
657 lua_pushstring(L, alpha2);
658 lua_setfield(L, -2, "alpha2");
660 lua_pushstring(L, ccode);
661 lua_setfield(L, -2, "ccode");
663 lua_pushstring(L, l->name);
664 lua_setfield(L, -2, "name");
666 lua_rawseti(L, -2, i++);
677 LUA_WRAP_INT_OP(wl,channel)
678 LUA_WRAP_INT_OP(wl,frequency)
679 LUA_WRAP_INT_OP(wl,frequency_offset)
680 LUA_WRAP_INT_OP(wl,txpower)
681 LUA_WRAP_INT_OP(wl,txpower_offset)
682 LUA_WRAP_INT_OP(wl,bitrate)
683 LUA_WRAP_INT_OP(wl,signal)
684 LUA_WRAP_INT_OP(wl,noise)
685 LUA_WRAP_INT_OP(wl,quality)
686 LUA_WRAP_INT_OP(wl,quality_max)
687 LUA_WRAP_STRING_OP(wl,ssid)
688 LUA_WRAP_STRING_OP(wl,bssid)
689 LUA_WRAP_STRING_OP(wl,country)
690 LUA_WRAP_STRING_OP(wl,hardware_name)
691 LUA_WRAP_STRING_OP(wl,phyname)
692 LUA_WRAP_STRUCT_OP(wl,mode)
693 LUA_WRAP_STRUCT_OP(wl,assoclist)
694 LUA_WRAP_STRUCT_OP(wl,txpwrlist)
695 LUA_WRAP_STRUCT_OP(wl,scanlist)
696 LUA_WRAP_STRUCT_OP(wl,freqlist)
697 LUA_WRAP_STRUCT_OP(wl,countrylist)
698 LUA_WRAP_STRUCT_OP(wl,hwmodelist)
699 LUA_WRAP_STRUCT_OP(wl,htmodelist)
700 LUA_WRAP_STRUCT_OP(wl,encryption)
701 LUA_WRAP_STRUCT_OP(wl,mbssid_support)
702 LUA_WRAP_STRUCT_OP(wl,hardware_id)
707 LUA_WRAP_INT_OP(madwifi,channel)
708 LUA_WRAP_INT_OP(madwifi,frequency)
709 LUA_WRAP_INT_OP(madwifi,frequency_offset)
710 LUA_WRAP_INT_OP(madwifi,txpower)
711 LUA_WRAP_INT_OP(madwifi,txpower_offset)
712 LUA_WRAP_INT_OP(madwifi,bitrate)
713 LUA_WRAP_INT_OP(madwifi,signal)
714 LUA_WRAP_INT_OP(madwifi,noise)
715 LUA_WRAP_INT_OP(madwifi,quality)
716 LUA_WRAP_INT_OP(madwifi,quality_max)
717 LUA_WRAP_STRING_OP(madwifi,ssid)
718 LUA_WRAP_STRING_OP(madwifi,bssid)
719 LUA_WRAP_STRING_OP(madwifi,country)
720 LUA_WRAP_STRING_OP(madwifi,hardware_name)
721 LUA_WRAP_STRING_OP(madwifi,phyname)
722 LUA_WRAP_STRUCT_OP(madwifi,mode)
723 LUA_WRAP_STRUCT_OP(madwifi,assoclist)
724 LUA_WRAP_STRUCT_OP(madwifi,txpwrlist)
725 LUA_WRAP_STRUCT_OP(madwifi,scanlist)
726 LUA_WRAP_STRUCT_OP(madwifi,freqlist)
727 LUA_WRAP_STRUCT_OP(madwifi,countrylist)
728 LUA_WRAP_STRUCT_OP(madwifi,hwmodelist)
729 LUA_WRAP_STRUCT_OP(madwifi,htmodelist)
730 LUA_WRAP_STRUCT_OP(madwifi,encryption)
731 LUA_WRAP_STRUCT_OP(madwifi,mbssid_support)
732 LUA_WRAP_STRUCT_OP(madwifi,hardware_id)
737 LUA_WRAP_INT_OP(nl80211,channel)
738 LUA_WRAP_INT_OP(nl80211,frequency)
739 LUA_WRAP_INT_OP(nl80211,frequency_offset)
740 LUA_WRAP_INT_OP(nl80211,txpower)
741 LUA_WRAP_INT_OP(nl80211,txpower_offset)
742 LUA_WRAP_INT_OP(nl80211,bitrate)
743 LUA_WRAP_INT_OP(nl80211,signal)
744 LUA_WRAP_INT_OP(nl80211,noise)
745 LUA_WRAP_INT_OP(nl80211,quality)
746 LUA_WRAP_INT_OP(nl80211,quality_max)
747 LUA_WRAP_STRING_OP(nl80211,ssid)
748 LUA_WRAP_STRING_OP(nl80211,bssid)
749 LUA_WRAP_STRING_OP(nl80211,country)
750 LUA_WRAP_STRING_OP(nl80211,hardware_name)
751 LUA_WRAP_STRING_OP(nl80211,phyname)
752 LUA_WRAP_STRUCT_OP(nl80211,mode)
753 LUA_WRAP_STRUCT_OP(nl80211,assoclist)
754 LUA_WRAP_STRUCT_OP(nl80211,txpwrlist)
755 LUA_WRAP_STRUCT_OP(nl80211,scanlist)
756 LUA_WRAP_STRUCT_OP(nl80211,freqlist)
757 LUA_WRAP_STRUCT_OP(nl80211,countrylist)
758 LUA_WRAP_STRUCT_OP(nl80211,hwmodelist)
759 LUA_WRAP_STRUCT_OP(nl80211,htmodelist)
760 LUA_WRAP_STRUCT_OP(nl80211,encryption)
761 LUA_WRAP_STRUCT_OP(nl80211,mbssid_support)
762 LUA_WRAP_STRUCT_OP(nl80211,hardware_id)
766 LUA_WRAP_INT_OP(wext,channel)
767 LUA_WRAP_INT_OP(wext,frequency)
768 LUA_WRAP_INT_OP(wext,frequency_offset)
769 LUA_WRAP_INT_OP(wext,txpower)
770 LUA_WRAP_INT_OP(wext,txpower_offset)
771 LUA_WRAP_INT_OP(wext,bitrate)
772 LUA_WRAP_INT_OP(wext,signal)
773 LUA_WRAP_INT_OP(wext,noise)
774 LUA_WRAP_INT_OP(wext,quality)
775 LUA_WRAP_INT_OP(wext,quality_max)
776 LUA_WRAP_STRING_OP(wext,ssid)
777 LUA_WRAP_STRING_OP(wext,bssid)
778 LUA_WRAP_STRING_OP(wext,country)
779 LUA_WRAP_STRING_OP(wext,hardware_name)
780 LUA_WRAP_STRING_OP(wext,phyname)
781 LUA_WRAP_STRUCT_OP(wext,mode)
782 LUA_WRAP_STRUCT_OP(wext,assoclist)
783 LUA_WRAP_STRUCT_OP(wext,txpwrlist)
784 LUA_WRAP_STRUCT_OP(wext,scanlist)
785 LUA_WRAP_STRUCT_OP(wext,freqlist)
786 LUA_WRAP_STRUCT_OP(wext,countrylist)
787 LUA_WRAP_STRUCT_OP(wext,hwmodelist)
788 LUA_WRAP_STRUCT_OP(wext,htmodelist)
789 LUA_WRAP_STRUCT_OP(wext,encryption)
790 LUA_WRAP_STRUCT_OP(wext,mbssid_support)
791 LUA_WRAP_STRUCT_OP(wext,hardware_id)
795 static const luaL_reg R_wl[] = {
797 LUA_REG(wl,frequency),
798 LUA_REG(wl,frequency_offset),
800 LUA_REG(wl,txpower_offset),
805 LUA_REG(wl,quality_max),
810 LUA_REG(wl,assoclist),
811 LUA_REG(wl,txpwrlist),
812 LUA_REG(wl,scanlist),
813 LUA_REG(wl,freqlist),
814 LUA_REG(wl,countrylist),
815 LUA_REG(wl,hwmodelist),
816 LUA_REG(wl,htmodelist),
817 LUA_REG(wl,encryption),
818 LUA_REG(wl,mbssid_support),
819 LUA_REG(wl,hardware_id),
820 LUA_REG(wl,hardware_name),
828 static const luaL_reg R_madwifi[] = {
829 LUA_REG(madwifi,channel),
830 LUA_REG(madwifi,frequency),
831 LUA_REG(madwifi,frequency_offset),
832 LUA_REG(madwifi,txpower),
833 LUA_REG(madwifi,txpower_offset),
834 LUA_REG(madwifi,bitrate),
835 LUA_REG(madwifi,signal),
836 LUA_REG(madwifi,noise),
837 LUA_REG(madwifi,quality),
838 LUA_REG(madwifi,quality_max),
839 LUA_REG(madwifi,mode),
840 LUA_REG(madwifi,ssid),
841 LUA_REG(madwifi,bssid),
842 LUA_REG(madwifi,country),
843 LUA_REG(madwifi,assoclist),
844 LUA_REG(madwifi,txpwrlist),
845 LUA_REG(madwifi,scanlist),
846 LUA_REG(madwifi,freqlist),
847 LUA_REG(madwifi,countrylist),
848 LUA_REG(madwifi,hwmodelist),
849 LUA_REG(madwifi,htmodelist),
850 LUA_REG(madwifi,encryption),
851 LUA_REG(madwifi,mbssid_support),
852 LUA_REG(madwifi,hardware_id),
853 LUA_REG(madwifi,hardware_name),
854 LUA_REG(madwifi,phyname),
861 static const luaL_reg R_nl80211[] = {
862 LUA_REG(nl80211,channel),
863 LUA_REG(nl80211,frequency),
864 LUA_REG(nl80211,frequency_offset),
865 LUA_REG(nl80211,txpower),
866 LUA_REG(nl80211,txpower_offset),
867 LUA_REG(nl80211,bitrate),
868 LUA_REG(nl80211,signal),
869 LUA_REG(nl80211,noise),
870 LUA_REG(nl80211,quality),
871 LUA_REG(nl80211,quality_max),
872 LUA_REG(nl80211,mode),
873 LUA_REG(nl80211,ssid),
874 LUA_REG(nl80211,bssid),
875 LUA_REG(nl80211,country),
876 LUA_REG(nl80211,assoclist),
877 LUA_REG(nl80211,txpwrlist),
878 LUA_REG(nl80211,scanlist),
879 LUA_REG(nl80211,freqlist),
880 LUA_REG(nl80211,countrylist),
881 LUA_REG(nl80211,hwmodelist),
882 LUA_REG(nl80211,htmodelist),
883 LUA_REG(nl80211,encryption),
884 LUA_REG(nl80211,mbssid_support),
885 LUA_REG(nl80211,hardware_id),
886 LUA_REG(nl80211,hardware_name),
887 LUA_REG(nl80211,phyname),
893 static const luaL_reg R_wext[] = {
894 LUA_REG(wext,channel),
895 LUA_REG(wext,frequency),
896 LUA_REG(wext,frequency_offset),
897 LUA_REG(wext,txpower),
898 LUA_REG(wext,txpower_offset),
899 LUA_REG(wext,bitrate),
900 LUA_REG(wext,signal),
902 LUA_REG(wext,quality),
903 LUA_REG(wext,quality_max),
907 LUA_REG(wext,country),
908 LUA_REG(wext,assoclist),
909 LUA_REG(wext,txpwrlist),
910 LUA_REG(wext,scanlist),
911 LUA_REG(wext,freqlist),
912 LUA_REG(wext,countrylist),
913 LUA_REG(wext,hwmodelist),
914 LUA_REG(wext,htmodelist),
915 LUA_REG(wext,encryption),
916 LUA_REG(wext,mbssid_support),
917 LUA_REG(wext,hardware_id),
918 LUA_REG(wext,hardware_name),
919 LUA_REG(wext,phyname),
924 static const luaL_reg R_common[] = {
925 { "type", iwinfo_L_type },
926 { "__gc", iwinfo_L__gc },
931 LUALIB_API int luaopen_iwinfo(lua_State *L) {
932 luaL_register(L, IWINFO_META, R_common);
935 luaL_newmetatable(L, IWINFO_WL_META);
936 luaL_register(L, NULL, R_common);
937 luaL_register(L, NULL, R_wl);
938 lua_pushvalue(L, -1);
939 lua_setfield(L, -2, "__index");
940 lua_setfield(L, -2, "wl");
944 luaL_newmetatable(L, IWINFO_MADWIFI_META);
945 luaL_register(L, NULL, R_common);
946 luaL_register(L, NULL, R_madwifi);
947 lua_pushvalue(L, -1);
948 lua_setfield(L, -2, "__index");
949 lua_setfield(L, -2, "madwifi");
953 luaL_newmetatable(L, IWINFO_NL80211_META);
954 luaL_register(L, NULL, R_common);
955 luaL_register(L, NULL, R_nl80211);
956 lua_pushvalue(L, -1);
957 lua_setfield(L, -2, "__index");
958 lua_setfield(L, -2, "nl80211");
961 luaL_newmetatable(L, IWINFO_WEXT_META);
962 luaL_register(L, NULL, R_common);
963 luaL_register(L, NULL, R_wext);
964 lua_pushvalue(L, -1);
965 lua_setfield(L, -2, "__index");
966 lua_setfield(L, -2, "wext");