/** * @brief Get station info * * @param wiphy A pointer to wiphy structure * @param dev A pointer to net_device structure * @param mac A pointer to station mac address * @param stainfo A pointer to station_info structure * * @return 0 -- success, otherwise fail */ int woal_uap_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, u8 * mac, struct station_info *stainfo) { moal_private *priv = (moal_private *) woal_get_netdev_priv(dev); int ret = -EFAULT; int i = 0; mlan_ds_get_info *info = NULL; mlan_ioctl_req *ioctl_req = NULL; ENTER(); if (priv->media_connected == MFALSE) { PRINTM(MINFO, "cfg80211: Media not connected!\n"); LEAVE(); return -ENOENT; } /* Allocate an IOCTL request buffer */ ioctl_req = (mlan_ioctl_req *) woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_get_info)); if (ioctl_req == NULL) { ret = -ENOMEM; goto done; } info = (mlan_ds_get_info *) ioctl_req->pbuf; info->sub_command = MLAN_OID_UAP_STA_LIST; ioctl_req->req_id = MLAN_IOCTL_GET_INFO; ioctl_req->action = MLAN_ACT_GET; if (MLAN_STATUS_SUCCESS != woal_request_ioctl(priv, ioctl_req, MOAL_IOCTL_WAIT)) { goto done; } for (i = 0; i < info->param.sta_list.sta_count; i++) { if (!memcmp(info->param.sta_list.info[i].mac_address, mac, ETH_ALEN)) { PRINTM(MIOCTL, "Get station: %02x:%02x:%02x:%02x:%02x:%02x RSSI=%d\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], (int) info->param.sta_list.info[i].rssi); stainfo->filled = STATION_INFO_INACTIVE_TIME | STATION_INFO_SIGNAL; stainfo->inactive_time = 0; stainfo->signal = info->param.sta_list.info[i].rssi; ret = 0; break; } } done: if (ioctl_req) kfree(ioctl_req); LEAVE(); return ret; }
/** * @brief reset AP or GO parameters * * @param wiphy A pointer to wiphy structure * @param dev A pointer to net_device structure * * @return 0 -- success, otherwise fail */ int woal_cfg80211_del_beacon(struct wiphy *wiphy, struct net_device *dev) { moal_private *priv = (moal_private *)woal_get_netdev_priv(dev); int ret = 0; #ifdef STA_SUPPORT moal_private *pmpriv = NULL; #endif ENTER(); PRINTM(MMSG, "wlan: Stoping AP\n"); woal_deauth_all_station(priv); /* if the bss is still running, then stop it */ if (priv->bss_started == MTRUE) { if (MLAN_STATUS_SUCCESS != woal_uap_bss_ctrl(priv, MOAL_IOCTL_WAIT_TIMEOUT, UAP_BSS_STOP)) { ret = -EFAULT; goto done; } if (MLAN_STATUS_SUCCESS != woal_uap_bss_ctrl(priv, MOAL_IOCTL_WAIT, UAP_BSS_RESET)) { ret = -EFAULT; goto done; } /* Set WLAN MAC addresses */ if (MLAN_STATUS_SUCCESS != woal_request_set_mac_address(priv)) { PRINTM(MERROR, "Set MAC address failed\n"); ret = -EFAULT; goto done; } } woal_clear_all_mgmt_ies(priv, MOAL_IOCTL_WAIT); #ifdef STA_SUPPORT if (!woal_is_any_interface_active(priv->phandle)) { pmpriv = woal_get_priv((moal_handle *)priv->phandle, MLAN_BSS_ROLE_STA); if (pmpriv) woal_set_scan_time(pmpriv, ACTIVE_SCAN_CHAN_TIME, PASSIVE_SCAN_CHAN_TIME, SPECIFIC_SCAN_CHAN_TIME); } #endif priv->cipher = 0; memset(priv->uap_wep_key, 0, sizeof(priv->uap_wep_key)); priv->channel = 0; PRINTM(MMSG, "wlan: AP stopped\n"); done: LEAVE(); return ret; }
/** * @brief reset AP or GO parameters * * @param wiphy A pointer to wiphy structure * @param dev A pointer to net_device structure * * @return 0 -- success, otherwise fail */ int woal_cfg80211_del_beacon(struct wiphy *wiphy, struct net_device *dev) { moal_private *priv = (moal_private *) woal_get_netdev_priv(dev); int ret = 0; ENTER(); PRINTM(MIOCTL, "del beacon\n"); /* if the bss is still running, then stop it */ if (priv->bss_started == MTRUE) { if (MLAN_STATUS_SUCCESS != woal_uap_bss_ctrl(priv, MOAL_IOCTL_WAIT, UAP_BSS_STOP)) { ret = -EFAULT; goto done; } if (MLAN_STATUS_SUCCESS != woal_uap_bss_ctrl(priv, MOAL_IOCTL_WAIT, UAP_BSS_RESET)) { ret = -EFAULT; goto done; } } #if LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0) && !defined(COMPAT_WIRELESS) /* clear BEACON WPS/P2P IE */ if (MLAN_STATUS_SUCCESS != woal_cfg80211_mgmt_frame_ie(priv, NULL, 0, NULL, 0, NULL, 0, NULL, 0, MGMT_MASK_BEACON_WPS_P2P)) { ret = -EFAULT; goto done; } #endif /* clear mgmt frame ies */ if (MLAN_STATUS_SUCCESS != woal_cfg80211_mgmt_frame_ie(priv, NULL, 0, NULL, 0, NULL, 0, NULL, 0, MGMT_MASK_BEACON | MGMT_MASK_PROBE_RESP | MGMT_MASK_ASSOC_RESP)) { ret = -EFAULT; goto done; } priv->cipher = 0; priv->key_len = 0; done: LEAVE(); return ret; }
/** * @brief vendor command to set drvdbg * * @param wiphy A pointer to wiphy struct * @param wdev A pointer to wireless_dev struct * @param data a pointer to data * @param len data length * * @return 0: success 1: fail */ static int woal_cfg80211_subcmd_set_drvdbg(struct wiphy *wiphy, struct wireless_dev *wdev, const void *data, int data_len) { struct net_device *dev = wdev->netdev; moal_private *priv = (moal_private *)woal_get_netdev_priv(dev); struct sk_buff *skb = NULL; t_u8 *pos = NULL; int ret = 0; ENTER(); /**handle this sub command*/ DBG_HEXDUMP(MCMD_D, "Vendor drvdbg", (t_u8 *)data, data_len); if (data_len) { /* Get the driver debug bit masks from user */ drvdbg = *((t_u32 *)data); PRINTM(MIOCTL, "new drvdbg %x\n", drvdbg); /* Set the driver debug bit masks into mlan */ if (woal_set_drvdbg(priv, drvdbg)) { PRINTM(MERROR, "Set drvdbg failed!\n"); ret = 1; } } /** Allocate skb for cmd reply*/ skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(drvdbg)); if (!skb) { PRINTM(MERROR, "allocate memory fail for vendor cmd\n"); ret = 1; LEAVE(); return ret; } pos = skb_put(skb, sizeof(drvdbg)); memcpy(pos, &drvdbg, sizeof(drvdbg)); ret = cfg80211_vendor_cmd_reply(skb); LEAVE(); return ret; }
/** * @brief set AP or GO parameter * * @param wiphy A pointer to wiphy structure * @param dev A pointer to net_device structure * @param params A pointer to beacon_parameters structure * @return 0 -- success, otherwise fail */ int woal_cfg80211_set_beacon(struct wiphy *wiphy, struct net_device *dev, struct beacon_parameters *params) #endif { moal_private *priv = (moal_private *) woal_get_netdev_priv(dev); int ret = 0; ENTER(); PRINTM(MIOCTL, "set beacon\n"); if (params != NULL) { #if LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0) && !defined(COMPAT_WIRELESS) if (params->tail && params->tail_len) { if (MLAN_STATUS_SUCCESS != woal_cfg80211_mgmt_frame_ie(priv, params->tail, params->tail_len, NULL, 0, NULL, 0, NULL, 0, MGMT_MASK_BEACON)) { ret = -EFAULT; goto done; } } #else if (params->beacon_ies && params->beacon_ies_len) { if (MLAN_STATUS_SUCCESS != woal_cfg80211_mgmt_frame_ie(priv, params->tail, params->tail_len, NULL, 0, NULL, 0, NULL, 0, MGMT_MASK_BEACON)) { ret = -EFAULT; goto done; } } if (params->proberesp_ies && params->proberesp_ies_len) { if (MLAN_STATUS_SUCCESS != woal_cfg80211_mgmt_frame_ie(priv, NULL, 0, params->proberesp_ies, params->proberesp_ies_len, NULL, 0, NULL, 0, MGMT_MASK_PROBE_RESP)) { ret = -EFAULT; goto done; } } if (params->assocresp_ies && params->assocresp_ies_len) { if (MLAN_STATUS_SUCCESS != woal_cfg80211_mgmt_frame_ie(priv, NULL, 0, NULL, 0, params->assocresp_ies, params->assocresp_ies_len, NULL, 0, MGMT_MASK_ASSOC_RESP)) { ret = -EFAULT; goto done; } } #endif } done: LEAVE(); return ret; }
/** * @brief initialize AP or GO parameters * * @param wiphy A pointer to wiphy structure * @param dev A pointer to net_device structure * @param params A pointer to beacon_parameters structure * @return 0 -- success, otherwise fail */ int woal_cfg80211_add_beacon(struct wiphy *wiphy, struct net_device *dev, struct beacon_parameters *params) #endif { moal_private *priv = (moal_private *) woal_get_netdev_priv(dev); int ret = 0; ENTER(); PRINTM(MIOCTL, "add beacon\n"); #ifdef STA_CFG80211 /*** cancel pending scan */ woal_cancel_scan(priv, MOAL_IOCTL_WAIT); #endif if (params != NULL) { /* bss config */ if (MLAN_STATUS_SUCCESS != woal_cfg80211_beacon_config(priv, params)) { ret = -EFAULT; goto done; } /* set mgmt frame ies */ if (MLAN_STATUS_SUCCESS != woal_cfg80211_mgmt_frame_ie(priv, #if LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0) && !defined(COMPAT_WIRELESS) params->tail, params->tail_len, NULL, 0, NULL, 0, NULL, 0, MGMT_MASK_BEACON #else #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0) params->beacon. tail, params->beacon. tail_len, params->beacon. proberesp_ies, params->beacon. proberesp_ies_len, params->beacon. assocresp_ies, params->beacon. assocresp_ies_len, #else params->tail, params->tail_len, params-> proberesp_ies, params-> proberesp_ies_len, params-> assocresp_ies, params-> assocresp_ies_len, #endif NULL, 0, MGMT_MASK_BEACON | MGMT_MASK_PROBE_RESP | MGMT_MASK_ASSOC_RESP #endif )) { ret = -EFAULT; goto done; } } /* if the bss is stopped, then start it */ if (priv->bss_started == MFALSE) { if (MLAN_STATUS_SUCCESS != woal_uap_bss_ctrl(priv, MOAL_IOCTL_WAIT, UAP_BSS_START)) { ret = -EFAULT; goto done; } } done: LEAVE(); return ret; }
/** * @brief set AP or GO parameter * * @param wiphy A pointer to wiphy structure * @param dev A pointer to net_device structure * @param params A pointer to beacon_parameters structure * @return 0 -- success, otherwise fail */ int woal_cfg80211_set_beacon(struct wiphy *wiphy, struct net_device *dev, struct beacon_parameters *params) #endif { moal_private *priv = (moal_private *)woal_get_netdev_priv(dev); int ret = 0; ENTER(); PRINTM(MIOCTL, "set beacon\n"); if (params != NULL) { #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 2, 0) && !defined(COMPAT_WIRELESS) if (params->tail && params->tail_len) { ret = woal_cfg80211_mgmt_frame_ie(priv, params->tail, params->tail_len, NULL, 0, NULL, 0, NULL, 0, MGMT_MASK_BEACON); if (ret) goto done; } #else if (params->tail && params->tail_len) { ret = woal_cfg80211_mgmt_frame_ie(priv, params->tail, params->tail_len, NULL, 0, NULL, 0, NULL, 0, MGMT_MASK_BEACON, MOAL_IOCTL_WAIT); if (ret) goto done; } if (params->beacon_ies && params->beacon_ies_len) { ret = woal_cfg80211_mgmt_frame_ie(priv, params->beacon_ies, params-> beacon_ies_len, NULL, 0, NULL, 0, NULL, 0, MGMT_MASK_BEACON_WPS_P2P, MOAL_IOCTL_WAIT); if (ret) { PRINTM(MERROR, "Failed to set beacon wps/p2p ie\n"); goto done; } } if (params->proberesp_ies && params->proberesp_ies_len) { ret = woal_cfg80211_mgmt_frame_ie(priv, NULL, 0, params->proberesp_ies, params-> proberesp_ies_len, NULL, 0, NULL, 0, MGMT_MASK_PROBE_RESP, MOAL_IOCTL_WAIT); if (ret) goto done; } if (params->assocresp_ies && params->assocresp_ies_len) { ret = woal_cfg80211_mgmt_frame_ie(priv, NULL, 0, NULL, 0, params->assocresp_ies, params-> assocresp_ies_len, NULL, 0, MGMT_MASK_ASSOC_RESP, MOAL_IOCTL_WAIT); if (ret) goto done; } #endif } done: LEAVE(); return ret; }
/** * @brief initialize AP or GO parameters * * @param wiphy A pointer to wiphy structure * @param dev A pointer to net_device structure * @param params A pointer to beacon_parameters structure * @return 0 -- success, otherwise fail */ int woal_cfg80211_add_beacon(struct wiphy *wiphy, struct net_device *dev, struct beacon_parameters *params) #endif { moal_private *priv = (moal_private *)woal_get_netdev_priv(dev); int ret = 0; ENTER(); PRINTM(MMSG, "wlan: Starting AP\n"); #ifdef STA_CFG80211 /*** cancel pending scan */ woal_cancel_scan(priv, MOAL_IOCTL_WAIT); #endif if (params != NULL) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0) #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0) priv->channel = ieee80211_frequency_to_channel(params->chandef.chan-> center_freq); #else priv->channel = ieee80211_frequency_to_channel(params->channel-> center_freq); #endif #endif /* bss config */ if (MLAN_STATUS_SUCCESS != woal_cfg80211_beacon_config(priv, params)) { ret = -EFAULT; goto done; } /* set mgmt frame ies */ ret = woal_cfg80211_mgmt_frame_ie(priv, #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 2, 0) && !defined(COMPAT_WIRELESS) params->tail, params->tail_len, NULL, 0, NULL, 0, NULL, 0, MGMT_MASK_BEACON #else #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0) params->beacon.tail, params->beacon.tail_len, params->beacon.proberesp_ies, params->beacon. proberesp_ies_len, params->beacon.assocresp_ies, params->beacon. assocresp_ies_len, #else params->tail, params->tail_len, params->proberesp_ies, params->proberesp_ies_len, params->assocresp_ies, params->assocresp_ies_len, #endif NULL, 0, MGMT_MASK_BEACON | MGMT_MASK_PROBE_RESP | MGMT_MASK_ASSOC_RESP #endif , MOAL_IOCTL_WAIT); if (ret) goto done; } #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) || defined(COMPAT_WIRELESS) #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0) if (params->beacon.beacon_ies && params->beacon.beacon_ies_len) { ret = woal_cfg80211_mgmt_frame_ie(priv, params->beacon.beacon_ies, params->beacon.beacon_ies_len, NULL, 0, NULL, 0, NULL, 0, MGMT_MASK_BEACON_WPS_P2P, MOAL_IOCTL_WAIT); if (ret) { PRINTM(MERROR, "Failed to set beacon wps/p2p ie\n"); goto done; } } #else if (params->beacon_ies && params->beacon_ies_len) { ret = woal_cfg80211_mgmt_frame_ie(priv, params->beacon_ies, params->beacon_ies_len, NULL, 0, NULL, 0, NULL, 0, MGMT_MASK_BEACON_WPS_P2P, MOAL_IOCTL_WAIT); if (ret) { PRINTM(MERROR, "Failed to set beacon wps/p2p ie\n"); goto done; } } #endif #endif /* if the bss is stopped, then start it */ if (priv->bss_started == MFALSE) { if (MLAN_STATUS_SUCCESS != woal_uap_bss_ctrl(priv, MOAL_IOCTL_WAIT, UAP_BSS_START)) { ret = -EFAULT; goto done; } } PRINTM(MMSG, "wlan: AP started\n"); done: LEAVE(); return ret; }
* * @param wiphy A pointer to wiphy structure * @param dev A pointer to net_device structure * @param mac_addr A pointer to station mac address * * @return 0 -- success, otherwise fail */ int woal_cfg80211_del_station(struct wiphy *wiphy, struct net_device *dev, #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0) const u8 *mac_addr) #else u8 *mac_addr) #endif { moal_private *priv = (moal_private *)woal_get_netdev_priv(dev); ENTER(); if (priv->media_connected == MFALSE) { PRINTM(MINFO, "cfg80211: Media not connected!\n"); LEAVE(); return 0; } /** we will not send deauth to p2p interface, it might cause WPS failure */ if (mac_addr) { PRINTM(MMSG, "wlan: deauth station " MACSTR "\n", MAC2STR(mac_addr)); #ifdef WIFI_DIRECT_SUPPORT if (!priv->phandle->is_go_timer_set && priv->bss_type != MLAN_BSS_TYPE_WIFIDIRECT) #endif woal_deauth_station(priv, (u8 *)mac_addr);