• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/iwinfo/iwinfo_lua.c

  1 /*
  2  * iwinfo - Wireless Information Library - Lua Bindings
  3  *
  4  *   Copyright (C) 2009 Jo-Philipp Wich <xm@subsignal.org>
  5  *
  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.
  9  *
 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.
 14  *
 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/.
 17  */
 18 
 19 #include "iwinfo/lua.h"
 20 
 21 
 22 /* Determine type */
 23 static int iwinfo_L_type(lua_State *L)
 24 {
 25         const char *ifname = luaL_checkstring(L, 1);
 26         const char *type = iwinfo_type(ifname);
 27 
 28         if (type)
 29                 lua_pushstring(L, type);
 30         else
 31                 lua_pushnil(L);
 32 
 33         return 1;
 34 }
 35 
 36 /* Shutdown backends */
 37 static int iwinfo_L__gc(lua_State *L)
 38 {
 39         iwinfo_finish();
 40         return 0;
 41 }
 42 
 43 /*
 44  * Build a short textual description of the crypto info
 45  */
 46 
 47 static char * iwinfo_crypto_print_ciphers(int ciphers)
 48 {
 49         static char str[128] = { 0 };
 50         char *pos = str;
 51 
 52         if (ciphers & IWINFO_CIPHER_WEP40)
 53                 pos += sprintf(pos, "WEP-40, ");
 54 
 55         if (ciphers & IWINFO_CIPHER_WEP104)
 56                 pos += sprintf(pos, "WEP-104, ");
 57 
 58         if (ciphers & IWINFO_CIPHER_TKIP)
 59                 pos += sprintf(pos, "TKIP, ");
 60 
 61         if (ciphers & IWINFO_CIPHER_CCMP)
 62                 pos += sprintf(pos, "CCMP, ");
 63 
 64         if (ciphers & IWINFO_CIPHER_CCMP256)
 65                 pos += sprintf(pos, "CCMP-256, ");
 66 
 67         if (ciphers & IWINFO_CIPHER_GCMP)
 68                 pos += sprintf(pos, "GCMP, ");
 69 
 70         if (ciphers & IWINFO_CIPHER_GCMP256)
 71                 pos += sprintf(pos, "GCMP-256, ");
 72 
 73         if (ciphers & IWINFO_CIPHER_WRAP)
 74                 pos += sprintf(pos, "WRAP, ");
 75 
 76         if (ciphers & IWINFO_CIPHER_AESOCB)
 77                 pos += sprintf(pos, "AES-OCB, ");
 78 
 79         if (ciphers & IWINFO_CIPHER_CKIP)
 80                 pos += sprintf(pos, "CKIP, ");
 81 
 82         if (!ciphers || (ciphers & IWINFO_CIPHER_NONE))
 83                 pos += sprintf(pos, "NONE, ");
 84 
 85         *(pos - 2) = 0;
 86 
 87         return str;
 88 }
 89 
 90 static char * iwinfo_crypto_print_suites(int suites)
 91 {
 92         static char str[64] = { 0 };
 93         char *pos = str;
 94 
 95         if (suites & IWINFO_KMGMT_PSK)
 96                 pos += sprintf(pos, "PSK/");
 97 
 98         if (suites & IWINFO_KMGMT_8021x)
 99                 pos += sprintf(pos, "802.1X/");
100 
101         if (suites & IWINFO_KMGMT_SAE)
102                 pos += sprintf(pos, "SAE/");
103 
104         if (suites & IWINFO_KMGMT_OWE)
105                 pos += sprintf(pos, "OWE/");
106 
107         if (!suites || (suites & IWINFO_KMGMT_NONE))
108                 pos += sprintf(pos, "NONE/");
109 
110         *(pos - 1) = 0;
111 
112         return str;
113 }
114 
115 static char * iwinfo_crypto_desc(struct iwinfo_crypto_entry *c)
116 {
117         static char desc[512] = { 0 };
118         char *pos = desc;
119         int i, n;
120 
121         if (c)
122         {
123                 if (c->enabled)
124                 {
125                         /* WEP */
126                         if (c->auth_algs && !c->wpa_version)
127                         {
128                                 if ((c->auth_algs & IWINFO_AUTH_OPEN) &&
129                                     (c->auth_algs & IWINFO_AUTH_SHARED))
130                                 {
131                                         sprintf(desc, "WEP Open/Shared (%s)",
132                                                 iwinfo_crypto_print_ciphers(c->pair_ciphers));
133                                 }
134                                 else if (c->auth_algs & IWINFO_AUTH_OPEN)
135                                 {
136                                         sprintf(desc, "WEP Open System (%s)",
137                                                 iwinfo_crypto_print_ciphers(c->pair_ciphers));
138                                 }
139                                 else if (c->auth_algs & IWINFO_AUTH_SHARED)
140                                 {
141                                         sprintf(desc, "WEP Shared Auth (%s)",
142                                                 iwinfo_crypto_print_ciphers(c->pair_ciphers));
143                                 }
144                         }
145 
146                         /* WPA */
147                         else if (c->wpa_version)
148                         {
149                                 for (i = 0, n = 0; i < 3; i++)
150                                         if (c->wpa_version & (1 << i))
151                                                 n++;
152 
153                                 if (n > 1)
154                                         pos += sprintf(pos, "mixed ");
155 
156                                 for (i = 0; i < 3; i++)
157                                         if (c->wpa_version & (1 << i))
158                                                 if (i)
159                                                         pos += sprintf(pos, "WPA%d/", i + 1);
160                                                 else
161                                                         pos += sprintf(pos, "WPA/");
162 
163                                 pos--;
164 
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));
169                         }
170                         else
171                         {
172                                 sprintf(desc, "None");
173                         }
174                 }
175                 else
176                 {
177                         sprintf(desc, "None");
178                 }
179         }
180         else
181         {
182                 sprintf(desc, "Unknown");
183         }
184 
185         return desc;
186 }
187 
188 /* Build Lua table from crypto data */
189 static void iwinfo_L_cryptotable(lua_State *L, struct iwinfo_crypto_entry *c)
190 {
191         int i, j;
192 
193         lua_newtable(L);
194 
195         lua_pushboolean(L, c->enabled);
196         lua_setfield(L, -2, "enabled");
197 
198         lua_pushstring(L, iwinfo_crypto_desc(c));
199         lua_setfield(L, -2, "description");
200 
201         lua_pushboolean(L, (c->enabled && !c->wpa_version));
202         lua_setfield(L, -2, "wep");
203 
204         lua_pushinteger(L, c->wpa_version);
205         lua_setfield(L, -2, "wpa");
206 
207         lua_newtable(L);
208         for (i = 0, j = 1; i < ARRAY_SIZE(IWINFO_CIPHER_NAMES); i++)
209         {
210                 if (c->pair_ciphers & (1 << i))
211                 {
212                         lua_pushstring(L, IWINFO_CIPHER_NAMES[i]);
213                         lua_rawseti(L, -2, j++);
214                 }
215         }
216         lua_setfield(L, -2, "pair_ciphers");
217 
218         lua_newtable(L);
219         for (i = 0, j = 1; i < ARRAY_SIZE(IWINFO_CIPHER_NAMES); i++)
220         {
221                 if (c->group_ciphers & (1 << i))
222                 {
223                         lua_pushstring(L, IWINFO_CIPHER_NAMES[i]);
224                         lua_rawseti(L, -2, j++);
225                 }
226         }
227         lua_setfield(L, -2, "group_ciphers");
228 
229         lua_newtable(L);
230         for (i = 0, j = 1; i < ARRAY_SIZE(IWINFO_KMGMT_NAMES); i++)
231         {
232                 if (c->auth_suites & (1 << i))
233                 {
234                         lua_pushstring(L, IWINFO_KMGMT_NAMES[i]);
235                         lua_rawseti(L, -2, j++);
236                 }
237         }
238         lua_setfield(L, -2, "auth_suites");
239 
240         lua_newtable(L);
241         for (i = 0, j = 1; i < ARRAY_SIZE(IWINFO_AUTH_NAMES); i++)
242         {
243                 if (c->auth_algs & (1 << i))
244                 {
245                         lua_pushstring(L, IWINFO_AUTH_NAMES[i]);
246                         lua_rawseti(L, -2, j++);
247                 }
248         }
249         lua_setfield(L, -2, "auth_algs");
250 }
251 
252 
253 /* Wrapper for mode */
254 static int iwinfo_L_mode(lua_State *L, int (*func)(const char *, int *))
255 {
256         int mode;
257         const char *ifname = luaL_checkstring(L, 1);
258 
259         if ((*func)(ifname, &mode))
260                 mode = IWINFO_OPMODE_UNKNOWN;
261 
262         lua_pushstring(L, IWINFO_OPMODE_NAMES[mode]);
263         return 1;
264 }
265 
266 static void set_rateinfo(lua_State *L, struct iwinfo_rate_entry *r, bool rx)
267 {
268         lua_pushnumber(L, r->rate);
269         lua_setfield(L, -2, rx ? "rx_rate" : "tx_rate");
270 
271         lua_pushboolean(L, r->is_ht);
272         lua_setfield(L, -2, rx ? "rx_ht" : "tx_ht");
273 
274         lua_pushboolean(L, r->is_vht);
275         lua_setfield(L, -2, rx ? "rx_vht" : "tx_vht");
276 
277         lua_pushboolean(L, r->is_he);
278         lua_setfield(L, -2, rx ? "rx_he" : "tx_he");
279 
280         lua_pushnumber(L, r->mhz);
281         lua_setfield(L, -2, rx ? "rx_mhz" : "tx_mhz");
282 
283         if (r->is_ht)
284         {
285                 lua_pushboolean(L, r->is_40mhz);
286                 lua_setfield(L, -2, rx ? "rx_40mhz" : "tx_40mhz");
287 
288                 lua_pushnumber(L, r->mcs);
289                 lua_setfield(L, -2, rx ? "rx_mcs" : "tx_mcs");
290 
291                 lua_pushboolean(L, r->is_short_gi);
292                 lua_setfield(L, -2, rx ? "rx_short_gi" : "tx_short_gi");
293         }
294         else if (r->is_vht || r->is_he)
295         {
296                 lua_pushnumber(L, r->mcs);
297                 lua_setfield(L, -2, rx ? "rx_mcs" : "tx_mcs");
298 
299                 lua_pushnumber(L, r->nss);
300                 lua_setfield(L, -2, rx ? "rx_nss" : "tx_nss");
301 
302                 if (r->is_he) {
303                         lua_pushnumber(L, r->he_gi);
304                         lua_setfield(L, -2, rx ? "rx_he_gi" : "tx_he_gi");
305 
306                         lua_pushnumber(L, r->he_dcm);
307                         lua_setfield(L, -2, rx ? "rx_he_dcm" : "tx_he_dcm");
308                 }
309 
310                 if (r->is_vht) {
311                         lua_pushboolean(L, r->is_short_gi);
312                         lua_setfield(L, -2, rx ? "rx_short_gi" : "tx_short_gi");
313                 }
314         }
315 }
316 
317 /* Wrapper for assoclist */
318 static int iwinfo_L_assoclist(lua_State *L, int (*func)(const char *, char *, int *))
319 {
320         int i, len;
321         char rv[IWINFO_BUFSIZE];
322         char macstr[18];
323         const char *ifname = luaL_checkstring(L, 1);
324         struct iwinfo_assoclist_entry *e;
325 
326         lua_newtable(L);
327         memset(rv, 0, sizeof(rv));
328 
329         if (!(*func)(ifname, rv, &len))
330         {
331                 for (i = 0; i < len; i += sizeof(struct iwinfo_assoclist_entry))
332                 {
333                         e = (struct iwinfo_assoclist_entry *) &rv[i];
334 
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]);
338 
339                         lua_newtable(L);
340 
341                         lua_pushnumber(L, e->signal);
342                         lua_setfield(L, -2, "signal");
343 
344                         lua_pushnumber(L, e->noise);
345                         lua_setfield(L, -2, "noise");
346 
347                         lua_pushnumber(L, e->inactive);
348                         lua_setfield(L, -2, "inactive");
349 
350                         lua_pushnumber(L, e->rx_packets);
351                         lua_setfield(L, -2, "rx_packets");
352 
353                         lua_pushnumber(L, e->tx_packets);
354                         lua_setfield(L, -2, "tx_packets");
355 
356                         set_rateinfo(L, &e->rx_rate, true);
357                         set_rateinfo(L, &e->tx_rate, false);
358 
359                         if (e->thr) {
360                                 lua_pushnumber(L, e->thr);
361                                 lua_setfield(L, -2, "expected_throughput");
362                         }
363 
364                         lua_setfield(L, -2, macstr);
365                 }
366         }
367 
368         return 1;
369 }
370 
371 /* Wrapper for tx power list */
372 static int iwinfo_L_txpwrlist(lua_State *L, int (*func)(const char *, char *, int *))
373 {
374         int i, x, len;
375         char rv[IWINFO_BUFSIZE];
376         const char *ifname = luaL_checkstring(L, 1);
377         struct iwinfo_txpwrlist_entry *e;
378 
379         memset(rv, 0, sizeof(rv));
380 
381         if (!(*func)(ifname, rv, &len))
382         {
383                 lua_newtable(L);
384 
385                 for (i = 0, x = 1; i < len; i += sizeof(struct iwinfo_txpwrlist_entry), x++)
386                 {
387                         e = (struct iwinfo_txpwrlist_entry *) &rv[i];
388 
389                         lua_newtable(L);
390 
391                         lua_pushnumber(L, e->mw);
392                         lua_setfield(L, -2, "mw");
393 
394                         lua_pushnumber(L, e->dbm);
395                         lua_setfield(L, -2, "dbm");
396 
397                         lua_rawseti(L, -2, x);
398                 }
399 
400                 return 1;
401         }
402 
403         return 0;
404 }
405 
406 /* Wrapper for scan list */
407 static int iwinfo_L_scanlist(lua_State *L, int (*func)(const char *, char *, int *))
408 {
409         int i, x, len = 0;
410         char rv[IWINFO_BUFSIZE];
411         char macstr[18];
412         const char *ifname = luaL_checkstring(L, 1);
413         struct iwinfo_scanlist_entry *e;
414 
415         lua_newtable(L);
416         memset(rv, 0, sizeof(rv));
417 
418         if (!(*func)(ifname, rv, &len))
419         {
420                 for (i = 0, x = 1; i < len; i += sizeof(struct iwinfo_scanlist_entry), x++)
421                 {
422                         e = (struct iwinfo_scanlist_entry *) &rv[i];
423 
424                         lua_newtable(L);
425 
426                         /* BSSID */
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]);
430 
431                         lua_pushstring(L, macstr);
432                         lua_setfield(L, -2, "bssid");
433 
434                         /* ESSID */
435                         if (e->ssid[0])
436                         {
437                                 lua_pushstring(L, (char *) e->ssid);
438                                 lua_setfield(L, -2, "ssid");
439                         }
440 
441                         /* Channel */
442                         lua_pushinteger(L, e->channel);
443                         lua_setfield(L, -2, "channel");
444 
445                         /* Mode */
446                         lua_pushstring(L, IWINFO_OPMODE_NAMES[e->mode]);
447                         lua_setfield(L, -2, "mode");
448 
449                         /* Quality, Signal */
450                         lua_pushinteger(L, e->quality);
451                         lua_setfield(L, -2, "quality");
452 
453                         lua_pushinteger(L, e->quality_max);
454                         lua_setfield(L, -2, "quality_max");
455 
456                         lua_pushnumber(L, (e->signal - 0x100));
457                         lua_setfield(L, -2, "signal");
458 
459                         /* Crypto */
460                         iwinfo_L_cryptotable(L, &e->crypto);
461                         lua_setfield(L, -2, "encryption");
462 
463                         lua_rawseti(L, -2, x);
464                 }
465         }
466 
467         return 1;
468 }
469 
470 /* Wrapper for frequency list */
471 static int iwinfo_L_freqlist(lua_State *L, int (*func)(const char *, char *, int *))
472 {
473         int i, x, len;
474         char rv[IWINFO_BUFSIZE];
475         const char *ifname = luaL_checkstring(L, 1);
476         struct iwinfo_freqlist_entry *e;
477 
478         lua_newtable(L);
479         memset(rv, 0, sizeof(rv));
480 
481         if (!(*func)(ifname, rv, &len))
482         {
483                 for (i = 0, x = 1; i < len; i += sizeof(struct iwinfo_freqlist_entry), x++)
484                 {
485                         e = (struct iwinfo_freqlist_entry *) &rv[i];
486 
487                         lua_newtable(L);
488 
489                         /* MHz */
490                         lua_pushinteger(L, e->mhz);
491                         lua_setfield(L, -2, "mhz");
492 
493                         /* Channel */
494                         lua_pushinteger(L, e->channel);
495                         lua_setfield(L, -2, "channel");
496 
497                         /* Restricted (DFS/TPC/Radar) */
498                         lua_pushboolean(L, e->restricted);
499                         lua_setfield(L, -2, "restricted");
500 
501                         lua_rawseti(L, -2, x);
502                 }
503         }
504 
505         return 1;
506 }
507 
508 /* Wrapper for crypto settings */
509 static int iwinfo_L_encryption(lua_State *L, int (*func)(const char *, char *))
510 {
511         const char *ifname = luaL_checkstring(L, 1);
512         struct iwinfo_crypto_entry c = { 0 };
513 
514         if (!(*func)(ifname, (char *)&c))
515         {
516                 iwinfo_L_cryptotable(L, &c);
517                 return 1;
518         }
519 
520         lua_pushnil(L);
521         return 1;
522 }
523 
524 /* Wrapper for hwmode list */
525 static int iwinfo_L_hwmodelist(lua_State *L, int (*func)(const char *, int *))
526 {
527         const char *ifname = luaL_checkstring(L, 1);
528         int hwmodes = 0;
529 
530         if (!(*func)(ifname, &hwmodes))
531         {
532                 lua_newtable(L);
533 
534                 lua_pushboolean(L, hwmodes & IWINFO_80211_A);
535                 lua_setfield(L, -2, "a");
536 
537                 lua_pushboolean(L, hwmodes & IWINFO_80211_B);
538                 lua_setfield(L, -2, "b");
539 
540                 lua_pushboolean(L, hwmodes & IWINFO_80211_G);
541                 lua_setfield(L, -2, "g");
542 
543                 lua_pushboolean(L, hwmodes & IWINFO_80211_N);
544                 lua_setfield(L, -2, "n");
545 
546                 lua_pushboolean(L, hwmodes & IWINFO_80211_AC);
547                 lua_setfield(L, -2, "ac");
548 
549                 lua_pushboolean(L, hwmodes & IWINFO_80211_AD);
550                 lua_setfield(L, -2, "ad");
551 
552                 lua_pushboolean(L, hwmodes & IWINFO_80211_AX);
553                 lua_setfield(L, -2, "ax");
554 
555                 return 1;
556         }
557 
558         lua_pushnil(L);
559         return 1;
560 }
561 
562 /* Wrapper for htmode list */
563 static int iwinfo_L_htmodelist(lua_State *L, int (*func)(const char *, int *))
564 {
565         const char *ifname = luaL_checkstring(L, 1);
566         int i, htmodes = 0;
567 
568         if (!(*func)(ifname, &htmodes))
569         {
570                 lua_newtable(L);
571 
572                 for (i = 0; i < ARRAY_SIZE(IWINFO_HTMODE_NAMES); i++)
573                 {
574                         lua_pushboolean(L, htmodes & (1 << i));
575                         lua_setfield(L, -2, IWINFO_HTMODE_NAMES[i]);
576                 }
577 
578                 return 1;
579         }
580 
581         lua_pushnil(L);
582         return 1;
583 }
584 
585 /* Wrapper for mbssid_support */
586 static int iwinfo_L_mbssid_support(lua_State *L, int (*func)(const char *, int *))
587 {
588         const char *ifname = luaL_checkstring(L, 1);
589         int support = 0;
590 
591         if (!(*func)(ifname, &support))
592         {
593                 lua_pushboolean(L, support);
594                 return 1;
595         }
596 
597         lua_pushnil(L);
598         return 1;
599 }
600 
601 /* Wrapper for hardware_id */
602 static int iwinfo_L_hardware_id(lua_State *L, int (*func)(const char *, char *))
603 {
604         const char *ifname = luaL_checkstring(L, 1);
605         struct iwinfo_hardware_id ids;
606 
607         if (!(*func)(ifname, (char *)&ids))
608         {
609                 lua_newtable(L);
610 
611                 lua_pushnumber(L, ids.vendor_id);
612                 lua_setfield(L, -2, "vendor_id");
613 
614                 lua_pushnumber(L, ids.device_id);
615                 lua_setfield(L, -2, "device_id");
616 
617                 lua_pushnumber(L, ids.subsystem_vendor_id);
618                 lua_setfield(L, -2, "subsystem_vendor_id");
619 
620                 lua_pushnumber(L, ids.subsystem_device_id);
621                 lua_setfield(L, -2, "subsystem_device_id");
622         }
623         else
624         {
625                 lua_pushnil(L);
626         }
627 
628         return 1;
629 }
630 
631 /* Wrapper for country list */
632 static char * iwinfo_L_country_lookup(char *buf, int len, int iso3166)
633 {
634         int i;
635         struct iwinfo_country_entry *c;
636 
637         for (i = 0; i < len; i += sizeof(struct iwinfo_country_entry))
638         {
639                 c = (struct iwinfo_country_entry *) &buf[i];
640 
641                 if (c->iso3166 == iso3166)
642                         return c->ccode;
643         }
644 
645         return NULL;
646 }
647 
648 static int iwinfo_L_countrylist(lua_State *L, int (*func)(const char *, char *, int *))
649 {
650         int len, i;
651         char rv[IWINFO_BUFSIZE], alpha2[3];
652         char *ccode;
653         const char *ifname = luaL_checkstring(L, 1);
654         const struct iwinfo_iso3166_label *l;
655 
656         lua_newtable(L);
657         memset(rv, 0, sizeof(rv));
658 
659         if (!(*func)(ifname, rv, &len))
660         {
661                 for (l = IWINFO_ISO3166_NAMES, i = 1; l->iso3166; l++)
662                 {
663                         if ((ccode = iwinfo_L_country_lookup(rv, len, l->iso3166)) != NULL)
664                         {
665                                 sprintf(alpha2, "%c%c",
666                                         (l->iso3166 / 256), (l->iso3166 % 256));
667 
668                                 lua_newtable(L);
669 
670                                 lua_pushstring(L, alpha2);
671                                 lua_setfield(L, -2, "alpha2");
672 
673                                 lua_pushstring(L, ccode);
674                                 lua_setfield(L, -2, "ccode");
675 
676                                 lua_pushstring(L, l->name);
677                                 lua_setfield(L, -2, "name");
678 
679                                 lua_rawseti(L, -2, i++);
680                         }
681                 }
682         }
683 
684         return 1;
685 }
686 
687 
688 #ifdef USE_WL
689 /* Broadcom */
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)
716 #endif
717 
718 #ifdef USE_MADWIFI
719 /* Madwifi */
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)
746 #endif
747 
748 #ifdef USE_NL80211
749 /* NL80211 */
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)
776 #endif
777 
778 /* Wext */
779 #ifdef USE_WEXT
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)
806 #endif
807 
808 #ifdef USE_WL
809 /* Broadcom table */
810 static const luaL_reg R_wl[] = {
811         LUA_REG(wl,channel),
812         LUA_REG(wl,frequency),
813         LUA_REG(wl,frequency_offset),
814         LUA_REG(wl,txpower),
815         LUA_REG(wl,txpower_offset),
816         LUA_REG(wl,bitrate),
817         LUA_REG(wl,signal),
818         LUA_REG(wl,noise),
819         LUA_REG(wl,quality),
820         LUA_REG(wl,quality_max),
821         LUA_REG(wl,mode),
822         LUA_REG(wl,ssid),
823         LUA_REG(wl,bssid),
824         LUA_REG(wl,country),
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),
836         LUA_REG(wl,phyname),
837         { NULL, NULL }
838 };
839 #endif
840 
841 #ifdef USE_MADWIFI
842 /* Madwifi table */
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),
870         { NULL, NULL }
871 };
872 #endif
873 
874 #ifdef USE_NL80211
875 /* NL80211 table */
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),
903         { NULL, NULL }
904 };
905 #endif
906 
907 /* Wext table */
908 #ifdef USE_WEXT
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),
917         LUA_REG(wext,noise),
918         LUA_REG(wext,quality),
919         LUA_REG(wext,quality_max),
920         LUA_REG(wext,mode),
921         LUA_REG(wext,ssid),
922         LUA_REG(wext,bssid),
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),
936         { NULL, NULL }
937 };
938 #endif
939 
940 /* Common */
941 static const luaL_reg R_common[] = {
942         { "type", iwinfo_L_type },
943         { "__gc", iwinfo_L__gc  },
944         { NULL, NULL }
945 };
946 
947 
948 LUALIB_API int luaopen_iwinfo(lua_State *L) {
949         luaL_register(L, IWINFO_META, R_common);
950 
951 #ifdef USE_WL
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");
958 #endif
959 
960 #ifdef USE_MADWIFI
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");
967 #endif
968 
969 #ifdef USE_NL80211
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");
976 #endif
977 
978 #ifdef USE_WEXT
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");
985 #endif
986 
987         return 1;
988 }
989 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt