static int dev_wlc_bufvar_set(struct net_device *dev, char *name, char *buf, int len) { #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31) char ioctlbuf_local[1024]; #else static char ioctlbuf_local[1024]; #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31) */ bcm_mkiovar(name, buf, len, ioctlbuf_local, sizeof(ioctlbuf_local)); return (wldev_ioctl(dev, WLC_SET_VAR, ioctlbuf_local, sizeof(ioctlbuf_local), true)); }
int wldev_set_band( struct net_device *dev, uint band) { int error = -1; if ((band == WLC_BAND_AUTO) || (band == WLC_BAND_5G) || (band == WLC_BAND_2G)) { error = wldev_ioctl(dev, WLC_SET_BAND, &band, sizeof(band), 1); } wl_cfg80211_abort_connecting(); return error; }
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; }
int wldev_get_rssi( struct net_device *dev, scb_val_t *scb_val) { int error; if (!scb_val) return -ENOMEM; error = wldev_ioctl(dev, WLC_GET_RSSI, scb_val, sizeof(scb_val_t), 0); if (unlikely(error)) return error; return error; }
static int wl_android_ch_res_rl(struct net_device *dev, bool change) { int error = 0; s32 srl = 7; s32 lrl = 4; printk("%s enter\n", __FUNCTION__); if (change) { srl = 4; lrl = 2; } error = wldev_ioctl(dev, WLC_SET_SRL, &srl, sizeof(s32), true); if (error) { DHD_ERROR(("Failed to set SRL, error = %d\n", error)); } error = wldev_ioctl(dev, WLC_SET_LRL, &lrl, sizeof(s32), true); if (error) { DHD_ERROR(("Failed to set LRL, error = %d\n", error)); } return error; }
s32 wldev_iovar_getbuf( struct net_device *dev, s8 *iovar_name, void *param, s32 paramlen, void *buf, s32 buflen, struct mutex* buf_sync) { s32 ret = 0; if (buf_sync) { mutex_lock(buf_sync); } wldev_mkiovar(iovar_name, param, paramlen, buf, buflen); ret = wldev_ioctl(dev, WLC_GET_VAR, buf, buflen, FALSE); if (buf_sync) mutex_unlock(buf_sync); return ret; }
int wldev_set_country( struct net_device *dev, char *country_code, bool notify, bool user_enforced, int revinfo) { int error = -1; wl_country_t cspec = {{0}, 0, {0}}; scb_val_t scbval; char smbuf[WLC_IOCTL_SMLEN]; if (!country_code) return error; bzero(&scbval, sizeof(scb_val_t)); error = wldev_iovar_getbuf(dev, "country", NULL, 0, &cspec, sizeof(cspec), NULL); if (error < 0) { WLDEV_ERROR(("%s: get country failed = %d\n", __FUNCTION__, error)); return error; } if ((error < 0) || dhd_force_country_change(dev) || (strncmp(country_code, cspec.ccode, WLC_CNTRY_BUF_SZ) != 0)) { if (user_enforced) { bzero(&scbval, sizeof(scb_val_t)); error = wldev_ioctl(dev, WLC_DISASSOC, &scbval, sizeof(scb_val_t), true); if (error < 0) { WLDEV_ERROR(("%s: set country failed due to Disassoc error %d\n", __FUNCTION__, error)); return error; } } cspec.rev = revinfo; memcpy(cspec.country_abbrev, country_code, WLC_CNTRY_BUF_SZ); memcpy(cspec.ccode, country_code, WLC_CNTRY_BUF_SZ); dhd_get_customized_country_code(dev, (char *)&cspec.country_abbrev, &cspec); error = wldev_iovar_setbuf(dev, "country", &cspec, sizeof(cspec), smbuf, sizeof(smbuf), NULL); if (error < 0) { WLDEV_ERROR(("%s: set country for %s as %s rev %d failed\n", __FUNCTION__, country_code, cspec.ccode, cspec.rev)); return error; } dhd_bus_country_set(dev, &cspec, notify); WLDEV_ERROR(("%s: set country for %s as %s rev %d\n", __FUNCTION__, country_code, cspec.ccode, cspec.rev)); } return 0; }
static int wl_android_get_roam_scan_period( struct net_device *dev, char *command, int total_len) { int bytes_written; int roam_scan_period = 0; if (wldev_ioctl(dev, WLC_GET_ROAM_SCAN_PERIOD, &roam_scan_period, sizeof(roam_scan_period), 0)) return -1; bytes_written = snprintf(command, total_len, "%s %d", CMD_ROAMSCANPERIOD_GET, roam_scan_period); return bytes_written; }
int wldev_set_band( struct net_device *dev, uint band) { int error = -1; if ((band == WLC_BAND_AUTO) || (band == WLC_BAND_5G) || (band == WLC_BAND_2G)) { error = wldev_ioctl(dev, WLC_SET_BAND, &band, sizeof(band), true); if (!error) dhd_bus_band_set(dev, band); } #ifdef CUSTOMER_HW_ONE wl_cfg80211_abort_connecting(); #endif return error; }
int wldev_get_link_speed( struct net_device *dev, int *plink_speed) { int error; if (!plink_speed) return -ENOMEM; error = wldev_ioctl(dev, WLC_GET_RATE, plink_speed, sizeof(int), 0); if (unlikely(error)) return error; /* Convert internal 500Kbps to Kbps */ *plink_speed *= 500; return error; }
int wldev_get_mode( struct net_device *dev, uint8 *cap) { int error = 0; int chanspec = 0; uint16 band = 0; uint16 bandwidth = 0; wl_bss_info_t *bss = NULL; char* buf = kmalloc(WL_EXTRA_BUF_MAX, GFP_KERNEL); if (!buf) return -1; *(u32*) buf = htod32(WL_EXTRA_BUF_MAX); error = wldev_ioctl(dev, WLC_GET_BSS_INFO, (void*)buf, WL_EXTRA_BUF_MAX, false); if (error) { WLDEV_ERROR(("%s:failed:%d\n", __FUNCTION__, error)); return -1; } bss = (struct wl_bss_info *)(buf + 4); chanspec = wl_chspec_driver_to_host(bss->chanspec); band = chanspec & WL_CHANSPEC_BAND_MASK; bandwidth = chanspec & WL_CHANSPEC_BW_MASK; if (band == WL_CHANSPEC_BAND_2G) { if (bss->n_cap) strcpy(cap, "n"); else strcpy(cap, "bg"); } else if (band == WL_CHANSPEC_BAND_5G) { if (bandwidth == WL_CHANSPEC_BW_80) strcpy(cap, "ac"); else if ((bandwidth == WL_CHANSPEC_BW_40) || (bandwidth == WL_CHANSPEC_BW_20)) { if ((bss->nbss_cap & 0xf00) && (bss->n_cap)) strcpy(cap, "n|ac"); else if (bss->n_cap) strcpy(cap, "n"); else if (bss->vht_cap) strcpy(cap, "ac"); else strcpy(cap, "a"); } else { WLDEV_ERROR(("%s:Mode get failed\n", __FUNCTION__)); return -1; } } return error; }
static int wl_android_set_ssid(struct net_device *dev, const char* hapd_ssid) { wlc_ssid_t ssid; s32 ret; ssid.SSID_len = strlen(hapd_ssid); bcm_strncpy_s(ssid.SSID, sizeof(ssid.SSID), hapd_ssid, ssid.SSID_len); DHD_INFO(("%s: HAPD_SSID = %s\n", __FUNCTION__, ssid.SSID)); ret = wldev_ioctl(dev, WLC_SET_SSID, &ssid, sizeof(wlc_ssid_t), true); if (ret < 0) { DHD_ERROR(("%s : WLC_SET_SSID Error:%d\n", __FUNCTION__, ret)); } return 1; }
s32 wldev_iovar_setbuf_bsscfg( struct net_device *dev, s8 *iovar_name, void *param, s32 paramlen, void *buf, s32 buflen, s32 bsscfg_idx, struct mutex* buf_sync) { s32 ret = 0; s32 iovar_len; if (buf_sync) { mutex_lock(buf_sync); } iovar_len = wldev_mkiovar_bsscfg(iovar_name, param, paramlen, buf, buflen, bsscfg_idx); ret = wldev_ioctl(dev, WLC_SET_VAR, buf, iovar_len, TRUE); if (buf_sync) { mutex_unlock(buf_sync); } return ret; }
/* * get named driver variable to uint register value and return error indication * calling example: dev_wlc_intvar_get_reg(dev, "btc_params",66, ®_value) */ static int dev_wlc_intvar_get_reg(struct net_device *dev, char *name, uint reg, int *retval) { union { char buf[WLC_IOCTL_SMLEN]; int val; } var; int error; bcm_mkiovar(name, (char *)(®), sizeof(reg), (char *)(&var), sizeof(var.buf)); error = wldev_ioctl(dev, WLC_GET_VAR, (char *)(&var), sizeof(var.buf), false); *retval = dtoh32(var.val); return (error); }
int wldev_get_rssi( struct net_device *dev, int *prssi) { scb_val_t scb_val; int error; if (!prssi) return -ENOMEM; bzero(&scb_val, sizeof(scb_val_t)); error = wldev_ioctl(dev, WLC_GET_RSSI, &scb_val, sizeof(scb_val_t), 0); if (unlikely(error)) return error; *prssi = dtoh32(scb_val.val); return error; }
s32 wldev_iovar_setbuf( struct net_device *dev, s8 *iovar_name, void *param, s32 paramlen, void *buf, s32 buflen, struct mutex* buf_sync) { s32 ret = 0; s32 iovar_len; if (buf_sync) { mutex_lock(buf_sync); } iovar_len = wldev_mkiovar(iovar_name, param, paramlen, buf, buflen); if (iovar_len > 0) ret = wldev_ioctl(dev, WLC_SET_VAR, buf, iovar_len, TRUE); else ret = BCME_BUFTOOSHORT; if (buf_sync) mutex_unlock(buf_sync); return ret; }
static void wl_android_iolist_resume(struct net_device *dev, struct list_head *head) { struct io_cfg *config; struct list_head *cur, *q; list_for_each_safe(cur, q, head) { config = list_entry(cur, struct io_cfg, list); if (config->iovar) { wldev_iovar_setint(dev, config->iovar, config->param); } else { wldev_ioctl(dev, config->ioctl + 1, config->arg, config->len, true); if (config->ioctl + 1 == WLC_SET_PM) wl_cfg80211_update_power_mode(dev); kfree(config->arg); } list_del(cur); kfree(config); }
int wldev_get_conap_ctrl_channel(struct net_device *dev,uint8 *ctrl_channel) { struct wl_bss_info *bss = NULL; int err; *(u32 *) wlcfg_drv_priv->extra_buf = htod32(WL_EXTRA_BUF_MAX); if ((err = wldev_ioctl(ap_net_dev, WLC_GET_BSS_INFO, wlcfg_drv_priv->extra_buf, WL_EXTRA_BUF_MAX, false))) { printf("Failed to get hostapd bss info, use temp channel \n"); return -1; } else { bss = (struct wl_bss_info *) (wlcfg_drv_priv->extra_buf + 4); *ctrl_channel = bss->ctl_ch; printf(" %s Valid BSS Found. ctrl_channel:%d \n",__func__ ,*ctrl_channel); return 0; } }
int wldev_set_country( struct net_device *dev, char *country_code) { int error = -1; wl_country_t cspec = {{0}, 0, {0}}; scb_val_t scbval; char smbuf[WLC_IOCTL_SMLEN]; if (!country_code) return error; error = wldev_iovar_getbuf(dev, "country", &cspec, sizeof(cspec), smbuf, sizeof(smbuf), NULL); if (error < 0) AP6210_ERR("%s: get country failed = %d\n", __FUNCTION__, error); if ((error < 0) || (strncmp(country_code, smbuf, WLC_CNTRY_BUF_SZ) != 0)) { bzero(&scbval, sizeof(scb_val_t)); error = wldev_ioctl(dev, WLC_DISASSOC, &scbval, sizeof(scb_val_t), true); if (error < 0) { AP6210_ERR("%s: set country failed due to Disassoc error %d\n", __FUNCTION__, error); return error; } cspec.rev = -1; memcpy(cspec.country_abbrev, country_code, WLC_CNTRY_BUF_SZ); memcpy(cspec.ccode, country_code, WLC_CNTRY_BUF_SZ); get_customized_country_code((char *)&cspec.country_abbrev, &cspec); error = wldev_iovar_setbuf(dev, "country", &cspec, sizeof(cspec), smbuf, sizeof(smbuf), NULL); if (error < 0) { AP6210_ERR("%s: set country for %s as %s rev %d failed\n", __FUNCTION__, country_code, cspec.ccode, cspec.rev); return error; } dhd_bus_country_set(dev, &cspec); AP6210_ERR("%s: set country for %s as %s rev %d\n", __FUNCTION__, country_code, cspec.ccode, cspec.rev); } return 0; }
static int wl_android_sta_diassoc(struct net_device *dev, const char* straddr) { scb_val_t scbval; DHD_INFO(("%s: deauth STA %s\n", __FUNCTION__, straddr)); /* Unspecified reason */ scbval.val = htod32(1); bcm_ether_atoe(straddr, &scbval.ea); DHD_INFO(("%s: deauth STA: %02X:%02X:%02X:%02X:%02X:%02X\n", __FUNCTION__, scbval.ea.octet[0], scbval.ea.octet[1], scbval.ea.octet[2], scbval.ea.octet[3], scbval.ea.octet[4], scbval.ea.octet[5])); wldev_ioctl(dev, WLC_SCB_DEAUTHENTICATE_FOR_REASON, &scbval, sizeof(scb_val_t), true); return 1; }
int wldev_start_stop_scansuppress(struct net_device *dev) { int res = 0; int enable = 1; if (!dev) { WLDEV_ERROR(("%s: dev is null\n", __FUNCTION__)); return (res = -1);; } if(scan_suppress_flag){ if ((res = wldev_ioctl(dev, WLC_SET_SCANSUPPRESS, &enable, sizeof(enable), 1))) { WLDEV_ERROR(("%s fail to SET_SCANSUPPRESS enable\n", __FUNCTION__)); return (res = -1); } printf("Successful Enable scan suppress!!\n"); return 0; } return 0; }
int wldev_get_rssi( struct net_device *dev, int *prssi) { scb_val_t scb_val; int error; if (!prssi) return -ENOMEM; bzero(&scb_val, sizeof(scb_val_t)); error = wldev_ioctl(dev, WLC_GET_RSSI, &scb_val, sizeof(scb_val_t), 0); if (unlikely(error)) return error; *prssi = dtoh32(scb_val.val); /* when the return value is zero. skip overrinding code */ if (*prssi > WL_IW_RSSI_INVALID) *prssi = WL_IW_RSSI_MAXVAL; return error; }
s32 wldev_set_ssid(struct net_device *dev,int *channel) { wlc_ssid_t ap_ssid; bss_setbuf_t bss_setbuf; char smbuf[WLC_IOCTL_SMLEN]; int res = 0; printf(" %s ap_cfg.ssid[%s]\n",__FUNCTION__, ap_cfg.ssid); ap_ssid.SSID_len = strlen(ap_cfg.ssid); strncpy(ap_ssid.SSID, ap_cfg.ssid, ap_ssid.SSID_len); bss_setbuf.cfg = 1; bss_setbuf.val = 0; /* down the interface */ if ((res = wldev_iovar_setbuf_bsscfg(dev, "bss", &bss_setbuf, sizeof(bss_setbuf), smbuf, sizeof(smbuf), 1, NULL)) < 0){ printf("%s: ERROR:%d, set bss down failed\n", __FUNCTION__, res); } bcm_mdelay(50); res = wldev_ioctl(ap_net_dev, WLC_SET_CHANNEL, channel, sizeof(*channel), 1); if (res < 0) { printf("%s set channel fial res[%d]",__FUNCTION__,res); } bss_setbuf.cfg = 1; bss_setbuf.val = 1; /* up the interface */ bcm_mdelay(50); if ((res = wldev_iovar_setbuf_bsscfg(dev, "bss", &bss_setbuf, sizeof(bss_setbuf), smbuf, sizeof(smbuf), 1, NULL)) < 0){ printf("%s: ERROR:%d, set bss up failed\n", __FUNCTION__, res); } printf("%s: up Conap part of apsta concurrent\n", __FUNCTION__); return res; }
static int dev_wlc_bufvar_get( struct net_device *dev, char *name, char *buf, int buflen) { #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31) char ioctlbuf_local[1024]; #else static char ioctlbuf_local[1024]; #endif int error; uint len; len = bcm_mkiovar(name, buf, buflen, ioctlbuf_local, sizeof(ioctlbuf_local)); ASSERT(len); error = wldev_ioctl(dev, WLC_GET_VAR, (void *)ioctlbuf_local, sizeof(ioctlbuf_local), false); if (!error) bcopy(ioctlbuf_local, buf, buflen); return (error); }
int wldev_set_apsta(struct net_device *dev, bool enable) { int res = 0; int mpc = 0; int concr_mode = 0; int roam_off; char smbuf[WLC_IOCTL_SMLEN]; bss_setbuf_t bss_setbuf; int frameburst; memset(smbuf, 0, sizeof(smbuf)); printf("%s: enter\n", __FUNCTION__); if (!dev) { WLDEV_ERROR(("%s: dev is null\n", __FUNCTION__)); return -1; } if (enable){ /* wait for interface ready */ wait_for_ap_ready(1); if ( ap_net_dev == NULL ) { WLDEV_ERROR(("%s ap_net_dev == NULL\n", __FUNCTION__)); goto fail; } concr_mode = 1; if ((res = wldev_iovar_setint(dev, "concr_mode_set", concr_mode))) { printf("%s fail to set concr_mode res[%d]\n", __FUNCTION__,res); } rxglom_fail_count = RXGLOM_CONCUR_MODE_FAIL_COUNT; max_cntl_timeout = MAX_CONCUR_MODE_CNTL_TIMEOUT; roam_off = 1; if((res = wldev_iovar_setint(dev, "roam_off", roam_off))) printf("%s fail to set roam_off res[%d]\n", __FUNCTION__,res); mpc = 0; if ((res = wldev_iovar_setint(dev, "mpc", mpc))) { WLDEV_ERROR(("%s fail to set mpc\n", __FUNCTION__)); goto fail; } if ((res = wl_iw_set_ap_security(ap_net_dev, &ap_cfg)) != 0) { WLDEV_ERROR((" %s ERROR setting SOFTAP security in :%d\n", __FUNCTION__, res)); goto fail; } if(wl_get_drv_status(wlcfg_drv_priv,CONNECTED,dev)) { u32 chanspec = 0; int err; if(wldev_iovar_getint(dev, "chanspec", (s32 *)&chanspec) == BCME_OK) { printf("%s get Chanspec [%0x]\n",__func__ ,chanspec); if((err = wldev_iovar_setint(ap_net_dev, "chanspec", chanspec)) == BCME_BADCHAN) { printf("%s set Chanspec failed\n",__func__); } else printf("%s set Chanspec OK\n",__func__); } else printf("%s get Chanspec failed\n",__func__); } else printf("%s Sta is not connected with any AP\n",__func__); bss_setbuf.cfg = 1; bss_setbuf.val = 1; /* up the interface */ if ((res = wldev_iovar_setbuf_bsscfg(dev, "bss", &bss_setbuf, sizeof(bss_setbuf), smbuf, sizeof(smbuf), 1, NULL)) < 0){ WLDEV_ERROR(("%s: ERROR:%d, set bss up failed\n", __FUNCTION__, res)); goto fail; } bcm_mdelay(500); printf("prepare set frameburst \n"); frameburst = 1; if ((res = wldev_ioctl(dev, WLC_SET_FAKEFRAG, &frameburst, sizeof(frameburst), 0))) { printf("%s fail to set frameburst !!\n", __FUNCTION__); } if ((res = wldev_iovar_setint(dev, "allmulti", 1))) { WLDEV_ERROR(("%s: ERROR:%d, set allmulti failed\n", __FUNCTION__, res)); goto fail; } #if !defined(WLCREDALL) if ((res = wldev_iovar_setint(dev, "bus:credall", 1))) { WLDEV_ERROR(("%s: ERROR:%d, set credall failed\n", __FUNCTION__, res)); goto fail; } #endif set_ap_channel(dev,&ap_cfg); ap_net_dev->operstate = IF_OPER_UP; } else { if ((res = wl_softap_stop(ap_net_dev))){ WLDEV_ERROR(("%s: ERROR:%d, call wl_softap_stop failed\n", __FUNCTION__, res)); goto fail; } concr_mode = 0; if ((res = wldev_iovar_setint(dev, "concr_mode_set", concr_mode))) { printf("%s fail to set concr_mode res[%d]\n", __FUNCTION__,res); } rxglom_fail_count = RXGLOM_FAIL_COUNT; max_cntl_timeout = MAX_CNTL_TIMEOUT; scan_suppress_flag = 0; /* 2012-09-21 Stop roam when start Concurrent ++++ */ roam_off = 0; if((res = wldev_iovar_setint(dev, "roam_off", roam_off))) printf("%s fail to set roam_off res[%d]\n", __FUNCTION__,res); mpc = 1; if ((res = wldev_iovar_setint(dev, "mpc", mpc))) { WLDEV_ERROR(("%s fail to set mpc\n", __FUNCTION__)); goto fail; } #if !defined(WLCREDALL) if ((res = wldev_iovar_setint(dev, "bus:credall", 0))) { WLDEV_ERROR(("%s fail to set credall\n", __FUNCTION__)); goto fail; } #endif printf("prepare set frameburst \n"); frameburst = 0; if ((res = wldev_ioctl(dev, WLC_SET_FAKEFRAG, &frameburst, sizeof(frameburst), 0))) { printf("%s fail to set frameburst !!\n", __FUNCTION__); } wlcfg_drv_priv->dongle_connected = 0; wldev_adj_apsta_scan_param(dev,wlcfg_drv_priv->dongle_connected); } fail: return res; }
void wldev_adj_apsta_scan_param(struct net_device *dev,int enable) { int res; if(enable){ //adjust parameters int scan_home_time = APSTA_SCAN_HOME_TIME; int scan_assoc_time = APSTA_SCAN_ASSOC_TIME; int scan_passive_time = APSTA_SCAN_PASSIVE_TIME; int scan_nprobes = APSTA_SCAN_NPROBES; int srl = APSTA_SCAN_SRL; int lrl = APSTA_SCAN_LRL; /*set scan home time*/ if((res = wldev_ioctl(dev, WLC_SET_SCAN_HOME_TIME, (char *)&scan_home_time,sizeof(scan_home_time), 1))) WLDEV_ERROR(("%s fail to WLC_SET_SCAN_HOME_TIME\n", __FUNCTION__)); /*set scan assoc time*/ if((res = wldev_ioctl(dev, WLC_SET_SCAN_CHANNEL_TIME, (char *)&scan_assoc_time,sizeof(scan_assoc_time), 1))) WLDEV_ERROR(("%s fail to WLC_SET_SCAN_CHANNEL_TIME\n", __FUNCTION__)); /*set scan passive time*/ if((res = wldev_ioctl(dev, WLC_SET_SCAN_PASSIVE_TIME, (char *)&scan_passive_time,sizeof(scan_passive_time), 1))) WLDEV_ERROR(("%s fail WLC_SET_SCAN_PASSIVE_TIME\n", __FUNCTION__)); /*set scan nprobes*/ if((res = wldev_ioctl(dev, WLC_SET_SCAN_NPROBES, (char *)&scan_nprobes,sizeof(scan_nprobes), 1))) WLDEV_ERROR(("%s fail to WLC_SET_SCAN_NPROBES\n", __FUNCTION__)); /*set srl*/ if((res = wldev_ioctl(dev, WLC_SET_SRL, (char *)&srl,sizeof(srl), 1))) WLDEV_ERROR(("%s fail to WLC_SET_SRL\n", __FUNCTION__)); /*set lrl*/ if((res = wldev_ioctl(dev, WLC_SET_LRL, (char *)&lrl,sizeof(lrl), 1))) WLDEV_ERROR(("%s fail to WLC_SET_LRL\n", __FUNCTION__)); }else{ //revert to the original design int scan_home_time = SCAN_HOME_TIME; int scan_assoc_time = SCAN_ASSOC_TIME; int scan_passive_time = SCAN_PASSIVE_TIME; int scan_nprobes = SCAN_NPROBES; int srl = SCAN_SRL; int lrl = SCAN_LRL; /*set scan home time*/ if((res = wldev_ioctl(dev, WLC_SET_SCAN_HOME_TIME, (char *)&scan_home_time,sizeof(scan_home_time), 1))) { WLDEV_ERROR(("%s fail to WLC_SET_SCAN_HOME_TIME\n", __FUNCTION__)); } /*store scan assoc time*/ if((res = wldev_ioctl(dev, WLC_SET_SCAN_CHANNEL_TIME, (char *)&scan_assoc_time,sizeof(scan_assoc_time), 1))) { WLDEV_ERROR(("%s fail to WLC_SET_SCAN_CHANNEL_TIME\n", __FUNCTION__)); } /*store scan passive time*/ if((res = wldev_ioctl(dev, WLC_SET_SCAN_PASSIVE_TIME, (char *)&scan_passive_time,sizeof(scan_passive_time), 1))) { WLDEV_ERROR(("%s fail to WLC_SET_SCAN_PASSIVE_TIME\n", __FUNCTION__)); } /*store scan nprobes*/ if((res = wldev_ioctl(dev, WLC_SET_SCAN_NPROBES, (char *)&scan_nprobes,sizeof(scan_nprobes), 1))) { WLDEV_ERROR(("%s fail WLC_SET_SCAN_NPROBES\n", __FUNCTION__)); } /*store srl*/ if((res = wldev_ioctl(dev, WLC_SET_SRL, (char *)&srl,sizeof(srl), 1))) { WLDEV_ERROR(("%s fail to WLC_SET_SRL\n", __FUNCTION__)); } /*store srl*/ if((res = wldev_ioctl(dev, WLC_SET_LRL, (char *)&lrl,sizeof(lrl), 1))) { WLDEV_ERROR(("%s fail to WLC_SET_LRL\n", __FUNCTION__)); } } }
int wldev_set_country( struct net_device *dev, char *country_code, bool notify, bool user_enforced) { int error = -1; wl_country_t cspec = {{0}, 0, {0}}; scb_val_t scbval; char smbuf[WLC_IOCTL_SMLEN]; #ifdef CUSTOMER_HW_ONE uint32 chan_buf[WL_NUMCHANNELS]; wl_uint32_list_t *list; channel_info_t ci; int retry = 0; int chan = 1; #endif if (!country_code) return error; bzero(&scbval, sizeof(scb_val_t)); error = wldev_iovar_getbuf(dev, "country", NULL, 0, &cspec, sizeof(cspec), NULL); if (error < 0) { WLDEV_ERROR(("%s: get country failed = %d\n", __FUNCTION__, error)); return error; } if ((error < 0) || (strncmp(country_code, cspec.country_abbrev, WLC_CNTRY_BUF_SZ) != 0)) { if (user_enforced) { bzero(&scbval, sizeof(scb_val_t)); error = wldev_ioctl(dev, WLC_DISASSOC, &scbval, sizeof(scb_val_t), true); if (error < 0) { WLDEV_ERROR(("%s: set country failed due to Disassoc error %d\n", __FUNCTION__, error)); return error; } } #ifdef CUSTOMER_HW_ONE error = wldev_ioctl(dev, WLC_SET_CHANNEL, &chan, sizeof(chan), 1); if (error < 0) { WLDEV_ERROR(("%s: set country failed due to channel 1 error %d\n", __FUNCTION__, error)); return error; } } get_channel_retry: if ((error = wldev_ioctl(dev, WLC_GET_CHANNEL, &ci, sizeof(ci), 0))) { WLDEV_ERROR(("%s: get channel fail!\n", __FUNCTION__)); return error; } ci.scan_channel = dtoh32(ci.scan_channel); if (ci.scan_channel) { retry++; printf("%s: scan in progress, retry %d!\n", __FUNCTION__, retry); if (retry > 3) return -EBUSY; bcm_mdelay(1000); goto get_channel_retry; } #endif cspec.rev = -1; memcpy(cspec.country_abbrev, country_code, WLC_CNTRY_BUF_SZ); memcpy(cspec.ccode, country_code, WLC_CNTRY_BUF_SZ); get_customized_country_code((char *)&cspec.country_abbrev, &cspec); error = wldev_iovar_setbuf(dev, "country", &cspec, sizeof(cspec), smbuf, sizeof(smbuf), NULL); if (error < 0) { #ifdef CUSTOMER_HW_ONE if (strcmp(cspec.country_abbrev, DEF_COUNTRY_CODE) != 0) { strcpy(country_code, DEF_COUNTRY_CODE); retry = 0; goto get_channel_retry; } else { #endif WLDEV_ERROR(("%s: set country for %s as %s rev %d failed\n", __FUNCTION__, country_code, cspec.ccode, cspec.rev)); return error; } #ifdef CUSTOMER_HW_ONE } /* check if there are available channels */ else { if (strcmp(country_code, DEF_COUNTRY_CODE) != 0) { list = (wl_uint32_list_t *)(void *)chan_buf; list->count = htod32(WL_NUMCHANNELS); if ((error = wldev_ioctl_no_memset(dev, WLC_GET_VALID_CHANNELS, &chan_buf, sizeof(chan_buf), 0))) { WLDEV_ERROR(("%s: get channel list fail! %d\n", __FUNCTION__, error)); return error; } /* if NULL, set default country code instead and set country code again */ printf("%s: channel_count = %d\n", __FUNCTION__, list->count); if (list->count == 0) { strcpy(country_code, DEF_COUNTRY_CODE); retry = 0; goto get_channel_retry; } } #endif dhd_bus_country_set(dev, &cspec, notify); WLDEV_ERROR(("%s: set country for %s as %s rev %d\n", __FUNCTION__, country_code, cspec.ccode, cspec.rev)); } #ifdef CUSTOMER_HW_ONE wl_cfg80211_abort_connecting(); #endif return 0; }
static int wl_android_set_ap_mac_list(struct net_device *dev, int macmode, struct maclist *maclist) { int i, j, match; int ret = 0; char mac_buf[MAX_NUM_OF_ASSOCLIST * sizeof(struct ether_addr) + sizeof(uint)] = {0}; struct maclist *assoc_maclist = (struct maclist *)mac_buf; /* set filtering mode */ if ((ret = wldev_ioctl(dev, WLC_SET_MACMODE, &macmode, sizeof(macmode), true)) != 0) { DHD_ERROR(("%s : WLC_SET_MACMODE error=%d\n", __FUNCTION__, ret)); return ret; } if (macmode != MACLIST_MODE_DISABLED) { /* set the MAC filter list */ if ((ret = wldev_ioctl(dev, WLC_SET_MACLIST, maclist, sizeof(int) + sizeof(struct ether_addr) * maclist->count, true)) != 0) { DHD_ERROR(("%s : WLC_SET_MACLIST error=%d\n", __FUNCTION__, ret)); return ret; } /* get the current list of associated STAs */ assoc_maclist->count = MAX_NUM_OF_ASSOCLIST; if ((ret = wldev_ioctl(dev, WLC_GET_ASSOCLIST, assoc_maclist, sizeof(mac_buf), false)) != 0) { DHD_ERROR(("%s : WLC_GET_ASSOCLIST error=%d\n", __FUNCTION__, ret)); return ret; } /* do we have any STA associated? */ if (assoc_maclist->count) { /* iterate each associated STA */ for (i = 0; i < assoc_maclist->count; i++) { match = 0; /* compare with each entry */ for (j = 0; j < maclist->count; j++) { DHD_INFO(("%s : associated="MACDBG " list="MACDBG "\n", __FUNCTION__, MAC2STRDBG(assoc_maclist->ea[i].octet), MAC2STRDBG(maclist->ea[j].octet))); if (memcmp(assoc_maclist->ea[i].octet, maclist->ea[j].octet, ETHER_ADDR_LEN) == 0) { match = 1; break; } } /* do conditional deauth */ /* "if not in the allow list" or "if in the deny list" */ if ((macmode == MACLIST_MODE_ALLOW && !match) || (macmode == MACLIST_MODE_DENY && match)) { scb_val_t scbval; scbval.val = htod32(1); memcpy(&scbval.ea, &assoc_maclist->ea[i], ETHER_ADDR_LEN); if ((ret = wldev_ioctl(dev, WLC_SCB_DEAUTHENTICATE_FOR_REASON, &scbval, sizeof(scb_val_t), true)) != 0) DHD_ERROR(("%s WLC_SCB_DEAUTHENTICATE error=%d\n", __FUNCTION__, ret)); } } } } return ret; }
static s32 wl_dongle_filter(struct net_device *ndev, u32 filter_mode) { /* Room for "event_msgs" + '\0' + bitvec */ s8 iovbuf[WL_EVENTING_MASK_LEN + 12]; const s8 *str; struct wl_pkt_filter pkt_filter; struct wl_pkt_filter *pkt_filterp; s32 buf_len; s32 str_len; u32 mask_size; u32 pattern_size; s8 buf[256]; s32 err = 0; /* add a default packet filter pattern */ str = "pkt_filter_add"; str_len = strlen(str); strncpy(buf, str, str_len); buf[str_len] = '\0'; buf_len = str_len + 1; pkt_filterp = (struct wl_pkt_filter *)(buf + str_len + 1); /* Parse packet filter id. */ pkt_filter.id = htod32(100); /* Parse filter polarity. */ pkt_filter.negate_match = htod32(0); /* Parse filter type. */ pkt_filter.type = htod32(0); /* Parse pattern filter offset. */ pkt_filter.u.pattern.offset = htod32(0); /* Parse pattern filter mask. */ mask_size = htod32(wl_pattern_atoh("0xff", (char *)pkt_filterp->u.pattern. mask_and_pattern)); /* Parse pattern filter pattern. */ pattern_size = htod32(wl_pattern_atoh("0x00", (char *)&pkt_filterp->u.pattern.mask_and_pattern[mask_size])); if (mask_size != pattern_size) { WL_ERR(("Mask and pattern not the same size\n")); err = -EINVAL; goto dongle_filter_out; } pkt_filter.u.pattern.size_bytes = mask_size; buf_len += WL_PKT_FILTER_FIXED_LEN; buf_len += (WL_PKT_FILTER_PATTERN_FIXED_LEN + 2 * mask_size); /* Keep-alive attributes are set in local * variable (keep_alive_pkt), and * then memcpy'ed into buffer (keep_alive_pktp) since there is no * guarantee that the buffer is properly aligned. */ memcpy((char *)pkt_filterp, &pkt_filter, WL_PKT_FILTER_FIXED_LEN + WL_PKT_FILTER_PATTERN_FIXED_LEN); err = wldev_ioctl(ndev, WLC_SET_VAR, buf, buf_len, true); if (err) { if (err == -EOPNOTSUPP) { WL_INFO(("filter not supported\n")); } else { WL_ERR(("filter (%d)\n", err)); } goto dongle_filter_out; } /* set mode to allow pattern */ bcm_mkiovar("pkt_filter_mode", (char *)&filter_mode, 4, iovbuf, sizeof(iovbuf)); err = wldev_ioctl(ndev, WLC_SET_VAR, iovbuf, sizeof(iovbuf), true); if (err) { if (err == -EOPNOTSUPP) { WL_INFO(("filter_mode not supported\n")); } else { WL_ERR(("filter_mode (%d)\n", err)); } goto dongle_filter_out; } dongle_filter_out: return err; }