1 /*
2 * templates.c
3 *
4 * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * * Neither the name Texas Instruments nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 /** \file reportReplvl.c
35 * \brief Report level implementation
36 *
37 * \see reportReplvl.h
38 */
39
40 /***************************************************************************/
41 /* */
42 /* MODULE: reportReplvl.c */
43 /* PURPOSE: Report level implementation */
44 /* */
45 /***************************************************************************/
46
47 #define __FILE_ID__ FILE_ID_88
48 #include "tidef.h"
49 #include "report.h"
50 #include "osApi.h"
51 #include "siteHash.h"
52 #include "rate.h"
53 #include "rsnApi.h"
54 #include "regulatoryDomainApi.h"
55 #include "siteMgrApi.h"
56 #include "TWDriver.h"
57 #include "StaCap.h"
58
59 /********************************************/
60 /* Functions Implementations */
61 /********************************************/
62
63 /************************************************************************
64 * buildNullTemplate *
65 ************************************************************************
66 DESCRIPTION: This function build a NULL data template to set to the HAL
67 when joining an infrastructure network
68 performs the following:
69 - Build a template & set the template len, the template type is set in the site mgr
70
71 INPUT: pSiteMgr - Handle to site manager
72 pTemplate - Pointer to the template structure
73
74
75 OUTPUT:
76
77
78 RETURN: TI_OK
79
80 ************************************************************************/
buildNullTemplate(siteMgr_t * pSiteMgr,TSetTemplate * pTemplate)81 TI_STATUS buildNullTemplate(siteMgr_t *pSiteMgr, TSetTemplate *pTemplate)
82 {
83 paramInfo_t param;
84 TI_UINT32 size;
85 nullDataTemplate_t *pBuffer = (nullDataTemplate_t *)pTemplate->ptr;
86 siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
87 TI_UINT16 fc;
88
89 os_memoryZero(pSiteMgr->hOs, pBuffer, sizeof(nullDataTemplate_t));
90
91 /*
92 * Header First
93 */
94 /* Set destination address */
95 MAC_COPY (pBuffer->hdr.DA, pPrimarySite->bssid);
96
97 /* Set BSSID address */
98 MAC_COPY (pBuffer->hdr.BSSID, pPrimarySite->bssid);
99
100 /* Build Source address */
101 param.paramType = CTRL_DATA_MAC_ADDRESS;
102 ctrlData_getParam(pSiteMgr->hCtrlData, ¶m);
103 MAC_COPY (pBuffer->hdr.SA, param.content.ctrlDataDeviceMacAddress);
104
105 fc = DOT11_FC_DATA_NULL_FUNCTION;
106 fc |= (TI_TRUE << DOT11_FC_TO_DS_SHIFT);
107
108 COPY_WLAN_WORD(&pBuffer->hdr.fc, &fc); /* copy with endianess handling. */
109
110 size = sizeof(dot11_mgmtHeader_t);
111
112 pTemplate->len = size;
113
114 return TI_OK;
115 }
116
117 /************************************************************************
118 * buildDisconnTemplate *
119 ************************************************************************
120 DESCRIPTION: This function build a Death/Disassoc template to set to the HAL
121 when joining an infrastructure network
122 performs the following:
123 - Build a template & set the template len, the template type is set in the site mgr
124
125 INPUT: pSiteMgr - Handle to site manager
126 pTemplate - Pointer to the template structure
127
128
129 OUTPUT:
130
131
132 RETURN: TI_OK
133
134 ************************************************************************/
buildDisconnTemplate(siteMgr_t * pSiteMgr,TSetTemplate * pTemplate)135 TI_STATUS buildDisconnTemplate(siteMgr_t *pSiteMgr, TSetTemplate *pTemplate)
136 {
137 paramInfo_t param;
138 TI_UINT32 size;
139 disconnTemplate_t *pBuffer = (disconnTemplate_t *)pTemplate->ptr;
140 siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
141 TI_UINT16 fc;
142
143 os_memoryZero(pSiteMgr->hOs, pBuffer, sizeof(disconnTemplate_t));
144
145 /*
146 * Header First
147 */
148 /* Set destination address */
149 MAC_COPY (pBuffer->hdr.DA, pPrimarySite->bssid);
150
151 /* Set BSSID address */
152 MAC_COPY (pBuffer->hdr.BSSID, pPrimarySite->bssid);
153
154 /* Build Source address */
155 param.paramType = CTRL_DATA_MAC_ADDRESS;
156 ctrlData_getParam(pSiteMgr->hCtrlData, ¶m);
157 MAC_COPY (pBuffer->hdr.SA, param.content.ctrlDataDeviceMacAddress);
158
159 fc = DOT11_FC_DISASSOC; /* will be change by firmware to DOT11_FC_DEAUTH if needed */
160 fc |= (TI_TRUE << DOT11_FC_TO_DS_SHIFT);
161
162 COPY_WLAN_WORD(&pBuffer->hdr.fc, &fc); /* copy with endianess handling. */
163
164 pBuffer->disconnReason = 0; /* filled by firmware */
165
166 size = sizeof(disconnTemplate_t);
167
168 pTemplate->len = size;
169
170 return TI_OK;
171 }
172
173 /**
174 * \fn setDefaultProbeReqTemplate
175 * \brief set Default Probe Req Template tp the FW.
176 *
177 * set Default Probe Req Template tp the FW.
178 *
179 * \param hSiteMgr - Handle to site manager
180 * \return None
181 * \sa
182 */
setDefaultProbeReqTemplate(TI_HANDLE hSiteMgr)183 void setDefaultProbeReqTemplate (TI_HANDLE hSiteMgr)
184 {
185 siteMgr_t *pSiteMgr = (siteMgr_t *)hSiteMgr;
186 TSetTemplate tTemplateStruct;
187 probeReqTemplate_t tProbeReqTemplate;
188 TSsid tBroadcastSSID;
189
190 /*
191 * Setting probe request temapltes for both bands.
192 * allocating EMPTY 32 bytes for the SSID IE, to reserve space for different SSIDs the FW will set
193 */
194 tBroadcastSSID.len = MAX_SSID_LEN;
195 os_memorySet (pSiteMgr->hOs, &(tBroadcastSSID.str[ 0 ]), 0, MAX_SSID_LEN);
196 tTemplateStruct.ptr = (TI_UINT8 *)&tProbeReqTemplate;
197 tTemplateStruct.type = PROBE_REQUEST_TEMPLATE;
198 tTemplateStruct.eBand = RADIO_BAND_2_4_GHZ;
199 tTemplateStruct.uRateMask = RATE_MASK_UNSPECIFIED;
200 buildProbeReqTemplate (hSiteMgr, &tTemplateStruct, &tBroadcastSSID, RADIO_BAND_2_4_GHZ);
201 TWD_CmdTemplate (pSiteMgr->hTWD, &tTemplateStruct, NULL, NULL);
202 tTemplateStruct.eBand = RADIO_BAND_5_0_GHZ;
203 buildProbeReqTemplate (hSiteMgr, &tTemplateStruct, &tBroadcastSSID, RADIO_BAND_5_0_GHZ);
204 TWD_CmdTemplate (pSiteMgr->hTWD, &tTemplateStruct, NULL, NULL);
205 }
206
207 /************************************************************************
208 * buildProbeReqTemplate *
209 ************************************************************************
210 DESCRIPTION: This function build a probe request template to set to the HAL in the scan process.
211 performs the following:
212 - Build a template & set the template len, the template type is set in the site mgr
213
214 INPUT: pSiteMgr - Handle to site manager
215 pTemplate - Pointer to the template structure
216 pSsid - Desired SSID
217
218
219 OUTPUT:
220
221
222 RETURN: TI_OK
223
224 ************************************************************************/
buildProbeReqTemplate(siteMgr_t * pSiteMgr,TSetTemplate * pTemplate,TSsid * pSsid,ERadioBand radioBand)225 TI_STATUS buildProbeReqTemplate(siteMgr_t *pSiteMgr, TSetTemplate *pTemplate, TSsid *pSsid, ERadioBand radioBand)
226 {
227 paramInfo_t param;
228 char *pBuf;
229 int i;
230 probeReqTemplate_t *pBuffer = (probeReqTemplate_t *)pTemplate->ptr;
231 TI_UINT32 size;
232 dot11_RATES_t *pDot11Rates;
233 TI_UINT32 len = 0, ofdmIndex = 0;
234 TI_UINT32 suppRatesLen, extSuppRatesLen;
235 TI_UINT8 ratesBuf[DOT11_MAX_SUPPORTED_RATES];
236 TI_UINT8 WSCOuiIe[4] = { 0x00, 0x50, 0xf2, 0x04};
237 TI_UINT32 supportedRateMask,basicRateMask;
238 TI_UINT16 fc = DOT11_FC_PROBE_REQ;
239
240 os_memoryZero(pSiteMgr->hOs, pBuffer, sizeof(probeReqTemplate_t));
241
242 /*
243 * Header First
244 */
245 /* Set destination address */
246 for (i = 0; i < MAC_ADDR_LEN; i++)
247 pBuffer->hdr.DA[i] = 0xFF;
248
249 /* Set BSSID address */
250
251 for (i = 0; i < MAC_ADDR_LEN; i++)
252 pBuffer->hdr.BSSID[i] = 0xFF;
253
254
255 /* Build Source address */
256 param.paramType = CTRL_DATA_MAC_ADDRESS;
257 ctrlData_getParam(pSiteMgr->hCtrlData, ¶m);
258 MAC_COPY (pBuffer->hdr.SA, param.content.ctrlDataDeviceMacAddress);
259
260 COPY_WLAN_WORD(&pBuffer->hdr.fc, &fc); /* copy with endianess handling. */
261
262 size = sizeof(dot11_mgmtHeader_t);
263 pBuf = (char *)&(pBuffer->infoElements);
264
265 /*
266 * Informataion elements
267 */
268 /* SSID */
269 ((dot11_SSID_t *)(pBuf))->hdr[0] = DOT11_SSID_ELE_ID;
270 ((dot11_SSID_t *)(pBuf))->hdr[1] = pSsid->len;
271 os_memoryCopy(pSiteMgr->hOs, pBuf + sizeof(dot11_eleHdr_t), (void *)pSsid->str, pSsid->len);
272 size += sizeof(dot11_eleHdr_t) + pSsid->len;
273 pBuf += sizeof(dot11_eleHdr_t) + pSsid->len;
274
275 /* Rates */
276 pDot11Rates = (dot11_RATES_t *) pBuf;
277
278 /*
279 * Supported rates in probe request will always use the default rates for BG or A bands,
280 * regardless of the STA desired rates.
281 */
282 if (radioBand == RADIO_BAND_2_4_GHZ)
283 {
284 /* Basic rates: 1,2,5.5,11 */
285 basicRateMask = rate_BasicToDrvBitmap(pSiteMgr->pDesiredParams->siteMgrRegstryBasicRate[DOT11_G_MODE], TI_FALSE);
286 /* Extended: 6,9,12,18,24,36,48,54 */
287 supportedRateMask = rate_SupportedToDrvBitmap(pSiteMgr->pDesiredParams->siteMgrRegstrySuppRate[DOT11_G_MODE], TI_FALSE);
288 }
289 else if (radioBand == RADIO_BAND_5_0_GHZ)
290 { /* Basic rates: 6,12,24 */
291 basicRateMask = rate_BasicToDrvBitmap(pSiteMgr->pDesiredParams->siteMgrRegstryBasicRate[DOT11_A_MODE], TI_TRUE);
292 /* Extended: 9,18,24,36,48,54 */
293 supportedRateMask = rate_SupportedToDrvBitmap(pSiteMgr->pDesiredParams->siteMgrRegstrySuppRate[DOT11_A_MODE], TI_TRUE);
294 }
295 else
296 {
297 TRACE1(pSiteMgr->hReport, REPORT_SEVERITY_ERROR, "buildProbeReqTemplate, radioBand =%d ???\n",radioBand);
298 /* Use default and pray for the best */
299 /* Basic rates: 1,2,5.5,11 */
300 basicRateMask = rate_BasicToDrvBitmap(BASIC_RATE_SET_1_2_5_5_11, TI_FALSE);
301 /* Extended: 6,9,12,18,24,36,48,54 */
302 supportedRateMask = rate_SupportedToDrvBitmap(SUPPORTED_RATE_SET_UP_TO_54, TI_FALSE);
303 }
304
305 rate_DrvBitmapToNetStr (supportedRateMask, basicRateMask, ratesBuf, &len, &ofdmIndex);
306
307 TRACE5(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "buildProbeReqTemplate, supportedRateMask=0x%x, basicRateMask=0x%x, len=%d, ofdmIndex=%d, radioBand =%d\n", supportedRateMask,basicRateMask,len, ofdmIndex, radioBand);
308
309 if(radioBand == RADIO_BAND_5_0_GHZ ||
310 pSiteMgr->pDesiredParams->siteMgrUseDraftNum == DRAFT_5_AND_EARLIER ||
311 ofdmIndex == len)
312 {
313 pDot11Rates->hdr[0] = DOT11_SUPPORTED_RATES_ELE_ID;
314 pDot11Rates->hdr[1] = len;
315 os_memoryCopy(pSiteMgr->hOs, (void *)pDot11Rates->rates, ratesBuf, pDot11Rates->hdr[1]);
316 size += pDot11Rates->hdr[1] + sizeof(dot11_eleHdr_t);
317 pBuf += pDot11Rates->hdr[1] + sizeof(dot11_eleHdr_t);
318 }
319 else
320 {
321 pDot11Rates->hdr[0] = DOT11_SUPPORTED_RATES_ELE_ID;
322 pDot11Rates->hdr[1] = ofdmIndex;
323 os_memoryCopy(pSiteMgr->hOs, (void *)pDot11Rates->rates, ratesBuf, pDot11Rates->hdr[1]);
324 suppRatesLen = pDot11Rates->hdr[1] + sizeof(dot11_eleHdr_t);
325 pDot11Rates = (dot11_RATES_t *) (pBuf + suppRatesLen);
326 pDot11Rates->hdr[0] = DOT11_EXT_SUPPORTED_RATES_ELE_ID;
327 pDot11Rates->hdr[1] = len - ofdmIndex;
328 os_memoryCopy(pSiteMgr->hOs, (void *)pDot11Rates->rates, &ratesBuf[ofdmIndex], pDot11Rates->hdr[1]);
329 extSuppRatesLen = pDot11Rates->hdr[1] + sizeof(dot11_eleHdr_t);
330 size += suppRatesLen + extSuppRatesLen;
331 pBuf += suppRatesLen + extSuppRatesLen;
332 }
333
334
335 /* add HT capabilities IE */
336 StaCap_GetHtCapabilitiesIe (pSiteMgr->hStaCap, pBuf, &len);
337 size += len;
338 pBuf += len;
339
340
341 /* WiFi Simple Config */
342 if (pSiteMgr->includeWSCinProbeReq)
343 {
344 if(pSiteMgr->siteMgrWSCCurrMode != TIWLN_SIMPLE_CONFIG_OFF)
345 {
346 ((dot11_WSC_t *)(pBuf))->hdr[0] = DOT11_WSC_PARAM_ELE_ID;
347 ((dot11_WSC_t *)(pBuf))->hdr[1] = DOT11_WSC_PROBE_REQ_MAX_LENGTH + DOT11_OUI_LEN + 1;
348 pBuf += sizeof(dot11_eleHdr_t);
349 os_memoryCopy(pSiteMgr->hOs, pBuf, &WSCOuiIe, DOT11_OUI_LEN+2);
350 os_memoryCopy(pSiteMgr->hOs, pBuf + DOT11_OUI_LEN+1, &pSiteMgr->siteMgrWSCProbeReqParams, DOT11_WSC_PROBE_REQ_MAX_LENGTH - (DOT11_OUI_LEN+2));
351 size += sizeof(dot11_eleHdr_t) + DOT11_WSC_PROBE_REQ_MAX_LENGTH + DOT11_OUI_LEN + 1;
352 pBuf += sizeof(dot11_eleHdr_t) + DOT11_WSC_PROBE_REQ_MAX_LENGTH + DOT11_OUI_LEN + 1;
353 }
354 }
355 pTemplate->len = size;
356
357 return TI_OK;
358 }
359
360 /************************************************************************
361 * buildProbeRspTemplate *
362 ************************************************************************
363 DESCRIPTION: This function build a probe response template to set to the HAL
364 when joining an IBSS network.
365 performs the following:
366 - Build a template & set the template len, the template type is set in the site mgr
367 - The template is built based on the chosen site attributes
368
369 NOTE: This function is used to build beacon template too.
370 The site manager set the template type (after thos function returns) to beacon or probe response accordingly.
371
372 INPUT: pSiteMgr - Handle to site manager
373 pTemplate - Pointer to the template structure
374
375
376 OUTPUT:
377
378
379 RETURN: TI_OK
380
381 ************************************************************************/
buildProbeRspTemplate(siteMgr_t * pSiteMgr,TSetTemplate * pTemplate)382 TI_STATUS buildProbeRspTemplate(siteMgr_t *pSiteMgr, TSetTemplate *pTemplate)
383 {
384 paramInfo_t param;
385 TI_UINT8 *pBuf;
386 probeRspTemplate_t *pBuffer = (probeRspTemplate_t *)pTemplate->ptr;
387 siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
388 TI_INT32 i, j;
389 TI_UINT32 size;
390 dot11_RATES_t *pDot11Rates;
391 dot11_ERP_t *pdot11Erp;
392 TI_UINT32 len = 0, ofdmIndex = 0;
393 TI_BOOL extRates = TI_FALSE;
394 TI_BOOL useProtection,NonErpPresent,barkerPreambleType;
395 TCountry *pCountry = NULL;
396 TI_UINT8 ratesBuf[DOT11_MAX_SUPPORTED_RATES];
397 TI_UINT32 supportedRateMask,basicRateMask;
398 TI_UINT16 headerFC = DOT11_FC_PROBE_RESP;
399
400 os_memoryZero(pSiteMgr->hOs, pBuffer, sizeof(probeRspTemplate_t));
401
402
403 /*
404 * Build WLAN Header:
405 * ==================
406 */
407
408 /* Set destination address */
409 for (i = 0; i < MAC_ADDR_LEN; i++)
410 pBuffer->hdr.DA[i] = 0xFF;
411
412 /* Set BSSID address */
413 MAC_COPY (pBuffer->hdr.BSSID, pPrimarySite->bssid);
414
415 /* Build Source address */
416 param.paramType = CTRL_DATA_MAC_ADDRESS;
417 ctrlData_getParam(pSiteMgr->hCtrlData, ¶m);
418 MAC_COPY (pBuffer->hdr.SA, param.content.ctrlDataDeviceMacAddress);
419
420 COPY_WLAN_WORD(&pBuffer->hdr.fc, &headerFC);
421
422 size = sizeof(dot11_mgmtHeader_t);
423 pBuf = (TI_UINT8 *)pBuffer->timeStamp;
424 /*
425 * Fixed Fields
426 */
427 /* we skip the timestamp field */
428 size += TIME_STAMP_LEN;
429 pBuf += TIME_STAMP_LEN;
430
431 /* Beacon interval */
432 COPY_WLAN_WORD(pBuf, &pPrimarySite->beaconInterval);
433 size += FIX_FIELD_LEN;
434 pBuf += FIX_FIELD_LEN;
435
436 /* capabilities */
437 COPY_WLAN_WORD(pBuf, &pPrimarySite->capabilities);
438 size += FIX_FIELD_LEN;
439 pBuf += FIX_FIELD_LEN;
440
441 /*
442 * Build Informataion Elements:
443 * ============================
444 */
445
446 /* SSID IE */
447 ((dot11_SSID_t *)(pBuf))->hdr[0] = DOT11_SSID_ELE_ID;
448 ((dot11_SSID_t *)(pBuf))->hdr[1] = pPrimarySite->ssid.len;
449 os_memoryCopy(pSiteMgr->hOs, pBuf + sizeof(dot11_eleHdr_t), (void *)pPrimarySite->ssid.str, pPrimarySite->ssid.len);
450 size += sizeof(dot11_eleHdr_t) + pPrimarySite->ssid.len;
451 pBuf += sizeof(dot11_eleHdr_t) + pPrimarySite->ssid.len;
452
453
454 /* Rates IE */
455
456 pDot11Rates = (dot11_RATES_t *) pBuf;
457
458 if (pPrimarySite->channel == SPECIAL_BG_CHANNEL)
459 {
460 supportedRateMask = rate_GetDrvBitmapForDefaultSupporteSet ();
461 basicRateMask = rate_GetDrvBitmapForDefaultBasicSet ();
462 }
463 else
464 {
465 supportedRateMask = pSiteMgr->pDesiredParams->siteMgrMatchedSuppRateMask;
466 basicRateMask = pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask;
467 }
468
469 rate_DrvBitmapToNetStr (supportedRateMask, basicRateMask, ratesBuf, &len, &ofdmIndex);
470
471 if(pSiteMgr->siteMgrOperationalMode != DOT11_G_MODE ||
472 pSiteMgr->pDesiredParams->siteMgrUseDraftNum == DRAFT_5_AND_EARLIER ||
473 ofdmIndex == len)
474 {
475 pDot11Rates->hdr[0] = DOT11_SUPPORTED_RATES_ELE_ID;
476 pDot11Rates->hdr[1] = len;
477 os_memoryCopy(pSiteMgr->hOs, (void *)pDot11Rates->rates, ratesBuf, pDot11Rates->hdr[1]);
478 size += pDot11Rates->hdr[1] + sizeof(dot11_eleHdr_t);
479 pBuf += pDot11Rates->hdr[1] + sizeof(dot11_eleHdr_t);
480 }
481 else
482 {
483 pDot11Rates->hdr[0] = DOT11_SUPPORTED_RATES_ELE_ID;
484 pDot11Rates->hdr[1] = ofdmIndex;
485 os_memoryCopy(pSiteMgr->hOs, (void *)pDot11Rates->rates, ratesBuf, pDot11Rates->hdr[1]);
486 size += pDot11Rates->hdr[1] + sizeof(dot11_eleHdr_t);
487 pBuf += pDot11Rates->hdr[1] + sizeof(dot11_eleHdr_t);
488 extRates = TI_TRUE;
489 }
490
491 /* DS IE */
492 ((dot11_DS_PARAMS_t *)(pBuf))->hdr[0] = DOT11_DS_PARAMS_ELE_ID;
493 ((dot11_DS_PARAMS_t *)(pBuf))->hdr[1] = DOT11_DS_PARAMS_ELE_LEN;
494 ((dot11_DS_PARAMS_t *)(pBuf))->currChannel = pPrimarySite->channel;
495 size += sizeof(dot11_eleHdr_t) + DOT11_DS_PARAMS_ELE_LEN;
496 pBuf += sizeof(dot11_eleHdr_t) + DOT11_DS_PARAMS_ELE_LEN;
497
498 /* IBSS IE */
499 ((dot11_IBSS_PARAMS_t *)(pBuf))->hdr[0] = DOT11_IBSS_PARAMS_ELE_ID;
500 ((dot11_IBSS_PARAMS_t *)(pBuf))->hdr[1] = DOT11_IBSS_PARAMS_ELE_LEN;
501 COPY_WLAN_WORD(&((dot11_IBSS_PARAMS_t *)(pBuf))->atimWindow, &pPrimarySite->atimWindow);
502 size += sizeof(dot11_eleHdr_t) + DOT11_IBSS_PARAMS_ELE_LEN;
503 pBuf += sizeof(dot11_eleHdr_t) + DOT11_IBSS_PARAMS_ELE_LEN;
504
505 /* Country IE */
506 param.paramType = REGULATORY_DOMAIN_ENABLED_PARAM;
507 regulatoryDomain_getParam(pSiteMgr->hRegulatoryDomain,¶m);
508
509 if( param.content.regulatoryDomainEnabled == TI_TRUE )
510 {
511 /* get country IE */
512 param.paramType = REGULATORY_DOMAIN_COUNTRY_PARAM;
513 regulatoryDomain_getParam(pSiteMgr->hRegulatoryDomain, ¶m);
514 pCountry = param.content.pCountry;
515
516 /* Check if a country IE was found */
517 if(pCountry != NULL)
518 {
519 *pBuf = DOT11_COUNTRY_ELE_ID;
520 pBuf++;
521 size++;
522 *pBuf = (TI_UINT8)(pCountry->len);
523 pBuf++;
524 size++;
525
526 /* Note: The country structure is not byte-aligned so it is copied as follows to ensure
527 that there are no gaps in the output structure (pBuf). */
528
529 os_memoryCopy(pSiteMgr->hOs, pBuf , &pCountry->countryIE.CountryString, DOT11_COUNTRY_STRING_LEN);
530 pBuf += DOT11_COUNTRY_STRING_LEN;
531 size += DOT11_COUNTRY_STRING_LEN;
532
533 /* Loop on all tripletChannels. Each item has three fields ('i' counts rows and 'j' counts bytes). */
534 for (i = 0, j = 0; j < (pCountry->len - DOT11_COUNTRY_STRING_LEN); i++, j+=3)
535 {
536 *(pBuf + j ) = pCountry->countryIE.tripletChannels[i].firstChannelNumber;
537 *(pBuf + j + 1) = pCountry->countryIE.tripletChannels[i].maxTxPowerLevel;
538 *(pBuf + j + 2) = pCountry->countryIE.tripletChannels[i].numberOfChannels;
539 }
540
541 pBuf += (pCountry->len - DOT11_COUNTRY_STRING_LEN);
542 size += (pCountry->len - DOT11_COUNTRY_STRING_LEN);
543 }
544 }
545
546 /*ERP IE*/
547 siteMgr_IsERP_Needed(pSiteMgr,&useProtection,&NonErpPresent,&barkerPreambleType);
548 if (useProtection || NonErpPresent || barkerPreambleType)
549 {
550 pdot11Erp = (dot11_ERP_t *) pBuf;
551 pdot11Erp->hdr[0] = DOT11_ERP_IE_ID;
552 pdot11Erp->hdr[1] = 1;
553 pdot11Erp->ctrl = 0;
554 if (NonErpPresent)
555 pdot11Erp->ctrl |= ERP_IE_NON_ERP_PRESENT_MASK;
556 if (useProtection)
557 pdot11Erp->ctrl |= ERP_IE_USE_PROTECTION_MASK;
558 if (barkerPreambleType)
559 pdot11Erp->ctrl |= ERP_IE_BARKER_PREAMBLE_MODE_MASK;
560 size += pdot11Erp->hdr[1] + sizeof(dot11_eleHdr_t);
561 pBuf += pdot11Erp->hdr[1] + sizeof(dot11_eleHdr_t);
562
563 }
564
565
566 /* Extended supported rates IE */
567 if(extRates)
568 {
569 pDot11Rates = (dot11_RATES_t *) pBuf;
570 pDot11Rates->hdr[0] = DOT11_EXT_SUPPORTED_RATES_ELE_ID;
571 pDot11Rates->hdr[1] = len - ofdmIndex;
572 os_memoryCopy(pSiteMgr->hOs, (void *)pDot11Rates->rates, &ratesBuf[ofdmIndex], pDot11Rates->hdr[1]);
573 size += pDot11Rates->hdr[1] + sizeof(dot11_eleHdr_t);
574 pBuf += pDot11Rates->hdr[1] + sizeof(dot11_eleHdr_t);
575 }
576
577 /* no need to insert RSN information elements */
578
579 pTemplate->len = size;
580 TRACE1(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "Probe response template len = %d\n",size);
581
582 return TI_OK;
583 }
584
585 /************************************************************************
586 * buildPsPollTemplate *
587 ************************************************************************
588 DESCRIPTION: This function build a ps poll template
589 performs the following:
590 - Build a template & set the template len, the template type is set in the site mgr
591
592 INPUT: pSiteMgr - Handle to site manager
593 pTemplate - Pointer to the template structure
594 pSsid - Desired SSID
595
596 OUTPUT:
597
598 RETURN: TI_OK
599 ************************************************************************/
buildPsPollTemplate(siteMgr_t * pSiteMgr,TSetTemplate * pTemplate)600 TI_STATUS buildPsPollTemplate(siteMgr_t *pSiteMgr, TSetTemplate *pTemplate)
601 {
602 paramInfo_t param;
603 TTwdParamInfo tTwdParam;
604 TI_UINT32 size;
605 psPollTemplate_t *pBuffer = (psPollTemplate_t *)pTemplate->ptr;
606 siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
607 TI_UINT16 fc;
608
609 os_memoryZero(pSiteMgr->hOs, pBuffer, sizeof(psPollTemplate_t));
610
611 /*
612 * Header First
613 */
614
615 /* Set BSSID address */
616 MAC_COPY (pBuffer->hdr.BSSID, pPrimarySite->bssid);
617
618 /* Build Source address */
619 param.paramType = CTRL_DATA_MAC_ADDRESS;
620 ctrlData_getParam(pSiteMgr->hCtrlData, ¶m);
621 MAC_COPY (pBuffer->hdr.TA, param.content.ctrlDataDeviceMacAddress);
622
623 /*
624 ** Building the Frame Control word (16 bits)
625 ** ---------------------------------------------
626 ** Type = Control
627 ** SubType = Power Save (PS) POLL, */
628 fc = DOT11_FC_PS_POLL;
629 /*
630 ** setting the Power Management bit in the Frame control field
631 ** to be "Power Save mode"
632 */
633 fc |= (0x1 << DOT11_FC_PWR_MGMT_SHIFT);
634
635 COPY_WLAN_WORD(&pBuffer->hdr.fc, &fc); /* copy with endianess handling. */
636
637 /*
638 ** Association ID
639 ** -----------------
640 */
641 tTwdParam.paramType = TWD_AID_PARAM_ID;
642 TWD_GetParam (pSiteMgr->hTWD, &tTwdParam);
643
644 /* AID should have its two MSB bit Set to "1"*/
645 pBuffer->hdr.AID = tTwdParam.content.halCtrlAid | 0xC000;
646
647 size = sizeof(dot11_PsPollFrameHeader_t);
648
649 pTemplate->len = size;
650
651 return TI_OK;
652 }
653
654
655 /************************************************************************
656 * buildQosNullDataTemplate *
657 ************************************************************************
658 DESCRIPTION: This function build a qos null data template
659 performs the following:
660 - Build a template & set the template len, the template type is set in the site mgr
661
662 INPUT: pSiteMgr - Handle to site manager
663 pTemplate - Pointer to the template structure
664 pSsid - Desired SSID
665
666 OUTPUT:
667
668 RETURN: TI_OK
669 ************************************************************************/
buildQosNullDataTemplate(siteMgr_t * pSiteMgr,TSetTemplate * pTemplate,TI_UINT8 userPriority)670 TI_STATUS buildQosNullDataTemplate(siteMgr_t *pSiteMgr, TSetTemplate *pTemplate, TI_UINT8 userPriority)
671 {
672 paramInfo_t param;
673 TI_UINT32 size;
674 QosNullDataTemplate_t *pBuffer = (QosNullDataTemplate_t *)pTemplate->ptr;
675 siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
676 TI_UINT16 fc;
677 TI_UINT16 qosControl;
678
679 os_memoryZero(pSiteMgr->hOs, pBuffer, sizeof(QosNullDataTemplate_t));
680
681 /*
682 * Header First
683 */
684 /* Set destination address */
685 if (pPrimarySite)
686 {
687 MAC_COPY (pBuffer->hdr.address1, pPrimarySite->bssid);
688
689 /* Set BSSID address */
690 MAC_COPY (pBuffer->hdr.address3, pPrimarySite->bssid);
691 }
692 else
693 {
694 TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "No Primary site so cannot fill QosNullData template\n");
695 }
696
697 /* Build Source address */
698 param.paramType = CTRL_DATA_MAC_ADDRESS;
699 ctrlData_getParam(pSiteMgr->hCtrlData, ¶m);
700 MAC_COPY (pBuffer->hdr.address2, param.content.ctrlDataDeviceMacAddress);
701
702 fc = DOT11_FC_DATA_NULL_QOS | (1 << DOT11_FC_TO_DS_SHIFT);
703 COPY_WLAN_WORD(&pBuffer->hdr.fc, &fc); /* copy with endianess handling. */
704
705 qosControl = (TI_UINT16)userPriority;
706 qosControl <<= QOS_CONTROL_UP_SHIFT;
707 COPY_WLAN_WORD(&pBuffer->hdr.qosControl, &qosControl); /* copy with endianess handling. */
708
709 size = WLAN_QOS_HDR_LEN;
710
711 pTemplate->len = size;
712
713 return TI_OK;
714 }
715
716
717
718
719
720