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

Sources/iwinfo/iwinfo_wl.c

  1 /*
  2  * iwinfo - Wireless Information Library - Broadcom wl.o Backend
  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  * This code is based on the wlc.c utility published by OpenWrt.org .
 19  */
 20 
 21 #include <sys/types.h>
 22 #include <sys/stat.h>
 23 
 24 #include "iwinfo.h"
 25 #include "api/broadcom.h"
 26 
 27 static int wl_ioctl(const char *name, int cmd, void *buf, int len)
 28 {
 29         struct ifreq ifr;
 30         wl_ioctl_t ioc;
 31 
 32         /* do it */
 33         ioc.cmd = cmd;
 34         ioc.buf = buf;
 35         ioc.len = len;
 36 
 37         strncpy(ifr.ifr_name, name, IFNAMSIZ);
 38         ifr.ifr_data = (caddr_t) &ioc;
 39 
 40         return iwinfo_ioctl(SIOCDEVPRIVATE, &ifr);
 41 }
 42 
 43 static int wl_iovar(const char *name, const char *cmd, const char *arg,
 44                                         int arglen, void *buf, int buflen)
 45 {
 46         int cmdlen = strlen(cmd) + 1;
 47 
 48         memcpy(buf, cmd, cmdlen);
 49 
 50         if (arg && arglen > 0)
 51                 memcpy(buf + cmdlen, arg, arglen);
 52 
 53         return wl_ioctl(name, WLC_GET_VAR, buf, buflen);
 54 }
 55 
 56 static struct wl_maclist * wl_read_assoclist(const char *ifname)
 57 {
 58         struct wl_maclist *macs;
 59         int maclen = 4 + WL_MAX_STA_COUNT * 6;
 60 
 61         if (strstr(ifname, "wds"))
 62                 return NULL;
 63 
 64         if ((macs = (struct wl_maclist *) malloc(maclen)) != NULL)
 65         {
 66                 memset(macs, 0, maclen);
 67                 macs->count = WL_MAX_STA_COUNT;
 68 
 69                 if (!wl_ioctl(ifname, WLC_GET_ASSOCLIST, macs, maclen))
 70                         return macs;
 71 
 72                 free(macs);
 73         }
 74 
 75         return NULL;
 76 }
 77 
 78 
 79 static int wl_probe(const char *ifname)
 80 {
 81         int magic;
 82         return (!wl_ioctl(ifname, WLC_GET_MAGIC, &magic, sizeof(magic)) &&
 83                         (magic == WLC_IOCTL_MAGIC));
 84 }
 85 
 86 static void wl_close(void)
 87 {
 88         /* Nop */
 89 }
 90 
 91 static int wl_get_mode(const char *ifname, int *buf)
 92 {
 93         int ret = -1;
 94         int ap, infra, passive;
 95 
 96         if ((ret = wl_ioctl(ifname, WLC_GET_AP, &ap, sizeof(ap))))
 97                 return ret;
 98 
 99         if ((ret = wl_ioctl(ifname, WLC_GET_INFRA, &infra, sizeof(infra))))
100                 return ret;
101 
102         if ((ret = wl_ioctl(ifname, WLC_GET_PASSIVE, &passive, sizeof(passive))))
103                 return ret;
104 
105         if (passive)
106                 *buf = IWINFO_OPMODE_MONITOR;
107         else if (!infra)
108                 *buf = IWINFO_OPMODE_ADHOC;
109         else if (ap)
110                 *buf = IWINFO_OPMODE_MASTER;
111         else
112                 *buf = IWINFO_OPMODE_CLIENT;
113 
114         return 0;
115 }
116 
117 static int wl_get_ssid(const char *ifname, char *buf)
118 {
119         int ret = -1;
120         wlc_ssid_t ssid;
121 
122         if (!(ret = wl_ioctl(ifname, WLC_GET_SSID, &ssid, sizeof(ssid))))
123                 memcpy(buf, ssid.ssid, ssid.ssid_len);
124 
125         return ret;
126 }
127 
128 static int wl_get_bssid(const char *ifname, char *buf)
129 {
130         int ret = -1;
131         char bssid[6];
132 
133         if (!(ret = wl_ioctl(ifname, WLC_GET_BSSID, bssid, 6)))
134                 sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X",
135                         (uint8_t)bssid[0], (uint8_t)bssid[1], (uint8_t)bssid[2],
136                         (uint8_t)bssid[3], (uint8_t)bssid[4], (uint8_t)bssid[5]
137                 );
138 
139         return ret;
140 }
141 
142 static int wl_get_channel(const char *ifname, int *buf)
143 {
144         return wl_ioctl(ifname, WLC_GET_CHANNEL, buf, sizeof(buf));
145 }
146 
147 static int wl_get_frequency(const char *ifname, int *buf)
148 {
149         return wext_ops.frequency(ifname, buf);
150 }
151 
152 static int wl_get_txpower(const char *ifname, int *buf)
153 {
154         /* WLC_GET_VAR "qtxpower" */
155         return wext_ops.txpower(ifname, buf);
156 }
157 
158 static int wl_get_bitrate(const char *ifname, int *buf)
159 {
160         int ret = -1;
161         int rate = 0;
162 
163         if( !(ret = wl_ioctl(ifname, WLC_GET_RATE, &rate, sizeof(rate))) && (rate > 0))
164                 *buf = ((rate / 2) * 1000) + ((rate & 1) ? 500 : 0);
165 
166         return ret;
167 }
168 
169 static int wl_get_signal(const char *ifname, int *buf)
170 {
171         unsigned int ap, rssi, i, rssi_count;
172         int ioctl_req_version = 0x2000;
173         char tmp[WLC_IOCTL_MAXLEN];
174         struct wl_maclist *macs = NULL;
175         wl_sta_rssi_t starssi;
176 
177         memset(tmp, 0, WLC_IOCTL_MAXLEN);
178         memcpy(tmp, &ioctl_req_version, sizeof(ioctl_req_version));
179 
180         wl_ioctl(ifname, WLC_GET_BSS_INFO, tmp, WLC_IOCTL_MAXLEN);
181 
182         if (!wl_ioctl(ifname, WLC_GET_AP, &ap, sizeof(ap)) && !ap)
183         {
184                 *buf = tmp[WL_BSS_RSSI_OFFSET];
185         }
186         else
187         {
188                 rssi = rssi_count = 0;
189 
190                 /* Calculate average rssi from conntected stations */
191                 if ((macs = wl_read_assoclist(ifname)) != NULL)
192                 {
193                         for (i = 0; i < macs->count; i++)
194                         {
195                                 memcpy(starssi.mac, &macs->ea[i], 6);
196 
197                                 if (!wl_ioctl(ifname, WLC_GET_RSSI, &starssi, 12))
198                                 {
199                                         rssi -= starssi.rssi;
200                                         rssi_count++;
201                                 }
202                         }
203 
204                         free(macs);
205                 }
206 
207                 *buf = (rssi == 0 || rssi_count == 0) ? 1 : -(rssi / rssi_count);
208         }
209 
210         return 0;
211 }
212 
213 static int wl_get_noise(const char *ifname, int *buf)
214 {
215         unsigned int ap, noise;
216         int ioctl_req_version = 0x2000;
217         char tmp[WLC_IOCTL_MAXLEN];
218 
219         memset(tmp, 0, WLC_IOCTL_MAXLEN);
220         memcpy(tmp, &ioctl_req_version, sizeof(ioctl_req_version));
221 
222         wl_ioctl(ifname, WLC_GET_BSS_INFO, tmp, WLC_IOCTL_MAXLEN);
223 
224         if ((wl_ioctl(ifname, WLC_GET_AP, &ap, sizeof(ap)) < 0) || ap)
225         {
226                 if (wl_ioctl(ifname, WLC_GET_PHY_NOISE, &noise, sizeof(noise)) < 0)
227                         noise = 0;
228         }
229         else
230         {
231                 noise = tmp[WL_BSS_NOISE_OFFSET];
232         }
233 
234         *buf = noise;
235 
236         return 0;
237 }
238 
239 static int wl_get_quality(const char *ifname, int *buf)
240 {
241         return wext_ops.quality(ifname, buf);
242 }
243 
244 static int wl_get_quality_max(const char *ifname, int *buf)
245 {
246         return wext_ops.quality_max(ifname, buf);
247 }
248 
249 static int wl_get_encryption(const char *ifname, char *buf)
250 {
251         uint32_t wsec, wauth, wpa;
252         struct iwinfo_crypto_entry *c = (struct iwinfo_crypto_entry *)buf;
253 
254         if( wl_ioctl(ifname, WLC_GET_WPA_AUTH, &wpa,   sizeof(uint32_t)) ||
255             wl_ioctl(ifname, WLC_GET_WSEC,     &wsec,  sizeof(uint32_t)) ||
256                 wl_ioctl(ifname, WLC_GET_AUTH,     &wauth, sizeof(uint32_t)) )
257                         return -1;
258 
259         switch(wsec)
260         {
261                 case 2:
262                         c->pair_ciphers |= IWINFO_CIPHER_TKIP;
263                         break;
264 
265                 case 4:
266                         c->pair_ciphers |= IWINFO_CIPHER_CCMP;
267                         break;
268 
269                 case 6:
270                         c->pair_ciphers |= IWINFO_CIPHER_TKIP;
271                         c->pair_ciphers |= IWINFO_CIPHER_CCMP;
272                         break;
273         }
274 
275         switch(wpa)
276         {
277                 case 0:
278                         if (wsec && !wauth)
279                                 c->auth_algs |= IWINFO_AUTH_OPEN;
280 
281                         else if (wsec && wauth)
282                                 c->auth_algs |= IWINFO_AUTH_SHARED;
283 
284                         /* ToDo: evaluate WEP key lengths */
285                         c->pair_ciphers = IWINFO_CIPHER_WEP40 | IWINFO_CIPHER_WEP104;
286                         c->auth_suites |= IWINFO_KMGMT_NONE;
287                         break;
288 
289                 case 2:
290                         c->wpa_version = 1;
291                         c->auth_suites |= IWINFO_KMGMT_8021x;
292                         break;
293 
294                 case 4:
295                         c->wpa_version = 1;
296                         c->auth_suites |= IWINFO_KMGMT_PSK;
297                         break;
298 
299                 case 32:
300                 case 64:
301                         c->wpa_version = 2;
302                         c->auth_suites |= IWINFO_KMGMT_8021x;
303                         break;
304 
305                 case 66:
306                         c->wpa_version = 3;
307                         c->auth_suites |= IWINFO_KMGMT_8021x;
308                         break;
309 
310                 case 128:
311                         c->wpa_version = 2;
312                         c->auth_suites |= IWINFO_KMGMT_PSK;
313                         break;
314 
315                 case 132:
316                         c->wpa_version = 3;
317                         c->auth_suites |= IWINFO_KMGMT_PSK;
318                         break;
319 
320                 default:
321                         break;
322         }
323 
324         c->enabled = (c->wpa_version || c->auth_algs) ? 1 : 0;
325         c->group_ciphers = c->pair_ciphers;
326 
327         return 0;
328 }
329 
330 static int wl_get_phyname(const char *ifname, char *buf)
331 {
332         char *p;
333 
334         strcpy(buf, ifname);
335 
336         if ((p = strchr(buf, '.')) != NULL)
337                 *p = 0;
338 
339         return 0;
340 }
341 
342 static int wl_get_enctype(const char *ifname, char *buf)
343 {
344         uint32_t wsec, wpa;
345         char algo[11];
346 
347         if( wl_ioctl(ifname, WLC_GET_WPA_AUTH, &wpa, sizeof(uint32_t)) ||
348             wl_ioctl(ifname, WLC_GET_WSEC, &wsec, sizeof(uint32_t)) )
349                         return -1;
350 
351         switch(wsec)
352         {
353                 case 2:
354                         sprintf(algo, "TKIP");
355                         break;
356 
357                 case 4:
358                         sprintf(algo, "CCMP");
359                         break;
360 
361                 case 6:
362                         sprintf(algo, "TKIP, CCMP");
363                         break;
364         }
365 
366         switch(wpa)
367         {
368                 case 0:
369                         sprintf(buf, "%s", wsec ? "WEP" : "None");
370                         break;
371 
372                 case 2:
373                         sprintf(buf, "WPA 802.1X (%s)", algo);
374                         break;
375 
376                 case 4:
377                         sprintf(buf, "WPA PSK (%s)", algo);
378                         break;
379 
380                 case 32:
381                         sprintf(buf, "802.1X (%s)", algo);
382                         break;
383 
384                 case 64:
385                         sprintf(buf, "WPA2 802.1X (%s)", algo);
386                         break;
387 
388                 case 66:
389                         sprintf(buf, "mixed WPA/WPA2 802.1X (%s)", algo);
390                         break;
391 
392                 case 128:
393                         sprintf(buf, "WPA2 PSK (%s)", algo);
394                         break;
395 
396                 case 132:
397                         sprintf(buf, "mixed WPA/WPA2 PSK (%s)", algo);
398                         break;
399 
400                 default:
401                         sprintf(buf, "Unknown");
402         }
403 
404         return 0;
405 }
406 
407 static void wl_get_assoclist_cb(const char *ifname,
408                                                             struct iwinfo_assoclist_entry *e)
409 {
410         wl_sta_info_t sta = { 0 };
411 
412         if (!wl_iovar(ifname, "sta_info", e->mac, 6, &sta, sizeof(sta)) &&
413                 (sta.ver >= 2))
414         {
415                 e->inactive     = sta.idle * 1000;
416                 e->rx_packets   = sta.rx_ucast_pkts;
417                 e->tx_packets   = sta.tx_pkts;
418                 e->rx_rate.rate = sta.rx_rate;
419                 e->tx_rate.rate = sta.tx_rate;
420 
421                 /* ToDo: 11n */
422                 e->rx_rate.mcs = -1;
423                 e->tx_rate.mcs = -1;
424         }
425 }
426 
427 static int wl_get_assoclist(const char *ifname, char *buf, int *len)
428 {
429         int i, j, noise;
430         int ap, infra, passive;
431         char line[128];
432         char macstr[18];
433         char devstr[IFNAMSIZ];
434         struct wl_maclist *macs;
435         struct wl_sta_rssi rssi;
436         struct iwinfo_assoclist_entry entry;
437         FILE *arp;
438 
439         ap = infra = passive = 0;
440 
441         wl_ioctl(ifname, WLC_GET_AP, &ap, sizeof(ap));
442         wl_ioctl(ifname, WLC_GET_INFRA, &infra, sizeof(infra));
443         wl_ioctl(ifname, WLC_GET_PASSIVE, &passive, sizeof(passive));
444 
445         if (wl_get_noise(ifname, &noise))
446                 noise = 0;
447 
448         if ((ap || infra || passive) && ((macs = wl_read_assoclist(ifname)) != NULL))
449         {
450                 for (i = 0, j = 0; i < macs->count; i++, j += sizeof(struct iwinfo_assoclist_entry))
451                 {
452                         memset(&entry, 0, sizeof(entry));
453                         memcpy(rssi.mac, &macs->ea[i], 6);
454 
455                         if (!wl_ioctl(ifname, WLC_GET_RSSI, &rssi, sizeof(struct wl_sta_rssi)))
456                                 entry.signal = (rssi.rssi - 0x100);
457                         else
458                                 entry.signal = 0;
459 
460                         entry.noise = noise;
461                         memcpy(entry.mac, &macs->ea[i], 6);
462                         wl_get_assoclist_cb(ifname, &entry);
463 
464                         memcpy(&buf[j], &entry, sizeof(entry));
465                 }
466 
467                 *len = j;
468                 free(macs);
469                 return 0;
470         }
471         else if ((arp = fopen("/proc/net/arp", "r")) != NULL)
472         {
473                 j = 0;
474 
475                 while (fgets(line, sizeof(line), arp) != NULL)
476                 {
477                         if (sscanf(line, "%*s 0x%*d 0x%*d %17s %*s %s", macstr, devstr) && !strcmp(devstr, ifname))
478                         {
479                                 rssi.mac[0] = strtol(&macstr[0],  NULL, 16);
480                                 rssi.mac[1] = strtol(&macstr[3],  NULL, 16);
481                                 rssi.mac[2] = strtol(&macstr[6],  NULL, 16);
482                                 rssi.mac[3] = strtol(&macstr[9],  NULL, 16);
483                                 rssi.mac[4] = strtol(&macstr[12], NULL, 16);
484                                 rssi.mac[5] = strtol(&macstr[15], NULL, 16);
485 
486                                 if (!wl_ioctl(ifname, WLC_GET_RSSI, &rssi, sizeof(struct wl_sta_rssi)))
487                                         entry.signal = (rssi.rssi - 0x100);
488                                 else
489                                         entry.signal = 0;
490 
491                                 entry.noise = noise;
492                                 memcpy(entry.mac, rssi.mac, 6);
493                                 memcpy(&buf[j], &entry, sizeof(entry));
494 
495                                 j += sizeof(entry);
496                         }
497                 }
498 
499                 *len = j;
500                 (void) fclose(arp);
501                 return 0;
502         }
503 
504         return -1;
505 }
506 
507 static int wl_get_txpwrlist(const char *ifname, char *buf, int *len)
508 {
509         struct iwinfo_txpwrlist_entry entry;
510         uint8_t dbm[11] = { 0, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24 };
511         uint8_t mw[11]  = { 1, 3, 6, 10, 15, 25, 39, 63, 100, 158, 251 };
512         int i;
513 
514         for (i = 0; i < 11; i++)
515         {
516                 entry.dbm = dbm[i];
517                 entry.mw  = mw[i];
518                 memcpy(&buf[i*sizeof(entry)], &entry, sizeof(entry));
519         }
520 
521         *len = 11 * sizeof(entry);
522         return 0;
523 }
524 
525 static int wl_get_scanlist(const char *ifname, char *buf, int *len)
526 {
527         return wext_ops.scanlist(ifname, buf, len);
528 }
529 
530 static int wl_get_freqlist(const char *ifname, char *buf, int *len)
531 {
532         return wext_ops.freqlist(ifname, buf, len);
533 }
534 
535 static int wl_get_country(const char *ifname, char *buf)
536 {
537         char ccode[WLC_CNTRY_BUF_SZ];
538 
539         if (!wl_ioctl(ifname, WLC_GET_COUNTRY, ccode, WLC_CNTRY_BUF_SZ))
540         {
541                 /* IL0 -> World */
542                 if (!strcmp(ccode, "IL0"))
543                         sprintf(buf, "00");
544 
545                 /* YU -> RS */
546                 else if (!strcmp(ccode, "YU"))
547                         sprintf(buf, "RS");
548 
549                 else
550                         memcpy(buf, ccode, 2);
551 
552                 return 0;
553         }
554 
555         return -1;
556 }
557 
558 static int wl_get_countrylist(const char *ifname, char *buf, int *len)
559 {
560         int i, count;
561         char cdata[WLC_IOCTL_MAXLEN];
562         struct iwinfo_country_entry *c = (struct iwinfo_country_entry *)buf;
563         wl_country_list_t *cl = (wl_country_list_t *)cdata;
564 
565         cl->buflen = sizeof(cdata);
566 
567         if (!wl_ioctl(ifname, WLC_GET_COUNTRY_LIST, cl, cl->buflen))
568         {
569                 for (i = 0, count = 0; i < cl->count; i++, c++)
570                 {
571                         snprintf(c->ccode, sizeof(c->ccode), "%s", &cl->country_abbrev[i * WLC_CNTRY_BUF_SZ]);
572                         c->iso3166 = c->ccode[0] * 256 + c->ccode[1];
573 
574                         /* IL0 -> World */
575                         if (!strcmp(c->ccode, "IL0"))
576                                 c->iso3166 = 0x3030;
577 
578                         /* YU -> RS */
579                         else if (!strcmp(c->ccode, "YU"))
580                                 c->iso3166 = 0x5253;
581                 }
582 
583                 *len = (i * sizeof(struct iwinfo_country_entry));
584                 return 0;
585         }
586 
587         return -1;
588 }
589 
590 static int wl_get_hwmodelist(const char *ifname, int *buf)
591 {
592         int phytype;
593         uint i, band[WLC_BAND_ALL], bands;
594 
595         if (!wl_ioctl(ifname, WLC_GET_PHYTYPE, &phytype, sizeof(phytype)) &&
596                 !wl_ioctl(ifname, WLC_GET_BANDLIST, band, sizeof(band)))
597         {
598                 *buf = 0;
599                 switch (phytype)
600                 {
601                         case WLC_PHY_TYPE_A:
602                                 *buf = IWINFO_80211_A;
603                                 break;
604                         case WLC_PHY_TYPE_B:
605                                 *buf = IWINFO_80211_B;
606                                 break;
607                         case WLC_PHY_TYPE_AC:
608                                 *buf |= IWINFO_80211_AC;
609                         case WLC_PHY_TYPE_HT:
610                         case WLC_PHY_TYPE_N:
611                                 *buf |= IWINFO_80211_N;
612                         case WLC_PHY_TYPE_LP:
613                         case WLC_PHY_TYPE_G:
614                                 bands = 0;
615                                 for (i = 1; i <= band[0]; i++)
616                                 {
617                                         bands |= band[i];
618                                 }
619                                 if (bands & WLC_BAND_5G)
620                                         *buf |= IWINFO_80211_A;
621                                 if (bands & WLC_BAND_2G)
622                                 {
623                                         *buf |= IWINFO_80211_B;
624                                         *buf |= IWINFO_80211_G;
625                                 }
626                                 break;
627                         default:
628                                 return -1;
629                                 break;
630                 }
631                         return 0;
632         }
633         return -1;
634 }
635 
636 static int wl_get_htmodelist(const char *ifname, int *buf)
637 {
638         int modes;
639 
640         if (!wl_get_hwmodelist(ifname, &modes))
641         {
642                 *buf = 0;
643 
644                 /* FIXME: determine real capabilities */
645 
646                 if (modes & IWINFO_80211_N)
647                         *buf |= IWINFO_HTMODE_HT20 | IWINFO_HTMODE_HT40;
648 
649                 if (modes & IWINFO_80211_AC)
650                         *buf |= IWINFO_HTMODE_VHT20 | IWINFO_HTMODE_VHT40 |
651                                 IWINFO_HTMODE_VHT80;
652 
653                 return 0;
654         }
655 
656         return -1;
657 }
658 
659 static int wl_get_mbssid_support(const char *ifname, int *buf)
660 {
661         wlc_rev_info_t revinfo;
662 
663         /* Multi bssid support only works on corerev >= 9 */
664         if (!wl_ioctl(ifname, WLC_GET_REVINFO, &revinfo, sizeof(revinfo)))
665         {
666                 if (revinfo.corerev >= 9)
667                 {
668                         *buf = 1;
669                         return 0;
670                 }
671         }
672 
673         return -1;
674 }
675 
676 static int wl_get_hardware_id(const char *ifname, char *buf)
677 {
678         wlc_rev_info_t revinfo;
679         struct iwinfo_hardware_id *ids = (struct iwinfo_hardware_id *)buf;
680 
681         if (wl_ioctl(ifname, WLC_GET_REVINFO, &revinfo, sizeof(revinfo)))
682                 return -1;
683 
684         ids->vendor_id = revinfo.vendorid;
685         ids->device_id = revinfo.deviceid;
686         ids->subsystem_vendor_id = revinfo.boardvendor;
687         ids->subsystem_device_id = revinfo.boardid;
688 
689         return 0;
690 }
691 
692 static int wl_get_hardware_name(const char *ifname, char *buf)
693 {
694         struct iwinfo_hardware_id ids;
695 
696         if (wl_get_hardware_id(ifname, (char *)&ids))
697                 return -1;
698 
699         sprintf(buf, "Broadcom BCM%04X", ids.device_id);
700 
701         return 0;
702 }
703 
704 static int wl_get_txpower_offset(const char *ifname, int *buf)
705 {
706         FILE *p;
707         char off[8];
708         struct stat s;
709 
710         *buf = 0;
711 
712         if (!stat("/usr/sbin/nvram", &s) && (s.st_mode & S_IXUSR))
713         {
714                 if ((p = popen("/usr/sbin/nvram get opo", "r")) != NULL)
715                 {
716                         if (fread(off, 1, sizeof(off), p))
717                                 *buf = strtoul(off, NULL, 16);
718 
719                         pclose(p);
720                 }
721         }
722 
723         return 0;
724 }
725 
726 static int wl_get_frequency_offset(const char *ifname, int *buf)
727 {
728         /* Stub */
729         *buf = 0;
730         return -1;
731 }
732 
733 const struct iwinfo_ops wl_ops = {
734         .name             = "wl",
735         .probe            = wl_probe,
736         .channel          = wl_get_channel,
737         .frequency        = wl_get_frequency,
738         .frequency_offset = wl_get_frequency_offset,
739         .txpower          = wl_get_txpower,
740         .txpower_offset   = wl_get_txpower_offset,
741         .bitrate          = wl_get_bitrate,
742         .signal           = wl_get_signal,
743         .noise            = wl_get_noise,
744         .quality          = wl_get_quality,
745         .quality_max      = wl_get_quality_max,
746         .mbssid_support   = wl_get_mbssid_support,
747         .hwmodelist       = wl_get_hwmodelist,
748         .htmodelist       = wl_get_htmodelist,
749         .mode             = wl_get_mode,
750         .ssid             = wl_get_ssid,
751         .bssid            = wl_get_bssid,
752         .country          = wl_get_country,
753         .hardware_id      = wl_get_hardware_id,
754         .hardware_name    = wl_get_hardware_name,
755         .encryption       = wl_get_encryption,
756         .phyname          = wl_get_phyname,
757         .assoclist        = wl_get_assoclist,
758         .txpwrlist        = wl_get_txpwrlist,
759         .scanlist         = wl_get_scanlist,
760         .freqlist         = wl_get_freqlist,
761         .countrylist      = wl_get_countrylist,
762         .close            = wl_close
763 };
764 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt