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_CCMP256
)
65 pos
+= sprintf(pos
, "CCMP-256, ");
67 if (ciphers
& IWINFO_CIPHER_GCMP
)
68 pos
+= sprintf(pos
, "GCMP, ");
70 if (ciphers
& IWINFO_CIPHER_GCMP256
)
71 pos
+= sprintf(pos
, "GCMP-256, ");
73 if (ciphers
& IWINFO_CIPHER_WRAP
)
74 pos
+= sprintf(pos
, "WRAP, ");
76 if (ciphers
& IWINFO_CIPHER_AESOCB
)
77 pos
+= sprintf(pos
, "AES-OCB, ");
79 if (ciphers
& IWINFO_CIPHER_CKIP
)
80 pos
+= sprintf(pos
, "CKIP, ");
82 if (!ciphers
|| (ciphers
& IWINFO_CIPHER_NONE
))
83 pos
+= sprintf(pos
, "NONE, ");
90 static char * iwinfo_crypto_print_suites(int suites
)
92 static char str
[64] = { 0 };
95 if (suites
& IWINFO_KMGMT_PSK
)
96 pos
+= sprintf(pos
, "PSK/");
98 if (suites
& IWINFO_KMGMT_8021x
)
99 pos
+= sprintf(pos
, "802.1X/");
101 if (suites
& IWINFO_KMGMT_SAE
)
102 pos
+= sprintf(pos
, "SAE/");
104 if (suites
& IWINFO_KMGMT_OWE
)
105 pos
+= sprintf(pos
, "OWE/");
107 if (!suites
|| (suites
& IWINFO_KMGMT_NONE
))
108 pos
+= sprintf(pos
, "NONE/");
115 static char * iwinfo_crypto_desc(struct iwinfo_crypto_entry
*c
)
117 static char desc
[512] = { 0 };
126 if (c
->auth_algs
&& !c
->wpa_version
)
128 if ((c
->auth_algs
& IWINFO_AUTH_OPEN
) &&
129 (c
->auth_algs
& IWINFO_AUTH_SHARED
))
131 sprintf(desc
, "WEP Open/Shared (%s)",
132 iwinfo_crypto_print_ciphers(c
->pair_ciphers
));
134 else if (c
->auth_algs
& IWINFO_AUTH_OPEN
)
136 sprintf(desc
, "WEP Open System (%s)",
137 iwinfo_crypto_print_ciphers(c
->pair_ciphers
));
139 else if (c
->auth_algs
& IWINFO_AUTH_SHARED
)
141 sprintf(desc
, "WEP Shared Auth (%s)",
142 iwinfo_crypto_print_ciphers(c
->pair_ciphers
));
147 else if (c
->wpa_version
)
149 for (i
= 0, n
= 0; i
< 3; i
++)
150 if (c
->wpa_version
& (1 << i
))
154 pos
+= sprintf(pos
, "mixed ");
156 for (i
= 0; i
< 3; i
++)
157 if (c
->wpa_version
& (1 << i
))
159 pos
+= sprintf(pos
, "WPA%d/", i
+ 1);
161 pos
+= sprintf(pos
, "WPA/");
165 sprintf(pos
, " %s (%s)",
166 iwinfo_crypto_print_suites(c
->auth_suites
),
167 iwinfo_crypto_print_ciphers(
168 c
->pair_ciphers
| c
->group_ciphers
));
172 sprintf(desc
, "None");
177 sprintf(desc
, "None");
182 sprintf(desc
, "Unknown");
188 /* Build Lua table from crypto data */
189 static void iwinfo_L_cryptotable(lua_State
*L
, struct iwinfo_crypto_entry
*c
)
195 lua_pushboolean(L
, c
->enabled
);
196 lua_setfield(L
, -2, "enabled");
198 lua_pushstring(L
, iwinfo_crypto_desc(c
));
199 lua_setfield(L
, -2, "description");
201 lua_pushboolean(L
, (c
->enabled
&& !c
->wpa_version
));
202 lua_setfield(L
, -2, "wep");
204 lua_pushinteger(L
, c
->wpa_version
);
205 lua_setfield(L
, -2, "wpa");
208 for (i
= 0, j
= 1; i
< ARRAY_SIZE(IWINFO_CIPHER_NAMES
); i
++)
210 if (c
->pair_ciphers
& (1 << i
))
212 lua_pushstring(L
, IWINFO_CIPHER_NAMES
[i
]);
213 lua_rawseti(L
, -2, j
++);
216 lua_setfield(L
, -2, "pair_ciphers");
219 for (i
= 0, j
= 1; i
< ARRAY_SIZE(IWINFO_CIPHER_NAMES
); i
++)
221 if (c
->group_ciphers
& (1 << i
))
223 lua_pushstring(L
, IWINFO_CIPHER_NAMES
[i
]);
224 lua_rawseti(L
, -2, j
++);
227 lua_setfield(L
, -2, "group_ciphers");
230 for (i
= 0, j
= 1; i
< ARRAY_SIZE(IWINFO_KMGMT_NAMES
); i
++)
232 if (c
->auth_suites
& (1 << i
))
234 lua_pushstring(L
, IWINFO_KMGMT_NAMES
[i
]);
235 lua_rawseti(L
, -2, j
++);
238 lua_setfield(L
, -2, "auth_suites");
241 for (i
= 0, j
= 1; i
< ARRAY_SIZE(IWINFO_AUTH_NAMES
); i
++)
243 if (c
->auth_algs
& (1 << i
))
245 lua_pushstring(L
, IWINFO_AUTH_NAMES
[i
]);
246 lua_rawseti(L
, -2, j
++);
249 lua_setfield(L
, -2, "auth_algs");
253 /* Wrapper for mode */
254 static int iwinfo_L_mode(lua_State
*L
, int (*func
)(const char *, int *))
257 const char *ifname
= luaL_checkstring(L
, 1);
259 if ((*func
)(ifname
, &mode
))
260 mode
= IWINFO_OPMODE_UNKNOWN
;
262 lua_pushstring(L
, IWINFO_OPMODE_NAMES
[mode
]);
266 static void set_rateinfo(lua_State
*L
, struct iwinfo_rate_entry
*r
, bool rx
)
268 lua_pushnumber(L
, r
->rate
);
269 lua_setfield(L
, -2, rx
? "rx_rate" : "tx_rate");
271 lua_pushboolean(L
, r
->is_ht
);
272 lua_setfield(L
, -2, rx
? "rx_ht" : "tx_ht");
274 lua_pushboolean(L
, r
->is_vht
);
275 lua_setfield(L
, -2, rx
? "rx_vht" : "tx_vht");
277 lua_pushboolean(L
, r
->is_he
);
278 lua_setfield(L
, -2, rx
? "rx_he" : "tx_he");
280 lua_pushnumber(L
, r
->mhz
);
281 lua_setfield(L
, -2, rx
? "rx_mhz" : "tx_mhz");
285 lua_pushboolean(L
, r
->is_40mhz
);
286 lua_setfield(L
, -2, rx
? "rx_40mhz" : "tx_40mhz");
288 lua_pushnumber(L
, r
->mcs
);
289 lua_setfield(L
, -2, rx
? "rx_mcs" : "tx_mcs");
291 lua_pushboolean(L
, r
->is_short_gi
);
292 lua_setfield(L
, -2, rx
? "rx_short_gi" : "tx_short_gi");
294 else if (r
->is_vht
|| r
->is_he
)
296 lua_pushnumber(L
, r
->mcs
);
297 lua_setfield(L
, -2, rx
? "rx_mcs" : "tx_mcs");
299 lua_pushnumber(L
, r
->nss
);
300 lua_setfield(L
, -2, rx
? "rx_nss" : "tx_nss");
303 lua_pushnumber(L
, r
->he_gi
);
304 lua_setfield(L
, -2, rx
? "rx_he_gi" : "tx_he_gi");
306 lua_pushnumber(L
, r
->he_dcm
);
307 lua_setfield(L
, -2, rx
? "rx_he_dcm" : "tx_he_dcm");
311 lua_pushboolean(L
, r
->is_short_gi
);
312 lua_setfield(L
, -2, rx
? "rx_short_gi" : "tx_short_gi");
317 /* Wrapper for assoclist */
318 static int iwinfo_L_assoclist(lua_State
*L
, int (*func
)(const char *, char *, int *))
321 char rv
[IWINFO_BUFSIZE
];
323 const char *ifname
= luaL_checkstring(L
, 1);
324 struct iwinfo_assoclist_entry
*e
;
327 memset(rv
, 0, sizeof(rv
));
329 if (!(*func
)(ifname
, rv
, &len
))
331 for (i
= 0; i
< len
; i
+= sizeof(struct iwinfo_assoclist_entry
))
333 e
= (struct iwinfo_assoclist_entry
*) &rv
[i
];
335 sprintf(macstr
, "%02X:%02X:%02X:%02X:%02X:%02X",
336 e
->mac
[0], e
->mac
[1], e
->mac
[2],
337 e
->mac
[3], e
->mac
[4], e
->mac
[5]);
341 lua_pushnumber(L
, e
->signal
);
342 lua_setfield(L
, -2, "signal");
344 lua_pushnumber(L
, e
->noise
);
345 lua_setfield(L
, -2, "noise");
347 lua_pushnumber(L
, e
->inactive
);
348 lua_setfield(L
, -2, "inactive");
350 lua_pushnumber(L
, e
->rx_packets
);
351 lua_setfield(L
, -2, "rx_packets");
353 lua_pushnumber(L
, e
->tx_packets
);
354 lua_setfield(L
, -2, "tx_packets");
356 set_rateinfo(L
, &e
->rx_rate
, true);
357 set_rateinfo(L
, &e
->tx_rate
, false);
360 lua_pushnumber(L
, e
->thr
);
361 lua_setfield(L
, -2, "expected_throughput");
364 lua_setfield(L
, -2, macstr
);
371 /* Wrapper for tx power list */
372 static int iwinfo_L_txpwrlist(lua_State
*L
, int (*func
)(const char *, char *, int *))
375 char rv
[IWINFO_BUFSIZE
];
376 const char *ifname
= luaL_checkstring(L
, 1);
377 struct iwinfo_txpwrlist_entry
*e
;
379 memset(rv
, 0, sizeof(rv
));
381 if (!(*func
)(ifname
, rv
, &len
))
385 for (i
= 0, x
= 1; i
< len
; i
+= sizeof(struct iwinfo_txpwrlist_entry
), x
++)
387 e
= (struct iwinfo_txpwrlist_entry
*) &rv
[i
];
391 lua_pushnumber(L
, e
->mw
);
392 lua_setfield(L
, -2, "mw");
394 lua_pushnumber(L
, e
->dbm
);
395 lua_setfield(L
, -2, "dbm");
397 lua_rawseti(L
, -2, x
);
406 /* Wrapper for scan list */
407 static int iwinfo_L_scanlist(lua_State
*L
, int (*func
)(const char *, char *, int *))
410 char rv
[IWINFO_BUFSIZE
];
412 const char *ifname
= luaL_checkstring(L
, 1);
413 struct iwinfo_scanlist_entry
*e
;
416 memset(rv
, 0, sizeof(rv
));
418 if (!(*func
)(ifname
, rv
, &len
))
420 for (i
= 0, x
= 1; i
< len
; i
+= sizeof(struct iwinfo_scanlist_entry
), x
++)
422 e
= (struct iwinfo_scanlist_entry
*) &rv
[i
];
427 sprintf(macstr
, "%02X:%02X:%02X:%02X:%02X:%02X",
428 e
->mac
[0], e
->mac
[1], e
->mac
[2],
429 e
->mac
[3], e
->mac
[4], e
->mac
[5]);
431 lua_pushstring(L
, macstr
);
432 lua_setfield(L
, -2, "bssid");
437 lua_pushstring(L
, (char *) e
->ssid
);
438 lua_setfield(L
, -2, "ssid");
442 lua_pushinteger(L
, e
->channel
);
443 lua_setfield(L
, -2, "channel");
446 lua_pushstring(L
, IWINFO_OPMODE_NAMES
[e
->mode
]);
447 lua_setfield(L
, -2, "mode");
449 /* Quality, Signal */
450 lua_pushinteger(L
, e
->quality
);
451 lua_setfield(L
, -2, "quality");
453 lua_pushinteger(L
, e
->quality_max
);
454 lua_setfield(L
, -2, "quality_max");
456 lua_pushnumber(L
, (e
->signal
- 0x100));
457 lua_setfield(L
, -2, "signal");
460 iwinfo_L_cryptotable(L
, &e
->crypto
);
461 lua_setfield(L
, -2, "encryption");
463 lua_rawseti(L
, -2, x
);
470 /* Wrapper for frequency list */
471 static int iwinfo_L_freqlist(lua_State
*L
, int (*func
)(const char *, char *, int *))
474 char rv
[IWINFO_BUFSIZE
];
475 const char *ifname
= luaL_checkstring(L
, 1);
476 struct iwinfo_freqlist_entry
*e
;
479 memset(rv
, 0, sizeof(rv
));
481 if (!(*func
)(ifname
, rv
, &len
))
483 for (i
= 0, x
= 1; i
< len
; i
+= sizeof(struct iwinfo_freqlist_entry
), x
++)
485 e
= (struct iwinfo_freqlist_entry
*) &rv
[i
];
490 lua_pushinteger(L
, e
->mhz
);
491 lua_setfield(L
, -2, "mhz");
494 lua_pushinteger(L
, e
->channel
);
495 lua_setfield(L
, -2, "channel");
497 /* Restricted (DFS/TPC/Radar) */
498 lua_pushboolean(L
, e
->restricted
);
499 lua_setfield(L
, -2, "restricted");
501 lua_rawseti(L
, -2, x
);
508 /* Wrapper for crypto settings */
509 static int iwinfo_L_encryption(lua_State
*L
, int (*func
)(const char *, char *))
511 const char *ifname
= luaL_checkstring(L
, 1);
512 struct iwinfo_crypto_entry c
= { 0 };
514 if (!(*func
)(ifname
, (char *)&c
))
516 iwinfo_L_cryptotable(L
, &c
);
524 /* Wrapper for hwmode list */
525 static int iwinfo_L_hwmodelist(lua_State
*L
, int (*func
)(const char *, int *))
527 const char *ifname
= luaL_checkstring(L
, 1);
530 if (!(*func
)(ifname
, &hwmodes
))
534 lua_pushboolean(L
, hwmodes
& IWINFO_80211_A
);
535 lua_setfield(L
, -2, "a");
537 lua_pushboolean(L
, hwmodes
& IWINFO_80211_B
);
538 lua_setfield(L
, -2, "b");
540 lua_pushboolean(L
, hwmodes
& IWINFO_80211_G
);
541 lua_setfield(L
, -2, "g");
543 lua_pushboolean(L
, hwmodes
& IWINFO_80211_N
);
544 lua_setfield(L
, -2, "n");
546 lua_pushboolean(L
, hwmodes
& IWINFO_80211_AC
);
547 lua_setfield(L
, -2, "ac");
549 lua_pushboolean(L
, hwmodes
& IWINFO_80211_AD
);
550 lua_setfield(L
, -2, "ad");
552 lua_pushboolean(L
, hwmodes
& IWINFO_80211_AX
);
553 lua_setfield(L
, -2, "ax");
562 /* Wrapper for htmode list */
563 static int iwinfo_L_htmodelist(lua_State
*L
, int (*func
)(const char *, int *))
565 const char *ifname
= luaL_checkstring(L
, 1);
568 if (!(*func
)(ifname
, &htmodes
))
572 for (i
= 0; i
< ARRAY_SIZE(IWINFO_HTMODE_NAMES
); i
++)
574 lua_pushboolean(L
, htmodes
& (1 << i
));
575 lua_setfield(L
, -2, IWINFO_HTMODE_NAMES
[i
]);
585 /* Wrapper for mbssid_support */
586 static int iwinfo_L_mbssid_support(lua_State
*L
, int (*func
)(const char *, int *))
588 const char *ifname
= luaL_checkstring(L
, 1);
591 if (!(*func
)(ifname
, &support
))
593 lua_pushboolean(L
, support
);
601 /* Wrapper for hardware_id */
602 static int iwinfo_L_hardware_id(lua_State
*L
, int (*func
)(const char *, char *))
604 const char *ifname
= luaL_checkstring(L
, 1);
605 struct iwinfo_hardware_id ids
;
607 if (!(*func
)(ifname
, (char *)&ids
))
611 lua_pushnumber(L
, ids
.vendor_id
);
612 lua_setfield(L
, -2, "vendor_id");
614 lua_pushnumber(L
, ids
.device_id
);
615 lua_setfield(L
, -2, "device_id");
617 lua_pushnumber(L
, ids
.subsystem_vendor_id
);
618 lua_setfield(L
, -2, "subsystem_vendor_id");
620 lua_pushnumber(L
, ids
.subsystem_device_id
);
621 lua_setfield(L
, -2, "subsystem_device_id");
631 /* Wrapper for country list */
632 static char * iwinfo_L_country_lookup(char *buf
, int len
, int iso3166
)
635 struct iwinfo_country_entry
*c
;
637 for (i
= 0; i
< len
; i
+= sizeof(struct iwinfo_country_entry
))
639 c
= (struct iwinfo_country_entry
*) &buf
[i
];
641 if (c
->iso3166
== iso3166
)
648 static int iwinfo_L_countrylist(lua_State
*L
, int (*func
)(const char *, char *, int *))
651 char rv
[IWINFO_BUFSIZE
], alpha2
[3];
653 const char *ifname
= luaL_checkstring(L
, 1);
654 const struct iwinfo_iso3166_label
*l
;
657 memset(rv
, 0, sizeof(rv
));
659 if (!(*func
)(ifname
, rv
, &len
))
661 for (l
= IWINFO_ISO3166_NAMES
, i
= 1; l
->iso3166
; l
++)
663 if ((ccode
= iwinfo_L_country_lookup(rv
, len
, l
->iso3166
)) != NULL
)
665 sprintf(alpha2
, "%c%c",
666 (l
->iso3166
/ 256), (l
->iso3166
% 256));
670 lua_pushstring(L
, alpha2
);
671 lua_setfield(L
, -2, "alpha2");
673 lua_pushstring(L
, ccode
);
674 lua_setfield(L
, -2, "ccode");
676 lua_pushstring(L
, l
->name
);
677 lua_setfield(L
, -2, "name");
679 lua_rawseti(L
, -2, i
++);
690 LUA_WRAP_INT_OP(wl
,channel
)
691 LUA_WRAP_INT_OP(wl
,frequency
)
692 LUA_WRAP_INT_OP(wl
,frequency_offset
)
693 LUA_WRAP_INT_OP(wl
,txpower
)
694 LUA_WRAP_INT_OP(wl
,txpower_offset
)
695 LUA_WRAP_INT_OP(wl
,bitrate
)
696 LUA_WRAP_INT_OP(wl
,signal
)
697 LUA_WRAP_INT_OP(wl
,noise
)
698 LUA_WRAP_INT_OP(wl
,quality
)
699 LUA_WRAP_INT_OP(wl
,quality_max
)
700 LUA_WRAP_STRING_OP(wl
,ssid
)
701 LUA_WRAP_STRING_OP(wl
,bssid
)
702 LUA_WRAP_STRING_OP(wl
,country
)
703 LUA_WRAP_STRING_OP(wl
,hardware_name
)
704 LUA_WRAP_STRING_OP(wl
,phyname
)
705 LUA_WRAP_STRUCT_OP(wl
,mode
)
706 LUA_WRAP_STRUCT_OP(wl
,assoclist
)
707 LUA_WRAP_STRUCT_OP(wl
,txpwrlist
)
708 LUA_WRAP_STRUCT_OP(wl
,scanlist
)
709 LUA_WRAP_STRUCT_OP(wl
,freqlist
)
710 LUA_WRAP_STRUCT_OP(wl
,countrylist
)
711 LUA_WRAP_STRUCT_OP(wl
,hwmodelist
)
712 LUA_WRAP_STRUCT_OP(wl
,htmodelist
)
713 LUA_WRAP_STRUCT_OP(wl
,encryption
)
714 LUA_WRAP_STRUCT_OP(wl
,mbssid_support
)
715 LUA_WRAP_STRUCT_OP(wl
,hardware_id
)
720 LUA_WRAP_INT_OP(madwifi
,channel
)
721 LUA_WRAP_INT_OP(madwifi
,frequency
)
722 LUA_WRAP_INT_OP(madwifi
,frequency_offset
)
723 LUA_WRAP_INT_OP(madwifi
,txpower
)
724 LUA_WRAP_INT_OP(madwifi
,txpower_offset
)
725 LUA_WRAP_INT_OP(madwifi
,bitrate
)
726 LUA_WRAP_INT_OP(madwifi
,signal
)
727 LUA_WRAP_INT_OP(madwifi
,noise
)
728 LUA_WRAP_INT_OP(madwifi
,quality
)
729 LUA_WRAP_INT_OP(madwifi
,quality_max
)
730 LUA_WRAP_STRING_OP(madwifi
,ssid
)
731 LUA_WRAP_STRING_OP(madwifi
,bssid
)
732 LUA_WRAP_STRING_OP(madwifi
,country
)
733 LUA_WRAP_STRING_OP(madwifi
,hardware_name
)
734 LUA_WRAP_STRING_OP(madwifi
,phyname
)
735 LUA_WRAP_STRUCT_OP(madwifi
,mode
)
736 LUA_WRAP_STRUCT_OP(madwifi
,assoclist
)
737 LUA_WRAP_STRUCT_OP(madwifi
,txpwrlist
)
738 LUA_WRAP_STRUCT_OP(madwifi
,scanlist
)
739 LUA_WRAP_STRUCT_OP(madwifi
,freqlist
)
740 LUA_WRAP_STRUCT_OP(madwifi
,countrylist
)
741 LUA_WRAP_STRUCT_OP(madwifi
,hwmodelist
)
742 LUA_WRAP_STRUCT_OP(madwifi
,htmodelist
)
743 LUA_WRAP_STRUCT_OP(madwifi
,encryption
)
744 LUA_WRAP_STRUCT_OP(madwifi
,mbssid_support
)
745 LUA_WRAP_STRUCT_OP(madwifi
,hardware_id
)
750 LUA_WRAP_INT_OP(nl80211
,channel
)
751 LUA_WRAP_INT_OP(nl80211
,frequency
)
752 LUA_WRAP_INT_OP(nl80211
,frequency_offset
)
753 LUA_WRAP_INT_OP(nl80211
,txpower
)
754 LUA_WRAP_INT_OP(nl80211
,txpower_offset
)
755 LUA_WRAP_INT_OP(nl80211
,bitrate
)
756 LUA_WRAP_INT_OP(nl80211
,signal
)
757 LUA_WRAP_INT_OP(nl80211
,noise
)
758 LUA_WRAP_INT_OP(nl80211
,quality
)
759 LUA_WRAP_INT_OP(nl80211
,quality_max
)
760 LUA_WRAP_STRING_OP(nl80211
,ssid
)
761 LUA_WRAP_STRING_OP(nl80211
,bssid
)
762 LUA_WRAP_STRING_OP(nl80211
,country
)
763 LUA_WRAP_STRING_OP(nl80211
,hardware_name
)
764 LUA_WRAP_STRING_OP(nl80211
,phyname
)
765 LUA_WRAP_STRUCT_OP(nl80211
,mode
)
766 LUA_WRAP_STRUCT_OP(nl80211
,assoclist
)
767 LUA_WRAP_STRUCT_OP(nl80211
,txpwrlist
)
768 LUA_WRAP_STRUCT_OP(nl80211
,scanlist
)
769 LUA_WRAP_STRUCT_OP(nl80211
,freqlist
)
770 LUA_WRAP_STRUCT_OP(nl80211
,countrylist
)
771 LUA_WRAP_STRUCT_OP(nl80211
,hwmodelist
)
772 LUA_WRAP_STRUCT_OP(nl80211
,htmodelist
)
773 LUA_WRAP_STRUCT_OP(nl80211
,encryption
)
774 LUA_WRAP_STRUCT_OP(nl80211
,mbssid_support
)
775 LUA_WRAP_STRUCT_OP(nl80211
,hardware_id
)
780 LUA_WRAP_INT_OP(wext
,channel
)
781 LUA_WRAP_INT_OP(wext
,frequency
)
782 LUA_WRAP_INT_OP(wext
,frequency_offset
)
783 LUA_WRAP_INT_OP(wext
,txpower
)
784 LUA_WRAP_INT_OP(wext
,txpower_offset
)
785 LUA_WRAP_INT_OP(wext
,bitrate
)
786 LUA_WRAP_INT_OP(wext
,signal
)
787 LUA_WRAP_INT_OP(wext
,noise
)
788 LUA_WRAP_INT_OP(wext
,quality
)
789 LUA_WRAP_INT_OP(wext
,quality_max
)
790 LUA_WRAP_STRING_OP(wext
,ssid
)
791 LUA_WRAP_STRING_OP(wext
,bssid
)
792 LUA_WRAP_STRING_OP(wext
,country
)
793 LUA_WRAP_STRING_OP(wext
,hardware_name
)
794 LUA_WRAP_STRING_OP(wext
,phyname
)
795 LUA_WRAP_STRUCT_OP(wext
,mode
)
796 LUA_WRAP_STRUCT_OP(wext
,assoclist
)
797 LUA_WRAP_STRUCT_OP(wext
,txpwrlist
)
798 LUA_WRAP_STRUCT_OP(wext
,scanlist
)
799 LUA_WRAP_STRUCT_OP(wext
,freqlist
)
800 LUA_WRAP_STRUCT_OP(wext
,countrylist
)
801 LUA_WRAP_STRUCT_OP(wext
,hwmodelist
)
802 LUA_WRAP_STRUCT_OP(wext
,htmodelist
)
803 LUA_WRAP_STRUCT_OP(wext
,encryption
)
804 LUA_WRAP_STRUCT_OP(wext
,mbssid_support
)
805 LUA_WRAP_STRUCT_OP(wext
,hardware_id
)
810 static const luaL_reg R_wl
[] = {
812 LUA_REG(wl
,frequency
),
813 LUA_REG(wl
,frequency_offset
),
815 LUA_REG(wl
,txpower_offset
),
820 LUA_REG(wl
,quality_max
),
825 LUA_REG(wl
,assoclist
),
826 LUA_REG(wl
,txpwrlist
),
827 LUA_REG(wl
,scanlist
),
828 LUA_REG(wl
,freqlist
),
829 LUA_REG(wl
,countrylist
),
830 LUA_REG(wl
,hwmodelist
),
831 LUA_REG(wl
,htmodelist
),
832 LUA_REG(wl
,encryption
),
833 LUA_REG(wl
,mbssid_support
),
834 LUA_REG(wl
,hardware_id
),
835 LUA_REG(wl
,hardware_name
),
843 static const luaL_reg R_madwifi
[] = {
844 LUA_REG(madwifi
,channel
),
845 LUA_REG(madwifi
,frequency
),
846 LUA_REG(madwifi
,frequency_offset
),
847 LUA_REG(madwifi
,txpower
),
848 LUA_REG(madwifi
,txpower_offset
),
849 LUA_REG(madwifi
,bitrate
),
850 LUA_REG(madwifi
,signal
),
851 LUA_REG(madwifi
,noise
),
852 LUA_REG(madwifi
,quality
),
853 LUA_REG(madwifi
,quality_max
),
854 LUA_REG(madwifi
,mode
),
855 LUA_REG(madwifi
,ssid
),
856 LUA_REG(madwifi
,bssid
),
857 LUA_REG(madwifi
,country
),
858 LUA_REG(madwifi
,assoclist
),
859 LUA_REG(madwifi
,txpwrlist
),
860 LUA_REG(madwifi
,scanlist
),
861 LUA_REG(madwifi
,freqlist
),
862 LUA_REG(madwifi
,countrylist
),
863 LUA_REG(madwifi
,hwmodelist
),
864 LUA_REG(madwifi
,htmodelist
),
865 LUA_REG(madwifi
,encryption
),
866 LUA_REG(madwifi
,mbssid_support
),
867 LUA_REG(madwifi
,hardware_id
),
868 LUA_REG(madwifi
,hardware_name
),
869 LUA_REG(madwifi
,phyname
),
876 static const luaL_reg R_nl80211
[] = {
877 LUA_REG(nl80211
,channel
),
878 LUA_REG(nl80211
,frequency
),
879 LUA_REG(nl80211
,frequency_offset
),
880 LUA_REG(nl80211
,txpower
),
881 LUA_REG(nl80211
,txpower_offset
),
882 LUA_REG(nl80211
,bitrate
),
883 LUA_REG(nl80211
,signal
),
884 LUA_REG(nl80211
,noise
),
885 LUA_REG(nl80211
,quality
),
886 LUA_REG(nl80211
,quality_max
),
887 LUA_REG(nl80211
,mode
),
888 LUA_REG(nl80211
,ssid
),
889 LUA_REG(nl80211
,bssid
),
890 LUA_REG(nl80211
,country
),
891 LUA_REG(nl80211
,assoclist
),
892 LUA_REG(nl80211
,txpwrlist
),
893 LUA_REG(nl80211
,scanlist
),
894 LUA_REG(nl80211
,freqlist
),
895 LUA_REG(nl80211
,countrylist
),
896 LUA_REG(nl80211
,hwmodelist
),
897 LUA_REG(nl80211
,htmodelist
),
898 LUA_REG(nl80211
,encryption
),
899 LUA_REG(nl80211
,mbssid_support
),
900 LUA_REG(nl80211
,hardware_id
),
901 LUA_REG(nl80211
,hardware_name
),
902 LUA_REG(nl80211
,phyname
),
909 static const luaL_reg R_wext
[] = {
910 LUA_REG(wext
,channel
),
911 LUA_REG(wext
,frequency
),
912 LUA_REG(wext
,frequency_offset
),
913 LUA_REG(wext
,txpower
),
914 LUA_REG(wext
,txpower_offset
),
915 LUA_REG(wext
,bitrate
),
916 LUA_REG(wext
,signal
),
918 LUA_REG(wext
,quality
),
919 LUA_REG(wext
,quality_max
),
923 LUA_REG(wext
,country
),
924 LUA_REG(wext
,assoclist
),
925 LUA_REG(wext
,txpwrlist
),
926 LUA_REG(wext
,scanlist
),
927 LUA_REG(wext
,freqlist
),
928 LUA_REG(wext
,countrylist
),
929 LUA_REG(wext
,hwmodelist
),
930 LUA_REG(wext
,htmodelist
),
931 LUA_REG(wext
,encryption
),
932 LUA_REG(wext
,mbssid_support
),
933 LUA_REG(wext
,hardware_id
),
934 LUA_REG(wext
,hardware_name
),
935 LUA_REG(wext
,phyname
),
941 static const luaL_reg R_common
[] = {
942 { "type", iwinfo_L_type
},
943 { "__gc", iwinfo_L__gc
},
948 LUALIB_API
int luaopen_iwinfo(lua_State
*L
) {
949 luaL_register(L
, IWINFO_META
, R_common
);
952 luaL_newmetatable(L
, IWINFO_WL_META
);
953 luaL_register(L
, NULL
, R_common
);
954 luaL_register(L
, NULL
, R_wl
);
955 lua_pushvalue(L
, -1);
956 lua_setfield(L
, -2, "__index");
957 lua_setfield(L
, -2, "wl");
961 luaL_newmetatable(L
, IWINFO_MADWIFI_META
);
962 luaL_register(L
, NULL
, R_common
);
963 luaL_register(L
, NULL
, R_madwifi
);
964 lua_pushvalue(L
, -1);
965 lua_setfield(L
, -2, "__index");
966 lua_setfield(L
, -2, "madwifi");
970 luaL_newmetatable(L
, IWINFO_NL80211_META
);
971 luaL_register(L
, NULL
, R_common
);
972 luaL_register(L
, NULL
, R_nl80211
);
973 lua_pushvalue(L
, -1);
974 lua_setfield(L
, -2, "__index");
975 lua_setfield(L
, -2, "nl80211");
979 luaL_newmetatable(L
, IWINFO_WEXT_META
);
980 luaL_register(L
, NULL
, R_common
);
981 luaL_register(L
, NULL
, R_wext
);
982 lua_pushvalue(L
, -1);
983 lua_setfield(L
, -2, "__index");
984 lua_setfield(L
, -2, "wext");