int wl_get_channels(void *wl, int max, int *len, uint16 *channels) { uint32 chan_buf[WL_NUMCHANNELS + 1]; wl_uint32_list_t *list; int ret; uint i; int count; list = (wl_uint32_list_t *)(void *)chan_buf; list->count = htod32(WL_NUMCHANNELS); ret = wlu_get(wl, WLC_GET_VALID_CHANNELS, chan_buf, sizeof(chan_buf)); if (ret < 0) return ret; count = 0; for (i = 0; i < dtoh32(list->count); i++) { if (count >= max) break; channels[count++] = dtoh32(list->element[i]); } *len = count; return ret; }
/* * Configures local channel for finding server. * Server call this fucntion for getting its current channel, * client uses this fucntion for setting its channel to new channel. */ static int rwl_wifi_config_channel(void *wl, int cmd, int *channel) { int error; channel_info_t ci; /* Get functionality is used only by server */ if (cmd == WLC_GET_CHANNEL) { memset((char*)&ci, 0, sizeof(ci)); if ((error = wl_get(wl, cmd, &ci, sizeof(channel_info_t)))) return error; ci.hw_channel = dtoh32(ci.hw_channel); ci.scan_channel = dtoh32(ci.scan_channel); ci.target_channel = dtoh32(ci.target_channel); if (ci.scan_channel) printf("Scan in progress.\n"); *channel = ci.hw_channel; } if (cmd == WLC_SET_CHANNEL) { /* Set functionality is used by the client */ ci.target_channel = *channel; /* When user wants to execute local CMD being in remote wifi mode, * rwl_wifi_swap_remote_type fucntion is used to change the remote types. */ rwl_wifi_swap_remote_type(remote_type); error = wl_set(wl, cmd, &ci.target_channel, sizeof(int)); /* rever it back to same old remote type */ rwl_wifi_swap_remote_type(remote_type); } return error; }
static uint16_t ptp_ptpip_event (PTPParams* params, PTPContainer* event, int wait) { fd_set infds; struct timeval timeout; int ret; unsigned char* data = NULL; PTPIPHeader hdr; int n; while (1) { FD_ZERO(&infds); FD_SET(params->evtfd, &infds); timeout.tv_sec = 0; if (wait == PTP_EVENT_CHECK_FAST) timeout.tv_usec = 1; else timeout.tv_usec = 1000; /* 1/1000 second .. perhaps wait longer? */ ret = select (params->evtfd+1, &infds, NULL, NULL, &timeout); if (1 != ret) { if (-1 == ret) { gp_log (GP_LOG_DEBUG,"ptpip/event", "select returned error, errno is %d", errno); return PTP_ERROR_IO; } return PTP_ERROR_TIMEOUT; } ret = ptp_ptpip_evt_read (params, &hdr, &data); if (ret != PTP_RC_OK) return ret; gp_log (GP_LOG_DEBUG,"ptpip/event", "hdr type %d, length %d", hdr.type, hdr.length); if (dtoh32(hdr.type) == PTPIP_EVENT) { break; } /* TODO: Handle cancel transaction and ping/pong * If not PTPIP_EVENT, process it and wait for next PTPIP_EVENT */ gp_log (GP_LOG_ERROR, "ptpip/event", "unknown/unhandled event type %d", dtoh32(hdr.type)); } event->Code = dtoh16a(&data[ptpip_event_code]); event->Transaction_ID = dtoh32a(&data[ptpip_event_transid]); n = (dtoh32(hdr.length) - sizeof(hdr) - ptpip_event_param1)/sizeof(uint32_t); switch (n) { case 3: event->Param3 = dtoh32a(&data[ptpip_event_param3]); case 2: event->Param2 = dtoh32a(&data[ptpip_event_param2]); case 1: event->Param1 = dtoh32a(&data[ptpip_event_param1]); case 0: break; default: gp_log( GP_LOG_ERROR, "ptpip/event", "response got %d parameters?", n); break; } free (data); return PTP_RC_OK; }
static int dhd_iscan_get_partial_result(void *dhdp, uint *scan_count) { wl_iscan_results_t *list_buf; wl_iscan_results_t list; wl_scan_results_t *results; iscan_buf_t *iscan_cur; int status = -1; dhd_pub_t *dhd = dhd_bus_pub(dhdp); int rc; DHD_TRACE(("%s: Enter\n", __FUNCTION__)); iscan_cur = dhd_iscan_allocate_buf(dhd, &iscan_chain); if (!iscan_cur) { DHD_ERROR(("%s: Failed to allocate node\n", __FUNCTION__)); dhd_iscan_free_buf(dhdp, 0); dhd_iscan_request(dhdp, WL_SCAN_ACTION_ABORT); dhd_ind_scan_confirm(dhdp, FALSE); goto fail; } dhd_iscan_lock(); memset(iscan_cur->iscan_buf, 0, WLC_IW_ISCAN_MAXLEN); list_buf = (wl_iscan_results_t*)iscan_cur->iscan_buf; results = &list_buf->results; results->buflen = WL_ISCAN_RESULTS_FIXED_SIZE; results->version = 0; results->count = 0; memset(&list, 0, sizeof(list)); list.results.buflen = htod32(WLC_IW_ISCAN_MAXLEN); bcm_mkiovar("iscanresults", (char *)&list, WL_ISCAN_RESULTS_FIXED_SIZE, iscan_cur->iscan_buf, WLC_IW_ISCAN_MAXLEN); rc = dhd_wl_ioctl_cmd(dhd, WLC_GET_VAR, iscan_cur->iscan_buf, WLC_IW_ISCAN_MAXLEN, FALSE, 0); results->buflen = dtoh32(results->buflen); results->version = dtoh32(results->version); *scan_count = results->count = dtoh32(results->count); status = dtoh32(list_buf->status); DHD_TRACE(("%s: Got %d resuls\n", __FUNCTION__, results->count)); dhd_iscan_unlock(); if (!(*scan_count)) { dhd_iscan_free_buf(dhdp, iscan_cur); } fail: return status; }
static int lua_ctl_aclchk(lua_State *L, void *wl, lua_cmd_t *cmd, char *argv) { struct maclist *maclist = (struct maclist *) buf; struct maclist *acllist = (struct maclist *) (buf + WLC_IOCTL_MAXLEN); uint i, j, max = (WLC_IOCTL_MAXLEN - sizeof(int)) / ETHER_ADDR_LEN; struct ether_addr *ea, *tea; int ret, val, deauth; if ((ret = wlu_get(wl, WLC_GET_MACMODE, &val, sizeof(int))) < 0) return ret; val = dtoh32(val); if (val == 0) { return 0; } maclist->count = htod32(max); if ((ret = wlu_get(wl, WLC_GET_ASSOCLIST, maclist, WLC_IOCTL_MAXLEN)) < 0) { return ret; } maclist->count = dtoh32(maclist->count); acllist->count = htod32(max); if ((ret = wlu_get(wl, WLC_GET_MACLIST, acllist, WLC_IOCTL_MAXLEN)) < 0) { return ret; } acllist->count = dtoh32(maclist->count); for (i = 0, ea = maclist->ea; i < maclist->count && i < max; i++, ea++) { deauth = (val == 2) ? 1 : 0; for (j = 0, tea = acllist->ea; j < acllist->count && j < max; j++, tea++) { if (memcmp(ea, tea, sizeof(struct ether_addr)) == 0) { deauth = !deauth; } } if (deauth) { /* No reason code furnished, so driver will use its default */ ret = wlu_set(wl, WLC_SCB_DEAUTHENTICATE, ea, ETHER_ADDR_LEN); } } return 0; }
static int lua_get_acllist(lua_State *L, void *wl, lua_cmd_t *cmd, char *argv) { struct maclist *maclist = (struct maclist *) buf; uint i, max = (WLC_IOCTL_MAXLEN - sizeof(int)) / ETHER_ADDR_LEN; struct ether_addr *ea; int ret; maclist->count = htod32(max); if ((ret = wlu_get(wl, WLC_GET_MACLIST, maclist, WLC_IOCTL_MAXLEN)) < 0) { return ret; } maclist->count = dtoh32(maclist->count); lua_newtable(L); for (i = 0, ea = maclist->ea; i < maclist->count && i < max; i++, ea++) { lua_newtable(L); lua_pushstring(L, wl_ether_etoa(ea)); lua_setfield(L, -2, "macaddr"); lua_rawseti(L, -2, i+1); } return ret; }
/* produce a growing image file */ int make_growing_image(FILE *fp, Bit64u sec) { redolog_header_t header; Bit32u i, not_allocated = htod32(REDOLOG_PAGE_NOT_ALLOCATED); memset(&header, 0, sizeof(header)); make_redolog_header(&header, REDOLOG_SUBTYPE_GROWING, sec * 512); if (fwrite(&header, sizeof(header), 1, fp) != 1) { fclose (fp); fatal ("ERROR: The disk image is not complete - could not write header!"); } for (i=0; i<dtoh32(header.specific.catalog); i++) { if (fwrite(¬_allocated, sizeof(Bit32u), 1, fp) != 1) { fclose (fp); fatal ("ERROR: The disk image is not complete - could not write catalog!"); } } return 0; }
int wlmEstimatedPowerGet(int *estPower, int chain) { tx_power_t power; int mimo; memset(&power, 0, sizeof(power)); if (wlu_get(irh, WLC_CURRENT_PWR, &power, sizeof(power)) < 0) { printf("wlmEstimatedPowerGet: %s\n", wlmLastError()); return FALSE; } power.flags = dtoh32(power.flags); power.chanspec = dtohchanspec(power.chanspec); mimo = (power.flags & WL_TX_POWER_F_MIMO); /* value returned is in units of quarter dBm, need to multiply by 250 to get milli-dBm */ if (mimo) { *estPower = power.est_Pout[chain] * 250; } else { *estPower = power.est_Pout[0] * 250; } if (!mimo && CHSPEC_IS2G(power.chanspec)) { *estPower = power.est_Pout_cck * 250; } return TRUE; }
int wldev_get_ap_status(struct net_device *dev) { int res = 0; int ap = 0; int apsta = 0; char smbuf[WLC_IOCTL_SMLEN]; printf("%s: enter\n", __FUNCTION__); if (!dev) { WLDEV_ERROR(("%s: dev is null\n", __FUNCTION__)); return -1; } if ((res = wldev_ioctl(dev, WLC_GET_AP, &ap, sizeof(ap), 0))) { WLDEV_ERROR(("%s fail to get ap\n", __FUNCTION__)); ap = 0; } if ((res = wldev_iovar_getbuf(dev, "apsta", &apsta, sizeof(apsta), smbuf, sizeof(smbuf), NULL)) < 0 ){ WLDEV_ERROR(("%s fail to get apsta \n", __FUNCTION__)); } else { memcpy(&apsta, smbuf, sizeof(apsta)); apsta = dtoh32(apsta); } return (ap||apsta); }
uint16_t ptp_ptpip_getresp (PTPParams* params, PTPContainer* resp) { PTPIPHeader hdr; unsigned char *data = NULL; uint16_t ret; int n; ret = ptp_ptpip_cmd_read (params, &hdr, &data); if (ret != PTP_RC_OK) return ret; resp->Code = dtoh16a(&data[ptpip_resp_code]); resp->Transaction_ID = dtoh32a(&data[ptpip_resp_transid]); n = (dtoh32(hdr.length) - sizeof(hdr) - ptpip_resp_param1)/sizeof(uint32_t); switch (n) { case 5: resp->Param5 = dtoh32a(&data[ptpip_resp_param5]); case 4: resp->Param4 = dtoh32a(&data[ptpip_resp_param4]); case 3: resp->Param3 = dtoh32a(&data[ptpip_resp_param3]); case 2: resp->Param2 = dtoh32a(&data[ptpip_resp_param2]); case 1: resp->Param1 = dtoh32a(&data[ptpip_resp_param1]); case 0: break; default: gp_log( GP_LOG_ERROR, "ptpip/getresp", "response got %d parameters?", n); break; } free (data); return PTP_RC_OK; }
static uint16_t ptp_ptpip_init_command_ack (PTPParams* params) { PTPIPHeader hdr; unsigned char *data = NULL; uint16_t ret; int i; unsigned short *name; ret = ptp_ptpip_generic_read (params, params->cmdfd, &hdr, &data); if (ret != PTP_RC_OK) return ret; if (hdr.type != dtoh32(PTPIP_INIT_COMMAND_ACK)) { gp_log (GP_LOG_ERROR, "ptpip/init_cmd_ack", "bad type returned %d", htod32(hdr.type)); free (data); return PTP_RC_GeneralError; } params->eventpipeid = dtoh32a(&data[ptpip_cmdack_idx]); memcpy (params->cameraguid, &data[ptpip_cmdack_guid], 16); name = (unsigned short*)&data[ptpip_cmdack_name]; for (i=0;name[i];i++) /* EMPTY */; params->cameraname = malloc((i+1)*sizeof(uint16_t)); for (i=0;name[i];i++) params->cameraname[i] = name[i]; free (data); return PTP_RC_OK; }
void wl_update_rssi_cache(wl_rssi_cache_ctrl_t *rssi_cache_ctrl, wl_scan_results_t *ss_list) { wl_rssi_cache_t *node, *prev, *leaf, **rssi_head; wl_bss_info_t *bi = NULL; int i, j, k; if (!ss_list->count) return; rssi_head = &rssi_cache_ctrl->m_cache_head; /* update RSSI */ for (i = 0; i < ss_list->count; i++) { node = *rssi_head; prev = NULL; k = 0; bi = bi ? (wl_bss_info_t *)((uintptr)bi + dtoh32(bi->length)) : ss_list->bss_info; for (;node;) { if (!memcmp(&node->BSSID, &bi->BSSID, ETHER_ADDR_LEN)) { ANDROID_INFO(("%s: Update %d with BSSID %pM, RSSI=%d, SSID \"%s\"\n", __FUNCTION__, k, &bi->BSSID, dtoh16(bi->RSSI), bi->SSID)); for(j=0; j<RSSIAVG_LEN-1; j++) node->RSSI[j] = node->RSSI[j+1]; node->RSSI[j] = dtoh16(bi->RSSI); node->dirty = 0; break; } prev = node; node = node->next; k++; } if (node) continue; leaf = kmalloc(sizeof(wl_rssi_cache_t), GFP_KERNEL); if (!leaf) { ANDROID_ERROR(("%s: Memory alloc failure %d\n", __FUNCTION__, sizeof(wl_rssi_cache_t))); return; } ANDROID_INFO(("%s: Add %d with cached BSSID %pM, RSSI=%d, SSID \"%s\" in the leaf\n", __FUNCTION__, k, &bi->BSSID, dtoh16(bi->RSSI), bi->SSID)); leaf->next = NULL; leaf->dirty = 0; memcpy(&leaf->BSSID, &bi->BSSID, ETHER_ADDR_LEN); for (j=0; j<RSSIAVG_LEN; j++) leaf->RSSI[j] = dtoh16(bi->RSSI); if (!prev) *rssi_head = leaf; else prev->next = leaf; } }
int wlmIsAdapterUp(int *up) { /* Get 'isup' - check if adapter is up */ up = dtoh32(up); if (wlu_get(irh, WLC_GET_UP, up, sizeof(int))) { printf("wlmIsAdapterUp: %s\n", wlmLastError()); return FALSE; } return TRUE; }
int vmware3_image_t::read_ints(int fd, Bit32u *buffer, size_t count) { size_t i; Bit32u *p; int res=::read(fd, (void*)buffer, count * 4); for (p = buffer, i=0; i<count; p++, i++) *p=dtoh32(*p); return res; }
int wl_p2p_dev(void *wl, int *bsscfgIndex) { int *ptr; int err; err = wlu_var_getbuf(wl, "p2p_dev", NULL, 0, (void*)&ptr); if (err >= 0) *bsscfgIndex = dtoh32(*ptr); return err; }
int wl_p2p_if(void *wl, struct ether_addr *ea, int *bsscfgIndex) { wl_p2p_ifq_t *ptr; int err; err = wlu_var_getbuf(wl, "p2p_if", ea, sizeof(*ea), (void*)&ptr); if (err >= 0) *bsscfgIndex = dtoh32(ptr->bsscfgidx); return err; }
/* * get named iovar as an integer value * iovar name is converted to lower case */ int wlu_iovar_getint(void *wl, const char *iovar, int *pval) { int ret; ret = wlu_iovar_get(wl, iovar, pval, sizeof(int)); if (ret >= 0) { *pval = dtoh32(*pval); } return ret; }
int wlmRssiGet(int *rssi) { wl_pkteng_stats_t *cnt; if (wlu_var_getbuf(irh, "pkteng_stats", NULL, 0, (void **)&cnt)) { printf("wlmRssiGet: %s\n", wlmLastError()); return FALSE; } *rssi = dtoh32(cnt->rssi); return TRUE; }
int wlmRxGetReceivedPackets(unsigned int *count) { wl_cnt_t *cnt; if (wlu_var_getbuf(irh, "counters", NULL, 0, (void **)&cnt)) { printf("wlmRxGetReceivedPackets: %s\n", wlmLastError()); return FALSE; } *count = dtoh32(cnt->pktengrxducast); return TRUE; }
int wldev_get_ssid( struct net_device *dev, wlc_ssid_t *pssid) { int error; if (!pssid) return -ENOMEM; error = wldev_ioctl(dev, WLC_GET_SSID, pssid, sizeof(wlc_ssid_t), 0); if (unlikely(error)) return error; pssid->SSID_len = dtoh32(pssid->SSID_len); return error; }
int wldev_get_datarate(struct net_device *dev, int *datarate) { int error = 0; error = wldev_ioctl(dev, WLC_GET_RATE, datarate, sizeof(int), false); if (error) { return -1; } else { *datarate = dtoh32(*datarate); } return error; }
static void printheader(FILE *f, const struct kerneldumpheader *h, const char *device, int bounds, const int status) { uint64_t dumplen; time_t t; const char *stat_str; fprintf(f, "Dump header from device %s\n", device); fprintf(f, " Architecture: %s\n", h->architecture); fprintf(f, " Architecture Version: %u\n", dtoh32(h->architectureversion)); dumplen = dtoh64(h->dumplength); fprintf(f, " Dump Length: %lldB (%lld MB)\n", (long long)dumplen, (long long)(dumplen >> 20)); fprintf(f, " Blocksize: %d\n", dtoh32(h->blocksize)); t = dtoh64(h->dumptime); fprintf(f, " Dumptime: %s", ctime(&t)); fprintf(f, " Hostname: %s\n", h->hostname); fprintf(f, " Magic: %s\n", h->magic); fprintf(f, " Version String: %s", h->versionstring); fprintf(f, " Panic String: %s\n", h->panicstring); fprintf(f, " Dump Parity: %u\n", h->parity); fprintf(f, " Bounds: %d\n", bounds); switch(status) { case STATUS_BAD: stat_str = "bad"; break; case STATUS_GOOD: stat_str = "good"; break; default: stat_str = "unknown"; } fprintf(f, " Dump Status: %s\n", stat_str); fflush(f); }
int32_t vp_wlc_get_instant_power(uint32_t *power) { int val; uint8_t buffer[WLC_IOCTL_MAXLEN]; uint32 *int_ptr; bool override = TRUE; strcpy((char*)&buffer[0], "qtxpower"); if( vp_wlc_get(WLC_GET_VAR, &buffer[0], strlen((char *)&buffer[0]) + 5) < 0) return -1; int_ptr = (uint32 *)&buffer[0]; val = dtoh32(*int_ptr); override = (bool)(val & WL_TXPWR_OVERRIDE);
static uint16_t ptp_ptpip_generic_read (PTPParams *params, int fd, PTPIPHeader *hdr, unsigned char**data) { int ret, len, curread; unsigned char *xhdr; xhdr = (unsigned char*)hdr; curread = 0; len = sizeof (PTPIPHeader); while (curread < len) { ret = read (fd, xhdr + curread, len - curread); if (ret == -1) { perror ("read PTPIPHeader"); return PTP_RC_GeneralError; } gp_log_data ( "ptpip/generic_read", (char*)xhdr+curread, ret); curread += ret; if (ret == 0) { gp_log (GP_LOG_ERROR, "ptpip", "End of stream after reading %d bytes of ptpipheader", ret); return PTP_RC_GeneralError; } } len = dtoh32 (hdr->length) - sizeof (PTPIPHeader); if (len < 0) { gp_log (GP_LOG_ERROR, "ptpip/generic_read", "len < 0, %d?", len); return PTP_RC_GeneralError; } *data = malloc (len); if (!*data) { gp_log (GP_LOG_ERROR, "ptpip/generic_read", "malloc failed."); return PTP_RC_GeneralError; } curread = 0; while (curread < len) { ret = read (fd, (*data)+curread, len-curread); if (ret == -1) { gp_log (GP_LOG_ERROR, "ptpip/generic_read", "error %d in reading PTPIP data", errno); free (*data);*data = NULL; return PTP_RC_GeneralError; } else { gp_log_data ( "ptpip/generic_read", (char*)((*data)+curread), ret); } if (ret == 0) break; curread += ret; } if (curread != len) { gp_log (GP_LOG_ERROR, "ptpip/generic_read", "read PTPIP data, ret %d vs len %d", ret, len); free (*data);*data = NULL; return PTP_RC_GeneralError; } return PTP_RC_OK; }
int wl_iw_get_wireless_stats(dhd_pub_t *pub, struct iw_statistics *wstats) { int res = 0; wl_cnt_t cnt; int phy_noise; scb_val_t scb_val; if (pub == NULL) { pub = G_dhd; } #if 0 phy_noise = 0; res = dhd_wl_ioctl_cmd(pub, WLC_GET_PHY_NOISE, &phy_noise, sizeof(phy_noise), 0); if (res) goto done; phy_noise = dtoh32(phy_noise); printf("wl_iw_get_wireless_stats phy noise=%d\n", phy_noise); #endif bzero(&scb_val, sizeof(scb_val_t)); res = dhd_wl_ioctl_cmd(pub, WLC_GET_RSSI, &scb_val, sizeof(scb_val_t), 0); if (res) goto done; WiFiCurAPRssi = -dtoh32(scb_val.val); printf("WiFiCurAPRssi = %d\n", WiFiCurAPRssi); //printf("wl_iw_get_wireless_stats phy rssi=%d %02x:%02x:%02x:%02x:%02x:%02x\n", WiFiCurAPRssi, // scb_val.ea.octet[0], scb_val.ea.octet[1], scb_val.ea.octet[2], scb_val.ea.octet[3], // scb_val.ea.octet[4], scb_val.ea.octet[5]); done: return res; }
static void printheader(xo_handle_t *xo, const struct kerneldumpheader *h, const char *device, int bounds, const int status) { uint64_t dumplen; time_t t; const char *stat_str; xo_flush_h(xo); xo_emit_h(xo, "{Lwc:Dump header from device}{:dump_device/%s}\n", device); xo_emit_h(xo, "{P: }{Lwc:Architecture}{:architecture/%s}\n", h->architecture); xo_emit_h(xo, "{P: }{Lwc:Architecture Version}{:architecture_version/%u}\n", dtoh32(h->architectureversion)); dumplen = dtoh64(h->dumplength); xo_emit_h(xo, "{P: }{Lwc:Dump Length}{:dump_length_bytes/%lld}\n", (long long)dumplen); xo_emit_h(xo, "{P: }{Lwc:Blocksize}{:blocksize/%d}\n", dtoh32(h->blocksize)); t = dtoh64(h->dumptime); xo_emit_h(xo, "{P: }{Lwc:Dumptime}{:dumptime/%s}", ctime(&t)); xo_emit_h(xo, "{P: }{Lwc:Hostname}{:hostname/%s}\n", h->hostname); xo_emit_h(xo, "{P: }{Lwc:Magic}{:magic/%s}\n", h->magic); xo_emit_h(xo, "{P: }{Lwc:Version String}{:version_string/%s}", h->versionstring); xo_emit_h(xo, "{P: }{Lwc:Panic String}{:panic_string/%s}\n", h->panicstring); xo_emit_h(xo, "{P: }{Lwc:Dump Parity}{:dump_parity/%u}\n", h->parity); xo_emit_h(xo, "{P: }{Lwc:Bounds}{:bounds/%d}\n", bounds); switch(status) { case STATUS_BAD: stat_str = "bad"; break; case STATUS_GOOD: stat_str = "good"; break; default: stat_str = "unknown"; } xo_emit_h(xo, "{P: }{Lwc:Dump Status}{:dump_status/%s}\n", stat_str); xo_flush_h(xo); }
int wlmGetBandList(WLM_BAND * bands) { unsigned int list[3]; unsigned int i; if (wlu_get(irh, WLC_GET_BANDLIST, list, sizeof(list))) { printf("wlmGetBandList: %s\n", wlmLastError()); return FALSE; } list[0] = dtoh32(list[0]); list[1] = dtoh32(list[1]); list[2] = dtoh32(list[2]); /* list[0] is count, followed by 'count' bands */ if (list[0] > 2) list[0] = 2; for (i = 1, *bands = (WLM_BAND)0; i <= list[0]; i++) *bands |= list[i]; return TRUE; }
int wl_status(void *wl, int *isAssociated, int biBufferSize, wl_bss_info_t *biBuffer) { int ret; struct ether_addr bssid; wl_bss_info_t *bi; *isAssociated = FALSE; if ((ret = wlu_get(wl, WLC_GET_BSSID, &bssid, ETHER_ADDR_LEN)) == 0) { /* The adapter is associated. */ *(uint32*)buf = htod32(WLC_IOCTL_MAXLEN); if ((ret = wlu_get(wl, WLC_GET_BSS_INFO, buf, WLC_IOCTL_MAXLEN)) < 0) return ret; bi = (wl_bss_info_t*)(buf + 4); if (dtoh32(bi->version) == WL_BSS_INFO_VERSION || dtoh32(bi->version) == LEGACY2_WL_BSS_INFO_VERSION || dtoh32(bi->version) == LEGACY_WL_BSS_INFO_VERSION) { *isAssociated = TRUE; if (bi->length <= (uint32)biBufferSize) { memcpy(biBuffer, bi, bi->length); } else { fprintf(stderr, "buffer too small %d > %d\n", bi->length, biBufferSize); } } else fprintf(stderr, "Sorry, your driver has bss_info_version %d " "but this program supports only version %d.\n", bi->version, WL_BSS_INFO_VERSION); } return 0; }
/* * print scan cache * print partial iscan_skip list differently */ int dhd_iscan_print_cache(iscan_buf_t *iscan_skip) { int i = 0, l = 0; iscan_buf_t *iscan_cur; wl_iscan_results_t *list; wl_scan_results_t *results; wl_bss_info_t UNALIGNED *bi; dhd_iscan_lock(); iscan_cur = dhd_iscan_result_buf(); while (iscan_cur) { list = (wl_iscan_results_t *)iscan_cur->iscan_buf; if (!list) break; results = (wl_scan_results_t *)&list->results; if (!results) break; if (results->version != WL_BSS_INFO_VERSION) { DHD_ERROR(("%s: results->version %d != WL_BSS_INFO_VERSION\n", __FUNCTION__, results->version)); goto done; } bi = results->bss_info; for (i = 0; i < results->count; i++) { if (!bi) break; DHD_ERROR(("%s[%2.2d:%2.2d] %X:%X:%X:%X:%X:%X\n", iscan_cur != iscan_skip?"BSS":"bss", l, i, bi->BSSID.octet[0], bi->BSSID.octet[1], bi->BSSID.octet[2], bi->BSSID.octet[3], bi->BSSID.octet[4], bi->BSSID.octet[5])); bi = (wl_bss_info_t *)((uintptr)bi + dtoh32(bi->length)); } iscan_cur = iscan_cur->next; l++; } done: dhd_iscan_unlock(); return 0; }
s32 wldev_iovar_getint_bsscfg( struct net_device *dev, s8 *iovar, s32 *pval, s32 bssidx) { s8 iovar_buf[WLC_IOCTL_SMLEN]; s32 err; memset(iovar_buf, 0, sizeof(iovar_buf)); err = wldev_iovar_getbuf_bsscfg(dev, iovar, pval, sizeof(*pval), iovar_buf, sizeof(iovar_buf), bssidx, NULL); if (err == 0) { memcpy(pval, iovar_buf, sizeof(*pval)); *pval = dtoh32(*pval); } return err; }