blob: e360ca9d3db10ead54e199997c3bf569265cc1c5 [file] [log] [blame]
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001
2/****************************************************************************
3 * (c) Copyright 2007 Wi-Fi Alliance. All Rights Reserved
4 *
5 *
6 * LICENSE
7 *
8 * License is granted only to Wi-Fi Alliance members and designated
9 * contractors ($B!H(BAuthorized Licensees$B!I(B)..AN Authorized Licensees are granted
10 * the non-exclusive, worldwide, limited right to use, copy, import, export
11 * and distribute this software:
12 * (i) solely for noncommercial applications and solely for testing Wi-Fi
13 * equipment; and
14 * (ii) solely for the purpose of embedding the software into Authorized
15 * Licensee$B!G(Bs proprietary equipment and software products for distribution to
16 * its customers under a license with at least the same restrictions as
17 * contained in this License, including, without limitation, the disclaimer of
18 * warranty and limitation of liability, below..AN The distribution rights
19 * granted in clause
20 * (ii), above, include distribution to third party companies who will
21 * redistribute the Authorized Licensee$B!G(Bs product to their customers with or
22 * without such third party$B!G(Bs private label. Other than expressly granted
23 * herein, this License is not transferable or sublicensable, and it does not
24 * extend to and may not be used with non-Wi-Fi applications..AN Wi-Fi Alliance
25 * reserves all rights not expressly granted herein..AN
26 *.AN
27 * Except as specifically set forth above, commercial derivative works of
28 * this software or applications that use the Wi-Fi scripts generated by this
29 * software are NOT AUTHORIZED without specific prior written permission from
30 * Wi-Fi Alliance.
31 *.AN
32 * Non-Commercial derivative works of this software for internal use are
33 * authorized and are limited by the same restrictions; provided, however,
34 * that the Authorized Licensee shall provide Wi-Fi Alliance with a copy of
35 * such derivative works under a perpetual, payment-free license to use,
36 * modify, and distribute such derivative works for purposes of testing Wi-Fi
37 * equipment.
38 *.AN
39 * Neither the name of the author nor "Wi-Fi Alliance" may be used to endorse
40 * or promote products that are derived from or that use this software without
41 * specific prior written permission from Wi-Fi Alliance.
42 *
43 * THIS SOFTWARE IS PROVIDED BY WI-FI ALLIANCE "AS IS" AND ANY EXPRESS OR
44 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
45 * OF MERCHANTABILITY, NON-INFRINGEMENT AND FITNESS FOR A.AN PARTICULAR PURPOSE,
46 * ARE DISCLAIMED. IN NO EVENT SHALL WI-FI ALLIANCE BE LIABLE FOR ANY DIRECT,
47 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
48 * (INCLUDING, BUT NOT LIMITED TO, THE COST OF PROCUREMENT OF SUBSTITUTE
49 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
51 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE) ARISING IN ANY WAY OUT OF
52 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************
53 */
54
55/*
56 * File: wfa_cs.c -- configuration and setup
57 * This file contains all implementation for the dut setup and control
58 * functions, such as network interfaces, ip address and wireless specific
59 * setup with its supplicant.
60 *
61 * The current implementation is to show how these functions
62 * should be defined in order to support the Agent Control/Test Manager
63 * control commands. To simplify the current work and avoid any GPL licenses,
64 * the functions mostly invoke shell commands by calling linux system call,
65 * system("<commands>").
66 *
67 * It depends on the differnt device and platform, vendors can choice their
68 * own ways to interact its systems, supplicants and process these commands
69 * such as using the native APIs.
70 *
71 * Revision History:
72 * 2006/03/10 -- initially created by qhu
73 * 2006/06/01 -- BETA Release by qhu
74 * 2006/06/13 -- 00.02 Release by qhu
75 * 2006/06/30 -- 00.10 Release by qhu
76 * 2006/07/10 -- 01.00 Release by qhu
77 * 2006/09/01 -- 01.05 Release by qhu
78 * 2006/10/26 -- 01.06 Released by qhu
79 * replace hardcoded buf size with macro
80 * 2006/12/02 -- bugs: 1. fixes incorrect order of getipconfig.sh
81 * input parameters reported by p.schwann
82 * 2. will add a new network for wap_cli command
83 * in case the network id 0 not present,
84 * recommended by c.benson
85 * the solution is to reimplement with calling
86 * native C API
87 * 2007/01/11 -- 01.10 released by qhu
88 * 2007/02/15 -- WMM Extension Beta released by qhu, mkaroshi
89 * 2007/03/18 -- add file close statements
90 * 2007/03/21 -- rename the file to avoid the confusion.
91 * 2007/03/30 -- 01.40 WPA2 and Official WMM Beta Release by qhu
92 * 2007/04/20 -- 02.00 WPA2 and Official WMM Release by qhu
93 * 2007/08/15 -- 02.10 WMM-Power Save release by qhu
94 * 2007/10/10 -- 02.20 Voice SOHO beta -- qhu
95 * 2007/11/07 -- 02.30 Voice HSO -- qhu
96 * 2007/12/10 -- 02.32 Add a function to upload test results.
97 * 2008/01/03 -- 02.34 Support the result upload command.
98 * 2008/03/12 -- 02.41 Bug #16, incorrect file descriptor used. Change
99 * the "tmpfile" to "tmpfd" and a few places. Make a macro
100 * WFA_STAUT_IF in file "inc/wfa_cs.h" for WLAN interface
101 * name in the function "wfaDeviceListIF()
102 *
103 * Not A Bug. Put back to the function from
104 * wfaSetEncryption1() to wfaSetEncryption() for
105 * supporting WEP. Porting could select which should be
106 * used according to WEP support or not.
107 *
108 *
109 */
110#include <stdio.h>
111#include <unistd.h>
112#include <string.h>
113#include <stdlib.h>
114#include <sys/socket.h>
115#include <arpa/inet.h>
116#include <linux/types.h>
117#include <linux/socket.h>
118#include <poll.h>
119
120#include "wfa_portall.h"
121#include "wfa_debug.h"
122#include "wfa_ver.h"
123#include "wfa_main.h"
124#include "wfa_types.h"
125#include "wfa_ca.h"
126#include "wfa_tlv.h"
127#include "wfa_sock.h"
128#include "wfa_tg.h"
129#include "wfa_cmds.h"
130#include "wfa_rsp.h"
131#include "wfa_utils.h"
132#ifdef WFA_WMM_PS_EXT
133#include "wfa_wmmps.h"
134#endif
135
136#define CERTIFICATES_PATH "/etc/wpa_supplicant"
137
138/* Some device may only support UDP ECHO, activate this line */
139//#define WFA_PING_UDP_ECHO_ONLY 1
140
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800141#define WFA_ENABLED 1
142
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000143extern unsigned short wfa_defined_debug;
144int wfaExecuteCLI(char *CLI);
145
146/* Since the two definitions are used all over the CA function */
147char gCmdStr[WFA_CMD_STR_SZ];
148dutCmdResponse_t gGenericResp;
149int wfaTGSetPrio(int sockfd, int tgClass);
150void create_apts_msg(int msg, unsigned int txbuf[],int id);
151
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800152int sret = 0;
153
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000154extern char e2eResults[];
155//extern char *e2eResults;
156FILE *e2efp = NULL;
157int chk_ret_status()
158{
159 char *ret = getenv(WFA_RET_ENV);
160
161 if(*ret == '1')
162 return WFA_SUCCESS;
163 else
164 return WFA_FAILURE;
165}
166
167/*
168 * agtCmdProcGetVersion(): response "ca_get_version" command to controller
169 * input: cmd --- not used
170 * valLen -- not used
171 * output: parms -- a buffer to store the version info response.
172 */
173int agtCmdProcGetVersion(int len, BYTE *parms, int *respLen, BYTE *respBuf)
174{
175 dutCmdResponse_t *getverResp = &gGenericResp;
176
177 DPRINT_INFO(WFA_OUT, "entering agtCmdProcGetVersion ...\n");
178
179 getverResp->status = STATUS_COMPLETE;
180 wSTRNCPY(getverResp->cmdru.version, WFA_SYSTEM_VER, WFA_VERNAM_LEN);
181
182 wfaEncodeTLV(WFA_GET_VERSION_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)getverResp, respBuf);
183
184 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
185
186 return WFA_SUCCESS;
187}
188
189/*
190 * wfaStaAssociate():
191 * The function is to force the station wireless I/F to re/associate
192 * with the AP.
193 */
194int wfaStaAssociate(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
195{
196 dutCommand_t *assoc = (dutCommand_t *)caCmdBuf;
197 char *ifname = assoc->intf;
198 dutCmdResponse_t *staAssocResp = &gGenericResp;
199
200 DPRINT_INFO(WFA_OUT, "entering wfaStaAssociate ...\n");
201 /*
202 * if bssid appears, station should associate with the specific
203 * BSSID AP at its initial association.
204 * If it is different to the current associating AP, it will be forced to
205 * roam the new AP
206 */
207 if(assoc->cmdsu.assoc.bssid[0] != '\0')
208 {
209 /* if (the first association) */
210 /* just do initial association to the BSSID */
211
212
213 /* else (station already associate to an AP) */
214 /* Do forced roaming */
215
216 }
217 else
218 {
219 /* use 'ifconfig' command to bring down the interface (linux specific) */
220 sprintf(gCmdStr, "ifconfig %s down", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800221 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000222
223 /* use 'ifconfig' command to bring up the interface (linux specific) */
224 sprintf(gCmdStr, "ifconfig %s up", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800225 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000226
227 /*
228 * use 'wpa_cli' command to force a 802.11 re/associate
229 * (wpa_supplicant specific)
230 */
231 sprintf(gCmdStr, "wpa_cli -i%s reassociate", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800232 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000233 }
234
235 /*
236 * Then report back to control PC for completion.
237 * This does not have failed/error status. The result only tells
238 * a completion.
239 */
240 staAssocResp->status = STATUS_COMPLETE;
241 wfaEncodeTLV(WFA_STA_ASSOCIATE_RESP_TLV, 4, (BYTE *)staAssocResp, respBuf);
242 *respLen = WFA_TLV_HDR_LEN + 4;
243
244 return WFA_SUCCESS;
245}
246
247/*
248 * wfaStaReAssociate():
249 * The function is to force the station wireless I/F to re/associate
250 * with the AP.
251 */
252int wfaStaReAssociate(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
253{
254 dutCommand_t *assoc = (dutCommand_t *)caCmdBuf;
255 char *ifname = assoc->intf;
256 dutCmdResponse_t *staAssocResp = &gGenericResp;
257
258 DPRINT_INFO(WFA_OUT, "entering wfaStaAssociate ...\n");
259 /*
260 * if bssid appears, station should associate with the specific
261 * BSSID AP at its initial association.
262 * If it is different to the current associating AP, it will be forced to
263 * roam the new AP
264 */
265 if(assoc->cmdsu.assoc.bssid[0] != '\0')
266 {
267 /* if (the first association) */
268 /* just do initial association to the BSSID */
269
270
271 /* else (station already associate to an AP) */
272 /* Do forced roaming */
273
274 }
275 else
276 {
277 /* use 'ifconfig' command to bring down the interface (linux specific) */
278 sprintf(gCmdStr, "ifconfig %s down", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800279 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000280
281 /* use 'ifconfig' command to bring up the interface (linux specific) */
282 sprintf(gCmdStr, "ifconfig %s up", ifname);
283
284 /*
285 * use 'wpa_cli' command to force a 802.11 re/associate
286 * (wpa_supplicant specific)
287 */
288 sprintf(gCmdStr, "wpa_cli -i%s reassociate", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800289 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000290 }
291
292 /*
293 * Then report back to control PC for completion.
294 * This does not have failed/error status. The result only tells
295 * a completion.
296 */
297 staAssocResp->status = STATUS_COMPLETE;
298 wfaEncodeTLV(WFA_STA_ASSOCIATE_RESP_TLV, 4, (BYTE *)staAssocResp, respBuf);
299 *respLen = WFA_TLV_HDR_LEN + 4;
300
301 return WFA_SUCCESS;
302}
303
304/*
305 * wfaStaIsConnected():
306 * The function is to check whether the station's wireless I/F has
307 * already connected to an AP.
308 */
309int wfaStaIsConnected(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
310{
311 dutCommand_t *connStat = (dutCommand_t *)caCmdBuf;
312 dutCmdResponse_t *staConnectResp = &gGenericResp;
313 char *ifname = connStat->intf;
314 FILE *tmpfile = NULL;
315 char result[32];
316
317
318 DPRINT_INFO(WFA_OUT, "Entering isConnected ...\n");
319
320#ifdef WFA_NEW_CLI_FORMAT
321 sprintf(gCmdStr, "wfa_chkconnect %s\n", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800322 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000323
324 if(chk_ret_status() == WFA_SUCCESS)
325 staConnectResp->cmdru.connected = 1;
326 else
327 staConnectResp->cmdru.connected = 0;
328#else
329 /*
330 * use 'wpa_cli' command to check the interface status
331 * none, scanning or complete (wpa_supplicant specific)
332 */
333 sprintf(gCmdStr, "/sbin/wpa_cli -i%s status | grep ^wpa_state= | cut -f2- -d= > /tmp/.isConnected", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800334 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000335
336 /*
337 * the status is saved in a file. Open the file and check it.
338 */
339 tmpfile = fopen("/tmp/.isConnected", "r+");
340 if(tmpfile == NULL)
341 {
342 staConnectResp->status = STATUS_ERROR;
343 wfaEncodeTLV(WFA_STA_IS_CONNECTED_RESP_TLV, 4, (BYTE *)staConnectResp, respBuf);
344 *respLen = WFA_TLV_HDR_LEN + 4;
345
346 DPRINT_ERR(WFA_ERR, "file open failed\n");
347 return WFA_FAILURE;
348 }
349
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800350 sret = fscanf(tmpfile, "%s", (char *)result);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000351
352 if(strncmp(result, "COMPLETED", 9) == 0)
353 staConnectResp->cmdru.connected = 1;
354 else
355 staConnectResp->cmdru.connected = 0;
356#endif
357
358 /*
359 * Report back the status: Complete or Failed.
360 */
361 staConnectResp->status = STATUS_COMPLETE;
362
363 wfaEncodeTLV(WFA_STA_IS_CONNECTED_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)staConnectResp, respBuf);
364 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
365
366 return WFA_SUCCESS;
367}
368
369/*
370 * wfaStaGetIpConfig():
371 * This function is to retriev the ip info including
372 * 1. dhcp enable
373 * 2. ip address
374 * 3. mask
375 * 4. primary-dns
376 * 5. secondary-dns
377 *
378 * The current implementation is to use a script to find these information
379 * and store them in a file.
380 */
381int wfaStaGetIpConfig(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
382{
383 int slen, ret, i = 0;
384 dutCommand_t *getIpConf = (dutCommand_t *)caCmdBuf;
385 dutCmdResponse_t *ipconfigResp = &gGenericResp;
386 char *ifname = getIpConf->intf;
387 caStaGetIpConfigResp_t *ifinfo = &ipconfigResp->cmdru.getIfconfig;
388
389 FILE *tmpfd;
390 char string[256];
391 char *str;
392
393 /*
394 * check a script file (the current implementation specific)
395 */
396 ret = access("/usr/local/sbin/getipconfig.sh", F_OK);
397 if(ret == -1)
398 {
399 ipconfigResp->status = STATUS_ERROR;
400 wfaEncodeTLV(WFA_STA_GET_IP_CONFIG_RESP_TLV, 4, (BYTE *)ipconfigResp, respBuf);
401 *respLen = WFA_TLV_HDR_LEN + 4;
402
403 DPRINT_ERR(WFA_ERR, "file not exist\n");
404 return WFA_FAILURE;
405
406 }
407
408 strcpy(ifinfo->dns[0], "0");
409 strcpy(ifinfo->dns[1], "0");
410
411 /*
412 * Run the script file "getipconfig.sh" to check the ip status
413 * (current implementation specific).
414 * note: "getipconfig.sh" is only defined for the current implementation
415 */
416 sprintf(gCmdStr, "getipconfig.sh /tmp/ipconfig.txt %s\n", ifname);
417
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800418 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000419
420 /* open the output result and scan/retrieve the info */
421 tmpfd = fopen("/tmp/ipconfig.txt", "r+");
422
423 if(tmpfd == NULL)
424 {
425 ipconfigResp->status = STATUS_ERROR;
426 wfaEncodeTLV(WFA_STA_GET_IP_CONFIG_RESP_TLV, 4, (BYTE *)ipconfigResp, respBuf);
427 *respLen = WFA_TLV_HDR_LEN + 4;
428
429 DPRINT_ERR(WFA_ERR, "file open failed\n");
430 return WFA_FAILURE;
431 }
432
433 for(;;)
434 {
435 if(fgets(string, 256, tmpfd) == NULL)
436 break;
437
438 /* check dhcp enabled */
439 if(strncmp(string, "dhcpcli", 7) ==0)
440 {
441 str = strtok(string, "=");
442 str = strtok(NULL, "=");
443 if(str != NULL)
444 ifinfo->isDhcp = 1;
445 else
446 ifinfo->isDhcp = 0;
447 }
448
449 /* find out the ip address */
450 if(strncmp(string, "ipaddr", 6) == 0)
451 {
452 str = strtok(string, "=");
453 str = strtok(NULL, " ");
454 if(str != NULL)
455 {
456 wSTRNCPY(ifinfo->ipaddr, str, 15);
457 ifinfo->ipaddr[15]='\0';
458 }
459 else
460 wSTRNCPY(ifinfo->ipaddr, "none", 15);
461 }
462
463 /* check the mask */
464 if(strncmp(string, "mask", 4) == 0)
465 {
466 char ttstr[16];
467 char *ttp = ttstr;
468
469 str = strtok_r(string, "=", &ttp);
470 if(*ttp != '\0')
471 {
472 strcpy(ifinfo->mask, ttp);
473 slen = strlen(ifinfo->mask);
474 ifinfo->mask[slen-1] = '\0';
475 }
476 else
477 strcpy(ifinfo->mask, "none");
478 }
479
480 /* find out the dns server ip address */
481 if(strncmp(string, "nameserv", 8) == 0)
482 {
483 char ttstr[16];
484 char *ttp = ttstr;
485
486 str = strtok_r(string, " ", &ttp);
487 if(str != NULL && i < 2)
488 {
489 strcpy(ifinfo->dns[i], ttp);
490 slen = strlen(ifinfo->dns[i]);
491 ifinfo->dns[i][slen-1] = '\0';
492 }
493 else
494 strcpy(ifinfo->dns[i], "none");
495
496 i++;
497 }
498 }
499
500 /*
501 * Report back the results
502 */
503 ipconfigResp->status = STATUS_COMPLETE;
504 wfaEncodeTLV(WFA_STA_GET_IP_CONFIG_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)ipconfigResp, respBuf);
505
506 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
507
508#if 0
509 DPRINT_INFO(WFA_OUT, "%i %i %s %s %s %s %i\n", ipconfigResp->status,
510 ifinfo->isDhcp, ifinfo->ipaddr, ifinfo->mask,
511 ifinfo->dns[0], ifinfo->dns[1], *respLen);
512#endif
513
514 fclose(tmpfd);
515 return WFA_SUCCESS;
516}
517
518/*
519 * wfaStaSetIpConfig():
520 * The function is to set the ip configuration to a wireless I/F.
521 * 1. IP address
522 * 2. Mac address
523 * 3. default gateway
524 * 4. dns nameserver (pri and sec).
525 */
526int wfaStaSetIpConfig(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
527{
528 dutCommand_t *setIpConf = (dutCommand_t *)caCmdBuf;
529 caStaSetIpConfig_t *ipconfig = &setIpConf->cmdsu.ipconfig;
530 dutCmdResponse_t *staSetIpResp = &gGenericResp;
531
532 DPRINT_INFO(WFA_OUT, "entering wfaStaSetIpConfig ...\n");
533
534 /*
535 * Use command 'ifconfig' to configure the interface ip address, mask.
536 * (Linux specific).
537 */
538 sprintf(gCmdStr, "/sbin/ifconfig %s %s netmask %s > /dev/null 2>&1 ", ipconfig->intf, ipconfig->ipaddr, ipconfig->mask);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800539 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000540
541 /* use command 'route add' to set set gatewway (linux specific) */
542 if(ipconfig->defGateway[0] != '\0')
543 {
544 sprintf(gCmdStr, "/sbin/route add default gw %s > /dev/null 2>&1", ipconfig->defGateway);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800545 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000546 }
547
548 /* set dns (linux specific) */
549 sprintf(gCmdStr, "cp /etc/resolv.conf /tmp/resolv.conf.bk");
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800550 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000551 sprintf(gCmdStr, "echo nameserv %s > /etc/resolv.conf", ipconfig->pri_dns);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800552 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000553 sprintf(gCmdStr, "echo nameserv %s >> /etc/resolv.conf", ipconfig->sec_dns);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800554 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000555
556 /*
557 * report status
558 */
559 staSetIpResp->status = STATUS_COMPLETE;
560 wfaEncodeTLV(WFA_STA_SET_IP_CONFIG_RESP_TLV, 4, (BYTE *)staSetIpResp, respBuf);
561 *respLen = WFA_TLV_HDR_LEN + 4;
562
563 return WFA_SUCCESS;
564}
565
566/*
567 * wfaStaVerifyIpConnection():
568 * The function is to verify if the station has IP connection with an AP by
569 * send ICMP/pings to the AP.
570 */
571int wfaStaVerifyIpConnection(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
572{
573 dutCommand_t *verip = (dutCommand_t *)caCmdBuf;
574 dutCmdResponse_t *verifyIpResp = &gGenericResp;
575
576#ifndef WFA_PING_UDP_ECHO_ONLY
577 char strout[64], *pcnt;
578 FILE *tmpfile;
579
580 DPRINT_INFO(WFA_OUT, "Entering wfaStaVerifyIpConnection ...\n");
581
582 /* set timeout value in case not set */
583 if(verip->cmdsu.verifyIp.timeout <= 0)
584 {
585 verip->cmdsu.verifyIp.timeout = 10;
586 }
587
588 /* execute the ping command and pipe the result to a tmp file */
589 sprintf(gCmdStr, "ping %s -c 3 -W %u | grep loss | cut -f3 -d, 1>& /tmp/pingout.txt", verip->cmdsu.verifyIp.dipaddr, verip->cmdsu.verifyIp.timeout);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800590 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000591
592 /* scan/check the output */
593 tmpfile = fopen("/tmp/pingout.txt", "r+");
594 if(tmpfile == NULL)
595 {
596 verifyIpResp->status = STATUS_ERROR;
597 wfaEncodeTLV(WFA_STA_VERIFY_IP_CONNECTION_RESP_TLV, 4, (BYTE *)verifyIpResp, respBuf);
598 *respLen = WFA_TLV_HDR_LEN + 4;
599
600 DPRINT_ERR(WFA_ERR, "file open failed\n");
601 return WFA_FAILURE;
602 }
603
604 verifyIpResp->status = STATUS_COMPLETE;
605 if(fscanf(tmpfile, "%s", strout) == EOF)
606 verifyIpResp->cmdru.connected = 0;
607 else
608 {
609 pcnt = strtok(strout, "%");
610
611 /* if the loss rate is 100%, not able to connect */
612 if(atoi(pcnt) == 100)
613 verifyIpResp->cmdru.connected = 0;
614 else
615 verifyIpResp->cmdru.connected = 1;
616 }
617
618 fclose(tmpfile);
619#else
620 int btSockfd;
621 struct pollfd fds[2];
622 int timeout = 2000;
623 char anyBuf[64];
624 struct sockaddr_in toAddr;
625 int done = 1, cnt = 0, ret, nbytes;
626
627 verifyIpResp->status = STATUS_COMPLETE;
628 verifyIpResp->cmdru.connected = 0;
629
630 btSockfd = wfaCreateUDPSock("127.0.0.1", WFA_UDP_ECHO_PORT);
631
632 if(btSockfd == -1)
633 {
634 verifyIpResp->status = STATUS_ERROR;
635 wfaEncodeTLV(WFA_STA_VERIFY_IP_CONNECTION_RESP_TLV, 4, (BYTE *)verifyIpResp, respBuf);
636 *respLen = WFA_TLV_HDR_LEN + 4;
637 return WFA_FAILURE;;
638 }
639
640 toAddr.sin_family = AF_INET;
641 toAddr.sin_addr.s_addr = inet_addr(verip->cmdsu.verifyIp.dipaddr);
642 toAddr.sin_port = htons(WFA_UDP_ECHO_PORT);
643
644 while(done)
645 {
646 wfaTrafficSendTo(btSockfd, (char *)anyBuf, 64, (struct sockaddr *)&toAddr);
647 cnt++;
648
649 fds[0].fd = btSockfd;
650 fds[0].events = POLLIN | POLLOUT;
651
652 ret = poll(fds, 1, timeout);
653 switch(ret)
654 {
655 case 0:
656 /* it is time out, count a packet lost*/
657 break;
658 case -1:
659 /* it is an error */
660 default:
661 {
662 switch(fds[0].revents)
663 {
664 case POLLIN:
665 case POLLPRI:
666 case POLLOUT:
667 nbytes = wfaTrafficRecv(btSockfd, (char *)anyBuf, (struct sockaddr *)&toAddr);
668 if(nbytes != 0)
669 verifyIpResp->cmdru.connected = 1;
670 done = 0;
671 break;
672 default:
673 /* errors but not care */
674 ;
675 }
676 }
677 }
678 if(cnt == 3)
679 {
680 done = 0;
681 }
682 }
683
684#endif
685
686 wfaEncodeTLV(WFA_STA_VERIFY_IP_CONNECTION_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)verifyIpResp, respBuf);
687
688 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
689
690 return WFA_SUCCESS;
691}
692
693/*
694 * wfaStaGetMacAddress()
695 * This function is to retrieve the MAC address of a wireless I/F.
696 */
697int wfaStaGetMacAddress(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
698{
699 dutCommand_t *getMac = (dutCommand_t *)caCmdBuf;
700 dutCmdResponse_t *getmacResp = &gGenericResp;
701 char *str;
702 char *ifname = getMac->intf;
703
704 FILE *tmpfd;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800705 char string[257];
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000706
707 DPRINT_INFO(WFA_OUT, "Entering wfaStaGetMacAddress ...\n");
708 /*
709 * run the script "getipconfig.sh" to find out the mac
710 */
711 //sprintf(gCmdStr, "getipconfig.sh /tmp/ipconfig.txt %s", ifname);
712 sprintf(gCmdStr, "ifconfig %s > /tmp/ipconfig.txt ", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800713 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000714
715 tmpfd = fopen("/tmp/ipconfig.txt", "r+");
716 if(tmpfd == NULL)
717 {
718 getmacResp->status = STATUS_ERROR;
719 wfaEncodeTLV(WFA_STA_GET_MAC_ADDRESS_RESP_TLV, 4, (BYTE *)getmacResp, respBuf);
720 *respLen = WFA_TLV_HDR_LEN + 4;
721
722 DPRINT_ERR(WFA_ERR, "file open failed\n");
723 return WFA_FAILURE;
724 }
725
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800726 if(fgets((char *)&string[0], 256, tmpfd) == NULL)
727 {
728 getmacResp->status = STATUS_ERROR;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000729 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800730
731 str = strtok(string, " ");
732 while(str && ((strcmp(str,"HWaddr")) != 0))
733 {
734 str = strtok(NULL, " ");
735 }
736
737 /* get mac */
738 if(str)
739 {
740 str = strtok(NULL, " ");
741 strcpy(getmacResp->cmdru.mac, str);
742 getmacResp->status = STATUS_COMPLETE;
743 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000744
745 wfaEncodeTLV(WFA_STA_GET_MAC_ADDRESS_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)getmacResp, respBuf);
746
747 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
748
749 fclose(tmpfd);
750 return WFA_SUCCESS;
751}
752
753/*
754 * wfaStaGetStats():
755 * The function is to retrieve the statistics of the I/F's layer 2 txFrames,
756 * rxFrames, txMulticast, rxMulticast, fcsErrors/crc, and txRetries.
757 * Currently there is not definition how to use these info.
758 */
759int wfaStaGetStats(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
760{
761 dutCmdResponse_t *statsResp = &gGenericResp;
762
763 /* this is never used, you can skip this call */
764
765 statsResp->status = STATUS_ERROR;
766 wfaEncodeTLV(WFA_STA_GET_STATS_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)statsResp, respBuf);
767 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
768
769
770 return WFA_SUCCESS;
771}
772
773/*
774 * wfaSetEncryption():
775 * The function is to set the wireless interface with WEP or none.
776 *
777 * Since WEP is optional test, current function is only used for
778 * resetting the Security to NONE/Plaintext (OPEN). To test WEP,
779 * this function should be replaced by the next one (wfaSetEncryption1())
780 *
781 * Input parameters:
782 * 1. I/F
783 * 2. ssid
784 * 3. encpType - wep or none
785 * Optional:
786 * 4. key1
787 * 5. key2
788 * 6. key3
789 * 7. key4
790 * 8. activeKey Index
791 */
792
793int wfaSetEncryption1(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
794{
795 caStaSetEncryption_t *setEncryp = (caStaSetEncryption_t *)caCmdBuf;
796 dutCmdResponse_t *setEncrypResp = &gGenericResp;
797
798 /*
799 * disable the network first
800 */
801 sprintf(gCmdStr, "wpa_cli -i %s disable_network 0", setEncryp->intf);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800802 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000803
804 /*
805 * set SSID
806 */
807 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 ssid '\"%s\"'", setEncryp->intf, setEncryp->ssid);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800808 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000809
810 /*
811 * Tell the supplicant for infrastructure mode (1)
812 */
813 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 mode 0", setEncryp->intf);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800814 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000815
816 /*
817 * set Key management to NONE (NO WPA) for plaintext or WEP
818 */
819 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt NONE", setEncryp->intf);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800820 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000821
822 sprintf(gCmdStr, "wpa_cli -i %s enable_network 0", setEncryp->intf);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800823 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000824
825 setEncrypResp->status = STATUS_COMPLETE;
826 wfaEncodeTLV(WFA_STA_SET_ENCRYPTION_RESP_TLV, 4, (BYTE *)setEncrypResp, respBuf);
827 *respLen = WFA_TLV_HDR_LEN + 4;
828
829 return WFA_SUCCESS;
830}
831
832/*
833 * Since WEP is optional, this function could be used to replace
834 * wfaSetEncryption() if necessary.
835 */
836int wfaSetEncryption(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
837{
838 caStaSetEncryption_t *setEncryp = (caStaSetEncryption_t *)caCmdBuf;
839 dutCmdResponse_t *setEncrypResp = &gGenericResp;
840 int i;
841
842 /*
843 * disable the network first
844 */
845 sprintf(gCmdStr, "wpa_cli -i %s disable_network 0", setEncryp->intf);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800846 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000847
848 /*
849 * set SSID
850 */
851 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 ssid '\"%s\"'", setEncryp->intf, setEncryp->ssid);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800852 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000853
854 /*
855 * Tell the supplicant for infrastructure mode (1)
856 */
857 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 mode 0", setEncryp->intf);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800858 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000859
860 /*
861 * set Key management to NONE (NO WPA) for plaintext or WEP
862 */
863 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt NONE", setEncryp->intf);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800864 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000865
866 /* set keys */
867 if(setEncryp->encpType == 1)
868 {
869 for(i=0; i<4; i++)
870 {
871 if(setEncryp->keys[i][0] != '\0')
872 {
873 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 wep_key%i %s",
874 setEncryp->intf, i, setEncryp->keys[i]);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800875 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000876 }
877 }
878
879 /* set active key */
880 i = setEncryp->activeKeyIdx;
881 if(setEncryp->keys[i][0] != '\0')
882 {
883 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 wep_tx_keyidx %i",
884 setEncryp->intf, setEncryp->activeKeyIdx);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800885 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000886 }
887 }
888 else /* clearly remove the keys -- reported by p.schwann */
889 {
890
891 for(i = 0; i < 4; i++)
892 {
893 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 wep_key%i \"\"", setEncryp->intf, i);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800894 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000895 }
896 }
897
898 sprintf(gCmdStr, "wpa_cli -i %s enable_network 0", setEncryp->intf);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800899 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000900
901 setEncrypResp->status = STATUS_COMPLETE;
902 wfaEncodeTLV(WFA_STA_SET_ENCRYPTION_RESP_TLV, 4, (BYTE *)setEncrypResp, respBuf);
903 *respLen = WFA_TLV_HDR_LEN + 4;
904
905 return WFA_SUCCESS;
906}
907
908int wfaStaSetSecurity(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
909{
910 int ret = WFA_SUCCESS;
911
912 return ret;
913}
914
915/*
916 * wfaStaSetEapTLS():
917 * This is to set
918 * 1. ssid
919 * 2. encrypType - tkip or aes-ccmp
920 * 3. keyManagementType - wpa or wpa2
921 * 4. trustedRootCA
922 * 5. clientCertificate
923 */
924int wfaStaSetEapTLS(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
925{
926 caStaSetEapTLS_t *setTLS = (caStaSetEapTLS_t *)caCmdBuf;
927 char *ifname = setTLS->intf;
928 dutCmdResponse_t *setEapTlsResp = &gGenericResp;
929
930 DPRINT_INFO(WFA_OUT, "Entering wfaStaSetEapTLS ...\n");
931
932 /*
933 * need to store the trustedROOTCA and clientCertificate into a file first.
934 */
935#ifdef WFA_NEW_CLI_FORMAT
936 sprintf(gCmdStr, "wfa_set_eaptls -i %s %s %s %s", ifname, setTLS->ssid, setTLS->trustedRootCA, setTLS->clientCertificate);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800937 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000938#else
939
940 sprintf(gCmdStr, "wpa_cli -i %s disable_network 0", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800941 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000942
943 /* ssid */
944 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 ssid '\"%s\"'", ifname, setTLS->ssid);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800945 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000946
947 /* key management */
948 if(strcasecmp(setTLS->keyMgmtType, "wpa2-sha256") == 0)
949 {
950 }
951 else if(strcasecmp(setTLS->keyMgmtType, "wpa2-eap") == 0)
952 {
953 }
954 else if(strcasecmp(setTLS->keyMgmtType, "wpa2-ft") == 0)
955 {
956
957 }
958 else if(strcasecmp(setTLS->keyMgmtType, "wpa") == 0)
959 {
960 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt WPA-EAP", ifname);
961 }
962 else if(strcasecmp(setTLS->keyMgmtType, "wpa2") == 0)
963 {
964 // to take all and device to pick any one supported.
965 }
966 else
967 {
968 // ??
969 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800970 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000971
972 /* protocol WPA */
973 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 proto WPA", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800974 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000975
976 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 eap TLS", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800977 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000978
979 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 ca_cert '\"%s\"'", ifname, setTLS->trustedRootCA);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800980 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000981
982 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 identity '\"wifi-user@wifilabs.local\"'", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800983 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000984
985 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 private_key '\"%s/%s\"'", ifname, CERTIFICATES_PATH, setTLS->clientCertificate);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800986 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000987
988 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 private_key_passwd '\"wifi\"'", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800989 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000990
991 sprintf(gCmdStr, "wpa_cli -i %s enable_network 0", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800992 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000993#endif
994
995 setEapTlsResp->status = STATUS_COMPLETE;
996 wfaEncodeTLV(WFA_STA_SET_EAPTLS_RESP_TLV, 4, (BYTE *)setEapTlsResp, respBuf);
997 *respLen = WFA_TLV_HDR_LEN + 4;
998
999 return WFA_SUCCESS;
1000}
1001
1002/*
1003 * The function is to set
1004 * 1. ssid
1005 * 2. passPhrase
1006 * 3. keyMangementType - wpa/wpa2
1007 * 4. encrypType - tkip or aes-ccmp
1008 */
1009int wfaStaSetPSK(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1010{
1011 caStaSetPSK_t *setPSK = (caStaSetPSK_t *)caCmdBuf;
1012 dutCmdResponse_t *setPskResp = &gGenericResp;
1013
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001014#ifdef WFA_NEW_CLI_FORMAT
1015 sprintf(gCmdStr, "wfa_set_psk %s %s %s", setPSK->intf, setPSK->ssid, setPSK->passphrase);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001016 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001017#else
1018 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 ssid '\"%s\"'", setPSK->intf, setPSK->ssid);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001019 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001020
1021 if(strcasecmp(setPSK->keyMgmtType, "wpa2-sha256") == 0)
1022 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt WPA2-SHA256", setPSK->intf);
1023 else if(strcasecmp(setPSK->keyMgmtType, "wpa2") == 0)
1024 {
1025 // take all and device to pick it supported.
1026 }
1027 else if(strcasecmp(setPSK->keyMgmtType, "wpa2-psk") == 0)
1028 {
1029
1030 }
1031 else if(strcasecmp(setPSK->keyMgmtType, "wpa2-ft") == 0)
1032 {
1033
1034 }
1035 else
1036 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt WPA-PSK", setPSK->intf);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001037
1038 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001039
1040 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 psk '\"%s\"'", setPSK->intf, setPSK->passphrase);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001041 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001042
1043 sprintf(gCmdStr, "wpa_cli -i %s enable_network 0", setPSK->intf);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001044 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001045
1046 /* if PMF enable */
1047 if(setPSK->pmf == WFA_ENABLED || setPSK->pmf == WFA_OPTIONAL)
1048 {
1049
1050 }
1051 else if(setPSK->pmf == WFA_REQUIRED)
1052 {
1053
1054 }
1055 else if(setPSK->pmf == WFA_F_REQUIRED)
1056 {
1057
1058 }
1059 else if(setPSK->pmf == WFA_F_DISABLED)
1060 {
1061
1062 }
1063 else
1064 { /* Disable PMF */
1065
1066 }
1067
1068#endif
1069
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001070 setPskResp->status = STATUS_COMPLETE;
1071 wfaEncodeTLV(WFA_STA_SET_PSK_RESP_TLV, 4, (BYTE *)setPskResp, respBuf);
1072 *respLen = WFA_TLV_HDR_LEN + 4;
1073
1074 return WFA_SUCCESS;
1075}
1076
1077/*
1078 * wfaStaGetInfo():
1079 * Get vendor specific information in name/value pair by a wireless I/F.
1080 */
1081int wfaStaGetInfo(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1082{
1083 dutCmdResponse_t infoResp;
1084 dutCommand_t *getInfo = (dutCommand_t *)caCmdBuf;
1085
1086 /*
1087 * Normally this is called to retrieve the vendor information
1088 * from a interface, no implement yet
1089 */
1090 sprintf(infoResp.cmdru.info, "interface,%s,vendor,XXX,cardtype,802.11a/b/g", getInfo->intf);
1091
1092 infoResp.status = STATUS_COMPLETE;
1093 wfaEncodeTLV(WFA_STA_GET_INFO_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
1094 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
1095
1096 return WFA_SUCCESS;
1097}
1098
1099/*
1100 * wfaStaSetEapTTLS():
1101 * This is to set
1102 * 1. ssid
1103 * 2. username
1104 * 3. passwd
1105 * 4. encrypType - tkip or aes-ccmp
1106 * 5. keyManagementType - wpa or wpa2
1107 * 6. trustedRootCA
1108 */
1109int wfaStaSetEapTTLS(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1110{
1111 caStaSetEapTTLS_t *setTTLS = (caStaSetEapTTLS_t *)caCmdBuf;
1112 char *ifname = setTTLS->intf;
1113 dutCmdResponse_t *setEapTtlsResp = &gGenericResp;
1114
1115#ifdef WFA_NEW_CLI_FORMAT
1116 sprintf(gCmdStr, "wfa_set_eapttls %s %s %s %s %s", ifname, setTTLS->ssid, setTTLS->username, setTTLS->passwd, setTTLS->trustedRootCA);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001117 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001118#else
1119
1120 sprintf(gCmdStr, "wpa_cli -i %s disable_network 0", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001121 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001122
1123 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 ssid '\"%s\"'", ifname, setTTLS->ssid);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001124 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001125
1126 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 identity '\"%s\"'", ifname, setTTLS->username);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001127 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001128
1129 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 password '\"%s\"'", ifname, setTTLS->passwd);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001130 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001131
1132 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt WPA-EAP", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001133 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001134
1135/* This may not need to set. if it is not set, default to take all */
1136// sprintf(cmdStr, "wpa_cli -i %s set_network 0 pairwise '\"%s\"", ifname, setTTLS->encrptype);
1137 if(strcasecmp(setTTLS->keyMgmtType, "wpa2-sha256") == 0)
1138 {
1139 }
1140 else if(strcasecmp(setTTLS->keyMgmtType, "wpa2-eap") == 0)
1141 {
1142 }
1143 else if(strcasecmp(setTTLS->keyMgmtType, "wpa2-ft") == 0)
1144 {
1145
1146 }
1147 else if(strcasecmp(setTTLS->keyMgmtType, "wpa") == 0)
1148 {
1149
1150 }
1151 else if(strcasecmp(setTTLS->keyMgmtType, "wpa2") == 0)
1152 {
1153 // to take all and device to pick one it supported
1154 }
1155 else
1156 {
1157 // ??
1158 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001159 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001160
1161 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 eap TTLS", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001162 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001163
1164 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 ca_cert '\"%s/%s\"'", ifname, CERTIFICATES_PATH, setTTLS->trustedRootCA);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001165 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001166
1167 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 proto WPA", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001168 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001169
1170// sprintf(gCmdStr, "wpa_cli -i %s set_network 0 anonymous_identity '\"anonymous\"'", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001171// sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001172
1173 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 phase2 '\"auth=MSCHAPV2\"'", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001174 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001175
1176 sprintf(gCmdStr, "wpa_cli -i %s enable_network 0", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001177 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001178#endif
1179
1180 setEapTtlsResp->status = STATUS_COMPLETE;
1181 wfaEncodeTLV(WFA_STA_SET_EAPTTLS_RESP_TLV, 4, (BYTE *)setEapTtlsResp, respBuf);
1182 *respLen = WFA_TLV_HDR_LEN + 4;
1183
1184 return WFA_SUCCESS;
1185}
1186
1187/*
1188 * wfaStaSetEapSIM():
1189 * This is to set
1190 * 1. ssid
1191 * 2. user name
1192 * 3. passwd
1193 * 4. encrypType - tkip or aes-ccmp
1194 * 5. keyMangementType - wpa or wpa2
1195 */
1196int wfaStaSetEapSIM(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1197{
1198 caStaSetEapSIM_t *setSIM = (caStaSetEapSIM_t *)caCmdBuf;
1199 char *ifname = setSIM->intf;
1200 dutCmdResponse_t *setEapSimResp = &gGenericResp;
1201
1202#ifdef WFA_NEW_CLI_FORMAT
1203 sprintf(gCmdStr, "wfa_set_eapsim %s %s %s %s", ifname, setSIM->ssid, setSIM->username, setSIM->encrptype);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001204 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001205#else
1206
1207 sprintf(gCmdStr, "wpa_cli -i %s disable_network 0", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001208 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001209
1210 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 ssid '\"%s\"'", ifname, setSIM->ssid);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001211 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001212
1213
1214 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 identity '\"%s\"'", ifname, setSIM->username);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001215 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001216
1217 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 pairwise '\"%s\"'", ifname, setSIM->encrptype);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001218 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001219
1220 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 eap SIM", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001221 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001222
1223 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 proto WPA", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001224 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001225
1226 sprintf(gCmdStr, "wpa_cli -i %s enable_network 0", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001227 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001228
1229 if(strcasecmp(setSIM->keyMgmtType, "wpa2-sha256") == 0)
1230 {
1231 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt WPA-SHA256", ifname);
1232 }
1233 else if(strcasecmp(setSIM->keyMgmtType, "wpa2-eap") == 0)
1234 {
1235 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt WPA-EAP", ifname);
1236 }
1237 else if(strcasecmp(setSIM->keyMgmtType, "wpa2-ft") == 0)
1238 {
1239 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt WPA-FT", ifname);
1240 }
1241 else if(strcasecmp(setSIM->keyMgmtType, "wpa") == 0)
1242 {
1243 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt WPA-EAP", ifname);
1244 }
1245 else if(strcasecmp(setSIM->keyMgmtType, "wpa2") == 0)
1246 {
1247 // take all and device to pick one which is supported.
1248 }
1249 else
1250 {
1251 // ??
1252 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001253 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001254
1255#endif
1256
1257 setEapSimResp->status = STATUS_COMPLETE;
1258 wfaEncodeTLV(WFA_STA_SET_EAPSIM_RESP_TLV, 4, (BYTE *)setEapSimResp, respBuf);
1259 *respLen = WFA_TLV_HDR_LEN + 4;
1260
1261 return WFA_SUCCESS;
1262}
1263
1264/*
1265 * wfaStaSetPEAP()
1266 * This is to set
1267 * 1. ssid
1268 * 2. user name
1269 * 3. passwd
1270 * 4. encryType - tkip or aes-ccmp
1271 * 5. keyMgmtType - wpa or wpa2
1272 * 6. trustedRootCA
1273 * 7. innerEAP
1274 * 8. peapVersion
1275 */
1276int wfaStaSetPEAP(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1277{
1278 caStaSetEapPEAP_t *setPEAP = (caStaSetEapPEAP_t *)caCmdBuf;
1279 char *ifname = setPEAP->intf;
1280 dutCmdResponse_t *setPeapResp = &gGenericResp;
1281
1282#ifdef WFA_NEW_CLI_FORMAT
1283 sprintf(gCmdStr, "wfa_set_peap %s %s %s %s %s %s %i %s", ifname, setPEAP->ssid, setPEAP->username,
1284 setPEAP->passwd, setPEAP->trustedRootCA,
1285 setPEAP->encrptype, setPEAP->peapVersion,
1286 setPEAP->innerEAP);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001287 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001288#else
1289
1290 sprintf(gCmdStr, "wpa_cli -i %s disable_network 0", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001291 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001292
1293 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 ssid '\"%s\"'", ifname, setPEAP->ssid);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001294 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001295
1296 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 eap PEAP", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001297 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001298
1299 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 anonymous_identity '\"anonymous\"' ", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001300 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001301
1302 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 identity '\"%s\"'", ifname, setPEAP->username);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001303 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001304
1305 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 password '\"%s\"'", ifname, setPEAP->passwd);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001306 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001307
1308 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 ca_cert '\"%s/%s\"'", ifname, CERTIFICATES_PATH, setPEAP->trustedRootCA);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001309 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001310
1311 /* if this not set, default to set support all */
1312 //sprintf(gCmdStr, "wpa_cli -i %s set_network 0 pairwise '\"%s\"'", ifname, setPEAP->encrptype);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001313 //sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001314
1315 if(strcasecmp(setPEAP->keyMgmtType, "wpa2-sha256") == 0)
1316 {
1317 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt WPA-SHA256", ifname);
1318 }
1319 else if(strcasecmp(setPEAP->keyMgmtType, "wpa2-eap") == 0)
1320 {
1321 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt WPA-EAP", ifname);
1322 }
1323 else if(strcasecmp(setPEAP->keyMgmtType, "wpa2-ft") == 0)
1324 {
1325 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt WPA-FT", ifname);
1326 }
1327 else if(strcasecmp(setPEAP->keyMgmtType, "wpa") == 0)
1328 {
1329 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt WPA-EAP", ifname);
1330 }
1331 else if(strcasecmp(setPEAP->keyMgmtType, "wpa2") == 0)
1332 {
1333 // take all and device to pick one which is supported.
1334 }
1335 else
1336 {
1337 // ??
1338 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001339 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001340
1341 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 phase1 '\"peaplabel=%i\"'", ifname, setPEAP->peapVersion);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001342 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001343
1344 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 phase2 '\"auth=%s\"'", ifname, setPEAP->innerEAP);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001345 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001346
1347 sprintf(gCmdStr, "wpa_cli -i %s enable_network 0", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001348 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001349#endif
1350
1351 setPeapResp->status = STATUS_COMPLETE;
1352 wfaEncodeTLV(WFA_STA_SET_PEAP_RESP_TLV, 4, (BYTE *)setPeapResp, respBuf);
1353 *respLen = WFA_TLV_HDR_LEN + 4;
1354
1355 return WFA_SUCCESS;
1356}
1357
1358/*
1359 * wfaStaSetUAPSD()
1360 * This is to set
1361 * 1. acBE
1362 * 2. acBK
1363 * 3. acVI
1364 * 4. acVO
1365 */
1366int wfaStaSetUAPSD(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1367{
1368 dutCmdResponse_t *setUAPSDResp = &gGenericResp;
1369#if 0 /* used for only one specific device, need to update to reflect yours */
1370 caStaSetUAPSD_t *setUAPSD = (caStaSetUAPSD_t *)caCmdBuf;
1371 char *ifname = setUAPSD->intf;
1372 char tmpStr[10];
1373 char line[100];
1374 char *pathl="/etc/Wireless/RT61STA";
1375 BYTE acBE=1;
1376 BYTE acBK=1;
1377 BYTE acVO=1;
1378 BYTE acVI=1;
1379 BYTE APSDCapable;
1380 FILE *pipe;
1381
1382 /*
1383 * A series of setting need to be done before doing WMM-PS
1384 * Additional steps of configuration may be needed.
1385 */
1386
1387 /*
1388 * bring down the interface
1389 */
1390 sprintf(gCmdStr, "ifconfig %s down",ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001391 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001392 /*
1393 * Unload the Driver
1394 */
1395 sprintf(gCmdStr, "rmmod rt61");
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001396 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001397#ifndef WFA_WMM_AC
1398 if(setUAPSD->acBE != 1)
1399 acBE=setUAPSD->acBE = 0;
1400 if(setUAPSD->acBK != 1)
1401 acBK=setUAPSD->acBK = 0;
1402 if(setUAPSD->acVO != 1)
1403 acVO=setUAPSD->acVO = 0;
1404 if(setUAPSD->acVI != 1)
1405 acVI=setUAPSD->acVI = 0;
1406#else
1407 acBE=setUAPSD->acBE;
1408 acBK=setUAPSD->acBK;
1409 acVO=setUAPSD->acVO;
1410 acVI=setUAPSD->acVI;
1411#endif
1412
1413 APSDCapable = acBE||acBK||acVO||acVI;
1414 /*
1415 * set other AC parameters
1416 */
1417
1418 sprintf(tmpStr,"%d;%d;%d;%d",setUAPSD->acBE,setUAPSD->acBK,setUAPSD->acVI,setUAPSD->acVO);
1419 sprintf(gCmdStr, "sed -e \"s/APSDCapable=.*/APSDCapable=%d/g\" -e \"s/APSDAC=.*/APSDAC=%s/g\" %s/rt61sta.dat >/tmp/wfa_tmp",APSDCapable,tmpStr,pathl);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001420 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001421
1422 sprintf(gCmdStr, "mv /tmp/wfa_tmp %s/rt61sta.dat",pathl);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001423 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001424 pipe = popen("uname -r", "r");
1425 /* Read into line the output of uname*/
1426 fscanf(pipe,"%s",line);
1427 pclose(pipe);
1428
1429 /*
1430 * load the Driver
1431 */
1432 sprintf(gCmdStr, "insmod /lib/modules/%s/extra/rt61.ko",line);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001433 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001434
1435 sprintf(gCmdStr, "ifconfig %s up",ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001436 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001437#endif
1438
1439 setUAPSDResp->status = STATUS_COMPLETE;
1440 wfaEncodeTLV(WFA_STA_SET_UAPSD_RESP_TLV, 4, (BYTE *)setUAPSDResp, respBuf);
1441 *respLen = WFA_TLV_HDR_LEN + 4;
1442 return WFA_SUCCESS;
1443}
1444
1445int wfaDeviceGetInfo(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1446{
1447 dutCommand_t *dutCmd = (dutCommand_t *)caCmdBuf;
1448 caDevInfo_t *devInfo = &dutCmd->cmdsu.dev;
1449 dutCmdResponse_t *infoResp = &gGenericResp;
1450 /*a vendor can fill in the proper info or anything non-disclosure */
1451 caDeviceGetInfoResp_t dinfo = {"WFA Lab", "DemoUnit", WFA_SYSTEM_VER};
1452
1453 DPRINT_INFO(WFA_OUT, "Entering wfaDeviceGetInfo ...\n");
1454
1455 if(devInfo->fw == 0)
1456 memcpy(&infoResp->cmdru.devInfo, &dinfo, sizeof(caDeviceGetInfoResp_t));
1457 else
1458 {
1459 // Call internal API to pull the version ID */
1460 memcpy(infoResp->cmdru.devInfo.firmware, "NOVERSION", 15);
1461 }
1462
1463 infoResp->status = STATUS_COMPLETE;
1464 wfaEncodeTLV(WFA_DEVICE_GET_INFO_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)infoResp, respBuf);
1465 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
1466
1467 return WFA_SUCCESS;
1468
1469}
1470
1471/*
1472 * This funciton is to retrieve a list of interfaces and return
1473 * the list back to Agent control.
1474 * ********************************************************************
1475 * Note: We intend to make this WLAN interface name as a hardcode name.
1476 * Therefore, for a particular device, you should know and change the name
1477 * for that device while doing porting. The MACRO "WFA_STAUT_IF" is defined in
1478 * the file "inc/wfa_ca.h". If the device OS is not linux-like, this most
1479 * likely is hardcoded just for CAPI command responses.
1480 * *******************************************************************
1481 *
1482 */
1483int wfaDeviceListIF(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1484{
1485 dutCmdResponse_t *infoResp = &gGenericResp;
1486 dutCommand_t *ifList = (dutCommand_t *)caCmdBuf;
1487 caDeviceListIFResp_t *ifListResp = &infoResp->cmdru.ifList;
1488
1489 DPRINT_INFO(WFA_OUT, "Entering wfaDeviceListIF ...\n");
1490
1491 switch(ifList->cmdsu.iftype)
1492 {
1493 case IF_80211:
1494 infoResp->status = STATUS_COMPLETE;
1495 ifListResp->iftype = IF_80211;
1496 strcpy(ifListResp->ifs[0], WFA_STAUT_IF);
1497 strcpy(ifListResp->ifs[1], "NULL");
1498 strcpy(ifListResp->ifs[2], "NULL");
1499 break;
1500 case IF_ETH:
1501 infoResp->status = STATUS_COMPLETE;
1502 ifListResp->iftype = IF_ETH;
1503 strcpy(ifListResp->ifs[0], "eth0");
1504 strcpy(ifListResp->ifs[1], "NULL");
1505 strcpy(ifListResp->ifs[2], "NULL");
1506 break;
1507 default:
1508 {
1509 infoResp->status = STATUS_ERROR;
1510 wfaEncodeTLV(WFA_DEVICE_LIST_IF_RESP_TLV, 4, (BYTE *)infoResp, respBuf);
1511 *respLen = WFA_TLV_HDR_LEN + 4;
1512
1513 return WFA_SUCCESS;
1514 }
1515 }
1516
1517 wfaEncodeTLV(WFA_DEVICE_LIST_IF_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)infoResp, respBuf);
1518 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
1519
1520 return WFA_SUCCESS;
1521}
1522
1523int wfaStaDebugSet(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1524{
1525 dutCmdResponse_t *debugResp = &gGenericResp;
1526 dutCommand_t *debugSet = (dutCommand_t *)caCmdBuf;
1527
1528 DPRINT_INFO(WFA_OUT, "Entering wfaStaDebugSet ...\n");
1529
1530 if(debugSet->cmdsu.dbg.state == 1) /* enable */
1531 wfa_defined_debug |= debugSet->cmdsu.dbg.level;
1532 else
1533 wfa_defined_debug = (~debugSet->cmdsu.dbg.level & wfa_defined_debug);
1534
1535 debugResp->status = STATUS_COMPLETE;
1536 wfaEncodeTLV(WFA_STA_GET_INFO_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)debugResp, respBuf);
1537 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
1538
1539
1540 return WFA_SUCCESS;
1541}
1542
1543
1544/*
1545 * wfaStaGetBSSID():
1546 * This function is to retrieve BSSID of a specific wireless I/F.
1547 */
1548int wfaStaGetBSSID(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1549{
1550 char string[64];
1551 char *str;
1552 FILE *tmpfd;
1553 dutCmdResponse_t *bssidResp = &gGenericResp;
1554
1555 DPRINT_INFO(WFA_OUT, "Entering wfaStaGetBSSID ...\n");
1556 /* retrieve the BSSID */
1557 sprintf(gCmdStr, "wpa_cli status > /tmp/bssid.txt");
1558
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001559 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001560
1561 tmpfd = fopen("/tmp/bssid.txt", "r+");
1562 if(tmpfd == NULL)
1563 {
1564 bssidResp->status = STATUS_ERROR;
1565 wfaEncodeTLV(WFA_STA_GET_BSSID_RESP_TLV, 4, (BYTE *)bssidResp, respBuf);
1566 *respLen = WFA_TLV_HDR_LEN + 4;
1567
1568 DPRINT_ERR(WFA_ERR, "file open failed\n");
1569 return WFA_FAILURE;
1570 }
1571
1572 for(;;)
1573 {
1574 if(fscanf(tmpfd, "%s", string) == EOF)
1575 {
1576 bssidResp->status = STATUS_COMPLETE;
1577 strcpy(bssidResp->cmdru.bssid, "00:00:00:00:00:00");
1578 break;
1579 }
1580
1581 if(strncmp(string, "bssid", 5) == 0)
1582 {
1583 str = strtok(string, "=");
1584 str = strtok(NULL, "=");
1585 if(str != NULL)
1586 {
1587 strcpy(bssidResp->cmdru.bssid, str);
1588 bssidResp->status = STATUS_COMPLETE;
1589 break;
1590 }
1591 }
1592 }
1593
1594 wfaEncodeTLV(WFA_STA_GET_BSSID_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)bssidResp, respBuf);
1595 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
1596
1597 fclose(tmpfd);
1598 return WFA_SUCCESS;
1599}
1600
1601/*
1602 * wfaStaSetIBSS()
1603 * This is to set
1604 * 1. ssid
1605 * 2. channel
1606 * 3. encrypType - none or wep
1607 * optional
1608 * 4. key1
1609 * 5. key2
1610 * 6. key3
1611 * 7. key4
1612 * 8. activeIndex - 1, 2, 3, or 4
1613 */
1614int wfaStaSetIBSS(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1615{
1616 caStaSetIBSS_t *setIBSS = (caStaSetIBSS_t *)caCmdBuf;
1617 dutCmdResponse_t *setIbssResp = &gGenericResp;
1618 int i;
1619
1620 /*
1621 * disable the network first
1622 */
1623 sprintf(gCmdStr, "wpa_cli -i %s disable_network 0", setIBSS->intf);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001624 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001625
1626 /*
1627 * set SSID
1628 */
1629 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 ssid '\"%s\"'", setIBSS->intf, setIBSS->ssid);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001630 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001631
1632 /*
1633 * Set channel for IBSS
1634 */
1635 sprintf(gCmdStr, "iwconfig %s channel %i", setIBSS->intf, setIBSS->channel);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001636 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001637
1638 /*
1639 * Tell the supplicant for IBSS mode (1)
1640 */
1641 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 mode 1", setIBSS->intf);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001642 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001643
1644 /*
1645 * set Key management to NONE (NO WPA) for plaintext or WEP
1646 */
1647 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt NONE", setIBSS->intf);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001648 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001649
1650 if(setIBSS->encpType == 1)
1651 {
1652 for(i=0; i<4; i++)
1653 {
1654 if(strlen(setIBSS->keys[i]) ==5 || strlen(setIBSS->keys[i]) == 13)
1655 {
1656 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 wep_key%i \"%s\"",
1657 setIBSS->intf, i, setIBSS->keys[i]);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001658 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001659 }
1660 }
1661
1662 i = setIBSS->activeKeyIdx;
1663 if(strlen(setIBSS->keys[i]) ==5 || strlen(setIBSS->keys[i]) == 13)
1664 {
1665 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 wep_tx_keyidx %i",
1666 setIBSS->intf, setIBSS->activeKeyIdx);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001667 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001668 }
1669 }
1670
1671 sprintf(gCmdStr, "wpa_cli -i %s enable_network 0", setIBSS->intf);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001672 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001673
1674 setIbssResp->status = STATUS_COMPLETE;
1675 wfaEncodeTLV(WFA_STA_SET_IBSS_RESP_TLV, 4, (BYTE *)setIbssResp, respBuf);
1676 *respLen = WFA_TLV_HDR_LEN + 4;
1677
1678 return WFA_SUCCESS;
1679}
1680
1681/*
1682 * wfaSetMode():
1683 * The function is to set the wireless interface with a given mode (possible
1684 * adhoc)
1685 * Input parameters:
1686 * 1. I/F
1687 * 2. ssid
1688 * 3. mode adhoc or managed
1689 * 4. encType
1690 * 5. channel
1691 * 6. key(s)
1692 * 7. active key
1693 */
1694int wfaStaSetMode(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1695{
1696 caStaSetMode_t *setmode = (caStaSetMode_t *)caCmdBuf;
1697 dutCmdResponse_t *SetModeResp = &gGenericResp;
1698 int i;
1699
1700 /*
1701 * bring down the interface
1702 */
1703 sprintf(gCmdStr, "ifconfig %s down",setmode->intf);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001704 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001705
1706 /*
1707 * distroy the interface
1708 */
1709 sprintf(gCmdStr, "wlanconfig %s destroy",setmode->intf);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001710 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001711
1712
1713 /*
1714 * re-create the interface with the given mode
1715 */
1716 if(setmode->mode == 1)
1717 sprintf(gCmdStr, "wlanconfig %s create wlandev wifi0 wlanmode adhoc",setmode->intf);
1718 else
1719 sprintf(gCmdStr, "wlanconfig %s create wlandev wifi0 wlanmode managed",setmode->intf);
1720
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001721 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001722 if(setmode->encpType == ENCRYPT_WEP)
1723 {
1724 int j = setmode->activeKeyIdx;
1725 for(i=0; i<4; i++)
1726 {
1727 if(setmode->keys[i][0] != '\0')
1728 {
1729 sprintf(gCmdStr, "iwconfig %s key s:%s",
1730 setmode->intf, setmode->keys[i]);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001731 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001732 }
1733 /* set active key */
1734 if(setmode->keys[j][0] != '\0')
1735 sprintf(gCmdStr, "iwconfig %s key s:%s",
1736 setmode->intf, setmode->keys[j]);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001737 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001738 }
1739
1740 }
1741 /*
1742 * Set channel for IBSS
1743 */
1744 if(setmode->channel)
1745 {
1746 sprintf(gCmdStr, "iwconfig %s channel %i", setmode->intf, setmode->channel);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001747 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001748 }
1749
1750
1751 /*
1752 * set SSID
1753 */
1754 sprintf(gCmdStr, "iwconfig %s essid %s", setmode->intf, setmode->ssid);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001755 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001756
1757 /*
1758 * bring up the interface
1759 */
1760 sprintf(gCmdStr, "ifconfig %s up",setmode->intf);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001761 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001762
1763 SetModeResp->status = STATUS_COMPLETE;
1764 wfaEncodeTLV(WFA_STA_SET_MODE_RESP_TLV, 4, (BYTE *)SetModeResp, respBuf);
1765 *respLen = WFA_TLV_HDR_LEN + 4;
1766
1767 return WFA_SUCCESS;
1768}
1769
1770int wfaStaSetPwrSave(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1771{
1772 caStaSetPwrSave_t *setps = (caStaSetPwrSave_t *)caCmdBuf;
1773 dutCmdResponse_t *SetPSResp = &gGenericResp;
1774
1775 sprintf(gCmdStr, "iwconfig %s power %s", setps->intf, setps->mode);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001776 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001777
1778
1779 SetPSResp->status = STATUS_COMPLETE;
1780 wfaEncodeTLV(WFA_STA_SET_PWRSAVE_RESP_TLV, 4, (BYTE *)SetPSResp, respBuf);
1781 *respLen = WFA_TLV_HDR_LEN + 4;
1782
1783 return WFA_SUCCESS;
1784}
1785
1786int wfaStaUpload(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1787{
1788 caStaUpload_t *upload = &((dutCommand_t *)caCmdBuf)->cmdsu.upload;
1789 dutCmdResponse_t *upLoadResp = &gGenericResp;
1790 caStaUploadResp_t *upld = &upLoadResp->cmdru.uld;
1791
1792 if(upload->type == WFA_UPLOAD_VHSO_RPT)
1793 {
1794 int rbytes;
1795 /*
1796 * if asked for the first packet, always to open the file
1797 */
1798 if(upload->next == 1)
1799 {
1800 if(e2efp != NULL)
1801 {
1802 fclose(e2efp);
1803 e2efp = NULL;
1804 }
1805
1806 e2efp = fopen(e2eResults, "r");
1807 }
1808
1809 if(e2efp == NULL)
1810 {
1811 upLoadResp->status = STATUS_ERROR;
1812 wfaEncodeTLV(WFA_STA_UPLOAD_RESP_TLV, 4, (BYTE *)upLoadResp, respBuf);
1813 *respLen = WFA_TLV_HDR_LEN + 4;
1814 return WFA_FAILURE;
1815 }
1816
1817 rbytes = fread(upld->bytes, 1, 256, e2efp);
1818
1819 if(rbytes < 256)
1820 {
1821 /*
1822 * this means no more bytes after this read
1823 */
1824 upld->seqnum = 0;
1825 fclose(e2efp);
1826 e2efp=NULL;
1827 }
1828 else
1829 {
1830 upld->seqnum = upload->next;
1831 }
1832
1833 upld->nbytes = rbytes;
1834
1835 upLoadResp->status = STATUS_COMPLETE;
1836 wfaEncodeTLV(WFA_STA_UPLOAD_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)upLoadResp, respBuf);
1837 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
1838 }
1839 else
1840 {
1841 upLoadResp->status = STATUS_ERROR;
1842 wfaEncodeTLV(WFA_STA_UPLOAD_RESP_TLV, 4, (BYTE *)upLoadResp, respBuf);
1843 *respLen = WFA_TLV_HDR_LEN + 4;
1844 }
1845
1846 return WFA_SUCCESS;
1847}
1848/*
1849 * wfaStaSetWMM()
1850 * TO be ported on a specific plaform for the DUT
1851 * This is to set the WMM related parameters at the DUT.
1852 * Currently the function is used for GROUPS WMM-AC and WMM general configuration for setting RTS Threshhold, Fragmentation threshold and wmm (ON/OFF)
1853 * It is expected that this function will set all the WMM related parametrs for a particular GROUP .
1854 */
1855int wfaStaSetWMM(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1856{
1857#ifdef WFA_WMM_AC
1858 caStaSetWMM_t *setwmm = (caStaSetWMM_t *)caCmdBuf;
1859 char *ifname = setwmm->intf;
1860 dutCmdResponse_t *setwmmResp = &gGenericResp;
1861 //IEEEtypes_WMM_TSPEC_t tspec;
1862
1863 switch(setwmm->group)
1864 {
1865 case GROUP_WMMAC:
1866 if (setwmm->send_trig)
1867 {
1868 int Sockfd;
1869 struct sockaddr_in psToAddr;
1870 unsigned int TxMsg[512];
1871
1872 Sockfd = wfaCreateUDPSock(setwmm->dipaddr, 12346);
1873 memset(&psToAddr, 0, sizeof(psToAddr));
1874 psToAddr.sin_family = AF_INET;
1875 psToAddr.sin_addr.s_addr = inet_addr(setwmm->dipaddr);
1876 psToAddr.sin_port = htons(12346);
1877
1878
1879 switch (setwmm->trig_ac)
1880 {
1881 case WMMAC_AC_VO:
1882 wfaTGSetPrio(Sockfd, 7);
1883 create_apts_msg(APTS_CK_VO, TxMsg, 0);
1884 printf("\r\nSending AC_VO trigger packet\n");
1885 break;
1886
1887 case WMMAC_AC_VI:
1888 wfaTGSetPrio(Sockfd, 5);
1889 create_apts_msg(APTS_CK_VI, TxMsg, 0);
1890 printf("\r\nSending AC_VI trigger packet\n");
1891 break;
1892
1893 case WMMAC_AC_BK:
1894 wfaTGSetPrio(Sockfd, 2);
1895 create_apts_msg(APTS_CK_BK, TxMsg, 0);
1896 printf("\r\nSending AC_BK trigger packet\n");
1897 break;
1898
1899 default:
1900 case WMMAC_AC_BE:
1901 wfaTGSetPrio(Sockfd, 0);
1902 create_apts_msg(APTS_CK_BE, TxMsg, 0);
1903 printf("\r\nSending AC_BE trigger packet\n");
1904 break;
1905 }
1906
1907 sendto(Sockfd, TxMsg, 256, 0, (struct sockaddr *)&psToAddr,
1908 sizeof(struct sockaddr));
1909 close(Sockfd);
1910 usleep(1000000);
1911 }
1912 else if (setwmm->action == WMMAC_ADDTS)
1913 {
1914 //wmmtspec_t* pCmdTspec = &(setwmm->actions.addts.tspec);
1915 printf("ADDTS AC PARAMS: dialog id: %d, TID: %d, "
1916 "DIRECTION: %d, PSB: %d, UP: %d, INFOACK: %d BURST SIZE DEF: %d"
1917 "Fixed %d, MSDU Size: %d, Max MSDU Size %d, "
1918 "MIN SERVICE INTERVAL: %d, MAX SERVICE INTERVAL: %d, "
1919 "INACTIVITY: %d, SUSPENSION %d, SERVICE START TIME: %d, "
1920 "MIN DATARATE: %d, MEAN DATA RATE: %d, PEAK DATA RATE: %d, "
1921 "BURSTSIZE or MSDU Aggreg: %d, DELAY BOUND: %d, PHYRATE: %d, SPLUSBW: %f, "
1922 "MEDIUM TIME: %d, ACCESSCAT: %d\n",
1923 setwmm->actions.addts.dialog_token,
1924 setwmm->actions.addts.tspec.tsinfo.TID,
1925 setwmm->actions.addts.tspec.tsinfo.direction,
1926 setwmm->actions.addts.tspec.tsinfo.PSB,
1927 setwmm->actions.addts.tspec.tsinfo.UP,
1928 setwmm->actions.addts.tspec.tsinfo.infoAck,
1929 setwmm->actions.addts.tspec.tsinfo.bstSzDef,
1930 setwmm->actions.addts.tspec.Fixed,
1931 setwmm->actions.addts.tspec.size,
1932 setwmm->actions.addts.tspec.maxsize,
1933 setwmm->actions.addts.tspec.min_srvc,
1934 setwmm->actions.addts.tspec.max_srvc,
1935 setwmm->actions.addts.tspec.inactivity,
1936 setwmm->actions.addts.tspec.suspension,
1937 setwmm->actions.addts.tspec.srvc_strt_tim,
1938 setwmm->actions.addts.tspec.mindatarate,
1939 setwmm->actions.addts.tspec.meandatarate,
1940 setwmm->actions.addts.tspec.peakdatarate,
1941 setwmm->actions.addts.tspec.burstsize,
1942 setwmm->actions.addts.tspec.delaybound,
1943 setwmm->actions.addts.tspec.PHYrate,
1944 setwmm->actions.addts.tspec.sba,
1945 setwmm->actions.addts.tspec.medium_time,
1946 setwmm->actions.addts.accesscat);
1947
1948 // you should set your tspec here.
1949
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001950 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001951 }
1952 else if (setwmm->action == WMMAC_DELTS)
1953 {
1954 // send del tspec
1955 }
1956
1957 setwmmResp->status = STATUS_COMPLETE;
1958 break;
1959
1960 case GROUP_WMMCONF:
1961 sprintf(gCmdStr, "iwconfig %s rts %d",
1962 ifname,setwmm->actions.config.rts_thr);
1963
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001964 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001965 sprintf(gCmdStr, "iwconfig %s frag %d",
1966 ifname,setwmm->actions.config.frag_thr);
1967
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001968 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001969 sprintf(gCmdStr, "iwpriv %s wmmcfg %d",
1970 ifname, setwmm->actions.config.wmm);
1971
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001972 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001973 setwmmResp->status = STATUS_COMPLETE;
1974 break;
1975
1976 default:
1977 DPRINT_ERR(WFA_ERR, "The group %d is not supported\n",setwmm->group);
1978 setwmmResp->status = STATUS_ERROR;
1979 break;
1980
1981 }
1982
1983 wfaEncodeTLV(WFA_STA_SET_WMM_RESP_TLV, 4, (BYTE *)setwmmResp, respBuf);
1984 *respLen = WFA_TLV_HDR_LEN + 4;
1985#endif
1986
1987 return WFA_SUCCESS;
1988}
1989
1990int wfaStaSendNeigReq(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1991{
1992 //dutCommand_t *sendNeigReq = (dutCommand_t *)caCmdBuf;
1993 dutCmdResponse_t *sendNeigReqResp = &gGenericResp;
1994
1995 /*
1996 * run your device to send NEIGREQ
1997 */
1998
1999 sendNeigReqResp->status = STATUS_COMPLETE;
2000 wfaEncodeTLV(WFA_STA_SEND_NEIGREQ_RESP_TLV, 4, (BYTE *)sendNeigReqResp, respBuf);
2001 *respLen = WFA_TLV_HDR_LEN + 4;
2002
2003 return WFA_SUCCESS;
2004}
2005
2006int wfaStaSetEapFAST(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2007{
2008 caStaSetEapFAST_t *setFAST= (caStaSetEapFAST_t *)caCmdBuf;
2009 char *ifname = setFAST->intf;
2010 dutCmdResponse_t *setEapFastResp = &gGenericResp;
2011
2012#ifdef WFA_NEW_CLI_FORMAT
2013 sprintf(gCmdStr, "wfa_set_eapfast %s %s %s %s %s %s", ifname, setFAST->ssid, setFAST->username,
2014 setFAST->passwd, setFAST->pacFileName,
2015 setFAST->innerEAP);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002016 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002017#else
2018
2019 sprintf(gCmdStr, "wpa_cli -i %s disable_network 0", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002020 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002021
2022 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 ssid '\"%s\"'", ifname, setFAST->ssid);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002023 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002024
2025 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 identity '\"%s\"'", ifname, setFAST->username);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002026 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002027
2028 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 password '\"%s\"'", ifname, setFAST->passwd);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002029 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002030
2031 if(strcasecmp(setFAST->keyMgmtType, "wpa2-sha256") == 0)
2032 {
2033 }
2034 else if(strcasecmp(setFAST->keyMgmtType, "wpa2-eap") == 0)
2035 {
2036 }
2037 else if(strcasecmp(setFAST->keyMgmtType, "wpa2-ft") == 0)
2038 {
2039
2040 }
2041 else if(strcasecmp(setFAST->keyMgmtType, "wpa") == 0)
2042 {
2043 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt WPA-EAP", ifname);
2044 }
2045 else if(strcasecmp(setFAST->keyMgmtType, "wpa2") == 0)
2046 {
2047 // take all and device to pick one which is supported.
2048 }
2049 else
2050 {
2051 // ??
2052 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002053 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002054
2055 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 eap FAST", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002056 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002057
2058 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 pac_file '\"%s/%s\"'", ifname, CERTIFICATES_PATH, setFAST->pacFileName);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002059 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002060
2061 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 anonymous_identity '\"anonymous\"'", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002062 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002063
2064 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 phase1 '\"fast_provisioning=1\"'", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002065 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002066
2067 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 phase2 '\"auth=%s\"'", ifname,setFAST->innerEAP);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002068 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002069
2070 sprintf(gCmdStr, "wpa_cli -i %s enable_network 0", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002071 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002072#endif
2073
2074 setEapFastResp->status = STATUS_COMPLETE;
2075 wfaEncodeTLV(WFA_STA_SET_EAPFAST_RESP_TLV, 4, (BYTE *)setEapFastResp, respBuf);
2076 *respLen = WFA_TLV_HDR_LEN + 4;
2077
2078 return WFA_SUCCESS;
2079}
2080
2081int wfaStaSetEapAKA(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2082{
2083 caStaSetEapAKA_t *setAKA= (caStaSetEapAKA_t *)caCmdBuf;
2084 char *ifname = setAKA->intf;
2085 dutCmdResponse_t *setEapAkaResp = &gGenericResp;
2086
2087#ifdef WFA_NEW_CLI_FORMAT
2088 sprintf(gCmdStr, "wfa_set_eapaka %s %s %s %s", ifname, setAKA->ssid, setAKA->username, setAKA->passwd);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002089 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002090#else
2091
2092 sprintf(gCmdStr, "wpa_cli -i %s disable_network 0", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002093 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002094
2095 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 ssid '\"%s\"'", ifname, setAKA->ssid);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002096 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002097
2098 if(strcasecmp(setAKA->keyMgmtType, "wpa2-sha256") == 0)
2099 {
2100 }
2101 else if(strcasecmp(setAKA->keyMgmtType, "wpa2-eap") == 0)
2102 {
2103 }
2104 else if(strcasecmp(setAKA->keyMgmtType, "wpa2-ft") == 0)
2105 {
2106
2107 }
2108 else if(strcasecmp(setAKA->keyMgmtType, "wpa") == 0)
2109 {
2110 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt WPA-EAP", ifname);
2111 }
2112 else if(strcasecmp(setAKA->keyMgmtType, "wpa2") == 0)
2113 {
2114 // take all and device to pick one which is supported.
2115 }
2116 else
2117 {
2118 // ??
2119 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002120 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002121
2122 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 proto WPA2", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002123 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002124 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 proto CCMP", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002125 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002126
2127 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 eap AKA", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002128 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002129
2130 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 phase1 \"result_ind=1\"", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002131 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002132
2133 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 identity '\"%s\"'", ifname, setAKA->username);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002134 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002135
2136 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 password '\"%s\"'", ifname, setAKA->passwd);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002137 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002138
2139 sprintf(gCmdStr, "wpa_cli -i %s enable_network 0", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002140 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002141#endif
2142
2143 setEapAkaResp->status = STATUS_COMPLETE;
2144 wfaEncodeTLV(WFA_STA_SET_EAPAKA_RESP_TLV, 4, (BYTE *)setEapAkaResp, respBuf);
2145 *respLen = WFA_TLV_HDR_LEN + 4;
2146
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002147 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002148}
2149
2150int wfaStaSetSystime(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2151{
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002152 caStaSetSystime_t *systime = (caStaSetSystime_t *)caCmdBuf;
2153 dutCmdResponse_t *setSystimeResp = &gGenericResp;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002154
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002155 DPRINT_INFO(WFA_OUT, "Entering wfaStaSetSystime ...\n");
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002156
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002157 sprintf(gCmdStr, "date %d-%d-%d",systime->month,systime->date,systime->year);
2158 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002159
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002160 sprintf(gCmdStr, "time %d:%d:%d", systime->hours,systime->minutes,systime->seconds);
2161 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002162
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002163 setSystimeResp->status = STATUS_COMPLETE;
2164 wfaEncodeTLV(WFA_STA_SET_SYSTIME_RESP_TLV, 4, (BYTE *)setSystimeResp, respBuf);
2165 *respLen = WFA_TLV_HDR_LEN + 4;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002166
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002167 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002168}
2169
2170#ifdef WFA_STA_TB
2171int wfaStaPresetParams(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2172{
2173 dutCmdResponse_t *PresetParamsResp = &gGenericResp;
2174 caStaPresetParameters_t *presetParams = (caStaPresetParameters_t *)caCmdBuf;
2175 //int ret;
2176 //char *intfname = presetParams->intf;
2177 BYTE presetDone = 1;
2178 int st = 0;
2179
2180 DPRINT_INFO(WFA_OUT, "Inside wfaStaPresetParameters function ...\n");
2181
2182 if(presetParams->wmmFlag)
2183 {
2184 st = wfaExecuteCLI(gCmdStr);
2185 switch(st)
2186 {
2187 case 0:
2188 presetDone = 1;
2189 break;
2190 case 1:
2191 presetDone = 0;
2192 break;
2193 case 2:
2194 presetDone = 0;
2195 break;
2196 }
2197 }
2198
2199 if(presetParams->modeFlag != 0)
2200 {
2201 switch(presetParams->wirelessMode)
2202 {
2203 default:
2204 printf("other mode does not need to support\n");
2205 }
2206
2207 st = wfaExecuteCLI(gCmdStr);
2208 switch(st)
2209 {
2210 case 0:
2211 presetDone = 1;
2212 break;
2213 case 1:
2214 presetDone = 0;
2215 case 2:
2216 presetDone = 0;
2217 break;
2218 }
2219 }
2220
2221
2222 if(presetParams->psFlag)
2223 {
2224
2225 printf("%s\n", gCmdStr);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002226 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002227 }
2228
2229 /************the followings are used for Voice Enterprise **************/
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002230 if(presetParams->program == PROG_TYPE_VENT)
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002231 {
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002232 if(presetParams->ftoa == eEnable)
2233 {
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002234 // enable Fast BSS Transition Over the Air
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002235 }
2236 else
2237 {
2238 // disable Fast BSS Transition Over the Air
2239 }
2240
2241 if(presetParams->ftds == eEnable)
2242 {
2243 // enable Fast BSS Transition Over the DS
2244 }
2245 else
2246 {
2247 // disable Fast BSS Transition Over the DS
2248 }
2249
2250 if(presetParams->activescan == eEnable)
2251 {
2252 // Enable Active Scan on STA
2253 }
2254 else
2255 {
2256 // disable Active Scan on STA
2257 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002258 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002259
2260 /************the followings are used for Wi-Fi Display *************/
2261 if(presetParams->program == PROG_TYPE_WFD)
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002262 {
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002263
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002264 if(presetParams->tdlsFlag)
2265 {
2266 // enable / disable tdls based on tdls
2267 }
2268 if(presetParams->wfdDevTypeFlag)
2269 {
2270 // set WFD device type to source/sink/dual based on wfdDevType
2271 }
2272 if(presetParams->wfdUibcGenFlag)
2273 {
2274 // enable / disable the feature
2275 }
2276 if(presetParams->wfdUibcHidFlag)
2277 {
2278 // enable / disable feature
2279 }
2280 if(presetParams->wfdUiInputFlag)
2281 {
2282 // set the UI input as mentioned
2283 }
2284 if(presetParams->wfdHdcpFlag)
2285 {
2286 // enable / disable feature
2287 }
2288 if(presetParams->wfdFrameSkipFlag)
2289 {
2290 // enable / disable feature
2291 }
2292 if(presetParams->wfdAvChangeFlag)
2293 {
2294 // enable / disable feature
2295 }
2296 if(presetParams->wfdStandByFlag)
2297 {
2298 // enable / disable feature
2299 }
2300 if(presetParams->wfdInVideoFlag)
2301 {
2302 // select the input vide as protecteed or non-protetcted or protected audio
2303 // or unprotected audio etc.
2304 }
2305
2306 if(presetParams->wfdVideoFmatFlag)
2307 {
2308 // set the video format as requested
2309
2310 //switch(presetParams->wfdVideoFmt )
2311 //{
2312 // case e640x480p60:
2313 // ;
2314 // default:
2315 // set the mandatory
2316 // }
2317 }
2318 if(presetParams->wfdAudioFmatFlag)
2319 {
2320 // set the Audio format as requested
2321
2322 //switch(presetParams->wfdAudioFmt )
2323 //{
2324 // case eMandatoryAudioMode:
2325 // ;
2326 // case eDefaultAudioMode:
2327 // ;
2328
2329 // default:
2330 // set the mandatory
2331 // }
2332 }
2333
2334 if(presetParams->wfdI2cFlag)
2335 {
2336 // enable / disable feature
2337 }
2338 if(presetParams->wfdVideoRecoveryFlag)
2339 {
2340 // enable / disable feature
2341 }
2342 if(presetParams->wfdPrefDisplayFlag)
2343 {
2344 // enable / disable feature
2345 }
2346 if(presetParams->wfdServiceDiscoveryFlag)
2347 {
2348 // enable / disable feature
2349 }
2350 if(presetParams->wfd3dVideoFlag)
2351 {
2352 // enable / disable feature
2353 }
2354 if(presetParams->wfdMultiTxStreamFlag)
2355 {
2356 // enable / disable feature
2357 }
2358 if(presetParams->wfdTimeSyncFlag)
2359 {
2360 // enable / disable feature
2361 }
2362 if(presetParams->wfdEDIDFlag)
2363 {
2364 // enable / disable feature
2365 }
2366 if(presetParams->wfdUIBCPrepareFlag)
2367 {
2368 // Provdes information to start valid WFD session to check UIBC operation.
2369 }
2370 if(presetParams->wfdCoupledCapFlag)
2371 {
2372 // enable / disable feature
2373 }
2374 if(presetParams->wfdOptionalFeatureFlag)
2375 {
2376 // disable all program specific optional features
2377 }
2378 if(presetParams->wfdSessionAvailFlag)
2379 {
2380 // enable / disable session available bit
2381 }
2382 if(presetParams->wfdDeviceDiscoverabilityFlag)
2383 {
2384 // enable / disable feature
2385 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002386 }
2387
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002388 if (presetDone)
2389 {
2390 PresetParamsResp->status = STATUS_COMPLETE;
2391 }
2392 else
2393 {
2394 PresetParamsResp->status = STATUS_INVALID;
2395 }
2396
2397 wfaEncodeTLV(WFA_STA_PRESET_PARAMETERS_RESP_TLV, 4, (BYTE *)PresetParamsResp, respBuf);
2398 *respLen = WFA_TLV_HDR_LEN + 4;
2399
2400 return WFA_SUCCESS;
2401}
2402
2403int wfaStaSet11n(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2404{
2405 dutCmdResponse_t *v11nParamsResp = &gGenericResp;
2406
2407 v11nParamsResp->status = STATUS_COMPLETE;
2408 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, 4, (BYTE *)v11nParamsResp, respBuf);
2409 *respLen = WFA_TLV_HDR_LEN + 4;
2410 return WFA_SUCCESS;
2411}
2412int wfaStaSetWireless(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2413{
2414 dutCmdResponse_t *staWirelessResp = &gGenericResp;
2415
2416 staWirelessResp->status = STATUS_COMPLETE;
2417 wfaEncodeTLV(WFA_STA_SET_WIRELESS_RESP_TLV, 4, (BYTE *)staWirelessResp, respBuf);
2418 *respLen = WFA_TLV_HDR_LEN + 4;
2419 return WFA_SUCCESS;
2420}
2421
2422int wfaStaSendADDBA(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2423{
2424 dutCmdResponse_t *staSendADDBAResp = &gGenericResp;
2425
2426 wfaEncodeTLV(WFA_STA_SET_SEND_ADDBA_RESP_TLV, 4, (BYTE *)staSendADDBAResp, respBuf);
2427 *respLen = WFA_TLV_HDR_LEN + 4;
2428 return WFA_SUCCESS;
2429}
2430
2431int wfaStaSetRIFS(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2432{
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002433 dutCmdResponse_t *staSetRIFSResp = &gGenericResp;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002434
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002435 wfaEncodeTLV(WFA_STA_SET_RIFS_TEST_RESP_TLV, 4, (BYTE *)staSetRIFSResp, respBuf);
2436 *respLen = WFA_TLV_HDR_LEN + 4;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002437
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002438 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002439}
2440
2441int wfaStaSendCoExistMGMT(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2442{
2443 dutCmdResponse_t *staSendMGMTResp = &gGenericResp;
2444
2445 wfaEncodeTLV(WFA_STA_SEND_COEXIST_MGMT_RESP_TLV, 4, (BYTE *)staSendMGMTResp, respBuf);
2446 *respLen = WFA_TLV_HDR_LEN + 4;
2447
2448 return WFA_SUCCESS;
2449
2450}
2451
2452int wfaStaResetDefault(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2453{
2454 caStaResetDefault_t *reset = (caStaResetDefault_t *)caCmdBuf;
2455 dutCmdResponse_t *ResetResp = &gGenericResp;
2456
2457
2458 // need to make your own command available for this, here is only an example
2459 sprintf(gCmdStr, "myresetdefault %s program %s", reset->intf, reset->prog);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002460 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002461
2462 ResetResp->status = STATUS_COMPLETE;
2463 wfaEncodeTLV(WFA_STA_RESET_DEFAULT_RESP_TLV, 4, (BYTE *)ResetResp, respBuf);
2464 *respLen = WFA_TLV_HDR_LEN + 4;
2465
2466 return WFA_SUCCESS;
2467}
2468
2469#else
2470
2471int wfaStaTestBedCmd(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2472{
2473 dutCmdResponse_t *staCmdResp = &gGenericResp;
2474
2475 wfaEncodeTLV(WFA_STA_DISCONNECT_RESP_TLV, 4, (BYTE *)staCmdResp, respBuf);
2476 *respLen = WFA_TLV_HDR_LEN + 4;
2477
2478 return WFA_SUCCESS;
2479}
2480#endif
2481
2482/*
2483 * This is used to send a frame or action frame
2484 */
Ankur Vachhanic485b712012-02-15 23:29:49 +00002485int wfaStaDevSendFrame(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002486{
2487 dutCommand_t *cmd = (dutCommand_t *)caCmdBuf;
2488 /* uncomment it if needed */
2489 // char *ifname = cmd->intf;
Ankur Vachhanic485b712012-02-15 23:29:49 +00002490 dutCmdResponse_t *devSendResp = &gGenericResp;
2491 caStaDevSendFrame_t *sf = &cmd->cmdsu.sf;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002492
Ankur Vachhanic485b712012-02-15 23:29:49 +00002493 DPRINT_INFO(WFA_OUT, "Inside wfaStaDevSendFrame function ...\n");
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002494 /* processing the frame */
2495
Ankur Vachhanic485b712012-02-15 23:29:49 +00002496 switch(sf->program)
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002497 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00002498 case PROG_TYPE_PMF:
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002499 {
2500 pmfFrame_t *pmf = &sf->frameType.pmf;
Ankur Vachhanic485b712012-02-15 23:29:49 +00002501 switch(pmf->eFrameName)
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002502 {
2503 case PMF_TYPE_DISASSOC:
2504 {
2505 /* use the protected to set what type of key to send */
2506
2507 }
2508 break;
2509 case PMF_TYPE_DEAUTH:
2510 {
2511
2512 }
2513 break;
2514 case PMF_TYPE_SAQUERY:
2515 {
2516
2517 }
2518 break;
2519 case PMF_TYPE_AUTH:
2520 {
2521 }
2522 break;
2523 case PMF_TYPE_ASSOCREQ:
2524 {
2525 }
2526 break;
2527 case PMF_TYPE_REASSOCREQ:
2528 {
2529 }
2530 break;
2531 }
2532 }
2533 break;
Ankur Vachhanic485b712012-02-15 23:29:49 +00002534 case PROG_TYPE_TDLS:
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002535 {
2536 tdlsFrame_t *tdls = &sf->frameType.tdls;
Ankur Vachhanic485b712012-02-15 23:29:49 +00002537 switch(tdls->eFrameName)
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002538 {
2539 case TDLS_TYPE_DISCOVERY:
2540 /* use the peer mac address to send the frame */
2541 break;
2542 case TDLS_TYPE_SETUP:
2543 break;
2544 case TDLS_TYPE_TEARDOWN:
2545 break;
2546 case TDLS_TYPE_CHANNELSWITCH:
2547 break;
2548 case TDLS_TYPE_NULLFRAME:
2549 break;
2550 }
2551 }
2552 break;
Ankur Vachhanic485b712012-02-15 23:29:49 +00002553 case PROG_TYPE_VENT:
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002554 {
2555 ventFrame_t *vent = &sf->frameType.vent;
2556 switch(vent->type)
2557 {
2558 case VENT_TYPE_NEIGREQ:
2559 break;
2560 case VENT_TYPE_TRANSMGMT:
2561 break;
2562 }
2563 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002564 case PROG_TYPE_WFD:
2565 {
2566 wfdFrame_t *wfd = &sf->frameType.wfd;
2567 switch(wfd->eframe)
2568 {
2569 case WFD_FRAME_PRBREQ:
2570 {
2571 /* send probe req */
2572 }
2573 break;
2574
2575 case WFD_FRAME_PRBREQ_TDLS_REQ:
2576 {
2577 /* send tunneled tdls probe req */
2578 }
2579 break;
2580
2581 case WFD_FRAME_11V_TIMING_MSR_REQ:
2582 {
2583 /* send 11v timing mearurement request */
2584 }
2585 break;
2586
2587 case WFD_FRAME_RTSP:
2588 {
2589 /* send WFD RTSP messages*/
2590 // fetch the type of RTSP message and send it.
2591 switch(wfd->eRtspMsgType)
2592 {
2593 case WFD_RTSP_PAUSE:
2594 break;
2595 case WFD_RTSP_PLAY:
2596 //send RTSP PLAY
2597 break;
2598 case WFD_RTSP_TEARDOWN:
2599 //send RTSP TEARDOWN
2600 break;
2601 case WFD_RTSP_TRIG_PAUSE:
2602 //send RTSP TRIGGER PAUSE
2603 break;
2604 case WFD_RTSP_TRIG_PLAY:
2605 //send RTSP TRIGGER PLAY
2606 break;
2607 case WFD_RTSP_TRIG_TEARDOWN:
2608 //send RTSP TRIGGER TEARDOWN
2609 break;
2610 case WFD_RTSP_SET_PARAMETER:
2611 //send RTSP SET PARAMETER
2612 if (wfd->eSetParams == WFD_CAP_UIBC_KEYBOARD)
2613 {
2614 //send RTSP SET PARAMETER message for UIBC keyboard
2615 }
2616 if (wfd->eSetParams == WFD_CAP_UIBC_MOUSE)
2617 {
2618 //send RTSP SET PARAMETER message for UIBC Mouse
2619 }
2620 else if (wfd->eSetParams == WFD_CAP_RE_NEGO)
2621 {
2622 //send RTSP SET PARAMETER message Capability re-negotiation
2623 }
2624 else if (wfd->eSetParams == WFD_STANDBY)
2625 {
2626 //send RTSP SET PARAMETER message for standby
2627 }
2628 else if (wfd->eSetParams == WFD_UIBC_SETTINGS_ENABLE)
2629 {
2630 //send RTSP SET PARAMETER message for UIBC settings enable
2631 }
2632 else if (wfd->eSetParams == WFD_UIBC_SETTINGS_DISABLE)
2633 {
2634 //send RTSP SET PARAMETER message for UIBC settings disable
2635 }
2636 else if (wfd->eSetParams == WFD_ROUTE_AUDIO)
2637 {
2638 //send RTSP SET PARAMETER message for route audio
2639 }
2640 else if (wfd->eSetParams == WFD_3D_VIDEOPARAM)
2641 {
2642 //send RTSP SET PARAMETER message for 3D video parameters
2643 }
2644 else if (wfd->eSetParams == WFD_2D_VIDEOPARAM)
2645 {
2646 //send RTSP SET PARAMETER message for 2D video parameters
2647 }
2648 break;
2649 }
2650 }
2651 break;
2652 }
2653 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00002654 case PROG_TYPE_GEN:
2655 {
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002656 /* General frames */
Ankur Vachhanic485b712012-02-15 23:29:49 +00002657 }
2658
2659
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002660 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00002661 devSendResp->status = STATUS_COMPLETE;
2662 wfaEncodeTLV(WFA_STA_DEV_SEND_FRAME_RESP_TLV, 4, (BYTE *)devSendResp, respBuf);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002663 *respLen = WFA_TLV_HDR_LEN + 4;
2664
2665 return WFA_SUCCESS;
2666}
2667
2668/*
2669 * This is used to set a temporary MAC address of an interface
2670 */
2671int wfaStaSetMacAddr(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2672{
2673 // Uncomment it if needed
2674 //dutCommand_t *cmd = (dutCommand_t *)caCmdBuf;
2675 // char *ifname = cmd->intf;
2676 dutCmdResponse_t *staCmdResp = &gGenericResp;
2677 // Uncomment it if needed
2678 //char *macaddr = &cmd->cmdsu.macaddr[0];
2679
2680 wfaEncodeTLV(WFA_STA_SET_MAC_ADDRESS_RESP_TLV, 4, (BYTE *)staCmdResp, respBuf);
2681 *respLen = WFA_TLV_HDR_LEN + 4;
2682
2683 return WFA_SUCCESS;
2684}
2685
2686
2687int wfaStaDisconnect(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2688{
2689 //dutCommand_t *disc = (dutCommand_t *)caCmdBuf;
2690 //char *intf = disc->intf;
2691 dutCmdResponse_t *staDiscResp = &gGenericResp;
2692
2693 // stop the supplicant
2694
2695 staDiscResp->status = STATUS_COMPLETE;
2696
2697 wfaEncodeTLV(WFA_STA_DISCONNECT_RESP_TLV, 4, (BYTE *)staDiscResp, respBuf);
2698 *respLen = WFA_TLV_HDR_LEN + 4;
2699
2700 return WFA_SUCCESS;
2701}
2702
2703/* Execute CLI, read the status from Environment variable */
2704int wfaExecuteCLI(char *CLI)
2705{
2706 char *retstr;
2707
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002708 sret = system(CLI);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002709
2710 retstr = getenv("WFA_CLI_STATUS");
2711 printf("cli status %s\n", retstr);
2712 return atoi(retstr);
2713}
2714
2715/* Supporting Functions */
2716
2717void wfaSendPing(tgPingStart_t *staPing, float *interval, int streamid)
2718{
2719 int totalpkts;
Naveen Kumard549d4b2014-03-13 10:56:56 -07002720 char cmdStr[256];
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002721// char *addr = staPing->dipaddr;
2722#ifdef WFA_PC_CONSOLE
Naveen Kumard549d4b2014-03-13 10:56:56 -07002723 char addr[40];
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002724 char bflag[] = "-b";
2725 char *tmpstr;
2726 int inum=0;
2727#else
2728 char bflag[] = " ";
2729#endif
Ray Wang9b47f362014-03-19 16:51:10 -07002730 //<<<-------------------------------------------------
2731 //jira issue: SIG-523
2732 //totalpkts should be integer
2733 totalpkts = (int)(staPing->duration * staPing->frameRate);
2734 ////totalpkts = staPing->duration * staPing->frameRate;
2735 //-------------------------------------------------->>>
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002736#ifdef WFA_PC_CONSOLE
2737
2738 printf("\nCS : The Stream ID is %d",streamid);
2739 printf("\nCS :the addr is %s ",addr);
2740 strcpy(addr,staPing->dipaddr);
2741 printf("\nCS :Inside the WFA_PC_CONSLE BLOCK");
2742 printf("\nCS :the addr is %s ",addr);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002743 if (staPing->iptype == 2)
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002744 {
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002745 memset(bflag, 0, strlen(bflag));
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002746 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002747 else
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002748 {
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002749 tmpstr = strtok(addr, ".");
2750 inum = atoi(tmpstr);
2751
2752 printf("interval %f\n", *interval);
2753
2754 if(inum >= 224 && inum <= 239) // multicast
2755 {
2756 }
2757 else // if not MC, check if it is BC address
2758 {
2759 printf("\nCS :Inside the BC address BLOCK");
2760 printf("\nCS :the inum %d",inum);
2761 strtok(NULL, ".");
2762 //strtok(NULL, ".");
2763 tmpstr = strtok(NULL, ".");
2764 printf("tmpstr %s\n", tmpstr);
2765 inum = atoi(tmpstr);
2766 printf("\nCS : The string is %s",tmpstr);
2767 if(inum != 255)
2768 memset(bflag, 0, strlen(bflag));
2769 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002770 }
2771#endif
2772 printf("\nCS : The Stream ID is %d",streamid);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002773 printf("IPtype : %i",staPing->iptype);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002774
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002775 if (staPing->iptype == 2)
2776 {
2777 sprintf(cmdStr, "echo streamid=%i > /tmp/spout_%d.txt;wfaping6.sh %s %s -i %f -c %i -s %i -q >> /tmp/spout_%d.txt 2>/dev/null",
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002778 streamid,streamid,bflag, staPing->dipaddr, *interval, totalpkts, staPing->frameSize,streamid);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002779 sret = system(cmdStr);
2780 printf("\nCS : The command string is %s",cmdStr);
2781 }
2782 else
2783 {
2784 sprintf(cmdStr, "echo streamid=%i > /tmp/spout_%d.txt;wfaping.sh %s %s -i %f -c %i -s %i -q >> /tmp/spout_%d.txt 2>/dev/null",
2785 streamid,streamid,bflag, staPing->dipaddr, *interval, totalpkts, staPing->frameSize,streamid);
2786 sret = system(cmdStr);
2787 printf("\nCS : The command string is %s",cmdStr);
2788 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002789 sprintf(cmdStr, "updatepid.sh /tmp/spout_%d.txt",streamid);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002790 sret = system(cmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002791 printf("\nCS : The command string is %s",cmdStr);
2792
2793}
2794
2795int wfaStopPing(dutCmdResponse_t *stpResp, int streamid)
2796{
2797 char strout[256];
2798 FILE *tmpfile = NULL;
2799 char cmdStr[128];
2800 printf("Ping stop id %d\n", streamid);
2801 sprintf(cmdStr, "getpid.sh /tmp/spout_%d.txt /tmp/pid.txt",streamid);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002802 sret = system(cmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002803
2804 printf("\nCS : The command string is %s",cmdStr);
2805
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002806 sret = system("stoping.sh /tmp/pid.txt ; sleep 2");
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002807
2808 sprintf(cmdStr, "getpstats.sh /tmp/spout_%d.txt",streamid);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002809 sret = system(cmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002810
2811 printf("\nCS : The command string is %s",cmdStr);
2812
2813 tmpfile = fopen("/tmp/stpsta.txt", "r+");
2814
2815 if(tmpfile == NULL)
2816 {
2817 return WFA_FAILURE;
2818 }
2819
2820 if(fscanf(tmpfile, "%s", strout) != EOF)
2821 {
2822 if(*strout == '\0')
2823 {
2824 stpResp->cmdru.pingStp.sendCnt = 0;
2825 }
2826
2827 else
2828 stpResp->cmdru.pingStp.sendCnt = atoi(strout);
2829 }
2830
2831 printf("after scan sent count %i\n", stpResp->cmdru.pingStp.sendCnt);
2832
2833
2834 if(fscanf(tmpfile, "%s", strout) != EOF)
2835 {
2836 if(*strout == '\0')
2837 {
2838 stpResp->cmdru.pingStp.repliedCnt = 0;
2839 }
2840 else
2841 stpResp->cmdru.pingStp.repliedCnt = atoi(strout);
2842 }
2843 printf("after scan replied count %i\n", stpResp->cmdru.pingStp.repliedCnt);
2844
2845 fclose(tmpfile);
2846
2847 return WFA_SUCCESS;
2848}
2849
Ankur Vachhanic485b712012-02-15 23:29:49 +00002850/*
2851 * wfaStaGetP2pDevAddress():
2852 */
2853int wfaStaGetP2pDevAddress(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2854{
2855 dutCmdResponse_t infoResp;
2856 /* dutCommand_t *getInfo = (dutCommand_t *)caCmdBuf; */
2857
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002858 printf("\n Entry wfaStaGetP2pDevAddress... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00002859
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002860 // Fetch the device ID and store into infoResp->cmdru.devid
2861 //strcpy(infoResp->cmdru.devid, str);
2862 strcpy(&infoResp.cmdru.devid[0], "ABCDEFGH");
Ankur Vachhanic485b712012-02-15 23:29:49 +00002863
2864 infoResp.status = STATUS_COMPLETE;
2865 wfaEncodeTLV(WFA_STA_P2P_GET_DEV_ADDRESS_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
2866 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
2867
2868 return WFA_SUCCESS;
2869}
2870
2871
2872
2873/*
2874 * wfaStaSetP2p():
2875 */
2876int wfaStaSetP2p(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2877{
2878 dutCmdResponse_t infoResp;
2879 /* caStaSetP2p_t *getStaSetP2p = (caStaSetP2p_t *)caCmdBuf; uncomment and use it*/
2880
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002881 printf("\n Entry wfaStaSetP2p... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00002882
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002883 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00002884
2885 infoResp.status = STATUS_COMPLETE;
2886 wfaEncodeTLV(WFA_STA_P2P_SETP2P_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
2887 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
2888
2889 return WFA_SUCCESS;
2890}
2891/*
2892 * wfaStaP2pConnect():
2893 */
2894int wfaStaP2pConnect(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2895{
2896 dutCmdResponse_t infoResp;
2897 /* caStaP2pConnect_t *getStaP2pConnect = (caStaP2pConnect_t *)caCmdBuf; uncomment and use it */
2898
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002899 printf("\n Entry wfaStaP2pConnect... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00002900
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002901 // Implement the function and does not return anything.
Ankur Vachhanic485b712012-02-15 23:29:49 +00002902
2903
2904 infoResp.status = STATUS_COMPLETE;
2905 wfaEncodeTLV(WFA_STA_P2P_CONNECT_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
2906 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
2907
2908 return WFA_SUCCESS;
2909}
2910
2911/*
2912 * wfaStaStartAutoGo():
2913 */
2914int wfaStaStartAutoGo(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2915{
2916 dutCmdResponse_t infoResp;
2917 //caStaStartAutoGo_t *getStaStartAutoGo = (caStaStartAutoGo_t *)caCmdBuf;
2918
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002919 printf("\n Entry wfaStaStartAutoGo... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00002920
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002921 // Fetch the group ID and store into infoResp->cmdru.grpid
2922 strcpy(&infoResp.cmdru.grpid[0], "ABCDEFGH");
Ankur Vachhanic485b712012-02-15 23:29:49 +00002923
2924 infoResp.status = STATUS_COMPLETE;
2925 wfaEncodeTLV(WFA_STA_P2P_START_AUTO_GO_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
2926 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
2927
2928 return WFA_SUCCESS;
2929}
2930
2931
2932
2933
2934/*
2935 * wfaStaP2pStartGrpFormation():
2936 */
2937int wfaStaP2pStartGrpFormation(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2938{
2939 dutCmdResponse_t infoResp;
2940 //caStaP2pStartGrpForm_t *getStaP2pStartGrpForm = (caStaP2pStartGrpForm_t *)caCmdBuf;
2941
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002942 printf("\n Entry wfaStaP2pStartGrpFormation... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00002943
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002944 // Fetch the device mode and put in infoResp->cmdru.p2presult
2945 //strcpy(infoResp->cmdru.p2presult, "GO");
Ankur Vachhanic485b712012-02-15 23:29:49 +00002946
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002947 // Fetch the device grp id and put in infoResp->cmdru.grpid
2948 //strcpy(infoResp->cmdru.grpid, "AA:BB:CC:DD:EE:FF_DIRECT-SSID");
2949
2950 strcpy(infoResp.cmdru.grpFormInfo.result, "CLIENT");
2951 strcpy(infoResp.cmdru.grpFormInfo.grpId, "AA:BB:CC:DD:EE:FF_DIRECT-SSID");
Ankur Vachhanic485b712012-02-15 23:29:49 +00002952
2953
2954 infoResp.status = STATUS_COMPLETE;
2955 wfaEncodeTLV(WFA_STA_P2P_START_GRP_FORMATION_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
2956 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
2957
2958 return WFA_SUCCESS;
2959}
2960
2961
2962/*
2963 * wfaStaP2pDissolve():
2964 */
2965int wfaStaP2pDissolve(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2966{
2967 dutCmdResponse_t infoResp;
2968 //caStaP2pDissolve_t *getStap2pDissolve= (caStaP2pDissolve_t *)caCmdBuf;
2969
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002970 printf("\n Entry wfaStaP2pDissolve... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00002971
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002972 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00002973
2974 infoResp.status = STATUS_COMPLETE;
2975 wfaEncodeTLV(WFA_STA_P2P_DISSOLVE_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
2976 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
2977
2978 return WFA_SUCCESS;
2979}
2980
2981/*
2982 * wfaStaSendP2pInvReq():
2983 */
2984int wfaStaSendP2pInvReq(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2985{
2986 dutCmdResponse_t infoResp;
2987 /* caStaSendP2pInvReq_t *getStaP2pInvReq= (caStaSendP2pInvReq_t *)caCmdBuf; */
2988
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002989 printf("\n Entry wfaStaSendP2pInvReq... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00002990
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002991 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00002992
2993 infoResp.status = STATUS_COMPLETE;
2994 wfaEncodeTLV(WFA_STA_P2P_SEND_INV_REQ_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
2995 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
2996
2997 return WFA_SUCCESS;
2998}
2999
3000
3001/*
3002 * wfaStaAcceptP2pInvReq():
3003 */
3004int wfaStaAcceptP2pInvReq(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3005{
3006 dutCmdResponse_t infoResp;
3007 /* uncomment and use it
3008 * caStaAcceptP2pInvReq_t *getStaP2pInvReq= (caStaAcceptP2pInvReq_t *)caCmdBuf;
3009 */
3010
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003011 printf("\n Entry wfaStaAcceptP2pInvReq... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003012
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003013 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003014
3015 infoResp.status = STATUS_COMPLETE;
3016 wfaEncodeTLV(WFA_STA_P2P_ACCEPT_INV_REQ_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3017 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3018
3019 return WFA_SUCCESS;
3020}
3021
3022
3023/*
3024 * wfaStaSendP2pProvDisReq():
3025 */
3026int wfaStaSendP2pProvDisReq(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3027{
3028 dutCmdResponse_t infoResp;
3029 /* uncomment and use it
3030 * caStaSendP2pProvDisReq_t *getStaP2pProvDisReq= (caStaSendP2pProvDisReq_t *)caCmdBuf;
3031 */
3032
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003033 printf("\n Entry wfaStaSendP2pProvDisReq... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003034
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003035 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003036
3037 infoResp.status = STATUS_COMPLETE;
3038 wfaEncodeTLV(WFA_STA_P2P_SEND_PROV_DIS_REQ_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3039 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3040
3041 return WFA_SUCCESS;
3042}
3043
3044/*
3045 * wfaStaSetWpsPbc():
3046 */
3047int wfaStaSetWpsPbc(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3048{
3049 dutCmdResponse_t infoResp;
3050 /* uncomment and use it
3051 * caStaSetWpsPbc_t *getStaSetWpsPbc= (caStaSetWpsPbc_t *)caCmdBuf;
3052 */
3053
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003054 printf("\n Entry wfaStaSetWpsPbc... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003055
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003056 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003057
3058 infoResp.status = STATUS_COMPLETE;
3059 wfaEncodeTLV(WFA_STA_WPS_SETWPS_PBC_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3060 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3061
3062 return WFA_SUCCESS;
3063}
3064
3065/*
3066 * wfaStaWpsReadPin():
3067 */
3068int wfaStaWpsReadPin(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3069{
3070 dutCmdResponse_t infoResp;
3071 /* uncomment and use it
3072 * caStaWpsReadPin_t *getStaWpsReadPin= (caStaWpsReadPin_t *)caCmdBuf;
3073 */
3074
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003075 printf("\n Entry wfaStaWpsReadPin... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003076
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003077 // Fetch the device PIN and put in infoResp->cmdru.wpsPin
3078 //strcpy(infoResp->cmdru.wpsPin, "12345678");
3079 strcpy(&infoResp.cmdru.wpsPin[0], "1234456");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003080
3081
3082 infoResp.status = STATUS_COMPLETE;
3083 wfaEncodeTLV(WFA_STA_WPS_READ_PIN_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3084 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3085
3086 return WFA_SUCCESS;
3087}
3088
3089
3090
3091/*
3092 * wfaStaWpsReadLabel():
3093 */
3094int wfaStaWpsReadLabel(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3095{
3096 dutCmdResponse_t infoResp;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003097
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003098 printf("\n Entry wfaStaWpsReadLabel... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003099
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003100 // Fetch the device Label and put in infoResp->cmdru.wpsPin
3101 //strcpy(infoResp->cmdru.wpsPin, "12345678");
3102 strcpy(&infoResp.cmdru.wpsPin[0], "1234456");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003103
3104
3105 infoResp.status = STATUS_COMPLETE;
3106 wfaEncodeTLV(WFA_STA_WPS_READ_PIN_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3107 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3108
3109 return WFA_SUCCESS;
3110}
3111
3112
3113/*
3114 * wfaStaWpsEnterPin():
3115 */
3116int wfaStaWpsEnterPin(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3117{
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003118 dutCmdResponse_t infoResp;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003119 /* uncomment and use it
3120 * caStaWpsEnterPin_t *getStaWpsEnterPin= (caStaWpsEnterPin_t *)caCmdBuf;
3121 */
3122
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003123 printf("\n Entry wfaStaWpsEnterPin... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003124
3125 // Implement the function and this does not return any thing back.
3126
3127
3128 infoResp.status = STATUS_COMPLETE;
3129 wfaEncodeTLV(WFA_STA_WPS_ENTER_PIN_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3130 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3131
3132 return WFA_SUCCESS;
3133}
3134
3135
3136/*
3137 * wfaStaGetPsk():
3138 */
3139int wfaStaGetPsk(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3140{
3141 dutCmdResponse_t infoResp;
3142 /* caStaGetPsk_t *getStaGetPsk= (caStaGetPsk_t *)caCmdBuf; uncomment and use it */
3143
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003144 printf("\n Entry wfaStaGetPsk... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003145
3146
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003147 // Fetch the device PP and SSID and put in infoResp->cmdru.pskInfo
3148 //strcpy(infoResp->cmdru.wpsPin, "12345678");
3149 strcpy(&infoResp.cmdru.pskInfo.passPhrase[0], "1234456");
3150 strcpy(&infoResp.cmdru.pskInfo.ssid[0], "WIFI_DIRECT");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003151
3152
3153 infoResp.status = STATUS_COMPLETE;
3154 wfaEncodeTLV(WFA_STA_P2P_GET_PSK_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3155 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3156
3157 return WFA_SUCCESS;
3158}
3159
3160/*
3161 * wfaStaP2pReset():
3162 */
3163int wfaStaP2pReset(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3164{
3165 dutCmdResponse_t infoResp;
3166 /* dutCommand_t *getStaP2pReset= (dutCommand_t *)caCmdBuf; */
3167
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003168 printf("\n Entry wfaStaP2pReset... ");
3169 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003170
3171 infoResp.status = STATUS_COMPLETE;
3172 wfaEncodeTLV(WFA_STA_P2P_RESET_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3173 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3174
3175 return WFA_SUCCESS;
3176}
3177
3178
3179
3180/*
3181 * wfaStaGetP2pIpConfig():
3182 */
3183int wfaStaGetP2pIpConfig(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3184{
3185 dutCmdResponse_t infoResp;
3186 /* caStaGetP2pIpConfig_t *staGetP2pIpConfig= (caStaGetP2pIpConfig_t *)caCmdBuf; */
3187
3188 caStaGetIpConfigResp_t *ifinfo = &(infoResp.cmdru.getIfconfig);
3189
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003190 printf("\n Entry wfaStaGetP2pIpConfig... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003191
3192
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003193 // Fetch the device IP config and put in infoResp->cmdru
3194 //strcpy(infoResp->cmdru.wpsPin, "12345678");
3195 ifinfo->isDhcp =0;
3196 strcpy(&(ifinfo->ipaddr[0]), "192.165.100.111");
3197 strcpy(&(ifinfo->mask[0]), "255.255.255.0");
3198 strcpy(&(ifinfo->dns[0][0]), "192.165.100.1");
3199 strcpy(&(ifinfo->mac[0]), "ba:ba:ba:ba:ba:ba");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003200
3201 infoResp.status = STATUS_COMPLETE;
3202 wfaEncodeTLV(WFA_STA_P2P_GET_IP_CONFIG_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3203 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3204
3205 return WFA_SUCCESS;
3206}
3207
3208
3209
3210
3211/*
3212 * wfaStaSendServiceDiscoveryReq():
3213 */
3214int wfaStaSendServiceDiscoveryReq(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3215{
3216 dutCmdResponse_t infoResp;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003217
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003218 printf("\n Entry wfaStaSendServiceDiscoveryReq... ");
3219 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003220
3221
3222 infoResp.status = STATUS_COMPLETE;
3223 wfaEncodeTLV(WFA_STA_P2P_SEND_SERVICE_DISCOVERY_REQ_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3224 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3225
3226 return WFA_SUCCESS;
3227}
3228
3229
3230
3231/*
3232 * wfaStaSendP2pPresenceReq():
3233 */
3234int wfaStaSendP2pPresenceReq(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3235{
3236 dutCmdResponse_t infoResp;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003237 //caStaSendP2pPresenceReq_t *staSendP2pPresenceReq= (caStaSendP2pPresenceReq_t *)caCmdBuf;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003238
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003239 //printf("\n Entry wfaStaSendP2pPresenceReq... ");
3240 //printf("\n The long long Duration: %lld... ",staSendP2pPresenceReq->duration);
3241 //printf("\n The long long interval : %lld.. ",staSendP2pPresenceReq->interval);
Ankur Vachhanic485b712012-02-15 23:29:49 +00003242
Ankur Vachhanic485b712012-02-15 23:29:49 +00003243 infoResp.status = STATUS_COMPLETE;
3244 wfaEncodeTLV(WFA_STA_P2P_SEND_PRESENCE_REQ_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3245 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3246
3247 return WFA_SUCCESS;
3248}
3249
3250/*
3251 * wfaStaSetSleepReq():
3252 */
3253int wfaStaSetSleepReq(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3254{
3255 dutCmdResponse_t infoResp;
3256 /* caStaSetSleep_t *staSetSleepReq= (caStaSetSleep_t *)caCmdBuf; */
3257
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003258 printf("\n Entry wfaStaSetSleepReq... ");
3259 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003260
3261
3262 infoResp.status = STATUS_COMPLETE;
3263 wfaEncodeTLV(WFA_STA_P2P_SET_SLEEP_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3264 *respLen = WFA_TLV_HDR_LEN +4;
3265
3266 return WFA_SUCCESS;
3267}
3268
3269/*
3270 * wfaStaSetOpportunisticPsReq():
3271 */
3272int wfaStaSetOpportunisticPsReq(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3273{
3274 dutCmdResponse_t infoResp;
3275 /* caStaSetOpprPs_t *staSetOpperPsReq= (caStaSetOpprPs_t *)caCmdBuf; uncomment and use it */
3276
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003277 printf("\n Entry wfaStaSetOpportunisticPsReq... ");
3278 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003279
3280
3281 infoResp.status = STATUS_COMPLETE;
3282 wfaEncodeTLV(WFA_STA_P2P_SET_OPPORTUNISTIC_PS_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3283 *respLen = WFA_TLV_HDR_LEN + 4;
3284
3285 return WFA_SUCCESS;
3286}
3287#ifndef WFA_STA_TB
3288/*
3289 * wfaStaPresetParams():
3290 */
3291
3292int wfaStaPresetParams(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3293{
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003294 dutCmdResponse_t infoResp;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003295
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003296 //caStaPresetParameters_t *presetParams = (caStaPresetParameters_t *)caCmdBuf;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003297
3298
3299 DPRINT_INFO(WFA_OUT, "Inside wfaStaPresetParameters function ...\n");
3300
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003301 // Implement the function and its sub commands
3302 infoResp.status = STATUS_COMPLETE;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003303
3304 wfaEncodeTLV(WFA_STA_PRESET_PARAMETERS_RESP_TLV, 4, (BYTE *)&infoResp, respBuf);
3305 *respLen = WFA_TLV_HDR_LEN + 4;
3306
3307 return WFA_SUCCESS;
3308}
3309int wfaStaSet11n(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3310{
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003311
3312 dutCmdResponse_t infoResp;
3313 dutCmdResponse_t *v11nParamsResp = &infoResp;
3314
3315#ifdef WFA_11N_SUPPORT_ONLY
Ankur Vachhanic485b712012-02-15 23:29:49 +00003316
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003317 caSta11n_t * v11nParams = (caSta11n_t *)caCmdBuf;
3318
3319 int st =0; // SUCCESS
Ankur Vachhanic485b712012-02-15 23:29:49 +00003320
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003321 DPRINT_INFO(WFA_OUT, "Inside wfaStaSet11n function....\n");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003322
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003323 if(v11nParams->addba_reject != 0xFF && v11nParams->addba_reject < 2)
3324 {
3325 // implement the funciton
3326 //st = wfaExecuteCLI(gCmdStr);
3327 if(st != 0)
3328 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003329 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003330 strcpy(v11nParamsResp->cmdru.info, "set_addba_reject failed");
3331 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3332 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3333 return FALSE;
3334 }
3335 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003336
3337 if(v11nParams->ampdu != 0xFF && v11nParams->ampdu < 2)
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003338 {
3339 // implement the funciton
3340 //st = wfaExecuteCLI(gCmdStr);
Ankur Vachhanic485b712012-02-15 23:29:49 +00003341
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003342 if(st != 0)
3343 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003344 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003345 strcpy(v11nParamsResp->cmdru.info, "set_ampdu failed");
3346 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3347 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3348 return FALSE;
3349 }
3350 }
3351
Ankur Vachhanic485b712012-02-15 23:29:49 +00003352 if(v11nParams->amsdu != 0xFF && v11nParams->amsdu < 2)
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003353 {
3354 // implement the funciton
3355 //st = wfaExecuteCLI(gCmdStr);
3356 if(st != 0)
3357 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003358 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003359 strcpy(v11nParamsResp->cmdru.info, "set_amsdu failed");
3360 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3361 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3362 return FALSE;
3363 }
3364 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003365
3366 if(v11nParams->greenfield != 0xFF && v11nParams->greenfield < 2)
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003367 {
3368 // implement the funciton
3369 //st = wfaExecuteCLI(gCmdStr);
3370 if(st != 0)
3371 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003372 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003373 strcpy(v11nParamsResp->cmdru.info, "_set_greenfield failed");
3374 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3375 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3376 return FALSE;
3377 }
3378 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003379
3380 if(v11nParams->mcs32!= 0xFF && v11nParams->mcs32 < 2 && v11nParams->mcs_fixedrate[0] != '\0')
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003381 {
3382 // implement the funciton
3383 //st = wfaExecuteCLI(gCmdStr);
3384 if(st != 0)
3385 {
3386 v11nParamsResp->status = STATUS_ERROR;
3387 strcpy(v11nParamsResp->cmdru.info, "set_mcs failed");
3388 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3389 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3390 return FALSE;
3391 }
3392 }
3393 else if (v11nParams->mcs32!= 0xFF && v11nParams->mcs32 < 2 && v11nParams->mcs_fixedrate[0] == '\0')
3394 {
3395 // implement the funciton
3396 //st = wfaExecuteCLI(gCmdStr);
3397 if(st != 0)
3398 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003399 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003400 strcpy(v11nParamsResp->cmdru.info, "set_mcs32 failed");
3401 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3402 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3403 return FALSE;
3404 }
3405 }
3406 else if (v11nParams->mcs32 == 0xFF && v11nParams->mcs_fixedrate[0] != '\0')
3407 {
3408 // implement the funciton
3409 //st = wfaExecuteCLI(gCmdStr);
3410 if(st != 0)
3411 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003412 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003413 strcpy(v11nParamsResp->cmdru.info, "set_mcs32 failed");
3414 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3415 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3416 return FALSE;
3417 }
3418 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003419
3420 if(v11nParams->rifs_test != 0xFF && v11nParams->rifs_test < 2)
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003421 {
3422 // implement the funciton
3423 //st = wfaExecuteCLI(gCmdStr);
3424 if(st != 0)
3425 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003426 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003427 strcpy(v11nParamsResp->cmdru.info, "set_rifs_test failed");
3428 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3429 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3430 return FALSE;
3431 }
3432 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003433
3434 if(v11nParams->sgi20 != 0xFF && v11nParams->sgi20 < 2)
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003435 {
3436 // implement the funciton
3437 //st = wfaExecuteCLI(gCmdStr);
3438 if(st != 0)
3439 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003440 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003441 strcpy(v11nParamsResp->cmdru.info, "set_sgi20 failed");
3442 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3443 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3444 return FALSE;
3445 }
3446 }
3447
3448 if(v11nParams->smps != 0xFFFF)
3449 {
3450 if(v11nParams->smps == 0)
3451 {
3452 // implement the funciton
3453 //st = wfaExecuteCLI(gCmdStr);
Ankur Vachhanic485b712012-02-15 23:29:49 +00003454 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003455 else if(v11nParams->smps == 1)
3456 {
3457 // implement the funciton
3458 //st = wfaExecuteCLI(gCmdStr);
3459 ;
3460 }
3461 else if(v11nParams->smps == 2)
3462 {
3463 // implement the funciton
3464 //st = wfaExecuteCLI(gCmdStr);
3465 ;
3466 }
3467 if(st != 0)
3468 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003469 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003470 strcpy(v11nParamsResp->cmdru.info, "set_smps failed");
3471 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3472 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3473 return FALSE;
3474 }
3475 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003476
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003477 if(v11nParams->stbc_rx != 0xFFFF)
3478 {
3479 // implement the funciton
3480 //st = wfaExecuteCLI(gCmdStr);
3481 if(st != 0)
3482 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003483 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003484 strcpy(v11nParamsResp->cmdru.info, "set_stbc_rx failed");
3485 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3486 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3487 return FALSE;
3488 }
3489 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003490
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003491 if(v11nParams->width[0] != '\0')
3492 {
3493 // implement the funciton
3494 //st = wfaExecuteCLI(gCmdStr);
3495 if(st != 0)
3496 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003497 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003498 strcpy(v11nParamsResp->cmdru.info, "set_11n_channel_width failed");
3499 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3500 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3501 return FALSE;
3502 }
3503 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003504
3505 if(v11nParams->_40_intolerant != 0xFF && v11nParams->_40_intolerant < 2)
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003506 {
3507 // implement the funciton
3508 //st = wfaExecuteCLI(gCmdStr);
3509 if(st != 0)
3510 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003511 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003512 strcpy(v11nParamsResp->cmdru.info, "set_40_intolerant failed");
3513 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3514 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3515 return FALSE;
3516 }
3517 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003518
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003519 if(v11nParams->txsp_stream != 0 && v11nParams->txsp_stream <4)
3520 {
3521 // implement the funciton
3522 //st = wfaExecuteCLI(gCmdStr);
3523 if(st != 0)
3524 {
3525 v11nParamsResp->status = STATUS_ERROR;
3526 strcpy(v11nParamsResp->cmdru.info, "set_txsp_stream failed");
3527 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3528 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3529 return FALSE;
3530 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003531
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003532 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003533
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003534 if(v11nParams->rxsp_stream != 0 && v11nParams->rxsp_stream < 4)
3535 {
3536 // implement the funciton
3537 //st = wfaExecuteCLI(gCmdStr);
3538 if(st != 0)
3539 {
3540 v11nParamsResp->status = STATUS_ERROR;
3541 strcpy(v11nParamsResp->cmdru.info, "set_rxsp_stream failed");
3542 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3543 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3544 return FALSE;
3545 }
3546 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003547
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003548#endif
Ankur Vachhanic485b712012-02-15 23:29:49 +00003549
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003550 v11nParamsResp->status = STATUS_COMPLETE;
3551 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, 4, (BYTE *)v11nParamsResp, respBuf);
3552 *respLen = WFA_TLV_HDR_LEN + 4;
3553 return WFA_SUCCESS;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003554}
3555#endif
3556/*
3557 * wfaStaAddArpTableEntry():
3558 */
3559int wfaStaAddArpTableEntry(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3560{
3561 dutCmdResponse_t infoResp;
3562 /* caStaAddARPTableEntry_t *staAddARPTableEntry= (caStaAddARPTableEntry_t *)caCmdBuf; uncomment and use it */
3563
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003564 printf("\n Entry wfastaAddARPTableEntry... ");
3565 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003566
3567 infoResp.status = STATUS_COMPLETE;
3568 wfaEncodeTLV(WFA_STA_P2P_ADD_ARP_TABLE_ENTRY_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3569 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3570
3571 return WFA_SUCCESS;
3572}
3573
3574/*
3575 * wfaStaBlockICMPResponse():
3576 */
3577int wfaStaBlockICMPResponse(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3578{
3579 dutCmdResponse_t infoResp;
3580 /* caStaBlockICMPResponse_t *staAddARPTableEntry= (caStaBlockICMPResponse_t *)caCmdBuf; uncomment and use it */
3581
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003582 printf("\n Entry wfaStaBlockICMPResponse... ");
3583 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003584
3585 infoResp.status = STATUS_COMPLETE;
3586 wfaEncodeTLV(WFA_STA_P2P_BLOCK_ICMP_RESPONSE_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3587 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3588
3589 return WFA_SUCCESS;
3590}
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003591
3592/*
3593 * wfaStaSetRadio():
3594 */
3595
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00003596int wfaStaSetRadio(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3597{
3598 dutCommand_t *setRadio = (dutCommand_t *)caCmdBuf;
3599 dutCmdResponse_t *staCmdResp = &gGenericResp;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00003600 caStaSetRadio_t *sr = &setRadio->cmdsu.sr;
3601
3602 if(sr->mode == WFA_OFF)
3603 {
3604 // turn radio off
3605 }
3606 else
3607 {
3608 // always turn the radio on
3609 }
3610
3611 staCmdResp->status = STATUS_COMPLETE;
3612 wfaEncodeTLV(WFA_STA_SET_RADIO_RESP_TLV, 4, (BYTE *)staCmdResp, respBuf);
3613 *respLen = WFA_TLV_HDR_LEN + 4;
3614
3615 return WFA_SUCCESS;
3616}
3617
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003618/*
3619 * wfaStaSetRFeature():
3620 */
3621
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00003622int wfaStaSetRFeature(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3623{
3624 dutCommand_t *dutCmd = (dutCommand_t *)caCmdBuf;
3625 caStaRFeat_t *rfeat = &dutCmd->cmdsu.rfeat;
3626 dutCmdResponse_t *caResp = &gGenericResp;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00003627
3628 if(strcasecmp(rfeat->prog, "tdls") == 0)
3629 {
3630
3631
3632 }
3633
3634 caResp->status = STATUS_COMPLETE;
3635 wfaEncodeTLV(WFA_STA_SET_RFEATURE_RESP_TLV, 4, (BYTE *)caResp, respBuf);
3636 *respLen = WFA_TLV_HDR_LEN + 4;
3637
3638 return WFA_SUCCESS;
3639}
3640
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003641/*
3642 * wfaStaStartWfdConnection():
3643 */
3644int wfaStaStartWfdConnection(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3645{
3646 dutCmdResponse_t infoResp;
3647 //caStaStartWfdConn_t *staStartWfdConn= (caStaStartWfdConn_t *)caCmdBuf; //uncomment and use it
3648
3649 printf("\n Entry wfaStaStartWfdConnection... ");
3650
3651
3652 // Fetch the GrpId and WFD session and return
3653 strcpy(&infoResp.cmdru.wfdConnInfo.wfdSessionId[0], "1234567890");
3654 strcpy(&infoResp.cmdru.wfdConnInfo.p2pGrpId[0], "WIFI_DISPLAY");
3655 strcpy(&infoResp.cmdru.wfdConnInfo.result[0], "GO");
3656
3657 infoResp.status = STATUS_COMPLETE;
3658 wfaEncodeTLV(WFA_STA_START_WFD_CONNECTION_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3659 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3660
3661 return WFA_SUCCESS;
3662}
3663/*
3664 * wfaStaCliCommand():
3665 */
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00003666
Ankur Vachhanic485b712012-02-15 23:29:49 +00003667int wfaStaCliCommand(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3668{
3669
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003670 char cmdName[32];
3671 char *pcmdStr=NULL, *str;
3672 int st;
3673 char CmdStr[WFA_CMD_STR_SZ];
3674 FILE *wfaCliFd;
3675 char wfaCliBuff[64];
3676 char retstr[256];
3677 int CmdReturnFlag;
3678 char tmp[256];
3679 FILE * sh_pipe;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003680
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003681 caStaCliCmdResp_t infoResp;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003682
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003683 printf("\n Entry wfaStaCliCommand... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003684
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003685 printf("The command Received: %s",caCmdBuf);
Ankur Vachhanic485b712012-02-15 23:29:49 +00003686
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003687 memcpy(cmdName, strtok_r((char *)caCmdBuf, ",", (char **)&pcmdStr), 32);
Ankur Vachhanic485b712012-02-15 23:29:49 +00003688
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003689 sprintf(CmdStr, "%s",cmdName);
3690
3691 for(;;)
3692 {
3693 str = strtok_r(NULL, ",", &pcmdStr);
3694 if(str == NULL || str[0] == '\0')
3695 break;
3696 else
3697 {
3698 sprintf(CmdStr, "%s /%s",CmdStr,str);
3699 str = strtok_r(NULL, ",", &pcmdStr);
3700 sprintf(CmdStr, "%s %s",CmdStr,str);
3701 }
3702 }
3703
3704 CmdReturnFlag =0;
3705 // check the return process
3706 wfaCliFd=fopen("/etc/WfaEndpoint/wfa_cli.txt","r");
3707 if(wfaCliFd!= NULL)
3708 {
3709 while(fgets(wfaCliBuff, 64, wfaCliFd) != NULL)
3710 {
3711 //printf("\nLine read from CLI file : %s",wfaCliBuff);
3712 if(ferror(wfaCliFd))
3713 break;
3714
3715 str=strtok(wfaCliBuff,"-");
3716 if(strcmp(str,cmdName) == 0)
3717 {
3718 str=strtok(NULL,",");
3719 if(strcmp(str,"TRUE") == 0)
3720 CmdReturnFlag =1;
3721
3722 break;
3723 }
3724 }
3725 fclose(wfaCliFd);
3726 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003727
3728
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003729 //printf("\n Command Return Flag : %d",CmdReturnFlag);
3730 st = 1;
3731 memset(&retstr[0],'\0',255);
3732 memset(&tmp[0],'\0',255);
Ankur Vachhanic485b712012-02-15 23:29:49 +00003733
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003734 sprintf(gCmdStr, "%s", CmdStr);
3735 printf("\nCLI Command -- %s\n", gCmdStr);
Ankur Vachhanic485b712012-02-15 23:29:49 +00003736
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003737 sh_pipe = popen(gCmdStr,"r");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003738
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003739 if(!sh_pipe)
3740 {
3741 printf ("Error in opening pipe");
3742 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003743
3744
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003745 //tmp_val=getdelim(&retstr,255,"\n",sh_pipe);
3746 if (fgets(&retstr[0], 255, sh_pipe) == NULL)
3747 {
3748 printf("Getting NULL string\n");
3749 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003750
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003751 if(pclose(sh_pipe) != 0)
3752 {
3753 printf("Error in closing shell cmd pipe");
3754 }
3755 sleep(2);
Ankur Vachhanic485b712012-02-15 23:29:49 +00003756
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003757 printf("CLI retun value- %s\n",retstr);
Ankur Vachhanic485b712012-02-15 23:29:49 +00003758
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003759 memcpy(tmp, strtok_r((char *)retstr, "-", (char **)&pcmdStr), 2);
3760 printf("\ncli status - %s",tmp);
3761 if(strlen(tmp) > 0)
3762 st = atoi(tmp);
3763
3764 infoResp.resFlag=CmdReturnFlag;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003765
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003766 switch(st)
3767 {
3768 case 0:
3769 infoResp.status = STATUS_COMPLETE;
3770 if (CmdReturnFlag)
3771 {
3772 str=strtok_r(NULL, "\n", (char **)&pcmdStr);
3773 strncpy(tmp,str, 255);
3774 printf("\nresult - %s",tmp);
3775 if(tmp != NULL)
3776 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003777 memset(&infoResp.result[0],'\0',WFA_CLI_CMD_RESP_LEN-1);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003778 strncpy(&infoResp.result[0], tmp,(strlen(tmp) < WFA_CLI_CMD_RESP_LEN ) ? strlen(tmp) : (WFA_CLI_CMD_RESP_LEN-1) );
3779 printf("Return CLI result to CA: %s****\n", &infoResp.result[0]);
3780 }
3781 else
3782 strcpy(&infoResp.result[0], "ENV_VAR_NOT_DEFINED");
3783 }
3784 break;
3785 case 1:
3786 infoResp.status = STATUS_ERROR;
3787 break;
3788 case 2:
3789 infoResp.status = STATUS_INVALID;
3790 break;
3791 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003792
3793 wfaEncodeTLV(WFA_STA_CLI_CMD_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3794 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3795
3796 printf("\nExit from CLI function\n");
3797 return TRUE;
3798
3799
3800}
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003801/*
3802 * wfaStaConnectGoStartWfd():
3803 */
3804
3805int wfaStaConnectGoStartWfd(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3806{
3807 dutCmdResponse_t infoResp;
3808// caStaConnectGoStartWfd_t *staConnecGoStartWfd= (caStaConnectGoStartWfd_t *)caCmdBuf; //uncomment and use it
3809
3810 printf("\n Entry wfaStaConnectGoStartWfd... ");
3811
3812 // connect the specified GO and then establish the wfd session
3813
3814 // Fetch WFD session and return
3815 strcpy(&infoResp.cmdru.wfdConnInfo.wfdSessionId[0], "1234567890");
3816
3817 infoResp.status = STATUS_COMPLETE;
3818 wfaEncodeTLV(WFA_STA_CONNECT_GO_START_WFD_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3819 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3820
3821 return WFA_SUCCESS;
3822}
3823
3824/*
3825 * wfaStaGenerateEvent():
3826 */
3827
3828int wfaStaGenerateEvent(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3829{
3830 dutCmdResponse_t infoResp;
3831 caStaGenEvent_t *staGenerateEvent= (caStaGenEvent_t *)caCmdBuf; //uncomment and use it
3832 caWfdStaGenEvent_t *wfdGenEvent;
3833
3834 printf("\n Entry wfaStaGenerateEvent... ");
3835
3836
3837 // Geneate the specified action and return with complete/error.
3838 if(staGenerateEvent->program == PROG_TYPE_WFD)
3839 {
3840 wfdGenEvent = &staGenerateEvent->wfdEvent;
3841 if(wfdGenEvent ->type == eUibcGen)
3842 {
3843 }
3844 else if(wfdGenEvent ->type == eUibcHid)
3845 {
3846 }
3847 else if(wfdGenEvent ->type == eFrameSkip)
3848 {
3849
3850 }
3851 else if(wfdGenEvent ->type == eI2cRead)
3852 {
3853 }
3854 else if(wfdGenEvent ->type == eI2cWrite)
3855 {
3856 }
3857 else if(wfdGenEvent ->type == eInputContent)
3858 {
3859 }
3860 else if(wfdGenEvent ->type == eIdrReq)
3861 {
3862 }
3863 }
3864
3865 infoResp.status = STATUS_COMPLETE;
3866 wfaEncodeTLV(WFA_STA_GENERATE_EVENT_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3867 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3868
3869 return WFA_SUCCESS;
3870}
3871
3872
3873
3874
3875/*
3876 * wfaStaReinvokeWfdSession():
3877 */
3878
3879int wfaStaReinvokeWfdSession(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3880{
3881 dutCmdResponse_t infoResp;
3882// caStaReinvokeWfdSession_t *staReinvokeSession= (caStaReinvokeWfdSession_t *)caCmdBuf; //uncomment and use it
3883
3884 printf("\n Entry wfaStaReinvokeWfdSession... ");
3885
3886 // Reinvoke the WFD session by accepting the p2p invitation or sending p2p invitation
3887
3888
3889 infoResp.status = STATUS_COMPLETE;
3890 wfaEncodeTLV(WFA_STA_REINVOKE_WFD_SESSION_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3891 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3892
3893 return WFA_SUCCESS;
3894}
3895
3896
3897int wfaStaGetParameter(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3898{
3899 dutCmdResponse_t infoResp;
3900 caStaGetParameter_t *staGetParam= (caStaGetParameter_t *)caCmdBuf; //uncomment and use it
3901
3902
3903 caStaGetParameterResp_t *paramList = &infoResp.cmdru.getParamValue;
3904
3905 printf("\n Entry wfaStaGetParameter... ");
3906
3907 // Check the program type
3908 if(staGetParam->program == PROG_TYPE_WFD)
3909 {
3910 if(staGetParam->getParamValue == eDiscoveredDevList )
3911 {
3912 // Get the discovered devices, make space seperated list and return, check list is not bigger than 128 bytes.
3913 paramList->getParamType = eDiscoveredDevList;
3914 strcpy((char *)&paramList->devList, "11:22:33:44:55:66 22:33:44:55:66:77 33:44:55:66:77:88");
3915 }
3916 }
3917
3918
3919 infoResp.status = STATUS_COMPLETE;
3920 wfaEncodeTLV(WFA_STA_GET_PARAMETER_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3921 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3922
3923 return WFA_SUCCESS;
3924}
3925
Ankur Vachhanic485b712012-02-15 23:29:49 +00003926