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
))
160 pos
+= sprintf(pos
, "WPA%d/", i
+ 1);
162 pos
+= sprintf(pos
, "WPA/");
167 sprintf(pos
, " %s (%s)",
168 iwinfo_crypto_print_suites(c
->auth_suites
),
169 iwinfo_crypto_print_ciphers(
170 c
->pair_ciphers
| c
->group_ciphers
));
174 sprintf(desc
, "None");
179 sprintf(desc
, "None");
184 sprintf(desc
, "Unknown");
190 /* Build Lua table from crypto data */
191 static void iwinfo_L_cryptotable(lua_State
*L
, struct iwinfo_crypto_entry
*c
)
197 lua_pushboolean(L
, c
->enabled
);
198 lua_setfield(L
, -2, "enabled");
200 lua_pushstring(L
, iwinfo_crypto_desc(c
));
201 lua_setfield(L
, -2, "description");
203 lua_pushboolean(L
, (c
->enabled
&& !c
->wpa_version
));
204 lua_setfield(L
, -2, "wep");
206 lua_pushinteger(L
, c
->wpa_version
);
207 lua_setfield(L
, -2, "wpa");
210 for (i
= 0, j
= 1; i
< ARRAY_SIZE(IWINFO_CIPHER_NAMES
); i
++)
212 if (c
->pair_ciphers
& (1 << i
))
214 lua_pushstring(L
, IWINFO_CIPHER_NAMES
[i
]);
215 lua_rawseti(L
, -2, j
++);
218 lua_setfield(L
, -2, "pair_ciphers");
221 for (i
= 0, j
= 1; i
< ARRAY_SIZE(IWINFO_CIPHER_NAMES
); i
++)
223 if (c
->group_ciphers
& (1 << i
))
225 lua_pushstring(L
, IWINFO_CIPHER_NAMES
[i
]);
226 lua_rawseti(L
, -2, j
++);
229 lua_setfield(L
, -2, "group_ciphers");
232 for (i
= 0, j
= 1; i
< ARRAY_SIZE(IWINFO_KMGMT_NAMES
); i
++)
234 if (c
->auth_suites
& (1 << i
))
236 lua_pushstring(L
, IWINFO_KMGMT_NAMES
[i
]);
237 lua_rawseti(L
, -2, j
++);
240 lua_setfield(L
, -2, "auth_suites");
243 for (i
= 0, j
= 1; i
< ARRAY_SIZE(IWINFO_AUTH_NAMES
); i
++)
245 if (c
->auth_algs
& (1 << i
))
247 lua_pushstring(L
, IWINFO_AUTH_NAMES
[i
]);
248 lua_rawseti(L
, -2, j
++);
251 lua_setfield(L
, -2, "auth_algs");
255 /* Wrapper for mode */
256 static int iwinfo_L_mode(lua_State
*L
, int (*func
)(const char *, int *))
259 const char *ifname
= luaL_checkstring(L
, 1);
261 if ((*func
)(ifname
, &mode
))
262 mode
= IWINFO_OPMODE_UNKNOWN
;
264 lua_pushstring(L
, IWINFO_OPMODE_NAMES
[mode
]);
268 static void set_rateinfo(lua_State
*L
, struct iwinfo_rate_entry
*r
, bool rx
)
270 lua_pushnumber(L
, r
->rate
);
271 lua_setfield(L
, -2, rx
? "rx_rate" : "tx_rate");
273 lua_pushboolean(L
, r
->is_ht
);
274 lua_setfield(L
, -2, rx
? "rx_ht" : "tx_ht");
276 lua_pushboolean(L
, r
->is_vht
);
277 lua_setfield(L
, -2, rx
? "rx_vht" : "tx_vht");
279 lua_pushboolean(L
, r
->is_he
);
280 lua_setfield(L
, -2, rx
? "rx_he" : "tx_he");
282 lua_pushnumber(L
, r
->mhz
);
283 lua_setfield(L
, -2, rx
? "rx_mhz" : "tx_mhz");
287 lua_pushboolean(L
, r
->is_40mhz
);
288 lua_setfield(L
, -2, rx
? "rx_40mhz" : "tx_40mhz");
290 lua_pushnumber(L
, r
->mcs
);
291 lua_setfield(L
, -2, rx
? "rx_mcs" : "tx_mcs");
293 lua_pushboolean(L
, r
->is_short_gi
);
294 lua_setfield(L
, -2, rx
? "rx_short_gi" : "tx_short_gi");
296 else if (r
->is_vht
|| r
->is_he
)
298 lua_pushnumber(L
, r
->mcs
);
299 lua_setfield(L
, -2, rx
? "rx_mcs" : "tx_mcs");
301 lua_pushnumber(L
, r
->nss
);
302 lua_setfield(L
, -2, rx
? "rx_nss" : "tx_nss");
305 lua_pushnumber(L
, r
->he_gi
);
306 lua_setfield(L
, -2, rx
? "rx_he_gi" : "tx_he_gi");
308 lua_pushnumber(L
, r
->he_dcm
);
309 lua_setfield(L
, -2, rx
? "rx_he_dcm" : "tx_he_dcm");
313 lua_pushboolean(L
, r
->is_short_gi
);
314 lua_setfield(L
, -2, rx
? "rx_short_gi" : "tx_short_gi");
319 /* Wrapper for assoclist */
320 static int iwinfo_L_assoclist(lua_State
*L
, int (*func
)(const char *, char *, int *))
323 char rv
[IWINFO_BUFSIZE
];
325 const char *ifname
= luaL_checkstring(L
, 1);
326 struct iwinfo_assoclist_entry
*e
;
329 memset(rv
, 0, sizeof(rv
));
331 if (!(*func
)(ifname
, rv
, &len
))
333 for (i
= 0; i
< len
; i
+= sizeof(struct iwinfo_assoclist_entry
))
335 e
= (struct iwinfo_assoclist_entry
*) &rv
[i
];
337 sprintf(macstr
, "%02X:%02X:%02X:%02X:%02X:%02X",
338 e
->mac
[0], e
->mac
[1], e
->mac
[2],
339 e
->mac
[3], e
->mac
[4], e
->mac
[5]);
343 lua_pushnumber(L
, e
->signal
);
344 lua_setfield(L
, -2, "signal");
346 lua_pushnumber(L
, e
->noise
);
347 lua_setfield(L
, -2, "noise");
349 lua_pushnumber(L
, e
->inactive
);
350 lua_setfield(L
, -2, "inactive");
352 lua_pushnumber(L
, e
->rx_packets
);
353 lua_setfield(L
, -2, "rx_packets");
355 lua_pushnumber(L
, e
->tx_packets
);
356 lua_setfield(L
, -2, "tx_packets");
358 set_rateinfo(L
, &e
->rx_rate
, true);
359 set_rateinfo(L
, &e
->tx_rate
, false);
362 lua_pushnumber(L
, e
->thr
);
363 lua_setfield(L
, -2, "expected_throughput");
366 lua_setfield(L
, -2, macstr
);
373 /* Wrapper for tx power list */
374 static int iwinfo_L_txpwrlist(lua_State
*L
, int (*func
)(const char *, char *, int *))
377 char rv
[IWINFO_BUFSIZE
];
378 const char *ifname
= luaL_checkstring(L
, 1);
379 struct iwinfo_txpwrlist_entry
*e
;
381 memset(rv
, 0, sizeof(rv
));
383 if (!(*func
)(ifname
, rv
, &len
))
387 for (i
= 0, x
= 1; i
< len
; i
+= sizeof(struct iwinfo_txpwrlist_entry
), x
++)
389 e
= (struct iwinfo_txpwrlist_entry
*) &rv
[i
];
393 lua_pushnumber(L
, e
->mw
);
394 lua_setfield(L
, -2, "mw");
396 lua_pushnumber(L
, e
->dbm
);
397 lua_setfield(L
, -2, "dbm");
399 lua_rawseti(L
, -2, x
);
408 /* Wrapper for scan list */
409 static int iwinfo_L_scanlist(lua_State
*L
, int (*func
)(const char *, char *, int *))
412 char rv
[IWINFO_BUFSIZE
];
414 const char *ifname
= luaL_checkstring(L
, 1);
415 struct iwinfo_scanlist_entry
*e
;
418 memset(rv
, 0, sizeof(rv
));
420 if (!(*func
)(ifname
, rv
, &len
))
422 for (i
= 0, x
= 1; i
< len
; i
+= sizeof(struct iwinfo_scanlist_entry
), x
++)
424 e
= (struct iwinfo_scanlist_entry
*) &rv
[i
];
429 sprintf(macstr
, "%02X:%02X:%02X:%02X:%02X:%02X",
430 e
->mac
[0], e
->mac
[1], e
->mac
[2],
431 e
->mac
[3], e
->mac
[4], e
->mac
[5]);
433 lua_pushstring(L
, macstr
);
434 lua_setfield(L
, -2, "bssid");
439 lua_pushstring(L
, (char *) e
->ssid
);
440 lua_setfield(L
, -2, "ssid");
444 lua_pushinteger(L
, e
->channel
);
445 lua_setfield(L
, -2, "channel");
448 lua_pushstring(L
, IWINFO_OPMODE_NAMES
[e
->mode
]);
449 lua_setfield(L
, -2, "mode");
451 /* Quality, Signal */
452 lua_pushinteger(L
, e
->quality
);
453 lua_setfield(L
, -2, "quality");
455 lua_pushinteger(L
, e
->quality_max
);
456 lua_setfield(L
, -2, "quality_max");
458 lua_pushnumber(L
, (e
->signal
- 0x100));
459 lua_setfield(L
, -2, "signal");
462 iwinfo_L_cryptotable(L
, &e
->crypto
);
463 lua_setfield(L
, -2, "encryption");
465 lua_rawseti(L
, -2, x
);
472 /* Wrapper for frequency list */
473 static int iwinfo_L_freqlist(lua_State
*L
, int (*func
)(const char *, char *, int *))
476 char rv
[IWINFO_BUFSIZE
];
477 const char *ifname
= luaL_checkstring(L
, 1);
478 struct iwinfo_freqlist_entry
*e
;
481 memset(rv
, 0, sizeof(rv
));
483 if (!(*func
)(ifname
, rv
, &len
))
485 for (i
= 0, x
= 1; i
< len
; i
+= sizeof(struct iwinfo_freqlist_entry
), x
++)
487 e
= (struct iwinfo_freqlist_entry
*) &rv
[i
];
492 lua_pushinteger(L
, e
->mhz
);
493 lua_setfield(L
, -2, "mhz");
496 lua_pushinteger(L
, e
->channel
);
497 lua_setfield(L
, -2, "channel");
499 /* Restricted (DFS/TPC/Radar) */
500 lua_pushboolean(L
, e
->restricted
);
501 lua_setfield(L
, -2, "restricted");
503 lua_rawseti(L
, -2, x
);
510 /* Wrapper for crypto settings */
511 static int iwinfo_L_encryption(lua_State
*L
, int (*func
)(const char *, char *))
513 const char *ifname
= luaL_checkstring(L
, 1);
514 struct iwinfo_crypto_entry c
= { 0 };
516 if (!(*func
)(ifname
, (char *)&c
))
518 iwinfo_L_cryptotable(L
, &c
);
526 /* Wrapper for hwmode list */
527 static int iwinfo_L_hwmodelist(lua_State
*L
, int (*func
)(const char *, int *))
529 const char *ifname
= luaL_checkstring(L
, 1);
532 if (!(*func
)(ifname
, &hwmodes
))
536 lua_pushboolean(L
, hwmodes
& IWINFO_80211_A
);
537 lua_setfield(L
, -2, "a");
539 lua_pushboolean(L
, hwmodes
& IWINFO_80211_B
);
540 lua_setfield(L
, -2, "b");
542 lua_pushboolean(L
, hwmodes
& IWINFO_80211_G
);
543 lua_setfield(L
, -2, "g");
545 lua_pushboolean(L
, hwmodes
& IWINFO_80211_N
);
546 lua_setfield(L
, -2, "n");
548 lua_pushboolean(L
, hwmodes
& IWINFO_80211_AC
);
549 lua_setfield(L
, -2, "ac");
551 lua_pushboolean(L
, hwmodes
& IWINFO_80211_AD
);
552 lua_setfield(L
, -2, "ad");
554 lua_pushboolean(L
, hwmodes
& IWINFO_80211_AX
);
555 lua_setfield(L
, -2, "ax");
564 /* Wrapper for htmode list */
565 static int iwinfo_L_htmodelist(lua_State
*L
, int (*func
)(const char *, int *))
567 const char *ifname
= luaL_checkstring(L
, 1);
570 if (!(*func
)(ifname
, &htmodes
))
574 for (i
= 0; i
< ARRAY_SIZE(IWINFO_HTMODE_NAMES
); i
++)
576 lua_pushboolean(L
, htmodes
& (1 << i
));
577 lua_setfield(L
, -2, IWINFO_HTMODE_NAMES
[i
]);
587 /* Wrapper for mbssid_support */
588 static int iwinfo_L_mbssid_support(lua_State
*L
, int (*func
)(const char *, int *))
590 const char *ifname
= luaL_checkstring(L
, 1);
593 if (!(*func
)(ifname
, &support
))
595 lua_pushboolean(L
, support
);
603 /* Wrapper for hardware_id */
604 static int iwinfo_L_hardware_id(lua_State
*L
, int (*func
)(const char *, char *))
606 const char *ifname
= luaL_checkstring(L
, 1);
607 struct iwinfo_hardware_id ids
;
609 if (!(*func
)(ifname
, (char *)&ids
))
613 lua_pushnumber(L
, ids
.vendor_id
);
614 lua_setfield(L
, -2, "vendor_id");
616 lua_pushnumber(L
, ids
.device_id
);
617 lua_setfield(L
, -2, "device_id");
619 lua_pushnumber(L
, ids
.subsystem_vendor_id
);
620 lua_setfield(L
, -2, "subsystem_vendor_id");
622 lua_pushnumber(L
, ids
.subsystem_device_id
);
623 lua_setfield(L
, -2, "subsystem_device_id");
633 /* Wrapper for country list */
634 static char * iwinfo_L_country_lookup(char *buf
, int len
, int iso3166
)
637 struct iwinfo_country_entry
*c
;
639 for (i
= 0; i
< len
; i
+= sizeof(struct iwinfo_country_entry
))
641 c
= (struct iwinfo_country_entry
*) &buf
[i
];
643 if (c
->iso3166
== iso3166
)
650 static int iwinfo_L_countrylist(lua_State
*L
, int (*func
)(const char *, char *, int *))
653 char rv
[IWINFO_BUFSIZE
], alpha2
[3];
655 const char *ifname
= luaL_checkstring(L
, 1);
656 const struct iwinfo_iso3166_label
*l
;
659 memset(rv
, 0, sizeof(rv
));
661 if (!(*func
)(ifname
, rv
, &len
))
663 for (l
= IWINFO_ISO3166_NAMES
, i
= 1; l
->iso3166
; l
++)
665 if ((ccode
= iwinfo_L_country_lookup(rv
, len
, l
->iso3166
)) != NULL
)
667 sprintf(alpha2
, "%c%c",
668 (l
->iso3166
/ 256), (l
->iso3166
% 256));
672 lua_pushstring(L
, alpha2
);
673 lua_setfield(L
, -2, "alpha2");
675 lua_pushstring(L
, ccode
);
676 lua_setfield(L
, -2, "ccode");
678 lua_pushstring(L
, l
->name
);
679 lua_setfield(L
, -2, "name");
681 lua_rawseti(L
, -2, i
++);
692 LUA_WRAP_INT_OP(wl
,channel
)
693 LUA_WRAP_INT_OP(wl
,frequency
)
694 LUA_WRAP_INT_OP(wl
,frequency_offset
)
695 LUA_WRAP_INT_OP(wl
,txpower
)
696 LUA_WRAP_INT_OP(wl
,txpower_offset
)
697 LUA_WRAP_INT_OP(wl
,bitrate
)
698 LUA_WRAP_INT_OP(wl
,signal
)
699 LUA_WRAP_INT_OP(wl
,noise
)
700 LUA_WRAP_INT_OP(wl
,quality
)
701 LUA_WRAP_INT_OP(wl
,quality_max
)
702 LUA_WRAP_STRING_OP(wl
,ssid
)
703 LUA_WRAP_STRING_OP(wl
,bssid
)
704 LUA_WRAP_STRING_OP(wl
,country
)
705 LUA_WRAP_STRING_OP(wl
,hardware_name
)
706 LUA_WRAP_STRING_OP(wl
,phyname
)
707 LUA_WRAP_STRUCT_OP(wl
,mode
)
708 LUA_WRAP_STRUCT_OP(wl
,assoclist
)
709 LUA_WRAP_STRUCT_OP(wl
,txpwrlist
)
710 LUA_WRAP_STRUCT_OP(wl
,scanlist
)
711 LUA_WRAP_STRUCT_OP(wl
,freqlist
)
712 LUA_WRAP_STRUCT_OP(wl
,countrylist
)
713 LUA_WRAP_STRUCT_OP(wl
,hwmodelist
)
714 LUA_WRAP_STRUCT_OP(wl
,htmodelist
)
715 LUA_WRAP_STRUCT_OP(wl
,encryption
)
716 LUA_WRAP_STRUCT_OP(wl
,mbssid_support
)
717 LUA_WRAP_STRUCT_OP(wl
,hardware_id
)
722 LUA_WRAP_INT_OP(madwifi
,channel
)
723 LUA_WRAP_INT_OP(madwifi
,frequency
)
724 LUA_WRAP_INT_OP(madwifi
,frequency_offset
)
725 LUA_WRAP_INT_OP(madwifi
,txpower
)
726 LUA_WRAP_INT_OP(madwifi
,txpower_offset
)
727 LUA_WRAP_INT_OP(madwifi
,bitrate
)
728 LUA_WRAP_INT_OP(madwifi
,signal
)
729 LUA_WRAP_INT_OP(madwifi
,noise
)
730 LUA_WRAP_INT_OP(madwifi
,quality
)
731 LUA_WRAP_INT_OP(madwifi
,quality_max
)
732 LUA_WRAP_STRING_OP(madwifi
,ssid
)
733 LUA_WRAP_STRING_OP(madwifi
,bssid
)
734 LUA_WRAP_STRING_OP(madwifi
,country
)
735 LUA_WRAP_STRING_OP(madwifi
,hardware_name
)
736 LUA_WRAP_STRING_OP(madwifi
,phyname
)
737 LUA_WRAP_STRUCT_OP(madwifi
,mode
)
738 LUA_WRAP_STRUCT_OP(madwifi
,assoclist
)
739 LUA_WRAP_STRUCT_OP(madwifi
,txpwrlist
)
740 LUA_WRAP_STRUCT_OP(madwifi
,scanlist
)
741 LUA_WRAP_STRUCT_OP(madwifi
,freqlist
)
742 LUA_WRAP_STRUCT_OP(madwifi
,countrylist
)
743 LUA_WRAP_STRUCT_OP(madwifi
,hwmodelist
)
744 LUA_WRAP_STRUCT_OP(madwifi
,htmodelist
)
745 LUA_WRAP_STRUCT_OP(madwifi
,encryption
)
746 LUA_WRAP_STRUCT_OP(madwifi
,mbssid_support
)
747 LUA_WRAP_STRUCT_OP(madwifi
,hardware_id
)
752 LUA_WRAP_INT_OP(nl80211
,channel
)
753 LUA_WRAP_INT_OP(nl80211
,frequency
)
754 LUA_WRAP_INT_OP(nl80211
,frequency_offset
)
755 LUA_WRAP_INT_OP(nl80211
,txpower
)
756 LUA_WRAP_INT_OP(nl80211
,txpower_offset
)
757 LUA_WRAP_INT_OP(nl80211
,bitrate
)
758 LUA_WRAP_INT_OP(nl80211
,signal
)
759 LUA_WRAP_INT_OP(nl80211
,noise
)
760 LUA_WRAP_INT_OP(nl80211
,quality
)
761 LUA_WRAP_INT_OP(nl80211
,quality_max
)
762 LUA_WRAP_STRING_OP(nl80211
,ssid
)
763 LUA_WRAP_STRING_OP(nl80211
,bssid
)
764 LUA_WRAP_STRING_OP(nl80211
,country
)
765 LUA_WRAP_STRING_OP(nl80211
,hardware_name
)
766 LUA_WRAP_STRING_OP(nl80211
,phyname
)
767 LUA_WRAP_STRUCT_OP(nl80211
,mode
)
768 LUA_WRAP_STRUCT_OP(nl80211
,assoclist
)
769 LUA_WRAP_STRUCT_OP(nl80211
,txpwrlist
)
770 LUA_WRAP_STRUCT_OP(nl80211
,scanlist
)
771 LUA_WRAP_STRUCT_OP(nl80211
,freqlist
)
772 LUA_WRAP_STRUCT_OP(nl80211
,countrylist
)
773 LUA_WRAP_STRUCT_OP(nl80211
,hwmodelist
)
774 LUA_WRAP_STRUCT_OP(nl80211
,htmodelist
)
775 LUA_WRAP_STRUCT_OP(nl80211
,encryption
)
776 LUA_WRAP_STRUCT_OP(nl80211
,mbssid_support
)
777 LUA_WRAP_STRUCT_OP(nl80211
,hardware_id
)
782 LUA_WRAP_INT_OP(wext
,channel
)
783 LUA_WRAP_INT_OP(wext
,frequency
)
784 LUA_WRAP_INT_OP(wext
,frequency_offset
)
785 LUA_WRAP_INT_OP(wext
,txpower
)
786 LUA_WRAP_INT_OP(wext
,txpower_offset
)
787 LUA_WRAP_INT_OP(wext
,bitrate
)
788 LUA_WRAP_INT_OP(wext
,signal
)
789 LUA_WRAP_INT_OP(wext
,noise
)
790 LUA_WRAP_INT_OP(wext
,quality
)
791 LUA_WRAP_INT_OP(wext
,quality_max
)
792 LUA_WRAP_STRING_OP(wext
,ssid
)
793 LUA_WRAP_STRING_OP(wext
,bssid
)
794 LUA_WRAP_STRING_OP(wext
,country
)
795 LUA_WRAP_STRING_OP(wext
,hardware_name
)
796 LUA_WRAP_STRING_OP(wext
,phyname
)
797 LUA_WRAP_STRUCT_OP(wext
,mode
)
798 LUA_WRAP_STRUCT_OP(wext
,assoclist
)
799 LUA_WRAP_STRUCT_OP(wext
,txpwrlist
)
800 LUA_WRAP_STRUCT_OP(wext
,scanlist
)
801 LUA_WRAP_STRUCT_OP(wext
,freqlist
)
802 LUA_WRAP_STRUCT_OP(wext
,countrylist
)
803 LUA_WRAP_STRUCT_OP(wext
,hwmodelist
)
804 LUA_WRAP_STRUCT_OP(wext
,htmodelist
)
805 LUA_WRAP_STRUCT_OP(wext
,encryption
)
806 LUA_WRAP_STRUCT_OP(wext
,mbssid_support
)
807 LUA_WRAP_STRUCT_OP(wext
,hardware_id
)
812 static const luaL_reg R_wl
[] = {
814 LUA_REG(wl
,frequency
),
815 LUA_REG(wl
,frequency_offset
),
817 LUA_REG(wl
,txpower_offset
),
822 LUA_REG(wl
,quality_max
),
827 LUA_REG(wl
,assoclist
),
828 LUA_REG(wl
,txpwrlist
),
829 LUA_REG(wl
,scanlist
),
830 LUA_REG(wl
,freqlist
),
831 LUA_REG(wl
,countrylist
),
832 LUA_REG(wl
,hwmodelist
),
833 LUA_REG(wl
,htmodelist
),
834 LUA_REG(wl
,encryption
),
835 LUA_REG(wl
,mbssid_support
),
836 LUA_REG(wl
,hardware_id
),
837 LUA_REG(wl
,hardware_name
),
845 static const luaL_reg R_madwifi
[] = {
846 LUA_REG(madwifi
,channel
),
847 LUA_REG(madwifi
,frequency
),
848 LUA_REG(madwifi
,frequency_offset
),
849 LUA_REG(madwifi
,txpower
),
850 LUA_REG(madwifi
,txpower_offset
),
851 LUA_REG(madwifi
,bitrate
),
852 LUA_REG(madwifi
,signal
),
853 LUA_REG(madwifi
,noise
),
854 LUA_REG(madwifi
,quality
),
855 LUA_REG(madwifi
,quality_max
),
856 LUA_REG(madwifi
,mode
),
857 LUA_REG(madwifi
,ssid
),
858 LUA_REG(madwifi
,bssid
),
859 LUA_REG(madwifi
,country
),
860 LUA_REG(madwifi
,assoclist
),
861 LUA_REG(madwifi
,txpwrlist
),
862 LUA_REG(madwifi
,scanlist
),
863 LUA_REG(madwifi
,freqlist
),
864 LUA_REG(madwifi
,countrylist
),
865 LUA_REG(madwifi
,hwmodelist
),
866 LUA_REG(madwifi
,htmodelist
),
867 LUA_REG(madwifi
,encryption
),
868 LUA_REG(madwifi
,mbssid_support
),
869 LUA_REG(madwifi
,hardware_id
),
870 LUA_REG(madwifi
,hardware_name
),
871 LUA_REG(madwifi
,phyname
),
878 static const luaL_reg R_nl80211
[] = {
879 LUA_REG(nl80211
,channel
),
880 LUA_REG(nl80211
,frequency
),
881 LUA_REG(nl80211
,frequency_offset
),
882 LUA_REG(nl80211
,txpower
),
883 LUA_REG(nl80211
,txpower_offset
),
884 LUA_REG(nl80211
,bitrate
),
885 LUA_REG(nl80211
,signal
),
886 LUA_REG(nl80211
,noise
),
887 LUA_REG(nl80211
,quality
),
888 LUA_REG(nl80211
,quality_max
),
889 LUA_REG(nl80211
,mode
),
890 LUA_REG(nl80211
,ssid
),
891 LUA_REG(nl80211
,bssid
),
892 LUA_REG(nl80211
,country
),
893 LUA_REG(nl80211
,assoclist
),
894 LUA_REG(nl80211
,txpwrlist
),
895 LUA_REG(nl80211
,scanlist
),
896 LUA_REG(nl80211
,freqlist
),
897 LUA_REG(nl80211
,countrylist
),
898 LUA_REG(nl80211
,hwmodelist
),
899 LUA_REG(nl80211
,htmodelist
),
900 LUA_REG(nl80211
,encryption
),
901 LUA_REG(nl80211
,mbssid_support
),
902 LUA_REG(nl80211
,hardware_id
),
903 LUA_REG(nl80211
,hardware_name
),
904 LUA_REG(nl80211
,phyname
),
911 static const luaL_reg R_wext
[] = {
912 LUA_REG(wext
,channel
),
913 LUA_REG(wext
,frequency
),
914 LUA_REG(wext
,frequency_offset
),
915 LUA_REG(wext
,txpower
),
916 LUA_REG(wext
,txpower_offset
),
917 LUA_REG(wext
,bitrate
),
918 LUA_REG(wext
,signal
),
920 LUA_REG(wext
,quality
),
921 LUA_REG(wext
,quality_max
),
925 LUA_REG(wext
,country
),
926 LUA_REG(wext
,assoclist
),
927 LUA_REG(wext
,txpwrlist
),
928 LUA_REG(wext
,scanlist
),
929 LUA_REG(wext
,freqlist
),
930 LUA_REG(wext
,countrylist
),
931 LUA_REG(wext
,hwmodelist
),
932 LUA_REG(wext
,htmodelist
),
933 LUA_REG(wext
,encryption
),
934 LUA_REG(wext
,mbssid_support
),
935 LUA_REG(wext
,hardware_id
),
936 LUA_REG(wext
,hardware_name
),
937 LUA_REG(wext
,phyname
),
943 static const luaL_reg R_common
[] = {
944 { "type", iwinfo_L_type
},
945 { "__gc", iwinfo_L__gc
},
950 LUALIB_API
int luaopen_iwinfo(lua_State
*L
) {
951 luaL_register(L
, IWINFO_META
, R_common
);
954 luaL_newmetatable(L
, IWINFO_WL_META
);
955 luaL_register(L
, NULL
, R_common
);
956 luaL_register(L
, NULL
, R_wl
);
957 lua_pushvalue(L
, -1);
958 lua_setfield(L
, -2, "__index");
959 lua_setfield(L
, -2, "wl");
963 luaL_newmetatable(L
, IWINFO_MADWIFI_META
);
964 luaL_register(L
, NULL
, R_common
);
965 luaL_register(L
, NULL
, R_madwifi
);
966 lua_pushvalue(L
, -1);
967 lua_setfield(L
, -2, "__index");
968 lua_setfield(L
, -2, "madwifi");
972 luaL_newmetatable(L
, IWINFO_NL80211_META
);
973 luaL_register(L
, NULL
, R_common
);
974 luaL_register(L
, NULL
, R_nl80211
);
975 lua_pushvalue(L
, -1);
976 lua_setfield(L
, -2, "__index");
977 lua_setfield(L
, -2, "nl80211");
981 luaL_newmetatable(L
, IWINFO_WEXT_META
);
982 luaL_register(L
, NULL
, R_common
);
983 luaL_register(L
, NULL
, R_wext
);
984 lua_pushvalue(L
, -1);
985 lua_setfield(L
, -2, "__index");
986 lua_setfield(L
, -2, "wext");