import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / connectivity / combo / drv_wlan / mt6620 / wlan / mgmt / p2p_func.c
1 #include "precomp.h"
2
3 #ifdef __GNUC__
4 #pragma GCC diagnostic ignored "-Wformat"
5 #endif
6
7
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 */
11 };
12
13
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 */
24 };
25
26 /*----------------------------------------------------------------------------*/
27 /*!
28 * @brief Function for requesting scan. There is an option to do ACTIVE or PASSIVE scan.
29 *
30 * @param eScanType - Specify the scan type of the scan request. It can be an ACTIVE/PASSIVE
31 * Scan.
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)
38 *
39 *
40 * @return (none)
41 */
42 /*----------------------------------------------------------------------------*/
43 VOID p2pFuncRequestScan(IN P_ADAPTER_T prAdapter, IN P_P2P_SCAN_REQ_INFO_T prScanReqInfo)
44 {
45
46 P_MSG_SCN_SCAN_REQ prScanReq = (P_MSG_SCN_SCAN_REQ) NULL;
47
48 DEBUGFUNC("p2pFuncRequestScan()");
49
50 do {
51 ASSERT_BREAK((prAdapter != NULL) && (prScanReqInfo != NULL));
52
53 if (prScanReqInfo->eChannelSet == SCAN_CHANNEL_SPECIFIED) {
54 ASSERT_BREAK(prScanReqInfo->ucNumChannelList > 0);
55 DBGLOG(P2P, LOUD,
56 ("P2P Scan Request Channel:%d\n",
57 prScanReqInfo->arScanChannelList[0].ucChannelNum));
58 }
59
60 prScanReq =
61 (P_MSG_SCN_SCAN_REQ) cnmMemAlloc(prAdapter, RAM_TYPE_MSG,
62 sizeof(MSG_SCN_SCAN_REQ));
63 if (!prScanReq) {
64 ASSERT(0); /* Can't trigger SCAN FSM */
65 break;
66 }
67
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;
74
75 /* Copy IE for Probe Request. */
76 kalMemCopy(prScanReq->aucIE, prScanReqInfo->aucIEBuf, prScanReqInfo->u4BufLength);
77 prScanReq->u2IELen = (UINT_16) prScanReqInfo->u4BufLength;
78
79 prScanReq->u2ChannelDwellTime = prScanReqInfo->u2PassiveDewellTime;
80
81 switch (prScanReqInfo->eChannelSet) {
82 case SCAN_CHANNEL_SPECIFIED:
83 {
84 UINT_32 u4Idx = 0;
85 P_RF_CHANNEL_INFO_T prDomainInfo =
86 (P_RF_CHANNEL_INFO_T) prScanReqInfo->arScanChannelList;
87
88 if (prScanReqInfo->ucNumChannelList >
89 MAXIMUM_OPERATION_CHANNEL_LIST) {
90 prScanReqInfo->ucNumChannelList =
91 MAXIMUM_OPERATION_CHANNEL_LIST;
92 }
93
94
95 for (u4Idx = 0; u4Idx < prScanReqInfo->ucNumChannelList; u4Idx++) {
96 prScanReq->arChnlInfoList[u4Idx].ucChannelNum =
97 prDomainInfo->ucChannelNum;
98 prScanReq->arChnlInfoList[u4Idx].eBand =
99 prDomainInfo->eBand;
100 prDomainInfo++;
101 }
102
103 prScanReq->ucChannelListNum = prScanReqInfo->ucNumChannelList;
104 }
105 case SCAN_CHANNEL_FULL:
106 case SCAN_CHANNEL_2G4:
107 case SCAN_CHANNEL_P2P_SOCIAL:
108 {
109 UINT_8 aucP2pSsid[] = P2P_WILDCARD_SSID;
110
111 COPY_SSID(prScanReq->aucSSID,
112 prScanReq->ucSSIDLength,
113 prScanReqInfo->rSsidStruct.aucSsid,
114 prScanReqInfo->rSsidStruct.ucSsidLen);
115
116 /* For compatible. */
117 if (EQUAL_SSID
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;
123 }
124 }
125 break;
126 default:
127 /* Currently there is no other scan channel set. */
128 ASSERT(FALSE);
129 break;
130 }
131
132 mboxSendMsg(prAdapter, MBOX_ID_0, (P_MSG_HDR_T) prScanReq, MSG_SEND_METHOD_BUF);
133
134 } while (FALSE);
135
136 return;
137 } /* p2pFuncRequestScan */
138
139 VOID p2pFuncCancelScan(IN P_ADAPTER_T prAdapter, IN P_P2P_SCAN_REQ_INFO_T prScanInfo)
140 {
141 P_MSG_SCN_SCAN_CANCEL prScanCancelMsg = (P_MSG_SCN_SCAN_CANCEL) NULL;
142
143 do {
144 ASSERT_BREAK((prAdapter != NULL) && (prScanInfo != NULL));
145
146 if (!prScanInfo->fgIsScanRequest) {
147 break;
148 }
149
150
151 if (prScanInfo->ucSeqNumOfScnMsg) {
152 /* There is a channel privilege on hand. */
153 DBGLOG(P2P, TRACE, ("P2P Cancel Scan\n"));
154
155 prScanCancelMsg =
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"));
161 ASSERT(FALSE);
162 break;
163 }
164
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;
170
171 mboxSendMsg(prAdapter,
172 MBOX_ID_0, (P_MSG_HDR_T) prScanCancelMsg, MSG_SEND_METHOD_BUF);
173
174
175 }
176
177
178 } while (FALSE);
179
180 return;
181 } /* p2pFuncCancelScan */
182
183
184 VOID
185 p2pFuncSwitchOPMode(IN P_ADAPTER_T prAdapter,
186 IN P_BSS_INFO_T prP2pBssInfo, IN ENUM_OP_MODE_T eOpMode, IN BOOLEAN fgSyncToFW)
187 {
188 do {
189 ASSERT_BREAK((prAdapter != NULL) &&
190 (prP2pBssInfo != NULL) && (eOpMode < OP_MODE_NUM));
191
192 if (prP2pBssInfo->eCurrentOPMode != eOpMode) {
193 DBGLOG(P2P, TRACE,
194 ("p2pFuncSwitchOPMode: Switch to from %d, to %d.\n",
195 prP2pBssInfo->eCurrentOPMode, eOpMode));
196
197 switch (prP2pBssInfo->eCurrentOPMode) {
198 case OP_MODE_ACCESS_POINT:
199 p2pFuncDissolve(prAdapter, prP2pBssInfo, TRUE,
200 REASON_CODE_DEAUTH_LEAVING_BSS);
201
202 p2pFsmRunEventStopAP(prAdapter, NULL);
203 break;
204 default:
205 break;
206 }
207
208
209 prP2pBssInfo->eIntendOPMode = eOpMode;
210 prP2pBssInfo->eCurrentOPMode = eOpMode;
211 switch (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); */
218 /* } */
219
220 /* Change interface address. */
221 if (eOpMode == OP_MODE_ACCESS_POINT) {
222 DBGLOG(P2P, TRACE,
223 ("p2pFuncSwitchOPMode: Switch to AP.\n"));
224 prP2pBssInfo->ucSSIDLen = 0;
225 }
226
227 COPY_MAC_ADDR(prP2pBssInfo->aucOwnMacAddr,
228 prAdapter->rWifiVar.aucInterfaceAddress);
229 COPY_MAC_ADDR(prP2pBssInfo->aucBSSID,
230 prAdapter->rWifiVar.aucInterfaceAddress);
231
232
233 break;
234 case OP_MODE_P2P_DEVICE:
235 {
236 /* Change device address. */
237 DBGLOG(P2P, TRACE,
238 ("p2pFuncSwitchOPMode: Switch back to P2P Device.\n"));
239
240 /* if (!IS_BSS_ACTIVE(prP2pBssInfo)) { */
241 /* SET_NET_ACTIVE(prAdapter, NETWORK_TYPE_P2P_INDEX); */
242 /* nicActivateNetwork(prAdapter, NETWORK_TYPE_P2P_INDEX); */
243 /* } */
244
245 p2pChangeMediaState(prAdapter,
246 PARAM_MEDIA_STATE_DISCONNECTED);
247
248 COPY_MAC_ADDR(prP2pBssInfo->aucOwnMacAddr,
249 prAdapter->rWifiVar.aucDeviceAddress);
250 COPY_MAC_ADDR(prP2pBssInfo->aucBSSID,
251 prAdapter->rWifiVar.aucDeviceAddress);
252
253
254 }
255 break;
256 default:
257 /* if (IS_BSS_ACTIVE(prP2pBssInfo)) { */
258 /* UNSET_NET_ACTIVE(prAdapter, NETWORK_TYPE_P2P_INDEX); */
259
260 /* nicDeactivateNetwork(prAdapter, NETWORK_TYPE_P2P_INDEX); */
261 /* } */
262 ASSERT(FALSE);
263 break;
264 }
265
266 if (1) {
267 P2P_DISCONNECT_INFO rP2PDisInfo;
268
269 rP2PDisInfo.ucRole = 2;
270 wlanSendSetQueryCmd(prAdapter,
271 CMD_ID_P2P_ABORT,
272 TRUE,
273 FALSE,
274 FALSE,
275 NULL,
276 NULL,
277 sizeof(P2P_DISCONNECT_INFO),
278 (PUINT_8) & rP2PDisInfo, NULL, 0);
279 }
280
281
282 DBGLOG(P2P, TRACE,
283 ("The device address is changed to " MACSTR "\n",
284 MAC2STR(prP2pBssInfo->aucOwnMacAddr)));
285 DBGLOG(P2P, TRACE,
286 ("The BSSID is changed to " MACSTR "\n",
287 MAC2STR(prP2pBssInfo->aucBSSID)));
288
289 /* Update BSS INFO to FW. */
290 if ((fgSyncToFW) && (eOpMode != OP_MODE_ACCESS_POINT)) {
291 nicUpdateBss(prAdapter, NETWORK_TYPE_P2P_INDEX);
292 }
293 }
294
295 } while (FALSE);
296
297 return;
298 } /* p2pFuncSwitchOPMode */
299
300
301
302 /*----------------------------------------------------------------------------*/
303 /*!
304 * @brief This function will start a P2P Group Owner and send Beacon Frames.
305 *
306 * @param (none)
307 *
308 * @return (none)
309 */
310 /*----------------------------------------------------------------------------*/
311 VOID
312 p2pFuncStartGO(IN P_ADAPTER_T prAdapter,
313 IN P_BSS_INFO_T prBssInfo,
314 IN PUINT_8 pucSsidBuf,
315 IN UINT_8 ucSsidLen,
316 IN UINT_8 ucChannelNum,
317 IN ENUM_BAND_T eBand, IN ENUM_CHNL_EXT_T eSco, IN BOOLEAN fgIsPureAP)
318 {
319 do {
320 ASSERT_BREAK((prAdapter != NULL) && (prBssInfo != NULL));
321
322 ASSERT(prBssInfo->eCurrentOPMode == OP_MODE_ACCESS_POINT);
323
324 DBGLOG(P2P, TRACE, ("p2pFuncStartGO:\n"));
325
326 /* AP mode started. */
327 p2pFuncSwitchOPMode(prAdapter, prBssInfo, prBssInfo->eIntendOPMode, FALSE);
328
329 prBssInfo->eIntendOPMode = OP_MODE_NUM;
330
331 /* 4 <1.1> Assign SSID */
332 COPY_SSID(prBssInfo->aucSSID, prBssInfo->ucSSIDLen, pucSsidBuf, ucSsidLen);
333
334 DBGLOG(P2P, TRACE, ("GO SSID:%s\n", prBssInfo->aucSSID));
335
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;
339
340
341 /* 4 <1.3> Setup Channel, Band and Phy Attributes */
342 prBssInfo->ucPrimaryChannel = ucChannelNum;
343 prBssInfo->eBand = eBand;
344 prBssInfo->eBssSCO = eSco;
345
346 DBGLOG(P2P, TRACE, ("GO Channel:%d\n", ucChannelNum));
347
348
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 */
355 } else {
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 */
358 }
359
360
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;
367
368 if (prBssInfo->ucAllSupportedRatesLen == 0) {
369 rateGetDataRatesFromRateSet(prBssInfo->u2OperationalRateSet,
370 prBssInfo->u2BSSBasicRateSet,
371 prBssInfo->aucAllSupportedRates,
372 &prBssInfo->ucAllSupportedRatesLen);
373 }
374 /* 4 <1.5> Setup MIB for current BSS */
375 prBssInfo->u2ATIMWindow = 0;
376 prBssInfo->ucBeaconTimeoutCount = 0;
377
378 /* 3 <2> Update BSS_INFO_T common part */
379 #if CFG_SUPPORT_AAA
380 if (!fgIsPureAP) {
381 prBssInfo->fgIsProtection = TRUE; /* Always enable protection at P2P GO */
382 kalP2PSetCipher(prAdapter->prGlueInfo, IW_AUTH_CIPHER_CCMP);
383 } else {
384 if (kalP2PGetCipher(prAdapter->prGlueInfo))
385 prBssInfo->fgIsProtection = TRUE;
386 }
387
388 /* 20120106 frog: I want separate OP_Mode & Beacon TX Function. */
389 /* p2pFuncSwitchOPMode(prAdapter, prBssInfo, OP_MODE_ACCESS_POINT, FALSE); */
390
391 bssInitForAP(prAdapter, prBssInfo, FALSE);
392
393 nicQmUpdateWmmParms(prAdapter, NETWORK_TYPE_P2P_INDEX);
394 #endif /* CFG_SUPPORT_AAA */
395
396
397 /* 3 <3> Set MAC HW */
398 /* 4 <3.1> Setup channel and bandwidth */
399 rlmBssInitForAPandIbss(prAdapter, prBssInfo);
400
401 /* 4 <3.2> Reset HW TSF Update Mode and Beacon Mode */
402 nicUpdateBss(prAdapter, NETWORK_TYPE_P2P_INDEX);
403
404 /* 4 <3.3> Update Beacon again for network phy type confirmed. */
405 bssUpdateBeaconContent(prAdapter, NETWORK_TYPE_P2P_INDEX);
406
407 /* 4 <3.4> Setup BSSID */
408 nicPmIndicateBssCreated(prAdapter, NETWORK_TYPE_P2P_INDEX);
409
410 } while (FALSE);
411
412 return;
413 } /* p2pFuncStartGO() */
414
415
416
417
418 /*----------------------------------------------------------------------------*/
419 /*!
420 * \brief This function is to inform CNM that channel privilege
421 * has been released
422 *
423 * \param[in] prAdapter Pointer of ADAPTER_T
424 *
425 * \return none
426 */
427 /*----------------------------------------------------------------------------*/
428 VOID p2pFuncReleaseCh(IN P_ADAPTER_T prAdapter, IN P_P2P_CHNL_REQ_INFO_T prChnlReqInfo)
429 {
430 P_MSG_CH_ABORT_T prMsgChRelease = (P_MSG_CH_ABORT_T) NULL;
431
432 DEBUGFUNC("p2pFuncReleaseCh()");
433
434 do {
435 ASSERT_BREAK((prAdapter != NULL) && (prChnlReqInfo != NULL));
436
437 if (!prChnlReqInfo->fgIsChannelRequested) {
438 break;
439 } else {
440 DBGLOG(P2P, TRACE, ("P2P Release Channel\n"));
441 prChnlReqInfo->fgIsChannelRequested = FALSE;
442 }
443
444 /* 1. return channel privilege to CNM immediately */
445 prMsgChRelease =
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 */
449 break;
450 }
451
452 prMsgChRelease->rMsgHdr.eMsgId = MID_MNY_CNM_CH_ABORT;
453 prMsgChRelease->ucNetTypeIndex = NETWORK_TYPE_P2P_INDEX;
454 prMsgChRelease->ucTokenID = prChnlReqInfo->ucSeqNumOfChReq++;
455
456 mboxSendMsg(prAdapter,
457 MBOX_ID_0, (P_MSG_HDR_T) prMsgChRelease, MSG_SEND_METHOD_BUF);
458
459 } while (FALSE);
460
461 return;
462 } /* p2pFuncReleaseCh */
463
464
465 /*----------------------------------------------------------------------------*/
466 /*!
467 * @brief Process of CHANNEL_REQ_JOIN Initial. Enter CHANNEL_REQ_JOIN State.
468 *
469 * @param (none)
470 *
471 * @return (none)
472 */
473 /*----------------------------------------------------------------------------*/
474 VOID p2pFuncAcquireCh(IN P_ADAPTER_T prAdapter, IN P_P2P_CHNL_REQ_INFO_T prChnlReqInfo)
475 {
476 P_MSG_CH_REQ_T prMsgChReq = (P_MSG_CH_REQ_T) NULL;
477
478 do {
479 ASSERT_BREAK((prAdapter != NULL) && (prChnlReqInfo != NULL));
480
481 p2pFuncReleaseCh(prAdapter, prChnlReqInfo);
482
483 /* send message to CNM for acquiring channel */
484 prMsgChReq =
485 (P_MSG_CH_REQ_T) cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(MSG_CH_REQ_T));
486
487 if (!prMsgChReq) {
488 ASSERT(0); /* Can't indicate CNM for channel acquiring */
489 break;
490 }
491
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;
497
498 prMsgChReq->ucPrimaryChannel = prChnlReqInfo->ucReqChnlNum;
499 prMsgChReq->eRfSco = prChnlReqInfo->eChnlSco;
500 prMsgChReq->eRfBand = prChnlReqInfo->eBand;
501
502 kalMemZero(prMsgChReq->aucBSSID, MAC_ADDR_LEN);
503
504 /* Channel request join BSSID. */
505
506 mboxSendMsg(prAdapter, MBOX_ID_0, (P_MSG_HDR_T) prMsgChReq, MSG_SEND_METHOD_BUF);
507
508 prChnlReqInfo->fgIsChannelRequested = TRUE;
509
510 } while (FALSE);
511
512 return;
513 } /* p2pFuncAcquireCh */
514
515 #if 0
516 WLAN_STATUS
517 p2pFuncBeaconUpdate(IN P_ADAPTER_T prAdapter,
518 IN PUINT_8 pucBcnHdr,
519 IN UINT_32 u4HdrLen,
520 IN PUINT_8 pucBcnBody,
521 IN UINT_32 u4BodyLen, IN UINT_32 u4DtimPeriod, IN UINT_32 u4BcnInterval)
522 {
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];
530
531 do {
532 ASSERT_BREAK(prAdapter != NULL);
533
534 prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
535 prBcnMsduInfo = prP2pBssInfo->prBeacon ASSERT_BREAK(prBcnMsduInfo != NULL);
536
537 /* TODO: Find TIM IE pointer. */
538 prBcnFrame = prBcnMsduInfo->prPacket;
539
540 ASSERT_BREAK(prBcnFrame != NULL);
541
542 do {
543 /* Ori header. */
544 UINT_16 u2IELength = 0, u2Offset = 0;
545 PUINT_8 pucIEBuf = prBcnFrame->aucInfoElem;
546
547 u2IELength =
548 prBcnMsduInfo->u2FrameLength - prBcnMsduInfo->ucMacHeaderLength;
549
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;
554 break;
555 }
556 u2FrameLength += IE_SIZE(pucIEBuf);
557 }
558
559 if (pucTIMBody == NULL) {
560 pucTIMBody = pucIEBuf;
561 }
562
563 /* Body not change. */
564 u2OldBodyLen = (UINT_16) ((UINT_32) pucTIMBody - (UINT_32) prBcnFrame->aucInfoElem);
565 /* Move body. */
566 kalMemCmp(aucIEBuf, pucTIMBody, u2OldBodyLen);
567 } while (FALSE);
568
569 if (pucBcnHdr) {
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. */
574 } else {
575 /* Header not change. */
576 u2FrameLength += prBcnMsduInfo->ucMacHeaderLength;
577 }
578
579
580 if (pucBcnBody) {
581 kalMemCopy(pucTIMBody, pucBcnBody, u4BodyLen);
582 u2FrameLength += (UINT_16) u4BodyLen;
583 } else {
584 kalMemCopy(pucTIMBody, aucIEBuf, u2OldBodyLen);
585 u2FrameLength += u2OldBodyLen;
586 }
587
588 /* Frame Length */
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);
606 }
607
608 } while (FALSE);
609
610 return rResultStatus;
611 } /* p2pFuncBeaconUpdate */
612
613 #else
614 WLAN_STATUS
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)
620 {
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];
626
627 do {
628 ASSERT_BREAK((prAdapter != NULL) && (prP2pBssInfo != NULL) && (prBcnUpdateInfo != NULL));
629
630 prBcnMsduInfo = prP2pBssInfo->prBeacon;
631
632 #if DBG
633 if (prBcnUpdateInfo->pucBcnHdr != NULL) {
634 ASSERT((UINT_32) prBcnUpdateInfo->pucBcnHdr ==
635 ((UINT_32) prBcnMsduInfo->prPacket + MAC_TX_RESERVED_FIELD));
636 }
637
638 if (prBcnUpdateInfo->pucBcnBody != NULL) {
639 ASSERT((UINT_32) prBcnUpdateInfo->pucBcnBody ==
640 ((UINT_32) prBcnUpdateInfo->pucBcnHdr +
641 (UINT_32) prBcnUpdateInfo->u4BcnHdrLen));
642 }
643 #endif
644 prBcnFrame =
645 (P_WLAN_BEACON_FRAME_T) ((UINT_32) prBcnMsduInfo->prPacket + MAC_TX_RESERVED_FIELD);
646
647 if (!pucNewBcnBody) {
648 /* Old body. */
649 pucNewBcnBody = prBcnUpdateInfo->pucBcnBody;
650 ASSERT(u4NewBodyLen == 0);
651 u4NewBodyLen = prBcnUpdateInfo->u4BcnBodyLen;
652 } else {
653 prBcnUpdateInfo->u4BcnBodyLen = u4NewBodyLen;
654 }
655
656 /* Temp buffer body part. */
657 kalMemCopy(aucIEBuf, pucNewBcnBody, u4NewBodyLen);
658
659 if (pucNewBcnHdr) {
660 kalMemCopy(prBcnFrame, pucNewBcnHdr, u4NewHdrLen);
661 prBcnUpdateInfo->pucBcnHdr = (PUINT_8) prBcnFrame;
662 prBcnUpdateInfo->u4BcnHdrLen = u4NewHdrLen;
663 }
664
665 pucIEBuf =
666 (PUINT_8) ((UINT_32) prBcnUpdateInfo->pucBcnHdr +
667 (UINT_32) prBcnUpdateInfo->u4BcnHdrLen);
668 kalMemCopy(pucIEBuf, aucIEBuf, u4NewBodyLen);
669 prBcnUpdateInfo->pucBcnBody = pucIEBuf;
670
671 /* Frame Length */
672 prBcnMsduInfo->u2FrameLength =
673 (UINT_16) (prBcnUpdateInfo->u4BcnHdrLen + prBcnUpdateInfo->u4BcnBodyLen);
674
675 prBcnMsduInfo->ucPacketType = 3;
676 prBcnMsduInfo->fgIs802_11 = TRUE;
677 prBcnMsduInfo->ucNetworkType = NETWORK_TYPE_P2P_INDEX;
678
679
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;
684
685 p2pFuncParseBeaconContent(prAdapter,
686 prP2pBssInfo,
687 (PUINT_8) prBcnFrame->aucInfoElem,
688 (prBcnMsduInfo->u2FrameLength -
689 OFFSET_OF(WLAN_BEACON_FRAME_T, aucInfoElem)));
690
691 #if 1
692 /* bssUpdateBeaconContent(prAdapter, NETWORK_TYPE_P2P_INDEX); */
693 #else
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)));
701 #endif
702 } while (FALSE);
703
704 return rWlanStatus;
705 } /* p2pFuncBeaconUpdate */
706
707 #endif
708
709 /* TODO: We do not apply IE in deauth frame set from upper layer now. */
710 WLAN_STATUS
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)
715 {
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;
720
721 do {
722 ASSERT_BREAK((prAdapter != NULL) && (pucPeerMacAddr != NULL));
723
724 prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
725
726 prCliStaRec = cnmGetStaRecByAddress(prAdapter,
727 NETWORK_TYPE_P2P_INDEX, pucPeerMacAddr);
728
729 switch (prP2pBssInfo->eCurrentOPMode) {
730 case OP_MODE_ACCESS_POINT:
731 {
732 P_LINK_T prStaRecOfClientList = (P_LINK_T) NULL;
733 P_LINK_ENTRY_T prLinkEntry = (P_LINK_ENTRY_T) NULL;
734
735 prStaRecOfClientList = &(prP2pBssInfo->rStaRecOfClientList);
736
737 LINK_FOR_EACH(prLinkEntry, prStaRecOfClientList) {
738 if ((UINT_32) prCliStaRec == (UINT_32) prLinkEntry) {
739 LINK_REMOVE_KNOWN_ENTRY(prStaRecOfClientList,
740 &prCliStaRec->rLinkEntry);
741 fgIsStaFound = TRUE;
742 break;
743 }
744 }
745
746 }
747 break;
748 case OP_MODE_INFRASTRUCTURE:
749 ASSERT(prCliStaRec == prP2pBssInfo->prStaRecOfAP);
750 if (prCliStaRec != prP2pBssInfo->prStaRecOfAP) {
751 break;
752 }
753 prP2pBssInfo->prStaRecOfAP = NULL;
754 fgIsStaFound = TRUE;
755 break;
756 default:
757 break;
758 }
759
760 if (fgIsStaFound) {
761 p2pFuncDisconnect(prAdapter, prCliStaRec, fgSendDeauth, u2ReasonCode);
762 }
763
764 rWlanStatus = WLAN_STATUS_SUCCESS;
765 } while (FALSE);
766
767 return rWlanStatus;
768 } /* p2pFuncDeauth */
769
770 /* TODO: We do not apply IE in disassoc frame set from upper layer now. */
771 WLAN_STATUS
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)
776 {
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;
781
782 do {
783 ASSERT_BREAK((prAdapter != NULL) && (pucPeerMacAddr != NULL));
784
785 prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
786
787 prCliStaRec = cnmGetStaRecByAddress(prAdapter,
788 NETWORK_TYPE_P2P_INDEX, pucPeerMacAddr);
789
790 switch (prP2pBssInfo->eCurrentOPMode) {
791 case OP_MODE_ACCESS_POINT:
792 {
793 P_LINK_T prStaRecOfClientList = (P_LINK_T) NULL;
794 P_LINK_ENTRY_T prLinkEntry = (P_LINK_ENTRY_T) NULL;
795
796 prStaRecOfClientList = &(prP2pBssInfo->rStaRecOfClientList);
797
798 LINK_FOR_EACH(prLinkEntry, prStaRecOfClientList) {
799 if ((UINT_32) prCliStaRec == (UINT_32) prLinkEntry) {
800 LINK_REMOVE_KNOWN_ENTRY(prStaRecOfClientList,
801 &prCliStaRec->rLinkEntry);
802 fgIsStaFound = TRUE;
803 /* p2pFuncDisconnect(prAdapter, prCliStaRec, fgSendDisassoc, u2ReasonCode); */
804 break;
805 }
806 }
807
808 }
809 break;
810 case OP_MODE_INFRASTRUCTURE:
811 ASSERT(prCliStaRec == prP2pBssInfo->prStaRecOfAP);
812 if (prCliStaRec != prP2pBssInfo->prStaRecOfAP) {
813 break;
814 }
815 /* p2pFuncDisconnect(prAdapter, prCliStaRec, fgSendDisassoc, u2ReasonCode); */
816 prP2pBssInfo->prStaRecOfAP = NULL;
817 fgIsStaFound = TRUE;
818 break;
819 default:
820 break;
821 }
822
823 if (fgIsStaFound) {
824
825 p2pFuncDisconnect(prAdapter, prCliStaRec, fgSendDisassoc, u2ReasonCode);
826 /* 20120830 moved into p2pFuncDisconnect(). */
827 /* cnmStaRecFree(prAdapter, prCliStaRec, TRUE); */
828
829 }
830
831 rWlanStatus = WLAN_STATUS_SUCCESS;
832 } while (FALSE);
833
834 return rWlanStatus;
835 } /* p2pFuncDisassoc */
836
837 /*----------------------------------------------------------------------------*/
838 /*!
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
842 *
843 * @param[in] prAdapter Pointer to the adapter structure.
844 *
845 * @return (none)
846 */
847 /*----------------------------------------------------------------------------*/
848 VOID
849 p2pFuncDissolve(IN P_ADAPTER_T prAdapter,
850 IN P_BSS_INFO_T prP2pBssInfo, IN BOOLEAN fgSendDeauth, IN UINT_16 u2ReasonCode)
851 {
852 DEBUGFUNC("p2pFuncDissolve()");
853
854 do {
855
856 ASSERT_BREAK((prAdapter != NULL) && (prP2pBssInfo != NULL));
857
858 switch (prP2pBssInfo->eCurrentOPMode) {
859 case OP_MODE_INFRASTRUCTURE:
860 /* Reset station record status. */
861 if (prP2pBssInfo->prStaRecOfAP) {
862 kalP2PGCIndicateConnectionStatus(prAdapter->prGlueInfo,
863 NULL,
864 NULL,
865 0, REASON_CODE_DEAUTH_LEAVING_BSS);
866
867 /* 2012/02/14 frog: After formation before join group, prStaRecOfAP is NULL. */
868 p2pFuncDisconnect(prAdapter,
869 prP2pBssInfo->prStaRecOfAP,
870 fgSendDeauth, u2ReasonCode);
871 }
872
873 /* Fix possible KE when RX Beacon & call nicPmIndicateBssConnected(). hit prStaRecOfAP == NULL. */
874 p2pChangeMediaState(prAdapter, PARAM_MEDIA_STATE_DISCONNECTED);
875
876 prP2pBssInfo->prStaRecOfAP = NULL;
877
878 break;
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.
882 */
883 {
884 P_LINK_T prStaRecOfClientList = (P_LINK_T) NULL;
885
886 /* Send deauth. */
887 authSendDeauthFrame(prAdapter,
888 NULL,
889 (P_SW_RFB_T) NULL,
890 u2ReasonCode, (PFN_TX_DONE_HANDLER) NULL);
891
892 prStaRecOfClientList = &prP2pBssInfo->rStaRecOfClientList;
893
894 while (!LINK_IS_EMPTY(prStaRecOfClientList)) {
895 P_STA_RECORD_T prCurrStaRec;
896
897 LINK_REMOVE_HEAD(prStaRecOfClientList, prCurrStaRec,
898 P_STA_RECORD_T);
899
900 /* Indicate to Host. */
901 /* kalP2PGOStationUpdate(prAdapter->prGlueInfo, prCurrStaRec, FALSE); */
902
903 p2pFuncDisconnect(prAdapter, prCurrStaRec, TRUE,
904 u2ReasonCode);
905
906 }
907
908 }
909
910 break;
911 default:
912 return; /* 20110420 -- alreay in Device Mode. */
913 }
914
915 /* Make the deauth frame send to FW ASAP. */
916 wlanAcquirePowerControl(prAdapter);
917 wlanProcessCommandQueue(prAdapter, &prAdapter->prGlueInfo->rCmdQueue);
918 wlanReleasePowerControl(prAdapter);
919
920 kalMdelay(100);
921
922 /* Change Connection Status. */
923 p2pChangeMediaState(prAdapter, PARAM_MEDIA_STATE_DISCONNECTED);
924
925 } while (FALSE);
926
927 return;
928 } /* p2pFuncDissolve */
929
930
931 /*----------------------------------------------------------------------------*/
932 /*!
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
936 *
937 * @param[in] prAdapter Pointer to the adapter structure.
938 *
939 * @return (none)
940 */
941 /*----------------------------------------------------------------------------*/
942 VOID
943 p2pFuncDisconnect(IN P_ADAPTER_T prAdapter,
944 IN P_STA_RECORD_T prStaRec, IN BOOLEAN fgSendDeauth, IN UINT_16 u2ReasonCode)
945 {
946 P_BSS_INFO_T prP2pBssInfo = (P_BSS_INFO_T) NULL;
947 ENUM_PARAM_MEDIA_STATE_T eOriMediaStatus;
948
949 DBGLOG(P2P, TRACE, ("p2pFuncDisconnect()"));
950
951 do {
952 ASSERT_BREAK((prAdapter != NULL) && (prStaRec != NULL));
953
954 prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
955 eOriMediaStatus = prP2pBssInfo->eConnectionState;
956
957 /* Indicate disconnect. */
958 /* TODO: */
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);
964 }
965
966 if (fgSendDeauth) {
967 /* Send deauth. */
968 authSendDeauthFrame(prAdapter,
969 prStaRec,
970 (P_SW_RFB_T) NULL,
971 u2ReasonCode,
972 (PFN_TX_DONE_HANDLER) p2pFsmRunEventDeauthTxDone);
973 /* Change station state. */
974 cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_1);
975
976 /* Reset Station Record Status. */
977 p2pFuncResetStaRecStatus(prAdapter, prStaRec);
978
979
980 } else {
981 /* Change station state. */
982 cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_1);
983
984 /* Reset Station Record Status. */
985 p2pFuncResetStaRecStatus(prAdapter, prStaRec);
986
987 cnmStaRecFree(prAdapter, prStaRec, TRUE);
988
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);
993 }
994
995 if (eOriMediaStatus != prP2pBssInfo->eConnectionState) {
996 /* Update Disconnected state to FW. */
997 nicUpdateBss(prAdapter, NETWORK_TYPE_P2P_INDEX);
998 }
999
1000 }
1001
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);
1005
1006 /* Reset RLM related field of BSSINFO. */
1007 rlmBssAborted(prAdapter, prP2pBssInfo);
1008 }
1009
1010 } while (FALSE);
1011
1012 return;
1013
1014 } /* p2pFuncDisconnect */
1015
1016
1017
1018
1019
1020
1021 WLAN_STATUS
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)
1025 {
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;
1030
1031 do {
1032 ASSERT_BREAK((prAdapter != NULL) && (prMgmtTxReqInfo != NULL));
1033
1034 if (prMgmtTxReqInfo->fgIsMgmtTxRequested) {
1035
1036 /* 1. prMgmtTxReqInfo->prMgmtTxMsdu != NULL */
1037 /* Packet on driver, not done yet, drop it. */
1038 if ((prTxMsduInfo = prMgmtTxReqInfo->prMgmtTxMsdu) != NULL) {
1039
1040 kalP2PIndicateMgmtTxStatus(prAdapter->prGlueInfo,
1041 prMgmtTxReqInfo->u8Cookie,
1042 FALSE,
1043 prTxMsduInfo->prPacket,
1044 (UINT_32) prTxMsduInfo->u2FrameLength);
1045
1046 /* Leave it to TX Done handler. */
1047 /* cnmMgtPktFree(prAdapter, prTxMsduInfo); */
1048 prMgmtTxReqInfo->prMgmtTxMsdu = NULL;
1049 }
1050 /* 2. prMgmtTxReqInfo->prMgmtTxMsdu == NULL */
1051 /* Packet transmitted, wait tx done. (cookie issue) */
1052 /* 20120105 frog - use another u8cookie to store this value. */
1053
1054 }
1055
1056 ASSERT(prMgmtTxReqInfo->prMgmtTxMsdu == NULL);
1057
1058
1059
1060 prWlanHdr =
1061 (P_WLAN_MAC_HEADER_T) ((UINT_32) prMgmtTxMsdu->prPacket +
1062 MAC_TX_RESERVED_FIELD);
1063 prStaRec =
1064 cnmGetStaRecByAddress(prAdapter, NETWORK_TYPE_P2P_INDEX, prWlanHdr->aucAddr1);
1065 prMgmtTxMsdu->ucNetworkType = (UINT_8) NETWORK_TYPE_P2P_INDEX;
1066
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);
1071 break;
1072 default:
1073 break;
1074 }
1075
1076
1077 prMgmtTxReqInfo->u8Cookie = u8Cookie;
1078 prMgmtTxReqInfo->prMgmtTxMsdu = prMgmtTxMsdu;
1079 prMgmtTxReqInfo->fgIsMgmtTxRequested = TRUE;
1080
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) {
1085 DBGLOG(P2P, TRACE,
1086 ("Mgmt with station record: " MACSTR " .\n",
1087 MAC2STR(prStaRec->aucMacAddr)));
1088 }
1089
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));
1097
1098 nicTxEnqueueMsdu(prAdapter, prMgmtTxMsdu);
1099
1100 } while (FALSE);
1101
1102 return rWlanStatus;
1103 } /* p2pFuncTxMgmtFrame */
1104
1105
1106
1107 VOID p2pFuncSetChannel(IN P_ADAPTER_T prAdapter, IN P_RF_CHANNEL_INFO_T prRfChannelInfo)
1108 {
1109 P_P2P_CONNECTION_SETTINGS_T prP2pConnSettings = (P_P2P_CONNECTION_SETTINGS_T) NULL;
1110
1111 do {
1112 ASSERT_BREAK((prAdapter != NULL) && (prRfChannelInfo != NULL));
1113
1114 prP2pConnSettings = prAdapter->rWifiVar.prP2PConnSettings;
1115
1116 prP2pConnSettings->ucOperatingChnl = prRfChannelInfo->ucChannelNum;
1117 prP2pConnSettings->eBand = prRfChannelInfo->eBand;
1118
1119
1120 } while (FALSE);
1121
1122 return;
1123 }
1124
1125 /* p2pFuncSetChannel */
1126
1127
1128
1129 /*----------------------------------------------------------------------------*/
1130 /*!
1131 * @brief Retry JOIN for AUTH_MODE_AUTO_SWITCH
1132 *
1133 * @param[in] prStaRec Pointer to the STA_RECORD_T
1134 *
1135 * @retval TRUE We will retry JOIN
1136 * @retval FALSE We will not retry JOIN
1137 */
1138 /*----------------------------------------------------------------------------*/
1139 BOOLEAN
1140 p2pFuncRetryJOIN(IN P_ADAPTER_T prAdapter,
1141 IN P_STA_RECORD_T prStaRec, IN P_P2P_JOIN_INFO_T prJoinInfo)
1142 {
1143 P_MSG_JOIN_REQ_T prJoinReqMsg = (P_MSG_JOIN_REQ_T) NULL;
1144 BOOLEAN fgRetValue = FALSE;
1145
1146 do {
1147 ASSERT_BREAK((prAdapter != NULL) && (prStaRec != NULL) && (prJoinInfo != NULL));
1148
1149 /* Retry other AuthType if possible */
1150 if (!prJoinInfo->ucAvailableAuthTypes) {
1151 break;
1152 }
1153
1154 if (prJoinInfo->ucAvailableAuthTypes & (UINT_8) AUTH_TYPE_SHARED_KEY) {
1155
1156 DBGLOG(P2P, INFO,
1157 ("RETRY JOIN INIT: Retry Authentication with AuthType == SHARED_KEY.\n"));
1158
1159 prJoinInfo->ucAvailableAuthTypes &= ~(UINT_8) AUTH_TYPE_SHARED_KEY;
1160
1161 prStaRec->ucAuthAlgNum = (UINT_8) AUTH_ALGORITHM_NUM_SHARED_KEY;
1162 } else {
1163 DBGLOG(P2P, ERROR,
1164 ("RETRY JOIN INIT: Retry Authentication with Unexpected AuthType.\n"));
1165 ASSERT(0);
1166 break;
1167 }
1168
1169 prJoinInfo->ucAvailableAuthTypes = 0; /* No more available Auth Types */
1170
1171 /* Trigger SAA to start JOIN process. */
1172 prJoinReqMsg =
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 */
1176 break;
1177 }
1178
1179 prJoinReqMsg->rMsgHdr.eMsgId = MID_P2P_SAA_FSM_START;
1180 prJoinReqMsg->ucSeqNum = ++prJoinInfo->ucSeqNumOfReqMsg;
1181 prJoinReqMsg->prStaRec = prStaRec;
1182
1183 mboxSendMsg(prAdapter, MBOX_ID_0, (P_MSG_HDR_T) prJoinReqMsg, MSG_SEND_METHOD_BUF);
1184
1185
1186 fgRetValue = TRUE;
1187 } while (FALSE);
1188
1189 return fgRetValue;
1190
1191
1192
1193 } /* end of p2pFuncRetryJOIN() */
1194
1195
1196
1197
1198
1199 /*----------------------------------------------------------------------------*/
1200 /*!
1201 * @brief This function will update the contain of BSS_INFO_T for AIS network once
1202 * the association was completed.
1203 *
1204 * @param[in] prStaRec Pointer to the STA_RECORD_T
1205 * @param[in] prAssocRspSwRfb Pointer to SW RFB of ASSOC RESP FRAME.
1206 *
1207 * @return (none)
1208 */
1209 /*----------------------------------------------------------------------------*/
1210 VOID
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)
1214 {
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;
1218 UINT_16 u2IELength;
1219 PUINT_8 pucIE;
1220
1221 DEBUGFUNC("p2pUpdateBssInfoForJOIN()");
1222
1223 ASSERT(prAdapter);
1224 ASSERT(prStaRec);
1225 ASSERT(prAssocRspSwRfb);
1226
1227 prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
1228 prP2pConnSettings = prAdapter->rWifiVar.prP2PConnSettings;
1229 prAssocRspFrame = (P_WLAN_ASSOC_RSP_FRAME_T) prAssocRspSwRfb->pvHeader;
1230
1231 DBGLOG(P2P, INFO, ("Update P2P_BSS_INFO_T and apply settings to MAC\n"));
1232
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;
1236
1237 /* 4 <1.2> Setup SSID */
1238 COPY_SSID(prP2pBssInfo->aucSSID,
1239 prP2pBssInfo->ucSSIDLen,
1240 prP2pConnSettings->aucSSID, prP2pConnSettings->ucSSIDLen);
1241
1242 if (prBssDesc == NULL) {
1243 /* Target BSS NULL. */
1244 DBGLOG(P2P, TRACE, ("Target BSS NULL\n"));
1245 return;
1246 }
1247
1248
1249 if (UNEQUAL_MAC_ADDR(prBssDesc->aucBSSID, prAssocRspFrame->aucBSSID)) {
1250 ASSERT(FALSE);
1251 }
1252 /* 4 <1.3> Setup Channel, Band */
1253 prP2pBssInfo->ucPrimaryChannel = prBssDesc->ucChannelNum;
1254 prP2pBssInfo->eBand = prBssDesc->eBand;
1255
1256
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;
1261
1262 /* 4 <2.2> Setup Capability */
1263 prP2pBssInfo->u2CapInfo = prStaRec->u2CapInfo; /* Use AP's Cap Info as BSS Cap Info */
1264
1265 if (prP2pBssInfo->u2CapInfo & CAP_INFO_SHORT_PREAMBLE) {
1266 prP2pBssInfo->fgIsShortPreambleAllowed = TRUE;
1267 } else {
1268 prP2pBssInfo->fgIsShortPreambleAllowed = FALSE;
1269 }
1270
1271 /* 4 <2.3> Setup PHY Attributes and Basic Rate Set/Operational Rate Set */
1272 prP2pBssInfo->ucPhyTypeSet = prStaRec->ucDesiredPhyTypeSet;
1273
1274 prP2pBssInfo->ucNonHTBasicPhyType = prStaRec->ucNonHTBasicPhyType;
1275
1276 prP2pBssInfo->u2OperationalRateSet = prStaRec->u2OperationalRateSet;
1277 prP2pBssInfo->u2BSSBasicRateSet = prStaRec->u2BSSBasicRateSet;
1278
1279
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);
1283
1284
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;
1289
1290
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);
1294
1295 prP2pBssInfo->fgIsQBSS = prStaRec->fgIsQoS;
1296
1297 /* 3 <4> Update BSS_INFO_T from BSS_DESC_T */
1298 ASSERT(prBssDesc);
1299
1300 prBssDesc->fgIsConnecting = FALSE;
1301 prBssDesc->fgIsConnected = TRUE;
1302
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;
1308
1309 prP2pBssInfo->ucBeaconTimeoutCount = AIS_BEACON_TIMEOUT_COUNT_INFRA;
1310
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()
1314 */
1315 rlmProcessAssocRsp(prAdapter, prAssocRspSwRfb, pucIE, u2IELength);
1316
1317 /* 4 <4.3> Sync with firmware for BSS-INFO */
1318 nicUpdateBss(prAdapter, NETWORK_TYPE_P2P_INDEX);
1319
1320 /* 4 <4.4> *DEFER OPERATION* nicPmIndicateBssConnected() will be invoked */
1321 /* inside scanProcessBeaconAndProbeResp() after 1st beacon is received */
1322
1323 return;
1324 } /* end of p2pUpdateBssInfoForJOIN() */
1325
1326
1327
1328 /*----------------------------------------------------------------------------*/
1329 /*!
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.
1333 *
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
1338 *
1339 * @retval TRUE Reply the Auth
1340 * @retval FALSE Don't reply the Auth
1341 */
1342 /*----------------------------------------------------------------------------*/
1343 BOOLEAN
1344 p2pFuncValidateAuth(IN P_ADAPTER_T prAdapter,
1345 IN P_SW_RFB_T prSwRfb, IN PP_STA_RECORD_T pprStaRec, OUT PUINT_16 pu2StatusCode)
1346 {
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;
1351
1352 DBGLOG(P2P, TRACE, ("p2pValidate Authentication Frame\n"))
1353
1354 do {
1355 ASSERT_BREAK((prAdapter != NULL) &&
1356 (prSwRfb != NULL) && (pprStaRec != NULL) && (pu2StatusCode != NULL));
1357
1358 /* P2P 3.2.8 */
1359 *pu2StatusCode = STATUS_CODE_REQ_DECLINED;
1360
1361 prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
1362 prAuthFrame = (P_WLAN_AUTH_FRAME_T) prSwRfb->pvHeader;
1363
1364
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;
1369 DBGLOG(P2P, WARN,
1370 ("Current OP mode is not under AP mode. (%d)\n",
1371 prP2pBssInfo->eCurrentOPMode));
1372 break;
1373 }
1374
1375 prStaRec = cnmGetStaRecByAddress(prAdapter,
1376 (UINT_8) NETWORK_TYPE_P2P_INDEX,
1377 prAuthFrame->aucSrcAddr);
1378
1379 if (!prStaRec) {
1380 prStaRec = cnmStaRecAlloc(prAdapter, (UINT_8) NETWORK_TYPE_P2P_INDEX);
1381
1382 /* TODO(Kevin): Error handling of allocation of STA_RECORD_T for
1383 * exhausted case and do removal of unused STA_RECORD_T.
1384 */
1385 /* Sent a message event to clean un-used STA_RECORD_T. */
1386 ASSERT(prStaRec);
1387
1388 COPY_MAC_ADDR(prStaRec->aucMacAddr, prAuthFrame->aucSrcAddr);
1389
1390 prSwRfb->ucStaRecIdx = prStaRec->ucIndex;
1391
1392 prStaRec->u2BSSBasicRateSet = prP2pBssInfo->u2BSSBasicRateSet;
1393
1394 prStaRec->u2DesiredNonHTRateSet = RATE_SET_ERP_P2P;
1395
1396 prStaRec->u2OperationalRateSet = RATE_SET_ERP_P2P;
1397 prStaRec->ucPhyTypeSet = PHY_TYPE_SET_802_11GN;
1398 prStaRec->eStaType = STA_TYPE_P2P_GC;
1399
1400 /* NOTE(Kevin): Better to change state here, not at TX Done */
1401 cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_1);
1402 } else {
1403 prSwRfb->ucStaRecIdx = prStaRec->ucIndex;
1404
1405 if ((prStaRec->ucStaState > STA_STATE_1) && (IS_STA_IN_P2P(prStaRec))) {
1406
1407 cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_1);
1408
1409 p2pFuncResetStaRecStatus(prAdapter, prStaRec);
1410
1411 bssRemoveStaRecFromClientList(prAdapter, prP2pBssInfo, prStaRec);
1412 }
1413
1414 }
1415
1416 if (prP2pBssInfo->rStaRecOfClientList.u4NumElem > P2P_MAXIMUM_CLIENT_COUNT ||
1417 kalP2PMaxClients(prAdapter->prGlueInfo,
1418 prP2pBssInfo->rStaRecOfClientList.u4NumElem)) {
1419 /* GROUP limit full. */
1420 /* P2P 3.2.8 */
1421 DBGLOG(P2P, WARN,
1422 ("Group Limit Full. (%d)\n",
1423 (INT_16) prP2pBssInfo->rStaRecOfClientList.u4NumElem));
1424 bssRemoveStaRecFromClientList(prAdapter, prP2pBssInfo, prStaRec);
1425 cnmStaRecFree(prAdapter, prStaRec, FALSE);
1426 break;
1427 } else {
1428 /* Hotspot Blacklist */
1429 if (prAuthFrame->aucSrcAddr) {
1430 if (kalP2PCmpBlackList
1431 (prAdapter->prGlueInfo, prAuthFrame->aucSrcAddr)) {
1432 fgReplyAuth = FALSE;
1433 return fgReplyAuth;
1434 }
1435 }
1436 }
1437
1438 /* prStaRec->eStaType = STA_TYPE_INFRA_CLIENT; */
1439 prStaRec->eStaType = STA_TYPE_P2P_GC;
1440
1441 prStaRec->ucNetTypeIndex = NETWORK_TYPE_P2P_INDEX;
1442
1443 /* Update Station Record - Status/Reason Code */
1444 prStaRec->u2StatusCode = STATUS_CODE_SUCCESSFUL;
1445
1446 prStaRec->ucJoinFailureCount = 0;
1447
1448 *pprStaRec = prStaRec;
1449
1450 *pu2StatusCode = STATUS_CODE_SUCCESSFUL;
1451
1452 } while (FALSE);
1453
1454
1455 return fgReplyAuth;
1456
1457 } /* p2pFuncValidateAuth */
1458
1459
1460
1461
1462 VOID p2pFuncResetStaRecStatus(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prStaRec)
1463 {
1464 do {
1465 if ((prAdapter == NULL) || (prStaRec == NULL)) {
1466 ASSERT(FALSE);
1467 break;
1468 }
1469
1470
1471 prStaRec->u2StatusCode = STATUS_CODE_SUCCESSFUL;
1472 prStaRec->u2ReasonCode = REASON_CODE_RESERVED;
1473 prStaRec->ucJoinFailureCount = 0;
1474 prStaRec->fgTransmitKeyExist = FALSE;
1475
1476 prStaRec->fgSetPwrMgtBit = FALSE;
1477
1478 } while (FALSE);
1479
1480 return;
1481 } /* p2pFuncResetStaRecStatus */
1482
1483
1484
1485 /*----------------------------------------------------------------------------*/
1486 /*!
1487 * @brief The function is used to initialize the value of the connection settings for
1488 * P2P network
1489 *
1490 * @param (none)
1491 *
1492 * @return (none)
1493 */
1494 /*----------------------------------------------------------------------------*/
1495 VOID
1496 p2pFuncInitConnectionSettings(IN P_ADAPTER_T prAdapter,
1497 IN P_P2P_CONNECTION_SETTINGS_T prP2PConnSettings)
1498 {
1499 P_DEVICE_TYPE_T prDevType;
1500 UINT_8 aucDefaultDevName[] = P2P_DEFAULT_DEV_NAME;
1501 UINT_8 aucWfaOui[] = VENDOR_OUI_WFA;
1502
1503 ASSERT(prP2PConnSettings);
1504
1505 /* Setup Default Device Name */
1506 prP2PConnSettings->ucDevNameLen = P2P_DEFAULT_DEV_NAME_LEN;
1507 kalMemCopy(prP2PConnSettings->aucDevName, aucDefaultDevName, sizeof(aucDefaultDevName));
1508
1509 /* Setup Primary Device Type (Big-Endian) */
1510 prDevType = &prP2PConnSettings->rPrimaryDevTypeBE;
1511
1512 prDevType->u2CategoryId = HTONS(P2P_DEFAULT_PRIMARY_CATEGORY_ID);
1513 prDevType->u2SubCategoryId = HTONS(P2P_DEFAULT_PRIMARY_SUB_CATEGORY_ID);
1514
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;
1519
1520 /* Setup Secondary Device Type */
1521 prP2PConnSettings->ucSecondaryDevTypeCount = 0;
1522
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;
1529
1530 /* For Device Capability */
1531 prP2PConnSettings->fgSupportServiceDiscovery = FALSE;
1532 prP2PConnSettings->fgSupportClientDiscoverability = TRUE;
1533 prP2PConnSettings->fgSupportConcurrentOperation = TRUE;
1534 prP2PConnSettings->fgSupportInfraManaged = FALSE;
1535 prP2PConnSettings->fgSupportInvitationProcedure = FALSE;
1536
1537 /* For Group Capability */
1538 #if CFG_SUPPORT_PERSISTENT_GROUP
1539 prP2PConnSettings->fgSupportPersistentP2PGroup = TRUE;
1540 #else
1541 prP2PConnSettings->fgSupportPersistentP2PGroup = FALSE;
1542 #endif
1543 prP2PConnSettings->fgSupportIntraBSSDistribution = TRUE;
1544 prP2PConnSettings->fgSupportCrossConnection = TRUE;
1545 prP2PConnSettings->fgSupportPersistentReconnect = FALSE;
1546
1547 prP2PConnSettings->fgSupportOppPS = FALSE;
1548 prP2PConnSettings->u2CTWindow = P2P_CTWINDOW_DEFAULT;
1549
1550 /* For Connection Settings. */
1551 prP2PConnSettings->eAuthMode = AUTH_MODE_OPEN;
1552
1553 prP2PConnSettings->prTargetP2pDesc = NULL;
1554 prP2PConnSettings->ucSSIDLen = 0;
1555
1556 /* Misc */
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);
1563
1564 prP2PConnSettings->eFormationPolicy = ENUM_P2P_FORMATION_POLICY_AUTO;
1565
1566 return;
1567 } /* p2pFuncInitConnectionSettings */
1568
1569
1570
1571
1572
1573 /*----------------------------------------------------------------------------*/
1574 /*!
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.
1578 *
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
1582 *
1583 * @retval TRUE Reply the Assoc Resp
1584 * @retval FALSE Don't reply the Assoc Resp
1585 */
1586 /*----------------------------------------------------------------------------*/
1587 BOOLEAN
1588 p2pFuncValidateAssocReq(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb, OUT PUINT_16 pu2StatusCode)
1589 {
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;
1594 #if CFG_SUPPORT_WFD
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;
1598 #endif
1599
1600
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.
1606 */
1607
1608 do {
1609 ASSERT_BREAK((prAdapter != NULL) && (prSwRfb != NULL) && (pu2StatusCode != NULL));
1610
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;
1614
1615 prStaRec = cnmGetStaRecByIndex(prAdapter, prSwRfb->ucStaRecIdx);
1616
1617 if (prStaRec == NULL) {
1618 /* Station record should be ready while RX AUTH frame. */
1619 fgReplyAssocResp = FALSE;
1620 ASSERT(FALSE);
1621 break;
1622 } else {
1623 prStaRec->ucRCPI = prSwRfb->prHifRxHdr->ucRcpi;
1624 }
1625
1626 prStaRec->u2DesiredNonHTRateSet &= prP2pBssInfo->u2OperationalRateSet;
1627 prStaRec->ucDesiredPhyTypeSet = prStaRec->ucPhyTypeSet & prP2pBssInfo->ucPhyTypeSet;
1628
1629 if (prStaRec->ucDesiredPhyTypeSet == 0) {
1630 /* The station only support 11B rate. */
1631 *pu2StatusCode = STATUS_CODE_ASSOC_DENIED_RATE_NOT_SUPPORTED;
1632 break;
1633 }
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;
1638 ASSERT(FALSE);
1639 break;
1640 }
1641
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)) {
1646 /* Rejected all. */
1647 break;
1648 } else {
1649
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;
1654
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); */
1661
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,
1668 aucInfoElem)),
1669 WFD_ATTRI_ID_DEV_INFO);
1670
1671 if ((prWfdCfgSettings->u4WfdPolicy & BIT(5))
1672 && (prAttriWfdDevInfo != NULL)) {
1673 /* Rejected with WFD IE. */
1674 break;
1675 }
1676
1677 if ((prWfdCfgSettings->u4WfdPolicy & BIT(0))
1678 && (prAttriWfdDevInfo == NULL)) {
1679 /* Rejected without WFD IE. */
1680 break;
1681 }
1682
1683 if (prAttriWfdDevInfo != NULL) {
1684
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. */ */
1692 /* break; */
1693 /* } */
1694
1695 WLAN_GET_FIELD_BE16(&prAttriWfdDevInfo->u2WfdDevInfo,
1696 &u2WfdDevInfo);
1697 DBGLOG(P2P, INFO,
1698 ("RX Assoc Req WFD Info:0x%x.\n", u2WfdDevInfo));
1699
1700 if ((prWfdCfgSettings->u4WfdPolicy & BIT(1))
1701 && ((u2WfdDevInfo & 0x3) == 0x0)) {
1702 /* Rejected because of SOURCE. */
1703 break;
1704 }
1705
1706 if ((prWfdCfgSettings->u4WfdPolicy & BIT(2))
1707 && ((u2WfdDevInfo & 0x3) == 0x1)) {
1708 /* Rejected because of Primary Sink. */
1709 break;
1710 }
1711
1712 if ((prWfdCfgSettings->u4WfdPolicy & BIT(3))
1713 && ((u2WfdDevInfo & 0x3) == 0x2)) {
1714 /* Rejected because of Secondary Sink. */
1715 break;
1716 }
1717
1718 if ((prWfdCfgSettings->u4WfdPolicy & BIT(4))
1719 && ((u2WfdDevInfo & 0x3) == 0x3)) {
1720 /* Rejected because of Source & Primary Sink. */
1721 break;
1722 }
1723
1724 /* Check role */
1725
1726 if (prWfdCfgSettings->u4WfdFlag & WFD_FLAGS_DEV_INFO_VALID) {
1727
1728 if ((prWfdCfgSettings->u2WfdDevInfo & BITS(0, 1)) ==
1729 0x3) {
1730 /* P_MSG_WFD_CONFIG_SETTINGS_CHANGED_T prMsgWfdCfgUpdate = (P_MSG_WFD_CONFIG_SETTINGS_CHANGED_T)NULL; */
1731 UINT_16 u2DevInfo =
1732 prWfdCfgSettings->u2WfdDevInfo;
1733
1734 /* We may change role here if we are dual role */
1735
1736 if ((u2WfdDevInfo & BITS(0, 1)) ==
1737 0x00 /* Peer is Source */) {
1738 DBGLOG(P2P, INFO,
1739 ("WFD: Switch role to primary sink\n"));
1740
1741 prWfdCfgSettings->u2WfdDevInfo &=
1742 ~BITS(0, 1);
1743 prWfdCfgSettings->u2WfdDevInfo |=
1744 0x1;
1745
1746 /* event to annonce the role is chanaged to P-Sink */
1747
1748 } else if ((u2WfdDevInfo & BITS(0, 1)) ==
1749 0x01 /* Peer is P-Sink */) {
1750
1751 DBGLOG(P2P, INFO,
1752 ("WFD: Switch role to source\n"));
1753 prWfdCfgSettings->u2WfdDevInfo &=
1754 ~BITS(0, 1);
1755 /* event to annonce the role is chanaged to Source */
1756 } else {
1757
1758 DBGLOG(P2P, INFO,
1759 ("WFD: Peer role is wrong type(dev 0x%x)\n",
1760 (u2DevInfo)));
1761 DBGLOG(P2P, INFO,
1762 ("WFD: Switch role to source\n"));
1763 prWfdCfgSettings->u2WfdDevInfo &=
1764 ~BITS(0, 1);
1765 /* event to annonce the role is chanaged to Source */
1766 }
1767
1768 p2pFsmRunEventWfdSettingUpdate(prAdapter,
1769 NULL);
1770
1771 } /* Dual role p2p->wfd_params->WfdDevInfo */
1772 }
1773
1774 /* WFD_FLAG_DEV_INFO_VALID */
1775 } else {
1776 /* Without WFD IE.
1777 * Do nothing. Accept the connection request.
1778 */
1779 }
1780 }
1781
1782 }
1783 /* ucWfdEnable */
1784 #endif
1785
1786 *pu2StatusCode = STATUS_CODE_SUCCESSFUL;
1787
1788 } while (FALSE);
1789
1790 #if CFG_SUPPORT_WFD
1791 if ((prWfdAttribute) && (fgNeedFree)) {
1792 kalMemFree(prWfdAttribute, VIR_MEM_TYPE, WPS_MAXIMUM_ATTRIBUTES_CACHE_SIZE);
1793 }
1794 #endif
1795
1796 return fgReplyAssocResp;
1797
1798 } /* p2pFuncValidateAssocReq */
1799
1800
1801
1802
1803 /*----------------------------------------------------------------------------*/
1804 /*!
1805 * @brief This function is used to check the P2P IE
1806 *
1807 *
1808 * @return none
1809 */
1810 /*----------------------------------------------------------------------------*/
1811 BOOLEAN
1812 p2pFuncParseCheckForP2PInfoElem(IN P_ADAPTER_T prAdapter, IN PUINT_8 pucBuf, OUT PUINT_8 pucOuiType)
1813 {
1814 UINT_8 aucWfaOui[] = VENDOR_OUI_WFA_SPECIFIC;
1815 P_IE_WFA_T prWfaIE = (P_IE_WFA_T) NULL;
1816
1817 do {
1818 ASSERT_BREAK((prAdapter != NULL) && (pucBuf != NULL) && (pucOuiType != NULL));
1819
1820 prWfaIE = (P_IE_WFA_T) pucBuf;
1821
1822 if (IE_LEN(pucBuf) <= ELEM_MIN_LEN_WFA_OUI_TYPE_SUBTYPE) {
1823 break;
1824 } else if (prWfaIE->aucOui[0] != aucWfaOui[0] ||
1825 prWfaIE->aucOui[1] != aucWfaOui[1] ||
1826 prWfaIE->aucOui[2] != aucWfaOui[2]) {
1827 break;
1828 }
1829
1830 *pucOuiType = prWfaIE->ucOuiType;
1831
1832 return TRUE;
1833 } while (FALSE);
1834
1835 return FALSE;
1836 } /* p2pFuncParseCheckForP2PInfoElem */
1837
1838
1839
1840
1841 /*----------------------------------------------------------------------------*/
1842 /*!
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.
1846 *
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
1850 *
1851 * @retval TRUE Reply the Probe Response
1852 * @retval FALSE Don't reply the Probe Response
1853 */
1854 /*----------------------------------------------------------------------------*/
1855 BOOLEAN
1856 p2pFuncValidateProbeReq(IN P_ADAPTER_T prAdapter,
1857 IN P_SW_RFB_T prSwRfb, OUT PUINT_32 pu4ControlFlags)
1858 {
1859 BOOLEAN fgIsReplyProbeRsp = FALSE;
1860 P_P2P_FSM_INFO_T prP2pFsmInfo = (P_P2P_FSM_INFO_T) NULL;
1861
1862 DEBUGFUNC("p2pFuncValidateProbeReq");
1863 DBGLOG(P2P, TRACE, ("p2pFuncValidateProbeReq\n"));
1864
1865 do {
1866
1867 ASSERT_BREAK((prAdapter != NULL) && (prSwRfb != NULL));
1868
1869 prP2pFsmInfo = prAdapter->rWifiVar.prP2pFsmInfo;
1870
1871 if (prP2pFsmInfo->u4P2pPacketFilter & PARAM_PACKET_FILTER_PROBE_REQ) {
1872
1873 printk("p2pFuncValidateProbeReq\n");
1874
1875 /* Leave the probe response to p2p_supplicant. */
1876 kalP2PIndicateRxMgmtFrame(prAdapter->prGlueInfo, prSwRfb);
1877 }
1878
1879 } while (FALSE);
1880
1881 return fgIsReplyProbeRsp;
1882
1883 } /* end of p2pFuncValidateProbeReq() */
1884
1885
1886
1887 /*----------------------------------------------------------------------------*/
1888 /*!
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.
1892 *
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
1896 *
1897 * @retval TRUE Reply the Probe Response
1898 * @retval FALSE Don't reply the Probe Response
1899 */
1900 /*----------------------------------------------------------------------------*/
1901 VOID p2pFuncValidateRxActionFrame(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb)
1902 {
1903 P_P2P_FSM_INFO_T prP2pFsmInfo = (P_P2P_FSM_INFO_T) NULL;
1904
1905 DEBUGFUNC("p2pFuncValidateProbeReq");
1906
1907 do {
1908
1909 ASSERT_BREAK((prAdapter != NULL) && (prSwRfb != NULL));
1910
1911 prP2pFsmInfo = prAdapter->rWifiVar.prP2pFsmInfo;
1912
1913 if (prP2pFsmInfo->u4P2pPacketFilter & PARAM_PACKET_FILTER_ACTION_FRAME) {
1914 /* Leave the probe response to p2p_supplicant. */
1915 kalP2PIndicateRxMgmtFrame(prAdapter->prGlueInfo, prSwRfb);
1916 }
1917
1918 } while (FALSE);
1919
1920 return;
1921
1922 } /* p2pFuncValidateRxMgmtFrame */
1923
1924
1925
1926 BOOLEAN p2pFuncIsAPMode(IN P_P2P_FSM_INFO_T prP2pFsmInfo)
1927 {
1928 if (prP2pFsmInfo) {
1929 if (prP2pFsmInfo->fgIsWPSMode == 1) {
1930 return FALSE;
1931 }
1932 return prP2pFsmInfo->fgIsApMode;
1933 } else {
1934 return FALSE;
1935 }
1936 }
1937
1938 /* p2pFuncIsAPMode */
1939
1940
1941
1942 VOID
1943 p2pFuncParseBeaconContent(IN P_ADAPTER_T prAdapter,
1944 IN P_BSS_INFO_T prP2pBssInfo, IN PUINT_8 pucIEInfo, IN UINT_32 u4IELen)
1945 {
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;
1951
1952 do {
1953 ASSERT_BREAK((prAdapter != NULL) && (prP2pBssInfo != NULL));
1954
1955 if (u4IELen == 0) {
1956 break;
1957 }
1958
1959 prP2pSpecificBssInfo = prAdapter->rWifiVar.prP2pSpecificBssInfo;
1960 prP2pSpecificBssInfo->u2AttributeLen = 0;
1961
1962 ASSERT_BREAK(pucIEInfo != NULL);
1963
1964 pucIE = pucIEInfo;
1965
1966 ucOldSecMode = kalP2PGetCipher(prAdapter->prGlueInfo);
1967
1968 IE_FOR_EACH(pucIE, u4IELen, u2Offset) {
1969 switch (IE_ID(pucIE)) {
1970 case ELEM_ID_SSID: /* 0 *//* V *//* Done */
1971 {
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 */
1976 /*
1977 COPY_SSID(prP2pBssInfo->aucSSID,
1978 prP2pBssInfo->ucSSIDLen,
1979 SSID_IE(pucIE)->aucSSID,
1980 SSID_IE(pucIE)->ucLength);
1981
1982 COPY_SSID(prP2pSpecificBssInfo->aucGroupSsid,
1983 prP2pSpecificBssInfo->u2GroupSsidLen,
1984 SSID_IE(pucIE)->aucSSID,
1985 SSID_IE(pucIE)->ucLength);
1986 */
1987 }
1988 break;
1989 case ELEM_ID_SUP_RATES: /* 1 *//* V *//* Done */
1990 {
1991 DBGLOG(P2P, TRACE, ("Support Rate IE\n"));
1992 kalMemCopy(prP2pBssInfo->aucAllSupportedRates,
1993 SUP_RATES_IE(pucIE)->aucSupportedRates,
1994 SUP_RATES_IE(pucIE)->ucLength);
1995
1996 prP2pBssInfo->ucAllSupportedRatesLen =
1997 SUP_RATES_IE(pucIE)->ucLength;
1998
1999 DBGLOG_MEM8(P2P, TRACE,
2000 SUP_RATES_IE(pucIE)->aucSupportedRates,
2001 SUP_RATES_IE(pucIE)->ucLength);
2002 }
2003 break;
2004 case ELEM_ID_DS_PARAM_SET: /* 3 *//* V *//* Done */
2005 {
2006 P_P2P_CONNECTION_SETTINGS_T prP2pConnSettings =
2007 prAdapter->rWifiVar.prP2PConnSettings;
2008
2009 DBGLOG(P2P, TRACE, ("DS PARAM IE\n"));
2010
2011 ASSERT(prP2pConnSettings->ucOperatingChnl ==
2012 DS_PARAM_IE(pucIE)->ucCurrChnl);
2013
2014 if (prP2pConnSettings->eBand != BAND_2G4) {
2015 ASSERT(FALSE);
2016 break;
2017 }
2018 /* prP2pBssInfo->ucPrimaryChannel = DS_PARAM_IE(pucIE)->ucCurrChnl; */
2019
2020 /* prP2pBssInfo->eBand = BAND_2G4; */
2021 }
2022 break;
2023 case ELEM_ID_TIM: /* 5 *//* V */
2024 DBGLOG(P2P, TRACE, ("TIM IE\n"));
2025 TIM_IE(pucIE)->ucDTIMPeriod = prP2pBssInfo->ucDTIMPeriod;
2026 break;
2027 case ELEM_ID_ERP_INFO: /* 42 *//* V */
2028 {
2029 #if 1
2030 /* This IE would dynamic change due to FW detection change is required. */
2031 DBGLOG(P2P, TRACE,
2032 ("ERP IE will be over write by driver\n"));
2033 DBGLOG(P2P, TRACE,
2034 (" ucERP: %x.\n", ERP_INFO_IE(pucIE)->ucERP));
2035
2036 #else
2037 /* This IE would dynamic change due to FW detection change is required. */
2038 DBGLOG(P2P, TRACE, ("ERP IE.\n"));
2039
2040 prP2pBssInfo->ucPhyTypeSet |= PHY_TYPE_SET_802_11GN;
2041
2042 ASSERT(prP2pBssInfo->eBand == BAND_2G4);
2043
2044 prP2pBssInfo->fgObssErpProtectMode =
2045 ((ERP_INFO_IE(pucIE)->
2046 ucERP & ERP_INFO_USE_PROTECTION) ? TRUE : FALSE);
2047
2048 prP2pBssInfo->fgErpProtectMode =
2049 ((ERP_INFO_IE(pucIE)->
2050 ucERP & (ERP_INFO_USE_PROTECTION |
2051 ERP_INFO_NON_ERP_PRESENT)) ? TRUE : FALSE);
2052 #endif
2053
2054 }
2055 break;
2056 case ELEM_ID_HT_CAP: /* 45 *//* V */
2057 {
2058 #if 1
2059 DBGLOG(P2P, TRACE,
2060 ("HT CAP IE would be overwritten by driver\n"));
2061
2062 DBGLOG(P2P, TRACE,
2063 ("HT Cap Info:%x, AMPDU Param:%x\n",
2064 HT_CAP_IE(pucIE)->u2HtCapInfo,
2065 HT_CAP_IE(pucIE)->ucAmpduParam));
2066
2067 DBGLOG(P2P, TRACE,
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));
2072 #else
2073 prP2pBssInfo->ucPhyTypeSet |= PHY_TYPE_SET_802_11N;
2074
2075 /* u2HtCapInfo */
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;
2080 } else {
2081 prP2pBssInfo->fgAssoc40mBwAllowed = TRUE;
2082 }
2083
2084 if ((HT_CAP_IE(pucIE)->u2HtCapInfo &
2085 (HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_SHORT_GI_40M))
2086 == 0) {
2087 prAdapter->rWifiVar.rConnSettings.
2088 fgRxShortGIDisabled = TRUE;
2089 } else {
2090 prAdapter->rWifiVar.rConnSettings.
2091 fgRxShortGIDisabled = FALSE;
2092 }
2093
2094 /* ucAmpduParam */
2095 DBGLOG(P2P, TRACE,
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));
2099
2100 /* rSupMcsSet */
2101 /* Can do nothing. the field is default value from other configuration. */
2102 /* HT_CAP_IE(pucIE)->rSupMcsSet; */
2103
2104 /* u2HtExtendedCap */
2105 ASSERT(HT_CAP_IE(pucIE)->u2HtExtendedCap ==
2106 (HT_EXT_CAP_DEFAULT_VAL &
2107 ~(HT_EXT_CAP_PCO |
2108 HT_EXT_CAP_PCO_TRANS_TIME_NONE)));
2109
2110 /* u4TxBeamformingCap */
2111 ASSERT(HT_CAP_IE(pucIE)->u4TxBeamformingCap ==
2112 TX_BEAMFORMING_CAP_DEFAULT_VAL);
2113
2114 /* ucAselCap */
2115 ASSERT(HT_CAP_IE(pucIE)->ucAselCap == ASEL_CAP_DEFAULT_VAL);
2116 #endif
2117 }
2118 break;
2119 case ELEM_ID_RSN: /* 48 *//* V */
2120 {
2121 RSN_INFO_T rRsnIe;
2122
2123 DBGLOG(P2P, TRACE, ("RSN IE\n"));
2124 kalP2PSetCipher(prAdapter->prGlueInfo, IW_AUTH_CIPHER_CCMP);
2125 ucNewSecMode = TRUE;
2126
2127 if (rsnParseRsnIE(prAdapter, RSN_IE(pucIE), &rRsnIe)) {
2128 prP2pBssInfo =
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 =
2136 RSN_AKM_SUITE_PSK;
2137 prP2pBssInfo->u2RsnSelectedCapInfo =
2138 rRsnIe.u2RsnCap;
2139 }
2140 }
2141 break;
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"));
2145 kalMemCopy(&
2146 (prP2pBssInfo->
2147 aucAllSupportedRates[prP2pBssInfo->
2148 ucAllSupportedRatesLen]),
2149 EXT_SUP_RATES_IE(pucIE)->aucExtSupportedRates,
2150 EXT_SUP_RATES_IE(pucIE)->ucLength);
2151
2152 DBGLOG_MEM8(P2P, TRACE,
2153 EXT_SUP_RATES_IE(pucIE)->aucExtSupportedRates,
2154 EXT_SUP_RATES_IE(pucIE)->ucLength);
2155
2156 prP2pBssInfo->ucAllSupportedRatesLen +=
2157 EXT_SUP_RATES_IE(pucIE)->ucLength;
2158 break;
2159 case ELEM_ID_HT_OP: /* 61 */* * V */// TODO: */
2160 {
2161 #if 1
2162 DBGLOG(P2P, TRACE,
2163 ("HT OP IE would be overwritten by driver\n"));
2164
2165 DBGLOG(P2P, TRACE,
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));
2170 #else
2171 UINT_16 u2Info2 = 0;
2172 prP2pBssInfo->ucPhyTypeSet |= PHY_TYPE_SET_802_11N;
2173
2174 DBGLOG(P2P, TRACE, ("HT OP IE\n"));
2175
2176 /* ucPrimaryChannel. */
2177 ASSERT(HT_OP_IE(pucIE)->ucPrimaryChannel ==
2178 prP2pBssInfo->ucPrimaryChannel);
2179
2180 /* ucInfo1 */
2181 prP2pBssInfo->ucHtOpInfo1 = HT_OP_IE(pucIE)->ucInfo1;
2182
2183 /* u2Info2 */
2184 u2Info2 = HT_OP_IE(pucIE)->u2Info2;
2185
2186 if (u2Info2 & HT_OP_INFO2_NON_GF_HT_STA_PRESENT) {
2187 ASSERT(prP2pBssInfo->eGfOperationMode !=
2188 GF_MODE_NORMAL);
2189 u2Info2 &= ~HT_OP_INFO2_NON_GF_HT_STA_PRESENT;
2190 }
2191
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;
2196 }
2197
2198 switch (u2Info2 & HT_OP_INFO2_HT_PROTECTION) {
2199 case HT_PROTECT_MODE_NON_HT:
2200 prP2pBssInfo->eHtProtectMode =
2201 HT_PROTECT_MODE_NON_HT;
2202 break;
2203 case HT_PROTECT_MODE_NON_MEMBER:
2204 prP2pBssInfo->eHtProtectMode = HT_PROTECT_MODE_NONE;
2205 prP2pBssInfo->eObssHtProtectMode =
2206 HT_PROTECT_MODE_NON_MEMBER;
2207 break;
2208 default:
2209 prP2pBssInfo->eHtProtectMode =
2210 HT_OP_IE(pucIE)->u2Info2;
2211 break;
2212 }
2213
2214 /* u2Info3 */
2215 prP2pBssInfo->u2HtOpInfo3 = HT_OP_IE(pucIE)->u2Info3;
2216
2217 /* aucBasicMcsSet */
2218 DBGLOG_MEM8(P2P, TRACE, HT_OP_IE(pucIE)->aucBasicMcsSet,
2219 16);
2220 #endif
2221 }
2222 break;
2223 case ELEM_ID_OBSS_SCAN_PARAMS: /* 74 *//* V */
2224 {
2225 DBGLOG(P2P, TRACE,
2226 ("ELEM_ID_OBSS_SCAN_PARAMS IE would be replaced by driver\n"));
2227 }
2228 break;
2229 case ELEM_ID_EXTENDED_CAP: /* 127 *//* V */
2230 {
2231 DBGLOG(P2P, TRACE,
2232 ("ELEM_ID_EXTENDED_CAP IE would be replaced by driver\n"));
2233 }
2234 break;
2235 case ELEM_ID_VENDOR: /* 221 *//* V */
2236 DBGLOG(P2P, TRACE, ("Vender Specific IE\n"));
2237 {
2238 UINT_8 ucOuiType;
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,
2249 IE_SIZE(pucIE));
2250 prP2pSpecificBssInfo->u2WpaIeLen =
2251 IE_SIZE(pucIE);
2252 } else if ((ucOuiType == VENDOR_OUI_TYPE_WPS)) {
2253 kalP2PUpdateWSC_IE(prAdapter->prGlueInfo, 0,
2254 pucIE, IE_SIZE(pucIE));
2255 }
2256 /* WMM here. */
2257 } else
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->
2264 aucAttributesCache
2265 [prP2pSpecificBssInfo->
2266 u2AttributeLen], pucIE,
2267 IE_SIZE(pucIE));
2268
2269 prP2pSpecificBssInfo->u2AttributeLen +=
2270 IE_SIZE(pucIE);
2271 } else if (ucOuiType == VENDOR_OUI_TYPE_WFD) {
2272
2273 kalMemCopy(&prP2pSpecificBssInfo->
2274 aucAttributesCache
2275 [prP2pSpecificBssInfo->
2276 u2AttributeLen], pucIE,
2277 IE_SIZE(pucIE));
2278
2279 prP2pSpecificBssInfo->u2AttributeLen +=
2280 IE_SIZE(pucIE);
2281 }
2282 } else {
2283
2284 kalMemCopy(&prP2pSpecificBssInfo->
2285 aucAttributesCache[prP2pSpecificBssInfo->
2286 u2AttributeLen],
2287 pucIE, IE_SIZE(pucIE));
2288
2289 prP2pSpecificBssInfo->u2AttributeLen +=
2290 IE_SIZE(pucIE);
2291 DBGLOG(P2P, TRACE,
2292 ("Driver unprocessed Vender Specific IE\n"));
2293 ASSERT(FALSE);
2294 }
2295
2296 /* TODO: Store other Vender IE except for WMM Param. */
2297 }
2298 break;
2299 default:
2300 DBGLOG(P2P, TRACE, ("Unprocessed element ID:%d\n", IE_ID(pucIE)));
2301 break;
2302 }
2303 }
2304
2305 if (!ucNewSecMode && ucOldSecMode)
2306 kalP2PSetCipher(prAdapter->prGlueInfo, IW_AUTH_CIPHER_NONE);
2307
2308 } while (FALSE);
2309
2310 return;
2311 } /* p2pFuncParseBeaconContent */
2312
2313
2314
2315
2316 P_BSS_DESC_T
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)
2321 {
2322 P_BSS_DESC_T prTargetBss = (P_BSS_DESC_T) NULL;
2323 P_BSS_INFO_T prP2pBssInfo = (P_BSS_INFO_T) NULL;
2324
2325 do {
2326 ASSERT_BREAK((prAdapter != NULL) &&
2327 (prConnReqInfo != NULL) &&
2328 (prChnlReqInfo != NULL) && (prScanReqInfo != NULL));
2329
2330 prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
2331
2332 if (prP2pBssInfo->eCurrentOPMode != OP_MODE_INFRASTRUCTURE) {
2333 break;
2334 }
2335 /* Update connection request information. */
2336 ASSERT(prConnReqInfo->fgIsConnRequest == TRUE);
2337
2338 /* Find BSS Descriptor first. */
2339 prTargetBss = scanP2pSearchDesc(prAdapter, prP2pBssInfo, prConnReqInfo);
2340
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;
2348 } else {
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;
2355 }
2356
2357 } while (FALSE);
2358
2359 return prTargetBss;
2360 } /* p2pFuncKeepOnConnection */
2361
2362 /* Currently Only for ASSOC Response Frame. */
2363 VOID p2pFuncStoreAssocRspIEBuffer(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb)
2364 {
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;
2368 INT_16 i2IELen = 0;
2369
2370 do {
2371 ASSERT_BREAK((prAdapter != NULL) && (prSwRfb != NULL));
2372
2373 prAssocRspFrame = (P_WLAN_ASSOC_RSP_FRAME_T) prSwRfb->pvHeader;
2374
2375 if (prAssocRspFrame->u2FrameCtrl != MAC_FRAME_ASSOC_RSP) {
2376 break;
2377 }
2378
2379 i2IELen = prSwRfb->u2PacketLen - (WLAN_MAC_HEADER_LEN +
2380 CAP_INFO_FIELD_LEN +
2381 STATUS_CODE_FIELD_LEN + AID_FIELD_LEN);
2382
2383
2384 if (i2IELen <= 0) {
2385 break;
2386 }
2387
2388 prP2pFsmInfo = prAdapter->rWifiVar.prP2pFsmInfo;
2389 prJoinInfo = &(prP2pFsmInfo->rJoinInfo);
2390 prJoinInfo->u4BufLength = (UINT_32) i2IELen;
2391
2392 kalMemCopy(prJoinInfo->aucIEBuf, prAssocRspFrame->aucInfoElem,
2393 prJoinInfo->u4BufLength);
2394
2395 } while (FALSE);
2396
2397
2398 return;
2399 } /* p2pFuncStoreAssocRspIEBuffer */
2400
2401
2402
2403
2404 /*----------------------------------------------------------------------------*/
2405 /*!
2406 * \brief This routine is called to set Packet Filter.
2407 *
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.
2415 *
2416 * \retval WLAN_STATUS_SUCCESS
2417 * \retval WLAN_STATUS_INVALID_LENGTH
2418 * \retval WLAN_STATUS_NOT_SUPPORTED
2419 * \retval WLAN_STATUS_ADAPTER_NOT_READY
2420 */
2421 /*----------------------------------------------------------------------------*/
2422 VOID
2423 p2pFuncMgmtFrameRegister(IN P_ADAPTER_T prAdapter,
2424 IN UINT_16 u2FrameType,
2425 IN BOOLEAN fgIsRegistered, OUT PUINT_32 pu4P2pPacketFilter)
2426 {
2427 UINT_32 u4NewPacketFilter = 0;
2428
2429 DEBUGFUNC("p2pFuncMgmtFrameRegister");
2430
2431 do {
2432 ASSERT_BREAK(prAdapter != NULL);
2433
2434 if (pu4P2pPacketFilter) {
2435 u4NewPacketFilter = *pu4P2pPacketFilter;
2436 }
2437
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"));
2443 } else {
2444 u4NewPacketFilter &= ~PARAM_PACKET_FILTER_PROBE_REQ;
2445 DBGLOG(P2P, TRACE, ("Close packet filer probe request\n"));
2446 }
2447 break;
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"));
2452 } else {
2453 u4NewPacketFilter &= ~PARAM_PACKET_FILTER_ACTION_FRAME;
2454 DBGLOG(P2P, TRACE, ("Close packet filer action frame.\n"));
2455 }
2456 break;
2457 default:
2458 DBGLOG(P2P, TRACE, ("Ask frog to add code for mgmt:%x\n", u2FrameType));
2459 break;
2460 }
2461
2462 if (pu4P2pPacketFilter) {
2463 *pu4P2pPacketFilter = u4NewPacketFilter;
2464 }
2465 /* u4NewPacketFilter |= prAdapter->u4OsPacketFilter; */
2466
2467 prAdapter->u4OsPacketFilter &= ~PARAM_PACKET_FILTER_P2P_MASK;
2468 prAdapter->u4OsPacketFilter |= u4NewPacketFilter;
2469
2470 DBGLOG(P2P, TRACE, ("P2P Set PACKET filter:0x%lx\n", prAdapter->u4OsPacketFilter));
2471
2472 wlanSendSetQueryCmd(prAdapter,
2473 CMD_ID_SET_RX_FILTER,
2474 TRUE,
2475 FALSE,
2476 FALSE,
2477 nicCmdEventSetCommon,
2478 nicOidCmdTimeoutCommon,
2479 sizeof(UINT_32),
2480 (PUINT_8) &prAdapter->u4OsPacketFilter,
2481 &u4NewPacketFilter, sizeof(u4NewPacketFilter)
2482 );
2483
2484 } while (FALSE);
2485
2486 return;
2487 } /* p2pFuncMgmtFrameRegister */
2488
2489
2490 VOID p2pFuncUpdateMgmtFrameRegister(IN P_ADAPTER_T prAdapter, IN UINT_32 u4OsFilter)
2491 {
2492
2493 do {
2494
2495 prAdapter->rWifiVar.prP2pFsmInfo->u4P2pPacketFilter = u4OsFilter;
2496
2497 if ((prAdapter->u4OsPacketFilter & PARAM_PACKET_FILTER_P2P_MASK) ^ u4OsFilter) {
2498
2499 prAdapter->u4OsPacketFilter &= ~PARAM_PACKET_FILTER_P2P_MASK;
2500
2501 prAdapter->u4OsPacketFilter |= (u4OsFilter & PARAM_PACKET_FILTER_P2P_MASK);
2502
2503 wlanSendSetQueryCmd(prAdapter,
2504 CMD_ID_SET_RX_FILTER,
2505 TRUE,
2506 FALSE,
2507 FALSE,
2508 nicCmdEventSetCommon,
2509 nicOidCmdTimeoutCommon,
2510 sizeof(UINT_32),
2511 (PUINT_8) &prAdapter->u4OsPacketFilter,
2512 &u4OsFilter, sizeof(u4OsFilter)
2513 );
2514 DBGLOG(P2P, TRACE,
2515 ("P2P Set PACKET filter:0x%lx\n", prAdapter->u4OsPacketFilter));
2516 }
2517
2518 } while (FALSE);
2519
2520
2521
2522
2523 return;
2524 } /* p2pFuncUpdateMgmtFrameRegister */
2525
2526
2527 VOID
2528 p2pFuncGetStationInfo(IN P_ADAPTER_T prAdapter,
2529 IN PUINT_8 pucMacAddr, OUT P_P2P_STATION_INFO_T prStaInfo)
2530 {
2531
2532 do {
2533 ASSERT_BREAK((prAdapter != NULL) && (pucMacAddr != NULL) && (prStaInfo != NULL));
2534
2535 prStaInfo->u4InactiveTime = 0;
2536 prStaInfo->u4RxBytes = 0;
2537 prStaInfo->u4TxBytes = 0;
2538 prStaInfo->u4RxPackets = 0;
2539 prStaInfo->u4TxPackets = 0;
2540 /* TODO: */
2541
2542 } while (FALSE);
2543
2544 return;
2545 } /* p2pFuncGetStationInfo */
2546
2547
2548 BOOLEAN
2549 p2pFuncGetAttriList(IN P_ADAPTER_T prAdapter,
2550 IN UINT_8 ucOuiType,
2551 IN PUINT_8 pucIE,
2552 IN UINT_16 u2IELength, OUT PPUINT_8 ppucAttriList, OUT PUINT_16 pu2AttriListLen)
2553 {
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;
2561
2562 do {
2563 ASSERT_BREAK((prAdapter != NULL) &&
2564 (pucIE != NULL) &&
2565 (u2IELength != 0) &&
2566 (ppucAttriList != NULL) && (pu2AttriListLen != NULL));
2567
2568 if (ppucAttriList) {
2569 *ppucAttriList = NULL;
2570 }
2571 if (pu2AttriListLen) {
2572 *pu2AttriListLen = 0;
2573 }
2574
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)
2580 #if CFG_SUPPORT_WFD
2581 && (ucOuiType != VENDOR_OUI_TYPE_WFD)
2582 #endif
2583 ) {
2584 DBGLOG(P2P, INFO, ("Not supported OUI Type to parsing 0x%x\n", ucOuiType));
2585 break;
2586 }
2587
2588
2589 IE_FOR_EACH(pucIE, u2IELength, u2Offset) {
2590 if (ELEM_ID_VENDOR == IE_ID(pucIE)) {
2591 prIe = (P_IE_P2P_T) pucIE;
2592
2593 if (prIe->ucLength <= P2P_OUI_TYPE_LEN) {
2594 continue;
2595
2596 }
2597
2598 if ((prIe->aucOui[0] == aucWfaOui[0]) &&
2599 (prIe->aucOui[1] == aucWfaOui[1]) &&
2600 (prIe->aucOui[2] == aucWfaOui[2]) &&
2601 (ucOuiType == prIe->ucOuiType)) {
2602
2603 if (!pucAttriListStart) {
2604 pucAttriListStart = &prIe->aucP2PAttributes[0];
2605 if (prIe->ucLength > P2P_OUI_TYPE_LEN) {
2606 u2AttriListLen =
2607 (UINT_16) (prIe->ucLength -
2608 P2P_OUI_TYPE_LEN);
2609 } else {
2610 ASSERT(FALSE);
2611 }
2612 } else {
2613 /* More than 2 attributes. */
2614 UINT_16 u2CopyLen;
2615
2616 if (FALSE == fgBackupAttributes) {
2617 P_P2P_SPECIFIC_BSS_INFO_T
2618 prP2pSpecificBssInfo =
2619 prAdapter->rWifiVar.
2620 prP2pSpecificBssInfo;
2621
2622 fgBackupAttributes = TRUE;
2623 if (ucOuiType == VENDOR_OUI_TYPE_P2P) {
2624 kalMemCopy(&prP2pSpecificBssInfo->
2625 aucAttributesCache[0],
2626 pucAttriListStart,
2627 u2AttriListLen);
2628
2629 pucAttriListStart =
2630 &prP2pSpecificBssInfo->
2631 aucAttributesCache[0];
2632
2633 u2BufferSize =
2634 P2P_MAXIMUM_ATTRIBUTE_LEN;
2635 } else if (ucOuiType == VENDOR_OUI_TYPE_WPS) {
2636 kalMemCopy(&prP2pSpecificBssInfo->
2637 aucWscAttributesCache[0],
2638 pucAttriListStart,
2639 u2AttriListLen);
2640 pucAttriListStart =
2641 &prP2pSpecificBssInfo->
2642 aucWscAttributesCache[0];
2643
2644 u2BufferSize =
2645 WPS_MAXIMUM_ATTRIBUTES_CACHE_SIZE;
2646 }
2647 #if CFG_SUPPORT_WFD
2648 else if (ucOuiType == VENDOR_OUI_TYPE_WFD) {
2649 PUINT_8 pucTmpBuf = (PUINT_8) NULL;
2650 pucTmpBuf =
2651 (PUINT_8)
2652 kalMemAlloc
2653 (WPS_MAXIMUM_ATTRIBUTES_CACHE_SIZE,
2654 VIR_MEM_TYPE);
2655
2656 if (pucTmpBuf != NULL) {
2657 fgIsAllocMem = TRUE;
2658 } else {
2659 /* Can't alloca memory for WFD IE relocate. */
2660 ASSERT(FALSE);
2661 break;
2662 }
2663
2664 kalMemCopy(pucTmpBuf,
2665 pucAttriListStart,
2666 u2AttriListLen);
2667
2668 pucAttriListStart = pucTmpBuf;
2669
2670 u2BufferSize =
2671 WPS_MAXIMUM_ATTRIBUTES_CACHE_SIZE;
2672 }
2673 #endif
2674 else {
2675 fgBackupAttributes = FALSE;
2676 }
2677 }
2678
2679 u2CopyLen =
2680 (UINT_16) (prIe->ucLength - P2P_OUI_TYPE_LEN);
2681
2682 if ((u2AttriListLen + u2CopyLen) > u2BufferSize) {
2683
2684 u2CopyLen = u2BufferSize - u2AttriListLen;
2685
2686 DBGLOG(P2P, WARN,
2687 ("Length of received P2P attributes > maximum cache size.\n"));
2688
2689 }
2690
2691 if (u2CopyLen) {
2692 kalMemCopy((PUINT_8)
2693 ((UINT_32) pucAttriListStart +
2694 (UINT_32) u2AttriListLen),
2695 &prIe->aucP2PAttributes[0],
2696 u2CopyLen);
2697
2698 u2AttriListLen += u2CopyLen;
2699 }
2700
2701
2702 }
2703 } /* prIe->aucOui */
2704 } /* ELEM_ID_VENDOR */
2705 } /* IE_FOR_EACH */
2706
2707
2708 } while (FALSE);
2709
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)));
2722 }
2723 } else {
2724 }
2725
2726 ASSERT(u2Offset == u2AttriListLen);
2727
2728 *ppucAttriList = pucAttriListStart;
2729 *pu2AttriListLen = u2AttriListLen;
2730
2731 } else {
2732 *ppucAttriList = (PUINT_8) NULL;
2733 *pu2AttriListLen = 0;
2734 }
2735
2736 return fgIsAllocMem;
2737 } /* p2pFuncGetAttriList */
2738
2739
2740 P_MSDU_INFO_T p2pFuncProcessP2pProbeRsp(IN P_ADAPTER_T prAdapter, IN P_MSDU_INFO_T prMgmtTxMsdu)
2741 {
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;
2750
2751
2752 do {
2753 ASSERT_BREAK((prAdapter != NULL) && (prMgmtTxMsdu != NULL));
2754
2755 prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
2756
2757 /* 3 Make sure this is probe response frame. */
2758 prProbeRspFrame =
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);
2763
2764 /* 3 Get the importent P2P IE. */
2765 u2ProbeRspHdrLen =
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;
2770
2771 #if CFG_SUPPORT_WFD
2772 prAdapter->prGlueInfo->prP2PInfo->u2VenderIELen = 0;
2773 #endif
2774
2775 IE_FOR_EACH(pucIEBuf, u2IELength, u2Offset) {
2776 switch (IE_ID(pucIEBuf)) {
2777 case ELEM_ID_SSID:
2778 {
2779
2780 COPY_SSID(prP2pBssInfo->aucSSID,
2781 prP2pBssInfo->ucSSIDLen,
2782 SSID_IE(pucIEBuf)->aucSSID,
2783 SSID_IE(pucIEBuf)->ucLength);
2784 }
2785 break;
2786 case ELEM_ID_VENDOR:
2787 {
2788 UINT_8 ucOuiType = 0;
2789 UINT_16 u2SubTypeVersion = 0;
2790 #if!CFG_SUPPORT_WFD
2791
2792
2793 if (rsnParseCheckForWFAInfoElem
2794 (prAdapter, pucIEBuf, &ucOuiType, &u2SubTypeVersion)) {
2795 if (ucOuiType == VENDOR_OUI_TYPE_WPS) {
2796 kalP2PUpdateWSC_IE(prAdapter->prGlueInfo, 2,
2797 pucIEBuf,
2798 IE_SIZE(pucIEBuf));
2799 fgIsWSCIE = TRUE;
2800 }
2801
2802 }
2803
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,
2809 pucIEBuf,
2810 IE_SIZE(pucIEBuf));
2811 fgIsP2PIE = TRUE;
2812 }
2813
2814 }
2815
2816 else {
2817 if ((prAdapter->prGlueInfo->prP2PInfo->
2818 u2VenderIELen + IE_SIZE(pucIEBuf)) < 512) {
2819 kalMemCopy(prAdapter->prGlueInfo->
2820 prP2PInfo->aucVenderIE, pucIEBuf,
2821 IE_SIZE(pucIEBuf));
2822 prAdapter->prGlueInfo->prP2PInfo->
2823 u2VenderIELen += IE_SIZE(pucIEBuf);
2824 }
2825 }
2826 #else
2827 /* Eddie May be WFD */
2828 if (rsnParseCheckForWFAInfoElem
2829 (prAdapter, pucIEBuf, &ucOuiType, &u2SubTypeVersion)) {
2830 if (ucOuiType == VENDOR_OUI_TYPE_WMM) {
2831 break;
2832 }
2833
2834 }
2835 if ((prAdapter->prGlueInfo->prP2PInfo->u2VenderIELen +
2836 IE_SIZE(pucIEBuf)) < 1024) {
2837 kalMemCopy(prAdapter->prGlueInfo->prP2PInfo->
2838 aucVenderIE +
2839 prAdapter->prGlueInfo->prP2PInfo->
2840 u2VenderIELen, pucIEBuf,
2841 IE_SIZE(pucIEBuf));
2842 prAdapter->prGlueInfo->prP2PInfo->u2VenderIELen +=
2843 IE_SIZE(pucIEBuf);
2844 }
2845 #endif
2846
2847
2848 }
2849 break;
2850 default:
2851 break;
2852 }
2853
2854 }
2855
2856
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);
2865
2866 u2EstimatedExtraIELen = 0;
2867
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;
2873 }
2874
2875 else {
2876 ASSERT(txProbeRspIETable[u4Idx].pfnCalculateVariableIELen);
2877
2878 u2EstimatedExtraIELen +=
2879 (UINT_16) (txProbeRspIETable[u4Idx].
2880 pfnCalculateVariableIELen(prAdapter,
2881 NETWORK_TYPE_P2P_INDEX,
2882 NULL));
2883 }
2884
2885 }
2886
2887
2888 if (fgIsWSCIE) {
2889 u2EstimatedExtraIELen += kalP2PCalWSC_IELen(prAdapter->prGlueInfo, 2);
2890 }
2891
2892 if (fgIsP2PIE) {
2893 u2EstimatedExtraIELen += kalP2PCalWSC_IELen(prAdapter->prGlueInfo, 1);
2894 }
2895 #if CFG_SUPPORT_WFD
2896 u2EstimatedExtraIELen += prAdapter->prGlueInfo->prP2PInfo->u2VenderIELen;
2897 #endif
2898
2899
2900
2901 if ((u2EstimateSize += u2EstimatedExtraIELen) > (prRetMsduInfo->u2FrameLength)) {
2902 prRetMsduInfo = cnmMgtPktAlloc(prAdapter, u2EstimateSize);
2903
2904 if (prRetMsduInfo == NULL) {
2905 DBGLOG(P2P, WARN,
2906 ("No packet for sending new probe response, use original one\n"));
2907 prRetMsduInfo = prMgmtTxMsdu;
2908 break;
2909 }
2910
2911
2912 prRetMsduInfo->ucNetworkType = NETWORK_TYPE_P2P_INDEX;
2913 }
2914
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);
2924
2925 prRetMsduInfo->u2FrameLength =
2926 (WLAN_MAC_MGMT_HEADER_LEN + TIMESTAMP_FIELD_LEN + BEACON_INTERVAL_FIELD_LEN +
2927 CAP_INFO_FIELD_LEN);
2928
2929 bssBuildBeaconProbeRespFrameCommonIEs(prRetMsduInfo,
2930 prP2pBssInfo, prProbeRspFrame->aucDestAddr);
2931
2932
2933 for (u4Idx = 0; u4Idx < u4IeArraySize; u4Idx++) {
2934 if (txProbeRspIETable[u4Idx].pfnAppendIE) {
2935 txProbeRspIETable[u4Idx].pfnAppendIE(prAdapter, prRetMsduInfo);
2936 }
2937
2938 }
2939
2940
2941 if (fgIsWSCIE) {
2942 kalP2PGenWSC_IE(prAdapter->prGlueInfo,
2943 2,
2944 (PUINT_8) ((UINT_32) prRetMsduInfo->prPacket +
2945 (UINT_32) prRetMsduInfo->u2FrameLength));
2946
2947 prRetMsduInfo->u2FrameLength +=
2948 (UINT_16) kalP2PCalWSC_IELen(prAdapter->prGlueInfo, 2);
2949 }
2950
2951 if (fgIsP2PIE) {
2952 kalP2PGenWSC_IE(prAdapter->prGlueInfo,
2953 1,
2954 (PUINT_8) ((UINT_32) prRetMsduInfo->prPacket +
2955 (UINT_32) prRetMsduInfo->u2FrameLength));
2956
2957 prRetMsduInfo->u2FrameLength +=
2958 (UINT_16) kalP2PCalWSC_IELen(prAdapter->prGlueInfo, 1);
2959 }
2960 #if CFG_SUPPORT_WFD
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;
2969 }
2970 #endif
2971
2972
2973 } while (FALSE);
2974
2975 if (prRetMsduInfo != prMgmtTxMsdu) {
2976 cnmMgtPktFree(prAdapter, prMgmtTxMsdu);
2977 }
2978
2979
2980 return prRetMsduInfo;
2981 } /* p2pFuncProcessP2pProbeRsp */
2982
2983
2984 #if 0 /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) */
2985 UINT_32
2986 p2pFuncCalculateExtra_IELenForBeacon(IN P_ADAPTER_T prAdapter,
2987 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex,
2988 IN P_STA_RECORD_T prStaRec)
2989 {
2990
2991 P_P2P_SPECIFIC_BSS_INFO_T prP2pSpeBssInfo = (P_P2P_SPECIFIC_BSS_INFO_T) NULL;
2992 UINT_32 u4IELen = 0;
2993
2994 do {
2995 ASSERT_BREAK((prAdapter != NULL) && (eNetTypeIndex == NETWORK_TYPE_P2P_INDEX));
2996
2997 if (p2pFuncIsAPMode(prAdapter->rWifiVar.prP2pFsmInfo)) {
2998 break;
2999 }
3000
3001 prP2pSpeBssInfo = prAdapter->rWifiVar.prP2pSpecificBssInfo;
3002
3003 u4IELen = prP2pSpeBssInfo->u2IELenForBCN;
3004
3005 } while (FALSE);
3006
3007 return u4IELen;
3008 } /* p2pFuncCalculateP2p_IELenForBeacon */
3009
3010 VOID p2pFuncGenerateExtra_IEForBeacon(IN P_ADAPTER_T prAdapter, IN P_MSDU_INFO_T prMsduInfo)
3011 {
3012 P_P2P_SPECIFIC_BSS_INFO_T prP2pSpeBssInfo = (P_P2P_SPECIFIC_BSS_INFO_T) NULL;
3013 PUINT_8 pucIEBuf = (PUINT_8) NULL;
3014
3015 do {
3016 ASSERT_BREAK((prAdapter != NULL) && (prMsduInfo != NULL));
3017
3018 prP2pSpeBssInfo = prAdapter->rWifiVar.prP2pSpecificBssInfo;
3019
3020 if (p2pFuncIsAPMode(prAdapter->rWifiVar.prP2pFsmInfo)) {
3021
3022 break;
3023 }
3024
3025 pucIEBuf =
3026 (PUINT_8) ((UINT_32) prMsduInfo->prPacket +
3027 (UINT_32) prMsduInfo->u2FrameLength);
3028
3029 kalMemCopy(pucIEBuf, prP2pSpeBssInfo->aucBeaconIECache,
3030 prP2pSpeBssInfo->u2IELenForBCN);
3031
3032 prMsduInfo->u2FrameLength += prP2pSpeBssInfo->u2IELenForBCN;
3033
3034 } while (FALSE);
3035
3036 return;
3037 } /* p2pFuncGenerateExtra_IEForBeacon */
3038
3039
3040 #else
3041 UINT_32
3042 p2pFuncCalculateP2p_IELenForBeacon(IN P_ADAPTER_T prAdapter,
3043 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex,
3044 IN P_STA_RECORD_T prStaRec)
3045 {
3046 P_P2P_SPECIFIC_BSS_INFO_T prP2pSpeBssInfo = (P_P2P_SPECIFIC_BSS_INFO_T) NULL;
3047 UINT_32 u4IELen = 0;
3048
3049 do {
3050 ASSERT_BREAK((prAdapter != NULL) && (eNetTypeIndex == NETWORK_TYPE_P2P_INDEX));
3051
3052 if (!prAdapter->fgIsP2PRegistered) {
3053 break;
3054 }
3055
3056
3057 if (p2pFuncIsAPMode(prAdapter->rWifiVar.prP2pFsmInfo)) {
3058 break;
3059 }
3060
3061 prP2pSpeBssInfo = prAdapter->rWifiVar.prP2pSpecificBssInfo;
3062
3063 u4IELen = prP2pSpeBssInfo->u2AttributeLen;
3064
3065 } while (FALSE);
3066
3067 return u4IELen;
3068 } /* p2pFuncCalculateP2p_IELenForBeacon */
3069
3070
3071 VOID p2pFuncGenerateP2p_IEForBeacon(IN P_ADAPTER_T prAdapter, IN P_MSDU_INFO_T prMsduInfo)
3072 {
3073 P_P2P_SPECIFIC_BSS_INFO_T prP2pSpeBssInfo = (P_P2P_SPECIFIC_BSS_INFO_T) NULL;
3074 PUINT_8 pucIEBuf = (PUINT_8) NULL;
3075
3076 do {
3077 ASSERT_BREAK((prAdapter != NULL) && (prMsduInfo != NULL));
3078
3079 if (!prAdapter->fgIsP2PRegistered) {
3080 break;
3081 }
3082
3083 prP2pSpeBssInfo = prAdapter->rWifiVar.prP2pSpecificBssInfo;
3084
3085 if (p2pFuncIsAPMode(prAdapter->rWifiVar.prP2pFsmInfo)) {
3086
3087 break;
3088 }
3089
3090 pucIEBuf =
3091 (PUINT_8) ((UINT_32) prMsduInfo->prPacket +
3092 (UINT_32) prMsduInfo->u2FrameLength);
3093
3094 kalMemCopy(pucIEBuf, prP2pSpeBssInfo->aucAttributesCache,
3095 prP2pSpeBssInfo->u2AttributeLen);
3096
3097 prMsduInfo->u2FrameLength += prP2pSpeBssInfo->u2AttributeLen;
3098
3099 } while (FALSE);
3100
3101 return;
3102 } /* p2pFuncGenerateP2p_IEForBeacon */
3103
3104
3105
3106
3107
3108 UINT_32
3109 p2pFuncCalculateWSC_IELenForBeacon(IN P_ADAPTER_T prAdapter,
3110 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex,
3111 IN P_STA_RECORD_T prStaRec)
3112 {
3113 if (eNetTypeIndex != NETWORK_TYPE_P2P_INDEX) {
3114 return 0;
3115 }
3116
3117 return kalP2PCalWSC_IELen(prAdapter->prGlueInfo, 0);
3118 } /* p2pFuncCalculateP2p_IELenForBeacon */
3119
3120
3121 VOID p2pFuncGenerateWSC_IEForBeacon(IN P_ADAPTER_T prAdapter, IN P_MSDU_INFO_T prMsduInfo)
3122 {
3123 PUINT_8 pucBuffer;
3124 UINT_16 u2IELen = 0;
3125 ASSERT(prAdapter);
3126 ASSERT(prMsduInfo);
3127
3128 if (prMsduInfo->ucNetworkType != NETWORK_TYPE_P2P_INDEX) {
3129 return;
3130 }
3131
3132 u2IELen = (UINT_16) kalP2PCalWSC_IELen(prAdapter->prGlueInfo, 0);
3133
3134 pucBuffer = (PUINT_8) ((UINT_32) prMsduInfo->prPacket +
3135 (UINT_32) prMsduInfo->u2FrameLength);
3136
3137 ASSERT(pucBuffer);
3138
3139 /* TODO: Check P2P FSM State. */
3140 kalP2PGenWSC_IE(prAdapter->prGlueInfo, 0, pucBuffer);
3141
3142 prMsduInfo->u2FrameLength += u2IELen;
3143
3144 return;
3145 } /* p2pFuncGenerateP2p_IEForBeacon */
3146
3147 #endif
3148 /*----------------------------------------------------------------------------*/
3149 /*!
3150 * @brief This function is used to calculate P2P IE length for Beacon frame.
3151 *
3152 * @param[in] eNetTypeIndex Specify which network
3153 * @param[in] prStaRec Pointer to the STA_RECORD_T
3154 *
3155 * @return The length of P2P IE added
3156 */
3157 /*----------------------------------------------------------------------------*/
3158 UINT_32
3159 p2pFuncCalculateP2p_IELenForAssocRsp(IN P_ADAPTER_T prAdapter,
3160 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex,
3161 IN P_STA_RECORD_T prStaRec)
3162 {
3163
3164 if (eNetTypeIndex != NETWORK_TYPE_P2P_INDEX) {
3165 return 0;
3166 }
3167
3168 return p2pFuncCalculateP2P_IELen(prAdapter,
3169 eNetTypeIndex,
3170 prStaRec,
3171 txAssocRspAttributesTable,
3172 sizeof(txAssocRspAttributesTable) /
3173 sizeof(APPEND_VAR_ATTRI_ENTRY_T));
3174
3175 } /* p2pFuncCalculateP2p_IELenForAssocRsp */
3176
3177
3178
3179
3180
3181
3182 /*----------------------------------------------------------------------------*/
3183 /*!
3184 * @brief This function is used to generate P2P IE for Beacon frame.
3185 *
3186 * @param[in] prMsduInfo Pointer to the composed MSDU_INFO_T.
3187 *
3188 * @return none
3189 */
3190 /*----------------------------------------------------------------------------*/
3191 VOID p2pFuncGenerateP2p_IEForAssocRsp(IN P_ADAPTER_T prAdapter, IN P_MSDU_INFO_T prMsduInfo)
3192 {
3193 P_P2P_FSM_INFO_T prP2pFsmInfo = (P_P2P_FSM_INFO_T) NULL;
3194 P_STA_RECORD_T prStaRec = (P_STA_RECORD_T) NULL;
3195
3196 do {
3197 ASSERT_BREAK((prAdapter != NULL) && (prMsduInfo != NULL));
3198
3199 prP2pFsmInfo = prAdapter->rWifiVar.prP2pFsmInfo;
3200
3201 prStaRec = cnmGetStaRecByIndex(prAdapter, prMsduInfo->ucStaRecIndex);
3202
3203 if (IS_STA_P2P_TYPE(prStaRec)) {
3204 DBGLOG(P2P, TRACE, ("Generate NULL P2P IE for Assoc Rsp.\n"));
3205
3206 p2pFuncGenerateP2P_IE(prAdapter,
3207 TRUE,
3208 &prMsduInfo->u2FrameLength,
3209 prMsduInfo->prPacket,
3210 1500,
3211 txAssocRspAttributesTable,
3212 sizeof(txAssocRspAttributesTable) /
3213 sizeof(APPEND_VAR_ATTRI_ENTRY_T));
3214 } else {
3215
3216 DBGLOG(P2P, TRACE, ("Legacy device, no P2P IE.\n"));
3217 }
3218
3219 } while (FALSE);
3220
3221 return;
3222
3223 } /* p2pFuncGenerateP2p_IEForAssocRsp */
3224
3225
3226 UINT_32
3227 p2pFuncCalculateWSC_IELenForAssocRsp(IN P_ADAPTER_T prAdapter,
3228 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex,
3229 IN P_STA_RECORD_T prStaRec)
3230 {
3231 DBGLOG(P2P, TRACE, ("p2pFuncCalculateWSC_IELenForAssocRsp\n"));
3232 if (eNetTypeIndex != NETWORK_TYPE_P2P_INDEX) {
3233 return 0;
3234 }
3235
3236 return kalP2PCalWSC_IELen(prAdapter->prGlueInfo, 0);
3237 } /* p2pFuncCalculateP2p_IELenForAssocRsp */
3238
3239
3240 VOID p2pFuncGenerateWSC_IEForAssocRsp(IN P_ADAPTER_T prAdapter, IN P_MSDU_INFO_T prMsduInfo)
3241 {
3242 PUINT_8 pucBuffer;
3243 UINT_16 u2IELen = 0;
3244 ASSERT(prAdapter);
3245 ASSERT(prMsduInfo);
3246
3247 if (prMsduInfo->ucNetworkType != NETWORK_TYPE_P2P_INDEX) {
3248 return;
3249 }
3250 DBGLOG(P2P, TRACE, ("p2pFuncGenerateWSC_IEForAssocRsp\n"));
3251
3252 u2IELen = (UINT_16) kalP2PCalWSC_IELen(prAdapter->prGlueInfo, 0);
3253
3254 pucBuffer = (PUINT_8) ((UINT_32) prMsduInfo->prPacket +
3255 (UINT_32) prMsduInfo->u2FrameLength);
3256
3257 ASSERT(pucBuffer);
3258
3259 /* TODO: Check P2P FSM State. */
3260 kalP2PGenWSC_IE(prAdapter->prGlueInfo, 0, pucBuffer);
3261
3262 prMsduInfo->u2FrameLength += u2IELen;
3263
3264 return;
3265 }
3266
3267 /* p2pFuncGenerateP2p_IEForAssocRsp */
3268
3269
3270
3271
3272 UINT_32
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)
3278 {
3279
3280 UINT_32 u4OverallAttriLen, u4Dummy;
3281 UINT_16 u2EstimatedFixedAttriLen;
3282 UINT_32 i;
3283
3284
3285 /* Overall length of all Attributes */
3286 u4OverallAttriLen = 0;
3287
3288 for (i = 0; i < u4AttriTableSize; i++) {
3289 u2EstimatedFixedAttriLen = arAppendAttriTable[i].u2EstimatedFixedAttriLen;
3290
3291 if (u2EstimatedFixedAttriLen) {
3292 u4OverallAttriLen += u2EstimatedFixedAttriLen;
3293 } else {
3294 ASSERT(arAppendAttriTable[i].pfnCalculateVariableAttriLen);
3295
3296 u4OverallAttriLen +=
3297 arAppendAttriTable[i].pfnCalculateVariableAttriLen(prAdapter, prStaRec);
3298 }
3299 }
3300
3301 u4Dummy = u4OverallAttriLen;
3302 u4OverallAttriLen += P2P_IE_OUI_HDR;
3303
3304 for (; (u4Dummy > P2P_MAXIMUM_ATTRIBUTE_LEN);) {
3305 u4OverallAttriLen += P2P_IE_OUI_HDR;
3306 u4Dummy -= P2P_MAXIMUM_ATTRIBUTE_LEN;
3307 }
3308
3309 return u4OverallAttriLen;
3310 } /* p2pFuncCalculateP2P_IELen */
3311
3312
3313 VOID
3314 p2pFuncGenerateP2P_IE(IN P_ADAPTER_T prAdapter,
3315 IN BOOLEAN fgIsAssocFrame,
3316 IN PUINT_16 pu2Offset,
3317 IN PUINT_8 pucBuf,
3318 IN UINT_16 u2BufSize,
3319 IN APPEND_VAR_ATTRI_ENTRY_T arAppendAttriTable[], IN UINT_32 u4AttriTableSize)
3320 {
3321 PUINT_8 pucBuffer = (PUINT_8) NULL;
3322 P_IE_P2P_T prIeP2P = (P_IE_P2P_T) NULL;
3323 UINT_32 u4OverallAttriLen;
3324 UINT_32 u4AttriLen;
3325 UINT_8 aucWfaOui[] = VENDOR_OUI_WFA_SPECIFIC;
3326 UINT_8 aucTempBuffer[P2P_MAXIMUM_ATTRIBUTE_LEN];
3327 UINT_32 i;
3328
3329
3330 do {
3331 ASSERT_BREAK((prAdapter != NULL) && (pucBuf != NULL));
3332
3333 pucBuffer = (PUINT_8) ((UINT_32) pucBuf + (*pu2Offset));
3334
3335 ASSERT_BREAK(pucBuffer != NULL);
3336
3337 /* Check buffer length is still enough. */
3338 ASSERT_BREAK((u2BufSize - (*pu2Offset)) >= P2P_IE_OUI_HDR);
3339
3340 prIeP2P = (P_IE_P2P_T) pucBuffer;
3341
3342 prIeP2P->ucId = ELEM_ID_P2P;
3343
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;
3348
3349 (*pu2Offset) += P2P_IE_OUI_HDR;
3350
3351 /* Overall length of all Attributes */
3352 u4OverallAttriLen = 0;
3353
3354
3355 for (i = 0; i < u4AttriTableSize; i++) {
3356
3357 if (arAppendAttriTable[i].pfnAppendAttri) {
3358 u4AttriLen =
3359 arAppendAttriTable[i].pfnAppendAttri(prAdapter, fgIsAssocFrame,
3360 pu2Offset, pucBuf,
3361 u2BufSize);
3362
3363 u4OverallAttriLen += u4AttriLen;
3364
3365 if (u4OverallAttriLen > P2P_MAXIMUM_ATTRIBUTE_LEN) {
3366 u4OverallAttriLen -= P2P_MAXIMUM_ATTRIBUTE_LEN;
3367
3368 prIeP2P->ucLength =
3369 (VENDOR_OUI_TYPE_LEN + P2P_MAXIMUM_ATTRIBUTE_LEN);
3370
3371 pucBuffer =
3372 (PUINT_8) ((UINT_32) prIeP2P +
3373 (VENDOR_OUI_TYPE_LEN +
3374 P2P_MAXIMUM_ATTRIBUTE_LEN));
3375
3376 prIeP2P = (P_IE_P2P_T) ((UINT_32) prIeP2P +
3377 (ELEM_HDR_LEN +
3378 (VENDOR_OUI_TYPE_LEN +
3379 P2P_MAXIMUM_ATTRIBUTE_LEN)));
3380
3381 kalMemCopy(aucTempBuffer, pucBuffer, u4OverallAttriLen);
3382
3383 prIeP2P->ucId = ELEM_ID_P2P;
3384
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;
3389
3390 kalMemCopy(prIeP2P->aucP2PAttributes, aucTempBuffer,
3391 u4OverallAttriLen);
3392 (*pu2Offset) += P2P_IE_OUI_HDR;
3393 }
3394
3395 }
3396
3397 }
3398
3399 prIeP2P->ucLength = (UINT_8) (VENDOR_OUI_TYPE_LEN + u4OverallAttriLen);
3400
3401
3402 } while (FALSE);
3403
3404 return;
3405 } /* p2pFuncGenerateP2P_IE */
3406
3407 UINT_32
3408 p2pFuncAppendAttriStatusForAssocRsp(IN P_ADAPTER_T prAdapter,
3409 IN BOOLEAN fgIsAssocFrame,
3410 IN PUINT_16 pu2Offset, IN PUINT_8 pucBuf, IN UINT_16 u2BufSize)
3411 {
3412 PUINT_8 pucBuffer;
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;
3416
3417 ASSERT(prAdapter);
3418 ASSERT(pucBuf);
3419
3420 prP2pConnSettings = prAdapter->rWifiVar.prP2PConnSettings;
3421
3422 if (fgIsAssocFrame) {
3423 return u4AttriLen;
3424 }
3425 /* TODO: For assoc request P2P IE check in driver & return status in P2P IE. */
3426
3427 pucBuffer = (PUINT_8) ((UINT_32) pucBuf + (UINT_32) (*pu2Offset));
3428
3429 ASSERT(pucBuffer);
3430 prAttriStatus = (P_P2P_ATTRI_STATUS_T) pucBuffer;
3431
3432 ASSERT(u2BufSize >= ((*pu2Offset) + (UINT_16) u4AttriLen));
3433
3434
3435
3436
3437 prAttriStatus->ucId = P2P_ATTRI_ID_STATUS;
3438 WLAN_SET_FIELD_16(&prAttriStatus->u2Length, P2P_ATTRI_MAX_LEN_STATUS);
3439
3440 prAttriStatus->ucStatusCode = P2P_STATUS_FAIL_PREVIOUS_PROTOCOL_ERR;
3441
3442 u4AttriLen = (P2P_ATTRI_HDR_LEN + P2P_ATTRI_MAX_LEN_STATUS);
3443
3444 (*pu2Offset) += (UINT_16) u4AttriLen;
3445
3446 return u4AttriLen;
3447 } /* p2pFuncAppendAttriStatusForAssocRsp */
3448
3449 UINT_32
3450 p2pFuncAppendAttriExtListenTiming(IN P_ADAPTER_T prAdapter,
3451 IN BOOLEAN fgIsAssocFrame,
3452 IN PUINT_16 pu2Offset, IN PUINT_8 pucBuf, IN UINT_16 u2BufSize)
3453 {
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;
3459
3460 ASSERT(prAdapter);
3461 ASSERT(pucBuf);
3462
3463 if (fgIsAssocFrame) {
3464 return u4AttriLen;
3465 }
3466 /* TODO: For extend listen timing. */
3467
3468 prP2pSpecificBssInfo = prAdapter->rWifiVar.prP2pSpecificBssInfo;
3469
3470 u4AttriLen = (P2P_ATTRI_HDR_LEN + P2P_ATTRI_MAX_LEN_EXT_LISTEN_TIMING);
3471
3472 ASSERT(u2BufSize >= ((*pu2Offset) + (UINT_16) u4AttriLen));
3473
3474 pucBuffer = (PUINT_8) ((UINT_32) pucBuf + (UINT_32) (*pu2Offset));
3475
3476 ASSERT(pucBuffer);
3477
3478 prP2pExtListenTiming = (P_P2P_ATTRI_EXT_LISTEN_TIMING_T) pucBuffer;
3479
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);
3486
3487 (*pu2Offset) += (UINT_16) u4AttriLen;
3488
3489 return u4AttriLen;
3490 } /* p2pFuncAppendAttriExtListenTiming */
3491
3492
3493 P_IE_HDR_T
3494 p2pFuncGetSpecIE(IN P_ADAPTER_T prAdapter,
3495 IN PUINT_8 pucIEBuf,
3496 IN UINT_16 u2BufferLen, IN UINT_8 ucElemID, IN PBOOLEAN pfgIsMore)
3497 {
3498 P_IE_HDR_T prTargetIE = (P_IE_HDR_T) NULL;
3499 PUINT_8 pucIE = (PUINT_8) NULL;
3500 UINT_16 u2Offset = 0;
3501
3502 if (pfgIsMore) {
3503 *pfgIsMore = FALSE;
3504 }
3505
3506 do {
3507 ASSERT_BREAK((prAdapter != NULL)
3508 && (pucIEBuf != NULL));
3509
3510 pucIE = pucIEBuf;
3511
3512 IE_FOR_EACH(pucIE, u2BufferLen, u2Offset) {
3513 if (IE_ID(pucIE) == ucElemID) {
3514 if ((prTargetIE) && (pfgIsMore)) {
3515
3516 *pfgIsMore = TRUE;
3517 break;
3518 } else {
3519 prTargetIE = (P_IE_HDR_T) pucIE;
3520
3521 if (pfgIsMore == NULL) {
3522 break;
3523 }
3524
3525 }
3526
3527 }
3528 }
3529
3530 } while (FALSE);
3531
3532 return prTargetIE;
3533 } /* p2pFuncGetSpecIE */
3534
3535
3536
3537 P_ATTRIBUTE_HDR_T
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)
3541 {
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;
3549
3550
3551 DBGLOG(P2P, INFO,
3552 ("Check AssocReq Oui type %u attri %u for len %u\n", ucOuiType, u2AttriID,
3553 u2BufferLen));
3554
3555 do {
3556 ASSERT_BREAK((prAdapter != NULL)
3557 && (pucIEBuf != NULL));
3558
3559 u2BufferLenLeft = u2BufferLen;
3560 pucIE = pucIEBuf;
3561 do {
3562 fgIsMore = FALSE;
3563 prP2pIE = (P_IE_P2P_T) p2pFuncGetSpecIE(prAdapter,
3564 pucIE,
3565 u2BufferLenLeft,
3566 ELEM_ID_VENDOR, &fgIsMore);
3567
3568 if (prP2pIE) {
3569
3570 ASSERT(prP2pIE > pucIE);
3571
3572 u2BufferLenLeft =
3573 u2BufferLen - (UINT_16) (((UINT_32) prP2pIE) -
3574 ((UINT_32) pucIEBuf));
3575
3576 DBGLOG(P2P, INFO,
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));
3580
3581 if (IE_LEN(prP2pIE) > P2P_OUI_TYPE_LEN) {
3582
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;
3589 break;
3590 case VENDOR_OUI_TYPE_P2P:
3591 break;
3592 case VENDOR_OUI_TYPE_WPA:
3593 case VENDOR_OUI_TYPE_WMM:
3594 case VENDOR_OUI_TYPE_WFD:
3595 default:
3596 break;
3597 }
3598
3599
3600 if ((prP2pIE->aucOui[0] == aucWfaOui[0])
3601 && (prP2pIE->aucOui[1] == aucWfaOui[1])
3602 && (prP2pIE->aucOui[2] == aucWfaOui[2])
3603 ) {
3604
3605 u2OffsetAttri = 0;
3606 pucAttri = prP2pIE->aucP2PAttributes;
3607
3608 if (ucOuiType == VENDOR_OUI_TYPE_WPS) {
3609 WSC_ATTRI_FOR_EACH(pucAttri,
3610 (IE_LEN(prP2pIE)
3611 -
3612 P2P_OUI_TYPE_LEN),
3613 u2OffsetAttri) {
3614 /* LOG_FUNC("WSC: attri id=%u len=%u\n",WSC_ATTRI_ID(pucAttri), WSC_ATTRI_LEN(pucAttri)); */
3615 if (WSC_ATTRI_ID(pucAttri)
3616 == u2AttriID) {
3617 prTargetAttri =
3618 (P_ATTRIBUTE_HDR_T)
3619 pucAttri;
3620 break;
3621 }
3622
3623 }
3624
3625 }
3626
3627 else if (ucOuiType == VENDOR_OUI_TYPE_P2P) {
3628 P2P_ATTRI_FOR_EACH(pucAttri,
3629 (IE_LEN(prP2pIE)
3630 -
3631 P2P_OUI_TYPE_LEN),
3632 u2OffsetAttri) {
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) {
3636 prTargetAttri =
3637 (P_ATTRIBUTE_HDR_T)
3638 pucAttri;
3639 break;
3640 }
3641
3642 }
3643
3644 } else if (ucOuiType == VENDOR_OUI_TYPE_WFD) {
3645 WFD_ATTRI_FOR_EACH(pucAttri,
3646 (IE_LEN(prP2pIE)
3647 -
3648 P2P_OUI_TYPE_LEN),
3649 u2OffsetAttri) {
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) {
3653 prTargetAttri =
3654 (P_ATTRIBUTE_HDR_T)
3655 pucAttri;
3656 break;
3657 }
3658
3659 }
3660 } else {
3661 /* Possible or else. */
3662 }
3663
3664 }
3665 } /* ucOuiType */
3666 }
3667 /* P2P_OUI_TYPE_LEN */
3668 pucIE = (PUINT_8) (((UINT_32) prP2pIE) + IE_SIZE(prP2pIE));
3669
3670 }
3671 /* prP2pIE */
3672 } while (prP2pIE && fgIsMore && u2BufferLenLeft);
3673
3674 } while (FALSE);
3675
3676 return prTargetAttri;
3677 }
3678
3679 /* p2pFuncGetSpecAttri */
3680
3681
3682 WLAN_STATUS
3683 p2pFuncGenerateBeaconProbeRsp(IN P_ADAPTER_T prAdapter,
3684 IN P_BSS_INFO_T prBssInfo,
3685 IN P_MSDU_INFO_T prMsduInfo, IN BOOLEAN fgIsProbeRsp)
3686 {
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; */
3690
3691
3692 do {
3693
3694 ASSERT_BREAK((prAdapter != NULL) && (prBssInfo != NULL) && (prMsduInfo != NULL));
3695
3696
3697 /* txBcnIETable */
3698
3699 /* txProbeRspIETable */
3700
3701
3702
3703 prBcnFrame = (P_WLAN_BEACON_FRAME_T) prMsduInfo->prPacket;
3704
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));
3712
3713 } while (FALSE);
3714
3715 return rWlanStatus;
3716 } /* p2pFuncGenerateBeaconProbeRsp */
3717
3718
3719 WLAN_STATUS
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)
3726 {
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;
3731
3732 PUINT_8 pucBuffer = (PUINT_8) NULL;
3733
3734 do {
3735 ASSERT_BREAK((prAdapter != NULL) && (pucBcnBuffer != NULL));
3736
3737 prWlanBcnFrame = (P_WLAN_MAC_HEADER_T) pucBcnBuffer;
3738
3739 if ((prWlanBcnFrame->u2FrameCtrl != MAC_FRAME_BEACON) && (!fgIsProbeRsp)) {
3740 rWlanStatus = WLAN_STATUS_INVALID_DATA;
3741 break;
3742 }
3743
3744 else if (prWlanBcnFrame->u2FrameCtrl != MAC_FRAME_PROBE_RSP) {
3745 rWlanStatus = WLAN_STATUS_INVALID_DATA;
3746 break;
3747 }
3748
3749
3750
3751 if (fgIsProbeRsp) {
3752 ASSERT_BREAK(prP2pProbeRspInfo != NULL);
3753
3754 if (!prP2pProbeRspInfo->prProbeRspMsduTemplate) {
3755 cnmMgtPktFree(prAdapter, prP2pProbeRspInfo->prProbeRspMsduTemplate);
3756 }
3757
3758 prP2pProbeRspInfo->prProbeRspMsduTemplate =
3759 cnmMgtPktAlloc(prAdapter, u4BcnBufLen);
3760
3761 prMsduInfo = prP2pProbeRspInfo->prProbeRspMsduTemplate;
3762
3763 prMsduInfo->eSrc = TX_PACKET_MGMT;
3764 prMsduInfo->ucStaRecIndex = 0xFF;
3765 prMsduInfo->ucNetworkType = NETWORK_TYPE_P2P_INDEX;
3766
3767 } else {
3768 prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
3769 prMsduInfo = prP2pBssInfo->prBeacon;
3770
3771 if (prMsduInfo == NULL) {
3772 rWlanStatus = WLAN_STATUS_FAILURE;
3773 break;
3774 }
3775
3776 if (u4BcnBufLen >
3777 (OFFSET_OF(WLAN_BEACON_FRAME_T, aucInfoElem[0]) + MAX_IE_LENGTH)) {
3778 /* Unexpected error, buffer overflow. */
3779 ASSERT(FALSE);
3780 break;
3781 }
3782
3783 }
3784
3785
3786 pucBuffer = (PUINT_8) ((UINT_32) (prMsduInfo->prPacket) + MAC_TX_RESERVED_FIELD);
3787
3788 kalMemCopy(pucBuffer, pucBcnBuffer, u4BcnBufLen);
3789
3790 prMsduInfo->fgIs802_11 = TRUE;
3791 prMsduInfo->u2FrameLength = (UINT_16) u4BcnBufLen;
3792
3793 if (fgSynToFW) {
3794 rWlanStatus =
3795 p2pFuncGenerateBeaconProbeRsp(prAdapter, prP2pBssInfo, prMsduInfo,
3796 fgIsProbeRsp);
3797 }
3798
3799 } while (FALSE);
3800
3801 return rWlanStatus;
3802
3803 } /* p2pFuncComposeBeaconTemplate */