]>
Commit | Line | Data |
---|---|---|
c5c77ba1 JK |
1 | /* ////////////////////////////////////////////////////////////////////////// */ |
2 | /* */ | |
3 | /* Copyright (c) Atmel Corporation. All rights reserved. */ | |
4 | /* */ | |
5 | /* Module Name: wilc_wlan_cfg.c */ | |
6 | /* */ | |
7 | /* */ | |
8 | /* ///////////////////////////////////////////////////////////////////////// */ | |
9 | ||
10 | #include "wilc_wlan_if.h" | |
11 | #include "wilc_wlan.h" | |
12 | #include "wilc_wlan_cfg.h" | |
13 | #include "coreconfigurator.h" | |
14 | ||
15 | #ifdef WILC_FULLY_HOSTING_AP | |
16 | #include "wilc_host_ap.h" | |
17 | void WILC_mgm_HOSTAPD_ACK(void *priv, WILC_Bool bStatus); | |
18 | #endif | |
19 | ||
20 | /******************************************** | |
21 | * | |
22 | * Global Data | |
23 | * | |
24 | ********************************************/ | |
25 | ||
26 | typedef struct { | |
27 | wilc_debug_func dPrint; | |
28 | ||
29 | int mac_status; | |
30 | uint8_t mac_address[7]; | |
31 | uint8_t ip_address[5]; | |
32 | uint8_t bssid[7]; | |
33 | uint8_t ssid[34]; | |
34 | uint8_t firmware_version[129]; | |
35 | uint8_t supp_rate[24]; | |
36 | uint8_t wep_key[28]; | |
37 | uint8_t i_psk[66]; | |
38 | uint8_t hardwareProductVersion[33]; | |
39 | uint8_t phyversion[17]; | |
40 | uint8_t supp_username[21]; | |
41 | uint8_t supp_password[64]; | |
42 | uint8_t assoc_req[256]; | |
43 | uint8_t assoc_rsp[256]; | |
44 | uint8_t firmware_info[8]; | |
45 | uint8_t scan_result[256]; | |
46 | uint8_t scan_result1[256]; | |
47 | } wilc_mac_cfg_t; | |
48 | ||
49 | static wilc_mac_cfg_t g_mac; | |
50 | ||
51 | static wilc_cfg_byte_t g_cfg_byte[] = { | |
52 | {WID_BSS_TYPE, 0}, | |
53 | {WID_CURRENT_TX_RATE, 0}, | |
54 | {WID_CURRENT_CHANNEL, 0}, | |
55 | {WID_PREAMBLE, 0}, | |
56 | {WID_11G_OPERATING_MODE, 0}, | |
57 | {WID_STATUS, 0}, | |
58 | {WID_SCAN_TYPE, 0}, | |
59 | {WID_KEY_ID, 0}, | |
60 | {WID_QOS_ENABLE, 0}, | |
61 | {WID_POWER_MANAGEMENT, 0}, | |
62 | {WID_11I_MODE, 0}, | |
63 | {WID_AUTH_TYPE, 0}, | |
64 | {WID_SITE_SURVEY, 0}, | |
65 | {WID_LISTEN_INTERVAL, 0}, | |
66 | {WID_DTIM_PERIOD, 0}, | |
67 | {WID_ACK_POLICY, 0}, | |
68 | {WID_BCAST_SSID, 0}, | |
69 | {WID_REKEY_POLICY, 0}, | |
70 | {WID_SHORT_SLOT_ALLOWED, 0}, | |
71 | {WID_START_SCAN_REQ, 0}, | |
72 | {WID_RSSI, 0}, | |
73 | {WID_LINKSPEED, 0}, | |
74 | {WID_AUTO_RX_SENSITIVITY, 0}, | |
75 | {WID_DATAFLOW_CONTROL, 0}, | |
76 | {WID_SCAN_FILTER, 0}, | |
77 | {WID_11N_PROT_MECH, 0}, | |
78 | {WID_11N_ERP_PROT_TYPE, 0}, | |
79 | {WID_11N_ENABLE, 0}, | |
80 | {WID_11N_OPERATING_MODE, 0}, | |
81 | {WID_11N_OBSS_NONHT_DETECTION, 0}, | |
82 | {WID_11N_HT_PROT_TYPE, 0}, | |
83 | {WID_11N_RIFS_PROT_ENABLE, 0}, | |
84 | {WID_11N_SMPS_MODE, 0}, | |
85 | {WID_11N_CURRENT_TX_MCS, 0}, | |
86 | {WID_11N_SHORT_GI_ENABLE, 0}, | |
87 | {WID_RIFS_MODE, 0}, | |
88 | {WID_TX_ABORT_CONFIG, 0}, | |
89 | {WID_11N_IMMEDIATE_BA_ENABLED, 0}, | |
90 | {WID_11N_TXOP_PROT_DISABLE, 0}, | |
91 | {WID_NIL, 0} | |
92 | }; | |
93 | ||
94 | static wilc_cfg_hword_t g_cfg_hword[] = { | |
95 | {WID_LINK_LOSS_THRESHOLD, 0}, | |
96 | {WID_RTS_THRESHOLD, 0}, | |
97 | {WID_FRAG_THRESHOLD, 0}, | |
98 | {WID_SHORT_RETRY_LIMIT, 0}, | |
99 | {WID_LONG_RETRY_LIMIT, 0}, | |
100 | {WID_BEACON_INTERVAL, 0}, | |
101 | {WID_RX_SENSE, 0}, | |
102 | {WID_ACTIVE_SCAN_TIME, 0}, | |
103 | {WID_PASSIVE_SCAN_TIME, 0}, | |
104 | {WID_SITE_SURVEY_SCAN_TIME, 0}, | |
105 | {WID_JOIN_START_TIMEOUT, 0}, | |
106 | {WID_AUTH_TIMEOUT, 0}, | |
107 | {WID_ASOC_TIMEOUT, 0}, | |
108 | {WID_11I_PROTOCOL_TIMEOUT, 0}, | |
109 | {WID_EAPOL_RESPONSE_TIMEOUT, 0}, | |
110 | {WID_11N_SIG_QUAL_VAL, 0}, | |
111 | {WID_CCA_THRESHOLD, 0}, | |
112 | {WID_NIL, 0} | |
113 | }; | |
114 | ||
115 | static wilc_cfg_word_t g_cfg_word[] = { | |
116 | {WID_FAILED_COUNT, 0}, | |
117 | {WID_RETRY_COUNT, 0}, | |
118 | {WID_MULTIPLE_RETRY_COUNT, 0}, | |
119 | {WID_FRAME_DUPLICATE_COUNT, 0}, | |
120 | {WID_ACK_FAILURE_COUNT, 0}, | |
121 | {WID_RECEIVED_FRAGMENT_COUNT, 0}, | |
122 | {WID_MCAST_RECEIVED_FRAME_COUNT, 0}, | |
123 | {WID_FCS_ERROR_COUNT, 0}, | |
124 | {WID_SUCCESS_FRAME_COUNT, 0}, | |
125 | {WID_TX_FRAGMENT_COUNT, 0}, | |
126 | {WID_TX_MULTICAST_FRAME_COUNT, 0}, | |
127 | {WID_RTS_SUCCESS_COUNT, 0}, | |
128 | {WID_RTS_FAILURE_COUNT, 0}, | |
129 | {WID_WEP_UNDECRYPTABLE_COUNT, 0}, | |
130 | {WID_REKEY_PERIOD, 0}, | |
131 | {WID_REKEY_PACKET_COUNT, 0}, | |
132 | {WID_HW_RX_COUNT, 0}, | |
133 | {WID_GET_INACTIVE_TIME, 0}, | |
134 | {WID_NIL, 0} | |
135 | ||
136 | }; | |
137 | ||
138 | static wilc_cfg_str_t g_cfg_str[] = { | |
139 | {WID_SSID, g_mac.ssid}, /* 33 + 1 bytes */ | |
140 | {WID_FIRMWARE_VERSION, g_mac.firmware_version}, | |
141 | {WID_OPERATIONAL_RATE_SET, g_mac.supp_rate}, | |
142 | {WID_BSSID, g_mac.bssid}, /* 6 bytes */ | |
143 | {WID_WEP_KEY_VALUE, g_mac.wep_key}, /* 27 bytes */ | |
144 | {WID_11I_PSK, g_mac.i_psk}, /* 65 bytes */ | |
145 | /* {WID_11E_P_ACTION_REQ, g_mac.action_req}, */ | |
146 | {WID_HARDWARE_VERSION, g_mac.hardwareProductVersion}, | |
147 | {WID_MAC_ADDR, g_mac.mac_address}, | |
148 | {WID_PHY_VERSION, g_mac.phyversion}, | |
149 | {WID_SUPP_USERNAME, g_mac.supp_username}, | |
150 | {WID_SUPP_PASSWORD, g_mac.supp_password}, | |
151 | {WID_SITE_SURVEY_RESULTS, g_mac.scan_result}, | |
152 | {WID_SITE_SURVEY_RESULTS, g_mac.scan_result1}, | |
153 | /* {WID_RX_POWER_LEVEL, g_mac.channel_rssi}, */ | |
154 | {WID_ASSOC_REQ_INFO, g_mac.assoc_req}, | |
155 | {WID_ASSOC_RES_INFO, g_mac.assoc_rsp}, | |
156 | /* {WID_11N_P_ACTION_REQ, g_mac.action_req}, */ | |
157 | {WID_FIRMWARE_INFO, g_mac.firmware_version}, | |
158 | {WID_IP_ADDRESS, g_mac.ip_address}, | |
159 | {WID_NIL, NULL} | |
160 | }; | |
161 | ||
162 | /******************************************** | |
163 | * | |
164 | * Configuration Functions | |
165 | * | |
166 | ********************************************/ | |
167 | ||
168 | static int wilc_wlan_cfg_set_byte(uint8_t *frame, uint32_t offset, uint16_t id, uint8_t val8) | |
169 | { | |
170 | uint8_t *buf; | |
171 | ||
172 | if ((offset + 4) >= MAX_CFG_FRAME_SIZE) | |
173 | return 0; | |
174 | ||
175 | buf = &frame[offset]; | |
176 | ||
177 | buf[0] = (uint8_t)id; | |
178 | buf[1] = (uint8_t)(id >> 8); | |
179 | buf[2] = 1; | |
180 | buf[3] = val8; | |
181 | return 4; | |
182 | } | |
183 | ||
184 | static int wilc_wlan_cfg_set_hword(uint8_t *frame, uint32_t offset, uint16_t id, uint16_t val16) | |
185 | { | |
186 | uint8_t *buf; | |
187 | ||
188 | if ((offset + 5) >= MAX_CFG_FRAME_SIZE) | |
189 | return 0; | |
190 | ||
191 | buf = &frame[offset]; | |
192 | ||
193 | buf[0] = (uint8_t)id; | |
194 | buf[1] = (uint8_t)(id >> 8); | |
195 | buf[2] = 2; | |
196 | buf[3] = (uint8_t)val16; | |
197 | buf[4] = (uint8_t)(val16 >> 8); | |
198 | ||
199 | return 5; | |
200 | } | |
201 | ||
202 | static int wilc_wlan_cfg_set_word(uint8_t *frame, uint32_t offset, uint16_t id, uint32_t val32) | |
203 | { | |
204 | uint8_t *buf; | |
205 | ||
206 | if ((offset + 7) >= MAX_CFG_FRAME_SIZE) | |
207 | return 0; | |
208 | ||
209 | buf = &frame[offset]; | |
210 | ||
211 | buf[0] = (uint8_t)id; | |
212 | buf[1] = (uint8_t)(id >> 8); | |
213 | buf[2] = 4; | |
214 | buf[3] = (uint8_t)val32; | |
215 | buf[4] = (uint8_t)(val32 >> 8); | |
216 | buf[5] = (uint8_t)(val32 >> 16); | |
217 | buf[6] = (uint8_t)(val32 >> 24); | |
218 | ||
219 | return 7; | |
220 | } | |
221 | ||
222 | static int wilc_wlan_cfg_set_str(uint8_t *frame, uint32_t offset, uint16_t id, uint8_t *str, uint32_t size) | |
223 | { | |
224 | uint8_t *buf; | |
225 | ||
226 | if ((offset + size + 3) >= MAX_CFG_FRAME_SIZE) | |
227 | return 0; | |
228 | ||
229 | buf = &frame[offset]; | |
230 | ||
231 | buf[0] = (uint8_t)id; | |
232 | buf[1] = (uint8_t)(id >> 8); | |
233 | buf[2] = (uint8_t)size; | |
234 | ||
235 | if ((str != NULL) && (size != 0)) | |
236 | memcpy(&buf[3], str, size); | |
237 | ||
238 | return (size + 3); | |
239 | } | |
240 | ||
241 | static int wilc_wlan_cfg_set_bin(uint8_t *frame, uint32_t offset, uint16_t id, uint8_t *b, uint32_t size) | |
242 | { | |
243 | uint8_t *buf; | |
244 | uint32_t i; | |
245 | uint8_t checksum = 0; | |
246 | ||
247 | if ((offset + size + 5) >= MAX_CFG_FRAME_SIZE) | |
248 | return 0; | |
249 | ||
250 | buf = &frame[offset]; | |
251 | buf[0] = (uint8_t)id; | |
252 | buf[1] = (uint8_t)(id >> 8); | |
253 | buf[2] = (uint8_t)size; | |
254 | buf[3] = (uint8_t)(size >> 8); | |
255 | ||
256 | if ((b != NULL) && (size != 0)) { | |
257 | memcpy(&buf[4], b, size); | |
258 | for (i = 0; i < size; i++) { | |
259 | checksum += buf[i + 4]; | |
260 | } | |
261 | } | |
262 | ||
263 | buf[size + 4] = checksum; | |
264 | ||
265 | return (size + 5); | |
266 | } | |
267 | ||
268 | /******************************************** | |
269 | * | |
270 | * Configuration Response Functions | |
271 | * | |
272 | ********************************************/ | |
273 | ||
274 | static void wilc_wlan_parse_response_frame(uint8_t *info, int size) | |
275 | { | |
276 | uint32_t wid, len = 0, i = 0; | |
277 | static int seq; | |
278 | ||
279 | while (size > 0) { | |
280 | i = 0; | |
281 | wid = info[0] | (info[1] << 8); | |
282 | #ifdef BIG_ENDIAN | |
283 | wid = BYTE_SWAP(wid); | |
284 | #endif | |
285 | PRINT_INFO(GENERIC_DBG, "Processing response for %d seq %d\n", wid, seq++); | |
286 | switch ((wid >> 12) & 0x7) { | |
287 | case WID_CHAR: | |
288 | do { | |
289 | if (g_cfg_byte[i].id == WID_NIL) | |
290 | break; | |
291 | ||
292 | if (g_cfg_byte[i].id == wid) { | |
293 | g_cfg_byte[i].val = info[3]; | |
294 | break; | |
295 | } | |
296 | i++; | |
297 | } while (1); | |
298 | len = 2; | |
299 | break; | |
300 | ||
301 | case WID_SHORT: | |
302 | do { | |
303 | if (g_cfg_hword[i].id == WID_NIL) | |
304 | break; | |
305 | ||
306 | if (g_cfg_hword[i].id == wid) { | |
307 | #ifdef BIG_ENDIAN | |
308 | g_cfg_hword[i].val = (info[3] << 8) | (info[4]); | |
309 | #else | |
310 | g_cfg_hword[i].val = info[3] | (info[4] << 8); | |
311 | #endif | |
312 | break; | |
313 | } | |
314 | i++; | |
315 | } while (1); | |
316 | len = 3; | |
317 | break; | |
318 | ||
319 | case WID_INT: | |
320 | do { | |
321 | if (g_cfg_word[i].id == WID_NIL) | |
322 | break; | |
323 | ||
324 | if (g_cfg_word[i].id == wid) { | |
325 | #ifdef BIG_ENDIAN | |
326 | g_cfg_word[i].val = (info[3] << 24) | (info[4] << 16) | (info[5] << 8) | (info[6]); | |
327 | #else | |
328 | g_cfg_word[i].val = info[3] | (info[4] << 8) | (info[5] << 16) | (info[6] << 24); | |
329 | #endif | |
330 | break; | |
331 | } | |
332 | i++; | |
333 | } while (1); | |
334 | len = 5; | |
335 | break; | |
336 | ||
337 | case WID_STR: | |
338 | do { | |
339 | if (g_cfg_str[i].id == WID_NIL) | |
340 | break; | |
341 | ||
342 | if (g_cfg_str[i].id == wid) { | |
343 | if (wid == WID_SITE_SURVEY_RESULTS) { | |
344 | static int toggle; | |
345 | PRINT_INFO(GENERIC_DBG, "Site survey results received[%d]\n", | |
346 | size); | |
347 | ||
348 | PRINT_INFO(GENERIC_DBG, "Site survey results value[%d]toggle[%d]\n", size, toggle); | |
349 | i += toggle; | |
350 | toggle ^= 1; | |
351 | } | |
352 | memcpy(g_cfg_str[i].str, &info[2], (info[2] + 1)); | |
353 | break; | |
354 | } | |
355 | i++; | |
356 | } while (1); | |
357 | len = 1 + info[2]; | |
358 | break; | |
359 | ||
360 | default: | |
361 | break; | |
362 | } | |
363 | size -= (2 + len); | |
364 | info += (2 + len); | |
365 | } | |
366 | ||
367 | return; | |
368 | } | |
369 | ||
370 | static int wilc_wlan_parse_info_frame(uint8_t *info, int size) | |
371 | { | |
372 | wilc_mac_cfg_t *pd = (wilc_mac_cfg_t *)&g_mac; | |
373 | uint32_t wid, len; | |
374 | int type = WILC_CFG_RSP_STATUS; | |
375 | ||
376 | wid = info[0] | (info[1] << 8); | |
377 | #if 0 | |
378 | #ifdef BIG_ENDIAN | |
379 | wid = BYTE_SWAP(wid); | |
380 | #endif | |
381 | #endif | |
382 | ||
383 | len = info[2]; | |
384 | PRINT_INFO(GENERIC_DBG, "Status Len = %d Id= %d\n", len, wid); | |
385 | if ((len == 1) && (wid == WID_STATUS)) { | |
386 | pd->mac_status = info[3]; | |
387 | type = WILC_CFG_RSP_STATUS; | |
388 | } | |
389 | ||
390 | return type; | |
391 | } | |
392 | ||
393 | #if 0 | |
394 | static int wilc_wlan_parse_network_frame(uint8_t *info, int size) | |
395 | { | |
396 | wilc_mac_cfg_t *priv = (wilc_mac_cfg_t *)&g_mac; | |
397 | uint32_t wid, len; | |
398 | ||
399 | wid = info[0] | (info[1] << 8); | |
400 | len = info[2] | (info[3] << 8); | |
401 | ||
402 | /** | |
403 | * Review: this message is only for AP mode. | |
404 | * TBD | |
405 | **/ | |
406 | if (wid == WID_NETWORK_INFO) { /* not send by the firmware */ | |
407 | ||
408 | } | |
409 | ||
410 | return; | |
411 | } | |
412 | #endif | |
413 | ||
414 | /******************************************** | |
415 | * | |
416 | * Configuration Exported Functions | |
417 | * | |
418 | ********************************************/ | |
419 | ||
420 | static int wilc_wlan_cfg_set_wid(uint8_t *frame, uint32_t offset, uint16_t id, uint8_t *buf, int size) | |
421 | { | |
422 | uint8_t type = (id >> 12) & 0xf; | |
423 | int ret = 0; | |
424 | ||
425 | if (type == 0) { /* byte command */ | |
426 | if (size >= 1) | |
427 | ret = wilc_wlan_cfg_set_byte(frame, offset, id, *buf); | |
428 | } else if (type == 1) { /* half word command */ | |
429 | if (size >= 2) | |
430 | ret = wilc_wlan_cfg_set_hword(frame, offset, id, *((uint16_t *)buf)); | |
431 | } else if (type == 2) { /* word command */ | |
432 | if (size >= 4) | |
433 | ret = wilc_wlan_cfg_set_word(frame, offset, id, *((uint32_t *)buf)); | |
434 | } else if (type == 3) { /* string command */ | |
435 | ret = wilc_wlan_cfg_set_str(frame, offset, id, buf, size); | |
436 | } else if (type == 4) { /* binary command */ | |
437 | ret = wilc_wlan_cfg_set_bin(frame, offset, id, buf, size); | |
438 | } else { | |
439 | g_mac.dPrint(N_ERR, "illegal id\n"); | |
440 | } | |
441 | ||
442 | return ret; | |
443 | } | |
444 | ||
445 | static int wilc_wlan_cfg_get_wid(uint8_t *frame, uint32_t offset, uint16_t id) | |
446 | { | |
447 | uint8_t *buf; | |
448 | ||
449 | if ((offset + 2) >= MAX_CFG_FRAME_SIZE) | |
450 | return 0; | |
451 | ||
452 | buf = &frame[offset]; | |
453 | ||
454 | buf[0] = (uint8_t)id; | |
455 | buf[1] = (uint8_t)(id >> 8); | |
456 | ||
457 | return 2; | |
458 | } | |
459 | ||
460 | static int wilc_wlan_cfg_get_wid_value(uint16_t wid, uint8_t *buffer, uint32_t buffer_size) | |
461 | { | |
462 | uint32_t type = (wid >> 12) & 0xf; | |
463 | int i, ret = 0; | |
464 | ||
465 | if (wid == WID_STATUS) { | |
466 | *((uint32_t *)buffer) = g_mac.mac_status; | |
467 | return 4; | |
468 | } | |
469 | ||
470 | i = 0; | |
471 | if (type == 0) { /* byte command */ | |
472 | do { | |
473 | if (g_cfg_byte[i].id == WID_NIL) | |
474 | break; | |
475 | ||
476 | if (g_cfg_byte[i].id == wid) { | |
477 | memcpy(buffer, &g_cfg_byte[i].val, 1); | |
478 | ret = 1; | |
479 | break; | |
480 | } | |
481 | i++; | |
482 | } while (1); | |
483 | } else if (type == 1) { /* half word command */ | |
484 | do { | |
485 | if (g_cfg_hword[i].id == WID_NIL) | |
486 | break; | |
487 | ||
488 | if (g_cfg_hword[i].id == wid) { | |
489 | memcpy(buffer, &g_cfg_hword[i].val, 2); | |
490 | ret = 2; | |
491 | break; | |
492 | } | |
493 | i++; | |
494 | } while (1); | |
495 | } else if (type == 2) { /* word command */ | |
496 | do { | |
497 | if (g_cfg_word[i].id == WID_NIL) | |
498 | break; | |
499 | ||
500 | if (g_cfg_word[i].id == wid) { | |
501 | memcpy(buffer, &g_cfg_word[i].val, 4); | |
502 | ret = 4; | |
503 | break; | |
504 | } | |
505 | i++; | |
506 | } while (1); | |
507 | } else if (type == 3) { /* string command */ | |
508 | do { | |
509 | if (g_cfg_str[i].id == WID_NIL) | |
510 | break; | |
511 | ||
512 | if (g_cfg_str[i].id == wid) { | |
513 | uint32_t size = g_cfg_str[i].str[0]; | |
514 | if (buffer_size >= size) { | |
515 | if (g_cfg_str[i].id == WID_SITE_SURVEY_RESULTS) { | |
516 | static int toggle; | |
517 | PRINT_INFO(GENERIC_DBG, "Site survey results value[%d]\n", | |
518 | size); | |
519 | i += toggle; | |
520 | toggle ^= 1; | |
521 | ||
522 | } | |
523 | memcpy(buffer, &g_cfg_str[i].str[1], size); | |
524 | ret = size; | |
525 | } | |
526 | break; | |
527 | } | |
528 | i++; | |
529 | } while (1); | |
530 | } else { | |
531 | g_mac.dPrint(N_ERR, "[CFG]: illegal type (%08x)\n", wid); | |
532 | } | |
533 | ||
534 | return ret; | |
535 | } | |
536 | ||
537 | static int wilc_wlan_cfg_indicate_rx(uint8_t *frame, int size, wilc_cfg_rsp_t *rsp) | |
538 | { | |
539 | int ret = 1; | |
540 | uint8_t msg_type; | |
541 | uint8_t msg_id; | |
542 | uint16_t msg_len; | |
543 | #ifdef WILC_FULLY_HOSTING_AP | |
544 | WILC_Uint32 *ptru32Frame; | |
545 | WILC_Bool bStatus = frame[2]; | |
546 | ||
547 | #ifdef BIG_ENDIAN | |
548 | ptru32Frame = (frame[4] << 24) | (frame[5] << 16) | (frame[6] << 8) | frame[7]; | |
549 | #else | |
550 | ptru32Frame = (frame[7] << 24) | (frame[6] << 16) | (frame[5] << 8) | frame[4]; | |
551 | #endif /* BIG_ENDIAN */ | |
552 | ||
553 | #endif /* WILC_FULLY_HOSTING_AP */ | |
554 | ||
555 | msg_type = frame[0]; | |
556 | msg_id = frame[1]; /* seq no */ | |
557 | #ifdef BIG_ENDIAN | |
558 | msg_len = (frame[2] << 8) | frame[3]; | |
559 | #else | |
560 | msg_len = (frame[3] << 8) | frame[2]; | |
561 | #endif | |
562 | frame += 4; | |
563 | size -= 4; | |
564 | ||
565 | /** | |
566 | * The valid types of response messages are 'R' (Response), 'I' (Information), and 'N' (Network Information) | |
567 | **/ | |
568 | ||
569 | switch (msg_type) { | |
570 | case 'R': | |
571 | wilc_wlan_parse_response_frame(frame, size); | |
572 | rsp->type = WILC_CFG_RSP; | |
573 | rsp->seq_no = msg_id; | |
574 | break; | |
575 | ||
576 | case 'I': | |
577 | rsp->type = wilc_wlan_parse_info_frame(frame, size); | |
578 | rsp->seq_no = msg_id; | |
579 | /*call host interface info parse as well*/ | |
580 | PRINT_INFO(RX_DBG, "Info message received\n"); | |
581 | GnrlAsyncInfoReceived(frame - 4, size + 4); | |
582 | break; | |
583 | ||
584 | case 'L': | |
585 | #ifndef SWITCH_LOG_TERMINAL | |
586 | PRINT_ER("Unexpected firmware log message received \n"); | |
587 | #else | |
588 | PRINT_D(FIRM_DBG, "\nFIRMWARE LOGS :\n<<\n%s\n>>\n", frame); | |
589 | break; | |
590 | ||
591 | #endif | |
592 | #if 1 | |
593 | case 'N': | |
594 | NetworkInfoReceived(frame - 4, size + 4); | |
595 | rsp->type = 0; | |
596 | break; | |
597 | ||
598 | #endif | |
599 | /*bug3819:*/ | |
600 | case 'S': | |
601 | PRINT_INFO(RX_DBG, "Scan Notification Received \n"); | |
602 | host_int_ScanCompleteReceived(frame - 4, size + 4); | |
603 | break; | |
604 | ||
605 | #ifdef WILC_FULLY_HOSTING_AP | |
606 | case 'T': | |
607 | PRINT_INFO(RX_DBG, "TBTT Notification Received \n"); | |
608 | process_tbtt_isr(); | |
609 | break; | |
610 | ||
611 | case 'A': | |
612 | PRINT_INFO(RX_DBG, "HOSTAPD ACK Notification Received \n"); | |
613 | WILC_mgm_HOSTAPD_ACK(ptru32Frame, bStatus); | |
614 | break; | |
615 | #endif | |
616 | ||
617 | default: | |
618 | PRINT_INFO(RX_DBG, "Receive unknown message type[%d-%d-%d-%d-%d-%d-%d-%d]\n", | |
619 | frame[0], frame[1], frame[2], frame[3], frame[4], | |
620 | frame[5], frame[6], frame[7]); | |
621 | rsp->type = 0; | |
622 | rsp->seq_no = msg_id; | |
623 | ret = 0; | |
624 | break; | |
625 | } | |
626 | ||
627 | return ret; | |
628 | } | |
629 | ||
630 | static int wilc_wlan_cfg_init(wilc_debug_func func) | |
631 | { | |
632 | memset((void *)&g_mac, 0, sizeof(wilc_mac_cfg_t)); | |
633 | g_mac.dPrint = func; | |
634 | return 1; | |
635 | } | |
636 | ||
637 | wilc_cfg_func_t mac_cfg = { | |
638 | wilc_wlan_cfg_set_wid, | |
639 | wilc_wlan_cfg_get_wid, | |
640 | wilc_wlan_cfg_get_wid_value, | |
641 | wilc_wlan_cfg_indicate_rx, | |
642 | wilc_wlan_cfg_init, | |
643 | }; |