4 #pragma GCC diagnostic ignored "-Wformat"
8 APPEND_VAR_ATTRI_ENTRY_T txAssocRspAttributesTable
[] = {
9 {(P2P_ATTRI_HDR_LEN
+ P2P_ATTRI_MAX_LEN_STATUS
), NULL
, p2pFuncAppendAttriStatusForAssocRsp
} /* 0 */* / Status */
10 , {(P2P_ATTRI_HDR_LEN
+ P2P_ATTRI_MAX_LEN_EXT_LISTEN_TIMING
), NULL
, p2pFuncAppendAttriExtListenTiming
} /* 8 */
14 APPEND_VAR_IE_ENTRY_T txProbeRspIETable
[] = {
15 {(ELEM_HDR_LEN
+ (RATE_NUM
- ELEM_MAX_LEN_SUP_RATES
)), NULL
, bssGenerateExtSuppRate_IE
} /* 50 */
16 , {(ELEM_HDR_LEN
+ ELEM_MAX_LEN_ERP
), NULL
, rlmRspGenerateErpIE
} /* 42 */
17 , {(ELEM_HDR_LEN
+ ELEM_MAX_LEN_HT_CAP
), NULL
, rlmRspGenerateHtCapIE
} /* 45 */
18 , {(ELEM_HDR_LEN
+ ELEM_MAX_LEN_HT_OP
), NULL
, rlmRspGenerateHtOpIE
} /* 61 */
19 , {(ELEM_HDR_LEN
+ ELEM_MAX_LEN_RSN
), NULL
, rsnGenerateRSNIE
} /* 48 */
20 , {(ELEM_HDR_LEN
+ ELEM_MAX_LEN_OBSS_SCAN
), NULL
, rlmRspGenerateObssScanIE
} /* 74 */
21 , {(ELEM_HDR_LEN
+ ELEM_MAX_LEN_EXT_CAP
), NULL
, rlmRspGenerateExtCapIE
} /* 127 */
22 , {(ELEM_HDR_LEN
+ ELEM_MAX_LEN_WPA
), NULL
, rsnGenerateWpaNoneIE
} /* 221 */
23 , {(ELEM_HDR_LEN
+ ELEM_MAX_LEN_WMM_PARAM
), NULL
, mqmGenerateWmmParamIE
} /* 221 */
26 /*----------------------------------------------------------------------------*/
28 * @brief Function for requesting scan. There is an option to do ACTIVE or PASSIVE scan.
30 * @param eScanType - Specify the scan type of the scan request. It can be an ACTIVE/PASSIVE
32 * eChannelSet - Specify the prefered channel set.
33 * A FULL scan would request a legacy full channel normal scan.(usually ACTIVE).
34 * A P2P_SOCIAL scan would scan 1+6+11 channels.(usually ACTIVE)
35 * A SPECIFIC scan would only 1/6/11 channels scan. (Passive Listen/Specific Search)
36 * ucChannelNum - A specific channel number. (Only when channel is specified)
37 * eBand - A specific band. (Only when channel is specified)
42 /*----------------------------------------------------------------------------*/
43 VOID
p2pFuncRequestScan(IN P_ADAPTER_T prAdapter
, IN P_P2P_SCAN_REQ_INFO_T prScanReqInfo
)
46 P_MSG_SCN_SCAN_REQ prScanReq
= (P_MSG_SCN_SCAN_REQ
) NULL
;
48 DEBUGFUNC("p2pFuncRequestScan()");
51 ASSERT_BREAK((prAdapter
!= NULL
) && (prScanReqInfo
!= NULL
));
53 if (prScanReqInfo
->eChannelSet
== SCAN_CHANNEL_SPECIFIED
) {
54 ASSERT_BREAK(prScanReqInfo
->ucNumChannelList
> 0);
56 ("P2P Scan Request Channel:%d\n",
57 prScanReqInfo
->arScanChannelList
[0].ucChannelNum
));
61 (P_MSG_SCN_SCAN_REQ
) cnmMemAlloc(prAdapter
, RAM_TYPE_MSG
,
62 sizeof(MSG_SCN_SCAN_REQ
));
64 ASSERT(0); /* Can't trigger SCAN FSM */
68 prScanReq
->rMsgHdr
.eMsgId
= MID_P2P_SCN_SCAN_REQ
;
69 prScanReq
->ucSeqNum
= ++prScanReqInfo
->ucSeqNumOfScnMsg
;
70 prScanReq
->ucNetTypeIndex
= (UINT_8
) NETWORK_TYPE_P2P_INDEX
;
71 prScanReq
->eScanType
= prScanReqInfo
->eScanType
;
72 prScanReq
->eScanChannel
= prScanReqInfo
->eChannelSet
;
73 prScanReq
->u2IELen
= 0;
75 /* Copy IE for Probe Request. */
76 kalMemCopy(prScanReq
->aucIE
, prScanReqInfo
->aucIEBuf
, prScanReqInfo
->u4BufLength
);
77 prScanReq
->u2IELen
= (UINT_16
) prScanReqInfo
->u4BufLength
;
79 prScanReq
->u2ChannelDwellTime
= prScanReqInfo
->u2PassiveDewellTime
;
81 switch (prScanReqInfo
->eChannelSet
) {
82 case SCAN_CHANNEL_SPECIFIED
:
85 P_RF_CHANNEL_INFO_T prDomainInfo
=
86 (P_RF_CHANNEL_INFO_T
) prScanReqInfo
->arScanChannelList
;
88 if (prScanReqInfo
->ucNumChannelList
>
89 MAXIMUM_OPERATION_CHANNEL_LIST
) {
90 prScanReqInfo
->ucNumChannelList
=
91 MAXIMUM_OPERATION_CHANNEL_LIST
;
95 for (u4Idx
= 0; u4Idx
< prScanReqInfo
->ucNumChannelList
; u4Idx
++) {
96 prScanReq
->arChnlInfoList
[u4Idx
].ucChannelNum
=
97 prDomainInfo
->ucChannelNum
;
98 prScanReq
->arChnlInfoList
[u4Idx
].eBand
=
103 prScanReq
->ucChannelListNum
= prScanReqInfo
->ucNumChannelList
;
105 case SCAN_CHANNEL_FULL
:
106 case SCAN_CHANNEL_2G4
:
107 case SCAN_CHANNEL_P2P_SOCIAL
:
109 UINT_8 aucP2pSsid
[] = P2P_WILDCARD_SSID
;
111 COPY_SSID(prScanReq
->aucSSID
,
112 prScanReq
->ucSSIDLength
,
113 prScanReqInfo
->rSsidStruct
.aucSsid
,
114 prScanReqInfo
->rSsidStruct
.ucSsidLen
);
116 /* For compatible. */
118 (aucP2pSsid
, P2P_WILDCARD_SSID_LEN
, prScanReq
->aucSSID
,
119 prScanReq
->ucSSIDLength
)) {
120 prScanReq
->ucSSIDType
= SCAN_REQ_SSID_P2P_WILDCARD
;
121 } else if (prScanReq
->ucSSIDLength
!= 0) {
122 prScanReq
->ucSSIDType
= SCAN_REQ_SSID_SPECIFIED
;
127 /* Currently there is no other scan channel set. */
132 mboxSendMsg(prAdapter
, MBOX_ID_0
, (P_MSG_HDR_T
) prScanReq
, MSG_SEND_METHOD_BUF
);
137 } /* p2pFuncRequestScan */
139 VOID
p2pFuncCancelScan(IN P_ADAPTER_T prAdapter
, IN P_P2P_SCAN_REQ_INFO_T prScanInfo
)
141 P_MSG_SCN_SCAN_CANCEL prScanCancelMsg
= (P_MSG_SCN_SCAN_CANCEL
) NULL
;
144 ASSERT_BREAK((prAdapter
!= NULL
) && (prScanInfo
!= NULL
));
146 if (!prScanInfo
->fgIsScanRequest
) {
151 if (prScanInfo
->ucSeqNumOfScnMsg
) {
152 /* There is a channel privilege on hand. */
153 DBGLOG(P2P
, TRACE
, ("P2P Cancel Scan\n"));
156 (P_MSG_SCN_SCAN_CANCEL
) cnmMemAlloc(prAdapter
, RAM_TYPE_MSG
,
157 sizeof(MSG_SCN_SCAN_CANCEL
));
158 if (!prScanCancelMsg
) {
159 /* Buffer not enough, can not cancel scan request. */
160 DBGLOG(P2P
, TRACE
, ("Buffer not enough, can not cancel scan.\n"));
165 prScanCancelMsg
->rMsgHdr
.eMsgId
= MID_P2P_SCN_SCAN_CANCEL
;
166 prScanCancelMsg
->ucNetTypeIndex
= NETWORK_TYPE_P2P_INDEX
;
167 prScanCancelMsg
->ucSeqNum
= prScanInfo
->ucSeqNumOfScnMsg
++;
168 prScanCancelMsg
->fgIsChannelExt
= FALSE
;
169 prScanInfo
->fgIsScanRequest
= FALSE
;
171 mboxSendMsg(prAdapter
,
172 MBOX_ID_0
, (P_MSG_HDR_T
) prScanCancelMsg
, MSG_SEND_METHOD_BUF
);
181 } /* p2pFuncCancelScan */
185 p2pFuncSwitchOPMode(IN P_ADAPTER_T prAdapter
,
186 IN P_BSS_INFO_T prP2pBssInfo
, IN ENUM_OP_MODE_T eOpMode
, IN BOOLEAN fgSyncToFW
)
189 ASSERT_BREAK((prAdapter
!= NULL
) &&
190 (prP2pBssInfo
!= NULL
) && (eOpMode
< OP_MODE_NUM
));
192 if (prP2pBssInfo
->eCurrentOPMode
!= eOpMode
) {
194 ("p2pFuncSwitchOPMode: Switch to from %d, to %d.\n",
195 prP2pBssInfo
->eCurrentOPMode
, eOpMode
));
197 switch (prP2pBssInfo
->eCurrentOPMode
) {
198 case OP_MODE_ACCESS_POINT
:
199 p2pFuncDissolve(prAdapter
, prP2pBssInfo
, TRUE
,
200 REASON_CODE_DEAUTH_LEAVING_BSS
);
202 p2pFsmRunEventStopAP(prAdapter
, NULL
);
209 prP2pBssInfo
->eIntendOPMode
= eOpMode
;
210 prP2pBssInfo
->eCurrentOPMode
= eOpMode
;
212 case OP_MODE_INFRASTRUCTURE
:
213 DBGLOG(P2P
, TRACE
, ("p2pFuncSwitchOPMode: Switch to Client.\n"));
214 case OP_MODE_ACCESS_POINT
:
215 /* if (!IS_BSS_ACTIVE(prP2pBssInfo)) { */
216 /* SET_NET_ACTIVE(prAdapter, NETWORK_TYPE_P2P_INDEX); */
217 /* nicActivateNetwork(prAdapter, NETWORK_TYPE_P2P_INDEX); */
220 /* Change interface address. */
221 if (eOpMode
== OP_MODE_ACCESS_POINT
) {
223 ("p2pFuncSwitchOPMode: Switch to AP.\n"));
224 prP2pBssInfo
->ucSSIDLen
= 0;
227 COPY_MAC_ADDR(prP2pBssInfo
->aucOwnMacAddr
,
228 prAdapter
->rWifiVar
.aucInterfaceAddress
);
229 COPY_MAC_ADDR(prP2pBssInfo
->aucBSSID
,
230 prAdapter
->rWifiVar
.aucInterfaceAddress
);
234 case OP_MODE_P2P_DEVICE
:
236 /* Change device address. */
238 ("p2pFuncSwitchOPMode: Switch back to P2P Device.\n"));
240 /* if (!IS_BSS_ACTIVE(prP2pBssInfo)) { */
241 /* SET_NET_ACTIVE(prAdapter, NETWORK_TYPE_P2P_INDEX); */
242 /* nicActivateNetwork(prAdapter, NETWORK_TYPE_P2P_INDEX); */
245 p2pChangeMediaState(prAdapter
,
246 PARAM_MEDIA_STATE_DISCONNECTED
);
248 COPY_MAC_ADDR(prP2pBssInfo
->aucOwnMacAddr
,
249 prAdapter
->rWifiVar
.aucDeviceAddress
);
250 COPY_MAC_ADDR(prP2pBssInfo
->aucBSSID
,
251 prAdapter
->rWifiVar
.aucDeviceAddress
);
257 /* if (IS_BSS_ACTIVE(prP2pBssInfo)) { */
258 /* UNSET_NET_ACTIVE(prAdapter, NETWORK_TYPE_P2P_INDEX); */
260 /* nicDeactivateNetwork(prAdapter, NETWORK_TYPE_P2P_INDEX); */
267 P2P_DISCONNECT_INFO rP2PDisInfo
;
269 rP2PDisInfo
.ucRole
= 2;
270 wlanSendSetQueryCmd(prAdapter
,
277 sizeof(P2P_DISCONNECT_INFO
),
278 (PUINT_8
) & rP2PDisInfo
, NULL
, 0);
283 ("The device address is changed to " MACSTR
"\n",
284 MAC2STR(prP2pBssInfo
->aucOwnMacAddr
)));
286 ("The BSSID is changed to " MACSTR
"\n",
287 MAC2STR(prP2pBssInfo
->aucBSSID
)));
289 /* Update BSS INFO to FW. */
290 if ((fgSyncToFW
) && (eOpMode
!= OP_MODE_ACCESS_POINT
)) {
291 nicUpdateBss(prAdapter
, NETWORK_TYPE_P2P_INDEX
);
298 } /* p2pFuncSwitchOPMode */
302 /*----------------------------------------------------------------------------*/
304 * @brief This function will start a P2P Group Owner and send Beacon Frames.
310 /*----------------------------------------------------------------------------*/
312 p2pFuncStartGO(IN P_ADAPTER_T prAdapter
,
313 IN P_BSS_INFO_T prBssInfo
,
314 IN PUINT_8 pucSsidBuf
,
316 IN UINT_8 ucChannelNum
,
317 IN ENUM_BAND_T eBand
, IN ENUM_CHNL_EXT_T eSco
, IN BOOLEAN fgIsPureAP
)
320 ASSERT_BREAK((prAdapter
!= NULL
) && (prBssInfo
!= NULL
));
322 ASSERT(prBssInfo
->eCurrentOPMode
== OP_MODE_ACCESS_POINT
);
324 DBGLOG(P2P
, TRACE
, ("p2pFuncStartGO:\n"));
326 /* AP mode started. */
327 p2pFuncSwitchOPMode(prAdapter
, prBssInfo
, prBssInfo
->eIntendOPMode
, FALSE
);
329 prBssInfo
->eIntendOPMode
= OP_MODE_NUM
;
331 /* 4 <1.1> Assign SSID */
332 COPY_SSID(prBssInfo
->aucSSID
, prBssInfo
->ucSSIDLen
, pucSsidBuf
, ucSsidLen
);
334 DBGLOG(P2P
, TRACE
, ("GO SSID:%s\n", prBssInfo
->aucSSID
));
336 /* 4 <1.2> Clear current AP's STA_RECORD_T and current AID */
337 prBssInfo
->prStaRecOfAP
= (P_STA_RECORD_T
) NULL
;
338 prBssInfo
->u2AssocId
= 0;
341 /* 4 <1.3> Setup Channel, Band and Phy Attributes */
342 prBssInfo
->ucPrimaryChannel
= ucChannelNum
;
343 prBssInfo
->eBand
= eBand
;
344 prBssInfo
->eBssSCO
= eSco
;
346 DBGLOG(P2P
, TRACE
, ("GO Channel:%d\n", ucChannelNum
));
349 if (prBssInfo
->eBand
== BAND_5G
) {
350 prBssInfo
->ucPhyTypeSet
= (prAdapter
->rWifiVar
.ucAvailablePhyTypeSet
& PHY_TYPE_SET_802_11AN
); /* Depend on eBand */
351 prBssInfo
->ucConfigAdHocAPMode
= AP_MODE_11A
; /* Depend on eCurrentOPMode and ucPhyTypeSet */
352 } else if (fgIsPureAP
) {
353 prBssInfo
->ucPhyTypeSet
= (prAdapter
->rWifiVar
.ucAvailablePhyTypeSet
& PHY_TYPE_SET_802_11BGN
); /* Depend on eBand */
354 prBssInfo
->ucConfigAdHocAPMode
= AP_MODE_MIXED_11BG
; /* Depend on eCurrentOPMode and ucPhyTypeSet */
356 prBssInfo
->ucPhyTypeSet
= (prAdapter
->rWifiVar
.ucAvailablePhyTypeSet
& PHY_TYPE_SET_802_11GN
); /* Depend on eBand */
357 prBssInfo
->ucConfigAdHocAPMode
= AP_MODE_11G_P2P
; /* Depend on eCurrentOPMode and ucPhyTypeSet */
361 prBssInfo
->ucNonHTBasicPhyType
= (UINT_8
)
362 rNonHTApModeAttributes
[prBssInfo
->ucConfigAdHocAPMode
].ePhyTypeIndex
;
363 prBssInfo
->u2BSSBasicRateSet
=
364 rNonHTApModeAttributes
[prBssInfo
->ucConfigAdHocAPMode
].u2BSSBasicRateSet
;
365 prBssInfo
->u2OperationalRateSet
=
366 rNonHTPhyAttributes
[prBssInfo
->ucNonHTBasicPhyType
].u2SupportedRateSet
;
368 if (prBssInfo
->ucAllSupportedRatesLen
== 0) {
369 rateGetDataRatesFromRateSet(prBssInfo
->u2OperationalRateSet
,
370 prBssInfo
->u2BSSBasicRateSet
,
371 prBssInfo
->aucAllSupportedRates
,
372 &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
);
384 if (kalP2PGetCipher(prAdapter
->prGlueInfo
))
385 prBssInfo
->fgIsProtection
= TRUE
;
388 /* 20120106 frog: I want separate OP_Mode & Beacon TX Function. */
389 /* p2pFuncSwitchOPMode(prAdapter, prBssInfo, OP_MODE_ACCESS_POINT, FALSE); */
391 bssInitForAP(prAdapter
, prBssInfo
, FALSE
);
393 nicQmUpdateWmmParms(prAdapter
, NETWORK_TYPE_P2P_INDEX
);
394 #endif /* CFG_SUPPORT_AAA */
397 /* 3 <3> Set MAC HW */
398 /* 4 <3.1> Setup channel and bandwidth */
399 rlmBssInitForAPandIbss(prAdapter
, prBssInfo
);
401 /* 4 <3.2> Reset HW TSF Update Mode and Beacon Mode */
402 nicUpdateBss(prAdapter
, NETWORK_TYPE_P2P_INDEX
);
404 /* 4 <3.3> Update Beacon again for network phy type confirmed. */
405 bssUpdateBeaconContent(prAdapter
, NETWORK_TYPE_P2P_INDEX
);
407 /* 4 <3.4> Setup BSSID */
408 nicPmIndicateBssCreated(prAdapter
, NETWORK_TYPE_P2P_INDEX
);
413 } /* p2pFuncStartGO() */
418 /*----------------------------------------------------------------------------*/
420 * \brief This function is to inform CNM that channel privilege
423 * \param[in] prAdapter Pointer of ADAPTER_T
427 /*----------------------------------------------------------------------------*/
428 VOID
p2pFuncReleaseCh(IN P_ADAPTER_T prAdapter
, IN P_P2P_CHNL_REQ_INFO_T prChnlReqInfo
)
430 P_MSG_CH_ABORT_T prMsgChRelease
= (P_MSG_CH_ABORT_T
) NULL
;
432 DEBUGFUNC("p2pFuncReleaseCh()");
435 ASSERT_BREAK((prAdapter
!= NULL
) && (prChnlReqInfo
!= NULL
));
437 if (!prChnlReqInfo
->fgIsChannelRequested
) {
440 DBGLOG(P2P
, TRACE
, ("P2P Release Channel\n"));
441 prChnlReqInfo
->fgIsChannelRequested
= FALSE
;
444 /* 1. return channel privilege to CNM immediately */
446 (P_MSG_CH_ABORT_T
) cnmMemAlloc(prAdapter
, RAM_TYPE_MSG
, sizeof(MSG_CH_ABORT_T
));
447 if (!prMsgChRelease
) {
448 ASSERT(0); /* Can't release Channel to CNM */
452 prMsgChRelease
->rMsgHdr
.eMsgId
= MID_MNY_CNM_CH_ABORT
;
453 prMsgChRelease
->ucNetTypeIndex
= NETWORK_TYPE_P2P_INDEX
;
454 prMsgChRelease
->ucTokenID
= prChnlReqInfo
->ucSeqNumOfChReq
++;
456 mboxSendMsg(prAdapter
,
457 MBOX_ID_0
, (P_MSG_HDR_T
) prMsgChRelease
, MSG_SEND_METHOD_BUF
);
462 } /* p2pFuncReleaseCh */
465 /*----------------------------------------------------------------------------*/
467 * @brief Process of CHANNEL_REQ_JOIN Initial. Enter CHANNEL_REQ_JOIN State.
473 /*----------------------------------------------------------------------------*/
474 VOID
p2pFuncAcquireCh(IN P_ADAPTER_T prAdapter
, IN P_P2P_CHNL_REQ_INFO_T prChnlReqInfo
)
476 P_MSG_CH_REQ_T prMsgChReq
= (P_MSG_CH_REQ_T
) NULL
;
479 ASSERT_BREAK((prAdapter
!= NULL
) && (prChnlReqInfo
!= NULL
));
481 p2pFuncReleaseCh(prAdapter
, prChnlReqInfo
);
483 /* send message to CNM for acquiring channel */
485 (P_MSG_CH_REQ_T
) cnmMemAlloc(prAdapter
, RAM_TYPE_MSG
, sizeof(MSG_CH_REQ_T
));
488 ASSERT(0); /* Can't indicate CNM for channel acquiring */
492 prMsgChReq
->rMsgHdr
.eMsgId
= MID_MNY_CNM_CH_REQ
;
493 prMsgChReq
->ucNetTypeIndex
= NETWORK_TYPE_P2P_INDEX
;
494 prMsgChReq
->ucTokenID
= ++prChnlReqInfo
->ucSeqNumOfChReq
;
495 prMsgChReq
->eReqType
= CH_REQ_TYPE_JOIN
;
496 prMsgChReq
->u4MaxInterval
= prChnlReqInfo
->u4MaxInterval
;
498 prMsgChReq
->ucPrimaryChannel
= prChnlReqInfo
->ucReqChnlNum
;
499 prMsgChReq
->eRfSco
= prChnlReqInfo
->eChnlSco
;
500 prMsgChReq
->eRfBand
= prChnlReqInfo
->eBand
;
502 kalMemZero(prMsgChReq
->aucBSSID
, MAC_ADDR_LEN
);
504 /* Channel request join BSSID. */
506 mboxSendMsg(prAdapter
, MBOX_ID_0
, (P_MSG_HDR_T
) prMsgChReq
, MSG_SEND_METHOD_BUF
);
508 prChnlReqInfo
->fgIsChannelRequested
= TRUE
;
513 } /* p2pFuncAcquireCh */
517 p2pFuncBeaconUpdate(IN P_ADAPTER_T prAdapter
,
518 IN PUINT_8 pucBcnHdr
,
520 IN PUINT_8 pucBcnBody
,
521 IN UINT_32 u4BodyLen
, IN UINT_32 u4DtimPeriod
, IN UINT_32 u4BcnInterval
)
523 WLAN_STATUS rResultStatus
= WLAN_STATUS_INVALID_DATA
;
524 P_WLAN_BEACON_FRAME_T prBcnFrame
= (P_WLAN_BEACON_FRAME_T
) NULL
;
525 P_BSS_INFO_T prP2pBssInfo
= (P_BSS_INFO_T
) NULL
;
526 P_MSDU_INFO_T prBcnMsduInfo
= (P_MSDU_INFO_T
) NULL
;
527 PUINT_8 pucTIMBody
= (PUINT_8
) NULL
;
528 UINT_16 u2FrameLength
= 0, UINT_16 u2OldBodyLen
= 0;
529 UINT_8 aucIEBuf
[MAX_IE_LENGTH
];
532 ASSERT_BREAK(prAdapter
!= NULL
);
534 prP2pBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_P2P_INDEX
]);
535 prBcnMsduInfo
= prP2pBssInfo
->prBeacon
ASSERT_BREAK(prBcnMsduInfo
!= NULL
);
537 /* TODO: Find TIM IE pointer. */
538 prBcnFrame
= prBcnMsduInfo
->prPacket
;
540 ASSERT_BREAK(prBcnFrame
!= NULL
);
544 UINT_16 u2IELength
= 0, u2Offset
= 0;
545 PUINT_8 pucIEBuf
= prBcnFrame
->aucInfoElem
;
548 prBcnMsduInfo
->u2FrameLength
- prBcnMsduInfo
->ucMacHeaderLength
;
550 IE_FOR_EACH(pucIEBuf
, u2IELength
, u2Offset
) {
551 if ((IE_ID(pucIEBuf
) == ELEM_ID_TIM
) ||
552 ((IE_ID(pucIEBuf
) > ELEM_ID_IBSS_PARAM_SET
)) {
553 pucTIMBody
= pucIEBuf
;
556 u2FrameLength
+= IE_SIZE(pucIEBuf
);
559 if (pucTIMBody
== NULL
) {
560 pucTIMBody
= pucIEBuf
;
563 /* Body not change. */
564 u2OldBodyLen
= (UINT_16
) ((UINT_32
) pucTIMBody
- (UINT_32
) prBcnFrame
->aucInfoElem
);
566 kalMemCmp(aucIEBuf
, pucTIMBody
, u2OldBodyLen
);
570 kalMemCopy(prBcnMsduInfo
->prPacket
, pucBcnHdr
, u4HdrLen
);
571 pucTIMBody
= (PUINT_8
) ((UINT_32
) prBcnMsduInfo
->prPacket
+ u4HdrLen
);
572 prBcnMsduInfo
->ucMacHeaderLength
= (WLAN_MAC_MGMT_HEADER_LEN
+ (TIMESTAMP_FIELD_LEN
+ BEACON_INTERVAL_FIELD_LEN
+ CAP_INFO_FIELD_LEN
));
573 u2FrameLength
= u4HdrLen
; /* Header + Partial Body. */
575 /* Header not change. */
576 u2FrameLength
+= prBcnMsduInfo
->ucMacHeaderLength
;
581 kalMemCopy(pucTIMBody
, pucBcnBody
, u4BodyLen
);
582 u2FrameLength
+= (UINT_16
) u4BodyLen
;
584 kalMemCopy(pucTIMBody
, aucIEBuf
, u2OldBodyLen
);
585 u2FrameLength
+= u2OldBodyLen
;
589 prBcnMsduInfo
->u2FrameLength
= u2FrameLength
;
590 prBcnMsduInfo
->fgIs802_11
= TRUE
;
591 prBcnMsduInfo
->ucNetworkType
= NETWORK_TYPE_P2P_INDEX
;
592 prP2pBssInfo
->u2BeaconInterval
= (UINT_16
) u4BcnInterval
;
593 prP2pBssInfo
->ucDTIMPeriod
= (UINT_8
) u4DtimPeriod
;
594 prP2pBssInfo
->u2CapInfo
= prBcnFrame
->u2CapInfo
;
595 prBcnMsduInfo
->ucPacketType
= 3;
596 rResultStatus
= nicUpdateBeaconIETemplate(prAdapter
,
597 IE_UPD_METHOD_UPDATE_ALL
,
598 NETWORK_TYPE_P2P_INDEX
,
599 prP2pBssInfo
->u2CapInfo
,
600 (PUINT_8
) prBcnFrame
->aucInfoElem
,
601 prBcnMsduInfo
->u2FrameLength
- OFFSET_OF(WLAN_BEACON_FRAME_T
, aucInfoElem
));
602 if (prP2pBssInfo
->eCurrentOPMode
== OP_MODE_ACCESS_POINT
) {
603 /* AP is created, Beacon Update. */
604 nicPmIndicateBssAbort(prAdapter
, NETWORK_TYPE_P2P_INDEX
);
605 nicPmIndicateBssCreated(prAdapter
, NETWORK_TYPE_P2P_INDEX
);
610 return rResultStatus
;
611 } /* p2pFuncBeaconUpdate */
615 p2pFuncBeaconUpdate(IN P_ADAPTER_T prAdapter
,
616 IN P_BSS_INFO_T prP2pBssInfo
,
617 IN P_P2P_BEACON_UPDATE_INFO_T prBcnUpdateInfo
,
618 IN PUINT_8 pucNewBcnHdr
,
619 IN UINT_32 u4NewHdrLen
, IN PUINT_8 pucNewBcnBody
, IN UINT_32 u4NewBodyLen
)
621 WLAN_STATUS rWlanStatus
= WLAN_STATUS_SUCCESS
;
622 P_WLAN_BEACON_FRAME_T prBcnFrame
= (P_WLAN_BEACON_FRAME_T
) NULL
;
623 P_MSDU_INFO_T prBcnMsduInfo
= (P_MSDU_INFO_T
) NULL
;
624 PUINT_8 pucIEBuf
= (PUINT_8
) NULL
;
625 UINT_8 aucIEBuf
[MAX_IE_LENGTH
];
628 ASSERT_BREAK((prAdapter
!= NULL
) && (prP2pBssInfo
!= NULL
) && (prBcnUpdateInfo
!= NULL
));
630 prBcnMsduInfo
= prP2pBssInfo
->prBeacon
;
633 if (prBcnUpdateInfo
->pucBcnHdr
!= NULL
) {
634 ASSERT((UINT_32
) prBcnUpdateInfo
->pucBcnHdr
==
635 ((UINT_32
) prBcnMsduInfo
->prPacket
+ MAC_TX_RESERVED_FIELD
));
638 if (prBcnUpdateInfo
->pucBcnBody
!= NULL
) {
639 ASSERT((UINT_32
) prBcnUpdateInfo
->pucBcnBody
==
640 ((UINT_32
) prBcnUpdateInfo
->pucBcnHdr
+
641 (UINT_32
) prBcnUpdateInfo
->u4BcnHdrLen
));
645 (P_WLAN_BEACON_FRAME_T
) ((UINT_32
) prBcnMsduInfo
->prPacket
+ MAC_TX_RESERVED_FIELD
);
647 if (!pucNewBcnBody
) {
649 pucNewBcnBody
= prBcnUpdateInfo
->pucBcnBody
;
650 ASSERT(u4NewBodyLen
== 0);
651 u4NewBodyLen
= prBcnUpdateInfo
->u4BcnBodyLen
;
653 prBcnUpdateInfo
->u4BcnBodyLen
= u4NewBodyLen
;
656 /* Temp buffer body part. */
657 kalMemCopy(aucIEBuf
, pucNewBcnBody
, u4NewBodyLen
);
660 kalMemCopy(prBcnFrame
, pucNewBcnHdr
, u4NewHdrLen
);
661 prBcnUpdateInfo
->pucBcnHdr
= (PUINT_8
) prBcnFrame
;
662 prBcnUpdateInfo
->u4BcnHdrLen
= u4NewHdrLen
;
666 (PUINT_8
) ((UINT_32
) prBcnUpdateInfo
->pucBcnHdr
+
667 (UINT_32
) prBcnUpdateInfo
->u4BcnHdrLen
);
668 kalMemCopy(pucIEBuf
, aucIEBuf
, u4NewBodyLen
);
669 prBcnUpdateInfo
->pucBcnBody
= pucIEBuf
;
672 prBcnMsduInfo
->u2FrameLength
=
673 (UINT_16
) (prBcnUpdateInfo
->u4BcnHdrLen
+ prBcnUpdateInfo
->u4BcnBodyLen
);
675 prBcnMsduInfo
->ucPacketType
= 3;
676 prBcnMsduInfo
->fgIs802_11
= TRUE
;
677 prBcnMsduInfo
->ucNetworkType
= NETWORK_TYPE_P2P_INDEX
;
680 /* Update BSS INFO related information. */
681 COPY_MAC_ADDR(prP2pBssInfo
->aucOwnMacAddr
, prBcnFrame
->aucSrcAddr
);
682 COPY_MAC_ADDR(prP2pBssInfo
->aucBSSID
, prBcnFrame
->aucBSSID
);
683 prP2pBssInfo
->u2CapInfo
= prBcnFrame
->u2CapInfo
;
685 p2pFuncParseBeaconContent(prAdapter
,
687 (PUINT_8
) prBcnFrame
->aucInfoElem
,
688 (prBcnMsduInfo
->u2FrameLength
-
689 OFFSET_OF(WLAN_BEACON_FRAME_T
, aucInfoElem
)));
692 /* bssUpdateBeaconContent(prAdapter, NETWORK_TYPE_P2P_INDEX); */
694 nicUpdateBeaconIETemplate(prAdapter
,
695 IE_UPD_METHOD_UPDATE_ALL
,
696 NETWORK_TYPE_P2P_INDEX
,
697 prBcnFrame
->u2CapInfo
,
698 (PUINT_8
) prBcnFrame
->aucInfoElem
,
699 (prBcnMsduInfo
->u2FrameLength
-
700 OFFSET_OF(WLAN_BEACON_FRAME_T
, aucInfoElem
)));
705 } /* p2pFuncBeaconUpdate */
709 /* TODO: We do not apply IE in deauth frame set from upper layer now. */
711 p2pFuncDeauth(IN P_ADAPTER_T prAdapter
,
712 IN PUINT_8 pucPeerMacAddr
,
713 IN UINT_16 u2ReasonCode
,
714 IN PUINT_8 pucIEBuf
, IN UINT_16 u2IELen
, IN BOOLEAN fgSendDeauth
)
716 WLAN_STATUS rWlanStatus
= WLAN_STATUS_FAILURE
;
717 P_STA_RECORD_T prCliStaRec
= (P_STA_RECORD_T
) NULL
;
718 P_BSS_INFO_T prP2pBssInfo
= (P_BSS_INFO_T
) NULL
;
719 BOOLEAN fgIsStaFound
= FALSE
;
722 ASSERT_BREAK((prAdapter
!= NULL
) && (pucPeerMacAddr
!= NULL
));
724 prP2pBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_P2P_INDEX
]);
726 prCliStaRec
= cnmGetStaRecByAddress(prAdapter
,
727 NETWORK_TYPE_P2P_INDEX
, pucPeerMacAddr
);
729 switch (prP2pBssInfo
->eCurrentOPMode
) {
730 case OP_MODE_ACCESS_POINT
:
732 P_LINK_T prStaRecOfClientList
= (P_LINK_T
) NULL
;
733 P_LINK_ENTRY_T prLinkEntry
= (P_LINK_ENTRY_T
) NULL
;
735 prStaRecOfClientList
= &(prP2pBssInfo
->rStaRecOfClientList
);
737 LINK_FOR_EACH(prLinkEntry
, prStaRecOfClientList
) {
738 if ((UINT_32
) prCliStaRec
== (UINT_32
) prLinkEntry
) {
739 LINK_REMOVE_KNOWN_ENTRY(prStaRecOfClientList
,
740 &prCliStaRec
->rLinkEntry
);
748 case OP_MODE_INFRASTRUCTURE
:
749 ASSERT(prCliStaRec
== prP2pBssInfo
->prStaRecOfAP
);
750 if (prCliStaRec
!= prP2pBssInfo
->prStaRecOfAP
) {
753 prP2pBssInfo
->prStaRecOfAP
= NULL
;
761 p2pFuncDisconnect(prAdapter
, prCliStaRec
, fgSendDeauth
, u2ReasonCode
);
764 rWlanStatus
= WLAN_STATUS_SUCCESS
;
768 } /* p2pFuncDeauth */
770 /* TODO: We do not apply IE in disassoc frame set from upper layer now. */
772 p2pFuncDisassoc(IN P_ADAPTER_T prAdapter
,
773 IN PUINT_8 pucPeerMacAddr
,
774 IN UINT_16 u2ReasonCode
,
775 IN PUINT_8 pucIEBuf
, IN UINT_16 u2IELen
, IN BOOLEAN fgSendDisassoc
)
777 WLAN_STATUS rWlanStatus
= WLAN_STATUS_FAILURE
;
778 P_STA_RECORD_T prCliStaRec
= (P_STA_RECORD_T
) NULL
;
779 P_BSS_INFO_T prP2pBssInfo
= (P_BSS_INFO_T
) NULL
;
780 BOOLEAN fgIsStaFound
= FALSE
;
783 ASSERT_BREAK((prAdapter
!= NULL
) && (pucPeerMacAddr
!= NULL
));
785 prP2pBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_P2P_INDEX
]);
787 prCliStaRec
= cnmGetStaRecByAddress(prAdapter
,
788 NETWORK_TYPE_P2P_INDEX
, pucPeerMacAddr
);
790 switch (prP2pBssInfo
->eCurrentOPMode
) {
791 case OP_MODE_ACCESS_POINT
:
793 P_LINK_T prStaRecOfClientList
= (P_LINK_T
) NULL
;
794 P_LINK_ENTRY_T prLinkEntry
= (P_LINK_ENTRY_T
) NULL
;
796 prStaRecOfClientList
= &(prP2pBssInfo
->rStaRecOfClientList
);
798 LINK_FOR_EACH(prLinkEntry
, prStaRecOfClientList
) {
799 if ((UINT_32
) prCliStaRec
== (UINT_32
) prLinkEntry
) {
800 LINK_REMOVE_KNOWN_ENTRY(prStaRecOfClientList
,
801 &prCliStaRec
->rLinkEntry
);
803 /* p2pFuncDisconnect(prAdapter, prCliStaRec, fgSendDisassoc, u2ReasonCode); */
810 case OP_MODE_INFRASTRUCTURE
:
811 ASSERT(prCliStaRec
== prP2pBssInfo
->prStaRecOfAP
);
812 if (prCliStaRec
!= prP2pBssInfo
->prStaRecOfAP
) {
815 /* p2pFuncDisconnect(prAdapter, prCliStaRec, fgSendDisassoc, u2ReasonCode); */
816 prP2pBssInfo
->prStaRecOfAP
= NULL
;
825 p2pFuncDisconnect(prAdapter
, prCliStaRec
, fgSendDisassoc
, u2ReasonCode
);
826 /* 20120830 moved into p2pFuncDisconnect(). */
827 /* cnmStaRecFree(prAdapter, prCliStaRec, TRUE); */
831 rWlanStatus
= WLAN_STATUS_SUCCESS
;
835 } /* p2pFuncDisassoc */
837 /*----------------------------------------------------------------------------*/
839 * @brief This function is called to dissolve from group or one group. (Would not change P2P FSM.)
840 * 1. GC: Disconnect from AP. (Send Deauth)
841 * 2. GO: Disconnect all STA
843 * @param[in] prAdapter Pointer to the adapter structure.
847 /*----------------------------------------------------------------------------*/
849 p2pFuncDissolve(IN P_ADAPTER_T prAdapter
,
850 IN P_BSS_INFO_T prP2pBssInfo
, IN BOOLEAN fgSendDeauth
, IN UINT_16 u2ReasonCode
)
852 DEBUGFUNC("p2pFuncDissolve()");
856 ASSERT_BREAK((prAdapter
!= NULL
) && (prP2pBssInfo
!= NULL
));
858 switch (prP2pBssInfo
->eCurrentOPMode
) {
859 case OP_MODE_INFRASTRUCTURE
:
860 /* Reset station record status. */
861 if (prP2pBssInfo
->prStaRecOfAP
) {
862 kalP2PGCIndicateConnectionStatus(prAdapter
->prGlueInfo
,
865 0, REASON_CODE_DEAUTH_LEAVING_BSS
);
867 /* 2012/02/14 frog: After formation before join group, prStaRecOfAP is NULL. */
868 p2pFuncDisconnect(prAdapter
,
869 prP2pBssInfo
->prStaRecOfAP
,
870 fgSendDeauth
, u2ReasonCode
);
873 /* Fix possible KE when RX Beacon & call nicPmIndicateBssConnected(). hit prStaRecOfAP == NULL. */
874 p2pChangeMediaState(prAdapter
, PARAM_MEDIA_STATE_DISCONNECTED
);
876 prP2pBssInfo
->prStaRecOfAP
= NULL
;
879 case OP_MODE_ACCESS_POINT
:
880 /* Under AP mode, we would net send deauthentication frame to each STA.
881 * We only stop the Beacon & let all stations timeout.
884 P_LINK_T prStaRecOfClientList
= (P_LINK_T
) NULL
;
887 authSendDeauthFrame(prAdapter
,
890 u2ReasonCode
, (PFN_TX_DONE_HANDLER
) NULL
);
892 prStaRecOfClientList
= &prP2pBssInfo
->rStaRecOfClientList
;
894 while (!LINK_IS_EMPTY(prStaRecOfClientList
)) {
895 P_STA_RECORD_T prCurrStaRec
;
897 LINK_REMOVE_HEAD(prStaRecOfClientList
, prCurrStaRec
,
900 /* Indicate to Host. */
901 /* kalP2PGOStationUpdate(prAdapter->prGlueInfo, prCurrStaRec, FALSE); */
903 p2pFuncDisconnect(prAdapter
, prCurrStaRec
, TRUE
,
912 return; /* 20110420 -- alreay in Device Mode. */
915 /* Make the deauth frame send to FW ASAP. */
916 wlanAcquirePowerControl(prAdapter
);
917 wlanProcessCommandQueue(prAdapter
, &prAdapter
->prGlueInfo
->rCmdQueue
);
918 wlanReleasePowerControl(prAdapter
);
922 /* Change Connection Status. */
923 p2pChangeMediaState(prAdapter
, PARAM_MEDIA_STATE_DISCONNECTED
);
928 } /* p2pFuncDissolve */
931 /*----------------------------------------------------------------------------*/
933 * @brief This function is called to dissolve from group or one group. (Would not change P2P FSM.)
934 * 1. GC: Disconnect from AP. (Send Deauth)
935 * 2. GO: Disconnect all STA
937 * @param[in] prAdapter Pointer to the adapter structure.
941 /*----------------------------------------------------------------------------*/
943 p2pFuncDisconnect(IN P_ADAPTER_T prAdapter
,
944 IN P_STA_RECORD_T prStaRec
, IN BOOLEAN fgSendDeauth
, IN UINT_16 u2ReasonCode
)
946 P_BSS_INFO_T prP2pBssInfo
= (P_BSS_INFO_T
) NULL
;
947 ENUM_PARAM_MEDIA_STATE_T eOriMediaStatus
;
949 DBGLOG(P2P
, TRACE
, ("p2pFuncDisconnect()"));
952 ASSERT_BREAK((prAdapter
!= NULL
) && (prStaRec
!= NULL
));
954 prP2pBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_P2P_INDEX
]);
955 eOriMediaStatus
= prP2pBssInfo
->eConnectionState
;
957 /* Indicate disconnect. */
959 /* kalP2PGOStationUpdate */
960 /* kalP2PGCIndicateConnectionStatus */
961 /* p2pIndicationOfMediaStateToHost(prAdapter, PARAM_MEDIA_STATE_DISCONNECTED, prStaRec->aucMacAddr); */
962 if (prP2pBssInfo
->eCurrentOPMode
== OP_MODE_ACCESS_POINT
) {
963 kalP2PGOStationUpdate(prAdapter
->prGlueInfo
, prStaRec
, FALSE
);
968 authSendDeauthFrame(prAdapter
,
972 (PFN_TX_DONE_HANDLER
) p2pFsmRunEventDeauthTxDone
);
973 /* Change station state. */
974 cnmStaRecChangeState(prAdapter
, prStaRec
, STA_STATE_1
);
976 /* Reset Station Record Status. */
977 p2pFuncResetStaRecStatus(prAdapter
, prStaRec
);
981 /* Change station state. */
982 cnmStaRecChangeState(prAdapter
, prStaRec
, STA_STATE_1
);
984 /* Reset Station Record Status. */
985 p2pFuncResetStaRecStatus(prAdapter
, prStaRec
);
987 cnmStaRecFree(prAdapter
, prStaRec
, TRUE
);
989 if ((prP2pBssInfo
->eCurrentOPMode
!= OP_MODE_ACCESS_POINT
) ||
990 (prP2pBssInfo
->rStaRecOfClientList
.u4NumElem
== 0)) {
991 DBGLOG(P2P
, TRACE
, ("No More Client, Media Status DISCONNECTED\n"));
992 p2pChangeMediaState(prAdapter
, PARAM_MEDIA_STATE_DISCONNECTED
);
995 if (eOriMediaStatus
!= prP2pBssInfo
->eConnectionState
) {
996 /* Update Disconnected state to FW. */
997 nicUpdateBss(prAdapter
, NETWORK_TYPE_P2P_INDEX
);
1002 if (prP2pBssInfo
->eCurrentOPMode
!= OP_MODE_ACCESS_POINT
) {
1003 /* GO: It would stop Beacon TX. GC: Stop all BSS related PS function. */
1004 nicPmIndicateBssAbort(prAdapter
, NETWORK_TYPE_P2P_INDEX
);
1006 /* Reset RLM related field of BSSINFO. */
1007 rlmBssAborted(prAdapter
, prP2pBssInfo
);
1014 } /* p2pFuncDisconnect */
1022 p2pFuncTxMgmtFrame(IN P_ADAPTER_T prAdapter
,
1023 IN P_P2P_MGMT_TX_REQ_INFO_T prMgmtTxReqInfo
,
1024 IN P_MSDU_INFO_T prMgmtTxMsdu
, IN UINT_64 u8Cookie
)
1026 WLAN_STATUS rWlanStatus
= WLAN_STATUS_SUCCESS
;
1027 P_MSDU_INFO_T prTxMsduInfo
= (P_MSDU_INFO_T
) NULL
;
1028 P_WLAN_MAC_HEADER_T prWlanHdr
= (P_WLAN_MAC_HEADER_T
) NULL
;
1029 P_STA_RECORD_T prStaRec
= (P_STA_RECORD_T
) NULL
;
1032 ASSERT_BREAK((prAdapter
!= NULL
) && (prMgmtTxReqInfo
!= NULL
));
1034 if (prMgmtTxReqInfo
->fgIsMgmtTxRequested
) {
1036 /* 1. prMgmtTxReqInfo->prMgmtTxMsdu != NULL */
1037 /* Packet on driver, not done yet, drop it. */
1038 if ((prTxMsduInfo
= prMgmtTxReqInfo
->prMgmtTxMsdu
) != NULL
) {
1040 kalP2PIndicateMgmtTxStatus(prAdapter
->prGlueInfo
,
1041 prMgmtTxReqInfo
->u8Cookie
,
1043 prTxMsduInfo
->prPacket
,
1044 (UINT_32
) prTxMsduInfo
->u2FrameLength
);
1046 /* Leave it to TX Done handler. */
1047 /* cnmMgtPktFree(prAdapter, prTxMsduInfo); */
1048 prMgmtTxReqInfo
->prMgmtTxMsdu
= NULL
;
1050 /* 2. prMgmtTxReqInfo->prMgmtTxMsdu == NULL */
1051 /* Packet transmitted, wait tx done. (cookie issue) */
1052 /* 20120105 frog - use another u8cookie to store this value. */
1056 ASSERT(prMgmtTxReqInfo
->prMgmtTxMsdu
== NULL
);
1061 (P_WLAN_MAC_HEADER_T
) ((UINT_32
) prMgmtTxMsdu
->prPacket
+
1062 MAC_TX_RESERVED_FIELD
);
1064 cnmGetStaRecByAddress(prAdapter
, NETWORK_TYPE_P2P_INDEX
, prWlanHdr
->aucAddr1
);
1065 prMgmtTxMsdu
->ucNetworkType
= (UINT_8
) NETWORK_TYPE_P2P_INDEX
;
1067 switch (prWlanHdr
->u2FrameCtrl
& MASK_FRAME_TYPE
) {
1068 case MAC_FRAME_PROBE_RSP
:
1069 DBGLOG(P2P
, TRACE
, ("p2pFuncTxMgmtFrame: TX MAC_FRAME_PROBE_RSP\n"));
1070 prMgmtTxMsdu
= p2pFuncProcessP2pProbeRsp(prAdapter
, prMgmtTxMsdu
);
1077 prMgmtTxReqInfo
->u8Cookie
= u8Cookie
;
1078 prMgmtTxReqInfo
->prMgmtTxMsdu
= prMgmtTxMsdu
;
1079 prMgmtTxReqInfo
->fgIsMgmtTxRequested
= TRUE
;
1081 prMgmtTxMsdu
->eSrc
= TX_PACKET_MGMT
;
1082 prMgmtTxMsdu
->ucPacketType
= HIF_TX_PACKET_TYPE_MGMT
;
1083 prMgmtTxMsdu
->ucStaRecIndex
= (prStaRec
!= NULL
) ? (prStaRec
->ucIndex
) : (0xFF);
1084 if (prStaRec
!= NULL
) {
1086 ("Mgmt with station record: " MACSTR
" .\n",
1087 MAC2STR(prStaRec
->aucMacAddr
)));
1090 prMgmtTxMsdu
->ucMacHeaderLength
= WLAN_MAC_MGMT_HEADER_LEN
; /* TODO: undcertain. */
1091 prMgmtTxMsdu
->fgIs802_1x
= FALSE
;
1092 prMgmtTxMsdu
->fgIs802_11
= TRUE
;
1093 prMgmtTxMsdu
->ucTxSeqNum
= nicIncreaseTxSeqNum(prAdapter
);
1094 prMgmtTxMsdu
->pfTxDoneHandler
= p2pFsmRunEventMgmtFrameTxDone
;
1095 prMgmtTxMsdu
->fgIsBasicRate
= TRUE
;
1096 DBGLOG(P2P
, TRACE
, ("Mgmt seq NO. %d .\n", prMgmtTxMsdu
->ucTxSeqNum
));
1098 nicTxEnqueueMsdu(prAdapter
, prMgmtTxMsdu
);
1103 } /* p2pFuncTxMgmtFrame */
1107 VOID
p2pFuncSetChannel(IN P_ADAPTER_T prAdapter
, IN P_RF_CHANNEL_INFO_T prRfChannelInfo
)
1109 P_P2P_CONNECTION_SETTINGS_T prP2pConnSettings
= (P_P2P_CONNECTION_SETTINGS_T
) NULL
;
1112 ASSERT_BREAK((prAdapter
!= NULL
) && (prRfChannelInfo
!= NULL
));
1114 prP2pConnSettings
= prAdapter
->rWifiVar
.prP2PConnSettings
;
1116 prP2pConnSettings
->ucOperatingChnl
= prRfChannelInfo
->ucChannelNum
;
1117 prP2pConnSettings
->eBand
= prRfChannelInfo
->eBand
;
1125 /* p2pFuncSetChannel */
1129 /*----------------------------------------------------------------------------*/
1131 * @brief Retry JOIN for AUTH_MODE_AUTO_SWITCH
1133 * @param[in] prStaRec Pointer to the STA_RECORD_T
1135 * @retval TRUE We will retry JOIN
1136 * @retval FALSE We will not retry JOIN
1138 /*----------------------------------------------------------------------------*/
1140 p2pFuncRetryJOIN(IN P_ADAPTER_T prAdapter
,
1141 IN P_STA_RECORD_T prStaRec
, IN P_P2P_JOIN_INFO_T prJoinInfo
)
1143 P_MSG_JOIN_REQ_T prJoinReqMsg
= (P_MSG_JOIN_REQ_T
) NULL
;
1144 BOOLEAN fgRetValue
= FALSE
;
1147 ASSERT_BREAK((prAdapter
!= NULL
) && (prStaRec
!= NULL
) && (prJoinInfo
!= NULL
));
1149 /* Retry other AuthType if possible */
1150 if (!prJoinInfo
->ucAvailableAuthTypes
) {
1154 if (prJoinInfo
->ucAvailableAuthTypes
& (UINT_8
) AUTH_TYPE_SHARED_KEY
) {
1157 ("RETRY JOIN INIT: Retry Authentication with AuthType == SHARED_KEY.\n"));
1159 prJoinInfo
->ucAvailableAuthTypes
&= ~(UINT_8
) AUTH_TYPE_SHARED_KEY
;
1161 prStaRec
->ucAuthAlgNum
= (UINT_8
) AUTH_ALGORITHM_NUM_SHARED_KEY
;
1164 ("RETRY JOIN INIT: Retry Authentication with Unexpected AuthType.\n"));
1169 prJoinInfo
->ucAvailableAuthTypes
= 0; /* No more available Auth Types */
1171 /* Trigger SAA to start JOIN process. */
1173 (P_MSG_JOIN_REQ_T
) cnmMemAlloc(prAdapter
, RAM_TYPE_MSG
, sizeof(MSG_JOIN_REQ_T
));
1174 if (!prJoinReqMsg
) {
1175 ASSERT(0); /* Can't trigger SAA FSM */
1179 prJoinReqMsg
->rMsgHdr
.eMsgId
= MID_P2P_SAA_FSM_START
;
1180 prJoinReqMsg
->ucSeqNum
= ++prJoinInfo
->ucSeqNumOfReqMsg
;
1181 prJoinReqMsg
->prStaRec
= prStaRec
;
1183 mboxSendMsg(prAdapter
, MBOX_ID_0
, (P_MSG_HDR_T
) prJoinReqMsg
, MSG_SEND_METHOD_BUF
);
1193 } /* end of p2pFuncRetryJOIN() */
1199 /*----------------------------------------------------------------------------*/
1201 * @brief This function will update the contain of BSS_INFO_T for AIS network once
1202 * the association was completed.
1204 * @param[in] prStaRec Pointer to the STA_RECORD_T
1205 * @param[in] prAssocRspSwRfb Pointer to SW RFB of ASSOC RESP FRAME.
1209 /*----------------------------------------------------------------------------*/
1211 p2pFuncUpdateBssInfoForJOIN(IN P_ADAPTER_T prAdapter
,
1212 IN P_BSS_DESC_T prBssDesc
,
1213 IN P_STA_RECORD_T prStaRec
, IN P_SW_RFB_T prAssocRspSwRfb
)
1215 P_BSS_INFO_T prP2pBssInfo
= (P_BSS_INFO_T
) NULL
;
1216 P_P2P_CONNECTION_SETTINGS_T prP2pConnSettings
= (P_P2P_CONNECTION_SETTINGS_T
) NULL
;
1217 P_WLAN_ASSOC_RSP_FRAME_T prAssocRspFrame
= (P_WLAN_ASSOC_RSP_FRAME_T
) NULL
;
1221 DEBUGFUNC("p2pUpdateBssInfoForJOIN()");
1225 ASSERT(prAssocRspSwRfb
);
1227 prP2pBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_P2P_INDEX
]);
1228 prP2pConnSettings
= prAdapter
->rWifiVar
.prP2PConnSettings
;
1229 prAssocRspFrame
= (P_WLAN_ASSOC_RSP_FRAME_T
) prAssocRspSwRfb
->pvHeader
;
1231 DBGLOG(P2P
, INFO
, ("Update P2P_BSS_INFO_T and apply settings to MAC\n"));
1233 /* 3 <1> Update BSS_INFO_T from AIS_FSM_INFO_T or User Settings */
1234 /* 4 <1.1> Setup Operation Mode */
1235 prP2pBssInfo
->eCurrentOPMode
= OP_MODE_INFRASTRUCTURE
;
1237 /* 4 <1.2> Setup SSID */
1238 COPY_SSID(prP2pBssInfo
->aucSSID
,
1239 prP2pBssInfo
->ucSSIDLen
,
1240 prP2pConnSettings
->aucSSID
, prP2pConnSettings
->ucSSIDLen
);
1242 if (prBssDesc
== NULL
) {
1243 /* Target BSS NULL. */
1244 DBGLOG(P2P
, TRACE
, ("Target BSS NULL\n"));
1249 if (UNEQUAL_MAC_ADDR(prBssDesc
->aucBSSID
, prAssocRspFrame
->aucBSSID
)) {
1252 /* 4 <1.3> Setup Channel, Band */
1253 prP2pBssInfo
->ucPrimaryChannel
= prBssDesc
->ucChannelNum
;
1254 prP2pBssInfo
->eBand
= prBssDesc
->eBand
;
1257 /* 3 <2> Update BSS_INFO_T from STA_RECORD_T */
1258 /* 4 <2.1> Save current AP's STA_RECORD_T and current AID */
1259 prP2pBssInfo
->prStaRecOfAP
= prStaRec
;
1260 prP2pBssInfo
->u2AssocId
= prStaRec
->u2AssocId
;
1262 /* 4 <2.2> Setup Capability */
1263 prP2pBssInfo
->u2CapInfo
= prStaRec
->u2CapInfo
; /* Use AP's Cap Info as BSS Cap Info */
1265 if (prP2pBssInfo
->u2CapInfo
& CAP_INFO_SHORT_PREAMBLE
) {
1266 prP2pBssInfo
->fgIsShortPreambleAllowed
= TRUE
;
1268 prP2pBssInfo
->fgIsShortPreambleAllowed
= FALSE
;
1271 /* 4 <2.3> Setup PHY Attributes and Basic Rate Set/Operational Rate Set */
1272 prP2pBssInfo
->ucPhyTypeSet
= prStaRec
->ucDesiredPhyTypeSet
;
1274 prP2pBssInfo
->ucNonHTBasicPhyType
= prStaRec
->ucNonHTBasicPhyType
;
1276 prP2pBssInfo
->u2OperationalRateSet
= prStaRec
->u2OperationalRateSet
;
1277 prP2pBssInfo
->u2BSSBasicRateSet
= prStaRec
->u2BSSBasicRateSet
;
1280 /* 3 <3> Update BSS_INFO_T from SW_RFB_T (Association Resp Frame) */
1281 /* 4 <3.1> Setup BSSID */
1282 COPY_MAC_ADDR(prP2pBssInfo
->aucBSSID
, prAssocRspFrame
->aucBSSID
);
1285 u2IELength
= (UINT_16
) ((prAssocRspSwRfb
->u2PacketLen
- prAssocRspSwRfb
->u2HeaderLen
) -
1286 (OFFSET_OF(WLAN_ASSOC_RSP_FRAME_T
, aucInfoElem
[0]) -
1287 WLAN_MAC_MGMT_HEADER_LEN
));
1288 pucIE
= prAssocRspFrame
->aucInfoElem
;
1291 /* 4 <3.2> Parse WMM and setup QBSS flag */
1292 /* Parse WMM related IEs and configure HW CRs accordingly */
1293 mqmProcessAssocRsp(prAdapter
, prAssocRspSwRfb
, pucIE
, u2IELength
);
1295 prP2pBssInfo
->fgIsQBSS
= prStaRec
->fgIsQoS
;
1297 /* 3 <4> Update BSS_INFO_T from BSS_DESC_T */
1300 prBssDesc
->fgIsConnecting
= FALSE
;
1301 prBssDesc
->fgIsConnected
= TRUE
;
1303 /* 4 <4.1> Setup MIB for current BSS */
1304 prP2pBssInfo
->u2BeaconInterval
= prBssDesc
->u2BeaconInterval
;
1305 /* NOTE: Defer ucDTIMPeriod updating to when beacon is received after connection */
1306 prP2pBssInfo
->ucDTIMPeriod
= 0;
1307 prP2pBssInfo
->u2ATIMWindow
= 0;
1309 prP2pBssInfo
->ucBeaconTimeoutCount
= AIS_BEACON_TIMEOUT_COUNT_INFRA
;
1311 /* 4 <4.2> Update HT information and set channel */
1312 /* Record HT related parameters in rStaRec and rBssInfo
1313 * Note: it shall be called before nicUpdateBss()
1315 rlmProcessAssocRsp(prAdapter
, prAssocRspSwRfb
, pucIE
, u2IELength
);
1317 /* 4 <4.3> Sync with firmware for BSS-INFO */
1318 nicUpdateBss(prAdapter
, NETWORK_TYPE_P2P_INDEX
);
1320 /* 4 <4.4> *DEFER OPERATION* nicPmIndicateBssConnected() will be invoked */
1321 /* inside scanProcessBeaconAndProbeResp() after 1st beacon is received */
1324 } /* end of p2pUpdateBssInfoForJOIN() */
1328 /*----------------------------------------------------------------------------*/
1330 * @brief This function will validate the Rx Auth Frame and then return
1331 * the status code to AAA to indicate if need to perform following actions
1332 * when the specified conditions were matched.
1334 * @param[in] prAdapter Pointer to the Adapter structure.
1335 * @param[in] prSwRfb Pointer to SW RFB data structure.
1336 * @param[in] pprStaRec Pointer to pointer of STA_RECORD_T structure.
1337 * @param[out] pu2StatusCode The Status Code of Validation Result
1339 * @retval TRUE Reply the Auth
1340 * @retval FALSE Don't reply the Auth
1342 /*----------------------------------------------------------------------------*/
1344 p2pFuncValidateAuth(IN P_ADAPTER_T prAdapter
,
1345 IN P_SW_RFB_T prSwRfb
, IN PP_STA_RECORD_T pprStaRec
, OUT PUINT_16 pu2StatusCode
)
1347 BOOLEAN fgReplyAuth
= TRUE
;
1348 P_BSS_INFO_T prP2pBssInfo
= (P_BSS_INFO_T
) NULL
;
1349 P_STA_RECORD_T prStaRec
= (P_STA_RECORD_T
) NULL
;
1350 P_WLAN_AUTH_FRAME_T prAuthFrame
= (P_WLAN_AUTH_FRAME_T
) NULL
;
1352 DBGLOG(P2P
, TRACE
, ("p2pValidate Authentication Frame\n"))
1355 ASSERT_BREAK((prAdapter
!= NULL
) &&
1356 (prSwRfb
!= NULL
) && (pprStaRec
!= NULL
) && (pu2StatusCode
!= NULL
));
1359 *pu2StatusCode
= STATUS_CODE_REQ_DECLINED
;
1361 prP2pBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_P2P_INDEX
]);
1362 prAuthFrame
= (P_WLAN_AUTH_FRAME_T
) prSwRfb
->pvHeader
;
1365 if ((prP2pBssInfo
->eCurrentOPMode
!= OP_MODE_ACCESS_POINT
)
1366 || (prP2pBssInfo
->eIntendOPMode
!= OP_MODE_NUM
)) {
1367 /* We are not under AP Mode yet. */
1368 fgReplyAuth
= FALSE
;
1370 ("Current OP mode is not under AP mode. (%d)\n",
1371 prP2pBssInfo
->eCurrentOPMode
));
1375 prStaRec
= cnmGetStaRecByAddress(prAdapter
,
1376 (UINT_8
) NETWORK_TYPE_P2P_INDEX
,
1377 prAuthFrame
->aucSrcAddr
);
1380 prStaRec
= cnmStaRecAlloc(prAdapter
, (UINT_8
) NETWORK_TYPE_P2P_INDEX
);
1382 /* TODO(Kevin): Error handling of allocation of STA_RECORD_T for
1383 * exhausted case and do removal of unused STA_RECORD_T.
1385 /* Sent a message event to clean un-used STA_RECORD_T. */
1388 COPY_MAC_ADDR(prStaRec
->aucMacAddr
, prAuthFrame
->aucSrcAddr
);
1390 prSwRfb
->ucStaRecIdx
= prStaRec
->ucIndex
;
1392 prStaRec
->u2BSSBasicRateSet
= prP2pBssInfo
->u2BSSBasicRateSet
;
1394 prStaRec
->u2DesiredNonHTRateSet
= RATE_SET_ERP_P2P
;
1396 prStaRec
->u2OperationalRateSet
= RATE_SET_ERP_P2P
;
1397 prStaRec
->ucPhyTypeSet
= PHY_TYPE_SET_802_11GN
;
1398 prStaRec
->eStaType
= STA_TYPE_P2P_GC
;
1400 /* NOTE(Kevin): Better to change state here, not at TX Done */
1401 cnmStaRecChangeState(prAdapter
, prStaRec
, STA_STATE_1
);
1403 prSwRfb
->ucStaRecIdx
= prStaRec
->ucIndex
;
1405 if ((prStaRec
->ucStaState
> STA_STATE_1
) && (IS_STA_IN_P2P(prStaRec
))) {
1407 cnmStaRecChangeState(prAdapter
, prStaRec
, STA_STATE_1
);
1409 p2pFuncResetStaRecStatus(prAdapter
, prStaRec
);
1411 bssRemoveStaRecFromClientList(prAdapter
, prP2pBssInfo
, prStaRec
);
1416 if (prP2pBssInfo
->rStaRecOfClientList
.u4NumElem
> P2P_MAXIMUM_CLIENT_COUNT
||
1417 kalP2PMaxClients(prAdapter
->prGlueInfo
,
1418 prP2pBssInfo
->rStaRecOfClientList
.u4NumElem
)) {
1419 /* GROUP limit full. */
1422 ("Group Limit Full. (%d)\n",
1423 (INT_16
) prP2pBssInfo
->rStaRecOfClientList
.u4NumElem
));
1424 bssRemoveStaRecFromClientList(prAdapter
, prP2pBssInfo
, prStaRec
);
1425 cnmStaRecFree(prAdapter
, prStaRec
, FALSE
);
1428 /* Hotspot Blacklist */
1429 if (prAuthFrame
->aucSrcAddr
) {
1430 if (kalP2PCmpBlackList
1431 (prAdapter
->prGlueInfo
, prAuthFrame
->aucSrcAddr
)) {
1432 fgReplyAuth
= FALSE
;
1438 /* prStaRec->eStaType = STA_TYPE_INFRA_CLIENT; */
1439 prStaRec
->eStaType
= STA_TYPE_P2P_GC
;
1441 prStaRec
->ucNetTypeIndex
= NETWORK_TYPE_P2P_INDEX
;
1443 /* Update Station Record - Status/Reason Code */
1444 prStaRec
->u2StatusCode
= STATUS_CODE_SUCCESSFUL
;
1446 prStaRec
->ucJoinFailureCount
= 0;
1448 *pprStaRec
= prStaRec
;
1450 *pu2StatusCode
= STATUS_CODE_SUCCESSFUL
;
1457 } /* p2pFuncValidateAuth */
1462 VOID
p2pFuncResetStaRecStatus(IN P_ADAPTER_T prAdapter
, IN P_STA_RECORD_T prStaRec
)
1465 if ((prAdapter
== NULL
) || (prStaRec
== NULL
)) {
1471 prStaRec
->u2StatusCode
= STATUS_CODE_SUCCESSFUL
;
1472 prStaRec
->u2ReasonCode
= REASON_CODE_RESERVED
;
1473 prStaRec
->ucJoinFailureCount
= 0;
1474 prStaRec
->fgTransmitKeyExist
= FALSE
;
1476 prStaRec
->fgSetPwrMgtBit
= FALSE
;
1481 } /* p2pFuncResetStaRecStatus */
1485 /*----------------------------------------------------------------------------*/
1487 * @brief The function is used to initialize the value of the connection settings for
1494 /*----------------------------------------------------------------------------*/
1496 p2pFuncInitConnectionSettings(IN P_ADAPTER_T prAdapter
,
1497 IN P_P2P_CONNECTION_SETTINGS_T prP2PConnSettings
)
1499 P_DEVICE_TYPE_T prDevType
;
1500 UINT_8 aucDefaultDevName
[] = P2P_DEFAULT_DEV_NAME
;
1501 UINT_8 aucWfaOui
[] = VENDOR_OUI_WFA
;
1503 ASSERT(prP2PConnSettings
);
1505 /* Setup Default Device Name */
1506 prP2PConnSettings
->ucDevNameLen
= P2P_DEFAULT_DEV_NAME_LEN
;
1507 kalMemCopy(prP2PConnSettings
->aucDevName
, aucDefaultDevName
, sizeof(aucDefaultDevName
));
1509 /* Setup Primary Device Type (Big-Endian) */
1510 prDevType
= &prP2PConnSettings
->rPrimaryDevTypeBE
;
1512 prDevType
->u2CategoryId
= HTONS(P2P_DEFAULT_PRIMARY_CATEGORY_ID
);
1513 prDevType
->u2SubCategoryId
= HTONS(P2P_DEFAULT_PRIMARY_SUB_CATEGORY_ID
);
1515 prDevType
->aucOui
[0] = aucWfaOui
[0];
1516 prDevType
->aucOui
[1] = aucWfaOui
[1];
1517 prDevType
->aucOui
[2] = aucWfaOui
[2];
1518 prDevType
->aucOui
[3] = VENDOR_OUI_TYPE_WPS
;
1520 /* Setup Secondary Device Type */
1521 prP2PConnSettings
->ucSecondaryDevTypeCount
= 0;
1523 /* Setup Default Config Method */
1524 prP2PConnSettings
->eConfigMethodSelType
= ENUM_CONFIG_METHOD_SEL_AUTO
;
1525 prP2PConnSettings
->u2ConfigMethodsSupport
= P2P_DEFAULT_CONFIG_METHOD
;
1526 prP2PConnSettings
->u2TargetConfigMethod
= 0;
1527 prP2PConnSettings
->u2LocalConfigMethod
= 0;
1528 prP2PConnSettings
->fgIsPasswordIDRdy
= FALSE
;
1530 /* For Device Capability */
1531 prP2PConnSettings
->fgSupportServiceDiscovery
= FALSE
;
1532 prP2PConnSettings
->fgSupportClientDiscoverability
= TRUE
;
1533 prP2PConnSettings
->fgSupportConcurrentOperation
= TRUE
;
1534 prP2PConnSettings
->fgSupportInfraManaged
= FALSE
;
1535 prP2PConnSettings
->fgSupportInvitationProcedure
= FALSE
;
1537 /* For Group Capability */
1538 #if CFG_SUPPORT_PERSISTENT_GROUP
1539 prP2PConnSettings
->fgSupportPersistentP2PGroup
= TRUE
;
1541 prP2PConnSettings
->fgSupportPersistentP2PGroup
= FALSE
;
1543 prP2PConnSettings
->fgSupportIntraBSSDistribution
= TRUE
;
1544 prP2PConnSettings
->fgSupportCrossConnection
= TRUE
;
1545 prP2PConnSettings
->fgSupportPersistentReconnect
= FALSE
;
1547 prP2PConnSettings
->fgSupportOppPS
= FALSE
;
1548 prP2PConnSettings
->u2CTWindow
= P2P_CTWINDOW_DEFAULT
;
1550 /* For Connection Settings. */
1551 prP2PConnSettings
->eAuthMode
= AUTH_MODE_OPEN
;
1553 prP2PConnSettings
->prTargetP2pDesc
= NULL
;
1554 prP2PConnSettings
->ucSSIDLen
= 0;
1557 prP2PConnSettings
->fgIsScanReqIssued
= FALSE
;
1558 prP2PConnSettings
->fgIsServiceDiscoverIssued
= FALSE
;
1559 prP2PConnSettings
->fgP2pGroupLimit
= FALSE
;
1560 prP2PConnSettings
->ucOperatingChnl
= 0;
1561 prP2PConnSettings
->ucListenChnl
= 0;
1562 prP2PConnSettings
->ucTieBreaker
= (UINT_8
) (kalRandomNumber() & 0x1);
1564 prP2PConnSettings
->eFormationPolicy
= ENUM_P2P_FORMATION_POLICY_AUTO
;
1567 } /* p2pFuncInitConnectionSettings */
1573 /*----------------------------------------------------------------------------*/
1575 * @brief This function will validate the Rx Assoc Req Frame and then return
1576 * the status code to AAA to indicate if need to perform following actions
1577 * when the specified conditions were matched.
1579 * @param[in] prAdapter Pointer to the Adapter structure.
1580 * @param[in] prSwRfb Pointer to SW RFB data structure.
1581 * @param[out] pu2StatusCode The Status Code of Validation Result
1583 * @retval TRUE Reply the Assoc Resp
1584 * @retval FALSE Don't reply the Assoc Resp
1586 /*----------------------------------------------------------------------------*/
1588 p2pFuncValidateAssocReq(IN P_ADAPTER_T prAdapter
, IN P_SW_RFB_T prSwRfb
, OUT PUINT_16 pu2StatusCode
)
1590 BOOLEAN fgReplyAssocResp
= TRUE
;
1591 P_WLAN_ASSOC_REQ_FRAME_T prAssocReqFrame
= (P_WLAN_ASSOC_REQ_FRAME_T
) NULL
;
1592 P_STA_RECORD_T prStaRec
= (P_STA_RECORD_T
) NULL
;
1593 P_BSS_INFO_T prP2pBssInfo
= (P_BSS_INFO_T
) NULL
;
1595 P_WFD_CFG_SETTINGS_T prWfdCfgSettings
= (P_WFD_CFG_SETTINGS_T
) NULL
;
1596 P_WFD_ATTRIBUTE_T prWfdAttribute
= (P_WFD_ATTRIBUTE_T
) NULL
;
1597 BOOLEAN fgNeedFree
= FALSE
;
1601 /* TODO(Kevin): Call P2P functions to check ..
1602 2. Check we can accept connection from thsi peer
1603 a. If we are in PROVISION state, only accept the peer we do the GO formation previously.
1604 b. If we are in OPERATION state, only accept the other peer when P2P_GROUP_LIMIT is 0.
1605 3. Check Black List here.
1609 ASSERT_BREAK((prAdapter
!= NULL
) && (prSwRfb
!= NULL
) && (pu2StatusCode
!= NULL
));
1611 *pu2StatusCode
= STATUS_CODE_REQ_DECLINED
;
1612 prP2pBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_P2P_INDEX
]);
1613 prAssocReqFrame
= (P_WLAN_ASSOC_REQ_FRAME_T
) prSwRfb
->pvHeader
;
1615 prStaRec
= cnmGetStaRecByIndex(prAdapter
, prSwRfb
->ucStaRecIdx
);
1617 if (prStaRec
== NULL
) {
1618 /* Station record should be ready while RX AUTH frame. */
1619 fgReplyAssocResp
= FALSE
;
1623 prStaRec
->ucRCPI
= prSwRfb
->prHifRxHdr
->ucRcpi
;
1626 prStaRec
->u2DesiredNonHTRateSet
&= prP2pBssInfo
->u2OperationalRateSet
;
1627 prStaRec
->ucDesiredPhyTypeSet
= prStaRec
->ucPhyTypeSet
& prP2pBssInfo
->ucPhyTypeSet
;
1629 if (prStaRec
->ucDesiredPhyTypeSet
== 0) {
1630 /* The station only support 11B rate. */
1631 *pu2StatusCode
= STATUS_CODE_ASSOC_DENIED_RATE_NOT_SUPPORTED
;
1634 #if CFG_SUPPORT_WFD && 1
1635 /* LOG_FUNC("Skip check WFD IE becasue some API is not ready\n"); /* Eddie */ */
1636 if (!prAdapter
->rWifiVar
.prP2pFsmInfo
) {
1637 fgReplyAssocResp
= FALSE
;
1642 prWfdCfgSettings
= &prAdapter
->rWifiVar
.prP2pFsmInfo
->rWfdConfigureSettings
;
1643 DBGLOG(P2P
, INFO
, ("Current WfdCfgSettings wfd_en %u wfd_info 0x%x wfd_policy 0x%x wfd_flag 0x%x\n", prWfdCfgSettings
->ucWfdEnable
, prWfdCfgSettings
->u2WfdDevInfo
, prWfdCfgSettings
->u4WfdPolicy
, prWfdCfgSettings
->u4WfdFlag
)); /* Eddie */
1644 if (prWfdCfgSettings
->ucWfdEnable
) {
1645 if (prWfdCfgSettings
->u4WfdPolicy
& BIT(6)) {
1650 /* UINT_16 u2AttriListLen = 0; */
1651 UINT_16 u2WfdDevInfo
= 0;
1652 P_WFD_DEVICE_INFORMATION_IE_T prAttriWfdDevInfo
=
1653 (P_WFD_DEVICE_INFORMATION_IE_T
) NULL
;
1655 /* fgNeedFree = p2pFuncGetAttriList(prAdapter, */
1656 /* VENDOR_OUI_TYPE_WFD, */
1657 /* (PUINT_8)prAssocReqFrame->aucInfoElem, */
1658 /* (prSwRfb->u2PacketLen - OFFSET_OF(WLAN_ASSOC_REQ_FRAME_T, aucInfoElem)), */
1659 /* (PPUINT_8)&prWfdAttribute, */
1660 /* &u2AttriListLen); */
1662 prAttriWfdDevInfo
= (P_WFD_DEVICE_INFORMATION_IE_T
)
1663 p2pFuncGetSpecAttri(prAdapter
,
1664 VENDOR_OUI_TYPE_WFD
,
1665 (PUINT_8
) prAssocReqFrame
->aucInfoElem
,
1666 (prSwRfb
->u2PacketLen
-
1667 OFFSET_OF(WLAN_ASSOC_REQ_FRAME_T
,
1669 WFD_ATTRI_ID_DEV_INFO
);
1671 if ((prWfdCfgSettings
->u4WfdPolicy
& BIT(5))
1672 && (prAttriWfdDevInfo
!= NULL
)) {
1673 /* Rejected with WFD IE. */
1677 if ((prWfdCfgSettings
->u4WfdPolicy
& BIT(0))
1678 && (prAttriWfdDevInfo
== NULL
)) {
1679 /* Rejected without WFD IE. */
1683 if (prAttriWfdDevInfo
!= NULL
) {
1685 /* prAttriWfdDevInfo = (P_WFD_DEVICE_INFORMATION_IE_T)p2pFuncGetSpecAttri(prAdapter, */
1686 /* VENDOR_OUI_TYPE_WFD, */
1687 /* (PUINT_8)prWfdAttribute, */
1688 /* u2AttriListLen, */
1689 /* WFD_ATTRI_ID_DEV_INFO); */
1690 /* if (prAttriWfdDevInfo == NULL) { */
1691 /* /* No such attribute. */ */
1695 WLAN_GET_FIELD_BE16(&prAttriWfdDevInfo
->u2WfdDevInfo
,
1698 ("RX Assoc Req WFD Info:0x%x.\n", u2WfdDevInfo
));
1700 if ((prWfdCfgSettings
->u4WfdPolicy
& BIT(1))
1701 && ((u2WfdDevInfo
& 0x3) == 0x0)) {
1702 /* Rejected because of SOURCE. */
1706 if ((prWfdCfgSettings
->u4WfdPolicy
& BIT(2))
1707 && ((u2WfdDevInfo
& 0x3) == 0x1)) {
1708 /* Rejected because of Primary Sink. */
1712 if ((prWfdCfgSettings
->u4WfdPolicy
& BIT(3))
1713 && ((u2WfdDevInfo
& 0x3) == 0x2)) {
1714 /* Rejected because of Secondary Sink. */
1718 if ((prWfdCfgSettings
->u4WfdPolicy
& BIT(4))
1719 && ((u2WfdDevInfo
& 0x3) == 0x3)) {
1720 /* Rejected because of Source & Primary Sink. */
1726 if (prWfdCfgSettings
->u4WfdFlag
& WFD_FLAGS_DEV_INFO_VALID
) {
1728 if ((prWfdCfgSettings
->u2WfdDevInfo
& BITS(0, 1)) ==
1730 /* P_MSG_WFD_CONFIG_SETTINGS_CHANGED_T prMsgWfdCfgUpdate = (P_MSG_WFD_CONFIG_SETTINGS_CHANGED_T)NULL; */
1732 prWfdCfgSettings
->u2WfdDevInfo
;
1734 /* We may change role here if we are dual role */
1736 if ((u2WfdDevInfo
& BITS(0, 1)) ==
1737 0x00 /* Peer is Source */) {
1739 ("WFD: Switch role to primary sink\n"));
1741 prWfdCfgSettings
->u2WfdDevInfo
&=
1743 prWfdCfgSettings
->u2WfdDevInfo
|=
1746 /* event to annonce the role is chanaged to P-Sink */
1748 } else if ((u2WfdDevInfo
& BITS(0, 1)) ==
1749 0x01 /* Peer is P-Sink */) {
1752 ("WFD: Switch role to source\n"));
1753 prWfdCfgSettings
->u2WfdDevInfo
&=
1755 /* event to annonce the role is chanaged to Source */
1759 ("WFD: Peer role is wrong type(dev 0x%x)\n",
1762 ("WFD: Switch role to source\n"));
1763 prWfdCfgSettings
->u2WfdDevInfo
&=
1765 /* event to annonce the role is chanaged to Source */
1768 p2pFsmRunEventWfdSettingUpdate(prAdapter
,
1771 } /* Dual role p2p->wfd_params->WfdDevInfo */
1774 /* WFD_FLAG_DEV_INFO_VALID */
1777 * Do nothing. Accept the connection request.
1786 *pu2StatusCode
= STATUS_CODE_SUCCESSFUL
;
1791 if ((prWfdAttribute
) && (fgNeedFree
)) {
1792 kalMemFree(prWfdAttribute
, VIR_MEM_TYPE
, WPS_MAXIMUM_ATTRIBUTES_CACHE_SIZE
);
1796 return fgReplyAssocResp
;
1798 } /* p2pFuncValidateAssocReq */
1803 /*----------------------------------------------------------------------------*/
1805 * @brief This function is used to check the P2P IE
1810 /*----------------------------------------------------------------------------*/
1812 p2pFuncParseCheckForP2PInfoElem(IN P_ADAPTER_T prAdapter
, IN PUINT_8 pucBuf
, OUT PUINT_8 pucOuiType
)
1814 UINT_8 aucWfaOui
[] = VENDOR_OUI_WFA_SPECIFIC
;
1815 P_IE_WFA_T prWfaIE
= (P_IE_WFA_T
) NULL
;
1818 ASSERT_BREAK((prAdapter
!= NULL
) && (pucBuf
!= NULL
) && (pucOuiType
!= NULL
));
1820 prWfaIE
= (P_IE_WFA_T
) pucBuf
;
1822 if (IE_LEN(pucBuf
) <= ELEM_MIN_LEN_WFA_OUI_TYPE_SUBTYPE
) {
1824 } else if (prWfaIE
->aucOui
[0] != aucWfaOui
[0] ||
1825 prWfaIE
->aucOui
[1] != aucWfaOui
[1] ||
1826 prWfaIE
->aucOui
[2] != aucWfaOui
[2]) {
1830 *pucOuiType
= prWfaIE
->ucOuiType
;
1836 } /* p2pFuncParseCheckForP2PInfoElem */
1841 /*----------------------------------------------------------------------------*/
1843 * @brief This function will validate the Rx Probe Request Frame and then return
1844 * result to BSS to indicate if need to send the corresponding Probe Response
1845 * Frame if the specified conditions were matched.
1847 * @param[in] prAdapter Pointer to the Adapter structure.
1848 * @param[in] prSwRfb Pointer to SW RFB data structure.
1849 * @param[out] pu4ControlFlags Control flags for replying the Probe Response
1851 * @retval TRUE Reply the Probe Response
1852 * @retval FALSE Don't reply the Probe Response
1854 /*----------------------------------------------------------------------------*/
1856 p2pFuncValidateProbeReq(IN P_ADAPTER_T prAdapter
,
1857 IN P_SW_RFB_T prSwRfb
, OUT PUINT_32 pu4ControlFlags
)
1859 BOOLEAN fgIsReplyProbeRsp
= FALSE
;
1860 P_P2P_FSM_INFO_T prP2pFsmInfo
= (P_P2P_FSM_INFO_T
) NULL
;
1862 DEBUGFUNC("p2pFuncValidateProbeReq");
1863 DBGLOG(P2P
, TRACE
, ("p2pFuncValidateProbeReq\n"));
1867 ASSERT_BREAK((prAdapter
!= NULL
) && (prSwRfb
!= NULL
));
1869 prP2pFsmInfo
= prAdapter
->rWifiVar
.prP2pFsmInfo
;
1871 if (prP2pFsmInfo
->u4P2pPacketFilter
& PARAM_PACKET_FILTER_PROBE_REQ
) {
1873 printk("p2pFuncValidateProbeReq\n");
1875 /* Leave the probe response to p2p_supplicant. */
1876 kalP2PIndicateRxMgmtFrame(prAdapter
->prGlueInfo
, prSwRfb
);
1881 return fgIsReplyProbeRsp
;
1883 } /* end of p2pFuncValidateProbeReq() */
1887 /*----------------------------------------------------------------------------*/
1889 * @brief This function will validate the Rx Probe Request Frame and then return
1890 * result to BSS to indicate if need to send the corresponding Probe Response
1891 * Frame if the specified conditions were matched.
1893 * @param[in] prAdapter Pointer to the Adapter structure.
1894 * @param[in] prSwRfb Pointer to SW RFB data structure.
1895 * @param[out] pu4ControlFlags Control flags for replying the Probe Response
1897 * @retval TRUE Reply the Probe Response
1898 * @retval FALSE Don't reply the Probe Response
1900 /*----------------------------------------------------------------------------*/
1901 VOID
p2pFuncValidateRxActionFrame(IN P_ADAPTER_T prAdapter
, IN P_SW_RFB_T prSwRfb
)
1903 P_P2P_FSM_INFO_T prP2pFsmInfo
= (P_P2P_FSM_INFO_T
) NULL
;
1905 DEBUGFUNC("p2pFuncValidateProbeReq");
1909 ASSERT_BREAK((prAdapter
!= NULL
) && (prSwRfb
!= NULL
));
1911 prP2pFsmInfo
= prAdapter
->rWifiVar
.prP2pFsmInfo
;
1913 if (prP2pFsmInfo
->u4P2pPacketFilter
& PARAM_PACKET_FILTER_ACTION_FRAME
) {
1914 /* Leave the probe response to p2p_supplicant. */
1915 kalP2PIndicateRxMgmtFrame(prAdapter
->prGlueInfo
, prSwRfb
);
1922 } /* p2pFuncValidateRxMgmtFrame */
1926 BOOLEAN
p2pFuncIsAPMode(IN P_P2P_FSM_INFO_T prP2pFsmInfo
)
1929 if (prP2pFsmInfo
->fgIsWPSMode
== 1) {
1932 return prP2pFsmInfo
->fgIsApMode
;
1938 /* p2pFuncIsAPMode */
1943 p2pFuncParseBeaconContent(IN P_ADAPTER_T prAdapter
,
1944 IN P_BSS_INFO_T prP2pBssInfo
, IN PUINT_8 pucIEInfo
, IN UINT_32 u4IELen
)
1946 PUINT_8 pucIE
= (PUINT_8
) NULL
;
1947 UINT_16 u2Offset
= 0;
1948 P_P2P_SPECIFIC_BSS_INFO_T prP2pSpecificBssInfo
= (P_P2P_SPECIFIC_BSS_INFO_T
) NULL
;
1949 BOOL ucNewSecMode
= FALSE
;
1950 BOOL ucOldSecMode
= FALSE
;
1953 ASSERT_BREAK((prAdapter
!= NULL
) && (prP2pBssInfo
!= NULL
));
1959 prP2pSpecificBssInfo
= prAdapter
->rWifiVar
.prP2pSpecificBssInfo
;
1960 prP2pSpecificBssInfo
->u2AttributeLen
= 0;
1962 ASSERT_BREAK(pucIEInfo
!= NULL
);
1966 ucOldSecMode
= kalP2PGetCipher(prAdapter
->prGlueInfo
);
1968 IE_FOR_EACH(pucIE
, u4IELen
, u2Offset
) {
1969 switch (IE_ID(pucIE
)) {
1970 case ELEM_ID_SSID
: /* 0 *//* V *//* Done */
1972 /* DBGLOG(P2P, TRACE, ("SSID update\n")); */
1973 /* SSID is saved when start AP/GO */
1974 /* SSID IE set in beacon from supplicant will not
1975 always be the true since hidden SSID case */
1977 COPY_SSID(prP2pBssInfo->aucSSID,
1978 prP2pBssInfo->ucSSIDLen,
1979 SSID_IE(pucIE)->aucSSID,
1980 SSID_IE(pucIE)->ucLength);
1982 COPY_SSID(prP2pSpecificBssInfo->aucGroupSsid,
1983 prP2pSpecificBssInfo->u2GroupSsidLen,
1984 SSID_IE(pucIE)->aucSSID,
1985 SSID_IE(pucIE)->ucLength);
1989 case ELEM_ID_SUP_RATES
: /* 1 *//* V *//* Done */
1991 DBGLOG(P2P
, TRACE
, ("Support Rate IE\n"));
1992 kalMemCopy(prP2pBssInfo
->aucAllSupportedRates
,
1993 SUP_RATES_IE(pucIE
)->aucSupportedRates
,
1994 SUP_RATES_IE(pucIE
)->ucLength
);
1996 prP2pBssInfo
->ucAllSupportedRatesLen
=
1997 SUP_RATES_IE(pucIE
)->ucLength
;
1999 DBGLOG_MEM8(P2P
, TRACE
,
2000 SUP_RATES_IE(pucIE
)->aucSupportedRates
,
2001 SUP_RATES_IE(pucIE
)->ucLength
);
2004 case ELEM_ID_DS_PARAM_SET
: /* 3 *//* V *//* Done */
2006 P_P2P_CONNECTION_SETTINGS_T prP2pConnSettings
=
2007 prAdapter
->rWifiVar
.prP2PConnSettings
;
2009 DBGLOG(P2P
, TRACE
, ("DS PARAM IE\n"));
2011 ASSERT(prP2pConnSettings
->ucOperatingChnl
==
2012 DS_PARAM_IE(pucIE
)->ucCurrChnl
);
2014 if (prP2pConnSettings
->eBand
!= BAND_2G4
) {
2018 /* prP2pBssInfo->ucPrimaryChannel = DS_PARAM_IE(pucIE)->ucCurrChnl; */
2020 /* prP2pBssInfo->eBand = BAND_2G4; */
2023 case ELEM_ID_TIM
: /* 5 *//* V */
2024 DBGLOG(P2P
, TRACE
, ("TIM IE\n"));
2025 TIM_IE(pucIE
)->ucDTIMPeriod
= prP2pBssInfo
->ucDTIMPeriod
;
2027 case ELEM_ID_ERP_INFO
: /* 42 *//* V */
2030 /* This IE would dynamic change due to FW detection change is required. */
2032 ("ERP IE will be over write by driver\n"));
2034 (" ucERP: %x.\n", ERP_INFO_IE(pucIE
)->ucERP
));
2037 /* This IE would dynamic change due to FW detection change is required. */
2038 DBGLOG(P2P
, TRACE
, ("ERP IE.\n"));
2040 prP2pBssInfo
->ucPhyTypeSet
|= PHY_TYPE_SET_802_11GN
;
2042 ASSERT(prP2pBssInfo
->eBand
== BAND_2G4
);
2044 prP2pBssInfo
->fgObssErpProtectMode
=
2045 ((ERP_INFO_IE(pucIE
)->
2046 ucERP
& ERP_INFO_USE_PROTECTION
) ? TRUE
: FALSE
);
2048 prP2pBssInfo
->fgErpProtectMode
=
2049 ((ERP_INFO_IE(pucIE
)->
2050 ucERP
& (ERP_INFO_USE_PROTECTION
|
2051 ERP_INFO_NON_ERP_PRESENT
)) ? TRUE
: FALSE
);
2056 case ELEM_ID_HT_CAP
: /* 45 *//* V */
2060 ("HT CAP IE would be overwritten by driver\n"));
2063 ("HT Cap Info:%x, AMPDU Param:%x\n",
2064 HT_CAP_IE(pucIE
)->u2HtCapInfo
,
2065 HT_CAP_IE(pucIE
)->ucAmpduParam
));
2068 ("HT Extended Cap Info:%x, TX Beamforming Cap Info:%lx, Ant Selection Cap Info%x\n",
2069 HT_CAP_IE(pucIE
)->u2HtExtendedCap
,
2070 HT_CAP_IE(pucIE
)->u4TxBeamformingCap
,
2071 HT_CAP_IE(pucIE
)->ucAselCap
));
2073 prP2pBssInfo
->ucPhyTypeSet
|= PHY_TYPE_SET_802_11N
;
2076 if ((HT_CAP_IE(pucIE
)->u2HtCapInfo
&
2077 (HT_CAP_INFO_SUP_CHNL_WIDTH
| HT_CAP_INFO_SHORT_GI_40M
2078 | HT_CAP_INFO_DSSS_CCK_IN_40M
)) == 0) {
2079 prP2pBssInfo
->fgAssoc40mBwAllowed
= FALSE
;
2081 prP2pBssInfo
->fgAssoc40mBwAllowed
= TRUE
;
2084 if ((HT_CAP_IE(pucIE
)->u2HtCapInfo
&
2085 (HT_CAP_INFO_SHORT_GI_20M
| HT_CAP_INFO_SHORT_GI_40M
))
2087 prAdapter
->rWifiVar
.rConnSettings
.
2088 fgRxShortGIDisabled
= TRUE
;
2090 prAdapter
->rWifiVar
.rConnSettings
.
2091 fgRxShortGIDisabled
= FALSE
;
2096 ("AMPDU setting from supplicant:0x%x, & default value:0x%x\n",
2097 (UINT_8
) HT_CAP_IE(pucIE
)->ucAmpduParam
,
2098 (UINT_8
) AMPDU_PARAM_DEFAULT_VAL
));
2101 /* Can do nothing. the field is default value from other configuration. */
2102 /* HT_CAP_IE(pucIE)->rSupMcsSet; */
2104 /* u2HtExtendedCap */
2105 ASSERT(HT_CAP_IE(pucIE
)->u2HtExtendedCap
==
2106 (HT_EXT_CAP_DEFAULT_VAL
&
2108 HT_EXT_CAP_PCO_TRANS_TIME_NONE
)));
2110 /* u4TxBeamformingCap */
2111 ASSERT(HT_CAP_IE(pucIE
)->u4TxBeamformingCap
==
2112 TX_BEAMFORMING_CAP_DEFAULT_VAL
);
2115 ASSERT(HT_CAP_IE(pucIE
)->ucAselCap
== ASEL_CAP_DEFAULT_VAL
);
2119 case ELEM_ID_RSN
: /* 48 *//* V */
2123 DBGLOG(P2P
, TRACE
, ("RSN IE\n"));
2124 kalP2PSetCipher(prAdapter
->prGlueInfo
, IW_AUTH_CIPHER_CCMP
);
2125 ucNewSecMode
= TRUE
;
2127 if (rsnParseRsnIE(prAdapter
, RSN_IE(pucIE
), &rRsnIe
)) {
2129 &prAdapter
->rWifiVar
.
2130 arBssInfo
[NETWORK_TYPE_P2P_INDEX
];
2131 prP2pBssInfo
->u4RsnSelectedGroupCipher
=
2132 RSN_CIPHER_SUITE_CCMP
;
2133 prP2pBssInfo
->u4RsnSelectedPairwiseCipher
=
2134 RSN_CIPHER_SUITE_CCMP
;
2135 prP2pBssInfo
->u4RsnSelectedAKMSuite
=
2137 prP2pBssInfo
->u2RsnSelectedCapInfo
=
2142 case ELEM_ID_EXTENDED_SUP_RATES
: /* 50 *//* V */
2143 /* Be attention, ELEM_ID_SUP_RATES should be placed before ELEM_ID_EXTENDED_SUP_RATES. */
2144 DBGLOG(P2P
, TRACE
, ("Ex Support Rate IE\n"));
2147 aucAllSupportedRates
[prP2pBssInfo
->
2148 ucAllSupportedRatesLen
]),
2149 EXT_SUP_RATES_IE(pucIE
)->aucExtSupportedRates
,
2150 EXT_SUP_RATES_IE(pucIE
)->ucLength
);
2152 DBGLOG_MEM8(P2P
, TRACE
,
2153 EXT_SUP_RATES_IE(pucIE
)->aucExtSupportedRates
,
2154 EXT_SUP_RATES_IE(pucIE
)->ucLength
);
2156 prP2pBssInfo
->ucAllSupportedRatesLen
+=
2157 EXT_SUP_RATES_IE(pucIE
)->ucLength
;
2159 case ELEM_ID_HT_OP
: /* 61 */* * V */
// TODO
: */
2163 ("HT OP IE would be overwritten by driver\n"));
2166 (" Primary Channel: %x, Info1: %x, Info2: %x, Info3: %x\n",
2167 HT_OP_IE(pucIE
)->ucPrimaryChannel
,
2168 HT_OP_IE(pucIE
)->ucInfo1
, HT_OP_IE(pucIE
)->u2Info2
,
2169 HT_OP_IE(pucIE
)->u2Info3
));
2171 UINT_16 u2Info2
= 0;
2172 prP2pBssInfo
->ucPhyTypeSet
|= PHY_TYPE_SET_802_11N
;
2174 DBGLOG(P2P
, TRACE
, ("HT OP IE\n"));
2176 /* ucPrimaryChannel. */
2177 ASSERT(HT_OP_IE(pucIE
)->ucPrimaryChannel
==
2178 prP2pBssInfo
->ucPrimaryChannel
);
2181 prP2pBssInfo
->ucHtOpInfo1
= HT_OP_IE(pucIE
)->ucInfo1
;
2184 u2Info2
= HT_OP_IE(pucIE
)->u2Info2
;
2186 if (u2Info2
& HT_OP_INFO2_NON_GF_HT_STA_PRESENT
) {
2187 ASSERT(prP2pBssInfo
->eGfOperationMode
!=
2189 u2Info2
&= ~HT_OP_INFO2_NON_GF_HT_STA_PRESENT
;
2192 if (u2Info2
& HT_OP_INFO2_OBSS_NON_HT_STA_PRESENT
) {
2193 prP2pBssInfo
->eObssHtProtectMode
=
2194 HT_PROTECT_MODE_NON_MEMBER
;
2195 u2Info2
&= ~HT_OP_INFO2_OBSS_NON_HT_STA_PRESENT
;
2198 switch (u2Info2
& HT_OP_INFO2_HT_PROTECTION
) {
2199 case HT_PROTECT_MODE_NON_HT
:
2200 prP2pBssInfo
->eHtProtectMode
=
2201 HT_PROTECT_MODE_NON_HT
;
2203 case HT_PROTECT_MODE_NON_MEMBER
:
2204 prP2pBssInfo
->eHtProtectMode
= HT_PROTECT_MODE_NONE
;
2205 prP2pBssInfo
->eObssHtProtectMode
=
2206 HT_PROTECT_MODE_NON_MEMBER
;
2209 prP2pBssInfo
->eHtProtectMode
=
2210 HT_OP_IE(pucIE
)->u2Info2
;
2215 prP2pBssInfo
->u2HtOpInfo3
= HT_OP_IE(pucIE
)->u2Info3
;
2217 /* aucBasicMcsSet */
2218 DBGLOG_MEM8(P2P
, TRACE
, HT_OP_IE(pucIE
)->aucBasicMcsSet
,
2223 case ELEM_ID_OBSS_SCAN_PARAMS
: /* 74 *//* V */
2226 ("ELEM_ID_OBSS_SCAN_PARAMS IE would be replaced by driver\n"));
2229 case ELEM_ID_EXTENDED_CAP
: /* 127 *//* V */
2232 ("ELEM_ID_EXTENDED_CAP IE would be replaced by driver\n"));
2235 case ELEM_ID_VENDOR
: /* 221 *//* V */
2236 DBGLOG(P2P
, TRACE
, ("Vender Specific IE\n"));
2239 UINT_16 u2SubTypeVersion
;
2240 if (rsnParseCheckForWFAInfoElem
2241 (prAdapter
, pucIE
, &ucOuiType
, &u2SubTypeVersion
)) {
2242 if ((ucOuiType
== VENDOR_OUI_TYPE_WPA
)
2243 && (u2SubTypeVersion
== VERSION_WPA
)) {
2244 kalP2PSetCipher(prAdapter
->prGlueInfo
,
2245 IW_AUTH_CIPHER_TKIP
);
2246 ucNewSecMode
= TRUE
;
2247 kalMemCopy(prP2pSpecificBssInfo
->
2248 aucWpaIeBuffer
, pucIE
,
2250 prP2pSpecificBssInfo
->u2WpaIeLen
=
2252 } else if ((ucOuiType
== VENDOR_OUI_TYPE_WPS
)) {
2253 kalP2PUpdateWSC_IE(prAdapter
->prGlueInfo
, 0,
2254 pucIE
, IE_SIZE(pucIE
));
2258 if (p2pFuncParseCheckForP2PInfoElem
2259 (prAdapter
, pucIE
, &ucOuiType
)) {
2260 /* TODO Store the whole P2P IE & generate later. */
2261 /* Be aware that there may be one or more P2P IE. */
2262 if (ucOuiType
== VENDOR_OUI_TYPE_P2P
) {
2263 kalMemCopy(&prP2pSpecificBssInfo
->
2265 [prP2pSpecificBssInfo
->
2266 u2AttributeLen
], pucIE
,
2269 prP2pSpecificBssInfo
->u2AttributeLen
+=
2271 } else if (ucOuiType
== VENDOR_OUI_TYPE_WFD
) {
2273 kalMemCopy(&prP2pSpecificBssInfo
->
2275 [prP2pSpecificBssInfo
->
2276 u2AttributeLen
], pucIE
,
2279 prP2pSpecificBssInfo
->u2AttributeLen
+=
2284 kalMemCopy(&prP2pSpecificBssInfo
->
2285 aucAttributesCache
[prP2pSpecificBssInfo
->
2287 pucIE
, IE_SIZE(pucIE
));
2289 prP2pSpecificBssInfo
->u2AttributeLen
+=
2292 ("Driver unprocessed Vender Specific IE\n"));
2296 /* TODO: Store other Vender IE except for WMM Param. */
2300 DBGLOG(P2P
, TRACE
, ("Unprocessed element ID:%d\n", IE_ID(pucIE
)));
2305 if (!ucNewSecMode
&& ucOldSecMode
)
2306 kalP2PSetCipher(prAdapter
->prGlueInfo
, IW_AUTH_CIPHER_NONE
);
2311 } /* p2pFuncParseBeaconContent */
2317 p2pFuncKeepOnConnection(IN P_ADAPTER_T prAdapter
,
2318 IN P_P2P_CONNECTION_REQ_INFO_T prConnReqInfo
,
2319 IN P_P2P_CHNL_REQ_INFO_T prChnlReqInfo
,
2320 IN P_P2P_SCAN_REQ_INFO_T prScanReqInfo
)
2322 P_BSS_DESC_T prTargetBss
= (P_BSS_DESC_T
) NULL
;
2323 P_BSS_INFO_T prP2pBssInfo
= (P_BSS_INFO_T
) NULL
;
2326 ASSERT_BREAK((prAdapter
!= NULL
) &&
2327 (prConnReqInfo
!= NULL
) &&
2328 (prChnlReqInfo
!= NULL
) && (prScanReqInfo
!= NULL
));
2330 prP2pBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_P2P_INDEX
]);
2332 if (prP2pBssInfo
->eCurrentOPMode
!= OP_MODE_INFRASTRUCTURE
) {
2335 /* Update connection request information. */
2336 ASSERT(prConnReqInfo
->fgIsConnRequest
== TRUE
);
2338 /* Find BSS Descriptor first. */
2339 prTargetBss
= scanP2pSearchDesc(prAdapter
, prP2pBssInfo
, prConnReqInfo
);
2341 if (prTargetBss
== NULL
) {
2342 /* Update scan parameter... to scan target device. */
2343 prScanReqInfo
->ucNumChannelList
= 1;
2344 prScanReqInfo
->eScanType
= SCAN_TYPE_ACTIVE_SCAN
;
2345 prScanReqInfo
->eChannelSet
= SCAN_CHANNEL_FULL
;
2346 prScanReqInfo
->u4BufLength
= 0; /* Prevent other P2P ID in IE. */
2347 prScanReqInfo
->fgIsAbort
= TRUE
;
2349 prChnlReqInfo
->u8Cookie
= 0;
2350 prChnlReqInfo
->ucReqChnlNum
= prTargetBss
->ucChannelNum
;
2351 prChnlReqInfo
->eBand
= prTargetBss
->eBand
;
2352 prChnlReqInfo
->eChnlSco
= prTargetBss
->eSco
;
2353 prChnlReqInfo
->u4MaxInterval
= AIS_JOIN_CH_REQUEST_INTERVAL
;
2354 prChnlReqInfo
->eChannelReqType
= CHANNEL_REQ_TYPE_GC_JOIN_REQ
;
2360 } /* p2pFuncKeepOnConnection */
2362 /* Currently Only for ASSOC Response Frame. */
2363 VOID
p2pFuncStoreAssocRspIEBuffer(IN P_ADAPTER_T prAdapter
, IN P_SW_RFB_T prSwRfb
)
2365 P_P2P_FSM_INFO_T prP2pFsmInfo
= (P_P2P_FSM_INFO_T
) NULL
;
2366 P_P2P_JOIN_INFO_T prJoinInfo
= (P_P2P_JOIN_INFO_T
) NULL
;
2367 P_WLAN_ASSOC_RSP_FRAME_T prAssocRspFrame
= (P_WLAN_ASSOC_RSP_FRAME_T
) NULL
;
2371 ASSERT_BREAK((prAdapter
!= NULL
) && (prSwRfb
!= NULL
));
2373 prAssocRspFrame
= (P_WLAN_ASSOC_RSP_FRAME_T
) prSwRfb
->pvHeader
;
2375 if (prAssocRspFrame
->u2FrameCtrl
!= MAC_FRAME_ASSOC_RSP
) {
2379 i2IELen
= prSwRfb
->u2PacketLen
- (WLAN_MAC_HEADER_LEN
+
2380 CAP_INFO_FIELD_LEN
+
2381 STATUS_CODE_FIELD_LEN
+ AID_FIELD_LEN
);
2388 prP2pFsmInfo
= prAdapter
->rWifiVar
.prP2pFsmInfo
;
2389 prJoinInfo
= &(prP2pFsmInfo
->rJoinInfo
);
2390 prJoinInfo
->u4BufLength
= (UINT_32
) i2IELen
;
2392 kalMemCopy(prJoinInfo
->aucIEBuf
, prAssocRspFrame
->aucInfoElem
,
2393 prJoinInfo
->u4BufLength
);
2399 } /* p2pFuncStoreAssocRspIEBuffer */
2404 /*----------------------------------------------------------------------------*/
2406 * \brief This routine is called to set Packet Filter.
2408 * \param[in] prAdapter Pointer to the Adapter structure.
2409 * \param[in] pvSetBuffer Pointer to the buffer that holds the data to be set.
2410 * \param[in] u4SetBufferLen The length of the set buffer.
2411 * \param[out] pu4SetInfoLen If the call is successful, returns the number of
2412 * bytes read from the set buffer. If the call failed
2413 * due to invalid length of the set buffer, returns
2414 * the amount of storage needed.
2416 * \retval WLAN_STATUS_SUCCESS
2417 * \retval WLAN_STATUS_INVALID_LENGTH
2418 * \retval WLAN_STATUS_NOT_SUPPORTED
2419 * \retval WLAN_STATUS_ADAPTER_NOT_READY
2421 /*----------------------------------------------------------------------------*/
2423 p2pFuncMgmtFrameRegister(IN P_ADAPTER_T prAdapter
,
2424 IN UINT_16 u2FrameType
,
2425 IN BOOLEAN fgIsRegistered
, OUT PUINT_32 pu4P2pPacketFilter
)
2427 UINT_32 u4NewPacketFilter
= 0;
2429 DEBUGFUNC("p2pFuncMgmtFrameRegister");
2432 ASSERT_BREAK(prAdapter
!= NULL
);
2434 if (pu4P2pPacketFilter
) {
2435 u4NewPacketFilter
= *pu4P2pPacketFilter
;
2438 switch (u2FrameType
) {
2439 case MAC_FRAME_PROBE_REQ
:
2440 if (fgIsRegistered
) {
2441 u4NewPacketFilter
|= PARAM_PACKET_FILTER_PROBE_REQ
;
2442 DBGLOG(P2P
, TRACE
, ("Open packet filer probe request\n"));
2444 u4NewPacketFilter
&= ~PARAM_PACKET_FILTER_PROBE_REQ
;
2445 DBGLOG(P2P
, TRACE
, ("Close packet filer probe request\n"));
2448 case MAC_FRAME_ACTION
:
2449 if (fgIsRegistered
) {
2450 u4NewPacketFilter
|= PARAM_PACKET_FILTER_ACTION_FRAME
;
2451 DBGLOG(P2P
, TRACE
, ("Open packet filer action frame.\n"));
2453 u4NewPacketFilter
&= ~PARAM_PACKET_FILTER_ACTION_FRAME
;
2454 DBGLOG(P2P
, TRACE
, ("Close packet filer action frame.\n"));
2458 DBGLOG(P2P
, TRACE
, ("Ask frog to add code for mgmt:%x\n", u2FrameType
));
2462 if (pu4P2pPacketFilter
) {
2463 *pu4P2pPacketFilter
= u4NewPacketFilter
;
2465 /* u4NewPacketFilter |= prAdapter->u4OsPacketFilter; */
2467 prAdapter
->u4OsPacketFilter
&= ~PARAM_PACKET_FILTER_P2P_MASK
;
2468 prAdapter
->u4OsPacketFilter
|= u4NewPacketFilter
;
2470 DBGLOG(P2P
, TRACE
, ("P2P Set PACKET filter:0x%lx\n", prAdapter
->u4OsPacketFilter
));
2472 wlanSendSetQueryCmd(prAdapter
,
2473 CMD_ID_SET_RX_FILTER
,
2477 nicCmdEventSetCommon
,
2478 nicOidCmdTimeoutCommon
,
2480 (PUINT_8
) &prAdapter
->u4OsPacketFilter
,
2481 &u4NewPacketFilter
, sizeof(u4NewPacketFilter
)
2487 } /* p2pFuncMgmtFrameRegister */
2490 VOID
p2pFuncUpdateMgmtFrameRegister(IN P_ADAPTER_T prAdapter
, IN UINT_32 u4OsFilter
)
2495 prAdapter
->rWifiVar
.prP2pFsmInfo
->u4P2pPacketFilter
= u4OsFilter
;
2497 if ((prAdapter
->u4OsPacketFilter
& PARAM_PACKET_FILTER_P2P_MASK
) ^ u4OsFilter
) {
2499 prAdapter
->u4OsPacketFilter
&= ~PARAM_PACKET_FILTER_P2P_MASK
;
2501 prAdapter
->u4OsPacketFilter
|= (u4OsFilter
& PARAM_PACKET_FILTER_P2P_MASK
);
2503 wlanSendSetQueryCmd(prAdapter
,
2504 CMD_ID_SET_RX_FILTER
,
2508 nicCmdEventSetCommon
,
2509 nicOidCmdTimeoutCommon
,
2511 (PUINT_8
) &prAdapter
->u4OsPacketFilter
,
2512 &u4OsFilter
, sizeof(u4OsFilter
)
2515 ("P2P Set PACKET filter:0x%lx\n", prAdapter
->u4OsPacketFilter
));
2524 } /* p2pFuncUpdateMgmtFrameRegister */
2528 p2pFuncGetStationInfo(IN P_ADAPTER_T prAdapter
,
2529 IN PUINT_8 pucMacAddr
, OUT P_P2P_STATION_INFO_T prStaInfo
)
2533 ASSERT_BREAK((prAdapter
!= NULL
) && (pucMacAddr
!= NULL
) && (prStaInfo
!= NULL
));
2535 prStaInfo
->u4InactiveTime
= 0;
2536 prStaInfo
->u4RxBytes
= 0;
2537 prStaInfo
->u4TxBytes
= 0;
2538 prStaInfo
->u4RxPackets
= 0;
2539 prStaInfo
->u4TxPackets
= 0;
2545 } /* p2pFuncGetStationInfo */
2549 p2pFuncGetAttriList(IN P_ADAPTER_T prAdapter
,
2550 IN UINT_8 ucOuiType
,
2552 IN UINT_16 u2IELength
, OUT PPUINT_8 ppucAttriList
, OUT PUINT_16 pu2AttriListLen
)
2554 BOOLEAN fgIsAllocMem
= FALSE
;
2555 UINT_8 aucWfaOui
[] = VENDOR_OUI_WFA_SPECIFIC
;
2556 UINT_16 u2Offset
= 0;
2557 P_IE_P2P_T prIe
= (P_IE_P2P_T
) NULL
;
2558 PUINT_8 pucAttriListStart
= (PUINT_8
) NULL
;
2559 UINT_16 u2AttriListLen
= 0, u2BufferSize
= 0;
2560 BOOLEAN fgBackupAttributes
= FALSE
;
2563 ASSERT_BREAK((prAdapter
!= NULL
) &&
2565 (u2IELength
!= 0) &&
2566 (ppucAttriList
!= NULL
) && (pu2AttriListLen
!= NULL
));
2568 if (ppucAttriList
) {
2569 *ppucAttriList
= NULL
;
2571 if (pu2AttriListLen
) {
2572 *pu2AttriListLen
= 0;
2575 if (ucOuiType
== VENDOR_OUI_TYPE_WPS
) {
2576 aucWfaOui
[0] = 0x00;
2577 aucWfaOui
[1] = 0x50;
2578 aucWfaOui
[2] = 0xF2;
2579 } else if ((ucOuiType
!= VENDOR_OUI_TYPE_P2P
)
2581 && (ucOuiType
!= VENDOR_OUI_TYPE_WFD
)
2584 DBGLOG(P2P
, INFO
, ("Not supported OUI Type to parsing 0x%x\n", ucOuiType
));
2589 IE_FOR_EACH(pucIE
, u2IELength
, u2Offset
) {
2590 if (ELEM_ID_VENDOR
== IE_ID(pucIE
)) {
2591 prIe
= (P_IE_P2P_T
) pucIE
;
2593 if (prIe
->ucLength
<= P2P_OUI_TYPE_LEN
) {
2598 if ((prIe
->aucOui
[0] == aucWfaOui
[0]) &&
2599 (prIe
->aucOui
[1] == aucWfaOui
[1]) &&
2600 (prIe
->aucOui
[2] == aucWfaOui
[2]) &&
2601 (ucOuiType
== prIe
->ucOuiType
)) {
2603 if (!pucAttriListStart
) {
2604 pucAttriListStart
= &prIe
->aucP2PAttributes
[0];
2605 if (prIe
->ucLength
> P2P_OUI_TYPE_LEN
) {
2607 (UINT_16
) (prIe
->ucLength
-
2613 /* More than 2 attributes. */
2616 if (FALSE
== fgBackupAttributes
) {
2617 P_P2P_SPECIFIC_BSS_INFO_T
2618 prP2pSpecificBssInfo
=
2619 prAdapter
->rWifiVar
.
2620 prP2pSpecificBssInfo
;
2622 fgBackupAttributes
= TRUE
;
2623 if (ucOuiType
== VENDOR_OUI_TYPE_P2P
) {
2624 kalMemCopy(&prP2pSpecificBssInfo
->
2625 aucAttributesCache
[0],
2630 &prP2pSpecificBssInfo
->
2631 aucAttributesCache
[0];
2634 P2P_MAXIMUM_ATTRIBUTE_LEN
;
2635 } else if (ucOuiType
== VENDOR_OUI_TYPE_WPS
) {
2636 kalMemCopy(&prP2pSpecificBssInfo
->
2637 aucWscAttributesCache
[0],
2641 &prP2pSpecificBssInfo
->
2642 aucWscAttributesCache
[0];
2645 WPS_MAXIMUM_ATTRIBUTES_CACHE_SIZE
;
2648 else if (ucOuiType
== VENDOR_OUI_TYPE_WFD
) {
2649 PUINT_8 pucTmpBuf
= (PUINT_8
) NULL
;
2653 (WPS_MAXIMUM_ATTRIBUTES_CACHE_SIZE
,
2656 if (pucTmpBuf
!= NULL
) {
2657 fgIsAllocMem
= TRUE
;
2659 /* Can't alloca memory for WFD IE relocate. */
2664 kalMemCopy(pucTmpBuf
,
2668 pucAttriListStart
= pucTmpBuf
;
2671 WPS_MAXIMUM_ATTRIBUTES_CACHE_SIZE
;
2675 fgBackupAttributes
= FALSE
;
2680 (UINT_16
) (prIe
->ucLength
- P2P_OUI_TYPE_LEN
);
2682 if ((u2AttriListLen
+ u2CopyLen
) > u2BufferSize
) {
2684 u2CopyLen
= u2BufferSize
- u2AttriListLen
;
2687 ("Length of received P2P attributes > maximum cache size.\n"));
2692 kalMemCopy((PUINT_8
)
2693 ((UINT_32
) pucAttriListStart
+
2694 (UINT_32
) u2AttriListLen
),
2695 &prIe
->aucP2PAttributes
[0],
2698 u2AttriListLen
+= u2CopyLen
;
2703 } /* prIe->aucOui */
2704 } /* ELEM_ID_VENDOR */
2710 if (pucAttriListStart
) {
2711 PUINT_8 pucAttribute
= pucAttriListStart
;
2712 DBGLOG(P2P
, LOUD
, ("Checking Attribute Length.\n"));
2713 if (ucOuiType
== VENDOR_OUI_TYPE_P2P
) {
2714 P2P_ATTRI_FOR_EACH(pucAttribute
, u2AttriListLen
, u2Offset
);
2715 } else if (ucOuiType
== VENDOR_OUI_TYPE_WFD
) {
2716 } else if (ucOuiType
== VENDOR_OUI_TYPE_WPS
) {
2717 /* Big Endian: WSC, WFD. */
2718 WSC_ATTRI_FOR_EACH(pucAttribute
, u2AttriListLen
, u2Offset
) {
2719 DBGLOG(P2P
, LOUD
, ("Attribute ID:%d, Length:%d.\n",
2720 WSC_ATTRI_ID(pucAttribute
),
2721 WSC_ATTRI_LEN(pucAttribute
)));
2726 ASSERT(u2Offset
== u2AttriListLen
);
2728 *ppucAttriList
= pucAttriListStart
;
2729 *pu2AttriListLen
= u2AttriListLen
;
2732 *ppucAttriList
= (PUINT_8
) NULL
;
2733 *pu2AttriListLen
= 0;
2736 return fgIsAllocMem
;
2737 } /* p2pFuncGetAttriList */
2740 P_MSDU_INFO_T
p2pFuncProcessP2pProbeRsp(IN P_ADAPTER_T prAdapter
, IN P_MSDU_INFO_T prMgmtTxMsdu
)
2742 P_MSDU_INFO_T prRetMsduInfo
= prMgmtTxMsdu
;
2743 P_WLAN_PROBE_RSP_FRAME_T prProbeRspFrame
= (P_WLAN_PROBE_RSP_FRAME_T
) NULL
;
2744 PUINT_8 pucIEBuf
= (PUINT_8
) NULL
;
2745 UINT_16 u2Offset
= 0, u2IELength
= 0, u2ProbeRspHdrLen
= 0;
2746 BOOLEAN fgIsP2PIE
= FALSE
, fgIsWSCIE
= FALSE
;
2747 P_BSS_INFO_T prP2pBssInfo
= (P_BSS_INFO_T
) NULL
;
2748 UINT_16 u2EstimateSize
= 0, u2EstimatedExtraIELen
= 0;
2749 UINT_32 u4IeArraySize
= 0, u4Idx
= 0;
2753 ASSERT_BREAK((prAdapter
!= NULL
) && (prMgmtTxMsdu
!= NULL
));
2755 prP2pBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_P2P_INDEX
]);
2757 /* 3 Make sure this is probe response frame. */
2759 (P_WLAN_PROBE_RSP_FRAME_T
) ((UINT_32
) prMgmtTxMsdu
->prPacket
+
2760 MAC_TX_RESERVED_FIELD
);
2761 ASSERT_BREAK((prProbeRspFrame
->u2FrameCtrl
& MASK_FRAME_TYPE
) ==
2762 MAC_FRAME_PROBE_RSP
);
2764 /* 3 Get the importent P2P IE. */
2766 (WLAN_MAC_MGMT_HEADER_LEN
+ TIMESTAMP_FIELD_LEN
+ BEACON_INTERVAL_FIELD_LEN
+
2767 CAP_INFO_FIELD_LEN
);
2768 pucIEBuf
= prProbeRspFrame
->aucInfoElem
;
2769 u2IELength
= prMgmtTxMsdu
->u2FrameLength
- u2ProbeRspHdrLen
;
2772 prAdapter
->prGlueInfo
->prP2PInfo
->u2VenderIELen
= 0;
2775 IE_FOR_EACH(pucIEBuf
, u2IELength
, u2Offset
) {
2776 switch (IE_ID(pucIEBuf
)) {
2780 COPY_SSID(prP2pBssInfo
->aucSSID
,
2781 prP2pBssInfo
->ucSSIDLen
,
2782 SSID_IE(pucIEBuf
)->aucSSID
,
2783 SSID_IE(pucIEBuf
)->ucLength
);
2786 case ELEM_ID_VENDOR
:
2788 UINT_8 ucOuiType
= 0;
2789 UINT_16 u2SubTypeVersion
= 0;
2793 if (rsnParseCheckForWFAInfoElem
2794 (prAdapter
, pucIEBuf
, &ucOuiType
, &u2SubTypeVersion
)) {
2795 if (ucOuiType
== VENDOR_OUI_TYPE_WPS
) {
2796 kalP2PUpdateWSC_IE(prAdapter
->prGlueInfo
, 2,
2804 else if (p2pFuncParseCheckForP2PInfoElem
2805 (prAdapter
, pucIEBuf
, &ucOuiType
)) {
2806 if (ucOuiType
== VENDOR_OUI_TYPE_P2P
) {
2807 /* 2 Note(frog): I use WSC IE buffer for Probe Request to store the P2P IE for Probe Response. */
2808 kalP2PUpdateWSC_IE(prAdapter
->prGlueInfo
, 1,
2817 if ((prAdapter
->prGlueInfo
->prP2PInfo
->
2818 u2VenderIELen
+ IE_SIZE(pucIEBuf
)) < 512) {
2819 kalMemCopy(prAdapter
->prGlueInfo
->
2820 prP2PInfo
->aucVenderIE
, pucIEBuf
,
2822 prAdapter
->prGlueInfo
->prP2PInfo
->
2823 u2VenderIELen
+= IE_SIZE(pucIEBuf
);
2827 /* Eddie May be WFD */
2828 if (rsnParseCheckForWFAInfoElem
2829 (prAdapter
, pucIEBuf
, &ucOuiType
, &u2SubTypeVersion
)) {
2830 if (ucOuiType
== VENDOR_OUI_TYPE_WMM
) {
2835 if ((prAdapter
->prGlueInfo
->prP2PInfo
->u2VenderIELen
+
2836 IE_SIZE(pucIEBuf
)) < 1024) {
2837 kalMemCopy(prAdapter
->prGlueInfo
->prP2PInfo
->
2839 prAdapter
->prGlueInfo
->prP2PInfo
->
2840 u2VenderIELen
, pucIEBuf
,
2842 prAdapter
->prGlueInfo
->prP2PInfo
->u2VenderIELen
+=
2857 /* 3 Check the total size & current frame. */
2858 u2EstimateSize
= WLAN_MAC_MGMT_HEADER_LEN
+
2859 TIMESTAMP_FIELD_LEN
+
2860 BEACON_INTERVAL_FIELD_LEN
+
2861 CAP_INFO_FIELD_LEN
+
2862 (ELEM_HDR_LEN
+ ELEM_MAX_LEN_SSID
) +
2863 (ELEM_HDR_LEN
+ ELEM_MAX_LEN_SUP_RATES
) +
2864 (ELEM_HDR_LEN
+ ELEM_MAX_LEN_DS_PARAMETER_SET
);
2866 u2EstimatedExtraIELen
= 0;
2868 u4IeArraySize
= sizeof(txProbeRspIETable
) / sizeof(APPEND_VAR_IE_ENTRY_T
);
2869 for (u4Idx
= 0; u4Idx
< u4IeArraySize
; u4Idx
++) {
2870 if (txProbeRspIETable
[u4Idx
].u2EstimatedFixedIELen
) {
2871 u2EstimatedExtraIELen
+=
2872 txProbeRspIETable
[u4Idx
].u2EstimatedFixedIELen
;
2876 ASSERT(txProbeRspIETable
[u4Idx
].pfnCalculateVariableIELen
);
2878 u2EstimatedExtraIELen
+=
2879 (UINT_16
) (txProbeRspIETable
[u4Idx
].
2880 pfnCalculateVariableIELen(prAdapter
,
2881 NETWORK_TYPE_P2P_INDEX
,
2889 u2EstimatedExtraIELen
+= kalP2PCalWSC_IELen(prAdapter
->prGlueInfo
, 2);
2893 u2EstimatedExtraIELen
+= kalP2PCalWSC_IELen(prAdapter
->prGlueInfo
, 1);
2896 u2EstimatedExtraIELen
+= prAdapter
->prGlueInfo
->prP2PInfo
->u2VenderIELen
;
2901 if ((u2EstimateSize
+= u2EstimatedExtraIELen
) > (prRetMsduInfo
->u2FrameLength
)) {
2902 prRetMsduInfo
= cnmMgtPktAlloc(prAdapter
, u2EstimateSize
);
2904 if (prRetMsduInfo
== NULL
) {
2906 ("No packet for sending new probe response, use original one\n"));
2907 prRetMsduInfo
= prMgmtTxMsdu
;
2912 prRetMsduInfo
->ucNetworkType
= NETWORK_TYPE_P2P_INDEX
;
2915 /* 3 Compose / Re-compose probe response frame. */
2916 bssComposeBeaconProbeRespFrameHeaderAndFF((PUINT_8
)
2917 ((UINT_32
) (prRetMsduInfo
->prPacket
) +
2918 MAC_TX_RESERVED_FIELD
),
2919 prProbeRspFrame
->aucDestAddr
,
2920 prProbeRspFrame
->aucSrcAddr
,
2921 prProbeRspFrame
->aucBSSID
,
2922 prProbeRspFrame
->u2BeaconInterval
,
2923 prProbeRspFrame
->u2CapInfo
);
2925 prRetMsduInfo
->u2FrameLength
=
2926 (WLAN_MAC_MGMT_HEADER_LEN
+ TIMESTAMP_FIELD_LEN
+ BEACON_INTERVAL_FIELD_LEN
+
2927 CAP_INFO_FIELD_LEN
);
2929 bssBuildBeaconProbeRespFrameCommonIEs(prRetMsduInfo
,
2930 prP2pBssInfo
, prProbeRspFrame
->aucDestAddr
);
2933 for (u4Idx
= 0; u4Idx
< u4IeArraySize
; u4Idx
++) {
2934 if (txProbeRspIETable
[u4Idx
].pfnAppendIE
) {
2935 txProbeRspIETable
[u4Idx
].pfnAppendIE(prAdapter
, prRetMsduInfo
);
2942 kalP2PGenWSC_IE(prAdapter
->prGlueInfo
,
2944 (PUINT_8
) ((UINT_32
) prRetMsduInfo
->prPacket
+
2945 (UINT_32
) prRetMsduInfo
->u2FrameLength
));
2947 prRetMsduInfo
->u2FrameLength
+=
2948 (UINT_16
) kalP2PCalWSC_IELen(prAdapter
->prGlueInfo
, 2);
2952 kalP2PGenWSC_IE(prAdapter
->prGlueInfo
,
2954 (PUINT_8
) ((UINT_32
) prRetMsduInfo
->prPacket
+
2955 (UINT_32
) prRetMsduInfo
->u2FrameLength
));
2957 prRetMsduInfo
->u2FrameLength
+=
2958 (UINT_16
) kalP2PCalWSC_IELen(prAdapter
->prGlueInfo
, 1);
2961 if (prAdapter
->prGlueInfo
->prP2PInfo
->u2VenderIELen
> 0) {
2962 kalMemCopy((PUINT_8
)
2963 ((UINT_32
) prRetMsduInfo
->prPacket
+
2964 (UINT_32
) prRetMsduInfo
->u2FrameLength
),
2965 prAdapter
->prGlueInfo
->prP2PInfo
->aucVenderIE
,
2966 prAdapter
->prGlueInfo
->prP2PInfo
->u2VenderIELen
);
2967 prRetMsduInfo
->u2FrameLength
+=
2968 (UINT_16
) prAdapter
->prGlueInfo
->prP2PInfo
->u2VenderIELen
;
2975 if (prRetMsduInfo
!= prMgmtTxMsdu
) {
2976 cnmMgtPktFree(prAdapter
, prMgmtTxMsdu
);
2980 return prRetMsduInfo
;
2981 } /* p2pFuncProcessP2pProbeRsp */
2984 #if 0 /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) */
2986 p2pFuncCalculateExtra_IELenForBeacon(IN P_ADAPTER_T prAdapter
,
2987 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex
,
2988 IN P_STA_RECORD_T prStaRec
)
2991 P_P2P_SPECIFIC_BSS_INFO_T prP2pSpeBssInfo
= (P_P2P_SPECIFIC_BSS_INFO_T
) NULL
;
2992 UINT_32 u4IELen
= 0;
2995 ASSERT_BREAK((prAdapter
!= NULL
) && (eNetTypeIndex
== NETWORK_TYPE_P2P_INDEX
));
2997 if (p2pFuncIsAPMode(prAdapter
->rWifiVar
.prP2pFsmInfo
)) {
3001 prP2pSpeBssInfo
= prAdapter
->rWifiVar
.prP2pSpecificBssInfo
;
3003 u4IELen
= prP2pSpeBssInfo
->u2IELenForBCN
;
3008 } /* p2pFuncCalculateP2p_IELenForBeacon */
3010 VOID
p2pFuncGenerateExtra_IEForBeacon(IN P_ADAPTER_T prAdapter
, IN P_MSDU_INFO_T prMsduInfo
)
3012 P_P2P_SPECIFIC_BSS_INFO_T prP2pSpeBssInfo
= (P_P2P_SPECIFIC_BSS_INFO_T
) NULL
;
3013 PUINT_8 pucIEBuf
= (PUINT_8
) NULL
;
3016 ASSERT_BREAK((prAdapter
!= NULL
) && (prMsduInfo
!= NULL
));
3018 prP2pSpeBssInfo
= prAdapter
->rWifiVar
.prP2pSpecificBssInfo
;
3020 if (p2pFuncIsAPMode(prAdapter
->rWifiVar
.prP2pFsmInfo
)) {
3026 (PUINT_8
) ((UINT_32
) prMsduInfo
->prPacket
+
3027 (UINT_32
) prMsduInfo
->u2FrameLength
);
3029 kalMemCopy(pucIEBuf
, prP2pSpeBssInfo
->aucBeaconIECache
,
3030 prP2pSpeBssInfo
->u2IELenForBCN
);
3032 prMsduInfo
->u2FrameLength
+= prP2pSpeBssInfo
->u2IELenForBCN
;
3037 } /* p2pFuncGenerateExtra_IEForBeacon */
3042 p2pFuncCalculateP2p_IELenForBeacon(IN P_ADAPTER_T prAdapter
,
3043 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex
,
3044 IN P_STA_RECORD_T prStaRec
)
3046 P_P2P_SPECIFIC_BSS_INFO_T prP2pSpeBssInfo
= (P_P2P_SPECIFIC_BSS_INFO_T
) NULL
;
3047 UINT_32 u4IELen
= 0;
3050 ASSERT_BREAK((prAdapter
!= NULL
) && (eNetTypeIndex
== NETWORK_TYPE_P2P_INDEX
));
3052 if (!prAdapter
->fgIsP2PRegistered
) {
3057 if (p2pFuncIsAPMode(prAdapter
->rWifiVar
.prP2pFsmInfo
)) {
3061 prP2pSpeBssInfo
= prAdapter
->rWifiVar
.prP2pSpecificBssInfo
;
3063 u4IELen
= prP2pSpeBssInfo
->u2AttributeLen
;
3068 } /* p2pFuncCalculateP2p_IELenForBeacon */
3071 VOID
p2pFuncGenerateP2p_IEForBeacon(IN P_ADAPTER_T prAdapter
, IN P_MSDU_INFO_T prMsduInfo
)
3073 P_P2P_SPECIFIC_BSS_INFO_T prP2pSpeBssInfo
= (P_P2P_SPECIFIC_BSS_INFO_T
) NULL
;
3074 PUINT_8 pucIEBuf
= (PUINT_8
) NULL
;
3077 ASSERT_BREAK((prAdapter
!= NULL
) && (prMsduInfo
!= NULL
));
3079 if (!prAdapter
->fgIsP2PRegistered
) {
3083 prP2pSpeBssInfo
= prAdapter
->rWifiVar
.prP2pSpecificBssInfo
;
3085 if (p2pFuncIsAPMode(prAdapter
->rWifiVar
.prP2pFsmInfo
)) {
3091 (PUINT_8
) ((UINT_32
) prMsduInfo
->prPacket
+
3092 (UINT_32
) prMsduInfo
->u2FrameLength
);
3094 kalMemCopy(pucIEBuf
, prP2pSpeBssInfo
->aucAttributesCache
,
3095 prP2pSpeBssInfo
->u2AttributeLen
);
3097 prMsduInfo
->u2FrameLength
+= prP2pSpeBssInfo
->u2AttributeLen
;
3102 } /* p2pFuncGenerateP2p_IEForBeacon */
3109 p2pFuncCalculateWSC_IELenForBeacon(IN P_ADAPTER_T prAdapter
,
3110 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex
,
3111 IN P_STA_RECORD_T prStaRec
)
3113 if (eNetTypeIndex
!= NETWORK_TYPE_P2P_INDEX
) {
3117 return kalP2PCalWSC_IELen(prAdapter
->prGlueInfo
, 0);
3118 } /* p2pFuncCalculateP2p_IELenForBeacon */
3121 VOID
p2pFuncGenerateWSC_IEForBeacon(IN P_ADAPTER_T prAdapter
, IN P_MSDU_INFO_T prMsduInfo
)
3124 UINT_16 u2IELen
= 0;
3128 if (prMsduInfo
->ucNetworkType
!= NETWORK_TYPE_P2P_INDEX
) {
3132 u2IELen
= (UINT_16
) kalP2PCalWSC_IELen(prAdapter
->prGlueInfo
, 0);
3134 pucBuffer
= (PUINT_8
) ((UINT_32
) prMsduInfo
->prPacket
+
3135 (UINT_32
) prMsduInfo
->u2FrameLength
);
3139 /* TODO: Check P2P FSM State. */
3140 kalP2PGenWSC_IE(prAdapter
->prGlueInfo
, 0, pucBuffer
);
3142 prMsduInfo
->u2FrameLength
+= u2IELen
;
3145 } /* p2pFuncGenerateP2p_IEForBeacon */
3148 /*----------------------------------------------------------------------------*/
3150 * @brief This function is used to calculate P2P IE length for Beacon frame.
3152 * @param[in] eNetTypeIndex Specify which network
3153 * @param[in] prStaRec Pointer to the STA_RECORD_T
3155 * @return The length of P2P IE added
3157 /*----------------------------------------------------------------------------*/
3159 p2pFuncCalculateP2p_IELenForAssocRsp(IN P_ADAPTER_T prAdapter
,
3160 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex
,
3161 IN P_STA_RECORD_T prStaRec
)
3164 if (eNetTypeIndex
!= NETWORK_TYPE_P2P_INDEX
) {
3168 return p2pFuncCalculateP2P_IELen(prAdapter
,
3171 txAssocRspAttributesTable
,
3172 sizeof(txAssocRspAttributesTable
) /
3173 sizeof(APPEND_VAR_ATTRI_ENTRY_T
));
3175 } /* p2pFuncCalculateP2p_IELenForAssocRsp */
3182 /*----------------------------------------------------------------------------*/
3184 * @brief This function is used to generate P2P IE for Beacon frame.
3186 * @param[in] prMsduInfo Pointer to the composed MSDU_INFO_T.
3190 /*----------------------------------------------------------------------------*/
3191 VOID
p2pFuncGenerateP2p_IEForAssocRsp(IN P_ADAPTER_T prAdapter
, IN P_MSDU_INFO_T prMsduInfo
)
3193 P_P2P_FSM_INFO_T prP2pFsmInfo
= (P_P2P_FSM_INFO_T
) NULL
;
3194 P_STA_RECORD_T prStaRec
= (P_STA_RECORD_T
) NULL
;
3197 ASSERT_BREAK((prAdapter
!= NULL
) && (prMsduInfo
!= NULL
));
3199 prP2pFsmInfo
= prAdapter
->rWifiVar
.prP2pFsmInfo
;
3201 prStaRec
= cnmGetStaRecByIndex(prAdapter
, prMsduInfo
->ucStaRecIndex
);
3203 if (IS_STA_P2P_TYPE(prStaRec
)) {
3204 DBGLOG(P2P
, TRACE
, ("Generate NULL P2P IE for Assoc Rsp.\n"));
3206 p2pFuncGenerateP2P_IE(prAdapter
,
3208 &prMsduInfo
->u2FrameLength
,
3209 prMsduInfo
->prPacket
,
3211 txAssocRspAttributesTable
,
3212 sizeof(txAssocRspAttributesTable
) /
3213 sizeof(APPEND_VAR_ATTRI_ENTRY_T
));
3216 DBGLOG(P2P
, TRACE
, ("Legacy device, no P2P IE.\n"));
3223 } /* p2pFuncGenerateP2p_IEForAssocRsp */
3227 p2pFuncCalculateWSC_IELenForAssocRsp(IN P_ADAPTER_T prAdapter
,
3228 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex
,
3229 IN P_STA_RECORD_T prStaRec
)
3231 DBGLOG(P2P
, TRACE
, ("p2pFuncCalculateWSC_IELenForAssocRsp\n"));
3232 if (eNetTypeIndex
!= NETWORK_TYPE_P2P_INDEX
) {
3236 return kalP2PCalWSC_IELen(prAdapter
->prGlueInfo
, 0);
3237 } /* p2pFuncCalculateP2p_IELenForAssocRsp */
3240 VOID
p2pFuncGenerateWSC_IEForAssocRsp(IN P_ADAPTER_T prAdapter
, IN P_MSDU_INFO_T prMsduInfo
)
3243 UINT_16 u2IELen
= 0;
3247 if (prMsduInfo
->ucNetworkType
!= NETWORK_TYPE_P2P_INDEX
) {
3250 DBGLOG(P2P
, TRACE
, ("p2pFuncGenerateWSC_IEForAssocRsp\n"));
3252 u2IELen
= (UINT_16
) kalP2PCalWSC_IELen(prAdapter
->prGlueInfo
, 0);
3254 pucBuffer
= (PUINT_8
) ((UINT_32
) prMsduInfo
->prPacket
+
3255 (UINT_32
) prMsduInfo
->u2FrameLength
);
3259 /* TODO: Check P2P FSM State. */
3260 kalP2PGenWSC_IE(prAdapter
->prGlueInfo
, 0, pucBuffer
);
3262 prMsduInfo
->u2FrameLength
+= u2IELen
;
3267 /* p2pFuncGenerateP2p_IEForAssocRsp */
3273 p2pFuncCalculateP2P_IELen(IN P_ADAPTER_T prAdapter
,
3274 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex
,
3275 IN P_STA_RECORD_T prStaRec
,
3276 IN APPEND_VAR_ATTRI_ENTRY_T arAppendAttriTable
[],
3277 IN UINT_32 u4AttriTableSize
)
3280 UINT_32 u4OverallAttriLen
, u4Dummy
;
3281 UINT_16 u2EstimatedFixedAttriLen
;
3285 /* Overall length of all Attributes */
3286 u4OverallAttriLen
= 0;
3288 for (i
= 0; i
< u4AttriTableSize
; i
++) {
3289 u2EstimatedFixedAttriLen
= arAppendAttriTable
[i
].u2EstimatedFixedAttriLen
;
3291 if (u2EstimatedFixedAttriLen
) {
3292 u4OverallAttriLen
+= u2EstimatedFixedAttriLen
;
3294 ASSERT(arAppendAttriTable
[i
].pfnCalculateVariableAttriLen
);
3296 u4OverallAttriLen
+=
3297 arAppendAttriTable
[i
].pfnCalculateVariableAttriLen(prAdapter
, prStaRec
);
3301 u4Dummy
= u4OverallAttriLen
;
3302 u4OverallAttriLen
+= P2P_IE_OUI_HDR
;
3304 for (; (u4Dummy
> P2P_MAXIMUM_ATTRIBUTE_LEN
);) {
3305 u4OverallAttriLen
+= P2P_IE_OUI_HDR
;
3306 u4Dummy
-= P2P_MAXIMUM_ATTRIBUTE_LEN
;
3309 return u4OverallAttriLen
;
3310 } /* p2pFuncCalculateP2P_IELen */
3314 p2pFuncGenerateP2P_IE(IN P_ADAPTER_T prAdapter
,
3315 IN BOOLEAN fgIsAssocFrame
,
3316 IN PUINT_16 pu2Offset
,
3318 IN UINT_16 u2BufSize
,
3319 IN APPEND_VAR_ATTRI_ENTRY_T arAppendAttriTable
[], IN UINT_32 u4AttriTableSize
)
3321 PUINT_8 pucBuffer
= (PUINT_8
) NULL
;
3322 P_IE_P2P_T prIeP2P
= (P_IE_P2P_T
) NULL
;
3323 UINT_32 u4OverallAttriLen
;
3325 UINT_8 aucWfaOui
[] = VENDOR_OUI_WFA_SPECIFIC
;
3326 UINT_8 aucTempBuffer
[P2P_MAXIMUM_ATTRIBUTE_LEN
];
3331 ASSERT_BREAK((prAdapter
!= NULL
) && (pucBuf
!= NULL
));
3333 pucBuffer
= (PUINT_8
) ((UINT_32
) pucBuf
+ (*pu2Offset
));
3335 ASSERT_BREAK(pucBuffer
!= NULL
);
3337 /* Check buffer length is still enough. */
3338 ASSERT_BREAK((u2BufSize
- (*pu2Offset
)) >= P2P_IE_OUI_HDR
);
3340 prIeP2P
= (P_IE_P2P_T
) pucBuffer
;
3342 prIeP2P
->ucId
= ELEM_ID_P2P
;
3344 prIeP2P
->aucOui
[0] = aucWfaOui
[0];
3345 prIeP2P
->aucOui
[1] = aucWfaOui
[1];
3346 prIeP2P
->aucOui
[2] = aucWfaOui
[2];
3347 prIeP2P
->ucOuiType
= VENDOR_OUI_TYPE_P2P
;
3349 (*pu2Offset
) += P2P_IE_OUI_HDR
;
3351 /* Overall length of all Attributes */
3352 u4OverallAttriLen
= 0;
3355 for (i
= 0; i
< u4AttriTableSize
; i
++) {
3357 if (arAppendAttriTable
[i
].pfnAppendAttri
) {
3359 arAppendAttriTable
[i
].pfnAppendAttri(prAdapter
, fgIsAssocFrame
,
3363 u4OverallAttriLen
+= u4AttriLen
;
3365 if (u4OverallAttriLen
> P2P_MAXIMUM_ATTRIBUTE_LEN
) {
3366 u4OverallAttriLen
-= P2P_MAXIMUM_ATTRIBUTE_LEN
;
3369 (VENDOR_OUI_TYPE_LEN
+ P2P_MAXIMUM_ATTRIBUTE_LEN
);
3372 (PUINT_8
) ((UINT_32
) prIeP2P
+
3373 (VENDOR_OUI_TYPE_LEN
+
3374 P2P_MAXIMUM_ATTRIBUTE_LEN
));
3376 prIeP2P
= (P_IE_P2P_T
) ((UINT_32
) prIeP2P
+
3378 (VENDOR_OUI_TYPE_LEN
+
3379 P2P_MAXIMUM_ATTRIBUTE_LEN
)));
3381 kalMemCopy(aucTempBuffer
, pucBuffer
, u4OverallAttriLen
);
3383 prIeP2P
->ucId
= ELEM_ID_P2P
;
3385 prIeP2P
->aucOui
[0] = aucWfaOui
[0];
3386 prIeP2P
->aucOui
[1] = aucWfaOui
[1];
3387 prIeP2P
->aucOui
[2] = aucWfaOui
[2];
3388 prIeP2P
->ucOuiType
= VENDOR_OUI_TYPE_P2P
;
3390 kalMemCopy(prIeP2P
->aucP2PAttributes
, aucTempBuffer
,
3392 (*pu2Offset
) += P2P_IE_OUI_HDR
;
3399 prIeP2P
->ucLength
= (UINT_8
) (VENDOR_OUI_TYPE_LEN
+ u4OverallAttriLen
);
3405 } /* p2pFuncGenerateP2P_IE */
3408 p2pFuncAppendAttriStatusForAssocRsp(IN P_ADAPTER_T prAdapter
,
3409 IN BOOLEAN fgIsAssocFrame
,
3410 IN PUINT_16 pu2Offset
, IN PUINT_8 pucBuf
, IN UINT_16 u2BufSize
)
3413 P_P2P_ATTRI_STATUS_T prAttriStatus
;
3414 P_P2P_CONNECTION_SETTINGS_T prP2pConnSettings
= (P_P2P_CONNECTION_SETTINGS_T
) NULL
;
3415 UINT_32 u4AttriLen
= 0;
3420 prP2pConnSettings
= prAdapter
->rWifiVar
.prP2PConnSettings
;
3422 if (fgIsAssocFrame
) {
3425 /* TODO: For assoc request P2P IE check in driver & return status in P2P IE. */
3427 pucBuffer
= (PUINT_8
) ((UINT_32
) pucBuf
+ (UINT_32
) (*pu2Offset
));
3430 prAttriStatus
= (P_P2P_ATTRI_STATUS_T
) pucBuffer
;
3432 ASSERT(u2BufSize
>= ((*pu2Offset
) + (UINT_16
) u4AttriLen
));
3437 prAttriStatus
->ucId
= P2P_ATTRI_ID_STATUS
;
3438 WLAN_SET_FIELD_16(&prAttriStatus
->u2Length
, P2P_ATTRI_MAX_LEN_STATUS
);
3440 prAttriStatus
->ucStatusCode
= P2P_STATUS_FAIL_PREVIOUS_PROTOCOL_ERR
;
3442 u4AttriLen
= (P2P_ATTRI_HDR_LEN
+ P2P_ATTRI_MAX_LEN_STATUS
);
3444 (*pu2Offset
) += (UINT_16
) u4AttriLen
;
3447 } /* p2pFuncAppendAttriStatusForAssocRsp */
3450 p2pFuncAppendAttriExtListenTiming(IN P_ADAPTER_T prAdapter
,
3451 IN BOOLEAN fgIsAssocFrame
,
3452 IN PUINT_16 pu2Offset
, IN PUINT_8 pucBuf
, IN UINT_16 u2BufSize
)
3454 UINT_32 u4AttriLen
= 0;
3455 P_P2P_ATTRI_EXT_LISTEN_TIMING_T prP2pExtListenTiming
=
3456 (P_P2P_ATTRI_EXT_LISTEN_TIMING_T
) NULL
;
3457 P_P2P_SPECIFIC_BSS_INFO_T prP2pSpecificBssInfo
= (P_P2P_SPECIFIC_BSS_INFO_T
) NULL
;
3458 PUINT_8 pucBuffer
= NULL
;
3463 if (fgIsAssocFrame
) {
3466 /* TODO: For extend listen timing. */
3468 prP2pSpecificBssInfo
= prAdapter
->rWifiVar
.prP2pSpecificBssInfo
;
3470 u4AttriLen
= (P2P_ATTRI_HDR_LEN
+ P2P_ATTRI_MAX_LEN_EXT_LISTEN_TIMING
);
3472 ASSERT(u2BufSize
>= ((*pu2Offset
) + (UINT_16
) u4AttriLen
));
3474 pucBuffer
= (PUINT_8
) ((UINT_32
) pucBuf
+ (UINT_32
) (*pu2Offset
));
3478 prP2pExtListenTiming
= (P_P2P_ATTRI_EXT_LISTEN_TIMING_T
) pucBuffer
;
3480 prP2pExtListenTiming
->ucId
= P2P_ATTRI_ID_EXT_LISTEN_TIMING
;
3481 WLAN_SET_FIELD_16(&prP2pExtListenTiming
->u2Length
, P2P_ATTRI_MAX_LEN_EXT_LISTEN_TIMING
);
3482 WLAN_SET_FIELD_16(&prP2pExtListenTiming
->u2AvailInterval
,
3483 prP2pSpecificBssInfo
->u2AvailabilityInterval
);
3484 WLAN_SET_FIELD_16(&prP2pExtListenTiming
->u2AvailPeriod
,
3485 prP2pSpecificBssInfo
->u2AvailabilityPeriod
);
3487 (*pu2Offset
) += (UINT_16
) u4AttriLen
;
3490 } /* p2pFuncAppendAttriExtListenTiming */
3494 p2pFuncGetSpecIE(IN P_ADAPTER_T prAdapter
,
3495 IN PUINT_8 pucIEBuf
,
3496 IN UINT_16 u2BufferLen
, IN UINT_8 ucElemID
, IN PBOOLEAN pfgIsMore
)
3498 P_IE_HDR_T prTargetIE
= (P_IE_HDR_T
) NULL
;
3499 PUINT_8 pucIE
= (PUINT_8
) NULL
;
3500 UINT_16 u2Offset
= 0;
3507 ASSERT_BREAK((prAdapter
!= NULL
)
3508 && (pucIEBuf
!= NULL
));
3512 IE_FOR_EACH(pucIE
, u2BufferLen
, u2Offset
) {
3513 if (IE_ID(pucIE
) == ucElemID
) {
3514 if ((prTargetIE
) && (pfgIsMore
)) {
3519 prTargetIE
= (P_IE_HDR_T
) pucIE
;
3521 if (pfgIsMore
== NULL
) {
3533 } /* p2pFuncGetSpecIE */
3538 p2pFuncGetSpecAttri(IN P_ADAPTER_T prAdapter
,
3539 IN UINT_8 ucOuiType
,
3540 IN PUINT_8 pucIEBuf
, IN UINT_16 u2BufferLen
, IN UINT_16 u2AttriID
)
3542 P_IE_P2P_T prP2pIE
= (P_IE_P2P_T
) NULL
;
3543 P_ATTRIBUTE_HDR_T prTargetAttri
= (P_ATTRIBUTE_HDR_T
) NULL
;
3544 BOOLEAN fgIsMore
= FALSE
;
3545 PUINT_8 pucIE
= (PUINT_8
) NULL
, pucAttri
= (PUINT_8
) NULL
;
3546 UINT_16 u2OffsetAttri
= 0;
3547 UINT_16 u2BufferLenLeft
= 0;
3548 UINT_8 aucWfaOui
[] = VENDOR_OUI_WFA_SPECIFIC
;
3552 ("Check AssocReq Oui type %u attri %u for len %u\n", ucOuiType
, u2AttriID
,
3556 ASSERT_BREAK((prAdapter
!= NULL
)
3557 && (pucIEBuf
!= NULL
));
3559 u2BufferLenLeft
= u2BufferLen
;
3563 prP2pIE
= (P_IE_P2P_T
) p2pFuncGetSpecIE(prAdapter
,
3566 ELEM_ID_VENDOR
, &fgIsMore
);
3570 ASSERT(prP2pIE
> pucIE
);
3573 u2BufferLen
- (UINT_16
) (((UINT_32
) prP2pIE
) -
3574 ((UINT_32
) pucIEBuf
));
3577 ("Find vendor id %u len %u oui %u more %u LeftLen %u\n",
3578 IE_ID(prP2pIE
), IE_LEN(prP2pIE
), prP2pIE
->ucOuiType
,
3579 fgIsMore
, u2BufferLenLeft
));
3581 if (IE_LEN(prP2pIE
) > P2P_OUI_TYPE_LEN
) {
3583 if (prP2pIE
->ucOuiType
== ucOuiType
) {
3584 switch (ucOuiType
) {
3585 case VENDOR_OUI_TYPE_WPS
:
3586 aucWfaOui
[0] = 0x00;
3587 aucWfaOui
[1] = 0x50;
3588 aucWfaOui
[2] = 0xF2;
3590 case VENDOR_OUI_TYPE_P2P
:
3592 case VENDOR_OUI_TYPE_WPA
:
3593 case VENDOR_OUI_TYPE_WMM
:
3594 case VENDOR_OUI_TYPE_WFD
:
3600 if ((prP2pIE
->aucOui
[0] == aucWfaOui
[0])
3601 && (prP2pIE
->aucOui
[1] == aucWfaOui
[1])
3602 && (prP2pIE
->aucOui
[2] == aucWfaOui
[2])
3606 pucAttri
= prP2pIE
->aucP2PAttributes
;
3608 if (ucOuiType
== VENDOR_OUI_TYPE_WPS
) {
3609 WSC_ATTRI_FOR_EACH(pucAttri
,
3614 /* LOG_FUNC("WSC: attri id=%u len=%u\n",WSC_ATTRI_ID(pucAttri), WSC_ATTRI_LEN(pucAttri)); */
3615 if (WSC_ATTRI_ID(pucAttri
)
3627 else if (ucOuiType
== VENDOR_OUI_TYPE_P2P
) {
3628 P2P_ATTRI_FOR_EACH(pucAttri
,
3633 /* LOG_FUNC("P2P: attri id=%u len=%u\n",ATTRI_ID(pucAttri), ATTRI_LEN(pucAttri)); */
3634 if (ATTRI_ID(pucAttri
) ==
3635 (UINT_8
) u2AttriID
) {
3644 } else if (ucOuiType
== VENDOR_OUI_TYPE_WFD
) {
3645 WFD_ATTRI_FOR_EACH(pucAttri
,
3650 /* DBGLOG(P2P, INFO, ("WFD: attri id=%u len=%u\n",WFD_ATTRI_ID(pucAttri), WFD_ATTRI_LEN(pucAttri))); */
3651 if (ATTRI_ID(pucAttri
) ==
3652 (UINT_8
) u2AttriID
) {
3661 /* Possible or else. */
3667 /* P2P_OUI_TYPE_LEN */
3668 pucIE
= (PUINT_8
) (((UINT_32
) prP2pIE
) + IE_SIZE(prP2pIE
));
3672 } while (prP2pIE
&& fgIsMore
&& u2BufferLenLeft
);
3676 return prTargetAttri
;
3679 /* p2pFuncGetSpecAttri */
3683 p2pFuncGenerateBeaconProbeRsp(IN P_ADAPTER_T prAdapter
,
3684 IN P_BSS_INFO_T prBssInfo
,
3685 IN P_MSDU_INFO_T prMsduInfo
, IN BOOLEAN fgIsProbeRsp
)
3687 WLAN_STATUS rWlanStatus
= WLAN_STATUS_SUCCESS
;
3688 P_WLAN_BEACON_FRAME_T prBcnFrame
= (P_WLAN_BEACON_FRAME_T
) NULL
;
3689 /* P_APPEND_VAR_IE_ENTRY_T prAppendIeTable = (P_APPEND_VAR_IE_ENTRY_T)NULL; */
3694 ASSERT_BREAK((prAdapter
!= NULL
) && (prBssInfo
!= NULL
) && (prMsduInfo
!= NULL
));
3699 /* txProbeRspIETable */
3703 prBcnFrame
= (P_WLAN_BEACON_FRAME_T
) prMsduInfo
->prPacket
;
3705 return nicUpdateBeaconIETemplate(prAdapter
,
3706 IE_UPD_METHOD_UPDATE_ALL
,
3707 NETWORK_TYPE_P2P_INDEX
,
3708 prBssInfo
->u2CapInfo
,
3709 (PUINT_8
) prBcnFrame
->aucInfoElem
,
3710 prMsduInfo
->u2FrameLength
-
3711 OFFSET_OF(WLAN_BEACON_FRAME_T
, aucInfoElem
));
3716 } /* p2pFuncGenerateBeaconProbeRsp */
3720 p2pFuncComposeBeaconProbeRspTemplate(IN P_ADAPTER_T prAdapter
,
3721 IN PUINT_8 pucBcnBuffer
,
3722 IN UINT_32 u4BcnBufLen
,
3723 IN BOOLEAN fgIsProbeRsp
,
3724 IN P_P2P_PROBE_RSP_UPDATE_INFO_T prP2pProbeRspInfo
,
3725 IN BOOLEAN fgSynToFW
)
3727 WLAN_STATUS rWlanStatus
= WLAN_STATUS_SUCCESS
;
3728 P_MSDU_INFO_T prMsduInfo
= (P_MSDU_INFO_T
) NULL
;
3729 P_WLAN_MAC_HEADER_T prWlanBcnFrame
= (P_WLAN_MAC_HEADER_T
) NULL
;
3730 P_BSS_INFO_T prP2pBssInfo
= (P_BSS_INFO_T
) NULL
;
3732 PUINT_8 pucBuffer
= (PUINT_8
) NULL
;
3735 ASSERT_BREAK((prAdapter
!= NULL
) && (pucBcnBuffer
!= NULL
));
3737 prWlanBcnFrame
= (P_WLAN_MAC_HEADER_T
) pucBcnBuffer
;
3739 if ((prWlanBcnFrame
->u2FrameCtrl
!= MAC_FRAME_BEACON
) && (!fgIsProbeRsp
)) {
3740 rWlanStatus
= WLAN_STATUS_INVALID_DATA
;
3744 else if (prWlanBcnFrame
->u2FrameCtrl
!= MAC_FRAME_PROBE_RSP
) {
3745 rWlanStatus
= WLAN_STATUS_INVALID_DATA
;
3752 ASSERT_BREAK(prP2pProbeRspInfo
!= NULL
);
3754 if (!prP2pProbeRspInfo
->prProbeRspMsduTemplate
) {
3755 cnmMgtPktFree(prAdapter
, prP2pProbeRspInfo
->prProbeRspMsduTemplate
);
3758 prP2pProbeRspInfo
->prProbeRspMsduTemplate
=
3759 cnmMgtPktAlloc(prAdapter
, u4BcnBufLen
);
3761 prMsduInfo
= prP2pProbeRspInfo
->prProbeRspMsduTemplate
;
3763 prMsduInfo
->eSrc
= TX_PACKET_MGMT
;
3764 prMsduInfo
->ucStaRecIndex
= 0xFF;
3765 prMsduInfo
->ucNetworkType
= NETWORK_TYPE_P2P_INDEX
;
3768 prP2pBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_P2P_INDEX
]);
3769 prMsduInfo
= prP2pBssInfo
->prBeacon
;
3771 if (prMsduInfo
== NULL
) {
3772 rWlanStatus
= WLAN_STATUS_FAILURE
;
3777 (OFFSET_OF(WLAN_BEACON_FRAME_T
, aucInfoElem
[0]) + MAX_IE_LENGTH
)) {
3778 /* Unexpected error, buffer overflow. */
3786 pucBuffer
= (PUINT_8
) ((UINT_32
) (prMsduInfo
->prPacket
) + MAC_TX_RESERVED_FIELD
);
3788 kalMemCopy(pucBuffer
, pucBcnBuffer
, u4BcnBufLen
);
3790 prMsduInfo
->fgIs802_11
= TRUE
;
3791 prMsduInfo
->u2FrameLength
= (UINT_16
) u4BcnBufLen
;
3795 p2pFuncGenerateBeaconProbeRsp(prAdapter
, prP2pBssInfo
, prMsduInfo
,
3803 } /* p2pFuncComposeBeaconTemplate */