staging: wilc1000: delete unused global variables.
[deliverable/linux.git] / drivers / staging / wilc1000 / coreconfigurator.c
1
2 /*!
3 * @file coreconfigurator.c
4 * @brief
5 * @author
6 * @sa coreconfigurator.h
7 * @date 1 Mar 2012
8 * @version 1.0
9 */
10
11
12 /*****************************************************************************/
13 /* File Includes */
14 /*****************************************************************************/
15 #include "coreconfigurator.h"
16 /*****************************************************************************/
17 /* Constants */
18 /*****************************************************************************/
19 #define INLINE static __inline
20 #define TAG_PARAM_OFFSET (MAC_HDR_LEN + TIME_STAMP_LEN + \
21 BEACON_INTERVAL_LEN + CAP_INFO_LEN)
22
23 /*****************************************************************************/
24 /* Function Macros */
25 /*****************************************************************************/
26
27
28 /*****************************************************************************/
29 /* Type Definitions */
30 /*****************************************************************************/
31
32 /* Basic Frame Type Codes (2-bit) */
33 typedef enum {
34 FRAME_TYPE_CONTROL = 0x04,
35 FRAME_TYPE_DATA = 0x08,
36 FRAME_TYPE_MANAGEMENT = 0x00,
37 FRAME_TYPE_RESERVED = 0x0C,
38 FRAME_TYPE_FORCE_32BIT = 0xFFFFFFFF
39 } tenuBasicFrmType;
40
41 /* Frame Type and Subtype Codes (6-bit) */
42 typedef enum {
43 ASSOC_REQ = 0x00,
44 ASSOC_RSP = 0x10,
45 REASSOC_REQ = 0x20,
46 REASSOC_RSP = 0x30,
47 PROBE_REQ = 0x40,
48 PROBE_RSP = 0x50,
49 BEACON = 0x80,
50 ATIM = 0x90,
51 DISASOC = 0xA0,
52 AUTH = 0xB0,
53 DEAUTH = 0xC0,
54 ACTION = 0xD0,
55 PS_POLL = 0xA4,
56 RTS = 0xB4,
57 CTS = 0xC4,
58 ACK = 0xD4,
59 CFEND = 0xE4,
60 CFEND_ACK = 0xF4,
61 DATA = 0x08,
62 DATA_ACK = 0x18,
63 DATA_POLL = 0x28,
64 DATA_POLL_ACK = 0x38,
65 NULL_FRAME = 0x48,
66 CFACK = 0x58,
67 CFPOLL = 0x68,
68 CFPOLL_ACK = 0x78,
69 QOS_DATA = 0x88,
70 QOS_DATA_ACK = 0x98,
71 QOS_DATA_POLL = 0xA8,
72 QOS_DATA_POLL_ACK = 0xB8,
73 QOS_NULL_FRAME = 0xC8,
74 QOS_CFPOLL = 0xE8,
75 QOS_CFPOLL_ACK = 0xF8,
76 BLOCKACK_REQ = 0x84,
77 BLOCKACK = 0x94,
78 FRAME_SUBTYPE_FORCE_32BIT = 0xFFFFFFFF
79 } tenuFrmSubtype;
80
81 /* Element ID of various Information Elements */
82 typedef enum {
83 ISSID = 0, /* Service Set Identifier */
84 ISUPRATES = 1, /* Supported Rates */
85 IFHPARMS = 2, /* FH parameter set */
86 IDSPARMS = 3, /* DS parameter set */
87 ICFPARMS = 4, /* CF parameter set */
88 ITIM = 5, /* Traffic Information Map */
89 IIBPARMS = 6, /* IBSS parameter set */
90 ICOUNTRY = 7, /* Country element */
91 IEDCAPARAMS = 12, /* EDCA parameter set */
92 ITSPEC = 13, /* Traffic Specification */
93 ITCLAS = 14, /* Traffic Classification */
94 ISCHED = 15, /* Schedule */
95 ICTEXT = 16, /* Challenge Text */
96 IPOWERCONSTRAINT = 32, /* Power Constraint */
97 IPOWERCAPABILITY = 33, /* Power Capability */
98 ITPCREQUEST = 34, /* TPC Request */
99 ITPCREPORT = 35, /* TPC Report */
100 ISUPCHANNEL = 36, /* Supported channel list */
101 ICHSWANNOUNC = 37, /* Channel Switch Announcement */
102 IMEASUREMENTREQUEST = 38, /* Measurement request */
103 IMEASUREMENTREPORT = 39, /* Measurement report */
104 IQUIET = 40, /* Quiet element Info */
105 IIBSSDFS = 41, /* IBSS DFS */
106 IERPINFO = 42, /* ERP Information */
107 ITSDELAY = 43, /* TS Delay */
108 ITCLASPROCESS = 44, /* TCLAS Processing */
109 IHTCAP = 45, /* HT Capabilities */
110 IQOSCAP = 46, /* QoS Capability */
111 IRSNELEMENT = 48, /* RSN Information Element */
112 IEXSUPRATES = 50, /* Extended Supported Rates */
113 IEXCHSWANNOUNC = 60, /* Extended Ch Switch Announcement*/
114 IHTOPERATION = 61, /* HT Information */
115 ISECCHOFF = 62, /* Secondary Channel Offeset */
116 I2040COEX = 72, /* 20/40 Coexistence IE */
117 I2040INTOLCHREPORT = 73, /* 20/40 Intolerant channel report*/
118 IOBSSSCAN = 74, /* OBSS Scan parameters */
119 IEXTCAP = 127, /* Extended capability */
120 IWMM = 221, /* WMM parameters */
121 IWPAELEMENT = 221, /* WPA Information Element */
122 INFOELEM_ID_FORCE_32BIT = 0xFFFFFFFF
123 } tenuInfoElemID;
124
125
126 typedef struct {
127 char *pcRespBuffer;
128 s32 s32MaxRespBuffLen;
129 s32 s32BytesRead;
130 bool bRespRequired;
131 } tstrConfigPktInfo;
132
133
134
135 /*****************************************************************************/
136 /* Extern Variable Declarations */
137 /*****************************************************************************/
138
139 /*****************************************************************************/
140 /* Global Variables */
141 /*****************************************************************************/
142 /* WID Switches */
143 static tstrWID gastrWIDs[] = {
144 {WID_FIRMWARE_VERSION, WID_STR},
145 {WID_PHY_VERSION, WID_STR},
146 {WID_HARDWARE_VERSION, WID_STR},
147 {WID_BSS_TYPE, WID_CHAR},
148 {WID_QOS_ENABLE, WID_CHAR},
149 {WID_11I_MODE, WID_CHAR},
150 {WID_CURRENT_TX_RATE, WID_CHAR},
151 {WID_LINKSPEED, WID_CHAR},
152 {WID_RTS_THRESHOLD, WID_SHORT},
153 {WID_FRAG_THRESHOLD, WID_SHORT},
154 {WID_SSID, WID_STR},
155 {WID_BSSID, WID_ADR},
156 {WID_BEACON_INTERVAL, WID_SHORT},
157 {WID_POWER_MANAGEMENT, WID_CHAR},
158 {WID_LISTEN_INTERVAL, WID_CHAR},
159 {WID_DTIM_PERIOD, WID_CHAR},
160 {WID_CURRENT_CHANNEL, WID_CHAR},
161 {WID_TX_POWER_LEVEL_11A, WID_CHAR},
162 {WID_TX_POWER_LEVEL_11B, WID_CHAR},
163 {WID_PREAMBLE, WID_CHAR},
164 {WID_11G_OPERATING_MODE, WID_CHAR},
165 {WID_MAC_ADDR, WID_ADR},
166 {WID_IP_ADDRESS, WID_ADR},
167 {WID_ACK_POLICY, WID_CHAR},
168 {WID_PHY_ACTIVE_REG, WID_CHAR},
169 {WID_AUTH_TYPE, WID_CHAR},
170 {WID_REKEY_POLICY, WID_CHAR},
171 {WID_REKEY_PERIOD, WID_INT},
172 {WID_REKEY_PACKET_COUNT, WID_INT},
173 {WID_11I_PSK, WID_STR},
174 {WID_1X_KEY, WID_STR},
175 {WID_1X_SERV_ADDR, WID_IP},
176 {WID_SUPP_USERNAME, WID_STR},
177 {WID_SUPP_PASSWORD, WID_STR},
178 {WID_USER_CONTROL_ON_TX_POWER, WID_CHAR},
179 {WID_MEMORY_ADDRESS, WID_INT},
180 {WID_MEMORY_ACCESS_32BIT, WID_INT},
181 {WID_MEMORY_ACCESS_16BIT, WID_SHORT},
182 {WID_MEMORY_ACCESS_8BIT, WID_CHAR},
183 {WID_SITE_SURVEY_RESULTS, WID_STR},
184 {WID_PMKID_INFO, WID_STR},
185 {WID_ASSOC_RES_INFO, WID_STR},
186 {WID_MANUFACTURER, WID_STR}, /* 4 Wids added for the CAPI tool*/
187 {WID_MODEL_NAME, WID_STR},
188 {WID_MODEL_NUM, WID_STR},
189 {WID_DEVICE_NAME, WID_STR},
190 {WID_SSID_PROBE_REQ, WID_STR},
191
192 #ifdef MAC_802_11N
193 {WID_11N_ENABLE, WID_CHAR},
194 {WID_11N_CURRENT_TX_MCS, WID_CHAR},
195 {WID_TX_POWER_LEVEL_11N, WID_CHAR},
196 {WID_11N_OPERATING_MODE, WID_CHAR},
197 {WID_11N_SMPS_MODE, WID_CHAR},
198 {WID_11N_PROT_MECH, WID_CHAR},
199 {WID_11N_ERP_PROT_TYPE, WID_CHAR},
200 {WID_11N_HT_PROT_TYPE, WID_CHAR},
201 {WID_11N_PHY_ACTIVE_REG_VAL, WID_INT},
202 {WID_11N_PRINT_STATS, WID_CHAR},
203 {WID_11N_AUTORATE_TABLE, WID_BIN_DATA},
204 {WID_HOST_CONFIG_IF_TYPE, WID_CHAR},
205 {WID_HOST_DATA_IF_TYPE, WID_CHAR},
206 {WID_11N_SIG_QUAL_VAL, WID_SHORT},
207 {WID_11N_IMMEDIATE_BA_ENABLED, WID_CHAR},
208 {WID_11N_TXOP_PROT_DISABLE, WID_CHAR},
209 {WID_11N_SHORT_GI_20MHZ_ENABLE, WID_CHAR},
210 {WID_SHORT_SLOT_ALLOWED, WID_CHAR},
211 {WID_11W_ENABLE, WID_CHAR},
212 {WID_11W_MGMT_PROT_REQ, WID_CHAR},
213 {WID_2040_ENABLE, WID_CHAR},
214 {WID_2040_COEXISTENCE, WID_CHAR},
215 {WID_USER_SEC_CHANNEL_OFFSET, WID_CHAR},
216 {WID_2040_CURR_CHANNEL_OFFSET, WID_CHAR},
217 {WID_2040_40MHZ_INTOLERANT, WID_CHAR},
218 {WID_HUT_RESTART, WID_CHAR},
219 {WID_HUT_NUM_TX_PKTS, WID_INT},
220 {WID_HUT_FRAME_LEN, WID_SHORT},
221 {WID_HUT_TX_FORMAT, WID_CHAR},
222 {WID_HUT_BANDWIDTH, WID_CHAR},
223 {WID_HUT_OP_BAND, WID_CHAR},
224 {WID_HUT_STBC, WID_CHAR},
225 {WID_HUT_ESS, WID_CHAR},
226 {WID_HUT_ANTSET, WID_CHAR},
227 {WID_HUT_HT_OP_MODE, WID_CHAR},
228 {WID_HUT_RIFS_MODE, WID_CHAR},
229 {WID_HUT_SMOOTHING_REC, WID_CHAR},
230 {WID_HUT_SOUNDING_PKT, WID_CHAR},
231 {WID_HUT_HT_CODING, WID_CHAR},
232 {WID_HUT_TEST_DIR, WID_CHAR},
233 {WID_HUT_TXOP_LIMIT, WID_SHORT},
234 {WID_HUT_DEST_ADDR, WID_ADR},
235 {WID_HUT_TX_PATTERN, WID_BIN_DATA},
236 {WID_HUT_TX_TIME_TAKEN, WID_INT},
237 {WID_HUT_PHY_TEST_MODE, WID_CHAR},
238 {WID_HUT_PHY_TEST_RATE_HI, WID_CHAR},
239 {WID_HUT_PHY_TEST_RATE_LO, WID_CHAR},
240 {WID_HUT_TX_TEST_TIME, WID_INT},
241 {WID_HUT_LOG_INTERVAL, WID_INT},
242 {WID_HUT_DISABLE_RXQ_REPLENISH, WID_CHAR},
243 {WID_HUT_TEST_ID, WID_STR},
244 {WID_HUT_KEY_ORIGIN, WID_CHAR},
245 {WID_HUT_BCST_PERCENT, WID_CHAR},
246 {WID_HUT_GROUP_CIPHER_TYPE, WID_CHAR},
247 {WID_HUT_STATS, WID_BIN_DATA},
248 {WID_HUT_TSF_TEST_MODE, WID_CHAR},
249 {WID_HUT_SIG_QUAL_AVG, WID_SHORT},
250 {WID_HUT_SIG_QUAL_AVG_CNT, WID_SHORT},
251 {WID_HUT_TSSI_VALUE, WID_CHAR},
252 {WID_HUT_MGMT_PERCENT, WID_CHAR},
253 {WID_HUT_MGMT_BCST_PERCENT, WID_CHAR},
254 {WID_HUT_MGMT_ALLOW_HT, WID_CHAR},
255 {WID_HUT_UC_MGMT_TYPE, WID_CHAR},
256 {WID_HUT_BC_MGMT_TYPE, WID_CHAR},
257 {WID_HUT_UC_MGMT_FRAME_LEN, WID_SHORT},
258 {WID_HUT_BC_MGMT_FRAME_LEN, WID_SHORT},
259 {WID_HUT_11W_MFP_REQUIRED_TX, WID_CHAR},
260 {WID_HUT_11W_MFP_PEER_CAPABLE, WID_CHAR},
261 {WID_HUT_11W_TX_IGTK_ID, WID_CHAR},
262 {WID_HUT_FC_TXOP_MOD, WID_CHAR},
263 {WID_HUT_FC_PROT_TYPE, WID_CHAR},
264 {WID_HUT_SEC_CCA_ASSERT, WID_CHAR},
265 #endif /* MAC_802_11N */
266 };
267
268 u16 g_num_total_switches = (sizeof(gastrWIDs) / sizeof(tstrWID));
269 /*****************************************************************************/
270 /* Static Function Declarations */
271 /*****************************************************************************/
272
273
274
275 /*****************************************************************************/
276 /* Functions */
277 /*****************************************************************************/
278
279 /* This function extracts the beacon period field from the beacon or probe */
280 /* response frame. */
281 INLINE u16 get_beacon_period(u8 *data)
282 {
283 u16 bcn_per = 0;
284
285 bcn_per = data[0];
286 bcn_per |= (data[1] << 8);
287
288 return bcn_per;
289 }
290
291 INLINE u32 get_beacon_timestamp_lo(u8 *data)
292 {
293 u32 time_stamp = 0;
294 u32 index = MAC_HDR_LEN;
295
296 time_stamp |= data[index++];
297 time_stamp |= (data[index++] << 8);
298 time_stamp |= (data[index++] << 16);
299 time_stamp |= (data[index] << 24);
300
301 return time_stamp;
302 }
303
304 INLINE u32 get_beacon_timestamp_hi(u8 *data)
305 {
306 u32 time_stamp = 0;
307 u32 index = (MAC_HDR_LEN + 4);
308
309 time_stamp |= data[index++];
310 time_stamp |= (data[index++] << 8);
311 time_stamp |= (data[index++] << 16);
312 time_stamp |= (data[index] << 24);
313
314 return time_stamp;
315 }
316
317 /* This function extracts the 'frame type and sub type' bits from the MAC */
318 /* header of the input frame. */
319 /* Returns the value in the LSB of the returned value. */
320 INLINE tenuFrmSubtype get_sub_type(u8 *header)
321 {
322 return ((tenuFrmSubtype)(header[0] & 0xFC));
323 }
324
325 /* This function extracts the 'to ds' bit from the MAC header of the input */
326 /* frame. */
327 /* Returns the value in the LSB of the returned value. */
328 INLINE u8 get_to_ds(u8 *header)
329 {
330 return (header[1] & 0x01);
331 }
332
333 /* This function extracts the 'from ds' bit from the MAC header of the input */
334 /* frame. */
335 /* Returns the value in the LSB of the returned value. */
336 INLINE u8 get_from_ds(u8 *header)
337 {
338 return ((header[1] & 0x02) >> 1);
339 }
340
341 /* This function extracts the MAC Address in 'address1' field of the MAC */
342 /* header and updates the MAC Address in the allocated 'addr' variable. */
343 INLINE void get_address1(u8 *pu8msa, u8 *addr)
344 {
345 memcpy(addr, pu8msa + 4, 6);
346 }
347
348 /* This function extracts the MAC Address in 'address2' field of the MAC */
349 /* header and updates the MAC Address in the allocated 'addr' variable. */
350 INLINE void get_address2(u8 *pu8msa, u8 *addr)
351 {
352 memcpy(addr, pu8msa + 10, 6);
353 }
354
355 /* This function extracts the MAC Address in 'address3' field of the MAC */
356 /* header and updates the MAC Address in the allocated 'addr' variable. */
357 INLINE void get_address3(u8 *pu8msa, u8 *addr)
358 {
359 memcpy(addr, pu8msa + 16, 6);
360 }
361
362 /* This function extracts the BSSID from the incoming WLAN packet based on */
363 /* the 'from ds' bit, and updates the MAC Address in the allocated 'addr' */
364 /* variable. */
365 INLINE void get_BSSID(u8 *data, u8 *bssid)
366 {
367 if (get_from_ds(data) == 1)
368 get_address2(data, bssid);
369 else if (get_to_ds(data) == 1)
370 get_address1(data, bssid);
371 else
372 get_address3(data, bssid);
373 }
374
375 /* This function extracts the SSID from a beacon/probe response frame */
376 INLINE void get_ssid(u8 *data, u8 *ssid, u8 *p_ssid_len)
377 {
378 u8 len = 0;
379 u8 i = 0;
380 u8 j = 0;
381
382 len = data[MAC_HDR_LEN + TIME_STAMP_LEN + BEACON_INTERVAL_LEN +
383 CAP_INFO_LEN + 1];
384 j = MAC_HDR_LEN + TIME_STAMP_LEN + BEACON_INTERVAL_LEN +
385 CAP_INFO_LEN + 2;
386
387 /* If the SSID length field is set wrongly to a value greater than the */
388 /* allowed maximum SSID length limit, reset the length to 0 */
389 if (len >= MAX_SSID_LEN)
390 len = 0;
391
392 for (i = 0; i < len; i++, j++)
393 ssid[i] = data[j];
394
395 ssid[len] = '\0';
396
397 *p_ssid_len = len;
398 }
399
400 /* This function extracts the capability info field from the beacon or probe */
401 /* response frame. */
402 INLINE u16 get_cap_info(u8 *data)
403 {
404 u16 cap_info = 0;
405 u16 index = MAC_HDR_LEN;
406 tenuFrmSubtype st;
407
408 st = get_sub_type(data);
409
410 /* Location of the Capability field is different for Beacon and */
411 /* Association frames. */
412 if ((st == BEACON) || (st == PROBE_RSP))
413 index += TIME_STAMP_LEN + BEACON_INTERVAL_LEN;
414
415 cap_info = data[index];
416 cap_info |= (data[index + 1] << 8);
417
418 return cap_info;
419 }
420
421 /* This function extracts the capability info field from the Association */
422 /* response frame. */
423 INLINE u16 get_assoc_resp_cap_info(u8 *data)
424 {
425 u16 cap_info = 0;
426
427 cap_info = data[0];
428 cap_info |= (data[1] << 8);
429
430 return cap_info;
431 }
432
433 /* This funcion extracts the association status code from the incoming */
434 /* association response frame and returns association status code */
435 INLINE u16 get_asoc_status(u8 *data)
436 {
437 u16 asoc_status = 0;
438
439 asoc_status = data[3];
440 asoc_status = (asoc_status << 8) | data[2];
441
442 return asoc_status;
443 }
444
445 /* This function extracts association ID from the incoming association */
446 /* response frame */
447 INLINE u16 get_asoc_id(u8 *data)
448 {
449 u16 asoc_id = 0;
450
451 asoc_id = data[4];
452 asoc_id |= (data[5] << 8);
453
454 return asoc_id;
455 }
456
457 /**
458 * @brief initializes the Core Configurator
459 * @details
460 * @return Error code indicating success/failure
461 * @note
462 * @author mabubakr
463 * @date 1 Mar 2012
464 * @version 1.0
465 */
466
467 s32 CoreConfiguratorInit(void)
468 {
469 s32 s32Error = WILC_SUCCESS;
470
471 PRINT_D(CORECONFIG_DBG, "CoreConfiguratorInit()\n");
472
473 return s32Error;
474 }
475
476 u8 *get_tim_elm(u8 *pu8msa, u16 u16RxLen, u16 u16TagParamOffset)
477 {
478 u16 u16index = 0;
479
480 /*************************************************************************/
481 /* Beacon Frame - Frame Body */
482 /* --------------------------------------------------------------------- */
483 /* |Timestamp |BeaconInt |CapInfo |SSID |SupRates |DSParSet |TIM elm | */
484 /* --------------------------------------------------------------------- */
485 /* |8 |2 |2 |2-34 |3-10 |3 |4-256 | */
486 /* --------------------------------------------------------------------- */
487 /* */
488 /*************************************************************************/
489
490 u16index = u16TagParamOffset;
491
492 /* Search for the TIM Element Field and return if the element is found */
493 while (u16index < (u16RxLen - FCS_LEN)) {
494 if (pu8msa[u16index] == ITIM)
495 return &pu8msa[u16index];
496 else
497 u16index += (IE_HDR_LEN + pu8msa[u16index + 1]);
498 }
499
500 return NULL;
501 }
502
503 /* This function gets the current channel information from
504 * the 802.11n beacon/probe response frame */
505 u8 get_current_channel_802_11n(u8 *pu8msa, u16 u16RxLen)
506 {
507 u16 index;
508
509 index = TAG_PARAM_OFFSET;
510 while (index < (u16RxLen - FCS_LEN)) {
511 if (pu8msa[index] == IDSPARMS)
512 return pu8msa[index + 2];
513 else
514 /* Increment index by length information and header */
515 index += pu8msa[index + 1] + IE_HDR_LEN;
516 }
517
518 /* Return current channel information from the MIB, if beacon/probe */
519 /* response frame does not contain the DS parameter set IE */
520 /* return (mget_CurrentChannel() + 1); */
521 return 0; /* no MIB here */
522 }
523
524 u8 get_current_channel(u8 *pu8msa, u16 u16RxLen)
525 {
526 /* Extract current channel information from */
527 /* the beacon/probe response frame */
528 return get_current_channel_802_11n(pu8msa, u16RxLen);
529 }
530
531 /**
532 * @brief parses the received 'N' message
533 * @details
534 * @param[in] pu8MsgBuffer The message to be parsed
535 * @param[out] ppstrNetworkInfo pointer to pointer to the structure containing the parsed Network Info
536 * @return Error code indicating success/failure
537 * @note
538 * @author mabubakr
539 * @date 1 Mar 2012
540 * @version 1.0
541 */
542 s32 ParseNetworkInfo(u8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo)
543 {
544 s32 s32Error = WILC_SUCCESS;
545 tstrNetworkInfo *pstrNetworkInfo = NULL;
546 u8 u8MsgType = 0;
547 u8 u8MsgID = 0;
548 u16 u16MsgLen = 0;
549
550 u16 u16WidID = (u16)WID_NIL;
551 u16 u16WidLen = 0;
552 u8 *pu8WidVal = NULL;
553
554 u8MsgType = pu8MsgBuffer[0];
555
556 /* Check whether the received message type is 'N' */
557 if ('N' != u8MsgType) {
558 PRINT_ER("Received Message format incorrect.\n");
559 WILC_ERRORREPORT(s32Error, WILC_FAIL);
560 }
561
562 /* Extract message ID */
563 u8MsgID = pu8MsgBuffer[1];
564
565 /* Extract message Length */
566 u16MsgLen = MAKE_WORD16(pu8MsgBuffer[2], pu8MsgBuffer[3]);
567
568 /* Extract WID ID */
569 u16WidID = MAKE_WORD16(pu8MsgBuffer[4], pu8MsgBuffer[5]);
570
571 /* Extract WID Length */
572 u16WidLen = MAKE_WORD16(pu8MsgBuffer[6], pu8MsgBuffer[7]);
573
574 /* Assign a pointer to the WID value */
575 pu8WidVal = &pu8MsgBuffer[8];
576
577 /* parse the WID value of the WID "WID_NEWORK_INFO" */
578 {
579 u8 *pu8msa = NULL;
580 u16 u16RxLen = 0;
581 u8 *pu8TimElm = NULL;
582 u8 *pu8IEs = NULL;
583 u16 u16IEsLen = 0;
584 u8 u8index = 0;
585 u32 u32Tsf_Lo;
586 u32 u32Tsf_Hi;
587
588 pstrNetworkInfo = kmalloc(sizeof(tstrNetworkInfo), GFP_KERNEL);
589 if (!pstrNetworkInfo)
590 return -ENOMEM;
591
592 memset((void *)(pstrNetworkInfo), 0, sizeof(tstrNetworkInfo));
593
594 pstrNetworkInfo->s8rssi = pu8WidVal[0];
595
596 /* Assign a pointer to msa "Mac Header Start Address" */
597 pu8msa = &pu8WidVal[1];
598
599 u16RxLen = u16WidLen - 1;
600
601 /* parse msa*/
602
603 /* Get the cap_info */
604 pstrNetworkInfo->u16CapInfo = get_cap_info(pu8msa);
605 #ifdef WILC_P2P
606 /* Get time-stamp [Low only 32 bit] */
607 pstrNetworkInfo->u32Tsf = get_beacon_timestamp_lo(pu8msa);
608 PRINT_D(CORECONFIG_DBG, "TSF :%x\n", pstrNetworkInfo->u32Tsf);
609 #endif
610
611 /* Get full time-stamp [Low and High 64 bit] */
612 u32Tsf_Lo = get_beacon_timestamp_lo(pu8msa);
613 u32Tsf_Hi = get_beacon_timestamp_hi(pu8msa);
614
615 pstrNetworkInfo->u64Tsf = u32Tsf_Lo | ((u64)u32Tsf_Hi << 32);
616
617 /* Get SSID */
618 get_ssid(pu8msa, pstrNetworkInfo->au8ssid, &(pstrNetworkInfo->u8SsidLen));
619
620 /* Get BSSID */
621 get_BSSID(pu8msa, pstrNetworkInfo->au8bssid);
622
623 /* Get the current channel */
624 pstrNetworkInfo->u8channel = get_current_channel(pu8msa, (u16RxLen + FCS_LEN));
625
626 /* Get beacon period */
627 u8index = (MAC_HDR_LEN + TIME_STAMP_LEN);
628
629 pstrNetworkInfo->u16BeaconPeriod = get_beacon_period(pu8msa + u8index);
630
631 u8index += BEACON_INTERVAL_LEN + CAP_INFO_LEN;
632
633 /* Get DTIM Period */
634 pu8TimElm = get_tim_elm(pu8msa, (u16RxLen + FCS_LEN), u8index);
635 if (pu8TimElm != NULL)
636 pstrNetworkInfo->u8DtimPeriod = pu8TimElm[3];
637 pu8IEs = &pu8msa[MAC_HDR_LEN + TIME_STAMP_LEN + BEACON_INTERVAL_LEN + CAP_INFO_LEN];
638 u16IEsLen = u16RxLen - (MAC_HDR_LEN + TIME_STAMP_LEN + BEACON_INTERVAL_LEN + CAP_INFO_LEN);
639
640 if (u16IEsLen > 0) {
641 pstrNetworkInfo->pu8IEs = kmalloc(u16IEsLen, GFP_KERNEL);
642 if (!pstrNetworkInfo->pu8IEs)
643 return -ENOMEM;
644
645 memset((void *)(pstrNetworkInfo->pu8IEs), 0, u16IEsLen);
646
647 memcpy(pstrNetworkInfo->pu8IEs, pu8IEs, u16IEsLen);
648 }
649 pstrNetworkInfo->u16IEsLen = u16IEsLen;
650
651 }
652
653 *ppstrNetworkInfo = pstrNetworkInfo;
654
655 ERRORHANDLER:
656 return s32Error;
657 }
658
659 /**
660 * @brief Deallocates the parsed Network Info
661 * @details
662 * @param[in] pstrNetworkInfo Network Info to be deallocated
663 * @return Error code indicating success/failure
664 * @note
665 * @author mabubakr
666 * @date 1 Mar 2012
667 * @version 1.0
668 */
669 s32 DeallocateNetworkInfo(tstrNetworkInfo *pstrNetworkInfo)
670 {
671 s32 s32Error = WILC_SUCCESS;
672
673 if (pstrNetworkInfo != NULL) {
674 if (pstrNetworkInfo->pu8IEs != NULL) {
675 kfree(pstrNetworkInfo->pu8IEs);
676 pstrNetworkInfo->pu8IEs = NULL;
677 } else {
678 s32Error = WILC_FAIL;
679 }
680
681 kfree(pstrNetworkInfo);
682 pstrNetworkInfo = NULL;
683
684 } else {
685 s32Error = WILC_FAIL;
686 }
687
688 return s32Error;
689 }
690
691 /**
692 * @brief parses the received Association Response frame
693 * @details
694 * @param[in] pu8Buffer The Association Response frame to be parsed
695 * @param[out] ppstrConnectRespInfo pointer to pointer to the structure containing the parsed Association Response Info
696 * @return Error code indicating success/failure
697 * @note
698 * @author mabubakr
699 * @date 2 Apr 2012
700 * @version 1.0
701 */
702 s32 ParseAssocRespInfo(u8 *pu8Buffer, u32 u32BufferLen,
703 tstrConnectRespInfo **ppstrConnectRespInfo)
704 {
705 s32 s32Error = WILC_SUCCESS;
706 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
707 u16 u16AssocRespLen = 0;
708 u8 *pu8IEs = NULL;
709 u16 u16IEsLen = 0;
710
711 pstrConnectRespInfo = kmalloc(sizeof(tstrConnectRespInfo), GFP_KERNEL);
712 if (!pstrConnectRespInfo)
713 return -ENOMEM;
714
715 memset((void *)(pstrConnectRespInfo), 0, sizeof(tstrConnectRespInfo));
716
717 /* u16AssocRespLen = pu8Buffer[0]; */
718 u16AssocRespLen = (u16)u32BufferLen;
719
720 /* get the status code */
721 pstrConnectRespInfo->u16ConnectStatus = get_asoc_status(pu8Buffer);
722 if (pstrConnectRespInfo->u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
723
724 /* get the capability */
725 pstrConnectRespInfo->u16capability = get_assoc_resp_cap_info(pu8Buffer);
726
727 /* get the Association ID */
728 pstrConnectRespInfo->u16AssocID = get_asoc_id(pu8Buffer);
729
730 /* get the Information Elements */
731 pu8IEs = &pu8Buffer[CAP_INFO_LEN + STATUS_CODE_LEN + AID_LEN];
732 u16IEsLen = u16AssocRespLen - (CAP_INFO_LEN + STATUS_CODE_LEN + AID_LEN);
733
734 pstrConnectRespInfo->pu8RespIEs = kmalloc(u16IEsLen, GFP_KERNEL);
735 if (!pstrConnectRespInfo->pu8RespIEs)
736 return -ENOMEM;
737
738 memset((void *)(pstrConnectRespInfo->pu8RespIEs), 0, u16IEsLen);
739
740 memcpy(pstrConnectRespInfo->pu8RespIEs, pu8IEs, u16IEsLen);
741 pstrConnectRespInfo->u16RespIEsLen = u16IEsLen;
742 }
743
744 *ppstrConnectRespInfo = pstrConnectRespInfo;
745
746
747 return s32Error;
748 }
749
750 /**
751 * @brief Deallocates the parsed Association Response Info
752 * @details
753 * @param[in] pstrNetworkInfo Network Info to be deallocated
754 * @return Error code indicating success/failure
755 * @note
756 * @author mabubakr
757 * @date 2 Apr 2012
758 * @version 1.0
759 */
760 s32 DeallocateAssocRespInfo(tstrConnectRespInfo *pstrConnectRespInfo)
761 {
762 s32 s32Error = WILC_SUCCESS;
763
764 if (pstrConnectRespInfo != NULL) {
765 if (pstrConnectRespInfo->pu8RespIEs != NULL) {
766 kfree(pstrConnectRespInfo->pu8RespIEs);
767 pstrConnectRespInfo->pu8RespIEs = NULL;
768 } else {
769 s32Error = WILC_FAIL;
770 }
771
772 kfree(pstrConnectRespInfo);
773 pstrConnectRespInfo = NULL;
774
775 } else {
776 s32Error = WILC_FAIL;
777 }
778
779 return s32Error;
780 }
781
782 #ifndef CONNECT_DIRECT
783 s32 ParseSurveyResults(u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE],
784 wid_site_survey_reslts_s **ppstrSurveyResults,
785 u32 *pu32SurveyResultsCount)
786 {
787 s32 s32Error = WILC_SUCCESS;
788 wid_site_survey_reslts_s *pstrSurveyResults = NULL;
789 u32 u32SurveyResultsCount = 0;
790 u32 u32SurveyBytesLength = 0;
791 u8 *pu8BufferPtr;
792 u32 u32RcvdSurveyResultsNum = 2;
793 u8 u8ReadSurveyResFragNum;
794 u32 i;
795 u32 j;
796
797 for (i = 0; i < u32RcvdSurveyResultsNum; i++) {
798 u32SurveyBytesLength = ppu8RcvdSiteSurveyResults[i][0];
799
800
801 for (j = 0; j < u32SurveyBytesLength; j += SURVEY_RESULT_LENGTH) {
802 u32SurveyResultsCount++;
803 }
804 }
805
806 pstrSurveyResults = kmalloc_array(u32SurveyResultsCount,
807 sizeof(wid_site_survey_reslts_s), GFP_KERNEL);
808 if (!pstrSurveyResults)
809 return -ENOMEM;
810
811 memset((void *)(pstrSurveyResults), 0, u32SurveyResultsCount * sizeof(wid_site_survey_reslts_s));
812
813 u32SurveyResultsCount = 0;
814
815 for (i = 0; i < u32RcvdSurveyResultsNum; i++) {
816 pu8BufferPtr = ppu8RcvdSiteSurveyResults[i];
817
818 u32SurveyBytesLength = pu8BufferPtr[0];
819
820 /* TODO: mostafa: pu8BufferPtr[1] contains the fragment num */
821 u8ReadSurveyResFragNum = pu8BufferPtr[1];
822
823 pu8BufferPtr += 2;
824
825 for (j = 0; j < u32SurveyBytesLength; j += SURVEY_RESULT_LENGTH) {
826 memcpy(&pstrSurveyResults[u32SurveyResultsCount], pu8BufferPtr, SURVEY_RESULT_LENGTH);
827 pu8BufferPtr += SURVEY_RESULT_LENGTH;
828 u32SurveyResultsCount++;
829 }
830 }
831
832 ERRORHANDLER:
833 *ppstrSurveyResults = pstrSurveyResults;
834 *pu32SurveyResultsCount = u32SurveyResultsCount;
835
836 return s32Error;
837 }
838
839
840 s32 DeallocateSurveyResults(wid_site_survey_reslts_s *pstrSurveyResults)
841 {
842 s32 s32Error = WILC_SUCCESS;
843
844 if (pstrSurveyResults != NULL) {
845 kfree(pstrSurveyResults);
846 }
847
848 return s32Error;
849 }
850 #endif
851
852 /**
853 * @brief Deinitializes the Core Configurator
854 * @details
855 * @return Error code indicating success/failure
856 * @note
857 * @author mabubakr
858 * @date 1 Mar 2012
859 * @version 1.0
860 */
861
862 s32 CoreConfiguratorDeInit(void)
863 {
864 s32 s32Error = WILC_SUCCESS;
865
866 PRINT_D(CORECONFIG_DBG, "CoreConfiguratorDeInit()\n");
867
868
869 return s32Error;
870 }
871
872 /*Using the global handle of the driver*/
873 extern wilc_wlan_oup_t *gpstrWlanOps;
874 /**
875 * @brief sends certain Configuration Packet based on the input WIDs pstrWIDs
876 * using driver config layer
877 *
878 * @details
879 * @param[in] pstrWIDs WIDs to be sent in the configuration packet
880 * @param[in] u32WIDsCount number of WIDs to be sent in the configuration packet
881 * @param[out] pu8RxResp The received Packet Response
882 * @param[out] ps32RxRespLen Length of the received Packet Response
883 * @return Error code indicating success/failure
884 * @note
885 * @author mabubakr
886 * @date 1 Mar 2012
887 * @version 1.0
888 */
889 s32 SendConfigPkt(u8 u8Mode, tstrWID *pstrWIDs,
890 u32 u32WIDsCount, bool bRespRequired, u32 drvHandler)
891 {
892 s32 counter = 0, ret = 0;
893
894 if (gpstrWlanOps == NULL) {
895 PRINT_D(CORECONFIG_DBG, "Net Dev is still not initialized\n");
896 return 1;
897 } else {
898 PRINT_D(CORECONFIG_DBG, "Net Dev is initialized\n");
899 }
900 if (gpstrWlanOps->wlan_cfg_set == NULL ||
901 gpstrWlanOps->wlan_cfg_get == NULL) {
902 PRINT_D(CORECONFIG_DBG, "Set and Get is still not initialized\n");
903 return 1;
904 } else {
905 PRINT_D(CORECONFIG_DBG, "SET is initialized\n");
906 }
907 if (u8Mode == GET_CFG) {
908 for (counter = 0; counter < u32WIDsCount; counter++) {
909 PRINT_INFO(CORECONFIG_DBG, "Sending CFG packet [%d][%d]\n", !counter,
910 (counter == u32WIDsCount - 1));
911 if (!gpstrWlanOps->wlan_cfg_get(!counter,
912 pstrWIDs[counter].u16WIDid,
913 (counter == u32WIDsCount - 1), drvHandler)) {
914 ret = -1;
915 printk("[Sendconfigpkt]Get Timed out\n");
916 break;
917 }
918 }
919 /**
920 * get the value
921 **/
922 counter = 0;
923 for (counter = 0; counter < u32WIDsCount; counter++) {
924 pstrWIDs[counter].s32ValueSize = gpstrWlanOps->wlan_cfg_get_value(
925 pstrWIDs[counter].u16WIDid,
926 pstrWIDs[counter].ps8WidVal, pstrWIDs[counter].s32ValueSize);
927
928 }
929 } else if (u8Mode == SET_CFG) {
930 for (counter = 0; counter < u32WIDsCount; counter++) {
931 PRINT_D(CORECONFIG_DBG, "Sending config SET PACKET WID:%x\n", pstrWIDs[counter].u16WIDid);
932 if (!gpstrWlanOps->wlan_cfg_set(!counter,
933 pstrWIDs[counter].u16WIDid, pstrWIDs[counter].ps8WidVal,
934 pstrWIDs[counter].s32ValueSize,
935 (counter == u32WIDsCount - 1), drvHandler)) {
936 ret = -1;
937 printk("[Sendconfigpkt]Set Timed out\n");
938 break;
939 }
940 }
941 }
942
943 return ret;
944 }
This page took 0.077137 seconds and 5 git commands to generate.