static int radar_set_param(struct radarhandler *radar, const char *param, const char *val) { int v; v = atoi(val); if (strcmp(param, "enabled") == 0) { radarset(radar, DFS_PARAM_ENABLE, v); } else if (strcmp(param, "firpwr") == 0) { radarset(radar, DFS_PARAM_FIRPWR, v); } else if (strcmp(param, "rrssi") == 0) { radarset(radar, DFS_PARAM_RRSSI, v); } else if (strcmp(param, "height") == 0) { radarset(radar, DFS_PARAM_HEIGHT, v); } else if (strcmp(param, "prssi") == 0) { radarset(radar, DFS_PARAM_PRSSI, v); } else if (strcmp(param, "inband") == 0) { radarset(radar, DFS_PARAM_INBAND, v); } else if (strcmp(param, "relpwr") == 0) { radarset(radar, DFS_PARAM_RELPWR, v); } else if (strcmp(param, "relstep") == 0) { radarset(radar, DFS_PARAM_RELSTEP, v); } else if (strcmp(param, "maxlen") == 0) { radarset(radar, DFS_PARAM_MAXLEN, v); } else if (strcmp(param, "usefir128") == 0) { radarset(radar, DFS_PARAM_USEFIR128, v); } else if (strcmp(param, "blockradar") == 0) { radarset(radar, DFS_PARAM_BLOCKRADAR, v); } else if (strcmp(param, "enmaxrssi") == 0) { radarset(radar, DFS_PARAM_MAXRSSI_EN, v); } else if (strcmp(param, "extchannel") == 0) { radarset(radar, DFS_PARAM_EN_EXTCH, v); } else if (strcmp(param, "enrelpwr") == 0) { radarset(radar, DFS_PARAM_RELPWR_EN, v); } else if (strcmp(param, "en_relstep_check") == 0) { radarset(radar, DFS_PARAM_RELSTEP_EN, v); } else { return 0; } return 1; }
int main(int argc, char *argv[]) { #define streq(a,b) (strcasecmp(a,b) == 0) struct radarhandler radar; HAL_REVS revs; struct ifreq ifr; memset(&radar, 0, sizeof(radar)); radar.s = socket(AF_INET, SOCK_DGRAM, 0); if (radar.s < 0) err(1, "socket"); if (argc > 1 && strcmp(argv[1], "-i") == 0) { if (argc < 2) { fprintf(stderr, "%s: missing interface name for -i\n", argv[0]); exit(-1); } strncpy(radar.atd.ad_name, argv[2], sizeof (radar.atd.ad_name)); radar.atd.ad_name[sizeof(radar.atd.ad_name) - 1] = '\0'; argc -= 2, argv += 2; } else strncpy(radar.atd.ad_name, ATH_DEFAULT, sizeof (radar.atd.ad_name)); #if 0 radar.atd.ad_id = HAL_DIAG_REVS; radar.atd.ad_out_data = (void *) &revs; radar.atd.ad_out_size = sizeof(revs); strcpy(ifr.ifr_name, radar.atd.ad_name); ifr.ifr_data = (caddr_t) &radar.atd; if (ioctl(radar.s, SIOCGATHDIAG, &ifr) < 0) err(1, radar.atd.ad_name); switch (revs.ah_devid) { case AR5210_PROD: case AR5210_DEFAULT: printf("No radar detection yet for a 5210\n"); exit(0); case AR5211_DEVID: case AR5311_DEVID: case AR5211_DEFAULT: case AR5211_FPGA11B: printf("No radar detecton yet for a 5211\n"); exit(0); case AR5212_FPGA: case AR5212_DEVID: case AR5212_DEVID_IBM: case AR5212_DEFAULT: case AR5212_AR5312_REV2: case AR5212_AR5312_REV7: break; default: printf("No radar detection for device 0x%x\n", revs.ah_devid); exit(0); } #endif if (argc >= 2) { if(streq(argv[1], "firpwr")) { radarset(&radar, DFS_PARAM_FIRPWR, (u_int32_t) atoi(argv[2])); } else if (streq(argv[1], "rrssi")) { radarset(&radar, DFS_PARAM_RRSSI, strtoul(argv[2], NULL, 0)); } else if (streq(argv[1], "height")) { radarset(&radar, DFS_PARAM_HEIGHT, strtoul(argv[2], NULL, 0)); } else if (streq(argv[1], "prssi")) { radarset(&radar, DFS_PARAM_PRSSI, strtoul(argv[2], NULL, 0)); } else if (streq(argv[1], "inband")) { radarset(&radar, DFS_PARAM_INBAND, strtoul(argv[2], NULL, 0)); } else if (streq(argv[1], "dfstime")) { radarSetMuteTime(&radar, strtoul(argv[2], NULL, 0)); } else if (streq(argv[1], "usenol")) { radarSetUsenol(&radar, atoi(argv[2])); } else if (streq(argv[1], "dfsdebug")) { radarSetDebugLevel(&radar, (u_int32_t)atoi(argv[2])); } else if (streq(argv[1], "fft")) { radarEnableFFT(&radar); } else if (streq(argv[1], "nofft")) { radarDisableFFT(&radar); } else if (streq(argv[1], "bangradar")) { radarBangRadar(&radar); } else if (streq(argv[1], "shownol")) { radarShowNol(&radar); } else if (streq(argv[1], "disable")) { radarDisableDetect(&radar); } else if (streq(argv[1], "enable")) { radarEnableDetect(&radar); } else if (streq(argv[1], "numdetects")) { printf("Radar: detected %d radars\n", radarGetRadarDetects(&radar)); } else if (streq(argv[1], "getnol")){ radarGetNol(&radar, argv[2]); } else if (streq(argv[1], "setnol")) { radarSetNol(&radar, argv[2]); } else if (streq(argv[1],"-h")) { usage(); /* Following are valid for 5413 only */ } else if (streq(argv[1], "relpwr")) { radarset(&radar, DFS_PARAM_RELPWR, strtoul(argv[2], NULL, 0)); } else if (streq(argv[1], "relstep")) { radarset(&radar, DFS_PARAM_RELSTEP, strtoul(argv[2], NULL, 0)); } else if (streq(argv[1], "maxlen")) { radarset(&radar, DFS_PARAM_MAXLEN, strtoul(argv[2], NULL, 0)); } } else if (argc == 1) { HAL_PHYERR_PARAM pe; u_int32_t nol; nol = radarGetUseNol(&radar); /* ** channel switch announcement (CSA). The AP does ** the following on radar detect: ** nol = 0, use CSA, but new channel is same as old channel ** nol = 1, use CSA and switch to new channel (default) ** nol = 2, do not use CSA and stay on same channel ** **/ printf ("Radar;\nUse NOL: %s\n",(nol==1) ? "yes" : "no"); if (nol >= 2) printf ("No Channel Switch announcemnet\n"); radarGetThresholds(&radar, &pe); printf ("Firpwr (thresh to see if radar sig is gone): %d\n",pe.pe_firpwr); printf ("Radar Rssi (thresh to start radar det in dB): %u\n",pe.pe_rrssi); printf ("Height (thresh for pulse height (dB): %u\n",pe.pe_height); printf ("Pulse rssi (thresh if pulse is gone in dB): %u\n",pe.pe_prssi); printf ("Inband (thresh if pulse is inband (in 0.5dB): %u\n",pe.pe_inband); /* Following are valid for 5413 only */ if (pe.pe_relpwr & HAL_PHYERR_PARAM_ENABLE) printf ("Relative power check, thresh in 0.5dB steps: %u\n", pe.pe_relpwr & ~HAL_PHYERR_PARAM_ENABLE); else printf ("Relative power check disabled\n"); if (pe.pe_relstep & HAL_PHYERR_PARAM_ENABLE) printf ("Relative step thresh in 0.5dB steps: %u\n", pe.pe_relstep & ~HAL_PHYERR_PARAM_ENABLE); else printf ("Relative step for pulse detection disabled\n"); printf ("Max length of radar sig in 0.8us units: %u\n",pe.pe_maxlen); } else { usage (); } return 0; }