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 };
115 if (c
->auth_algs
&& !c
->wpa_version
)
117 if ((c
->auth_algs
& IWINFO_AUTH_OPEN
) &&
118 (c
->auth_algs
& IWINFO_AUTH_SHARED
))
120 sprintf(desc
, "WEP Open/Shared (%s)",
121 iwinfo_crypto_print_ciphers(c
->pair_ciphers
));
123 else if (c
->auth_algs
& IWINFO_AUTH_OPEN
)
125 sprintf(desc
, "WEP Open System (%s)",
126 iwinfo_crypto_print_ciphers(c
->pair_ciphers
));
128 else if (c
->auth_algs
& IWINFO_AUTH_SHARED
)
130 sprintf(desc
, "WEP Shared Auth (%s)",
131 iwinfo_crypto_print_ciphers(c
->pair_ciphers
));
136 else if (c
->wpa_version
)
138 switch (c
->wpa_version
) {
140 sprintf(desc
, "WPA3 %s (%s)",
141 iwinfo_crypto_print_suites(c
->auth_suites
),
142 iwinfo_crypto_print_ciphers(
143 c
->pair_ciphers
| c
->group_ciphers
));
147 sprintf(desc
, "mixed WPA/WPA2 %s (%s)",
148 iwinfo_crypto_print_suites(c
->auth_suites
),
149 iwinfo_crypto_print_ciphers(
150 c
->pair_ciphers
| c
->group_ciphers
));
154 sprintf(desc
, "WPA2 %s (%s)",
155 iwinfo_crypto_print_suites(c
->auth_suites
),
156 iwinfo_crypto_print_ciphers(
157 c
->pair_ciphers
| c
->group_ciphers
));
161 sprintf(desc
, "WPA %s (%s)",
162 iwinfo_crypto_print_suites(c
->auth_suites
),
163 iwinfo_crypto_print_ciphers(
164 c
->pair_ciphers
| c
->group_ciphers
));
170 sprintf(desc
, "None");
175 sprintf(desc
, "None");
180 sprintf(desc
, "Unknown");
186 /* Build Lua table from crypto data */
187 static void iwinfo_L_cryptotable(lua_State
*L
, struct iwinfo_crypto_entry
*c
)
193 lua_pushboolean(L
, c
->enabled
);
194 lua_setfield(L
, -2, "enabled");
196 lua_pushstring(L
, iwinfo_crypto_desc(c
));
197 lua_setfield(L
, -2, "description");
199 lua_pushboolean(L
, (c
->enabled
&& !c
->wpa_version
));
200 lua_setfield(L
, -2, "wep");
202 lua_pushinteger(L
, c
->wpa_version
);
203 lua_setfield(L
, -2, "wpa");
206 for (i
= 0, j
= 1; i
< ARRAY_SIZE(IWINFO_CIPHER_NAMES
); i
++)
208 if (c
->pair_ciphers
& (1 << i
))
210 lua_pushstring(L
, IWINFO_CIPHER_NAMES
[i
]);
211 lua_rawseti(L
, -2, j
++);
214 lua_setfield(L
, -2, "pair_ciphers");
217 for (i
= 0, j
= 1; i
< ARRAY_SIZE(IWINFO_CIPHER_NAMES
); i
++)
219 if (c
->group_ciphers
& (1 << i
))
221 lua_pushstring(L
, IWINFO_CIPHER_NAMES
[i
]);
222 lua_rawseti(L
, -2, j
++);
225 lua_setfield(L
, -2, "group_ciphers");
228 for (i
= 0, j
= 1; i
< ARRAY_SIZE(IWINFO_KMGMT_NAMES
); i
++)
230 if (c
->auth_suites
& (1 << i
))
232 lua_pushstring(L
, IWINFO_KMGMT_NAMES
[i
]);
233 lua_rawseti(L
, -2, j
++);
236 lua_setfield(L
, -2, "auth_suites");
239 for (i
= 0, j
= 1; i
< ARRAY_SIZE(IWINFO_AUTH_NAMES
); i
++)
241 if (c
->auth_algs
& (1 << i
))
243 lua_pushstring(L
, IWINFO_AUTH_NAMES
[i
]);
244 lua_rawseti(L
, -2, j
++);
247 lua_setfield(L
, -2, "auth_algs");
251 /* Wrapper for mode */
252 static int iwinfo_L_mode(lua_State
*L
, int (*func
)(const char *, int *))
255 const char *ifname
= luaL_checkstring(L
, 1);
257 if ((*func
)(ifname
, &mode
))
258 mode
= IWINFO_OPMODE_UNKNOWN
;
260 lua_pushstring(L
, IWINFO_OPMODE_NAMES
[mode
]);
264 static void set_rateinfo(lua_State
*L
, struct iwinfo_rate_entry
*r
, bool rx
)
266 lua_pushnumber(L
, r
->rate
);
267 lua_setfield(L
, -2, rx
? "rx_rate" : "tx_rate");
269 lua_pushboolean(L
, r
->is_ht
);
270 lua_setfield(L
, -2, rx
? "rx_ht" : "tx_ht");
272 lua_pushboolean(L
, r
->is_vht
);
273 lua_setfield(L
, -2, rx
? "rx_vht" : "tx_vht");
275 lua_pushnumber(L
, r
->mhz
);
276 lua_setfield(L
, -2, rx
? "rx_mhz" : "tx_mhz");
280 lua_pushboolean(L
, r
->is_40mhz
);
281 lua_setfield(L
, -2, rx
? "rx_40mhz" : "tx_40mhz");
283 lua_pushnumber(L
, r
->mcs
);
284 lua_setfield(L
, -2, rx
? "rx_mcs" : "tx_mcs");
286 lua_pushboolean(L
, r
->is_short_gi
);
287 lua_setfield(L
, -2, rx
? "rx_short_gi" : "tx_short_gi");
291 lua_pushnumber(L
, r
->mcs
);
292 lua_setfield(L
, -2, rx
? "rx_mcs" : "tx_mcs");
294 lua_pushnumber(L
, r
->nss
);
295 lua_setfield(L
, -2, rx
? "rx_nss" : "tx_nss");
297 lua_pushboolean(L
, r
->is_short_gi
);
298 lua_setfield(L
, -2, rx
? "rx_short_gi" : "tx_short_gi");
302 /* Wrapper for assoclist */
303 static int iwinfo_L_assoclist(lua_State
*L
, int (*func
)(const char *, char *, int *))
306 char rv
[IWINFO_BUFSIZE
];
308 const char *ifname
= luaL_checkstring(L
, 1);
309 struct iwinfo_assoclist_entry
*e
;
312 memset(rv
, 0, sizeof(rv
));
314 if (!(*func
)(ifname
, rv
, &len
))
316 for (i
= 0; i
< len
; i
+= sizeof(struct iwinfo_assoclist_entry
))
318 e
= (struct iwinfo_assoclist_entry
*) &rv
[i
];
320 sprintf(macstr
, "%02X:%02X:%02X:%02X:%02X:%02X",
321 e
->mac
[0], e
->mac
[1], e
->mac
[2],
322 e
->mac
[3], e
->mac
[4], e
->mac
[5]);
326 lua_pushnumber(L
, e
->signal
);
327 lua_setfield(L
, -2, "signal");
329 lua_pushnumber(L
, e
->noise
);
330 lua_setfield(L
, -2, "noise");
332 lua_pushnumber(L
, e
->inactive
);
333 lua_setfield(L
, -2, "inactive");
335 lua_pushnumber(L
, e
->rx_packets
);
336 lua_setfield(L
, -2, "rx_packets");
338 lua_pushnumber(L
, e
->tx_packets
);
339 lua_setfield(L
, -2, "tx_packets");
341 set_rateinfo(L
, &e
->rx_rate
, true);
342 set_rateinfo(L
, &e
->tx_rate
, false);
345 lua_pushnumber(L
, e
->thr
);
346 lua_setfield(L
, -2, "expected_throughput");
349 lua_setfield(L
, -2, macstr
);
356 /* Wrapper for tx power list */
357 static int iwinfo_L_txpwrlist(lua_State
*L
, int (*func
)(const char *, char *, int *))
360 char rv
[IWINFO_BUFSIZE
];
361 const char *ifname
= luaL_checkstring(L
, 1);
362 struct iwinfo_txpwrlist_entry
*e
;
364 memset(rv
, 0, sizeof(rv
));
366 if (!(*func
)(ifname
, rv
, &len
))
370 for (i
= 0, x
= 1; i
< len
; i
+= sizeof(struct iwinfo_txpwrlist_entry
), x
++)
372 e
= (struct iwinfo_txpwrlist_entry
*) &rv
[i
];
376 lua_pushnumber(L
, e
->mw
);
377 lua_setfield(L
, -2, "mw");
379 lua_pushnumber(L
, e
->dbm
);
380 lua_setfield(L
, -2, "dbm");
382 lua_rawseti(L
, -2, x
);
391 /* Wrapper for scan list */
392 static int iwinfo_L_scanlist(lua_State
*L
, int (*func
)(const char *, char *, int *))
395 char rv
[IWINFO_BUFSIZE
];
397 const char *ifname
= luaL_checkstring(L
, 1);
398 struct iwinfo_scanlist_entry
*e
;
401 memset(rv
, 0, sizeof(rv
));
403 if (!(*func
)(ifname
, rv
, &len
))
405 for (i
= 0, x
= 1; i
< len
; i
+= sizeof(struct iwinfo_scanlist_entry
), x
++)
407 e
= (struct iwinfo_scanlist_entry
*) &rv
[i
];
412 sprintf(macstr
, "%02X:%02X:%02X:%02X:%02X:%02X",
413 e
->mac
[0], e
->mac
[1], e
->mac
[2],
414 e
->mac
[3], e
->mac
[4], e
->mac
[5]);
416 lua_pushstring(L
, macstr
);
417 lua_setfield(L
, -2, "bssid");
422 lua_pushstring(L
, (char *) e
->ssid
);
423 lua_setfield(L
, -2, "ssid");
427 lua_pushinteger(L
, e
->channel
);
428 lua_setfield(L
, -2, "channel");
431 lua_pushstring(L
, IWINFO_OPMODE_NAMES
[e
->mode
]);
432 lua_setfield(L
, -2, "mode");
434 /* Quality, Signal */
435 lua_pushinteger(L
, e
->quality
);
436 lua_setfield(L
, -2, "quality");
438 lua_pushinteger(L
, e
->quality_max
);
439 lua_setfield(L
, -2, "quality_max");
441 lua_pushnumber(L
, (e
->signal
- 0x100));
442 lua_setfield(L
, -2, "signal");
445 iwinfo_L_cryptotable(L
, &e
->crypto
);
446 lua_setfield(L
, -2, "encryption");
448 lua_rawseti(L
, -2, x
);
455 /* Wrapper for frequency list */
456 static int iwinfo_L_freqlist(lua_State
*L
, int (*func
)(const char *, char *, int *))
459 char rv
[IWINFO_BUFSIZE
];
460 const char *ifname
= luaL_checkstring(L
, 1);
461 struct iwinfo_freqlist_entry
*e
;
464 memset(rv
, 0, sizeof(rv
));
466 if (!(*func
)(ifname
, rv
, &len
))
468 for (i
= 0, x
= 1; i
< len
; i
+= sizeof(struct iwinfo_freqlist_entry
), x
++)
470 e
= (struct iwinfo_freqlist_entry
*) &rv
[i
];
475 lua_pushinteger(L
, e
->mhz
);
476 lua_setfield(L
, -2, "mhz");
479 lua_pushinteger(L
, e
->channel
);
480 lua_setfield(L
, -2, "channel");
482 /* Restricted (DFS/TPC/Radar) */
483 lua_pushboolean(L
, e
->restricted
);
484 lua_setfield(L
, -2, "restricted");
486 lua_rawseti(L
, -2, x
);
493 /* Wrapper for crypto settings */
494 static int iwinfo_L_encryption(lua_State
*L
, int (*func
)(const char *, char *))
496 const char *ifname
= luaL_checkstring(L
, 1);
497 struct iwinfo_crypto_entry c
= { 0 };
499 if (!(*func
)(ifname
, (char *)&c
))
501 iwinfo_L_cryptotable(L
, &c
);
509 /* Wrapper for hwmode list */
510 static int iwinfo_L_hwmodelist(lua_State
*L
, int (*func
)(const char *, int *))
512 const char *ifname
= luaL_checkstring(L
, 1);
515 if (!(*func
)(ifname
, &hwmodes
))
519 lua_pushboolean(L
, hwmodes
& IWINFO_80211_A
);
520 lua_setfield(L
, -2, "a");
522 lua_pushboolean(L
, hwmodes
& IWINFO_80211_B
);
523 lua_setfield(L
, -2, "b");
525 lua_pushboolean(L
, hwmodes
& IWINFO_80211_G
);
526 lua_setfield(L
, -2, "g");
528 lua_pushboolean(L
, hwmodes
& IWINFO_80211_N
);
529 lua_setfield(L
, -2, "n");
531 lua_pushboolean(L
, hwmodes
& IWINFO_80211_AC
);
532 lua_setfield(L
, -2, "ac");
534 lua_pushboolean(L
, hwmodes
& IWINFO_80211_AD
);
535 lua_setfield(L
, -2, "ad");
544 /* Wrapper for htmode list */
545 static int iwinfo_L_htmodelist(lua_State
*L
, int (*func
)(const char *, int *))
547 const char *ifname
= luaL_checkstring(L
, 1);
550 if (!(*func
)(ifname
, &htmodes
))
554 for (i
= 0; i
< ARRAY_SIZE(IWINFO_HTMODE_NAMES
); i
++)
556 lua_pushboolean(L
, htmodes
& (1 << i
));
557 lua_setfield(L
, -2, IWINFO_HTMODE_NAMES
[i
]);
567 /* Wrapper for mbssid_support */
568 static int iwinfo_L_mbssid_support(lua_State
*L
, int (*func
)(const char *, int *))
570 const char *ifname
= luaL_checkstring(L
, 1);
573 if (!(*func
)(ifname
, &support
))
575 lua_pushboolean(L
, support
);
583 /* Wrapper for hardware_id */
584 static int iwinfo_L_hardware_id(lua_State
*L
, int (*func
)(const char *, char *))
586 const char *ifname
= luaL_checkstring(L
, 1);
587 struct iwinfo_hardware_id ids
;
589 if (!(*func
)(ifname
, (char *)&ids
))
593 lua_pushnumber(L
, ids
.vendor_id
);
594 lua_setfield(L
, -2, "vendor_id");
596 lua_pushnumber(L
, ids
.device_id
);
597 lua_setfield(L
, -2, "device_id");
599 lua_pushnumber(L
, ids
.subsystem_vendor_id
);
600 lua_setfield(L
, -2, "subsystem_vendor_id");
602 lua_pushnumber(L
, ids
.subsystem_device_id
);
603 lua_setfield(L
, -2, "subsystem_device_id");
613 /* Wrapper for country list */
614 static char * iwinfo_L_country_lookup(char *buf
, int len
, int iso3166
)
617 struct iwinfo_country_entry
*c
;
619 for (i
= 0; i
< len
; i
+= sizeof(struct iwinfo_country_entry
))
621 c
= (struct iwinfo_country_entry
*) &buf
[i
];
623 if (c
->iso3166
== iso3166
)
630 static int iwinfo_L_countrylist(lua_State
*L
, int (*func
)(const char *, char *, int *))
633 char rv
[IWINFO_BUFSIZE
], alpha2
[3];
635 const char *ifname
= luaL_checkstring(L
, 1);
636 const struct iwinfo_iso3166_label
*l
;
639 memset(rv
, 0, sizeof(rv
));
641 if (!(*func
)(ifname
, rv
, &len
))
643 for (l
= IWINFO_ISO3166_NAMES
, i
= 1; l
->iso3166
; l
++)
645 if ((ccode
= iwinfo_L_country_lookup(rv
, len
, l
->iso3166
)) != NULL
)
647 sprintf(alpha2
, "%c%c",
648 (l
->iso3166
/ 256), (l
->iso3166
% 256));
652 lua_pushstring(L
, alpha2
);
653 lua_setfield(L
, -2, "alpha2");
655 lua_pushstring(L
, ccode
);
656 lua_setfield(L
, -2, "ccode");
658 lua_pushstring(L
, l
->name
);
659 lua_setfield(L
, -2, "name");
661 lua_rawseti(L
, -2, i
++);
672 LUA_WRAP_INT_OP(wl
,channel
)
673 LUA_WRAP_INT_OP(wl
,frequency
)
674 LUA_WRAP_INT_OP(wl
,frequency_offset
)
675 LUA_WRAP_INT_OP(wl
,txpower
)
676 LUA_WRAP_INT_OP(wl
,txpower_offset
)
677 LUA_WRAP_INT_OP(wl
,bitrate
)
678 LUA_WRAP_INT_OP(wl
,signal
)
679 LUA_WRAP_INT_OP(wl
,noise
)
680 LUA_WRAP_INT_OP(wl
,quality
)
681 LUA_WRAP_INT_OP(wl
,quality_max
)
682 LUA_WRAP_STRING_OP(wl
,ssid
)
683 LUA_WRAP_STRING_OP(wl
,bssid
)
684 LUA_WRAP_STRING_OP(wl
,country
)
685 LUA_WRAP_STRING_OP(wl
,hardware_name
)
686 LUA_WRAP_STRING_OP(wl
,phyname
)
687 LUA_WRAP_STRUCT_OP(wl
,mode
)
688 LUA_WRAP_STRUCT_OP(wl
,assoclist
)
689 LUA_WRAP_STRUCT_OP(wl
,txpwrlist
)
690 LUA_WRAP_STRUCT_OP(wl
,scanlist
)
691 LUA_WRAP_STRUCT_OP(wl
,freqlist
)
692 LUA_WRAP_STRUCT_OP(wl
,countrylist
)
693 LUA_WRAP_STRUCT_OP(wl
,hwmodelist
)
694 LUA_WRAP_STRUCT_OP(wl
,htmodelist
)
695 LUA_WRAP_STRUCT_OP(wl
,encryption
)
696 LUA_WRAP_STRUCT_OP(wl
,mbssid_support
)
697 LUA_WRAP_STRUCT_OP(wl
,hardware_id
)
702 LUA_WRAP_INT_OP(madwifi
,channel
)
703 LUA_WRAP_INT_OP(madwifi
,frequency
)
704 LUA_WRAP_INT_OP(madwifi
,frequency_offset
)
705 LUA_WRAP_INT_OP(madwifi
,txpower
)
706 LUA_WRAP_INT_OP(madwifi
,txpower_offset
)
707 LUA_WRAP_INT_OP(madwifi
,bitrate
)
708 LUA_WRAP_INT_OP(madwifi
,signal
)
709 LUA_WRAP_INT_OP(madwifi
,noise
)
710 LUA_WRAP_INT_OP(madwifi
,quality
)
711 LUA_WRAP_INT_OP(madwifi
,quality_max
)
712 LUA_WRAP_STRING_OP(madwifi
,ssid
)
713 LUA_WRAP_STRING_OP(madwifi
,bssid
)
714 LUA_WRAP_STRING_OP(madwifi
,country
)
715 LUA_WRAP_STRING_OP(madwifi
,hardware_name
)
716 LUA_WRAP_STRING_OP(madwifi
,phyname
)
717 LUA_WRAP_STRUCT_OP(madwifi
,mode
)
718 LUA_WRAP_STRUCT_OP(madwifi
,assoclist
)
719 LUA_WRAP_STRUCT_OP(madwifi
,txpwrlist
)
720 LUA_WRAP_STRUCT_OP(madwifi
,scanlist
)
721 LUA_WRAP_STRUCT_OP(madwifi
,freqlist
)
722 LUA_WRAP_STRUCT_OP(madwifi
,countrylist
)
723 LUA_WRAP_STRUCT_OP(madwifi
,hwmodelist
)
724 LUA_WRAP_STRUCT_OP(madwifi
,htmodelist
)
725 LUA_WRAP_STRUCT_OP(madwifi
,encryption
)
726 LUA_WRAP_STRUCT_OP(madwifi
,mbssid_support
)
727 LUA_WRAP_STRUCT_OP(madwifi
,hardware_id
)
732 LUA_WRAP_INT_OP(nl80211
,channel
)
733 LUA_WRAP_INT_OP(nl80211
,frequency
)
734 LUA_WRAP_INT_OP(nl80211
,frequency_offset
)
735 LUA_WRAP_INT_OP(nl80211
,txpower
)
736 LUA_WRAP_INT_OP(nl80211
,txpower_offset
)
737 LUA_WRAP_INT_OP(nl80211
,bitrate
)
738 LUA_WRAP_INT_OP(nl80211
,signal
)
739 LUA_WRAP_INT_OP(nl80211
,noise
)
740 LUA_WRAP_INT_OP(nl80211
,quality
)
741 LUA_WRAP_INT_OP(nl80211
,quality_max
)
742 LUA_WRAP_STRING_OP(nl80211
,ssid
)
743 LUA_WRAP_STRING_OP(nl80211
,bssid
)
744 LUA_WRAP_STRING_OP(nl80211
,country
)
745 LUA_WRAP_STRING_OP(nl80211
,hardware_name
)
746 LUA_WRAP_STRING_OP(nl80211
,phyname
)
747 LUA_WRAP_STRUCT_OP(nl80211
,mode
)
748 LUA_WRAP_STRUCT_OP(nl80211
,assoclist
)
749 LUA_WRAP_STRUCT_OP(nl80211
,txpwrlist
)
750 LUA_WRAP_STRUCT_OP(nl80211
,scanlist
)
751 LUA_WRAP_STRUCT_OP(nl80211
,freqlist
)
752 LUA_WRAP_STRUCT_OP(nl80211
,countrylist
)
753 LUA_WRAP_STRUCT_OP(nl80211
,hwmodelist
)
754 LUA_WRAP_STRUCT_OP(nl80211
,htmodelist
)
755 LUA_WRAP_STRUCT_OP(nl80211
,encryption
)
756 LUA_WRAP_STRUCT_OP(nl80211
,mbssid_support
)
757 LUA_WRAP_STRUCT_OP(nl80211
,hardware_id
)
761 LUA_WRAP_INT_OP(wext
,channel
)
762 LUA_WRAP_INT_OP(wext
,frequency
)
763 LUA_WRAP_INT_OP(wext
,frequency_offset
)
764 LUA_WRAP_INT_OP(wext
,txpower
)
765 LUA_WRAP_INT_OP(wext
,txpower_offset
)
766 LUA_WRAP_INT_OP(wext
,bitrate
)
767 LUA_WRAP_INT_OP(wext
,signal
)
768 LUA_WRAP_INT_OP(wext
,noise
)
769 LUA_WRAP_INT_OP(wext
,quality
)
770 LUA_WRAP_INT_OP(wext
,quality_max
)
771 LUA_WRAP_STRING_OP(wext
,ssid
)
772 LUA_WRAP_STRING_OP(wext
,bssid
)
773 LUA_WRAP_STRING_OP(wext
,country
)
774 LUA_WRAP_STRING_OP(wext
,hardware_name
)
775 LUA_WRAP_STRING_OP(wext
,phyname
)
776 LUA_WRAP_STRUCT_OP(wext
,mode
)
777 LUA_WRAP_STRUCT_OP(wext
,assoclist
)
778 LUA_WRAP_STRUCT_OP(wext
,txpwrlist
)
779 LUA_WRAP_STRUCT_OP(wext
,scanlist
)
780 LUA_WRAP_STRUCT_OP(wext
,freqlist
)
781 LUA_WRAP_STRUCT_OP(wext
,countrylist
)
782 LUA_WRAP_STRUCT_OP(wext
,hwmodelist
)
783 LUA_WRAP_STRUCT_OP(wext
,htmodelist
)
784 LUA_WRAP_STRUCT_OP(wext
,encryption
)
785 LUA_WRAP_STRUCT_OP(wext
,mbssid_support
)
786 LUA_WRAP_STRUCT_OP(wext
,hardware_id
)
790 static const luaL_reg R_wl
[] = {
792 LUA_REG(wl
,frequency
),
793 LUA_REG(wl
,frequency_offset
),
795 LUA_REG(wl
,txpower_offset
),
800 LUA_REG(wl
,quality_max
),
805 LUA_REG(wl
,assoclist
),
806 LUA_REG(wl
,txpwrlist
),
807 LUA_REG(wl
,scanlist
),
808 LUA_REG(wl
,freqlist
),
809 LUA_REG(wl
,countrylist
),
810 LUA_REG(wl
,hwmodelist
),
811 LUA_REG(wl
,htmodelist
),
812 LUA_REG(wl
,encryption
),
813 LUA_REG(wl
,mbssid_support
),
814 LUA_REG(wl
,hardware_id
),
815 LUA_REG(wl
,hardware_name
),
823 static const luaL_reg R_madwifi
[] = {
824 LUA_REG(madwifi
,channel
),
825 LUA_REG(madwifi
,frequency
),
826 LUA_REG(madwifi
,frequency_offset
),
827 LUA_REG(madwifi
,txpower
),
828 LUA_REG(madwifi
,txpower_offset
),
829 LUA_REG(madwifi
,bitrate
),
830 LUA_REG(madwifi
,signal
),
831 LUA_REG(madwifi
,noise
),
832 LUA_REG(madwifi
,quality
),
833 LUA_REG(madwifi
,quality_max
),
834 LUA_REG(madwifi
,mode
),
835 LUA_REG(madwifi
,ssid
),
836 LUA_REG(madwifi
,bssid
),
837 LUA_REG(madwifi
,country
),
838 LUA_REG(madwifi
,assoclist
),
839 LUA_REG(madwifi
,txpwrlist
),
840 LUA_REG(madwifi
,scanlist
),
841 LUA_REG(madwifi
,freqlist
),
842 LUA_REG(madwifi
,countrylist
),
843 LUA_REG(madwifi
,hwmodelist
),
844 LUA_REG(madwifi
,htmodelist
),
845 LUA_REG(madwifi
,encryption
),
846 LUA_REG(madwifi
,mbssid_support
),
847 LUA_REG(madwifi
,hardware_id
),
848 LUA_REG(madwifi
,hardware_name
),
849 LUA_REG(madwifi
,phyname
),
856 static const luaL_reg R_nl80211
[] = {
857 LUA_REG(nl80211
,channel
),
858 LUA_REG(nl80211
,frequency
),
859 LUA_REG(nl80211
,frequency_offset
),
860 LUA_REG(nl80211
,txpower
),
861 LUA_REG(nl80211
,txpower_offset
),
862 LUA_REG(nl80211
,bitrate
),
863 LUA_REG(nl80211
,signal
),
864 LUA_REG(nl80211
,noise
),
865 LUA_REG(nl80211
,quality
),
866 LUA_REG(nl80211
,quality_max
),
867 LUA_REG(nl80211
,mode
),
868 LUA_REG(nl80211
,ssid
),
869 LUA_REG(nl80211
,bssid
),
870 LUA_REG(nl80211
,country
),
871 LUA_REG(nl80211
,assoclist
),
872 LUA_REG(nl80211
,txpwrlist
),
873 LUA_REG(nl80211
,scanlist
),
874 LUA_REG(nl80211
,freqlist
),
875 LUA_REG(nl80211
,countrylist
),
876 LUA_REG(nl80211
,hwmodelist
),
877 LUA_REG(nl80211
,htmodelist
),
878 LUA_REG(nl80211
,encryption
),
879 LUA_REG(nl80211
,mbssid_support
),
880 LUA_REG(nl80211
,hardware_id
),
881 LUA_REG(nl80211
,hardware_name
),
882 LUA_REG(nl80211
,phyname
),
888 static const luaL_reg R_wext
[] = {
889 LUA_REG(wext
,channel
),
890 LUA_REG(wext
,frequency
),
891 LUA_REG(wext
,frequency_offset
),
892 LUA_REG(wext
,txpower
),
893 LUA_REG(wext
,txpower_offset
),
894 LUA_REG(wext
,bitrate
),
895 LUA_REG(wext
,signal
),
897 LUA_REG(wext
,quality
),
898 LUA_REG(wext
,quality_max
),
902 LUA_REG(wext
,country
),
903 LUA_REG(wext
,assoclist
),
904 LUA_REG(wext
,txpwrlist
),
905 LUA_REG(wext
,scanlist
),
906 LUA_REG(wext
,freqlist
),
907 LUA_REG(wext
,countrylist
),
908 LUA_REG(wext
,hwmodelist
),
909 LUA_REG(wext
,htmodelist
),
910 LUA_REG(wext
,encryption
),
911 LUA_REG(wext
,mbssid_support
),
912 LUA_REG(wext
,hardware_id
),
913 LUA_REG(wext
,hardware_name
),
914 LUA_REG(wext
,phyname
),
919 static const luaL_reg R_common
[] = {
920 { "type", iwinfo_L_type
},
921 { "__gc", iwinfo_L__gc
},
926 LUALIB_API
int luaopen_iwinfo(lua_State
*L
) {
927 luaL_register(L
, IWINFO_META
, R_common
);
930 luaL_newmetatable(L
, IWINFO_WL_META
);
931 luaL_register(L
, NULL
, R_common
);
932 luaL_register(L
, NULL
, R_wl
);
933 lua_pushvalue(L
, -1);
934 lua_setfield(L
, -2, "__index");
935 lua_setfield(L
, -2, "wl");
939 luaL_newmetatable(L
, IWINFO_MADWIFI_META
);
940 luaL_register(L
, NULL
, R_common
);
941 luaL_register(L
, NULL
, R_madwifi
);
942 lua_pushvalue(L
, -1);
943 lua_setfield(L
, -2, "__index");
944 lua_setfield(L
, -2, "madwifi");
948 luaL_newmetatable(L
, IWINFO_NL80211_META
);
949 luaL_register(L
, NULL
, R_common
);
950 luaL_register(L
, NULL
, R_nl80211
);
951 lua_pushvalue(L
, -1);
952 lua_setfield(L
, -2, "__index");
953 lua_setfield(L
, -2, "nl80211");
956 luaL_newmetatable(L
, IWINFO_WEXT_META
);
957 luaL_register(L
, NULL
, R_common
);
958 luaL_register(L
, NULL
, R_wext
);
959 lua_pushvalue(L
, -1);
960 lua_setfield(L
, -2, "__index");
961 lua_setfield(L
, -2, "wext");