e49e454d3a81e12a58e5bb546b8ad63ecc59be3b
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_pushboolean(L
, r
->is_he
);
272 lua_setfield(L
, -2, rx
? "rx_he" : "tx_he");
274 lua_pushnumber(L
, r
->mhz
);
275 lua_setfield(L
, -2, rx
? "rx_mhz" : "tx_mhz");
279 lua_pushboolean(L
, r
->is_40mhz
);
280 lua_setfield(L
, -2, rx
? "rx_40mhz" : "tx_40mhz");
282 lua_pushnumber(L
, r
->mcs
);
283 lua_setfield(L
, -2, rx
? "rx_mcs" : "tx_mcs");
285 lua_pushboolean(L
, r
->is_short_gi
);
286 lua_setfield(L
, -2, rx
? "rx_short_gi" : "tx_short_gi");
288 else if (r
->is_vht
|| r
->is_he
)
290 lua_pushnumber(L
, r
->mcs
);
291 lua_setfield(L
, -2, rx
? "rx_mcs" : "tx_mcs");
293 lua_pushnumber(L
, r
->nss
);
294 lua_setfield(L
, -2, rx
? "rx_nss" : "tx_nss");
297 lua_pushnumber(L
, r
->he_gi
);
298 lua_setfield(L
, -2, rx
? "rx_he_gi" : "tx_he_gi");
300 lua_pushnumber(L
, r
->he_dcm
);
301 lua_setfield(L
, -2, rx
? "rx_he_dcm" : "tx_he_dcm");
305 lua_pushboolean(L
, r
->is_short_gi
);
306 lua_setfield(L
, -2, rx
? "rx_short_gi" : "tx_short_gi");
311 /* Wrapper for assoclist */
312 static int iwinfo_L_assoclist(lua_State
*L
, int (*func
)(const char *, char *, int *))
315 char rv
[IWINFO_BUFSIZE
];
317 const char *ifname
= luaL_checkstring(L
, 1);
318 struct iwinfo_assoclist_entry
*e
;
321 memset(rv
, 0, sizeof(rv
));
323 if (!(*func
)(ifname
, rv
, &len
))
325 for (i
= 0; i
< len
; i
+= sizeof(struct iwinfo_assoclist_entry
))
327 e
= (struct iwinfo_assoclist_entry
*) &rv
[i
];
329 sprintf(macstr
, "%02X:%02X:%02X:%02X:%02X:%02X",
330 e
->mac
[0], e
->mac
[1], e
->mac
[2],
331 e
->mac
[3], e
->mac
[4], e
->mac
[5]);
335 lua_pushnumber(L
, e
->signal
);
336 lua_setfield(L
, -2, "signal");
338 lua_pushnumber(L
, e
->noise
);
339 lua_setfield(L
, -2, "noise");
341 lua_pushnumber(L
, e
->inactive
);
342 lua_setfield(L
, -2, "inactive");
344 lua_pushnumber(L
, e
->rx_packets
);
345 lua_setfield(L
, -2, "rx_packets");
347 lua_pushnumber(L
, e
->tx_packets
);
348 lua_setfield(L
, -2, "tx_packets");
350 set_rateinfo(L
, &e
->rx_rate
, true);
351 set_rateinfo(L
, &e
->tx_rate
, false);
354 lua_pushnumber(L
, e
->thr
);
355 lua_setfield(L
, -2, "expected_throughput");
358 lua_setfield(L
, -2, macstr
);
365 /* Wrapper for tx power list */
366 static int iwinfo_L_txpwrlist(lua_State
*L
, int (*func
)(const char *, char *, int *))
369 char rv
[IWINFO_BUFSIZE
];
370 const char *ifname
= luaL_checkstring(L
, 1);
371 struct iwinfo_txpwrlist_entry
*e
;
373 memset(rv
, 0, sizeof(rv
));
375 if (!(*func
)(ifname
, rv
, &len
))
379 for (i
= 0, x
= 1; i
< len
; i
+= sizeof(struct iwinfo_txpwrlist_entry
), x
++)
381 e
= (struct iwinfo_txpwrlist_entry
*) &rv
[i
];
385 lua_pushnumber(L
, e
->mw
);
386 lua_setfield(L
, -2, "mw");
388 lua_pushnumber(L
, e
->dbm
);
389 lua_setfield(L
, -2, "dbm");
391 lua_rawseti(L
, -2, x
);
400 /* Wrapper for scan list */
401 static int iwinfo_L_scanlist(lua_State
*L
, int (*func
)(const char *, char *, int *))
404 char rv
[IWINFO_BUFSIZE
];
406 const char *ifname
= luaL_checkstring(L
, 1);
407 struct iwinfo_scanlist_entry
*e
;
410 memset(rv
, 0, sizeof(rv
));
412 if (!(*func
)(ifname
, rv
, &len
))
414 for (i
= 0, x
= 1; i
< len
; i
+= sizeof(struct iwinfo_scanlist_entry
), x
++)
416 e
= (struct iwinfo_scanlist_entry
*) &rv
[i
];
421 sprintf(macstr
, "%02X:%02X:%02X:%02X:%02X:%02X",
422 e
->mac
[0], e
->mac
[1], e
->mac
[2],
423 e
->mac
[3], e
->mac
[4], e
->mac
[5]);
425 lua_pushstring(L
, macstr
);
426 lua_setfield(L
, -2, "bssid");
431 lua_pushstring(L
, (char *) e
->ssid
);
432 lua_setfield(L
, -2, "ssid");
436 lua_pushinteger(L
, e
->channel
);
437 lua_setfield(L
, -2, "channel");
440 lua_pushstring(L
, IWINFO_OPMODE_NAMES
[e
->mode
]);
441 lua_setfield(L
, -2, "mode");
443 /* Quality, Signal */
444 lua_pushinteger(L
, e
->quality
);
445 lua_setfield(L
, -2, "quality");
447 lua_pushinteger(L
, e
->quality_max
);
448 lua_setfield(L
, -2, "quality_max");
450 lua_pushnumber(L
, (e
->signal
- 0x100));
451 lua_setfield(L
, -2, "signal");
454 iwinfo_L_cryptotable(L
, &e
->crypto
);
455 lua_setfield(L
, -2, "encryption");
457 lua_rawseti(L
, -2, x
);
464 /* Wrapper for frequency list */
465 static int iwinfo_L_freqlist(lua_State
*L
, int (*func
)(const char *, char *, int *))
468 char rv
[IWINFO_BUFSIZE
];
469 const char *ifname
= luaL_checkstring(L
, 1);
470 struct iwinfo_freqlist_entry
*e
;
473 memset(rv
, 0, sizeof(rv
));
475 if (!(*func
)(ifname
, rv
, &len
))
477 for (i
= 0, x
= 1; i
< len
; i
+= sizeof(struct iwinfo_freqlist_entry
), x
++)
479 e
= (struct iwinfo_freqlist_entry
*) &rv
[i
];
484 lua_pushinteger(L
, e
->mhz
);
485 lua_setfield(L
, -2, "mhz");
488 lua_pushinteger(L
, e
->channel
);
489 lua_setfield(L
, -2, "channel");
491 /* Restricted (DFS/TPC/Radar) */
492 lua_pushboolean(L
, e
->restricted
);
493 lua_setfield(L
, -2, "restricted");
495 lua_rawseti(L
, -2, x
);
502 /* Wrapper for crypto settings */
503 static int iwinfo_L_encryption(lua_State
*L
, int (*func
)(const char *, char *))
505 const char *ifname
= luaL_checkstring(L
, 1);
506 struct iwinfo_crypto_entry c
= { 0 };
508 if (!(*func
)(ifname
, (char *)&c
))
510 iwinfo_L_cryptotable(L
, &c
);
518 /* Wrapper for hwmode list */
519 static int iwinfo_L_hwmodelist(lua_State
*L
, int (*func
)(const char *, int *))
521 const char *ifname
= luaL_checkstring(L
, 1);
524 if (!(*func
)(ifname
, &hwmodes
))
528 lua_pushboolean(L
, hwmodes
& IWINFO_80211_A
);
529 lua_setfield(L
, -2, "a");
531 lua_pushboolean(L
, hwmodes
& IWINFO_80211_B
);
532 lua_setfield(L
, -2, "b");
534 lua_pushboolean(L
, hwmodes
& IWINFO_80211_G
);
535 lua_setfield(L
, -2, "g");
537 lua_pushboolean(L
, hwmodes
& IWINFO_80211_N
);
538 lua_setfield(L
, -2, "n");
540 lua_pushboolean(L
, hwmodes
& IWINFO_80211_AC
);
541 lua_setfield(L
, -2, "ac");
543 lua_pushboolean(L
, hwmodes
& IWINFO_80211_AD
);
544 lua_setfield(L
, -2, "ad");
546 lua_pushboolean(L
, hwmodes
& IWINFO_80211_AX
);
547 lua_setfield(L
, -2, "ax");
556 /* Wrapper for htmode list */
557 static int iwinfo_L_htmodelist(lua_State
*L
, int (*func
)(const char *, int *))
559 const char *ifname
= luaL_checkstring(L
, 1);
562 if (!(*func
)(ifname
, &htmodes
))
566 for (i
= 0; i
< ARRAY_SIZE(IWINFO_HTMODE_NAMES
); i
++)
568 lua_pushboolean(L
, htmodes
& (1 << i
));
569 lua_setfield(L
, -2, IWINFO_HTMODE_NAMES
[i
]);
579 /* Wrapper for mbssid_support */
580 static int iwinfo_L_mbssid_support(lua_State
*L
, int (*func
)(const char *, int *))
582 const char *ifname
= luaL_checkstring(L
, 1);
585 if (!(*func
)(ifname
, &support
))
587 lua_pushboolean(L
, support
);
595 /* Wrapper for hardware_id */
596 static int iwinfo_L_hardware_id(lua_State
*L
, int (*func
)(const char *, char *))
598 const char *ifname
= luaL_checkstring(L
, 1);
599 struct iwinfo_hardware_id ids
;
601 if (!(*func
)(ifname
, (char *)&ids
))
605 lua_pushnumber(L
, ids
.vendor_id
);
606 lua_setfield(L
, -2, "vendor_id");
608 lua_pushnumber(L
, ids
.device_id
);
609 lua_setfield(L
, -2, "device_id");
611 lua_pushnumber(L
, ids
.subsystem_vendor_id
);
612 lua_setfield(L
, -2, "subsystem_vendor_id");
614 lua_pushnumber(L
, ids
.subsystem_device_id
);
615 lua_setfield(L
, -2, "subsystem_device_id");
625 /* Wrapper for country list */
626 static char * iwinfo_L_country_lookup(char *buf
, int len
, int iso3166
)
629 struct iwinfo_country_entry
*c
;
631 for (i
= 0; i
< len
; i
+= sizeof(struct iwinfo_country_entry
))
633 c
= (struct iwinfo_country_entry
*) &buf
[i
];
635 if (c
->iso3166
== iso3166
)
642 static int iwinfo_L_countrylist(lua_State
*L
, int (*func
)(const char *, char *, int *))
645 char rv
[IWINFO_BUFSIZE
], alpha2
[3];
647 const char *ifname
= luaL_checkstring(L
, 1);
648 const struct iwinfo_iso3166_label
*l
;
651 memset(rv
, 0, sizeof(rv
));
653 if (!(*func
)(ifname
, rv
, &len
))
655 for (l
= IWINFO_ISO3166_NAMES
, i
= 1; l
->iso3166
; l
++)
657 if ((ccode
= iwinfo_L_country_lookup(rv
, len
, l
->iso3166
)) != NULL
)
659 sprintf(alpha2
, "%c%c",
660 (l
->iso3166
/ 256), (l
->iso3166
% 256));
664 lua_pushstring(L
, alpha2
);
665 lua_setfield(L
, -2, "alpha2");
667 lua_pushstring(L
, ccode
);
668 lua_setfield(L
, -2, "ccode");
670 lua_pushstring(L
, l
->name
);
671 lua_setfield(L
, -2, "name");
673 lua_rawseti(L
, -2, i
++);
684 LUA_WRAP_INT_OP(wl
,channel
)
685 LUA_WRAP_INT_OP(wl
,frequency
)
686 LUA_WRAP_INT_OP(wl
,frequency_offset
)
687 LUA_WRAP_INT_OP(wl
,txpower
)
688 LUA_WRAP_INT_OP(wl
,txpower_offset
)
689 LUA_WRAP_INT_OP(wl
,bitrate
)
690 LUA_WRAP_INT_OP(wl
,signal
)
691 LUA_WRAP_INT_OP(wl
,noise
)
692 LUA_WRAP_INT_OP(wl
,quality
)
693 LUA_WRAP_INT_OP(wl
,quality_max
)
694 LUA_WRAP_STRING_OP(wl
,ssid
)
695 LUA_WRAP_STRING_OP(wl
,bssid
)
696 LUA_WRAP_STRING_OP(wl
,country
)
697 LUA_WRAP_STRING_OP(wl
,hardware_name
)
698 LUA_WRAP_STRING_OP(wl
,phyname
)
699 LUA_WRAP_STRUCT_OP(wl
,mode
)
700 LUA_WRAP_STRUCT_OP(wl
,assoclist
)
701 LUA_WRAP_STRUCT_OP(wl
,txpwrlist
)
702 LUA_WRAP_STRUCT_OP(wl
,scanlist
)
703 LUA_WRAP_STRUCT_OP(wl
,freqlist
)
704 LUA_WRAP_STRUCT_OP(wl
,countrylist
)
705 LUA_WRAP_STRUCT_OP(wl
,hwmodelist
)
706 LUA_WRAP_STRUCT_OP(wl
,htmodelist
)
707 LUA_WRAP_STRUCT_OP(wl
,encryption
)
708 LUA_WRAP_STRUCT_OP(wl
,mbssid_support
)
709 LUA_WRAP_STRUCT_OP(wl
,hardware_id
)
714 LUA_WRAP_INT_OP(madwifi
,channel
)
715 LUA_WRAP_INT_OP(madwifi
,frequency
)
716 LUA_WRAP_INT_OP(madwifi
,frequency_offset
)
717 LUA_WRAP_INT_OP(madwifi
,txpower
)
718 LUA_WRAP_INT_OP(madwifi
,txpower_offset
)
719 LUA_WRAP_INT_OP(madwifi
,bitrate
)
720 LUA_WRAP_INT_OP(madwifi
,signal
)
721 LUA_WRAP_INT_OP(madwifi
,noise
)
722 LUA_WRAP_INT_OP(madwifi
,quality
)
723 LUA_WRAP_INT_OP(madwifi
,quality_max
)
724 LUA_WRAP_STRING_OP(madwifi
,ssid
)
725 LUA_WRAP_STRING_OP(madwifi
,bssid
)
726 LUA_WRAP_STRING_OP(madwifi
,country
)
727 LUA_WRAP_STRING_OP(madwifi
,hardware_name
)
728 LUA_WRAP_STRING_OP(madwifi
,phyname
)
729 LUA_WRAP_STRUCT_OP(madwifi
,mode
)
730 LUA_WRAP_STRUCT_OP(madwifi
,assoclist
)
731 LUA_WRAP_STRUCT_OP(madwifi
,txpwrlist
)
732 LUA_WRAP_STRUCT_OP(madwifi
,scanlist
)
733 LUA_WRAP_STRUCT_OP(madwifi
,freqlist
)
734 LUA_WRAP_STRUCT_OP(madwifi
,countrylist
)
735 LUA_WRAP_STRUCT_OP(madwifi
,hwmodelist
)
736 LUA_WRAP_STRUCT_OP(madwifi
,htmodelist
)
737 LUA_WRAP_STRUCT_OP(madwifi
,encryption
)
738 LUA_WRAP_STRUCT_OP(madwifi
,mbssid_support
)
739 LUA_WRAP_STRUCT_OP(madwifi
,hardware_id
)
744 LUA_WRAP_INT_OP(nl80211
,channel
)
745 LUA_WRAP_INT_OP(nl80211
,frequency
)
746 LUA_WRAP_INT_OP(nl80211
,frequency_offset
)
747 LUA_WRAP_INT_OP(nl80211
,txpower
)
748 LUA_WRAP_INT_OP(nl80211
,txpower_offset
)
749 LUA_WRAP_INT_OP(nl80211
,bitrate
)
750 LUA_WRAP_INT_OP(nl80211
,signal
)
751 LUA_WRAP_INT_OP(nl80211
,noise
)
752 LUA_WRAP_INT_OP(nl80211
,quality
)
753 LUA_WRAP_INT_OP(nl80211
,quality_max
)
754 LUA_WRAP_STRING_OP(nl80211
,ssid
)
755 LUA_WRAP_STRING_OP(nl80211
,bssid
)
756 LUA_WRAP_STRING_OP(nl80211
,country
)
757 LUA_WRAP_STRING_OP(nl80211
,hardware_name
)
758 LUA_WRAP_STRING_OP(nl80211
,phyname
)
759 LUA_WRAP_STRUCT_OP(nl80211
,mode
)
760 LUA_WRAP_STRUCT_OP(nl80211
,assoclist
)
761 LUA_WRAP_STRUCT_OP(nl80211
,txpwrlist
)
762 LUA_WRAP_STRUCT_OP(nl80211
,scanlist
)
763 LUA_WRAP_STRUCT_OP(nl80211
,freqlist
)
764 LUA_WRAP_STRUCT_OP(nl80211
,countrylist
)
765 LUA_WRAP_STRUCT_OP(nl80211
,hwmodelist
)
766 LUA_WRAP_STRUCT_OP(nl80211
,htmodelist
)
767 LUA_WRAP_STRUCT_OP(nl80211
,encryption
)
768 LUA_WRAP_STRUCT_OP(nl80211
,mbssid_support
)
769 LUA_WRAP_STRUCT_OP(nl80211
,hardware_id
)
773 LUA_WRAP_INT_OP(wext
,channel
)
774 LUA_WRAP_INT_OP(wext
,frequency
)
775 LUA_WRAP_INT_OP(wext
,frequency_offset
)
776 LUA_WRAP_INT_OP(wext
,txpower
)
777 LUA_WRAP_INT_OP(wext
,txpower_offset
)
778 LUA_WRAP_INT_OP(wext
,bitrate
)
779 LUA_WRAP_INT_OP(wext
,signal
)
780 LUA_WRAP_INT_OP(wext
,noise
)
781 LUA_WRAP_INT_OP(wext
,quality
)
782 LUA_WRAP_INT_OP(wext
,quality_max
)
783 LUA_WRAP_STRING_OP(wext
,ssid
)
784 LUA_WRAP_STRING_OP(wext
,bssid
)
785 LUA_WRAP_STRING_OP(wext
,country
)
786 LUA_WRAP_STRING_OP(wext
,hardware_name
)
787 LUA_WRAP_STRING_OP(wext
,phyname
)
788 LUA_WRAP_STRUCT_OP(wext
,mode
)
789 LUA_WRAP_STRUCT_OP(wext
,assoclist
)
790 LUA_WRAP_STRUCT_OP(wext
,txpwrlist
)
791 LUA_WRAP_STRUCT_OP(wext
,scanlist
)
792 LUA_WRAP_STRUCT_OP(wext
,freqlist
)
793 LUA_WRAP_STRUCT_OP(wext
,countrylist
)
794 LUA_WRAP_STRUCT_OP(wext
,hwmodelist
)
795 LUA_WRAP_STRUCT_OP(wext
,htmodelist
)
796 LUA_WRAP_STRUCT_OP(wext
,encryption
)
797 LUA_WRAP_STRUCT_OP(wext
,mbssid_support
)
798 LUA_WRAP_STRUCT_OP(wext
,hardware_id
)
802 static const luaL_reg R_wl
[] = {
804 LUA_REG(wl
,frequency
),
805 LUA_REG(wl
,frequency_offset
),
807 LUA_REG(wl
,txpower_offset
),
812 LUA_REG(wl
,quality_max
),
817 LUA_REG(wl
,assoclist
),
818 LUA_REG(wl
,txpwrlist
),
819 LUA_REG(wl
,scanlist
),
820 LUA_REG(wl
,freqlist
),
821 LUA_REG(wl
,countrylist
),
822 LUA_REG(wl
,hwmodelist
),
823 LUA_REG(wl
,htmodelist
),
824 LUA_REG(wl
,encryption
),
825 LUA_REG(wl
,mbssid_support
),
826 LUA_REG(wl
,hardware_id
),
827 LUA_REG(wl
,hardware_name
),
835 static const luaL_reg R_madwifi
[] = {
836 LUA_REG(madwifi
,channel
),
837 LUA_REG(madwifi
,frequency
),
838 LUA_REG(madwifi
,frequency_offset
),
839 LUA_REG(madwifi
,txpower
),
840 LUA_REG(madwifi
,txpower_offset
),
841 LUA_REG(madwifi
,bitrate
),
842 LUA_REG(madwifi
,signal
),
843 LUA_REG(madwifi
,noise
),
844 LUA_REG(madwifi
,quality
),
845 LUA_REG(madwifi
,quality_max
),
846 LUA_REG(madwifi
,mode
),
847 LUA_REG(madwifi
,ssid
),
848 LUA_REG(madwifi
,bssid
),
849 LUA_REG(madwifi
,country
),
850 LUA_REG(madwifi
,assoclist
),
851 LUA_REG(madwifi
,txpwrlist
),
852 LUA_REG(madwifi
,scanlist
),
853 LUA_REG(madwifi
,freqlist
),
854 LUA_REG(madwifi
,countrylist
),
855 LUA_REG(madwifi
,hwmodelist
),
856 LUA_REG(madwifi
,htmodelist
),
857 LUA_REG(madwifi
,encryption
),
858 LUA_REG(madwifi
,mbssid_support
),
859 LUA_REG(madwifi
,hardware_id
),
860 LUA_REG(madwifi
,hardware_name
),
861 LUA_REG(madwifi
,phyname
),
868 static const luaL_reg R_nl80211
[] = {
869 LUA_REG(nl80211
,channel
),
870 LUA_REG(nl80211
,frequency
),
871 LUA_REG(nl80211
,frequency_offset
),
872 LUA_REG(nl80211
,txpower
),
873 LUA_REG(nl80211
,txpower_offset
),
874 LUA_REG(nl80211
,bitrate
),
875 LUA_REG(nl80211
,signal
),
876 LUA_REG(nl80211
,noise
),
877 LUA_REG(nl80211
,quality
),
878 LUA_REG(nl80211
,quality_max
),
879 LUA_REG(nl80211
,mode
),
880 LUA_REG(nl80211
,ssid
),
881 LUA_REG(nl80211
,bssid
),
882 LUA_REG(nl80211
,country
),
883 LUA_REG(nl80211
,assoclist
),
884 LUA_REG(nl80211
,txpwrlist
),
885 LUA_REG(nl80211
,scanlist
),
886 LUA_REG(nl80211
,freqlist
),
887 LUA_REG(nl80211
,countrylist
),
888 LUA_REG(nl80211
,hwmodelist
),
889 LUA_REG(nl80211
,htmodelist
),
890 LUA_REG(nl80211
,encryption
),
891 LUA_REG(nl80211
,mbssid_support
),
892 LUA_REG(nl80211
,hardware_id
),
893 LUA_REG(nl80211
,hardware_name
),
894 LUA_REG(nl80211
,phyname
),
900 static const luaL_reg R_wext
[] = {
901 LUA_REG(wext
,channel
),
902 LUA_REG(wext
,frequency
),
903 LUA_REG(wext
,frequency_offset
),
904 LUA_REG(wext
,txpower
),
905 LUA_REG(wext
,txpower_offset
),
906 LUA_REG(wext
,bitrate
),
907 LUA_REG(wext
,signal
),
909 LUA_REG(wext
,quality
),
910 LUA_REG(wext
,quality_max
),
914 LUA_REG(wext
,country
),
915 LUA_REG(wext
,assoclist
),
916 LUA_REG(wext
,txpwrlist
),
917 LUA_REG(wext
,scanlist
),
918 LUA_REG(wext
,freqlist
),
919 LUA_REG(wext
,countrylist
),
920 LUA_REG(wext
,hwmodelist
),
921 LUA_REG(wext
,htmodelist
),
922 LUA_REG(wext
,encryption
),
923 LUA_REG(wext
,mbssid_support
),
924 LUA_REG(wext
,hardware_id
),
925 LUA_REG(wext
,hardware_name
),
926 LUA_REG(wext
,phyname
),
931 static const luaL_reg R_common
[] = {
932 { "type", iwinfo_L_type
},
933 { "__gc", iwinfo_L__gc
},
938 LUALIB_API
int luaopen_iwinfo(lua_State
*L
) {
939 luaL_register(L
, IWINFO_META
, R_common
);
942 luaL_newmetatable(L
, IWINFO_WL_META
);
943 luaL_register(L
, NULL
, R_common
);
944 luaL_register(L
, NULL
, R_wl
);
945 lua_pushvalue(L
, -1);
946 lua_setfield(L
, -2, "__index");
947 lua_setfield(L
, -2, "wl");
951 luaL_newmetatable(L
, IWINFO_MADWIFI_META
);
952 luaL_register(L
, NULL
, R_common
);
953 luaL_register(L
, NULL
, R_madwifi
);
954 lua_pushvalue(L
, -1);
955 lua_setfield(L
, -2, "__index");
956 lua_setfield(L
, -2, "madwifi");
960 luaL_newmetatable(L
, IWINFO_NL80211_META
);
961 luaL_register(L
, NULL
, R_common
);
962 luaL_register(L
, NULL
, R_nl80211
);
963 lua_pushvalue(L
, -1);
964 lua_setfield(L
, -2, "__index");
965 lua_setfield(L
, -2, "nl80211");
968 luaL_newmetatable(L
, IWINFO_WEXT_META
);
969 luaL_register(L
, NULL
, R_common
);
970 luaL_register(L
, NULL
, R_wext
);
971 lua_pushvalue(L
, -1);
972 lua_setfield(L
, -2, "__index");
973 lua_setfield(L
, -2, "wext");