int ej_active_wireless_if_ath9k(webs_t wp, int argc, char_t ** argv, char *ifname, int cnt, int turbo, int macmask) { char mac[32]; struct mac80211_info *mac80211_info; struct wifi_client_info *wc; char nb[32]; int bias, qual, it; int co = 0; sprintf(nb, "%s_bias", ifname); bias = atoi(nvram_default_get(nb, "0")); // sprintf(it, "inactivity_time", ifname); // it = atoi(nvram_default_get("inacttime", "300000")); mac80211_info = mac80211_assoclist(ifname); for (wc = mac80211_info->wci; wc; wc = wc->next) { strncpy(mac, wc->mac, 31); if (nvram_match("maskmac", "1") && macmask) { mac[0] = 'x'; mac[1] = 'x'; mac[3] = 'x'; mac[4] = 'x'; mac[6] = 'x'; mac[7] = 'x'; mac[9] = 'x'; mac[10] = 'x'; } qual = wc->signal * 124 + 11600; qual /= 10; // if (wc->inactive_time < it) { if (cnt) websWrite(wp, ","); websWrite(wp, "'%s','%s','%s','%dM','%dM','%d','%d','%d','%d'", mac, wc->ifname, UPTIME(wc->uptime), wc->txrate / 10, wc->rxrate / 10, wc->signal + bias, wc->noise + bias, wc->signal - wc->noise, qual); cnt++; // } } free_wifi_clients(mac80211_info->wci); free(mac80211_info); return cnt; }
int ej_active_wireless_if(webs_t wp, int argc, char_t ** argv, char *iface, char *visible, int cnt) { int rssi = 0, noise = 0; FILE *fp2; char *mode; char mac[30]; char line[80]; int macmask; macmask = atoi(argv[0]); if (!ifexists(iface)) return cnt; unlink(RSSI_TMP); char wlmode[32]; sprintf(wlmode, "%s_mode", visible); mode = nvram_safe_get(wlmode); unsigned char buf[WLC_IOCTL_MAXLEN]; memset(buf, 0, WLC_IOCTL_MAXLEN); // get_wdev int r = getassoclist(iface, buf); if (r < 0) return cnt; struct maclist *maclist = (struct maclist *)buf; int i; for (i = 0; i < maclist->count; i++) { ether_etoa((uint8 *) & maclist->ea[i], mac); rssi = 0; noise = 0; // get rssi value if (strcmp(mode, "ap") && strcmp(mode, "apsta") && strcmp(mode, "apstawet")) sysprintf("wl -i %s rssi > %s", iface, RSSI_TMP); else sysprintf("wl -i %s rssi \"%s\" > %s", iface, mac, RSSI_TMP); // get noise value if not ap mode // if (strcmp (mode, "ap")) // snprintf (cmd, sizeof (cmd), "wl -i %s noise >> %s", iface, // RSSI_TMP); // system2 (cmd); // get RSSI value for mac fp2 = fopen(RSSI_TMP, "r"); if (fgets(line, sizeof(line), fp2) != NULL) { // get rssi if (sscanf(line, "%d", &rssi) != 1) continue; noise = getNoise(iface, NULL); /* * if (strcmp (mode, "ap") && fgets (line, sizeof (line), fp2) != * NULL && sscanf (line, "%d", &noise) != 1) continue; */ // get noise for client/wet mode fclose(fp2); } if (nvram_match("maskmac", "1") && macmask) { mac[0] = 'x'; mac[1] = 'x'; mac[3] = 'x'; mac[4] = 'x'; mac[6] = 'x'; mac[7] = 'x'; mac[9] = 'x'; mac[10] = 'x'; } if (cnt) websWrite(wp, ","); cnt++; int rxrate[32]; int txrate[32]; int time[32]; strcpy(rxrate, "N/A"); strcpy(txrate, "N/A"); strcpy(time, "N/A"); #ifndef WL_STA_SCBSTATS #define WL_STA_SCBSTATS 0x4000 /* Per STA debug stats */ #endif sta_info_compat_t *sta; sta_info_compat_old_t *staold; char *param; int buflen; char buf[WLC_IOCTL_MEDLEN]; strcpy(buf, "sta_info"); buflen = strlen(buf) + 1; param = (char *)(buf + buflen); memcpy(param, (char *)&maclist->ea[i], ETHER_ADDR_LEN); if (!wl_ioctl(iface, WLC_GET_VAR, &buf[0], WLC_IOCTL_MEDLEN)) { /* display the sta info */ sta = (sta_info_compat_t *) buf; if (sta->ver == 2) { staold = (sta_info_compat_old_t *) buf; if (staold->flags & WL_STA_SCBSTATS) { int tx = staold->tx_rate; int rx = staold->rx_rate; if (tx > 0) sprintf(txrate, "%dM", tx / 1000); if (rx > 0) sprintf(rxrate, "%dM", rx / 1000); strcpy(time, UPTIME(staold->in)); } } else { // sta->ver == 3 if (sta->flags & WL_STA_SCBSTATS) { int tx = sta->tx_rate; int rx = sta->rx_rate; if (tx > 0) sprintf(txrate, "%dM", tx / 1000); if (rx > 0) sprintf(rxrate, "%dM", rx / 1000); strcpy(time, UPTIME(sta->in)); } } } /* * if (!strcmp (mode, "ap")) { noise = getNoise(iface,NULL); // null * only for broadcom } */ int qual = rssi * 124 + 11600; qual /= 10; websWrite(wp, "'%s','%s','%s','%s','%s','%d','%d','%d','%d'", mac, iface, time, txrate, rxrate, rssi, noise, rssi - noise, qual); } unlink(RSSI_TMP); return cnt; }
int ej_active_wireless_if_11n(webs_t wp, int argc, char_t ** argv, char *ifname, int cnt, int turbo, int macmask) { unsigned char *cp; int s, len; struct iwreq iwr; char nb[32]; sprintf(nb, "%s_bias", ifname); int bias = atoi(nvram_default_get(nb, "0")); if (!ifexists(ifname)) { printf("IOCTL_STA_INFO ifresolv %s failed!\n", ifname); return cnt; } int state = 0; state = get_radiostate(ifname); if (state == 0 || state == -1) { printf("IOCTL_STA_INFO radio %s not enabled!\n", ifname); return cnt; } s = getsocket(); if (s < 0) { fprintf(stderr, "socket(SOCK_DRAGM)\n"); return cnt; } (void)memset(&iwr, 0, sizeof(struct iwreq)); (void)strncpy(iwr.ifr_name, ifname, sizeof(iwr.ifr_name)); iwr.u.data.pointer = (void *)&madbuf[0]; iwr.u.data.length = 24 * 1024; if (ioctl(s, IEEE80211_IOCTL_STA_INFO, &iwr) < 0) { fprintf(stderr, "IOCTL_STA_INFO for %s failed!\n", ifname); closesocket(); return cnt; } len = iwr.u.data.length; if (len < sizeof(struct ieee80211req_sta_info)) { // fprintf(stderr,"IOCTL_STA_INFO len<struct %s failed!\n",ifname); closesocket(); return cnt; } cp = madbuf; int bufcount = 0; do { struct ieee80211req_sta_info *si; uint8_t *vp; si = (struct ieee80211req_sta_info *)cp; vp = (u_int8_t *)(si + 1); if (cnt) websWrite(wp, ","); cnt++; char mac[32]; strncpy(mac, ieee80211_ntoa(si->isi_macaddr), 31); if (nvram_match("maskmac", "1") && macmask) { mac[0] = 'x'; mac[1] = 'x'; mac[3] = 'x'; mac[4] = 'x'; mac[6] = 'x'; mac[7] = 'x'; mac[9] = 'x'; mac[10] = 'x'; } if (si->isi_noise == 0) { si->isi_noise = -95; } int qual = (si->isi_noise + si->isi_rssi) * 124 + 11600; qual /= 10; int rxrate = si->isi_rxrateKbps / 1000; int txrate = si->isi_txrateKbps / 1000; if (!rxrate) rxrate = si->isi_rates[si->isi_rxrate] & IEEE80211_RATE_VAL; if (!txrate) txrate = si->isi_rates[si->isi_txrate] & IEEE80211_RATE_VAL; char rx[32]; char tx[32]; if (rxrate) sprintf(rx, "%3dM", rxrate); else sprintf(rx, "N/A"); if (txrate) sprintf(tx, "%3dM", txrate); else sprintf(tx, "N/A"); websWrite(wp, "'%s','%s','%s','%s','%s','%d','%d','%d','%d'", mac, ifname, UPTIME(si->isi_uptime), tx, rx, si->isi_noise + si->isi_rssi + bias, si->isi_noise + bias, si->isi_rssi, qual); bufcount += si->isi_len; cp += si->isi_len; len -= si->isi_len; } while (len >= sizeof(struct ieee80211req_sta_info) && bufcount < (sizeof(madbuf) - sizeof(struct ieee80211req_sta_info))); closesocket(); return cnt; }