VOID kalP2PGOStationUpdate(IN P_GLUE_INFO_T prGlueInfo, IN P_STA_RECORD_T prCliStaRec, IN BOOLEAN fgIsNew) { P_GL_P2P_INFO_T prP2pGlueInfo = (P_GL_P2P_INFO_T) NULL; struct station_info rStationInfo; do { if ((prGlueInfo == NULL) || (prCliStaRec == NULL)) break; prP2pGlueInfo = prGlueInfo->prP2PInfo; if (fgIsNew) { rStationInfo.filled = STATION_INFO_ASSOC_REQ_IES; rStationInfo.generation = ++prP2pGlueInfo->i4Generation; rStationInfo.assoc_req_ies = prCliStaRec->pucAssocReqIe; rStationInfo.assoc_req_ies_len = prCliStaRec->u2AssocReqIeLen; /* rStationInfo.filled |= STATION_INFO_ASSOC_REQ_IES; */ cfg80211_new_sta(prGlueInfo->prP2PInfo->prDevHandler, /* struct net_device * dev, */ prCliStaRec->aucMacAddr, &rStationInfo, GFP_KERNEL); } else { ++prP2pGlueInfo->i4Generation; cfg80211_del_sta(prGlueInfo->prP2PInfo->prDevHandler, /* struct net_device * dev, */ prCliStaRec->aucMacAddr, GFP_KERNEL); } } while (FALSE); return; } /* kalP2PGOStationUpdate */
VOID kalP2PGOStationUpdate ( IN P_GLUE_INFO_T prGlueInfo, IN UINT_8 ucRoleIndex, IN P_STA_RECORD_T prCliStaRec, IN BOOLEAN fgIsNew ) { P_GL_P2P_INFO_T prP2pGlueInfo = (P_GL_P2P_INFO_T)NULL; do { if ((prGlueInfo == NULL) || (prCliStaRec == NULL) || (ucRoleIndex >= 2)) { break; } prP2pGlueInfo = prGlueInfo->prP2PInfo; if (fgIsNew) { struct station_info rStationInfo; kalMemZero(&rStationInfo, sizeof(rStationInfo)); rStationInfo.filled = STATION_INFO_ASSOC_REQ_IES; rStationInfo.generation = ++prP2pGlueInfo->i4Generation; rStationInfo.assoc_req_ies = prCliStaRec->pucAssocReqIe; rStationInfo.assoc_req_ies_len = prCliStaRec->u2AssocReqIeLen; cfg80211_new_sta(prGlueInfo->prP2PInfo->aprRoleHandler[ucRoleIndex], //struct net_device * dev, prCliStaRec->aucMacAddr, &rStationInfo, GFP_KERNEL); } else { ++prP2pGlueInfo->i4Generation; cfg80211_del_sta(prGlueInfo->prP2PInfo->aprRoleHandler[ucRoleIndex], //struct net_device * dev, prCliStaRec->aucMacAddr, GFP_KERNEL); } } while (FALSE); return; } /* kalP2PGOStationUpdate */
/* * This function handles AP interface specific events generated by firmware. * * Event specific routines are called by this function based * upon the generated event cause. * * * Events supported for AP - * - EVENT_UAP_STA_ASSOC * - EVENT_UAP_STA_DEAUTH * - EVENT_UAP_BSS_ACTIVE * - EVENT_UAP_BSS_START * - EVENT_UAP_BSS_IDLE * - EVENT_UAP_MIC_COUNTERMEASURES: */ int mwifiex_process_uap_event(struct mwifiex_private *priv) { struct mwifiex_adapter *adapter = priv->adapter; int len, i; u32 eventcause = adapter->event_cause; struct station_info sinfo; struct mwifiex_assoc_event *event; struct mwifiex_sta_node *node; u8 *deauth_mac; struct host_cmd_ds_11n_batimeout *ba_timeout; u16 ctrl; switch (eventcause) { case EVENT_UAP_STA_ASSOC: memset(&sinfo, 0, sizeof(sinfo)); event = (struct mwifiex_assoc_event *) (adapter->event_body + MWIFIEX_UAP_EVENT_EXTRA_HEADER); if (le16_to_cpu(event->type) == TLV_TYPE_UAP_MGMT_FRAME) { len = -1; if (ieee80211_is_assoc_req(event->frame_control)) len = 0; else if (ieee80211_is_reassoc_req(event->frame_control)) /* There will be ETH_ALEN bytes of * current_ap_addr before the re-assoc ies. */ len = ETH_ALEN; if (len != -1) { sinfo.assoc_req_ies = &event->data[len]; len = (u8 *)sinfo.assoc_req_ies - (u8 *)&event->frame_control; sinfo.assoc_req_ies_len = le16_to_cpu(event->len) - (u16)len; } } cfg80211_new_sta(priv->netdev, event->sta_addr, &sinfo, GFP_KERNEL); node = mwifiex_add_sta_entry(priv, event->sta_addr); if (!node) { mwifiex_dbg(adapter, ERROR, "could not create station entry!\n"); return -1; } if (!priv->ap_11n_enabled) break; mwifiex_set_sta_ht_cap(priv, sinfo.assoc_req_ies, sinfo.assoc_req_ies_len, node); for (i = 0; i < MAX_NUM_TID; i++) { if (node->is_11n_enabled) node->ampdu_sta[i] = priv->aggr_prio_tbl[i].ampdu_user; else node->ampdu_sta[i] = BA_STREAM_NOT_ALLOWED; } memset(node->rx_seq, 0xff, sizeof(node->rx_seq)); break; case EVENT_UAP_STA_DEAUTH: deauth_mac = adapter->event_body + MWIFIEX_UAP_EVENT_EXTRA_HEADER; cfg80211_del_sta(priv->netdev, deauth_mac, GFP_KERNEL); if (priv->ap_11n_enabled) { mwifiex_11n_del_rx_reorder_tbl_by_ta(priv, deauth_mac); mwifiex_del_tx_ba_stream_tbl_by_ra(priv, deauth_mac); } mwifiex_wmm_del_peer_ra_list(priv, deauth_mac); mwifiex_del_sta_entry(priv, deauth_mac); break; case EVENT_UAP_BSS_IDLE: priv->media_connected = false; priv->port_open = false; if (netif_carrier_ok(priv->netdev)) netif_carrier_off(priv->netdev); mwifiex_stop_net_dev_queue(priv->netdev, adapter); mwifiex_clean_txrx(priv); mwifiex_del_all_sta_list(priv); break; case EVENT_UAP_BSS_ACTIVE: priv->media_connected = true; priv->port_open = true; if (!netif_carrier_ok(priv->netdev)) netif_carrier_on(priv->netdev); mwifiex_wake_up_net_dev_queue(priv->netdev, adapter); break; case EVENT_UAP_BSS_START: mwifiex_dbg(adapter, EVENT, "AP EVENT: event id: %#x\n", eventcause); priv->port_open = false; memcpy(priv->netdev->dev_addr, adapter->event_body + 2, ETH_ALEN); if (priv->hist_data) mwifiex_hist_data_reset(priv); mwifiex_check_uap_capabilties(priv, adapter->event_skb); break; case EVENT_UAP_MIC_COUNTERMEASURES: /* For future development */ mwifiex_dbg(adapter, EVENT, "AP EVENT: event id: %#x\n", eventcause); break; case EVENT_AMSDU_AGGR_CTRL: ctrl = le16_to_cpu(*(__le16 *)adapter->event_body); mwifiex_dbg(adapter, EVENT, "event: AMSDU_AGGR_CTRL %d\n", ctrl); if (priv->media_connected) { adapter->tx_buf_size = min_t(u16, adapter->curr_tx_buf_size, ctrl); mwifiex_dbg(adapter, EVENT, "event: tx_buf_size %d\n", adapter->tx_buf_size); } break; case EVENT_ADDBA: mwifiex_dbg(adapter, EVENT, "event: ADDBA Request\n"); if (priv->media_connected) mwifiex_send_cmd(priv, HostCmd_CMD_11N_ADDBA_RSP, HostCmd_ACT_GEN_SET, 0, adapter->event_body, false); break; case EVENT_DELBA: mwifiex_dbg(adapter, EVENT, "event: DELBA Request\n"); if (priv->media_connected) mwifiex_11n_delete_ba_stream(priv, adapter->event_body); break; case EVENT_BA_STREAM_TIEMOUT: mwifiex_dbg(adapter, EVENT, "event: BA Stream timeout\n"); if (priv->media_connected) { ba_timeout = (void *)adapter->event_body; mwifiex_11n_ba_stream_timeout(priv, ba_timeout); } break; case EVENT_EXT_SCAN_REPORT: mwifiex_dbg(adapter, EVENT, "event: EXT_SCAN Report\n"); if (adapter->ext_scan) return mwifiex_handle_event_ext_scan_report(priv, adapter->event_skb->data); break; case EVENT_TX_STATUS_REPORT: mwifiex_dbg(adapter, EVENT, "event: TX_STATUS Report\n"); mwifiex_parse_tx_status_event(priv, adapter->event_body); break; case EVENT_PS_SLEEP: mwifiex_dbg(adapter, EVENT, "info: EVENT: SLEEP\n"); adapter->ps_state = PS_STATE_PRE_SLEEP; mwifiex_check_ps_cond(adapter); break; case EVENT_PS_AWAKE: mwifiex_dbg(adapter, EVENT, "info: EVENT: AWAKE\n"); if (!adapter->pps_uapsd_mode && priv->media_connected && adapter->sleep_period.period) { adapter->pps_uapsd_mode = true; mwifiex_dbg(adapter, EVENT, "event: PPS/UAPSD mode activated\n"); } adapter->tx_lock_flag = false; if (adapter->pps_uapsd_mode && adapter->gen_null_pkt) { if (mwifiex_check_last_packet_indication(priv)) { if (adapter->data_sent) { adapter->ps_state = PS_STATE_AWAKE; adapter->pm_wakeup_card_req = false; adapter->pm_wakeup_fw_try = false; break; } if (!mwifiex_send_null_packet (priv, MWIFIEX_TxPD_POWER_MGMT_NULL_PACKET | MWIFIEX_TxPD_POWER_MGMT_LAST_PACKET)) adapter->ps_state = PS_STATE_SLEEP; return 0; } } adapter->ps_state = PS_STATE_AWAKE; adapter->pm_wakeup_card_req = false; adapter->pm_wakeup_fw_try = false; break; case EVENT_CHANNEL_REPORT_RDY: mwifiex_dbg(adapter, EVENT, "event: Channel Report\n"); mwifiex_11h_handle_chanrpt_ready(priv, adapter->event_skb); break; case EVENT_RADAR_DETECTED: mwifiex_dbg(adapter, EVENT, "event: Radar detected\n"); mwifiex_11h_handle_radar_detected(priv, adapter->event_skb); break; case EVENT_BT_COEX_WLAN_PARA_CHANGE: dev_err(adapter->dev, "EVENT: BT coex wlan param update\n"); mwifiex_bt_coex_wlan_param_update_event(priv, adapter->event_skb); break; case EVENT_TX_DATA_PAUSE: mwifiex_dbg(adapter, EVENT, "event: TX DATA PAUSE\n"); mwifiex_process_tx_pause_event(priv, adapter->event_skb); break; case EVENT_MULTI_CHAN_INFO: mwifiex_dbg(adapter, EVENT, "event: multi-chan info\n"); mwifiex_process_multi_chan_event(priv, adapter->event_skb); break; default: mwifiex_dbg(adapter, EVENT, "event: unknown event id: %#x\n", eventcause); break; } return 0; }
void ath6kl_connect_ap_mode_sta(struct ath6kl_vif *vif, u16 aid, u8 *mac_addr, u8 keymgmt, u8 ucipher, u8 auth, u8 assoc_req_len, u8 *assoc_info) { struct ath6kl *ar = vif->ar; u8 *ies = NULL, *wpa_ie = NULL, *pos; size_t ies_len = 0; struct station_info sinfo; ath6kl_dbg(ATH6KL_DBG_TRC, "new station %pM aid=%d\n", mac_addr, aid); if (assoc_req_len > sizeof(struct ieee80211_hdr_3addr)) { struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) assoc_info; if (ieee80211_is_assoc_req(mgmt->frame_control) && assoc_req_len >= sizeof(struct ieee80211_hdr_3addr) + sizeof(mgmt->u.assoc_req)) { ies = mgmt->u.assoc_req.variable; ies_len = assoc_info + assoc_req_len - ies; } else if (ieee80211_is_reassoc_req(mgmt->frame_control) && assoc_req_len >= sizeof(struct ieee80211_hdr_3addr) + sizeof(mgmt->u.reassoc_req)) { ies = mgmt->u.reassoc_req.variable; ies_len = assoc_info + assoc_req_len - ies; } } pos = ies; while (pos && pos + 1 < ies + ies_len) { if (pos + 2 + pos[1] > ies + ies_len) break; if (pos[0] == WLAN_EID_RSN) wpa_ie = pos; /* RSN IE */ else if (pos[0] == WLAN_EID_VENDOR_SPECIFIC && pos[1] >= 4 && pos[2] == 0x00 && pos[3] == 0x50 && pos[4] == 0xf2) { if (pos[5] == 0x01) wpa_ie = pos; /* WPA IE */ else if (pos[5] == 0x04) { wpa_ie = pos; /* WPS IE */ break; /* overrides WPA/RSN IE */ } } else if (pos[0] == 0x44 && wpa_ie == NULL) { /* * Note: WAPI Parameter Set IE re-uses Element ID that * was officially allocated for BSS AC Access Delay. As * such, we need to be a bit more careful on when * parsing the frame. However, BSS AC Access Delay * element is not supposed to be included in * (Re)Association Request frames, so this should not * cause problems. */ wpa_ie = pos; /* WAPI IE */ break; } pos += 2 + pos[1]; } ath6kl_add_new_sta(ar, mac_addr, aid, wpa_ie, wpa_ie ? 2 + wpa_ie[1] : 0, keymgmt, ucipher, auth); /* send event to application */ memset(&sinfo, 0, sizeof(sinfo)); /* TODO: sinfo.generation */ sinfo.assoc_req_ies = ies; sinfo.assoc_req_ies_len = ies_len; sinfo.filled |= STATION_INFO_ASSOC_REQ_IES; cfg80211_new_sta(vif->ndev, mac_addr, &sinfo, GFP_KERNEL); netif_wake_queue(vif->ndev); }
static int qtnf_event_handle_sta_assoc(struct qtnf_wmac *mac, struct qtnf_vif *vif, const struct qlink_event_sta_assoc *sta_assoc, u16 len) { const u8 *sta_addr; u16 frame_control; struct station_info *sinfo; size_t payload_len; u16 tlv_type; u16 tlv_value_len; size_t tlv_full_len; const struct qlink_tlv_hdr *tlv; int ret = 0; if (unlikely(len < sizeof(*sta_assoc))) { pr_err("VIF%u.%u: payload is too short (%u < %zu)\n", mac->macid, vif->vifid, len, sizeof(*sta_assoc)); return -EINVAL; } if (vif->wdev.iftype != NL80211_IFTYPE_AP) { pr_err("VIF%u.%u: STA_ASSOC event when not in AP mode\n", mac->macid, vif->vifid); return -EPROTO; } sinfo = kzalloc(sizeof(*sinfo), GFP_KERNEL); if (!sinfo) return -ENOMEM; sta_addr = sta_assoc->sta_addr; frame_control = le16_to_cpu(sta_assoc->frame_control); pr_debug("VIF%u.%u: MAC:%pM FC:%x\n", mac->macid, vif->vifid, sta_addr, frame_control); qtnf_sta_list_add(vif, sta_addr); sinfo->assoc_req_ies = NULL; sinfo->assoc_req_ies_len = 0; sinfo->generation = vif->generation; payload_len = len - sizeof(*sta_assoc); tlv = (const struct qlink_tlv_hdr *)sta_assoc->ies; while (payload_len >= sizeof(*tlv)) { tlv_type = le16_to_cpu(tlv->type); tlv_value_len = le16_to_cpu(tlv->len); tlv_full_len = tlv_value_len + sizeof(struct qlink_tlv_hdr); if (tlv_full_len > payload_len) { ret = -EINVAL; goto out; } if (tlv_type == QTN_TLV_ID_IE_SET) { const struct qlink_tlv_ie_set *ie_set; unsigned int ie_len; if (payload_len < sizeof(*ie_set)) { ret = -EINVAL; goto out; } ie_set = (const struct qlink_tlv_ie_set *)tlv; ie_len = tlv_value_len - (sizeof(*ie_set) - sizeof(ie_set->hdr)); if (ie_set->type == QLINK_IE_SET_ASSOC_REQ && ie_len) { sinfo->assoc_req_ies = ie_set->ie_data; sinfo->assoc_req_ies_len = ie_len; } } payload_len -= tlv_full_len; tlv = (struct qlink_tlv_hdr *)(tlv->val + tlv_value_len); } if (payload_len) { ret = -EINVAL; goto out; } cfg80211_new_sta(vif->netdev, sta_assoc->sta_addr, sinfo, GFP_KERNEL); out: kfree(sinfo); return ret; }