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_GCMP
)
65 pos
+= sprintf(pos
, "GCMP, ");
67 if (ciphers
& IWINFO_CIPHER_WRAP
)
68 pos
+= sprintf(pos
, "WRAP, ");
70 if (ciphers
& IWINFO_CIPHER_AESOCB
)
71 pos
+= sprintf(pos
, "AES-OCB, ");
73 if (ciphers
& IWINFO_CIPHER_CKIP
)
74 pos
+= sprintf(pos
, "CKIP, ");
76 if (!ciphers
|| (ciphers
& IWINFO_CIPHER_NONE
))
77 pos
+= sprintf(pos
, "NONE, ");
84 static char * iwinfo_crypto_print_suites(int suites
)
86 static char str
[64] = { 0 };
89 if (suites
& IWINFO_KMGMT_PSK
)
90 pos
+= sprintf(pos
, "PSK/");
92 if (suites
& IWINFO_KMGMT_8021x
)
93 pos
+= sprintf(pos
, "802.1X/");
95 if (suites
& IWINFO_KMGMT_SAE
)
96 pos
+= sprintf(pos
, "SAE/");
98 if (suites
& IWINFO_KMGMT_OWE
)
99 pos
+= sprintf(pos
, "OWE/");
101 if (!suites
|| (suites
& IWINFO_KMGMT_NONE
))
102 pos
+= sprintf(pos
, "NONE/");
109 static char * iwinfo_crypto_desc(struct iwinfo_crypto_entry
*c
)
111 static char desc
[512] = { 0 };
120 if (c
->auth_algs
&& !c
->wpa_version
)
122 if ((c
->auth_algs
& IWINFO_AUTH_OPEN
) &&
123 (c
->auth_algs
& IWINFO_AUTH_SHARED
))
125 sprintf(desc
, "WEP Open/Shared (%s)",
126 iwinfo_crypto_print_ciphers(c
->pair_ciphers
));
128 else if (c
->auth_algs
& IWINFO_AUTH_OPEN
)
130 sprintf(desc
, "WEP Open System (%s)",
131 iwinfo_crypto_print_ciphers(c
->pair_ciphers
));
133 else if (c
->auth_algs
& IWINFO_AUTH_SHARED
)
135 sprintf(desc
, "WEP Shared Auth (%s)",
136 iwinfo_crypto_print_ciphers(c
->pair_ciphers
));
141 else if (c
->wpa_version
)
143 for (i
= 0, n
= 0; i
< 3; i
++)
144 if (c
->wpa_version
& (1 << i
))
148 pos
+= sprintf(pos
, "mixed ");
150 for (i
= 0; i
< 3; i
++)
151 if (c
->wpa_version
& (1 << i
))
153 pos
+= sprintf(pos
, "WPA%d/", i
+ 1);
155 pos
+= sprintf(pos
, "WPA/");
159 sprintf(pos
, " %s (%s)",
160 iwinfo_crypto_print_suites(c
->auth_suites
),
161 iwinfo_crypto_print_ciphers(
162 c
->pair_ciphers
| c
->group_ciphers
));
166 sprintf(desc
, "None");
171 sprintf(desc
, "None");
176 sprintf(desc
, "Unknown");
182 /* Build Lua table from crypto data */
183 static void iwinfo_L_cryptotable(lua_State
*L
, struct iwinfo_crypto_entry
*c
)
189 lua_pushboolean(L
, c
->enabled
);
190 lua_setfield(L
, -2, "enabled");
192 lua_pushstring(L
, iwinfo_crypto_desc(c
));
193 lua_setfield(L
, -2, "description");
195 lua_pushboolean(L
, (c
->enabled
&& !c
->wpa_version
));
196 lua_setfield(L
, -2, "wep");
198 lua_pushinteger(L
, c
->wpa_version
);
199 lua_setfield(L
, -2, "wpa");
202 for (i
= 0, j
= 1; i
< ARRAY_SIZE(IWINFO_CIPHER_NAMES
); i
++)
204 if (c
->pair_ciphers
& (1 << i
))
206 lua_pushstring(L
, IWINFO_CIPHER_NAMES
[i
]);
207 lua_rawseti(L
, -2, j
++);
210 lua_setfield(L
, -2, "pair_ciphers");
213 for (i
= 0, j
= 1; i
< ARRAY_SIZE(IWINFO_CIPHER_NAMES
); i
++)
215 if (c
->group_ciphers
& (1 << i
))
217 lua_pushstring(L
, IWINFO_CIPHER_NAMES
[i
]);
218 lua_rawseti(L
, -2, j
++);
221 lua_setfield(L
, -2, "group_ciphers");
224 for (i
= 0, j
= 1; i
< ARRAY_SIZE(IWINFO_KMGMT_NAMES
); i
++)
226 if (c
->auth_suites
& (1 << i
))
228 lua_pushstring(L
, IWINFO_KMGMT_NAMES
[i
]);
229 lua_rawseti(L
, -2, j
++);
232 lua_setfield(L
, -2, "auth_suites");
235 for (i
= 0, j
= 1; i
< ARRAY_SIZE(IWINFO_AUTH_NAMES
); i
++)
237 if (c
->auth_algs
& (1 << i
))
239 lua_pushstring(L
, IWINFO_AUTH_NAMES
[i
]);
240 lua_rawseti(L
, -2, j
++);
243 lua_setfield(L
, -2, "auth_algs");
247 /* Wrapper for mode */
248 static int iwinfo_L_mode(lua_State
*L
, int (*func
)(const char *, int *))
251 const char *ifname
= luaL_checkstring(L
, 1);
253 if ((*func
)(ifname
, &mode
))
254 mode
= IWINFO_OPMODE_UNKNOWN
;
256 lua_pushstring(L
, IWINFO_OPMODE_NAMES
[mode
]);
260 static void set_rateinfo(lua_State
*L
, struct iwinfo_rate_entry
*r
, bool rx
)
262 lua_pushnumber(L
, r
->rate
);
263 lua_setfield(L
, -2, rx
? "rx_rate" : "tx_rate");
265 lua_pushboolean(L
, r
->is_ht
);
266 lua_setfield(L
, -2, rx
? "rx_ht" : "tx_ht");
268 lua_pushboolean(L
, r
->is_vht
);
269 lua_setfield(L
, -2, rx
? "rx_vht" : "tx_vht");
271 lua_pushnumber(L
, r
->mhz
);
272 lua_setfield(L
, -2, rx
? "rx_mhz" : "tx_mhz");
276 lua_pushboolean(L
, r
->is_40mhz
);
277 lua_setfield(L
, -2, rx
? "rx_40mhz" : "tx_40mhz");
279 lua_pushnumber(L
, r
->mcs
);
280 lua_setfield(L
, -2, rx
? "rx_mcs" : "tx_mcs");
282 lua_pushboolean(L
, r
->is_short_gi
);
283 lua_setfield(L
, -2, rx
? "rx_short_gi" : "tx_short_gi");
287 lua_pushnumber(L
, r
->mcs
);
288 lua_setfield(L
, -2, rx
? "rx_mcs" : "tx_mcs");
290 lua_pushnumber(L
, r
->nss
);
291 lua_setfield(L
, -2, rx
? "rx_nss" : "tx_nss");
293 lua_pushboolean(L
, r
->is_short_gi
);
294 lua_setfield(L
, -2, rx
? "rx_short_gi" : "tx_short_gi");
298 /* Wrapper for assoclist */
299 static int iwinfo_L_assoclist(lua_State
*L
, int (*func
)(const char *, char *, int *))
302 char rv
[IWINFO_BUFSIZE
];
304 const char *ifname
= luaL_checkstring(L
, 1);
305 struct iwinfo_assoclist_entry
*e
;
308 memset(rv
, 0, sizeof(rv
));
310 if (!(*func
)(ifname
, rv
, &len
))
312 for (i
= 0; i
< len
; i
+= sizeof(struct iwinfo_assoclist_entry
))
314 e
= (struct iwinfo_assoclist_entry
*) &rv
[i
];
316 sprintf(macstr
, "%02X:%02X:%02X:%02X:%02X:%02X",
317 e
->mac
[0], e
->mac
[1], e
->mac
[2],
318 e
->mac
[3], e
->mac
[4], e
->mac
[5]);
322 lua_pushnumber(L
, e
->signal
);
323 lua_setfield(L
, -2, "signal");
325 lua_pushnumber(L
, e
->noise
);
326 lua_setfield(L
, -2, "noise");
328 lua_pushnumber(L
, e
->inactive
);
329 lua_setfield(L
, -2, "inactive");
331 lua_pushnumber(L
, e
->rx_packets
);
332 lua_setfield(L
, -2, "rx_packets");
334 lua_pushnumber(L
, e
->tx_packets
);
335 lua_setfield(L
, -2, "tx_packets");
337 set_rateinfo(L
, &e
->rx_rate
, true);
338 set_rateinfo(L
, &e
->tx_rate
, false);
341 lua_pushnumber(L
, e
->thr
);
342 lua_setfield(L
, -2, "expected_throughput");
345 lua_setfield(L
, -2, macstr
);
352 /* Wrapper for tx power list */
353 static int iwinfo_L_txpwrlist(lua_State
*L
, int (*func
)(const char *, char *, int *))
356 char rv
[IWINFO_BUFSIZE
];
357 const char *ifname
= luaL_checkstring(L
, 1);
358 struct iwinfo_txpwrlist_entry
*e
;
360 memset(rv
, 0, sizeof(rv
));
362 if (!(*func
)(ifname
, rv
, &len
))
366 for (i
= 0, x
= 1; i
< len
; i
+= sizeof(struct iwinfo_txpwrlist_entry
), x
++)
368 e
= (struct iwinfo_txpwrlist_entry
*) &rv
[i
];
372 lua_pushnumber(L
, e
->mw
);
373 lua_setfield(L
, -2, "mw");
375 lua_pushnumber(L
, e
->dbm
);
376 lua_setfield(L
, -2, "dbm");
378 lua_rawseti(L
, -2, x
);
387 /* Wrapper for scan list */
388 static int iwinfo_L_scanlist(lua_State
*L
, int (*func
)(const char *, char *, int *))
391 char rv
[IWINFO_BUFSIZE
];
393 const char *ifname
= luaL_checkstring(L
, 1);
394 struct iwinfo_scanlist_entry
*e
;
397 memset(rv
, 0, sizeof(rv
));
399 if (!(*func
)(ifname
, rv
, &len
))
401 for (i
= 0, x
= 1; i
< len
; i
+= sizeof(struct iwinfo_scanlist_entry
), x
++)
403 e
= (struct iwinfo_scanlist_entry
*) &rv
[i
];
408 sprintf(macstr
, "%02X:%02X:%02X:%02X:%02X:%02X",
409 e
->mac
[0], e
->mac
[1], e
->mac
[2],
410 e
->mac
[3], e
->mac
[4], e
->mac
[5]);
412 lua_pushstring(L
, macstr
);
413 lua_setfield(L
, -2, "bssid");
418 lua_pushstring(L
, (char *) e
->ssid
);
419 lua_setfield(L
, -2, "ssid");
423 lua_pushinteger(L
, e
->channel
);
424 lua_setfield(L
, -2, "channel");
427 lua_pushstring(L
, IWINFO_OPMODE_NAMES
[e
->mode
]);
428 lua_setfield(L
, -2, "mode");
430 /* Quality, Signal */
431 lua_pushinteger(L
, e
->quality
);
432 lua_setfield(L
, -2, "quality");
434 lua_pushinteger(L
, e
->quality_max
);
435 lua_setfield(L
, -2, "quality_max");
437 lua_pushnumber(L
, (e
->signal
- 0x100));
438 lua_setfield(L
, -2, "signal");
441 iwinfo_L_cryptotable(L
, &e
->crypto
);
442 lua_setfield(L
, -2, "encryption");
444 lua_rawseti(L
, -2, x
);
451 /* Wrapper for frequency list */
452 static int iwinfo_L_freqlist(lua_State
*L
, int (*func
)(const char *, char *, int *))
455 char rv
[IWINFO_BUFSIZE
];
456 const char *ifname
= luaL_checkstring(L
, 1);
457 struct iwinfo_freqlist_entry
*e
;
460 memset(rv
, 0, sizeof(rv
));
462 if (!(*func
)(ifname
, rv
, &len
))
464 for (i
= 0, x
= 1; i
< len
; i
+= sizeof(struct iwinfo_freqlist_entry
), x
++)
466 e
= (struct iwinfo_freqlist_entry
*) &rv
[i
];
471 lua_pushinteger(L
, e
->mhz
);
472 lua_setfield(L
, -2, "mhz");
475 lua_pushinteger(L
, e
->channel
);
476 lua_setfield(L
, -2, "channel");
478 /* Restricted (DFS/TPC/Radar) */
479 lua_pushboolean(L
, e
->restricted
);
480 lua_setfield(L
, -2, "restricted");
482 lua_rawseti(L
, -2, x
);
489 /* Wrapper for crypto settings */
490 static int iwinfo_L_encryption(lua_State
*L
, int (*func
)(const char *, char *))
492 const char *ifname
= luaL_checkstring(L
, 1);
493 struct iwinfo_crypto_entry c
= { 0 };
495 if (!(*func
)(ifname
, (char *)&c
))
497 iwinfo_L_cryptotable(L
, &c
);
505 /* Wrapper for hwmode list */
506 static int iwinfo_L_hwmodelist(lua_State
*L
, int (*func
)(const char *, int *))
508 const char *ifname
= luaL_checkstring(L
, 1);
511 if (!(*func
)(ifname
, &hwmodes
))
515 lua_pushboolean(L
, hwmodes
& IWINFO_80211_A
);
516 lua_setfield(L
, -2, "a");
518 lua_pushboolean(L
, hwmodes
& IWINFO_80211_B
);
519 lua_setfield(L
, -2, "b");
521 lua_pushboolean(L
, hwmodes
& IWINFO_80211_G
);
522 lua_setfield(L
, -2, "g");
524 lua_pushboolean(L
, hwmodes
& IWINFO_80211_N
);
525 lua_setfield(L
, -2, "n");
527 lua_pushboolean(L
, hwmodes
& IWINFO_80211_AC
);
528 lua_setfield(L
, -2, "ac");
530 lua_pushboolean(L
, hwmodes
& IWINFO_80211_AD
);
531 lua_setfield(L
, -2, "ad");
540 /* Wrapper for htmode list */
541 static int iwinfo_L_htmodelist(lua_State
*L
, int (*func
)(const char *, int *))
543 const char *ifname
= luaL_checkstring(L
, 1);
546 if (!(*func
)(ifname
, &htmodes
))
550 for (i
= 0; i
< ARRAY_SIZE(IWINFO_HTMODE_NAMES
); i
++)
552 lua_pushboolean(L
, htmodes
& (1 << i
));
553 lua_setfield(L
, -2, IWINFO_HTMODE_NAMES
[i
]);
563 /* Wrapper for mbssid_support */
564 static int iwinfo_L_mbssid_support(lua_State
*L
, int (*func
)(const char *, int *))
566 const char *ifname
= luaL_checkstring(L
, 1);
569 if (!(*func
)(ifname
, &support
))
571 lua_pushboolean(L
, support
);
579 /* Wrapper for hardware_id */
580 static int iwinfo_L_hardware_id(lua_State
*L
, int (*func
)(const char *, char *))
582 const char *ifname
= luaL_checkstring(L
, 1);
583 struct iwinfo_hardware_id ids
;
585 if (!(*func
)(ifname
, (char *)&ids
))
589 lua_pushnumber(L
, ids
.vendor_id
);
590 lua_setfield(L
, -2, "vendor_id");
592 lua_pushnumber(L
, ids
.device_id
);
593 lua_setfield(L
, -2, "device_id");
595 lua_pushnumber(L
, ids
.subsystem_vendor_id
);
596 lua_setfield(L
, -2, "subsystem_vendor_id");
598 lua_pushnumber(L
, ids
.subsystem_device_id
);
599 lua_setfield(L
, -2, "subsystem_device_id");
609 /* Wrapper for country list */
610 static char * iwinfo_L_country_lookup(char *buf
, int len
, int iso3166
)
613 struct iwinfo_country_entry
*c
;
615 for (i
= 0; i
< len
; i
+= sizeof(struct iwinfo_country_entry
))
617 c
= (struct iwinfo_country_entry
*) &buf
[i
];
619 if (c
->iso3166
== iso3166
)
626 static int iwinfo_L_countrylist(lua_State
*L
, int (*func
)(const char *, char *, int *))
629 char rv
[IWINFO_BUFSIZE
], alpha2
[3];
631 const char *ifname
= luaL_checkstring(L
, 1);
632 const struct iwinfo_iso3166_label
*l
;
635 memset(rv
, 0, sizeof(rv
));
637 if (!(*func
)(ifname
, rv
, &len
))
639 for (l
= IWINFO_ISO3166_NAMES
, i
= 1; l
->iso3166
; l
++)
641 if ((ccode
= iwinfo_L_country_lookup(rv
, len
, l
->iso3166
)) != NULL
)
643 sprintf(alpha2
, "%c%c",
644 (l
->iso3166
/ 256), (l
->iso3166
% 256));
648 lua_pushstring(L
, alpha2
);
649 lua_setfield(L
, -2, "alpha2");
651 lua_pushstring(L
, ccode
);
652 lua_setfield(L
, -2, "ccode");
654 lua_pushstring(L
, l
->name
);
655 lua_setfield(L
, -2, "name");
657 lua_rawseti(L
, -2, i
++);
668 LUA_WRAP_INT_OP(wl
,channel
)
669 LUA_WRAP_INT_OP(wl
,frequency
)
670 LUA_WRAP_INT_OP(wl
,frequency_offset
)
671 LUA_WRAP_INT_OP(wl
,txpower
)
672 LUA_WRAP_INT_OP(wl
,txpower_offset
)
673 LUA_WRAP_INT_OP(wl
,bitrate
)
674 LUA_WRAP_INT_OP(wl
,signal
)
675 LUA_WRAP_INT_OP(wl
,noise
)
676 LUA_WRAP_INT_OP(wl
,quality
)
677 LUA_WRAP_INT_OP(wl
,quality_max
)
678 LUA_WRAP_STRING_OP(wl
,ssid
)
679 LUA_WRAP_STRING_OP(wl
,bssid
)
680 LUA_WRAP_STRING_OP(wl
,country
)
681 LUA_WRAP_STRING_OP(wl
,hardware_name
)
682 LUA_WRAP_STRING_OP(wl
,phyname
)
683 LUA_WRAP_STRUCT_OP(wl
,mode
)
684 LUA_WRAP_STRUCT_OP(wl
,assoclist
)
685 LUA_WRAP_STRUCT_OP(wl
,txpwrlist
)
686 LUA_WRAP_STRUCT_OP(wl
,scanlist
)
687 LUA_WRAP_STRUCT_OP(wl
,freqlist
)
688 LUA_WRAP_STRUCT_OP(wl
,countrylist
)
689 LUA_WRAP_STRUCT_OP(wl
,hwmodelist
)
690 LUA_WRAP_STRUCT_OP(wl
,htmodelist
)
691 LUA_WRAP_STRUCT_OP(wl
,encryption
)
692 LUA_WRAP_STRUCT_OP(wl
,mbssid_support
)
693 LUA_WRAP_STRUCT_OP(wl
,hardware_id
)
698 LUA_WRAP_INT_OP(madwifi
,channel
)
699 LUA_WRAP_INT_OP(madwifi
,frequency
)
700 LUA_WRAP_INT_OP(madwifi
,frequency_offset
)
701 LUA_WRAP_INT_OP(madwifi
,txpower
)
702 LUA_WRAP_INT_OP(madwifi
,txpower_offset
)
703 LUA_WRAP_INT_OP(madwifi
,bitrate
)
704 LUA_WRAP_INT_OP(madwifi
,signal
)
705 LUA_WRAP_INT_OP(madwifi
,noise
)
706 LUA_WRAP_INT_OP(madwifi
,quality
)
707 LUA_WRAP_INT_OP(madwifi
,quality_max
)
708 LUA_WRAP_STRING_OP(madwifi
,ssid
)
709 LUA_WRAP_STRING_OP(madwifi
,bssid
)
710 LUA_WRAP_STRING_OP(madwifi
,country
)
711 LUA_WRAP_STRING_OP(madwifi
,hardware_name
)
712 LUA_WRAP_STRING_OP(madwifi
,phyname
)
713 LUA_WRAP_STRUCT_OP(madwifi
,mode
)
714 LUA_WRAP_STRUCT_OP(madwifi
,assoclist
)
715 LUA_WRAP_STRUCT_OP(madwifi
,txpwrlist
)
716 LUA_WRAP_STRUCT_OP(madwifi
,scanlist
)
717 LUA_WRAP_STRUCT_OP(madwifi
,freqlist
)
718 LUA_WRAP_STRUCT_OP(madwifi
,countrylist
)
719 LUA_WRAP_STRUCT_OP(madwifi
,hwmodelist
)
720 LUA_WRAP_STRUCT_OP(madwifi
,htmodelist
)
721 LUA_WRAP_STRUCT_OP(madwifi
,encryption
)
722 LUA_WRAP_STRUCT_OP(madwifi
,mbssid_support
)
723 LUA_WRAP_STRUCT_OP(madwifi
,hardware_id
)
728 LUA_WRAP_INT_OP(nl80211
,channel
)
729 LUA_WRAP_INT_OP(nl80211
,frequency
)
730 LUA_WRAP_INT_OP(nl80211
,frequency_offset
)
731 LUA_WRAP_INT_OP(nl80211
,txpower
)
732 LUA_WRAP_INT_OP(nl80211
,txpower_offset
)
733 LUA_WRAP_INT_OP(nl80211
,bitrate
)
734 LUA_WRAP_INT_OP(nl80211
,signal
)
735 LUA_WRAP_INT_OP(nl80211
,noise
)
736 LUA_WRAP_INT_OP(nl80211
,quality
)
737 LUA_WRAP_INT_OP(nl80211
,quality_max
)
738 LUA_WRAP_STRING_OP(nl80211
,ssid
)
739 LUA_WRAP_STRING_OP(nl80211
,bssid
)
740 LUA_WRAP_STRING_OP(nl80211
,country
)
741 LUA_WRAP_STRING_OP(nl80211
,hardware_name
)
742 LUA_WRAP_STRING_OP(nl80211
,phyname
)
743 LUA_WRAP_STRUCT_OP(nl80211
,mode
)
744 LUA_WRAP_STRUCT_OP(nl80211
,assoclist
)
745 LUA_WRAP_STRUCT_OP(nl80211
,txpwrlist
)
746 LUA_WRAP_STRUCT_OP(nl80211
,scanlist
)
747 LUA_WRAP_STRUCT_OP(nl80211
,freqlist
)
748 LUA_WRAP_STRUCT_OP(nl80211
,countrylist
)
749 LUA_WRAP_STRUCT_OP(nl80211
,hwmodelist
)
750 LUA_WRAP_STRUCT_OP(nl80211
,htmodelist
)
751 LUA_WRAP_STRUCT_OP(nl80211
,encryption
)
752 LUA_WRAP_STRUCT_OP(nl80211
,mbssid_support
)
753 LUA_WRAP_STRUCT_OP(nl80211
,hardware_id
)
757 LUA_WRAP_INT_OP(wext
,channel
)
758 LUA_WRAP_INT_OP(wext
,frequency
)
759 LUA_WRAP_INT_OP(wext
,frequency_offset
)
760 LUA_WRAP_INT_OP(wext
,txpower
)
761 LUA_WRAP_INT_OP(wext
,txpower_offset
)
762 LUA_WRAP_INT_OP(wext
,bitrate
)
763 LUA_WRAP_INT_OP(wext
,signal
)
764 LUA_WRAP_INT_OP(wext
,noise
)
765 LUA_WRAP_INT_OP(wext
,quality
)
766 LUA_WRAP_INT_OP(wext
,quality_max
)
767 LUA_WRAP_STRING_OP(wext
,ssid
)
768 LUA_WRAP_STRING_OP(wext
,bssid
)
769 LUA_WRAP_STRING_OP(wext
,country
)
770 LUA_WRAP_STRING_OP(wext
,hardware_name
)
771 LUA_WRAP_STRING_OP(wext
,phyname
)
772 LUA_WRAP_STRUCT_OP(wext
,mode
)
773 LUA_WRAP_STRUCT_OP(wext
,assoclist
)
774 LUA_WRAP_STRUCT_OP(wext
,txpwrlist
)
775 LUA_WRAP_STRUCT_OP(wext
,scanlist
)
776 LUA_WRAP_STRUCT_OP(wext
,freqlist
)
777 LUA_WRAP_STRUCT_OP(wext
,countrylist
)
778 LUA_WRAP_STRUCT_OP(wext
,hwmodelist
)
779 LUA_WRAP_STRUCT_OP(wext
,htmodelist
)
780 LUA_WRAP_STRUCT_OP(wext
,encryption
)
781 LUA_WRAP_STRUCT_OP(wext
,mbssid_support
)
782 LUA_WRAP_STRUCT_OP(wext
,hardware_id
)
786 static const luaL_reg R_wl
[] = {
788 LUA_REG(wl
,frequency
),
789 LUA_REG(wl
,frequency_offset
),
791 LUA_REG(wl
,txpower_offset
),
796 LUA_REG(wl
,quality_max
),
801 LUA_REG(wl
,assoclist
),
802 LUA_REG(wl
,txpwrlist
),
803 LUA_REG(wl
,scanlist
),
804 LUA_REG(wl
,freqlist
),
805 LUA_REG(wl
,countrylist
),
806 LUA_REG(wl
,hwmodelist
),
807 LUA_REG(wl
,htmodelist
),
808 LUA_REG(wl
,encryption
),
809 LUA_REG(wl
,mbssid_support
),
810 LUA_REG(wl
,hardware_id
),
811 LUA_REG(wl
,hardware_name
),
819 static const luaL_reg R_madwifi
[] = {
820 LUA_REG(madwifi
,channel
),
821 LUA_REG(madwifi
,frequency
),
822 LUA_REG(madwifi
,frequency_offset
),
823 LUA_REG(madwifi
,txpower
),
824 LUA_REG(madwifi
,txpower_offset
),
825 LUA_REG(madwifi
,bitrate
),
826 LUA_REG(madwifi
,signal
),
827 LUA_REG(madwifi
,noise
),
828 LUA_REG(madwifi
,quality
),
829 LUA_REG(madwifi
,quality_max
),
830 LUA_REG(madwifi
,mode
),
831 LUA_REG(madwifi
,ssid
),
832 LUA_REG(madwifi
,bssid
),
833 LUA_REG(madwifi
,country
),
834 LUA_REG(madwifi
,assoclist
),
835 LUA_REG(madwifi
,txpwrlist
),
836 LUA_REG(madwifi
,scanlist
),
837 LUA_REG(madwifi
,freqlist
),
838 LUA_REG(madwifi
,countrylist
),
839 LUA_REG(madwifi
,hwmodelist
),
840 LUA_REG(madwifi
,htmodelist
),
841 LUA_REG(madwifi
,encryption
),
842 LUA_REG(madwifi
,mbssid_support
),
843 LUA_REG(madwifi
,hardware_id
),
844 LUA_REG(madwifi
,hardware_name
),
845 LUA_REG(madwifi
,phyname
),
852 static const luaL_reg R_nl80211
[] = {
853 LUA_REG(nl80211
,channel
),
854 LUA_REG(nl80211
,frequency
),
855 LUA_REG(nl80211
,frequency_offset
),
856 LUA_REG(nl80211
,txpower
),
857 LUA_REG(nl80211
,txpower_offset
),
858 LUA_REG(nl80211
,bitrate
),
859 LUA_REG(nl80211
,signal
),
860 LUA_REG(nl80211
,noise
),
861 LUA_REG(nl80211
,quality
),
862 LUA_REG(nl80211
,quality_max
),
863 LUA_REG(nl80211
,mode
),
864 LUA_REG(nl80211
,ssid
),
865 LUA_REG(nl80211
,bssid
),
866 LUA_REG(nl80211
,country
),
867 LUA_REG(nl80211
,assoclist
),
868 LUA_REG(nl80211
,txpwrlist
),
869 LUA_REG(nl80211
,scanlist
),
870 LUA_REG(nl80211
,freqlist
),
871 LUA_REG(nl80211
,countrylist
),
872 LUA_REG(nl80211
,hwmodelist
),
873 LUA_REG(nl80211
,htmodelist
),
874 LUA_REG(nl80211
,encryption
),
875 LUA_REG(nl80211
,mbssid_support
),
876 LUA_REG(nl80211
,hardware_id
),
877 LUA_REG(nl80211
,hardware_name
),
878 LUA_REG(nl80211
,phyname
),
884 static const luaL_reg R_wext
[] = {
885 LUA_REG(wext
,channel
),
886 LUA_REG(wext
,frequency
),
887 LUA_REG(wext
,frequency_offset
),
888 LUA_REG(wext
,txpower
),
889 LUA_REG(wext
,txpower_offset
),
890 LUA_REG(wext
,bitrate
),
891 LUA_REG(wext
,signal
),
893 LUA_REG(wext
,quality
),
894 LUA_REG(wext
,quality_max
),
898 LUA_REG(wext
,country
),
899 LUA_REG(wext
,assoclist
),
900 LUA_REG(wext
,txpwrlist
),
901 LUA_REG(wext
,scanlist
),
902 LUA_REG(wext
,freqlist
),
903 LUA_REG(wext
,countrylist
),
904 LUA_REG(wext
,hwmodelist
),
905 LUA_REG(wext
,htmodelist
),
906 LUA_REG(wext
,encryption
),
907 LUA_REG(wext
,mbssid_support
),
908 LUA_REG(wext
,hardware_id
),
909 LUA_REG(wext
,hardware_name
),
910 LUA_REG(wext
,phyname
),
915 static const luaL_reg R_common
[] = {
916 { "type", iwinfo_L_type
},
917 { "__gc", iwinfo_L__gc
},
922 LUALIB_API
int luaopen_iwinfo(lua_State
*L
) {
923 luaL_register(L
, IWINFO_META
, R_common
);
926 luaL_newmetatable(L
, IWINFO_WL_META
);
927 luaL_register(L
, NULL
, R_common
);
928 luaL_register(L
, NULL
, R_wl
);
929 lua_pushvalue(L
, -1);
930 lua_setfield(L
, -2, "__index");
931 lua_setfield(L
, -2, "wl");
935 luaL_newmetatable(L
, IWINFO_MADWIFI_META
);
936 luaL_register(L
, NULL
, R_common
);
937 luaL_register(L
, NULL
, R_madwifi
);
938 lua_pushvalue(L
, -1);
939 lua_setfield(L
, -2, "__index");
940 lua_setfield(L
, -2, "madwifi");
944 luaL_newmetatable(L
, IWINFO_NL80211_META
);
945 luaL_register(L
, NULL
, R_common
);
946 luaL_register(L
, NULL
, R_nl80211
);
947 lua_pushvalue(L
, -1);
948 lua_setfield(L
, -2, "__index");
949 lua_setfield(L
, -2, "nl80211");
952 luaL_newmetatable(L
, IWINFO_WEXT_META
);
953 luaL_register(L
, NULL
, R_common
);
954 luaL_register(L
, NULL
, R_wext
);
955 lua_pushvalue(L
, -1);
956 lua_setfield(L
, -2, "__index");
957 lua_setfield(L
, -2, "wext");