3 APPEND_VAR_ATTRI_ENTRY_T txAssocRspAttributesTable[] = {
4 { (P2P_ATTRI_HDR_LEN + P2P_ATTRI_MAX_LEN_STATUS) , NULL, p2pFuncAppendAttriStatusForAssocRsp } /* 0 */ // Status
5 ,{ (P2P_ATTRI_HDR_LEN + P2P_ATTRI_MAX_LEN_EXT_LISTEN_TIMING), NULL, p2pFuncAppendAttriExtListenTiming } /* 8 */
9 APPEND_VAR_IE_ENTRY_T txProbeRspIETable[] = {
10 { (ELEM_HDR_LEN + (RATE_NUM - ELEM_MAX_LEN_SUP_RATES)), NULL, bssGenerateExtSuppRate_IE } /* 50 */
11 ,{ (ELEM_HDR_LEN + ELEM_MAX_LEN_ERP), NULL, rlmRspGenerateErpIE } /* 42 */
12 ,{ (ELEM_HDR_LEN + ELEM_MAX_LEN_HT_CAP), NULL, rlmRspGenerateHtCapIE } /* 45 */
13 ,{ (ELEM_HDR_LEN + ELEM_MAX_LEN_HT_OP), NULL, rlmRspGenerateHtOpIE } /* 61 */
14 ,{ (ELEM_HDR_LEN + ELEM_MAX_LEN_RSN), NULL, rsnGenerateRSNIE } /* 48 */
15 ,{ (ELEM_HDR_LEN + ELEM_MAX_LEN_OBSS_SCAN), NULL, rlmRspGenerateObssScanIE } /* 74 */
16 ,{ (ELEM_HDR_LEN + ELEM_MAX_LEN_EXT_CAP), NULL, rlmRspGenerateExtCapIE } /* 127 */
17 ,{ (ELEM_HDR_LEN + ELEM_MAX_LEN_WPA), NULL, rsnGenerateWpaNoneIE } /* 221 */
18 ,{ (ELEM_HDR_LEN + ELEM_MAX_LEN_WMM_PARAM), NULL, mqmGenerateWmmParamIE } /* 221 */
21 /*----------------------------------------------------------------------------*/
23 * @brief Function for requesting scan. There is an option to do ACTIVE or PASSIVE scan.
25 * @param eScanType - Specify the scan type of the scan request. It can be an ACTIVE/PASSIVE
27 * eChannelSet - Specify the prefered channel set.
28 * A FULL scan would request a legacy full channel normal scan.(usually ACTIVE).
29 * A P2P_SOCIAL scan would scan 1+6+11 channels.(usually ACTIVE)
30 * A SPECIFIC scan would only 1/6/11 channels scan. (Passive Listen/Specific Search)
31 * ucChannelNum - A specific channel number. (Only when channel is specified)
32 * eBand - A specific band. (Only when channel is specified)
37 /*----------------------------------------------------------------------------*/
40 IN P_ADAPTER_T prAdapter,
41 IN P_P2P_SCAN_REQ_INFO_T prScanReqInfo
45 P_MSG_SCN_SCAN_REQ prScanReq = (P_MSG_SCN_SCAN_REQ)NULL;
47 DEBUGFUNC("p2pFuncRequestScan()");
50 ASSERT_BREAK((prAdapter != NULL) &&
51 (prScanReqInfo != NULL));
53 if (prScanReqInfo->eChannelSet == SCAN_CHANNEL_SPECIFIED) {
54 ASSERT_BREAK(prScanReqInfo->ucNumChannelList > 0);
55 DBGLOG(P2P, LOUD, ("P2P Scan Request Channel:%d\n", prScanReqInfo->arScanChannelList[0].ucChannelNum));
58 prScanReq = (P_MSG_SCN_SCAN_REQ)cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(MSG_SCN_SCAN_REQ));
60 ASSERT(0); // Can't trigger SCAN FSM
64 prScanReq->rMsgHdr.eMsgId = MID_P2P_SCN_SCAN_REQ;
65 prScanReq->ucSeqNum = ++prScanReqInfo->ucSeqNumOfScnMsg;
66 prScanReq->ucNetTypeIndex = (UINT_8)NETWORK_TYPE_P2P_INDEX;
67 prScanReq->eScanType = prScanReqInfo->eScanType;
68 prScanReq->eScanChannel = prScanReqInfo->eChannelSet;
69 prScanReq->u2IELen = 0;
71 /* Copy IE for Probe Request. */
72 kalMemCopy(prScanReq->aucIE, prScanReqInfo->aucIEBuf, prScanReqInfo->u4BufLength);
73 prScanReq->u2IELen = (UINT_16)prScanReqInfo->u4BufLength;
75 prScanReq->u2ChannelDwellTime = prScanReqInfo->u2PassiveDewellTime;
77 switch (prScanReqInfo->eChannelSet) {
78 case SCAN_CHANNEL_SPECIFIED:
81 P_RF_CHANNEL_INFO_T prDomainInfo = (P_RF_CHANNEL_INFO_T)prScanReqInfo->arScanChannelList;
83 if (prScanReqInfo->ucNumChannelList > MAXIMUM_OPERATION_CHANNEL_LIST) {
84 prScanReqInfo->ucNumChannelList = MAXIMUM_OPERATION_CHANNEL_LIST;
88 for (u4Idx = 0; u4Idx < prScanReqInfo->ucNumChannelList; u4Idx++) {
89 prScanReq->arChnlInfoList[u4Idx].ucChannelNum = prDomainInfo->ucChannelNum;
90 prScanReq->arChnlInfoList[u4Idx].eBand = prDomainInfo->eBand;
94 prScanReq->ucChannelListNum = prScanReqInfo->ucNumChannelList;
96 case SCAN_CHANNEL_FULL:
97 case SCAN_CHANNEL_2G4:
98 case SCAN_CHANNEL_P2P_SOCIAL:
100 UINT_8 aucP2pSsid[] = P2P_WILDCARD_SSID;
102 COPY_SSID(prScanReq->aucSSID,
103 prScanReq->ucSSIDLength,
104 prScanReqInfo->rSsidStruct.aucSsid,
105 prScanReqInfo->rSsidStruct.ucSsidLen);
107 /* For compatible. */
108 if (EQUAL_SSID(aucP2pSsid, P2P_WILDCARD_SSID_LEN, prScanReq->aucSSID, prScanReq->ucSSIDLength)) {
109 prScanReq->ucSSIDType = SCAN_REQ_SSID_P2P_WILDCARD;
111 else if (prScanReq->ucSSIDLength != 0) {
112 prScanReq->ucSSIDType = SCAN_REQ_SSID_SPECIFIED;
117 /* Currently there is no other scan channel set. */
122 mboxSendMsg(prAdapter,
124 (P_MSG_HDR_T)prScanReq,
125 MSG_SEND_METHOD_BUF);
130 } /* p2pFuncRequestScan */
134 IN P_ADAPTER_T prAdapter,
135 IN P_P2P_SCAN_REQ_INFO_T prScanInfo
138 P_MSG_SCN_SCAN_CANCEL prScanCancelMsg = (P_MSG_SCN_SCAN_CANCEL)NULL;
141 ASSERT_BREAK((prAdapter != NULL) && (prScanInfo != NULL));
143 if (!prScanInfo->fgIsScanRequest) {
148 if (prScanInfo->ucSeqNumOfScnMsg) {
149 /* There is a channel privilege on hand. */
150 DBGLOG(P2P, TRACE, ("P2P Cancel Scan\n"));
152 prScanCancelMsg = (P_MSG_SCN_SCAN_CANCEL)cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(MSG_SCN_SCAN_CANCEL));
153 if (!prScanCancelMsg) {
154 /* Buffer not enough, can not cancel scan request. */
155 DBGLOG(P2P, TRACE, ("Buffer not enough, can not cancel scan.\n"));
160 prScanCancelMsg->rMsgHdr.eMsgId = MID_P2P_SCN_SCAN_CANCEL;
161 prScanCancelMsg->ucNetTypeIndex = NETWORK_TYPE_P2P_INDEX;
162 prScanCancelMsg->ucSeqNum = prScanInfo->ucSeqNumOfScnMsg++;
163 prScanCancelMsg->fgIsChannelExt = FALSE;
164 prScanInfo->fgIsScanRequest = FALSE;
166 mboxSendMsg(prAdapter,
168 (P_MSG_HDR_T)prScanCancelMsg,
169 MSG_SEND_METHOD_BUF);
178 } /* p2pFuncCancelScan */
182 p2pFuncSwitchOPMode (
183 IN P_ADAPTER_T prAdapter,
184 IN P_BSS_INFO_T prP2pBssInfo,
185 IN ENUM_OP_MODE_T eOpMode,
186 IN BOOLEAN fgSyncToFW
190 ASSERT_BREAK((prAdapter != NULL) &&
191 (prP2pBssInfo != NULL) &&
192 (eOpMode < OP_MODE_NUM));
194 if (prP2pBssInfo->eCurrentOPMode != eOpMode) {
195 DBGLOG(P2P, TRACE, ("p2pFuncSwitchOPMode: Switch to from %d, to %d.\n", prP2pBssInfo->eCurrentOPMode, eOpMode));
197 switch (prP2pBssInfo->eCurrentOPMode) {
198 case OP_MODE_ACCESS_POINT:
199 p2pFuncDissolve(prAdapter, prP2pBssInfo, TRUE, REASON_CODE_DEAUTH_LEAVING_BSS);
201 p2pFsmRunEventStopAP(prAdapter, NULL);
208 prP2pBssInfo->eIntendOPMode = eOpMode;
209 prP2pBssInfo->eCurrentOPMode = eOpMode;
211 case OP_MODE_INFRASTRUCTURE:
212 DBGLOG(P2P, TRACE, ("p2pFuncSwitchOPMode: Switch to Client.\n"));
213 case OP_MODE_ACCESS_POINT:
214 // if (!IS_BSS_ACTIVE(prP2pBssInfo)) {
215 // SET_NET_ACTIVE(prAdapter, NETWORK_TYPE_P2P_INDEX);
216 // nicActivateNetwork(prAdapter, NETWORK_TYPE_P2P_INDEX);
219 /* Change interface address. */
220 if (eOpMode == OP_MODE_ACCESS_POINT) {
221 DBGLOG(P2P, TRACE, ("p2pFuncSwitchOPMode: Switch to AP.\n"));
222 prP2pBssInfo->ucSSIDLen = 0;
225 COPY_MAC_ADDR(prP2pBssInfo->aucOwnMacAddr, prAdapter->rWifiVar.aucInterfaceAddress);
226 COPY_MAC_ADDR(prP2pBssInfo->aucBSSID, prAdapter->rWifiVar.aucInterfaceAddress);
230 case OP_MODE_P2P_DEVICE:
232 /* Change device address. */
233 DBGLOG(P2P, TRACE, ("p2pFuncSwitchOPMode: Switch back to P2P Device.\n"));
235 // if (!IS_BSS_ACTIVE(prP2pBssInfo)) {
236 // SET_NET_ACTIVE(prAdapter, NETWORK_TYPE_P2P_INDEX);
237 // nicActivateNetwork(prAdapter, NETWORK_TYPE_P2P_INDEX);
240 p2pChangeMediaState(prAdapter, PARAM_MEDIA_STATE_DISCONNECTED);
242 COPY_MAC_ADDR(prP2pBssInfo->aucOwnMacAddr, prAdapter->rWifiVar.aucDeviceAddress);
243 COPY_MAC_ADDR(prP2pBssInfo->aucBSSID, prAdapter->rWifiVar.aucDeviceAddress);
249 // if (IS_BSS_ACTIVE(prP2pBssInfo)) {
250 // UNSET_NET_ACTIVE(prAdapter, NETWORK_TYPE_P2P_INDEX);
252 // nicDeactivateNetwork(prAdapter, NETWORK_TYPE_P2P_INDEX);
259 P2P_DISCONNECT_INFO rP2PDisInfo;
261 rP2PDisInfo.ucRole = 2;
262 wlanSendSetQueryCmd(prAdapter,
269 sizeof(P2P_DISCONNECT_INFO),
270 (PUINT_8)&rP2PDisInfo,
276 DBGLOG(P2P, TRACE, ("The device address is changed to " MACSTR " \n", MAC2STR(prP2pBssInfo->aucOwnMacAddr)));
277 DBGLOG(P2P, TRACE, ("The BSSID is changed to " MACSTR " \n", MAC2STR(prP2pBssInfo->aucBSSID)));
279 /* Update BSS INFO to FW. */
280 if ((fgSyncToFW) && (eOpMode != OP_MODE_ACCESS_POINT)) {
281 nicUpdateBss(prAdapter, NETWORK_TYPE_P2P_INDEX);
288 } /* p2pFuncSwitchOPMode */
292 /*----------------------------------------------------------------------------*/
294 * @brief This function will start a P2P Group Owner and send Beacon Frames.
300 /*----------------------------------------------------------------------------*/
303 IN P_ADAPTER_T prAdapter,
304 IN P_BSS_INFO_T prBssInfo,
305 IN PUINT_8 pucSsidBuf,
307 IN UINT_8 ucChannelNum,
308 IN ENUM_BAND_T eBand,
309 IN ENUM_CHNL_EXT_T eSco,
310 IN BOOLEAN fgIsPureAP
314 ASSERT_BREAK((prAdapter != NULL) && (prBssInfo != NULL));
316 ASSERT(prBssInfo->eCurrentOPMode == OP_MODE_ACCESS_POINT);
318 DBGLOG(P2P, TRACE, ("p2pFuncStartGO:\n"));
320 /* AP mode started. */
321 p2pFuncSwitchOPMode(prAdapter, prBssInfo, prBssInfo->eIntendOPMode, FALSE);
323 prBssInfo->eIntendOPMode = OP_MODE_NUM;
325 //4 <1.1> Assign SSID
326 COPY_SSID(prBssInfo->aucSSID,
327 prBssInfo->ucSSIDLen,
331 DBGLOG(P2P, TRACE, ("GO SSID:%s \n", prBssInfo->aucSSID));
333 //4 <1.2> Clear current AP's STA_RECORD_T and current AID
334 prBssInfo->prStaRecOfAP = (P_STA_RECORD_T)NULL;
335 prBssInfo->u2AssocId = 0;
338 //4 <1.3> Setup Channel, Band and Phy Attributes
339 prBssInfo->ucPrimaryChannel = ucChannelNum;
340 prBssInfo->eBand = eBand;
341 prBssInfo->eBssSCO = eSco;
343 DBGLOG(P2P, TRACE, ("GO Channel:%d \n", ucChannelNum));
346 if (prBssInfo->eBand == BAND_5G) {
347 prBssInfo->ucPhyTypeSet = (prAdapter->rWifiVar.ucAvailablePhyTypeSet & PHY_TYPE_SET_802_11AN); /* Depend on eBand */
348 prBssInfo->ucConfigAdHocAPMode = AP_MODE_11A; /* Depend on eCurrentOPMode and ucPhyTypeSet */
350 else if (fgIsPureAP) {
351 prBssInfo->ucPhyTypeSet = (prAdapter->rWifiVar.ucAvailablePhyTypeSet & PHY_TYPE_SET_802_11BGN); /* Depend on eBand */
352 prBssInfo->ucConfigAdHocAPMode = AP_MODE_MIXED_11BG; /* Depend on eCurrentOPMode and ucPhyTypeSet */
355 prBssInfo->ucPhyTypeSet = (prAdapter->rWifiVar.ucAvailablePhyTypeSet & PHY_TYPE_SET_802_11GN); /* Depend on eBand */
356 prBssInfo->ucConfigAdHocAPMode = AP_MODE_11G_P2P; /* Depend on eCurrentOPMode and ucPhyTypeSet */
360 prBssInfo->ucNonHTBasicPhyType = (UINT_8)
361 rNonHTApModeAttributes[prBssInfo->ucConfigAdHocAPMode].ePhyTypeIndex;
362 prBssInfo->u2BSSBasicRateSet =
363 rNonHTApModeAttributes[prBssInfo->ucConfigAdHocAPMode].u2BSSBasicRateSet;
364 prBssInfo->u2OperationalRateSet =
365 rNonHTPhyAttributes[prBssInfo->ucNonHTBasicPhyType].u2SupportedRateSet;
367 if (prBssInfo->ucAllSupportedRatesLen == 0) {
368 rateGetDataRatesFromRateSet(prBssInfo->u2OperationalRateSet,
369 prBssInfo->u2BSSBasicRateSet,
370 prBssInfo->aucAllSupportedRates,
371 &prBssInfo->ucAllSupportedRatesLen);
374 //4 <1.5> Setup MIB for current BSS
375 prBssInfo->u2ATIMWindow = 0;
376 prBssInfo->ucBeaconTimeoutCount = 0;
378 //3 <2> Update BSS_INFO_T common part
381 prBssInfo->fgIsProtection = TRUE; /* Always enable protection at P2P GO */
382 kalP2PSetCipher(prAdapter->prGlueInfo, IW_AUTH_CIPHER_CCMP);
385 if (kalP2PGetCipher(prAdapter->prGlueInfo))
386 prBssInfo->fgIsProtection = TRUE;
389 // 20120106 frog: I want separate OP_Mode & Beacon TX Function.
390 //p2pFuncSwitchOPMode(prAdapter, prBssInfo, OP_MODE_ACCESS_POINT, FALSE);
392 bssInitForAP(prAdapter, prBssInfo, FALSE);
394 nicQmUpdateWmmParms(prAdapter, NETWORK_TYPE_P2P_INDEX);
395 #endif /* CFG_SUPPORT_AAA */
399 //4 <3.1> Setup channel and bandwidth
400 rlmBssInitForAPandIbss(prAdapter, prBssInfo);
402 //4 <3.2> Reset HW TSF Update Mode and Beacon Mode
403 nicUpdateBss(prAdapter, NETWORK_TYPE_P2P_INDEX);
405 //4 <3.3> Update Beacon again for network phy type confirmed.
406 bssUpdateBeaconContent(prAdapter, NETWORK_TYPE_P2P_INDEX);
408 //4 <3.4> Setup BSSID
409 nicPmIndicateBssCreated(prAdapter, NETWORK_TYPE_P2P_INDEX);
414 } /* p2pFuncStartGO() */
419 /*----------------------------------------------------------------------------*/
421 * \brief This function is to inform CNM that channel privilege
424 * \param[in] prAdapter Pointer of ADAPTER_T
428 /*----------------------------------------------------------------------------*/
431 IN P_ADAPTER_T prAdapter,
432 IN P_P2P_CHNL_REQ_INFO_T prChnlReqInfo
435 P_MSG_CH_ABORT_T prMsgChRelease = (P_MSG_CH_ABORT_T)NULL;
437 DEBUGFUNC("p2pFuncReleaseCh()");
440 ASSERT_BREAK((prAdapter != NULL) && (prChnlReqInfo != NULL));
442 if (!prChnlReqInfo->fgIsChannelRequested) {
446 DBGLOG(P2P, TRACE, ("P2P Release Channel\n"));
447 prChnlReqInfo->fgIsChannelRequested = FALSE;
450 /* 1. return channel privilege to CNM immediately */
451 prMsgChRelease = (P_MSG_CH_ABORT_T)cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(MSG_CH_ABORT_T));
452 if (!prMsgChRelease) {
453 ASSERT(0); // Can't release Channel to CNM
457 prMsgChRelease->rMsgHdr.eMsgId = MID_MNY_CNM_CH_ABORT;
458 prMsgChRelease->ucNetTypeIndex = NETWORK_TYPE_P2P_INDEX;
459 prMsgChRelease->ucTokenID = prChnlReqInfo->ucSeqNumOfChReq++;
461 mboxSendMsg(prAdapter,
463 (P_MSG_HDR_T) prMsgChRelease,
464 MSG_SEND_METHOD_BUF);
469 } /* p2pFuncReleaseCh */
472 /*----------------------------------------------------------------------------*/
474 * @brief Process of CHANNEL_REQ_JOIN Initial. Enter CHANNEL_REQ_JOIN State.
480 /*----------------------------------------------------------------------------*/
483 IN P_ADAPTER_T prAdapter,
484 IN P_P2P_CHNL_REQ_INFO_T prChnlReqInfo
487 P_MSG_CH_REQ_T prMsgChReq = (P_MSG_CH_REQ_T)NULL;
490 ASSERT_BREAK((prAdapter != NULL) && (prChnlReqInfo != NULL));
492 p2pFuncReleaseCh(prAdapter, prChnlReqInfo);
494 /* send message to CNM for acquiring channel */
495 prMsgChReq = (P_MSG_CH_REQ_T)cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(MSG_CH_REQ_T));
498 ASSERT(0); // Can't indicate CNM for channel acquiring
502 prMsgChReq->rMsgHdr.eMsgId = MID_MNY_CNM_CH_REQ;
503 prMsgChReq->ucNetTypeIndex = NETWORK_TYPE_P2P_INDEX;
504 prMsgChReq->ucTokenID = ++prChnlReqInfo->ucSeqNumOfChReq;
505 prMsgChReq->eReqType = CH_REQ_TYPE_JOIN;
506 prMsgChReq->u4MaxInterval = prChnlReqInfo->u4MaxInterval;
508 prMsgChReq->ucPrimaryChannel = prChnlReqInfo->ucReqChnlNum;
509 prMsgChReq->eRfSco = prChnlReqInfo->eChnlSco;
510 prMsgChReq->eRfBand = prChnlReqInfo->eBand;
512 kalMemZero(prMsgChReq->aucBSSID, MAC_ADDR_LEN);
514 /* Channel request join BSSID. */
516 mboxSendMsg(prAdapter,
518 (P_MSG_HDR_T) prMsgChReq,
519 MSG_SEND_METHOD_BUF);
521 prChnlReqInfo->fgIsChannelRequested = TRUE;
526 } /* p2pFuncAcquireCh */
531 IN P_ADAPTER_T prAdapter,
532 IN PUINT_8 pucBcnHdr,
534 IN PUINT_8 pucBcnBody,
535 IN UINT_32 u4BodyLen,
536 IN UINT_32 u4DtimPeriod,
537 IN UINT_32 u4BcnInterval)
539 WLAN_STATUS rResultStatus = WLAN_STATUS_INVALID_DATA;
540 P_WLAN_BEACON_FRAME_T prBcnFrame = (P_WLAN_BEACON_FRAME_T)NULL;
541 P_BSS_INFO_T prP2pBssInfo = (P_BSS_INFO_T)NULL;
542 P_MSDU_INFO_T prBcnMsduInfo = (P_MSDU_INFO_T)NULL;
543 PUINT_8 pucTIMBody = (PUINT_8)NULL;
544 UINT_16 u2FrameLength = 0, UINT_16 u2OldBodyLen = 0;
545 UINT_8 aucIEBuf[MAX_IE_LENGTH];
548 ASSERT_BREAK(prAdapter != NULL);
550 prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
551 prBcnMsduInfo = prP2pBssInfo->prBeacon
553 ASSERT_BREAK(prBcnMsduInfo != NULL);
555 /* TODO: Find TIM IE pointer. */
556 prBcnFrame = prBcnMsduInfo->prPacket;
558 ASSERT_BREAK(prBcnFrame != NULL);
562 UINT_16 u2IELength = 0, u2Offset = 0;
563 PUINT_8 pucIEBuf = prBcnFrame->aucInfoElem;
565 u2IELength = prBcnMsduInfo->u2FrameLength - prBcnMsduInfo->ucMacHeaderLength;
567 IE_FOR_EACH(pucIEBuf, u2IELength, u2Offset) {
568 if ((IE_ID(pucIEBuf) == ELEM_ID_TIM) ||
569 ((IE_ID(pucIEBuf) > ELEM_ID_IBSS_PARAM_SET)) {
570 pucTIMBody = pucIEBuf;
573 u2FrameLength += IE_SIZE(pucIEBuf);
576 if (pucTIMBody == NULL) {
577 pucTIMBody = pucIEBuf;
580 /* Body not change. */
581 u2OldBodyLen = (UINT_16)((UINT_32)pucTIMBody - (UINT_32)prBcnFrame->aucInfoElem);
584 kalMemCmp(aucIEBuf, pucTIMBody, u2OldBodyLen);
589 kalMemCopy(prBcnMsduInfo->prPacket, pucBcnHdr, u4HdrLen);
591 pucTIMBody = (PUINT_8)((UINT_32)prBcnMsduInfo->prPacket + u4HdrLen);
593 prBcnMsduInfo->ucMacHeaderLength = (WLAN_MAC_MGMT_HEADER_LEN +
594 (TIMESTAMP_FIELD_LEN + BEACON_INTERVAL_FIELD_LEN + CAP_INFO_FIELD_LEN));
596 u2FrameLength = u4HdrLen; /* Header + Partial Body. */
600 /* Header not change. */
601 u2FrameLength += prBcnMsduInfo->ucMacHeaderLength;
606 kalMemCopy(pucTIMBody, pucBcnBody, u4BodyLen);
607 u2FrameLength += (UINT_16)u4BodyLen;
610 kalMemCopy(pucTIMBody, aucIEBuf, u2OldBodyLen);
611 u2FrameLength += u2OldBodyLen;
615 prBcnMsduInfo->u2FrameLength = u2FrameLength;
617 prBcnMsduInfo->fgIs802_11 = TRUE;
618 prBcnMsduInfo->ucNetworkType = NETWORK_TYPE_P2P_INDEX;
620 prP2pBssInfo->u2BeaconInterval = (UINT_16)u4BcnInterval;
621 prP2pBssInfo->ucDTIMPeriod = (UINT_8)u4DtimPeriod;
622 prP2pBssInfo->u2CapInfo = prBcnFrame->u2CapInfo;
623 prBcnMsduInfo->ucPacketType = 3;
625 rResultStatus = nicUpdateBeaconIETemplate(prAdapter,
626 IE_UPD_METHOD_UPDATE_ALL,
627 NETWORK_TYPE_P2P_INDEX,
628 prP2pBssInfo->u2CapInfo,
629 (PUINT_8)prBcnFrame->aucInfoElem,
630 prBcnMsduInfo->u2FrameLength - OFFSET_OF(WLAN_BEACON_FRAME_T, aucInfoElem));
632 if (prP2pBssInfo->eCurrentOPMode == OP_MODE_ACCESS_POINT) {
633 /* AP is created, Beacon Update. */
634 nicPmIndicateBssAbort(prAdapter, NETWORK_TYPE_P2P_INDEX);
636 nicPmIndicateBssCreated(prAdapter, NETWORK_TYPE_P2P_INDEX);
641 return rResultStatus;
642 } /* p2pFuncBeaconUpdate */
646 p2pFuncBeaconUpdate (
647 IN P_ADAPTER_T prAdapter,
648 IN P_BSS_INFO_T prP2pBssInfo,
649 IN P_P2P_BEACON_UPDATE_INFO_T prBcnUpdateInfo,
650 IN PUINT_8 pucNewBcnHdr,
651 IN UINT_32 u4NewHdrLen,
652 IN PUINT_8 pucNewBcnBody,
653 IN UINT_32 u4NewBodyLen
656 WLAN_STATUS rWlanStatus = WLAN_STATUS_SUCCESS;
657 P_WLAN_BEACON_FRAME_T prBcnFrame = (P_WLAN_BEACON_FRAME_T)NULL;
658 P_MSDU_INFO_T prBcnMsduInfo = (P_MSDU_INFO_T)NULL;
659 PUINT_8 pucIEBuf = (PUINT_8)NULL;
660 UINT_8 aucIEBuf[MAX_IE_LENGTH];
663 ASSERT_BREAK((prAdapter != NULL) &&
664 (prP2pBssInfo != NULL) &&
665 (prBcnUpdateInfo != NULL));
667 prBcnMsduInfo = prP2pBssInfo->prBeacon;
670 if (prBcnUpdateInfo->pucBcnHdr != NULL) {
671 ASSERT((UINT_32)prBcnUpdateInfo->pucBcnHdr == ((UINT_32)prBcnMsduInfo->prPacket + MAC_TX_RESERVED_FIELD));
674 if (prBcnUpdateInfo->pucBcnBody != NULL) {
675 ASSERT((UINT_32)prBcnUpdateInfo->pucBcnBody == ((UINT_32)prBcnUpdateInfo->pucBcnHdr + (UINT_32)prBcnUpdateInfo->u4BcnHdrLen));
678 prBcnFrame = (P_WLAN_BEACON_FRAME_T)((UINT_32)prBcnMsduInfo->prPacket + MAC_TX_RESERVED_FIELD);
680 if (!pucNewBcnBody) {
682 pucNewBcnBody = prBcnUpdateInfo->pucBcnBody;
683 ASSERT(u4NewBodyLen == 0);
684 u4NewBodyLen = prBcnUpdateInfo->u4BcnBodyLen;
687 prBcnUpdateInfo->u4BcnBodyLen = u4NewBodyLen;
690 /* Temp buffer body part. */
691 kalMemCopy(aucIEBuf, pucNewBcnBody, u4NewBodyLen);
694 kalMemCopy(prBcnFrame, pucNewBcnHdr, u4NewHdrLen);
695 prBcnUpdateInfo->pucBcnHdr = (PUINT_8)prBcnFrame;
696 prBcnUpdateInfo->u4BcnHdrLen = u4NewHdrLen;
699 pucIEBuf = (PUINT_8)((UINT_32)prBcnUpdateInfo->pucBcnHdr + (UINT_32)prBcnUpdateInfo->u4BcnHdrLen);
700 kalMemCopy(pucIEBuf, aucIEBuf, u4NewBodyLen);
701 prBcnUpdateInfo->pucBcnBody = pucIEBuf;
704 prBcnMsduInfo->u2FrameLength = (UINT_16)(prBcnUpdateInfo->u4BcnHdrLen + prBcnUpdateInfo->u4BcnBodyLen);
706 prBcnMsduInfo->ucPacketType = 3;
707 prBcnMsduInfo->fgIs802_11 = TRUE;
708 prBcnMsduInfo->ucNetworkType = NETWORK_TYPE_P2P_INDEX;
711 /* Update BSS INFO related information. */
712 COPY_MAC_ADDR(prP2pBssInfo->aucOwnMacAddr, prBcnFrame->aucSrcAddr);
713 COPY_MAC_ADDR(prP2pBssInfo->aucBSSID, prBcnFrame->aucBSSID);
714 prP2pBssInfo->u2CapInfo = prBcnFrame->u2CapInfo;
716 p2pFuncParseBeaconContent(prAdapter,
718 (PUINT_8)prBcnFrame->aucInfoElem,
719 (prBcnMsduInfo->u2FrameLength - OFFSET_OF(WLAN_BEACON_FRAME_T, aucInfoElem)));
722 //bssUpdateBeaconContent(prAdapter, NETWORK_TYPE_P2P_INDEX);
724 nicUpdateBeaconIETemplate(prAdapter,
725 IE_UPD_METHOD_UPDATE_ALL,
726 NETWORK_TYPE_P2P_INDEX,
727 prBcnFrame->u2CapInfo,
728 (PUINT_8)prBcnFrame->aucInfoElem,
729 (prBcnMsduInfo->u2FrameLength - OFFSET_OF(WLAN_BEACON_FRAME_T, aucInfoElem)));
734 } /* p2pFuncBeaconUpdate */
738 // TODO: We do not apply IE in deauth frame set from upper layer now.
741 IN P_ADAPTER_T prAdapter,
742 IN PUINT_8 pucPeerMacAddr,
743 IN UINT_16 u2ReasonCode,
746 IN BOOLEAN fgSendDeauth
749 WLAN_STATUS rWlanStatus = WLAN_STATUS_FAILURE;
750 P_STA_RECORD_T prCliStaRec = (P_STA_RECORD_T)NULL;
751 P_BSS_INFO_T prP2pBssInfo = (P_BSS_INFO_T)NULL;
752 BOOLEAN fgIsStaFound = FALSE;
755 ASSERT_BREAK((prAdapter != NULL) && (pucPeerMacAddr != NULL));
757 prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
759 prCliStaRec = cnmGetStaRecByAddress(prAdapter,
760 NETWORK_TYPE_P2P_INDEX,
763 switch (prP2pBssInfo->eCurrentOPMode) {
764 case OP_MODE_ACCESS_POINT:
766 P_LINK_T prStaRecOfClientList = (P_LINK_T)NULL;
767 P_LINK_ENTRY_T prLinkEntry = (P_LINK_ENTRY_T)NULL;
769 prStaRecOfClientList = &(prP2pBssInfo->rStaRecOfClientList);
771 LINK_FOR_EACH(prLinkEntry, prStaRecOfClientList) {
772 if ((UINT_32)prCliStaRec == (UINT_32)prLinkEntry) {
773 LINK_REMOVE_KNOWN_ENTRY(prStaRecOfClientList, &prCliStaRec->rLinkEntry);
781 case OP_MODE_INFRASTRUCTURE:
782 ASSERT(prCliStaRec == prP2pBssInfo->prStaRecOfAP);
783 if (prCliStaRec != prP2pBssInfo->prStaRecOfAP) {
786 prP2pBssInfo->prStaRecOfAP = NULL;
794 p2pFuncDisconnect(prAdapter, prCliStaRec, fgSendDeauth, u2ReasonCode);
797 rWlanStatus = WLAN_STATUS_SUCCESS;
801 } /* p2pFuncDeauth */
803 // TODO: We do not apply IE in disassoc frame set from upper layer now.
806 IN P_ADAPTER_T prAdapter,
807 IN PUINT_8 pucPeerMacAddr,
808 IN UINT_16 u2ReasonCode,
811 IN BOOLEAN fgSendDisassoc
814 WLAN_STATUS rWlanStatus = WLAN_STATUS_FAILURE;
815 P_STA_RECORD_T prCliStaRec = (P_STA_RECORD_T)NULL;
816 P_BSS_INFO_T prP2pBssInfo = (P_BSS_INFO_T)NULL;
817 BOOLEAN fgIsStaFound = FALSE;
820 ASSERT_BREAK((prAdapter != NULL) && (pucPeerMacAddr != NULL));
822 prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
824 prCliStaRec = cnmGetStaRecByAddress(prAdapter,
825 NETWORK_TYPE_P2P_INDEX,
828 switch (prP2pBssInfo->eCurrentOPMode) {
829 case OP_MODE_ACCESS_POINT:
831 P_LINK_T prStaRecOfClientList = (P_LINK_T)NULL;
832 P_LINK_ENTRY_T prLinkEntry = (P_LINK_ENTRY_T)NULL;
834 prStaRecOfClientList = &(prP2pBssInfo->rStaRecOfClientList);
836 LINK_FOR_EACH(prLinkEntry, prStaRecOfClientList) {
837 if ((UINT_32)prCliStaRec == (UINT_32)prLinkEntry) {
838 LINK_REMOVE_KNOWN_ENTRY(prStaRecOfClientList, &prCliStaRec->rLinkEntry);
840 //p2pFuncDisconnect(prAdapter, prCliStaRec, fgSendDisassoc, u2ReasonCode);
847 case OP_MODE_INFRASTRUCTURE:
848 ASSERT(prCliStaRec == prP2pBssInfo->prStaRecOfAP);
849 if (prCliStaRec != prP2pBssInfo->prStaRecOfAP) {
853 //p2pFuncDisconnect(prAdapter, prCliStaRec, fgSendDisassoc, u2ReasonCode);
854 prP2pBssInfo->prStaRecOfAP = NULL;
863 p2pFuncDisconnect(prAdapter, prCliStaRec, fgSendDisassoc, u2ReasonCode);
864 //20120830 moved into p2pFuncDisconnect().
865 //cnmStaRecFree(prAdapter, prCliStaRec, TRUE);
869 rWlanStatus = WLAN_STATUS_SUCCESS;
873 } /* p2pFuncDisassoc */
875 /*----------------------------------------------------------------------------*/
877 * @brief This function is called to dissolve from group or one group. (Would not change P2P FSM.)
878 * 1. GC: Disconnect from AP. (Send Deauth)
879 * 2. GO: Disconnect all STA
881 * @param[in] prAdapter Pointer to the adapter structure.
885 /*----------------------------------------------------------------------------*/
888 IN P_ADAPTER_T prAdapter,
889 IN P_BSS_INFO_T prP2pBssInfo,
890 IN BOOLEAN fgSendDeauth,
891 IN UINT_16 u2ReasonCode
894 DEBUGFUNC("p2pFuncDissolve()");
898 ASSERT_BREAK((prAdapter != NULL) && (prP2pBssInfo != NULL));
900 switch (prP2pBssInfo->eCurrentOPMode) {
901 case OP_MODE_INFRASTRUCTURE:
902 /* Reset station record status. */
903 if (prP2pBssInfo->prStaRecOfAP) {
904 kalP2PGCIndicateConnectionStatus(prAdapter->prGlueInfo,
908 REASON_CODE_DEAUTH_LEAVING_BSS);
910 // 2012/02/14 frog: After formation before join group, prStaRecOfAP is NULL.
911 p2pFuncDisconnect(prAdapter,
912 prP2pBssInfo->prStaRecOfAP,
917 /* Fix possible KE when RX Beacon & call nicPmIndicateBssConnected(). hit prStaRecOfAP == NULL. */
918 p2pChangeMediaState(prAdapter, PARAM_MEDIA_STATE_DISCONNECTED);
920 prP2pBssInfo->prStaRecOfAP = NULL;
923 case OP_MODE_ACCESS_POINT:
924 /* Under AP mode, we would net send deauthentication frame to each STA.
925 * We only stop the Beacon & let all stations timeout.
928 P_LINK_T prStaRecOfClientList = (P_LINK_T)NULL;
931 authSendDeauthFrame(prAdapter,
935 (PFN_TX_DONE_HANDLER)NULL);
937 prStaRecOfClientList = &prP2pBssInfo->rStaRecOfClientList;
939 while (!LINK_IS_EMPTY(prStaRecOfClientList)) {
940 P_STA_RECORD_T prCurrStaRec;
942 LINK_REMOVE_HEAD(prStaRecOfClientList, prCurrStaRec, P_STA_RECORD_T);
944 /* Indicate to Host. */
945 //kalP2PGOStationUpdate(prAdapter->prGlueInfo, prCurrStaRec, FALSE);
947 p2pFuncDisconnect(prAdapter, prCurrStaRec, TRUE, u2ReasonCode);
955 return; // 20110420 -- alreay in Device Mode.
958 /* Make the deauth frame send to FW ASAP. */
959 wlanAcquirePowerControl(prAdapter);
960 wlanProcessCommandQueue(prAdapter, &prAdapter->prGlueInfo->rCmdQueue);
961 wlanReleasePowerControl(prAdapter);
965 /* Change Connection Status. */
966 p2pChangeMediaState(prAdapter, PARAM_MEDIA_STATE_DISCONNECTED);
971 } /* p2pFuncDissolve */
974 /*----------------------------------------------------------------------------*/
976 * @brief This function is called to dissolve from group or one group. (Would not change P2P FSM.)
977 * 1. GC: Disconnect from AP. (Send Deauth)
978 * 2. GO: Disconnect all STA
980 * @param[in] prAdapter Pointer to the adapter structure.
984 /*----------------------------------------------------------------------------*/
987 IN P_ADAPTER_T prAdapter,
988 IN P_STA_RECORD_T prStaRec,
989 IN BOOLEAN fgSendDeauth,
990 IN UINT_16 u2ReasonCode
993 P_BSS_INFO_T prP2pBssInfo = (P_BSS_INFO_T)NULL;
994 ENUM_PARAM_MEDIA_STATE_T eOriMediaStatus;
996 DBGLOG(P2P, TRACE, ("p2pFuncDisconnect()"));
999 ASSERT_BREAK((prAdapter != NULL) && (prStaRec != NULL));
1001 prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
1002 eOriMediaStatus = prP2pBssInfo->eConnectionState;
1004 /* Indicate disconnect. */
1006 // kalP2PGOStationUpdate
1007 // kalP2PGCIndicateConnectionStatus
1008 //p2pIndicationOfMediaStateToHost(prAdapter, PARAM_MEDIA_STATE_DISCONNECTED, prStaRec->aucMacAddr);
1009 if (prP2pBssInfo->eCurrentOPMode == OP_MODE_ACCESS_POINT) {
1010 kalP2PGOStationUpdate(prAdapter->prGlueInfo, prStaRec, FALSE);
1015 authSendDeauthFrame(prAdapter,
1019 (PFN_TX_DONE_HANDLER)p2pFsmRunEventDeauthTxDone);
1022 /* Change station state. */
1023 cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_1);
1025 /* Reset Station Record Status. */
1026 p2pFuncResetStaRecStatus(prAdapter, prStaRec);
1028 cnmStaRecFree(prAdapter, prStaRec, TRUE);
1030 if ((prP2pBssInfo->eCurrentOPMode != OP_MODE_ACCESS_POINT) ||
1031 (prP2pBssInfo->rStaRecOfClientList.u4NumElem == 0)) {
1032 DBGLOG(P2P, TRACE, ("No More Client, Media Status DISCONNECTED\n"));
1033 p2pChangeMediaState(prAdapter, PARAM_MEDIA_STATE_DISCONNECTED);
1036 if (eOriMediaStatus != prP2pBssInfo->eConnectionState) {
1037 /* Update Disconnected state to FW. */
1038 nicUpdateBss(prAdapter, NETWORK_TYPE_P2P_INDEX);
1043 if (prP2pBssInfo->eCurrentOPMode != OP_MODE_ACCESS_POINT) {
1044 /* GO: It would stop Beacon TX. GC: Stop all BSS related PS function. */
1045 nicPmIndicateBssAbort(prAdapter, NETWORK_TYPE_P2P_INDEX);
1047 /* Reset RLM related field of BSSINFO. */
1048 rlmBssAborted(prAdapter, prP2pBssInfo);
1055 } /* p2pFuncDisconnect */
1063 p2pFuncTxMgmtFrame (
1064 IN P_ADAPTER_T prAdapter,
1065 IN P_P2P_MGMT_TX_REQ_INFO_T prMgmtTxReqInfo,
1066 IN P_MSDU_INFO_T prMgmtTxMsdu,
1070 WLAN_STATUS rWlanStatus = WLAN_STATUS_SUCCESS;
1071 P_MSDU_INFO_T prTxMsduInfo = (P_MSDU_INFO_T)NULL;
1072 P_WLAN_MAC_HEADER_T prWlanHdr = (P_WLAN_MAC_HEADER_T)NULL;
1073 P_STA_RECORD_T prStaRec = (P_STA_RECORD_T)NULL;
1076 ASSERT_BREAK((prAdapter != NULL) && (prMgmtTxReqInfo != NULL));
1078 if (prMgmtTxReqInfo->fgIsMgmtTxRequested) {
1080 // 1. prMgmtTxReqInfo->prMgmtTxMsdu != NULL
1081 /* Packet on driver, not done yet, drop it. */
1082 if ((prTxMsduInfo = prMgmtTxReqInfo->prMgmtTxMsdu) != NULL) {
1084 kalP2PIndicateMgmtTxStatus(prAdapter->prGlueInfo,
1085 prMgmtTxReqInfo->u8Cookie,
1087 prTxMsduInfo->prPacket,
1088 (UINT_32)prTxMsduInfo->u2FrameLength);
1090 // Leave it to TX Done handler.
1091 //cnmMgtPktFree(prAdapter, prTxMsduInfo);
1092 prMgmtTxReqInfo->prMgmtTxMsdu = NULL;
1095 // 2. prMgmtTxReqInfo->prMgmtTxMsdu == NULL
1096 /* Packet transmitted, wait tx done. (cookie issue) */
1097 // 20120105 frog - use another u8cookie to store this value.
1101 ASSERT(prMgmtTxReqInfo->prMgmtTxMsdu == NULL);
1105 prWlanHdr = (P_WLAN_MAC_HEADER_T)((UINT_32)prMgmtTxMsdu->prPacket + MAC_TX_RESERVED_FIELD);
1106 prStaRec = cnmGetStaRecByAddress(prAdapter, NETWORK_TYPE_P2P_INDEX, prWlanHdr->aucAddr1);
1107 prMgmtTxMsdu->ucNetworkType = (UINT_8)NETWORK_TYPE_P2P_INDEX;
1109 switch (prWlanHdr->u2FrameCtrl & MASK_FRAME_TYPE) {
1110 case MAC_FRAME_PROBE_RSP:
1111 prMgmtTxMsdu = p2pFuncProcessP2pProbeRsp(prAdapter, prMgmtTxMsdu);
1118 prMgmtTxReqInfo->u8Cookie = u8Cookie;
1119 prMgmtTxReqInfo->prMgmtTxMsdu = prMgmtTxMsdu;
1120 prMgmtTxReqInfo->fgIsMgmtTxRequested = TRUE;
1122 prMgmtTxMsdu->eSrc = TX_PACKET_MGMT;
1123 prMgmtTxMsdu->ucPacketType = HIF_TX_PACKET_TYPE_MGMT;
1124 prMgmtTxMsdu->ucStaRecIndex = (prStaRec != NULL)?(prStaRec->ucIndex):(0xFF);
1125 if (prStaRec != NULL) {
1126 DBGLOG(P2P, TRACE, ("Mgmt with station record: "MACSTR" .\n", MAC2STR(prStaRec->aucMacAddr)));
1129 prMgmtTxMsdu->ucMacHeaderLength = WLAN_MAC_MGMT_HEADER_LEN; // TODO: undcertain.
1130 prMgmtTxMsdu->fgIs802_1x = FALSE;
1131 prMgmtTxMsdu->fgIs802_11 = TRUE;
1132 prMgmtTxMsdu->ucTxSeqNum = nicIncreaseTxSeqNum(prAdapter);
1133 prMgmtTxMsdu->pfTxDoneHandler = p2pFsmRunEventMgmtFrameTxDone;
1134 prMgmtTxMsdu->fgIsBasicRate = TRUE;
1135 DBGLOG(P2P, TRACE, ("Mgmt seq NO. %d .\n", prMgmtTxMsdu->ucTxSeqNum));
1137 nicTxEnqueueMsdu(prAdapter, prMgmtTxMsdu);
1142 } /* p2pFuncTxMgmtFrame */
1148 IN P_ADAPTER_T prAdapter,
1149 IN P_RF_CHANNEL_INFO_T prRfChannelInfo
1152 P_P2P_CONNECTION_SETTINGS_T prP2pConnSettings = (P_P2P_CONNECTION_SETTINGS_T)NULL;
1155 ASSERT_BREAK((prAdapter != NULL) && (prRfChannelInfo != NULL));
1157 prP2pConnSettings = prAdapter->rWifiVar.prP2PConnSettings;
1159 prP2pConnSettings->ucOperatingChnl = prRfChannelInfo->ucChannelNum;
1160 prP2pConnSettings->eBand = prRfChannelInfo->eBand;
1167 /* p2pFuncSetChannel */
1171 /*----------------------------------------------------------------------------*/
1173 * @brief Retry JOIN for AUTH_MODE_AUTO_SWITCH
1175 * @param[in] prStaRec Pointer to the STA_RECORD_T
1177 * @retval TRUE We will retry JOIN
1178 * @retval FALSE We will not retry JOIN
1180 /*----------------------------------------------------------------------------*/
1183 IN P_ADAPTER_T prAdapter,
1184 IN P_STA_RECORD_T prStaRec,
1185 IN P_P2P_JOIN_INFO_T prJoinInfo
1188 P_MSG_JOIN_REQ_T prJoinReqMsg = (P_MSG_JOIN_REQ_T)NULL;
1189 BOOLEAN fgRetValue = FALSE;
1192 ASSERT_BREAK((prAdapter != NULL) &&
1193 (prStaRec != NULL) &&
1194 (prJoinInfo != NULL));
1196 /* Retry other AuthType if possible */
1197 if (!prJoinInfo->ucAvailableAuthTypes) {
1201 if (prJoinInfo->ucAvailableAuthTypes &
1202 (UINT_8)AUTH_TYPE_SHARED_KEY) {
1204 DBGLOG(P2P, INFO, ("RETRY JOIN INIT: Retry Authentication with AuthType == SHARED_KEY.\n"));
1206 prJoinInfo->ucAvailableAuthTypes &=
1207 ~(UINT_8)AUTH_TYPE_SHARED_KEY;
1209 prStaRec->ucAuthAlgNum = (UINT_8)AUTH_ALGORITHM_NUM_SHARED_KEY;
1212 DBGLOG(P2P, ERROR, ("RETRY JOIN INIT: Retry Authentication with Unexpected AuthType.\n"));
1217 prJoinInfo->ucAvailableAuthTypes = 0; /* No more available Auth Types */
1219 /* Trigger SAA to start JOIN process. */
1220 prJoinReqMsg = (P_MSG_JOIN_REQ_T)cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(MSG_JOIN_REQ_T));
1221 if (!prJoinReqMsg) {
1222 ASSERT(0); // Can't trigger SAA FSM
1226 prJoinReqMsg->rMsgHdr.eMsgId = MID_P2P_SAA_FSM_START;
1227 prJoinReqMsg->ucSeqNum = ++prJoinInfo->ucSeqNumOfReqMsg;
1228 prJoinReqMsg->prStaRec = prStaRec;
1230 mboxSendMsg(prAdapter,
1232 (P_MSG_HDR_T) prJoinReqMsg,
1233 MSG_SEND_METHOD_BUF);
1243 }/* end of p2pFuncRetryJOIN() */
1249 /*----------------------------------------------------------------------------*/
1251 * @brief This function will update the contain of BSS_INFO_T for AIS network once
1252 * the association was completed.
1254 * @param[in] prStaRec Pointer to the STA_RECORD_T
1255 * @param[in] prAssocRspSwRfb Pointer to SW RFB of ASSOC RESP FRAME.
1259 /*----------------------------------------------------------------------------*/
1261 p2pFuncUpdateBssInfoForJOIN (
1262 IN P_ADAPTER_T prAdapter,
1263 IN P_BSS_DESC_T prBssDesc,
1264 IN P_STA_RECORD_T prStaRec,
1265 IN P_SW_RFB_T prAssocRspSwRfb
1268 P_BSS_INFO_T prP2pBssInfo = (P_BSS_INFO_T)NULL;
1269 P_P2P_CONNECTION_SETTINGS_T prP2pConnSettings = (P_P2P_CONNECTION_SETTINGS_T)NULL;
1270 P_WLAN_ASSOC_RSP_FRAME_T prAssocRspFrame = (P_WLAN_ASSOC_RSP_FRAME_T)NULL;
1274 DEBUGFUNC("p2pUpdateBssInfoForJOIN()");
1278 ASSERT(prAssocRspSwRfb);
1280 prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
1281 prP2pConnSettings = prAdapter->rWifiVar.prP2PConnSettings;
1282 prAssocRspFrame = (P_WLAN_ASSOC_RSP_FRAME_T) prAssocRspSwRfb->pvHeader;
1284 DBGLOG(P2P, INFO, ("Update P2P_BSS_INFO_T and apply settings to MAC\n"));
1286 //3 <1> Update BSS_INFO_T from AIS_FSM_INFO_T or User Settings
1287 //4 <1.1> Setup Operation Mode
1288 prP2pBssInfo->eCurrentOPMode = OP_MODE_INFRASTRUCTURE;
1290 //4 <1.2> Setup SSID
1291 COPY_SSID(prP2pBssInfo->aucSSID,
1292 prP2pBssInfo->ucSSIDLen,
1293 prP2pConnSettings->aucSSID,
1294 prP2pConnSettings->ucSSIDLen);
1296 if (prBssDesc == NULL) {
1297 /* Target BSS NULL. */
1298 DBGLOG(P2P, TRACE,("Target BSS NULL\n"));
1303 if (UNEQUAL_MAC_ADDR(prBssDesc->aucBSSID, prAssocRspFrame->aucBSSID)) {
1307 //4 <1.3> Setup Channel, Band
1308 prP2pBssInfo->ucPrimaryChannel = prBssDesc->ucChannelNum;
1309 prP2pBssInfo->eBand = prBssDesc->eBand;
1312 //3 <2> Update BSS_INFO_T from STA_RECORD_T
1313 //4 <2.1> Save current AP's STA_RECORD_T and current AID
1314 prP2pBssInfo->prStaRecOfAP = prStaRec;
1315 prP2pBssInfo->u2AssocId = prStaRec->u2AssocId;
1317 //4 <2.2> Setup Capability
1318 prP2pBssInfo->u2CapInfo = prStaRec->u2CapInfo; /* Use AP's Cap Info as BSS Cap Info */
1320 if (prP2pBssInfo->u2CapInfo & CAP_INFO_SHORT_PREAMBLE) {
1321 prP2pBssInfo->fgIsShortPreambleAllowed = TRUE;
1324 prP2pBssInfo->fgIsShortPreambleAllowed = FALSE;
1327 //4 <2.3> Setup PHY Attributes and Basic Rate Set/Operational Rate Set
1328 prP2pBssInfo->ucPhyTypeSet = prStaRec->ucDesiredPhyTypeSet;
1330 prP2pBssInfo->ucNonHTBasicPhyType = prStaRec->ucNonHTBasicPhyType;
1332 prP2pBssInfo->u2OperationalRateSet = prStaRec->u2OperationalRateSet;
1333 prP2pBssInfo->u2BSSBasicRateSet = prStaRec->u2BSSBasicRateSet;
1336 //3 <3> Update BSS_INFO_T from SW_RFB_T (Association Resp Frame)
1337 //4 <3.1> Setup BSSID
1338 COPY_MAC_ADDR(prP2pBssInfo->aucBSSID, prAssocRspFrame->aucBSSID);
1341 u2IELength = (UINT_16) ((prAssocRspSwRfb->u2PacketLen - prAssocRspSwRfb->u2HeaderLen) -
1342 (OFFSET_OF(WLAN_ASSOC_RSP_FRAME_T, aucInfoElem[0]) - WLAN_MAC_MGMT_HEADER_LEN));
1343 pucIE = prAssocRspFrame->aucInfoElem;
1346 //4 <3.2> Parse WMM and setup QBSS flag
1347 /* Parse WMM related IEs and configure HW CRs accordingly */
1348 mqmProcessAssocRsp(prAdapter, prAssocRspSwRfb, pucIE, u2IELength);
1350 prP2pBssInfo->fgIsQBSS = prStaRec->fgIsQoS;
1352 //3 <4> Update BSS_INFO_T from BSS_DESC_T
1355 prBssDesc->fgIsConnecting = FALSE;
1356 prBssDesc->fgIsConnected = TRUE;
1358 //4 <4.1> Setup MIB for current BSS
1359 prP2pBssInfo->u2BeaconInterval = prBssDesc->u2BeaconInterval;
1360 /* NOTE: Defer ucDTIMPeriod updating to when beacon is received after connection */
1361 prP2pBssInfo->ucDTIMPeriod = 0;
1362 prP2pBssInfo->u2ATIMWindow = 0;
1364 prP2pBssInfo->ucBeaconTimeoutCount = AIS_BEACON_TIMEOUT_COUNT_INFRA;
1366 //4 <4.2> Update HT information and set channel
1367 /* Record HT related parameters in rStaRec and rBssInfo
1368 * Note: it shall be called before nicUpdateBss()
1370 rlmProcessAssocRsp(prAdapter, prAssocRspSwRfb, pucIE, u2IELength);
1372 //4 <4.3> Sync with firmware for BSS-INFO
1373 nicUpdateBss(prAdapter, NETWORK_TYPE_P2P_INDEX);
1375 //4 <4.4> *DEFER OPERATION* nicPmIndicateBssConnected() will be invoked
1376 //inside scanProcessBeaconAndProbeResp() after 1st beacon is received
1379 } /* end of p2pUpdateBssInfoForJOIN() */
1383 /*----------------------------------------------------------------------------*/
1385 * @brief This function will validate the Rx Auth Frame and then return
1386 * the status code to AAA to indicate if need to perform following actions
1387 * when the specified conditions were matched.
1389 * @param[in] prAdapter Pointer to the Adapter structure.
1390 * @param[in] prSwRfb Pointer to SW RFB data structure.
1391 * @param[in] pprStaRec Pointer to pointer of STA_RECORD_T structure.
1392 * @param[out] pu2StatusCode The Status Code of Validation Result
1394 * @retval TRUE Reply the Auth
1395 * @retval FALSE Don't reply the Auth
1397 /*----------------------------------------------------------------------------*/
1399 p2pFuncValidateAuth (
1400 IN P_ADAPTER_T prAdapter,
1401 IN P_SW_RFB_T prSwRfb,
1402 IN PP_STA_RECORD_T pprStaRec,
1403 OUT PUINT_16 pu2StatusCode
1406 BOOLEAN fgReplyAuth = TRUE;
1407 P_BSS_INFO_T prP2pBssInfo = (P_BSS_INFO_T)NULL;
1408 P_STA_RECORD_T prStaRec = (P_STA_RECORD_T)NULL;
1409 P_WLAN_AUTH_FRAME_T prAuthFrame = (P_WLAN_AUTH_FRAME_T)NULL;
1411 DBGLOG(P2P, TRACE, ("p2pValidate Authentication Frame\n"))
1414 ASSERT_BREAK((prAdapter != NULL) &&
1415 (prSwRfb != NULL) &&
1416 (pprStaRec != NULL) &&
1417 (pu2StatusCode != NULL));
1420 *pu2StatusCode = STATUS_CODE_REQ_DECLINED;
1422 prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
1423 prAuthFrame = (P_WLAN_AUTH_FRAME_T)prSwRfb->pvHeader;
1426 if (prP2pBssInfo->eCurrentOPMode != OP_MODE_ACCESS_POINT) {
1427 /* We are not under AP Mode yet. */
1428 fgReplyAuth = FALSE;
1429 DBGLOG(P2P, WARN, ("Current OP mode is not under AP mode. (%d)\n", prP2pBssInfo->eCurrentOPMode));
1433 prStaRec = cnmGetStaRecByAddress(prAdapter,
1434 (UINT_8) NETWORK_TYPE_P2P_INDEX,
1435 prAuthFrame->aucSrcAddr);
1438 prStaRec = cnmStaRecAlloc(prAdapter,
1439 (UINT_8) NETWORK_TYPE_P2P_INDEX);
1441 /* TODO(Kevin): Error handling of allocation of STA_RECORD_T for
1442 * exhausted case and do removal of unused STA_RECORD_T.
1444 /* Sent a message event to clean un-used STA_RECORD_T. */
1447 COPY_MAC_ADDR(prStaRec->aucMacAddr, prAuthFrame->aucSrcAddr);
1449 prSwRfb->ucStaRecIdx = prStaRec->ucIndex;
1451 prStaRec->u2BSSBasicRateSet = prP2pBssInfo->u2BSSBasicRateSet;
1453 prStaRec->u2DesiredNonHTRateSet = RATE_SET_ERP_P2P;
1455 prStaRec->u2OperationalRateSet = RATE_SET_ERP_P2P;
1456 prStaRec->ucPhyTypeSet = PHY_TYPE_SET_802_11GN;
1457 prStaRec->eStaType = STA_TYPE_P2P_GC;
1459 /* NOTE(Kevin): Better to change state here, not at TX Done */
1460 cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_1);
1463 prSwRfb->ucStaRecIdx = prStaRec->ucIndex;
1465 if ((prStaRec->ucStaState > STA_STATE_1) && (IS_STA_IN_P2P(prStaRec))) {
1467 cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_1);
1469 p2pFuncResetStaRecStatus(prAdapter, prStaRec);
1471 bssRemoveStaRecFromClientList(prAdapter, prP2pBssInfo, prStaRec);
1476 if (prP2pBssInfo->rStaRecOfClientList.u4NumElem >= P2P_MAXIMUM_CLIENT_COUNT ||
1477 kalP2PMaxClients(prAdapter->prGlueInfo, prP2pBssInfo->rStaRecOfClientList.u4NumElem)) {
1478 /* GROUP limit full. */
1480 DBGLOG(P2P, WARN, ("Group Limit Full. (%d)\n", (INT_16)prP2pBssInfo->rStaRecOfClientList.u4NumElem));
1481 cnmStaRecFree(prAdapter, prStaRec, FALSE);
1485 /* Hotspot Blacklist */
1486 if(prAuthFrame->aucSrcAddr) {
1487 if(kalP2PCmpBlackList(prAdapter->prGlueInfo, prAuthFrame->aucSrcAddr)) {
1488 fgReplyAuth = FALSE;
1494 //prStaRec->eStaType = STA_TYPE_INFRA_CLIENT;
1495 prStaRec->eStaType = STA_TYPE_P2P_GC;
1497 prStaRec->ucNetTypeIndex = NETWORK_TYPE_P2P_INDEX;
1499 /* Update Station Record - Status/Reason Code */
1500 prStaRec->u2StatusCode = STATUS_CODE_SUCCESSFUL;
1502 prStaRec->ucJoinFailureCount = 0;
1504 *pprStaRec = prStaRec;
1506 *pu2StatusCode = STATUS_CODE_SUCCESSFUL;
1513 } /* p2pFuncValidateAuth */
1519 p2pFuncResetStaRecStatus (
1520 IN P_ADAPTER_T prAdapter,
1521 IN P_STA_RECORD_T prStaRec
1525 if ((prAdapter == NULL) || (prStaRec == NULL)) {
1531 prStaRec->u2StatusCode = STATUS_CODE_SUCCESSFUL;
1532 prStaRec->u2ReasonCode = REASON_CODE_RESERVED;
1533 prStaRec->ucJoinFailureCount = 0;
1534 prStaRec->fgTransmitKeyExist = FALSE;
1536 prStaRec->fgSetPwrMgtBit = FALSE;
1541 } /* p2pFuncResetStaRecStatus */
1545 /*----------------------------------------------------------------------------*/
1547 * @brief The function is used to initialize the value of the connection settings for
1554 /*----------------------------------------------------------------------------*/
1556 p2pFuncInitConnectionSettings (
1557 IN P_ADAPTER_T prAdapter,
1558 IN P_P2P_CONNECTION_SETTINGS_T prP2PConnSettings
1561 P_DEVICE_TYPE_T prDevType;
1562 UINT_8 aucDefaultDevName[] = P2P_DEFAULT_DEV_NAME;
1563 UINT_8 aucWfaOui[] = VENDOR_OUI_WFA;
1565 ASSERT(prP2PConnSettings);
1567 /* Setup Default Device Name */
1568 prP2PConnSettings->ucDevNameLen = P2P_DEFAULT_DEV_NAME_LEN;
1569 kalMemCopy(prP2PConnSettings->aucDevName, aucDefaultDevName, sizeof(aucDefaultDevName));
1571 /* Setup Primary Device Type (Big-Endian) */
1572 prDevType = &prP2PConnSettings->rPrimaryDevTypeBE;
1574 prDevType->u2CategoryId = HTONS(P2P_DEFAULT_PRIMARY_CATEGORY_ID);
1575 prDevType->u2SubCategoryId = HTONS(P2P_DEFAULT_PRIMARY_SUB_CATEGORY_ID);
1577 prDevType->aucOui[0] = aucWfaOui[0];
1578 prDevType->aucOui[1] = aucWfaOui[1];
1579 prDevType->aucOui[2] = aucWfaOui[2];
1580 prDevType->aucOui[3] = VENDOR_OUI_TYPE_WPS;
1582 /* Setup Secondary Device Type */
1583 prP2PConnSettings->ucSecondaryDevTypeCount = 0;
1585 /* Setup Default Config Method */
1586 prP2PConnSettings->eConfigMethodSelType = ENUM_CONFIG_METHOD_SEL_AUTO;
1587 prP2PConnSettings->u2ConfigMethodsSupport = P2P_DEFAULT_CONFIG_METHOD;
1588 prP2PConnSettings->u2TargetConfigMethod = 0;
1589 prP2PConnSettings->u2LocalConfigMethod = 0;
1590 prP2PConnSettings->fgIsPasswordIDRdy = FALSE;
1592 /* For Device Capability */
1593 prP2PConnSettings->fgSupportServiceDiscovery = FALSE;
1594 prP2PConnSettings->fgSupportClientDiscoverability = TRUE;
1595 prP2PConnSettings->fgSupportConcurrentOperation = TRUE;
1596 prP2PConnSettings->fgSupportInfraManaged = FALSE;
1597 prP2PConnSettings->fgSupportInvitationProcedure = FALSE;
1599 /* For Group Capability */
1600 #if CFG_SUPPORT_PERSISTENT_GROUP
1601 prP2PConnSettings->fgSupportPersistentP2PGroup = TRUE;
1603 prP2PConnSettings->fgSupportPersistentP2PGroup = FALSE;
1605 prP2PConnSettings->fgSupportIntraBSSDistribution = TRUE;
1606 prP2PConnSettings->fgSupportCrossConnection = TRUE;
1607 prP2PConnSettings->fgSupportPersistentReconnect = FALSE;
1609 prP2PConnSettings->fgSupportOppPS = FALSE;
1610 prP2PConnSettings->u2CTWindow = P2P_CTWINDOW_DEFAULT;
1612 /* For Connection Settings. */
1613 prP2PConnSettings->eAuthMode = AUTH_MODE_OPEN;
1615 prP2PConnSettings->prTargetP2pDesc = NULL;
1616 prP2PConnSettings->ucSSIDLen = 0;
1619 prP2PConnSettings->fgIsScanReqIssued = FALSE;
1620 prP2PConnSettings->fgIsServiceDiscoverIssued = FALSE;
1621 prP2PConnSettings->fgP2pGroupLimit = FALSE;
1622 prP2PConnSettings->ucOperatingChnl = 0;
1623 prP2PConnSettings->ucListenChnl = 0;
1624 prP2PConnSettings->ucTieBreaker = (UINT_8)(kalRandomNumber() & 0x1);
1626 prP2PConnSettings->eFormationPolicy = ENUM_P2P_FORMATION_POLICY_AUTO;
1629 } /* p2pFuncInitConnectionSettings */
1635 /*----------------------------------------------------------------------------*/
1637 * @brief This function will validate the Rx Assoc Req Frame and then return
1638 * the status code to AAA to indicate if need to perform following actions
1639 * when the specified conditions were matched.
1641 * @param[in] prAdapter Pointer to the Adapter structure.
1642 * @param[in] prSwRfb Pointer to SW RFB data structure.
1643 * @param[out] pu2StatusCode The Status Code of Validation Result
1645 * @retval TRUE Reply the Assoc Resp
1646 * @retval FALSE Don't reply the Assoc Resp
1648 /*----------------------------------------------------------------------------*/
1650 p2pFuncValidateAssocReq (
1651 IN P_ADAPTER_T prAdapter,
1652 IN P_SW_RFB_T prSwRfb,
1653 OUT PUINT_16 pu2StatusCode
1656 BOOLEAN fgReplyAssocResp = TRUE;
1657 P_WLAN_ASSOC_REQ_FRAME_T prAssocReqFrame = (P_WLAN_ASSOC_REQ_FRAME_T)NULL;
1658 P_STA_RECORD_T prStaRec = (P_STA_RECORD_T)NULL;
1659 P_BSS_INFO_T prP2pBssInfo = (P_BSS_INFO_T)NULL;
1661 /* TODO(Kevin): Call P2P functions to check ..
1662 2. Check we can accept connection from thsi peer
1663 a. If we are in PROVISION state, only accept the peer we do the GO formation previously.
1664 b. If we are in OPERATION state, only accept the other peer when P2P_GROUP_LIMIT is 0.
1665 3. Check Black List here.
1669 ASSERT_BREAK((prAdapter != NULL) &&
1670 (prSwRfb != NULL) &&
1671 (pu2StatusCode != NULL));
1673 *pu2StatusCode = STATUS_CODE_REQ_DECLINED;
1674 prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
1675 prAssocReqFrame = (P_WLAN_ASSOC_REQ_FRAME_T)prSwRfb->pvHeader;
1677 prStaRec = cnmGetStaRecByIndex(prAdapter, prSwRfb->ucStaRecIdx);
1679 if (prStaRec == NULL) {
1680 /* Station record should be ready while RX AUTH frame. */
1681 fgReplyAssocResp = FALSE;
1686 prStaRec->ucRCPI = prSwRfb->prHifRxHdr->ucRcpi;
1689 prStaRec->u2DesiredNonHTRateSet &= prP2pBssInfo->u2OperationalRateSet;
1690 prStaRec->ucDesiredPhyTypeSet = prStaRec->ucPhyTypeSet & prP2pBssInfo->ucPhyTypeSet;
1692 if (prStaRec->ucDesiredPhyTypeSet == 0) {
1693 /* The station only support 11B rate. */
1694 *pu2StatusCode = STATUS_CODE_ASSOC_DENIED_RATE_NOT_SUPPORTED;
1698 *pu2StatusCode = STATUS_CODE_SUCCESSFUL;
1702 return fgReplyAssocResp;
1704 } /* p2pFuncValidateAssocReq */
1709 /*----------------------------------------------------------------------------*/
1711 * @brief This function is used to check the P2P IE
1716 /*----------------------------------------------------------------------------*/
1718 p2pFuncParseCheckForP2PInfoElem (
1719 IN P_ADAPTER_T prAdapter,
1721 OUT PUINT_8 pucOuiType
1724 UINT_8 aucWfaOui[] = VENDOR_OUI_WFA_SPECIFIC;
1725 P_IE_WFA_T prWfaIE = (P_IE_WFA_T)NULL;
1728 ASSERT_BREAK((prAdapter != NULL) && (pucBuf != NULL) && (pucOuiType != NULL));
1730 prWfaIE = (P_IE_WFA_T)pucBuf;
1732 if (IE_LEN(pucBuf) <= ELEM_MIN_LEN_WFA_OUI_TYPE_SUBTYPE) {
1735 else if (prWfaIE->aucOui[0] != aucWfaOui[0] ||
1736 prWfaIE->aucOui[1] != aucWfaOui[1] ||
1737 prWfaIE->aucOui[2] != aucWfaOui[2]) {
1741 *pucOuiType = prWfaIE->ucOuiType;
1747 } /* p2pFuncParseCheckForP2PInfoElem */
1752 /*----------------------------------------------------------------------------*/
1754 * @brief This function will validate the Rx Probe Request Frame and then return
1755 * result to BSS to indicate if need to send the corresponding Probe Response
1756 * Frame if the specified conditions were matched.
1758 * @param[in] prAdapter Pointer to the Adapter structure.
1759 * @param[in] prSwRfb Pointer to SW RFB data structure.
1760 * @param[out] pu4ControlFlags Control flags for replying the Probe Response
1762 * @retval TRUE Reply the Probe Response
1763 * @retval FALSE Don't reply the Probe Response
1765 /*----------------------------------------------------------------------------*/
1767 p2pFuncValidateProbeReq (
1768 IN P_ADAPTER_T prAdapter,
1769 IN P_SW_RFB_T prSwRfb,
1770 OUT PUINT_32 pu4ControlFlags
1773 BOOLEAN fgIsReplyProbeRsp = FALSE;
1774 P_P2P_FSM_INFO_T prP2pFsmInfo = (P_P2P_FSM_INFO_T)NULL;
1776 DEBUGFUNC("p2pFuncValidateProbeReq");
1780 ASSERT_BREAK((prAdapter != NULL) && (prSwRfb != NULL));
1782 prP2pFsmInfo = prAdapter->rWifiVar.prP2pFsmInfo;
1784 if (prP2pFsmInfo->u4P2pPacketFilter & PARAM_PACKET_FILTER_PROBE_REQ) {
1785 /* Leave the probe response to p2p_supplicant. */
1786 kalP2PIndicateRxMgmtFrame(prAdapter->prGlueInfo, prSwRfb);
1791 return fgIsReplyProbeRsp;
1793 } /* end of p2pFuncValidateProbeReq() */
1797 /*----------------------------------------------------------------------------*/
1799 * @brief This function will validate the Rx Probe Request Frame and then return
1800 * result to BSS to indicate if need to send the corresponding Probe Response
1801 * Frame if the specified conditions were matched.
1803 * @param[in] prAdapter Pointer to the Adapter structure.
1804 * @param[in] prSwRfb Pointer to SW RFB data structure.
1805 * @param[out] pu4ControlFlags Control flags for replying the Probe Response
1807 * @retval TRUE Reply the Probe Response
1808 * @retval FALSE Don't reply the Probe Response
1810 /*----------------------------------------------------------------------------*/
1812 p2pFuncValidateRxActionFrame (
1813 IN P_ADAPTER_T prAdapter,
1814 IN P_SW_RFB_T prSwRfb
1817 P_P2P_FSM_INFO_T prP2pFsmInfo = (P_P2P_FSM_INFO_T)NULL;
1819 DEBUGFUNC("p2pFuncValidateProbeReq");
1823 ASSERT_BREAK((prAdapter != NULL) && (prSwRfb != NULL));
1825 prP2pFsmInfo = prAdapter->rWifiVar.prP2pFsmInfo;
1827 if (prP2pFsmInfo->u4P2pPacketFilter & PARAM_PACKET_FILTER_ACTION_FRAME) {
1828 /* Leave the probe response to p2p_supplicant. */
1829 kalP2PIndicateRxMgmtFrame(prAdapter->prGlueInfo, prSwRfb);
1836 } /* p2pFuncValidateRxMgmtFrame */
1843 IN P_P2P_FSM_INFO_T prP2pFsmInfo
1847 return prP2pFsmInfo->fgIsApMode;
1853 /* p2pFuncIsAPMode */
1858 p2pFuncParseBeaconContent (
1859 IN P_ADAPTER_T prAdapter,
1860 IN P_BSS_INFO_T prP2pBssInfo,
1861 IN PUINT_8 pucIEInfo,
1865 PUINT_8 pucIE = (PUINT_8)NULL;
1866 UINT_16 u2Offset = 0;
1867 P_P2P_SPECIFIC_BSS_INFO_T prP2pSpecificBssInfo = (P_P2P_SPECIFIC_BSS_INFO_T)NULL;
1868 BOOL ucNewSecMode = FALSE;
1869 BOOL ucOldSecMode = FALSE;
1872 ASSERT_BREAK((prAdapter != NULL) &&
1873 (prP2pBssInfo != NULL));
1879 prP2pSpecificBssInfo = prAdapter->rWifiVar.prP2pSpecificBssInfo;
1880 prP2pSpecificBssInfo->u2AttributeLen = 0;
1882 ASSERT_BREAK(pucIEInfo != NULL);
1886 ucOldSecMode = kalP2PGetCipher(prAdapter->prGlueInfo);
1888 IE_FOR_EACH(pucIE, u4IELen, u2Offset) {
1889 switch (IE_ID(pucIE)) {
1890 case ELEM_ID_SSID: /* 0 */ /* V */ /* Done */
1892 DBGLOG(P2P, TRACE, ("SSID update\n"));
1894 /* Update when starting GO. */
1895 COPY_SSID(prP2pBssInfo->aucSSID,
1896 prP2pBssInfo->ucSSIDLen,
1897 SSID_IE(pucIE)->aucSSID,
1898 SSID_IE(pucIE)->ucLength);
1900 COPY_SSID(prP2pSpecificBssInfo->aucGroupSsid,
1901 prP2pSpecificBssInfo->u2GroupSsidLen,
1902 SSID_IE(pucIE)->aucSSID,
1903 SSID_IE(pucIE)->ucLength);
1907 case ELEM_ID_SUP_RATES: /* 1 */ /* V */ /* Done */
1909 DBGLOG(P2P, TRACE, ("Support Rate IE\n"));
1910 kalMemCopy(prP2pBssInfo->aucAllSupportedRates,
1911 SUP_RATES_IE(pucIE)->aucSupportedRates,
1912 SUP_RATES_IE(pucIE)->ucLength);
1914 prP2pBssInfo->ucAllSupportedRatesLen = SUP_RATES_IE(pucIE)->ucLength;
1916 DBGLOG_MEM8(P2P, TRACE, SUP_RATES_IE(pucIE)->aucSupportedRates, SUP_RATES_IE(pucIE)->ucLength);
1919 case ELEM_ID_DS_PARAM_SET: /* 3 */ /* V */ /* Done */
1921 P_P2P_CONNECTION_SETTINGS_T prP2pConnSettings = prAdapter->rWifiVar.prP2PConnSettings;
1923 DBGLOG(P2P, TRACE, ("DS PARAM IE\n"));
1925 ASSERT(prP2pConnSettings->ucOperatingChnl == DS_PARAM_IE(pucIE)->ucCurrChnl);
1927 if (prP2pConnSettings->eBand != BAND_2G4) {
1932 //prP2pBssInfo->ucPrimaryChannel = DS_PARAM_IE(pucIE)->ucCurrChnl;
1934 //prP2pBssInfo->eBand = BAND_2G4;
1937 case ELEM_ID_TIM: /* 5 */ /* V */
1938 DBGLOG(P2P, TRACE, ("TIM IE\n"));
1939 TIM_IE(pucIE)->ucDTIMPeriod = prP2pBssInfo->ucDTIMPeriod;
1941 case ELEM_ID_ERP_INFO: /* 42 */ /* V */
1944 /* This IE would dynamic change due to FW detection change is required. */
1945 DBGLOG(P2P, TRACE, ("ERP IE will be over write by driver\n"));
1946 DBGLOG(P2P, TRACE, (" ucERP: %x. \n", ERP_INFO_IE(pucIE)->ucERP));
1949 /* This IE would dynamic change due to FW detection change is required. */
1950 DBGLOG(P2P, TRACE, ("ERP IE.\n"));
1952 prP2pBssInfo->ucPhyTypeSet |= PHY_TYPE_SET_802_11GN;
1954 ASSERT(prP2pBssInfo->eBand == BAND_2G4);
1956 prP2pBssInfo->fgObssErpProtectMode = ((ERP_INFO_IE(pucIE)->ucERP & ERP_INFO_USE_PROTECTION)? TRUE : FALSE);
1958 prP2pBssInfo->fgErpProtectMode = ((ERP_INFO_IE(pucIE)->ucERP & (ERP_INFO_USE_PROTECTION | ERP_INFO_NON_ERP_PRESENT))? TRUE : FALSE);
1963 case ELEM_ID_HT_CAP: /* 45 */ /* V */
1966 DBGLOG(P2P, TRACE, ("HT CAP IE would be overwritten by driver\n"));
1968 DBGLOG(P2P, TRACE, ("HT Cap Info:%x, AMPDU Param:%x\n", HT_CAP_IE(pucIE)->u2HtCapInfo, HT_CAP_IE(pucIE)->ucAmpduParam));
1970 DBGLOG(P2P, TRACE, ("HT Extended Cap Info:%x, TX Beamforming Cap Info:%lx, Ant Selection Cap Info%x \n",
1971 HT_CAP_IE(pucIE)->u2HtExtendedCap,
1972 HT_CAP_IE(pucIE)->u4TxBeamformingCap,
1973 HT_CAP_IE(pucIE)->ucAselCap));
1975 prP2pBssInfo->ucPhyTypeSet |= PHY_TYPE_SET_802_11N;
1978 if ((HT_CAP_IE(pucIE)->u2HtCapInfo &
1979 (HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_DSSS_CCK_IN_40M)) == 0) {
1980 prP2pBssInfo->fgAssoc40mBwAllowed = FALSE;
1983 prP2pBssInfo->fgAssoc40mBwAllowed = TRUE;
1986 if ((HT_CAP_IE(pucIE)->u2HtCapInfo &
1987 (HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_SHORT_GI_40M)) == 0) {
1988 prAdapter->rWifiVar.rConnSettings.fgRxShortGIDisabled = TRUE;
1991 prAdapter->rWifiVar.rConnSettings.fgRxShortGIDisabled = FALSE;
1995 DBGLOG(P2P, TRACE, ("AMPDU setting from supplicant:0x%x, & default value:0x%x\n", (UINT_8)HT_CAP_IE(pucIE)->ucAmpduParam, (UINT_8)AMPDU_PARAM_DEFAULT_VAL));
1998 /* Can do nothing. the field is default value from other configuration. */
1999 //HT_CAP_IE(pucIE)->rSupMcsSet;
2001 /* u2HtExtendedCap */
2002 ASSERT(HT_CAP_IE(pucIE)->u2HtExtendedCap == (HT_EXT_CAP_DEFAULT_VAL & ~(HT_EXT_CAP_PCO | HT_EXT_CAP_PCO_TRANS_TIME_NONE)));
2004 /* u4TxBeamformingCap */
2005 ASSERT(HT_CAP_IE(pucIE)->u4TxBeamformingCap == TX_BEAMFORMING_CAP_DEFAULT_VAL);
2008 ASSERT(HT_CAP_IE(pucIE)->ucAselCap == ASEL_CAP_DEFAULT_VAL);
2012 case ELEM_ID_RSN: /* 48 */ /* V */
2016 DBGLOG(P2P, TRACE, ("RSN IE\n"));
2017 kalP2PSetCipher(prAdapter->prGlueInfo, IW_AUTH_CIPHER_CCMP);
2018 ucNewSecMode = TRUE;
2020 if (rsnParseRsnIE(prAdapter, RSN_IE(pucIE), &rRsnIe)) {
2021 prP2pBssInfo = &prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX];
2022 prP2pBssInfo->u4RsnSelectedGroupCipher = RSN_CIPHER_SUITE_CCMP;
2023 prP2pBssInfo->u4RsnSelectedPairwiseCipher = RSN_CIPHER_SUITE_CCMP;
2024 prP2pBssInfo->u4RsnSelectedAKMSuite = RSN_AKM_SUITE_PSK;
2025 prP2pBssInfo->u2RsnSelectedCapInfo = rRsnIe.u2RsnCap;
2029 case ELEM_ID_EXTENDED_SUP_RATES: /* 50 */ /* V */
2030 /* Be attention, ELEM_ID_SUP_RATES should be placed before ELEM_ID_EXTENDED_SUP_RATES. */
2031 DBGLOG(P2P, TRACE, ("Ex Support Rate IE\n"));
2032 kalMemCopy(&(prP2pBssInfo->aucAllSupportedRates[prP2pBssInfo->ucAllSupportedRatesLen]),
2033 EXT_SUP_RATES_IE(pucIE)->aucExtSupportedRates,
2034 EXT_SUP_RATES_IE(pucIE)->ucLength);
2036 DBGLOG_MEM8(P2P, TRACE, EXT_SUP_RATES_IE(pucIE)->aucExtSupportedRates, EXT_SUP_RATES_IE(pucIE)->ucLength);
2038 prP2pBssInfo->ucAllSupportedRatesLen += EXT_SUP_RATES_IE(pucIE)->ucLength;
2040 case ELEM_ID_HT_OP: /* 61 */ /* V */ // TODO:
2043 DBGLOG(P2P, TRACE, ("HT OP IE would be overwritten by driver\n"));
2045 DBGLOG(P2P, TRACE, (" Primary Channel: %x, Info1: %x, Info2: %x, Info3: %x\n",
2046 HT_OP_IE(pucIE)->ucPrimaryChannel,
2047 HT_OP_IE(pucIE)->ucInfo1,
2048 HT_OP_IE(pucIE)->u2Info2,
2049 HT_OP_IE(pucIE)->u2Info3));
2051 UINT_16 u2Info2 = 0;
2052 prP2pBssInfo->ucPhyTypeSet |= PHY_TYPE_SET_802_11N;
2054 DBGLOG(P2P, TRACE, ("HT OP IE\n"));
2056 /* ucPrimaryChannel. */
2057 ASSERT(HT_OP_IE(pucIE)->ucPrimaryChannel == prP2pBssInfo->ucPrimaryChannel);
2060 prP2pBssInfo->ucHtOpInfo1 = HT_OP_IE(pucIE)->ucInfo1;
2063 u2Info2 = HT_OP_IE(pucIE)->u2Info2;
2065 if (u2Info2 & HT_OP_INFO2_NON_GF_HT_STA_PRESENT) {
2066 ASSERT(prP2pBssInfo->eGfOperationMode != GF_MODE_NORMAL);
2067 u2Info2 &= ~HT_OP_INFO2_NON_GF_HT_STA_PRESENT;
2070 if (u2Info2 & HT_OP_INFO2_OBSS_NON_HT_STA_PRESENT) {
2071 prP2pBssInfo->eObssHtProtectMode = HT_PROTECT_MODE_NON_MEMBER;
2072 u2Info2 &= ~HT_OP_INFO2_OBSS_NON_HT_STA_PRESENT;
2075 switch (u2Info2 & HT_OP_INFO2_HT_PROTECTION) {
2076 case HT_PROTECT_MODE_NON_HT:
2077 prP2pBssInfo->eHtProtectMode = HT_PROTECT_MODE_NON_HT;
2079 case HT_PROTECT_MODE_NON_MEMBER:
2080 prP2pBssInfo->eHtProtectMode = HT_PROTECT_MODE_NONE;
2081 prP2pBssInfo->eObssHtProtectMode = HT_PROTECT_MODE_NON_MEMBER;
2084 prP2pBssInfo->eHtProtectMode = HT_OP_IE(pucIE)->u2Info2;
2089 prP2pBssInfo->u2HtOpInfo3 = HT_OP_IE(pucIE)->u2Info3;
2091 /* aucBasicMcsSet */
2092 DBGLOG_MEM8(P2P, TRACE, HT_OP_IE(pucIE)->aucBasicMcsSet, 16);
2096 case ELEM_ID_OBSS_SCAN_PARAMS: /* 74 */ /* V */
2098 DBGLOG(P2P, TRACE, ("ELEM_ID_OBSS_SCAN_PARAMS IE would be replaced by driver\n"));
2101 case ELEM_ID_EXTENDED_CAP: /* 127 */ /* V */
2103 DBGLOG(P2P, TRACE, ("ELEM_ID_EXTENDED_CAP IE would be replaced by driver\n"));
2106 case ELEM_ID_VENDOR: /* 221 */ /* V */
2107 DBGLOG(P2P, TRACE, ("Vender Specific IE\n"));
2110 UINT_16 u2SubTypeVersion;
2111 if (rsnParseCheckForWFAInfoElem(prAdapter, pucIE, &ucOuiType, &u2SubTypeVersion)) {
2112 if ((ucOuiType == VENDOR_OUI_TYPE_WPA) &&
2113 (u2SubTypeVersion == VERSION_WPA)) {
2114 kalP2PSetCipher(prAdapter->prGlueInfo, IW_AUTH_CIPHER_TKIP);
2115 ucNewSecMode = TRUE;
2117 else if ((ucOuiType == VENDOR_OUI_TYPE_WPS)) {
2118 kalP2PUpdateWSC_IE(prAdapter->prGlueInfo, 0, pucIE, IE_SIZE(pucIE));
2123 else if (p2pFuncParseCheckForP2PInfoElem(prAdapter, pucIE, &ucOuiType)) {
2124 // TODO Store the whole P2P IE & generate later.
2125 // Be aware that there may be one or more P2P IE.
2126 if (ucOuiType == VENDOR_OUI_TYPE_P2P) {
2127 kalMemCopy(&prP2pSpecificBssInfo->aucAttributesCache[prP2pSpecificBssInfo->u2AttributeLen],
2131 prP2pSpecificBssInfo->u2AttributeLen += IE_SIZE(pucIE);
2136 kalMemCopy(&prP2pSpecificBssInfo->aucAttributesCache[prP2pSpecificBssInfo->u2AttributeLen],
2140 prP2pSpecificBssInfo->u2AttributeLen += IE_SIZE(pucIE);
2141 DBGLOG(P2P, TRACE, ("Driver unprocessed Vender Specific IE\n"));
2145 // TODO: Store other Vender IE except for WMM Param.
2149 DBGLOG(P2P, TRACE, ("Unprocessed element ID:%d \n", IE_ID(pucIE)));
2154 if (!ucNewSecMode && ucOldSecMode)
2155 kalP2PSetCipher(prAdapter->prGlueInfo, IW_AUTH_CIPHER_NONE);
2160 } /* p2pFuncParseBeaconContent */
2166 p2pFuncKeepOnConnection (
2167 IN P_ADAPTER_T prAdapter,
2168 IN P_P2P_CONNECTION_REQ_INFO_T prConnReqInfo,
2169 IN P_P2P_CHNL_REQ_INFO_T prChnlReqInfo,
2170 IN P_P2P_SCAN_REQ_INFO_T prScanReqInfo
2173 P_BSS_DESC_T prTargetBss = (P_BSS_DESC_T)NULL;
2174 P_BSS_INFO_T prP2pBssInfo = (P_BSS_INFO_T)NULL;
2177 ASSERT_BREAK((prAdapter != NULL) &&
2178 (prConnReqInfo != NULL) &&
2179 (prChnlReqInfo != NULL) &&
2180 (prScanReqInfo != NULL));
2182 prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
2184 if (prP2pBssInfo->eCurrentOPMode != OP_MODE_INFRASTRUCTURE) {
2188 // Update connection request information.
2189 ASSERT(prConnReqInfo->fgIsConnRequest == TRUE);
2191 /* Find BSS Descriptor first. */
2192 prTargetBss = scanP2pSearchDesc(prAdapter,
2196 if (prTargetBss == NULL) {
2197 /* Update scan parameter... to scan target device. */
2198 prScanReqInfo->ucNumChannelList = 1;
2199 prScanReqInfo->eScanType = SCAN_TYPE_ACTIVE_SCAN;
2200 prScanReqInfo->eChannelSet = SCAN_CHANNEL_FULL;
2201 prScanReqInfo->u4BufLength = 0; /* Prevent other P2P ID in IE. */
2202 prScanReqInfo->fgIsAbort = TRUE;
2205 prChnlReqInfo->u8Cookie = 0;
2206 prChnlReqInfo->ucReqChnlNum = prTargetBss->ucChannelNum;
2207 prChnlReqInfo->eBand = prTargetBss->eBand;
2208 prChnlReqInfo->eChnlSco = prTargetBss->eSco;
2209 prChnlReqInfo->u4MaxInterval = AIS_JOIN_CH_REQUEST_INTERVAL;
2210 prChnlReqInfo->eChannelReqType = CHANNEL_REQ_TYPE_GC_JOIN_REQ;
2216 } /* p2pFuncKeepOnConnection */
2218 /* Currently Only for ASSOC Response Frame. */
2220 p2pFuncStoreAssocRspIEBuffer (
2221 IN P_ADAPTER_T prAdapter,
2222 IN P_SW_RFB_T prSwRfb
2225 P_P2P_FSM_INFO_T prP2pFsmInfo = (P_P2P_FSM_INFO_T)NULL;
2226 P_P2P_JOIN_INFO_T prJoinInfo = (P_P2P_JOIN_INFO_T)NULL;
2227 P_WLAN_ASSOC_RSP_FRAME_T prAssocRspFrame = (P_WLAN_ASSOC_RSP_FRAME_T)NULL;
2231 ASSERT_BREAK((prAdapter != NULL) && (prSwRfb != NULL));
2233 prAssocRspFrame = (P_WLAN_ASSOC_RSP_FRAME_T)prSwRfb->pvHeader;
2235 if (prAssocRspFrame->u2FrameCtrl != MAC_FRAME_ASSOC_RSP) {
2239 i2IELen = prSwRfb->u2PacketLen - (WLAN_MAC_HEADER_LEN +
2240 CAP_INFO_FIELD_LEN +
2241 STATUS_CODE_FIELD_LEN +
2249 prP2pFsmInfo = prAdapter->rWifiVar.prP2pFsmInfo;
2250 prJoinInfo = &(prP2pFsmInfo->rJoinInfo);
2251 prJoinInfo->u4BufLength = (UINT_32)i2IELen;
2253 kalMemCopy(prJoinInfo->aucIEBuf, prAssocRspFrame->aucInfoElem, prJoinInfo->u4BufLength);
2259 } /* p2pFuncStoreAssocRspIEBuffer */
2264 /*----------------------------------------------------------------------------*/
2266 * \brief This routine is called to set Packet Filter.
2268 * \param[in] prAdapter Pointer to the Adapter structure.
2269 * \param[in] pvSetBuffer Pointer to the buffer that holds the data to be set.
2270 * \param[in] u4SetBufferLen The length of the set buffer.
2271 * \param[out] pu4SetInfoLen If the call is successful, returns the number of
2272 * bytes read from the set buffer. If the call failed
2273 * due to invalid length of the set buffer, returns
2274 * the amount of storage needed.
2276 * \retval WLAN_STATUS_SUCCESS
2277 * \retval WLAN_STATUS_INVALID_LENGTH
2278 * \retval WLAN_STATUS_NOT_SUPPORTED
2279 * \retval WLAN_STATUS_ADAPTER_NOT_READY
2281 /*----------------------------------------------------------------------------*/
2283 p2pFuncMgmtFrameRegister (
2284 IN P_ADAPTER_T prAdapter,
2285 IN UINT_16 u2FrameType,
2286 IN BOOLEAN fgIsRegistered,
2287 OUT PUINT_32 pu4P2pPacketFilter
2290 UINT_32 u4NewPacketFilter = 0;
2292 DEBUGFUNC("p2pFuncMgmtFrameRegister");
2295 ASSERT_BREAK(prAdapter != NULL);
2297 if (pu4P2pPacketFilter) {
2298 u4NewPacketFilter = *pu4P2pPacketFilter;
2301 switch (u2FrameType) {
2302 case MAC_FRAME_PROBE_REQ:
2303 if (fgIsRegistered) {
2304 u4NewPacketFilter |= PARAM_PACKET_FILTER_PROBE_REQ;
2305 DBGLOG(P2P, TRACE, ("Open packet filer probe request\n"));
2308 u4NewPacketFilter &= ~PARAM_PACKET_FILTER_PROBE_REQ;
2309 DBGLOG(P2P, TRACE, ("Close packet filer probe request\n"));
2312 case MAC_FRAME_ACTION:
2313 if (fgIsRegistered) {
2314 u4NewPacketFilter |= PARAM_PACKET_FILTER_ACTION_FRAME;
2315 DBGLOG(P2P, TRACE, ("Open packet filer action frame.\n"));
2318 u4NewPacketFilter &= ~PARAM_PACKET_FILTER_ACTION_FRAME;
2319 DBGLOG(P2P, TRACE, ("Close packet filer action frame.\n"));
2323 DBGLOG(P2P, TRACE, ("Ask frog to add code for mgmt:%x\n", u2FrameType));
2327 if (pu4P2pPacketFilter) {
2328 *pu4P2pPacketFilter = u4NewPacketFilter;
2331 // u4NewPacketFilter |= prAdapter->u4OsPacketFilter;
2333 prAdapter->u4OsPacketFilter &= ~PARAM_PACKET_FILTER_P2P_MASK;
2334 prAdapter->u4OsPacketFilter |= u4NewPacketFilter;
2336 DBGLOG(P2P, TRACE, ("P2P Set PACKET filter:0x%lx\n", prAdapter->u4OsPacketFilter));
2338 wlanSendSetQueryCmd(prAdapter,
2339 CMD_ID_SET_RX_FILTER,
2343 nicCmdEventSetCommon,
2344 nicOidCmdTimeoutCommon,
2346 (PUINT_8)&prAdapter->u4OsPacketFilter,
2348 sizeof(u4NewPacketFilter)
2354 } /* p2pFuncMgmtFrameRegister */
2358 p2pFuncUpdateMgmtFrameRegister (
2359 IN P_ADAPTER_T prAdapter,
2360 IN UINT_32 u4OsFilter
2366 prAdapter->rWifiVar.prP2pFsmInfo->u4P2pPacketFilter = u4OsFilter;
2368 if ((prAdapter->u4OsPacketFilter & PARAM_PACKET_FILTER_P2P_MASK) ^ u4OsFilter) {
2370 prAdapter->u4OsPacketFilter &= ~PARAM_PACKET_FILTER_P2P_MASK;
2372 prAdapter->u4OsPacketFilter |= (u4OsFilter & PARAM_PACKET_FILTER_P2P_MASK);
2374 wlanSendSetQueryCmd(prAdapter,
2375 CMD_ID_SET_RX_FILTER,
2379 nicCmdEventSetCommon,
2380 nicOidCmdTimeoutCommon,
2382 (PUINT_8)&prAdapter->u4OsPacketFilter,
2386 DBGLOG(P2P, TRACE, ("P2P Set PACKET filter:0x%lx\n", prAdapter->u4OsPacketFilter));
2395 } /* p2pFuncUpdateMgmtFrameRegister */
2399 p2pFuncGetStationInfo (
2400 IN P_ADAPTER_T prAdapter,
2401 IN PUINT_8 pucMacAddr,
2402 OUT P_P2P_STATION_INFO_T prStaInfo
2407 ASSERT_BREAK((prAdapter != NULL) &&
2408 (pucMacAddr != NULL) &&
2409 (prStaInfo != NULL));
2411 prStaInfo->u4InactiveTime = 0;
2412 prStaInfo->u4RxBytes = 0;
2413 prStaInfo->u4TxBytes = 0;
2414 prStaInfo->u4RxPackets = 0;
2415 prStaInfo->u4TxPackets = 0;
2421 } /* p2pFuncGetStationInfo */
2424 p2pFuncProcessP2pProbeRsp (
2425 IN P_ADAPTER_T prAdapter,
2426 IN P_MSDU_INFO_T prMgmtTxMsdu
2429 P_MSDU_INFO_T prRetMsduInfo = prMgmtTxMsdu;
2430 P_WLAN_PROBE_RSP_FRAME_T prProbeRspFrame = (P_WLAN_PROBE_RSP_FRAME_T)NULL;
2431 PUINT_8 pucIEBuf = (PUINT_8)NULL;
2432 UINT_16 u2Offset = 0, u2IELength = 0, u2ProbeRspHdrLen = 0;
2433 BOOLEAN fgIsP2PIE = FALSE, fgIsWSCIE = FALSE;
2434 P_BSS_INFO_T prP2pBssInfo = (P_BSS_INFO_T)NULL;
2435 UINT_16 u2EstimateSize = 0, u2EstimatedExtraIELen = 0;
2436 UINT_32 u4IeArraySize = 0, u4Idx = 0;
2440 ASSERT_BREAK((prAdapter != NULL) && (prMgmtTxMsdu != NULL));
2442 prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
2444 //3 Make sure this is probe response frame.
2445 prProbeRspFrame = (P_WLAN_PROBE_RSP_FRAME_T)((UINT_32)prMgmtTxMsdu->prPacket + MAC_TX_RESERVED_FIELD);
2446 ASSERT_BREAK((prProbeRspFrame->u2FrameCtrl & MASK_FRAME_TYPE) == MAC_FRAME_PROBE_RSP);
2448 //3 Get the importent P2P IE.
2449 u2ProbeRspHdrLen = (WLAN_MAC_MGMT_HEADER_LEN + TIMESTAMP_FIELD_LEN + BEACON_INTERVAL_FIELD_LEN + CAP_INFO_FIELD_LEN);
2450 pucIEBuf = prProbeRspFrame->aucInfoElem;
2451 u2IELength = prMgmtTxMsdu->u2FrameLength - u2ProbeRspHdrLen;
2452 IE_FOR_EACH(pucIEBuf, u2IELength, u2Offset) {
2453 switch (IE_ID(pucIEBuf)) {
2457 COPY_SSID(prP2pBssInfo->aucSSID,
2458 prP2pBssInfo->ucSSIDLen,
2459 SSID_IE(pucIEBuf)->aucSSID,
2460 SSID_IE(pucIEBuf)->ucLength);
2463 case ELEM_ID_VENDOR:
2465 UINT_8 ucOuiType = 0;
2466 UINT_16 u2SubTypeVersion = 0;
2467 if (rsnParseCheckForWFAInfoElem(prAdapter, pucIEBuf, &ucOuiType, &u2SubTypeVersion)) {
2468 if (ucOuiType == VENDOR_OUI_TYPE_WPS) {
2469 kalP2PUpdateWSC_IE(prAdapter->prGlueInfo, 2, pucIEBuf, IE_SIZE(pucIEBuf));
2475 else if (p2pFuncParseCheckForP2PInfoElem(prAdapter, pucIEBuf, &ucOuiType)) {
2476 if (ucOuiType == VENDOR_OUI_TYPE_P2P) {
2477 //2 Note(frog): I use WSC IE buffer for Probe Request to store the P2P IE for Probe Response.
2478 kalP2PUpdateWSC_IE(prAdapter->prGlueInfo, 1, pucIEBuf, IE_SIZE(pucIEBuf));
2493 //3 Check the total size & current frame.
2494 u2EstimateSize = WLAN_MAC_MGMT_HEADER_LEN + \
2495 TIMESTAMP_FIELD_LEN + \
2496 BEACON_INTERVAL_FIELD_LEN + \
2497 CAP_INFO_FIELD_LEN + \
2498 (ELEM_HDR_LEN + ELEM_MAX_LEN_SSID) + \
2499 (ELEM_HDR_LEN + ELEM_MAX_LEN_SUP_RATES) + \
2500 (ELEM_HDR_LEN + ELEM_MAX_LEN_DS_PARAMETER_SET);
2502 u2EstimatedExtraIELen = 0;
2504 u4IeArraySize = sizeof(txProbeRspIETable)/sizeof(APPEND_VAR_IE_ENTRY_T);
2505 for (u4Idx = 0; u4Idx < u4IeArraySize; u4Idx++) {
2506 if (txProbeRspIETable[u4Idx].u2EstimatedFixedIELen) {
2507 u2EstimatedExtraIELen += txProbeRspIETable[u4Idx].u2EstimatedFixedIELen;
2511 ASSERT(txProbeRspIETable[u4Idx].pfnCalculateVariableIELen);
2513 u2EstimatedExtraIELen += (UINT_16)(txProbeRspIETable[u4Idx].pfnCalculateVariableIELen(prAdapter,
2514 NETWORK_TYPE_P2P_INDEX,
2522 u2EstimatedExtraIELen += kalP2PCalWSC_IELen(prAdapter->prGlueInfo, 2);
2526 u2EstimatedExtraIELen += kalP2PCalWSC_IELen(prAdapter->prGlueInfo, 1);
2532 if ((u2EstimateSize += u2EstimatedExtraIELen) > (prRetMsduInfo->u2FrameLength)) {
2533 prRetMsduInfo = cnmMgtPktAlloc(prAdapter, u2EstimateSize);
2535 if (prRetMsduInfo == NULL) {
2536 DBGLOG(P2P, WARN, ("No packet for sending new probe response, use original one\n"));
2537 prRetMsduInfo = prMgmtTxMsdu;
2542 prRetMsduInfo->ucNetworkType = NETWORK_TYPE_P2P_INDEX;
2546 //3 Compose / Re-compose probe response frame.
2547 bssComposeBeaconProbeRespFrameHeaderAndFF(
2548 (PUINT_8)((UINT_32)(prRetMsduInfo->prPacket) + MAC_TX_RESERVED_FIELD),
2549 prProbeRspFrame->aucDestAddr,
2550 prProbeRspFrame->aucSrcAddr,
2551 prProbeRspFrame->aucBSSID,
2552 prProbeRspFrame->u2BeaconInterval,
2553 prProbeRspFrame->u2CapInfo);
2555 prRetMsduInfo->u2FrameLength = (WLAN_MAC_MGMT_HEADER_LEN + TIMESTAMP_FIELD_LEN + BEACON_INTERVAL_FIELD_LEN + CAP_INFO_FIELD_LEN);
2557 bssBuildBeaconProbeRespFrameCommonIEs(prRetMsduInfo,
2559 prProbeRspFrame->aucDestAddr);
2562 for (u4Idx = 0; u4Idx < u4IeArraySize; u4Idx++) {
2563 if (txProbeRspIETable[u4Idx].pfnAppendIE) {
2564 txProbeRspIETable[u4Idx].pfnAppendIE(prAdapter, prRetMsduInfo);
2571 kalP2PGenWSC_IE(prAdapter->prGlueInfo,
2573 (PUINT_8)((UINT_32)prRetMsduInfo->prPacket + (UINT_32)prRetMsduInfo->u2FrameLength));
2575 prRetMsduInfo->u2FrameLength += (UINT_16)kalP2PCalWSC_IELen(prAdapter->prGlueInfo, 2);
2579 kalP2PGenWSC_IE(prAdapter->prGlueInfo,
2581 (PUINT_8)((UINT_32)prRetMsduInfo->prPacket + (UINT_32)prRetMsduInfo->u2FrameLength));
2583 prRetMsduInfo->u2FrameLength += (UINT_16)kalP2PCalWSC_IELen(prAdapter->prGlueInfo, 1);
2589 if (prRetMsduInfo != prMgmtTxMsdu) {
2590 cnmMgtPktFree(prAdapter, prMgmtTxMsdu);
2594 return prRetMsduInfo;
2595 } /* p2pFuncProcessP2pProbeRsp */
2598 #if 0 //LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)
2600 p2pFuncCalculateExtra_IELenForBeacon (
2601 IN P_ADAPTER_T prAdapter,
2602 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex,
2603 IN P_STA_RECORD_T prStaRec
2607 P_P2P_SPECIFIC_BSS_INFO_T prP2pSpeBssInfo = (P_P2P_SPECIFIC_BSS_INFO_T)NULL;
2608 UINT_32 u4IELen = 0;
2611 ASSERT_BREAK((prAdapter != NULL) && (eNetTypeIndex == NETWORK_TYPE_P2P_INDEX));
2613 if (p2pFuncIsAPMode(prAdapter->rWifiVar.prP2pFsmInfo)) {
2617 prP2pSpeBssInfo = prAdapter->rWifiVar.prP2pSpecificBssInfo;
2619 u4IELen = prP2pSpeBssInfo->u2IELenForBCN;
2624 } /* p2pFuncCalculateP2p_IELenForBeacon */
2627 p2pFuncGenerateExtra_IEForBeacon (
2628 IN P_ADAPTER_T prAdapter,
2629 IN P_MSDU_INFO_T prMsduInfo
2632 P_P2P_SPECIFIC_BSS_INFO_T prP2pSpeBssInfo = (P_P2P_SPECIFIC_BSS_INFO_T)NULL;
2633 PUINT_8 pucIEBuf = (PUINT_8)NULL;
2636 ASSERT_BREAK((prAdapter != NULL) && (prMsduInfo != NULL));
2638 prP2pSpeBssInfo = prAdapter->rWifiVar.prP2pSpecificBssInfo;
2640 if (p2pFuncIsAPMode(prAdapter->rWifiVar.prP2pFsmInfo)) {
2645 pucIEBuf = (PUINT_8)((UINT_32)prMsduInfo->prPacket + (UINT_32)prMsduInfo->u2FrameLength);
2647 kalMemCopy(pucIEBuf, prP2pSpeBssInfo->aucBeaconIECache, prP2pSpeBssInfo->u2IELenForBCN);
2649 prMsduInfo->u2FrameLength += prP2pSpeBssInfo->u2IELenForBCN;
2654 } /* p2pFuncGenerateExtra_IEForBeacon */
2659 p2pFuncCalculateP2p_IELenForBeacon (
2660 IN P_ADAPTER_T prAdapter,
2661 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex,
2662 IN P_STA_RECORD_T prStaRec
2665 P_P2P_SPECIFIC_BSS_INFO_T prP2pSpeBssInfo = (P_P2P_SPECIFIC_BSS_INFO_T)NULL;
2666 UINT_32 u4IELen = 0;
2669 ASSERT_BREAK((prAdapter != NULL) && (eNetTypeIndex == NETWORK_TYPE_P2P_INDEX));
2671 if (!prAdapter->fgIsP2PRegistered) {
2676 if (p2pFuncIsAPMode(prAdapter->rWifiVar.prP2pFsmInfo)) {
2680 prP2pSpeBssInfo = prAdapter->rWifiVar.prP2pSpecificBssInfo;
2682 u4IELen = prP2pSpeBssInfo->u2AttributeLen;
2687 } /* p2pFuncCalculateP2p_IELenForBeacon */
2691 p2pFuncGenerateP2p_IEForBeacon (
2692 IN P_ADAPTER_T prAdapter,
2693 IN P_MSDU_INFO_T prMsduInfo
2696 P_P2P_SPECIFIC_BSS_INFO_T prP2pSpeBssInfo = (P_P2P_SPECIFIC_BSS_INFO_T)NULL;
2697 PUINT_8 pucIEBuf = (PUINT_8)NULL;
2700 ASSERT_BREAK((prAdapter != NULL) && (prMsduInfo != NULL));
2702 if (!prAdapter->fgIsP2PRegistered) {
2706 prP2pSpeBssInfo = prAdapter->rWifiVar.prP2pSpecificBssInfo;
2708 if (p2pFuncIsAPMode(prAdapter->rWifiVar.prP2pFsmInfo)) {
2713 pucIEBuf = (PUINT_8)((UINT_32)prMsduInfo->prPacket + (UINT_32)prMsduInfo->u2FrameLength);
2715 kalMemCopy(pucIEBuf, prP2pSpeBssInfo->aucAttributesCache, prP2pSpeBssInfo->u2AttributeLen);
2717 prMsduInfo->u2FrameLength += prP2pSpeBssInfo->u2AttributeLen;
2722 } /* p2pFuncGenerateP2p_IEForBeacon */
2729 p2pFuncCalculateWSC_IELenForBeacon (
2730 IN P_ADAPTER_T prAdapter,
2731 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex,
2732 IN P_STA_RECORD_T prStaRec
2735 if (eNetTypeIndex != NETWORK_TYPE_P2P_INDEX) {
2739 return kalP2PCalWSC_IELen(prAdapter->prGlueInfo, 0);
2740 } /* p2pFuncCalculateP2p_IELenForBeacon */
2744 p2pFuncGenerateWSC_IEForBeacon (
2745 IN P_ADAPTER_T prAdapter,
2746 IN P_MSDU_INFO_T prMsduInfo
2750 UINT_16 u2IELen = 0;
2754 if (prMsduInfo->ucNetworkType != NETWORK_TYPE_P2P_INDEX) {
2758 u2IELen = (UINT_16)kalP2PCalWSC_IELen(prAdapter->prGlueInfo, 0);
2760 pucBuffer = (PUINT_8)((UINT_32)prMsduInfo->prPacket +
2761 (UINT_32)prMsduInfo->u2FrameLength);
2765 // TODO: Check P2P FSM State.
2766 kalP2PGenWSC_IE(prAdapter->prGlueInfo,
2770 prMsduInfo->u2FrameLength += u2IELen;
2773 } /* p2pFuncGenerateP2p_IEForBeacon */
2776 /*----------------------------------------------------------------------------*/
2778 * @brief This function is used to calculate P2P IE length for Beacon frame.
2780 * @param[in] eNetTypeIndex Specify which network
2781 * @param[in] prStaRec Pointer to the STA_RECORD_T
2783 * @return The length of P2P IE added
2785 /*----------------------------------------------------------------------------*/
2787 p2pFuncCalculateP2p_IELenForAssocRsp (
2788 IN P_ADAPTER_T prAdapter,
2789 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex,
2790 IN P_STA_RECORD_T prStaRec
2794 if (eNetTypeIndex != NETWORK_TYPE_P2P_INDEX) {
2798 return p2pFuncCalculateP2P_IELen(prAdapter,
2801 txAssocRspAttributesTable,
2802 sizeof(txAssocRspAttributesTable)/sizeof(APPEND_VAR_ATTRI_ENTRY_T));
2804 } /* p2pFuncCalculateP2p_IELenForAssocRsp */
2811 /*----------------------------------------------------------------------------*/
2813 * @brief This function is used to generate P2P IE for Beacon frame.
2815 * @param[in] prMsduInfo Pointer to the composed MSDU_INFO_T.
2819 /*----------------------------------------------------------------------------*/
2821 p2pFuncGenerateP2p_IEForAssocRsp (
2822 IN P_ADAPTER_T prAdapter,
2823 IN P_MSDU_INFO_T prMsduInfo
2826 P_P2P_FSM_INFO_T prP2pFsmInfo = (P_P2P_FSM_INFO_T)NULL;
2827 P_STA_RECORD_T prStaRec = (P_STA_RECORD_T)NULL;
2830 ASSERT_BREAK((prAdapter != NULL) && (prMsduInfo != NULL));
2832 prP2pFsmInfo = prAdapter->rWifiVar.prP2pFsmInfo;
2834 prStaRec = cnmGetStaRecByIndex(prAdapter, prMsduInfo->ucStaRecIndex);
2836 if (IS_STA_P2P_TYPE(prStaRec)) {
2837 DBGLOG(P2P, TRACE, ("Generate NULL P2P IE for Assoc Rsp.\n"));
2839 p2pFuncGenerateP2P_IE(prAdapter,
2841 &prMsduInfo->u2FrameLength,
2842 prMsduInfo->prPacket,
2844 txAssocRspAttributesTable,
2845 sizeof(txAssocRspAttributesTable)/sizeof(APPEND_VAR_ATTRI_ENTRY_T));
2849 DBGLOG(P2P, TRACE, ("Legacy device, no P2P IE.\n"));
2856 } /* p2pFuncGenerateP2p_IEForAssocRsp */
2862 p2pFuncCalculateP2P_IELen (
2863 IN P_ADAPTER_T prAdapter,
2864 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex,
2865 IN P_STA_RECORD_T prStaRec,
2866 IN APPEND_VAR_ATTRI_ENTRY_T arAppendAttriTable[],
2867 IN UINT_32 u4AttriTableSize
2871 UINT_32 u4OverallAttriLen, u4Dummy;
2872 UINT_16 u2EstimatedFixedAttriLen;
2876 /* Overall length of all Attributes */
2877 u4OverallAttriLen = 0;
2879 for (i = 0; i < u4AttriTableSize; i++) {
2880 u2EstimatedFixedAttriLen = arAppendAttriTable[i].u2EstimatedFixedAttriLen;
2882 if (u2EstimatedFixedAttriLen) {
2883 u4OverallAttriLen += u2EstimatedFixedAttriLen;
2886 ASSERT(arAppendAttriTable[i].pfnCalculateVariableAttriLen);
2888 u4OverallAttriLen +=
2889 arAppendAttriTable[i].pfnCalculateVariableAttriLen(prAdapter, prStaRec);
2893 u4Dummy = u4OverallAttriLen;
2894 u4OverallAttriLen += P2P_IE_OUI_HDR;
2896 for (;(u4Dummy > P2P_MAXIMUM_ATTRIBUTE_LEN);) {
2897 u4OverallAttriLen += P2P_IE_OUI_HDR;
2898 u4Dummy -= P2P_MAXIMUM_ATTRIBUTE_LEN;
2901 return u4OverallAttriLen;
2902 } /* p2pFuncCalculateP2P_IELen */
2906 p2pFuncGenerateP2P_IE (
2907 IN P_ADAPTER_T prAdapter,
2908 IN BOOLEAN fgIsAssocFrame,
2909 IN PUINT_16 pu2Offset,
2911 IN UINT_16 u2BufSize,
2912 IN APPEND_VAR_ATTRI_ENTRY_T arAppendAttriTable[],
2913 IN UINT_32 u4AttriTableSize
2916 PUINT_8 pucBuffer = (PUINT_8)NULL;
2917 P_IE_P2P_T prIeP2P = (P_IE_P2P_T)NULL;
2918 UINT_32 u4OverallAttriLen;
2920 UINT_8 aucWfaOui[] = VENDOR_OUI_WFA_SPECIFIC;
2921 UINT_8 aucTempBuffer[P2P_MAXIMUM_ATTRIBUTE_LEN];
2926 ASSERT_BREAK((prAdapter != NULL) && (pucBuf != NULL));
2928 pucBuffer = (PUINT_8)((UINT_32)pucBuf + (*pu2Offset));
2930 ASSERT_BREAK(pucBuffer != NULL);
2932 /* Check buffer length is still enough. */
2933 ASSERT_BREAK((u2BufSize - (*pu2Offset)) >= P2P_IE_OUI_HDR);
2935 prIeP2P = (P_IE_P2P_T)pucBuffer;
2937 prIeP2P->ucId = ELEM_ID_P2P;
2939 prIeP2P->aucOui[0] = aucWfaOui[0];
2940 prIeP2P->aucOui[1] = aucWfaOui[1];
2941 prIeP2P->aucOui[2] = aucWfaOui[2];
2942 prIeP2P->ucOuiType = VENDOR_OUI_TYPE_P2P;
2944 (*pu2Offset) += P2P_IE_OUI_HDR;
2946 /* Overall length of all Attributes */
2947 u4OverallAttriLen = 0;
2950 for (i = 0; i < u4AttriTableSize; i++) {
2952 if (arAppendAttriTable[i].pfnAppendAttri) {
2953 u4AttriLen = arAppendAttriTable[i].pfnAppendAttri(prAdapter, fgIsAssocFrame, pu2Offset, pucBuf, u2BufSize);
2955 u4OverallAttriLen += u4AttriLen;
2957 if (u4OverallAttriLen > P2P_MAXIMUM_ATTRIBUTE_LEN) {
2958 u4OverallAttriLen -= P2P_MAXIMUM_ATTRIBUTE_LEN;
2960 prIeP2P->ucLength = (VENDOR_OUI_TYPE_LEN + P2P_MAXIMUM_ATTRIBUTE_LEN);
2962 pucBuffer = (PUINT_8)((UINT_32)prIeP2P + (VENDOR_OUI_TYPE_LEN + P2P_MAXIMUM_ATTRIBUTE_LEN));
2964 prIeP2P = (P_IE_P2P_T)((UINT_32)prIeP2P +
2965 (ELEM_HDR_LEN + (VENDOR_OUI_TYPE_LEN + P2P_MAXIMUM_ATTRIBUTE_LEN)));
2967 kalMemCopy(aucTempBuffer, pucBuffer, u4OverallAttriLen);
2969 prIeP2P->ucId = ELEM_ID_P2P;
2971 prIeP2P->aucOui[0] = aucWfaOui[0];
2972 prIeP2P->aucOui[1] = aucWfaOui[1];
2973 prIeP2P->aucOui[2] = aucWfaOui[2];
2974 prIeP2P->ucOuiType = VENDOR_OUI_TYPE_P2P;
2976 kalMemCopy(prIeP2P->aucP2PAttributes, aucTempBuffer, u4OverallAttriLen);
2977 (*pu2Offset) += P2P_IE_OUI_HDR;
2984 prIeP2P->ucLength = (UINT_8)(VENDOR_OUI_TYPE_LEN + u4OverallAttriLen);
2990 } /* p2pFuncGenerateP2P_IE */
2993 p2pFuncAppendAttriStatusForAssocRsp (
2994 IN P_ADAPTER_T prAdapter,
2995 IN BOOLEAN fgIsAssocFrame,
2996 IN PUINT_16 pu2Offset,
2998 IN UINT_16 u2BufSize
3002 P_P2P_ATTRI_STATUS_T prAttriStatus;
3003 P_P2P_CONNECTION_SETTINGS_T prP2pConnSettings = (P_P2P_CONNECTION_SETTINGS_T)NULL;
3004 UINT_32 u4AttriLen = 0;
3009 prP2pConnSettings = prAdapter->rWifiVar.prP2PConnSettings;
3011 if (fgIsAssocFrame) {
3015 // TODO: For assoc request P2P IE check in driver & return status in P2P IE.
3017 pucBuffer = (PUINT_8)((UINT_32)pucBuf +
3018 (UINT_32)(*pu2Offset));
3021 prAttriStatus = (P_P2P_ATTRI_STATUS_T)pucBuffer;
3023 ASSERT(u2BufSize >= ((*pu2Offset) + (UINT_16)u4AttriLen));
3028 prAttriStatus->ucId = P2P_ATTRI_ID_STATUS;
3029 WLAN_SET_FIELD_16(&prAttriStatus->u2Length, P2P_ATTRI_MAX_LEN_STATUS);
3031 prAttriStatus->ucStatusCode = P2P_STATUS_FAIL_PREVIOUS_PROTOCOL_ERR;
3033 u4AttriLen = (P2P_ATTRI_HDR_LEN + P2P_ATTRI_MAX_LEN_STATUS);
3035 (*pu2Offset) += (UINT_16)u4AttriLen;
3038 } /* p2pFuncAppendAttriStatusForAssocRsp */
3041 p2pFuncAppendAttriExtListenTiming (
3042 IN P_ADAPTER_T prAdapter,
3043 IN BOOLEAN fgIsAssocFrame,
3044 IN PUINT_16 pu2Offset,
3046 IN UINT_16 u2BufSize
3049 UINT_32 u4AttriLen = 0;
3050 P_P2P_ATTRI_EXT_LISTEN_TIMING_T prP2pExtListenTiming = (P_P2P_ATTRI_EXT_LISTEN_TIMING_T)NULL;
3051 P_P2P_SPECIFIC_BSS_INFO_T prP2pSpecificBssInfo = (P_P2P_SPECIFIC_BSS_INFO_T)NULL;
3052 PUINT_8 pucBuffer = NULL;
3057 if (fgIsAssocFrame) {
3061 // TODO: For extend listen timing.
3063 prP2pSpecificBssInfo = prAdapter->rWifiVar.prP2pSpecificBssInfo;
3065 u4AttriLen = (P2P_ATTRI_HDR_LEN + P2P_ATTRI_MAX_LEN_EXT_LISTEN_TIMING);
3067 ASSERT(u2BufSize >= ((*pu2Offset) + (UINT_16)u4AttriLen));
3069 pucBuffer = (PUINT_8)((UINT_32)pucBuf +
3070 (UINT_32)(*pu2Offset));
3074 prP2pExtListenTiming = (P_P2P_ATTRI_EXT_LISTEN_TIMING_T)pucBuffer;
3076 prP2pExtListenTiming->ucId = P2P_ATTRI_ID_EXT_LISTEN_TIMING;
3077 WLAN_SET_FIELD_16(&prP2pExtListenTiming->u2Length, P2P_ATTRI_MAX_LEN_EXT_LISTEN_TIMING);
3078 WLAN_SET_FIELD_16(&prP2pExtListenTiming->u2AvailInterval, prP2pSpecificBssInfo->u2AvailabilityInterval);
3079 WLAN_SET_FIELD_16(&prP2pExtListenTiming->u2AvailPeriod, prP2pSpecificBssInfo->u2AvailabilityPeriod);
3081 (*pu2Offset) += (UINT_16)u4AttriLen;
3084 } /* p2pFuncAppendAttriExtListenTiming */
3089 IN P_ADAPTER_T prAdapter,
3090 IN PUINT_8 pucIEBuf,
3091 IN UINT_16 u2BufferLen,
3093 IN PBOOLEAN pfgIsMore
3096 P_IE_HDR_T prTargetIE = (P_IE_HDR_T)NULL;
3097 PUINT_8 pucIE = (PUINT_8)NULL;
3098 UINT_16 u2Offset = 0;
3102 ASSERT_BREAK((prAdapter != NULL)
3103 && (pucIEBuf != NULL));
3112 IE_FOR_EACH(pucIE, u2BufferLen, u2Offset) {
3113 if (IE_ID(pucIE) == ucElemID) {
3114 if ((prTargetIE) && (pfgIsMore)) {
3120 prTargetIE = (P_IE_HDR_T)pucIE;
3122 if (pfgIsMore == NULL) {
3134 } /* p2pFuncGetSpecIE */
3139 p2pFuncGetSpecAttri (
3140 IN P_ADAPTER_T prAdapter,
3141 IN UINT_8 ucOuiType,
3142 IN PUINT_8 pucIEBuf,
3143 IN UINT_16 u2BufferLen,
3147 P_IE_P2P_T prP2pIE = (P_IE_P2P_T)NULL;
3148 P_ATTRIBUTE_HDR_T prTargetAttri = (P_ATTRIBUTE_HDR_T)NULL;
3149 BOOLEAN fgIsMore = FALSE;
3150 PUINT_8 pucIE = (PUINT_8)NULL, pucAttri = (PUINT_8)NULL;
3151 UINT_16 u2OffsetAttri = 0;
3152 UINT_8 aucWfaOui[] = VENDOR_OUI_WFA_SPECIFIC;
3155 ASSERT_BREAK((prAdapter != NULL)
3156 && (pucIEBuf != NULL));
3161 prP2pIE = (P_IE_P2P_T)p2pFuncGetSpecIE(prAdapter,
3168 if (prP2pIE->ucOuiType == ucOuiType) {
3169 switch (ucOuiType) {
3170 case VENDOR_OUI_TYPE_WPS:
3171 aucWfaOui[0] = 0x00;
3172 aucWfaOui[1] = 0x50;
3173 aucWfaOui[2] = 0xF2;
3175 case VENDOR_OUI_TYPE_P2P:
3177 case VENDOR_OUI_TYPE_WPA:
3178 case VENDOR_OUI_TYPE_WMM:
3184 if ((prP2pIE->aucOui[0] == aucWfaOui[0]) &&
3185 (prP2pIE->aucOui[1] == aucWfaOui[1]) &&
3186 (prP2pIE->aucOui[2] == aucWfaOui[2])) {
3188 pucAttri = prP2pIE->aucP2PAttributes;
3190 if (ucOuiType == VENDOR_OUI_TYPE_WPS) {
3191 WSC_ATTRI_FOR_EACH(pucAttri, (IE_LEN(prP2pIE) - P2P_IE_OUI_HDR), u2OffsetAttri) {
3192 if (WSC_ATTRI_ID(pucAttri) == ucAttriID) {
3193 prTargetAttri = (P_ATTRIBUTE_HDR_T)pucAttri;
3201 else if (ucOuiType == VENDOR_OUI_TYPE_P2P) {
3202 P2P_ATTRI_FOR_EACH(pucAttri, (IE_LEN(prP2pIE) - P2P_IE_OUI_HDR), u2OffsetAttri) {
3203 if (ATTRI_ID(pucAttri) == ucAttriID) {
3204 prTargetAttri = (P_ATTRIBUTE_HDR_T)pucAttri;
3213 // Possible WiFi Display or else.
3224 pucIE = (PUINT_8)((UINT_32)prP2pIE + IE_LEN(prP2pIE));
3230 return prTargetAttri;
3232 /* p2pFuncGetSpecAttri */
3236 p2pFuncGenerateBeaconProbeRsp (
3237 IN P_ADAPTER_T prAdapter,
3238 IN P_BSS_INFO_T prBssInfo,
3239 IN P_MSDU_INFO_T prMsduInfo,
3240 IN BOOLEAN fgIsProbeRsp
3243 WLAN_STATUS rWlanStatus = WLAN_STATUS_SUCCESS;
3244 P_WLAN_BEACON_FRAME_T prBcnFrame = (P_WLAN_BEACON_FRAME_T)NULL;
3245 // P_APPEND_VAR_IE_ENTRY_T prAppendIeTable = (P_APPEND_VAR_IE_ENTRY_T)NULL;
3250 ASSERT_BREAK((prAdapter != NULL) &&
3251 (prBssInfo != NULL) &&
3252 (prMsduInfo != NULL));
3257 // txProbeRspIETable
3261 prBcnFrame = (P_WLAN_BEACON_FRAME_T)prMsduInfo->prPacket;
3263 return nicUpdateBeaconIETemplate(prAdapter,
3264 IE_UPD_METHOD_UPDATE_ALL,
3265 NETWORK_TYPE_P2P_INDEX,
3266 prBssInfo->u2CapInfo,
3267 (PUINT_8)prBcnFrame->aucInfoElem,
3268 prMsduInfo->u2FrameLength - OFFSET_OF(WLAN_BEACON_FRAME_T, aucInfoElem));
3273 } /* p2pFuncGenerateBeaconProbeRsp */
3277 p2pFuncComposeBeaconProbeRspTemplate (
3278 IN P_ADAPTER_T prAdapter,
3279 IN PUINT_8 pucBcnBuffer,
3280 IN UINT_32 u4BcnBufLen,
3281 IN BOOLEAN fgIsProbeRsp,
3282 IN P_P2P_PROBE_RSP_UPDATE_INFO_T prP2pProbeRspInfo,
3283 IN BOOLEAN fgSynToFW
3286 WLAN_STATUS rWlanStatus = WLAN_STATUS_SUCCESS;
3287 P_MSDU_INFO_T prMsduInfo = (P_MSDU_INFO_T)NULL;
3288 P_WLAN_MAC_HEADER_T prWlanBcnFrame = (P_WLAN_MAC_HEADER_T)NULL;
3289 P_BSS_INFO_T prP2pBssInfo = (P_BSS_INFO_T)NULL;
3291 PUINT_8 pucBuffer = (PUINT_8)NULL;
3294 ASSERT_BREAK((prAdapter != NULL) && (pucBcnBuffer != NULL));
3296 prWlanBcnFrame = (P_WLAN_MAC_HEADER_T)pucBcnBuffer;
3298 if ((prWlanBcnFrame->u2FrameCtrl != MAC_FRAME_BEACON) && (!fgIsProbeRsp)) {
3299 rWlanStatus = WLAN_STATUS_INVALID_DATA;
3303 else if (prWlanBcnFrame->u2FrameCtrl != MAC_FRAME_PROBE_RSP) {
3304 rWlanStatus = WLAN_STATUS_INVALID_DATA;
3311 ASSERT_BREAK(prP2pProbeRspInfo != NULL);
3313 if (!prP2pProbeRspInfo->prProbeRspMsduTemplate) {
3314 cnmMgtPktFree(prAdapter, prP2pProbeRspInfo->prProbeRspMsduTemplate);
3317 prP2pProbeRspInfo->prProbeRspMsduTemplate = cnmMgtPktAlloc(prAdapter, u4BcnBufLen);
3319 prMsduInfo = prP2pProbeRspInfo->prProbeRspMsduTemplate;
3321 prMsduInfo->eSrc = TX_PACKET_MGMT;
3322 prMsduInfo->ucStaRecIndex = 0xFF;
3323 prMsduInfo->ucNetworkType = NETWORK_TYPE_P2P_INDEX;
3327 prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
3328 prMsduInfo = prP2pBssInfo->prBeacon;
3330 if (prMsduInfo == NULL) {
3331 rWlanStatus = WLAN_STATUS_FAILURE;
3335 if (u4BcnBufLen > (OFFSET_OF(WLAN_BEACON_FRAME_T, aucInfoElem[0]) + MAX_IE_LENGTH)) {
3336 /* Unexpected error, buffer overflow. */
3344 pucBuffer = (PUINT_8)((UINT_32)(prMsduInfo->prPacket) + MAC_TX_RESERVED_FIELD);
3346 kalMemCopy(pucBuffer, pucBcnBuffer, u4BcnBufLen);
3348 prMsduInfo->fgIs802_11 = TRUE;
3349 prMsduInfo->u2FrameLength = (UINT_16)u4BcnBufLen;
3352 rWlanStatus = p2pFuncGenerateBeaconProbeRsp(prAdapter, prP2pBssInfo, prMsduInfo, fgIsProbeRsp);
3359 } /* p2pFuncComposeBeaconTemplate */