blob: 73e57ac9f48e02899a411805575d084a53450045 [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
2730 totalpkts = staPing->duration * staPing->frameRate;
2731#ifdef WFA_PC_CONSOLE
2732
2733 printf("\nCS : The Stream ID is %d",streamid);
2734 printf("\nCS :the addr is %s ",addr);
2735 strcpy(addr,staPing->dipaddr);
2736 printf("\nCS :Inside the WFA_PC_CONSLE BLOCK");
2737 printf("\nCS :the addr is %s ",addr);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002738 if (staPing->iptype == 2)
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002739 {
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002740 memset(bflag, 0, strlen(bflag));
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002741 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002742 else
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002743 {
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002744 tmpstr = strtok(addr, ".");
2745 inum = atoi(tmpstr);
2746
2747 printf("interval %f\n", *interval);
2748
2749 if(inum >= 224 && inum <= 239) // multicast
2750 {
2751 }
2752 else // if not MC, check if it is BC address
2753 {
2754 printf("\nCS :Inside the BC address BLOCK");
2755 printf("\nCS :the inum %d",inum);
2756 strtok(NULL, ".");
2757 //strtok(NULL, ".");
2758 tmpstr = strtok(NULL, ".");
2759 printf("tmpstr %s\n", tmpstr);
2760 inum = atoi(tmpstr);
2761 printf("\nCS : The string is %s",tmpstr);
2762 if(inum != 255)
2763 memset(bflag, 0, strlen(bflag));
2764 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002765 }
2766#endif
2767 printf("\nCS : The Stream ID is %d",streamid);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002768 printf("IPtype : %i",staPing->iptype);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002769
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002770 if (staPing->iptype == 2)
2771 {
2772 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 +00002773 streamid,streamid,bflag, staPing->dipaddr, *interval, totalpkts, staPing->frameSize,streamid);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002774 sret = system(cmdStr);
2775 printf("\nCS : The command string is %s",cmdStr);
2776 }
2777 else
2778 {
2779 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",
2780 streamid,streamid,bflag, staPing->dipaddr, *interval, totalpkts, staPing->frameSize,streamid);
2781 sret = system(cmdStr);
2782 printf("\nCS : The command string is %s",cmdStr);
2783 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002784 sprintf(cmdStr, "updatepid.sh /tmp/spout_%d.txt",streamid);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002785 sret = system(cmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002786 printf("\nCS : The command string is %s",cmdStr);
2787
2788}
2789
2790int wfaStopPing(dutCmdResponse_t *stpResp, int streamid)
2791{
2792 char strout[256];
2793 FILE *tmpfile = NULL;
2794 char cmdStr[128];
2795 printf("Ping stop id %d\n", streamid);
2796 sprintf(cmdStr, "getpid.sh /tmp/spout_%d.txt /tmp/pid.txt",streamid);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002797 sret = system(cmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002798
2799 printf("\nCS : The command string is %s",cmdStr);
2800
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002801 sret = system("stoping.sh /tmp/pid.txt ; sleep 2");
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002802
2803 sprintf(cmdStr, "getpstats.sh /tmp/spout_%d.txt",streamid);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002804 sret = system(cmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002805
2806 printf("\nCS : The command string is %s",cmdStr);
2807
2808 tmpfile = fopen("/tmp/stpsta.txt", "r+");
2809
2810 if(tmpfile == NULL)
2811 {
2812 return WFA_FAILURE;
2813 }
2814
2815 if(fscanf(tmpfile, "%s", strout) != EOF)
2816 {
2817 if(*strout == '\0')
2818 {
2819 stpResp->cmdru.pingStp.sendCnt = 0;
2820 }
2821
2822 else
2823 stpResp->cmdru.pingStp.sendCnt = atoi(strout);
2824 }
2825
2826 printf("after scan sent count %i\n", stpResp->cmdru.pingStp.sendCnt);
2827
2828
2829 if(fscanf(tmpfile, "%s", strout) != EOF)
2830 {
2831 if(*strout == '\0')
2832 {
2833 stpResp->cmdru.pingStp.repliedCnt = 0;
2834 }
2835 else
2836 stpResp->cmdru.pingStp.repliedCnt = atoi(strout);
2837 }
2838 printf("after scan replied count %i\n", stpResp->cmdru.pingStp.repliedCnt);
2839
2840 fclose(tmpfile);
2841
2842 return WFA_SUCCESS;
2843}
2844
Ankur Vachhanic485b712012-02-15 23:29:49 +00002845/*
2846 * wfaStaGetP2pDevAddress():
2847 */
2848int wfaStaGetP2pDevAddress(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2849{
2850 dutCmdResponse_t infoResp;
2851 /* dutCommand_t *getInfo = (dutCommand_t *)caCmdBuf; */
2852
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002853 printf("\n Entry wfaStaGetP2pDevAddress... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00002854
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002855 // Fetch the device ID and store into infoResp->cmdru.devid
2856 //strcpy(infoResp->cmdru.devid, str);
2857 strcpy(&infoResp.cmdru.devid[0], "ABCDEFGH");
Ankur Vachhanic485b712012-02-15 23:29:49 +00002858
2859 infoResp.status = STATUS_COMPLETE;
2860 wfaEncodeTLV(WFA_STA_P2P_GET_DEV_ADDRESS_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
2861 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
2862
2863 return WFA_SUCCESS;
2864}
2865
2866
2867
2868/*
2869 * wfaStaSetP2p():
2870 */
2871int wfaStaSetP2p(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2872{
2873 dutCmdResponse_t infoResp;
2874 /* caStaSetP2p_t *getStaSetP2p = (caStaSetP2p_t *)caCmdBuf; uncomment and use it*/
2875
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002876 printf("\n Entry wfaStaSetP2p... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00002877
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002878 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00002879
2880 infoResp.status = STATUS_COMPLETE;
2881 wfaEncodeTLV(WFA_STA_P2P_SETP2P_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
2882 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
2883
2884 return WFA_SUCCESS;
2885}
2886/*
2887 * wfaStaP2pConnect():
2888 */
2889int wfaStaP2pConnect(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2890{
2891 dutCmdResponse_t infoResp;
2892 /* caStaP2pConnect_t *getStaP2pConnect = (caStaP2pConnect_t *)caCmdBuf; uncomment and use it */
2893
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002894 printf("\n Entry wfaStaP2pConnect... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00002895
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002896 // Implement the function and does not return anything.
Ankur Vachhanic485b712012-02-15 23:29:49 +00002897
2898
2899 infoResp.status = STATUS_COMPLETE;
2900 wfaEncodeTLV(WFA_STA_P2P_CONNECT_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
2901 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
2902
2903 return WFA_SUCCESS;
2904}
2905
2906/*
2907 * wfaStaStartAutoGo():
2908 */
2909int wfaStaStartAutoGo(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2910{
2911 dutCmdResponse_t infoResp;
2912 //caStaStartAutoGo_t *getStaStartAutoGo = (caStaStartAutoGo_t *)caCmdBuf;
2913
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002914 printf("\n Entry wfaStaStartAutoGo... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00002915
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002916 // Fetch the group ID and store into infoResp->cmdru.grpid
2917 strcpy(&infoResp.cmdru.grpid[0], "ABCDEFGH");
Ankur Vachhanic485b712012-02-15 23:29:49 +00002918
2919 infoResp.status = STATUS_COMPLETE;
2920 wfaEncodeTLV(WFA_STA_P2P_START_AUTO_GO_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
2921 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
2922
2923 return WFA_SUCCESS;
2924}
2925
2926
2927
2928
2929/*
2930 * wfaStaP2pStartGrpFormation():
2931 */
2932int wfaStaP2pStartGrpFormation(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2933{
2934 dutCmdResponse_t infoResp;
2935 //caStaP2pStartGrpForm_t *getStaP2pStartGrpForm = (caStaP2pStartGrpForm_t *)caCmdBuf;
2936
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002937 printf("\n Entry wfaStaP2pStartGrpFormation... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00002938
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002939 // Fetch the device mode and put in infoResp->cmdru.p2presult
2940 //strcpy(infoResp->cmdru.p2presult, "GO");
Ankur Vachhanic485b712012-02-15 23:29:49 +00002941
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002942 // Fetch the device grp id and put in infoResp->cmdru.grpid
2943 //strcpy(infoResp->cmdru.grpid, "AA:BB:CC:DD:EE:FF_DIRECT-SSID");
2944
2945 strcpy(infoResp.cmdru.grpFormInfo.result, "CLIENT");
2946 strcpy(infoResp.cmdru.grpFormInfo.grpId, "AA:BB:CC:DD:EE:FF_DIRECT-SSID");
Ankur Vachhanic485b712012-02-15 23:29:49 +00002947
2948
2949 infoResp.status = STATUS_COMPLETE;
2950 wfaEncodeTLV(WFA_STA_P2P_START_GRP_FORMATION_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
2951 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
2952
2953 return WFA_SUCCESS;
2954}
2955
2956
2957/*
2958 * wfaStaP2pDissolve():
2959 */
2960int wfaStaP2pDissolve(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2961{
2962 dutCmdResponse_t infoResp;
2963 //caStaP2pDissolve_t *getStap2pDissolve= (caStaP2pDissolve_t *)caCmdBuf;
2964
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002965 printf("\n Entry wfaStaP2pDissolve... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00002966
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002967 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00002968
2969 infoResp.status = STATUS_COMPLETE;
2970 wfaEncodeTLV(WFA_STA_P2P_DISSOLVE_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
2971 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
2972
2973 return WFA_SUCCESS;
2974}
2975
2976/*
2977 * wfaStaSendP2pInvReq():
2978 */
2979int wfaStaSendP2pInvReq(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2980{
2981 dutCmdResponse_t infoResp;
2982 /* caStaSendP2pInvReq_t *getStaP2pInvReq= (caStaSendP2pInvReq_t *)caCmdBuf; */
2983
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002984 printf("\n Entry wfaStaSendP2pInvReq... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00002985
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002986 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00002987
2988 infoResp.status = STATUS_COMPLETE;
2989 wfaEncodeTLV(WFA_STA_P2P_SEND_INV_REQ_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
2990 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
2991
2992 return WFA_SUCCESS;
2993}
2994
2995
2996/*
2997 * wfaStaAcceptP2pInvReq():
2998 */
2999int wfaStaAcceptP2pInvReq(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3000{
3001 dutCmdResponse_t infoResp;
3002 /* uncomment and use it
3003 * caStaAcceptP2pInvReq_t *getStaP2pInvReq= (caStaAcceptP2pInvReq_t *)caCmdBuf;
3004 */
3005
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003006 printf("\n Entry wfaStaAcceptP2pInvReq... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003007
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003008 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003009
3010 infoResp.status = STATUS_COMPLETE;
3011 wfaEncodeTLV(WFA_STA_P2P_ACCEPT_INV_REQ_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3012 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3013
3014 return WFA_SUCCESS;
3015}
3016
3017
3018/*
3019 * wfaStaSendP2pProvDisReq():
3020 */
3021int wfaStaSendP2pProvDisReq(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3022{
3023 dutCmdResponse_t infoResp;
3024 /* uncomment and use it
3025 * caStaSendP2pProvDisReq_t *getStaP2pProvDisReq= (caStaSendP2pProvDisReq_t *)caCmdBuf;
3026 */
3027
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003028 printf("\n Entry wfaStaSendP2pProvDisReq... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003029
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003030 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003031
3032 infoResp.status = STATUS_COMPLETE;
3033 wfaEncodeTLV(WFA_STA_P2P_SEND_PROV_DIS_REQ_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3034 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3035
3036 return WFA_SUCCESS;
3037}
3038
3039/*
3040 * wfaStaSetWpsPbc():
3041 */
3042int wfaStaSetWpsPbc(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3043{
3044 dutCmdResponse_t infoResp;
3045 /* uncomment and use it
3046 * caStaSetWpsPbc_t *getStaSetWpsPbc= (caStaSetWpsPbc_t *)caCmdBuf;
3047 */
3048
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003049 printf("\n Entry wfaStaSetWpsPbc... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003050
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003051 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003052
3053 infoResp.status = STATUS_COMPLETE;
3054 wfaEncodeTLV(WFA_STA_WPS_SETWPS_PBC_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3055 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3056
3057 return WFA_SUCCESS;
3058}
3059
3060/*
3061 * wfaStaWpsReadPin():
3062 */
3063int wfaStaWpsReadPin(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3064{
3065 dutCmdResponse_t infoResp;
3066 /* uncomment and use it
3067 * caStaWpsReadPin_t *getStaWpsReadPin= (caStaWpsReadPin_t *)caCmdBuf;
3068 */
3069
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003070 printf("\n Entry wfaStaWpsReadPin... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003071
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003072 // Fetch the device PIN and put in infoResp->cmdru.wpsPin
3073 //strcpy(infoResp->cmdru.wpsPin, "12345678");
3074 strcpy(&infoResp.cmdru.wpsPin[0], "1234456");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003075
3076
3077 infoResp.status = STATUS_COMPLETE;
3078 wfaEncodeTLV(WFA_STA_WPS_READ_PIN_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3079 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3080
3081 return WFA_SUCCESS;
3082}
3083
3084
3085
3086/*
3087 * wfaStaWpsReadLabel():
3088 */
3089int wfaStaWpsReadLabel(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3090{
3091 dutCmdResponse_t infoResp;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003092
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003093 printf("\n Entry wfaStaWpsReadLabel... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003094
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003095 // Fetch the device Label and put in infoResp->cmdru.wpsPin
3096 //strcpy(infoResp->cmdru.wpsPin, "12345678");
3097 strcpy(&infoResp.cmdru.wpsPin[0], "1234456");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003098
3099
3100 infoResp.status = STATUS_COMPLETE;
3101 wfaEncodeTLV(WFA_STA_WPS_READ_PIN_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3102 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3103
3104 return WFA_SUCCESS;
3105}
3106
3107
3108/*
3109 * wfaStaWpsEnterPin():
3110 */
3111int wfaStaWpsEnterPin(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3112{
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003113 dutCmdResponse_t infoResp;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003114 /* uncomment and use it
3115 * caStaWpsEnterPin_t *getStaWpsEnterPin= (caStaWpsEnterPin_t *)caCmdBuf;
3116 */
3117
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003118 printf("\n Entry wfaStaWpsEnterPin... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003119
3120 // Implement the function and this does not return any thing back.
3121
3122
3123 infoResp.status = STATUS_COMPLETE;
3124 wfaEncodeTLV(WFA_STA_WPS_ENTER_PIN_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3125 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3126
3127 return WFA_SUCCESS;
3128}
3129
3130
3131/*
3132 * wfaStaGetPsk():
3133 */
3134int wfaStaGetPsk(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3135{
3136 dutCmdResponse_t infoResp;
3137 /* caStaGetPsk_t *getStaGetPsk= (caStaGetPsk_t *)caCmdBuf; uncomment and use it */
3138
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003139 printf("\n Entry wfaStaGetPsk... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003140
3141
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003142 // Fetch the device PP and SSID and put in infoResp->cmdru.pskInfo
3143 //strcpy(infoResp->cmdru.wpsPin, "12345678");
3144 strcpy(&infoResp.cmdru.pskInfo.passPhrase[0], "1234456");
3145 strcpy(&infoResp.cmdru.pskInfo.ssid[0], "WIFI_DIRECT");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003146
3147
3148 infoResp.status = STATUS_COMPLETE;
3149 wfaEncodeTLV(WFA_STA_P2P_GET_PSK_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3150 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3151
3152 return WFA_SUCCESS;
3153}
3154
3155/*
3156 * wfaStaP2pReset():
3157 */
3158int wfaStaP2pReset(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3159{
3160 dutCmdResponse_t infoResp;
3161 /* dutCommand_t *getStaP2pReset= (dutCommand_t *)caCmdBuf; */
3162
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003163 printf("\n Entry wfaStaP2pReset... ");
3164 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003165
3166 infoResp.status = STATUS_COMPLETE;
3167 wfaEncodeTLV(WFA_STA_P2P_RESET_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3168 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3169
3170 return WFA_SUCCESS;
3171}
3172
3173
3174
3175/*
3176 * wfaStaGetP2pIpConfig():
3177 */
3178int wfaStaGetP2pIpConfig(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3179{
3180 dutCmdResponse_t infoResp;
3181 /* caStaGetP2pIpConfig_t *staGetP2pIpConfig= (caStaGetP2pIpConfig_t *)caCmdBuf; */
3182
3183 caStaGetIpConfigResp_t *ifinfo = &(infoResp.cmdru.getIfconfig);
3184
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003185 printf("\n Entry wfaStaGetP2pIpConfig... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003186
3187
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003188 // Fetch the device IP config and put in infoResp->cmdru
3189 //strcpy(infoResp->cmdru.wpsPin, "12345678");
3190 ifinfo->isDhcp =0;
3191 strcpy(&(ifinfo->ipaddr[0]), "192.165.100.111");
3192 strcpy(&(ifinfo->mask[0]), "255.255.255.0");
3193 strcpy(&(ifinfo->dns[0][0]), "192.165.100.1");
3194 strcpy(&(ifinfo->mac[0]), "ba:ba:ba:ba:ba:ba");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003195
3196 infoResp.status = STATUS_COMPLETE;
3197 wfaEncodeTLV(WFA_STA_P2P_GET_IP_CONFIG_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3198 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3199
3200 return WFA_SUCCESS;
3201}
3202
3203
3204
3205
3206/*
3207 * wfaStaSendServiceDiscoveryReq():
3208 */
3209int wfaStaSendServiceDiscoveryReq(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3210{
3211 dutCmdResponse_t infoResp;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003212
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003213 printf("\n Entry wfaStaSendServiceDiscoveryReq... ");
3214 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003215
3216
3217 infoResp.status = STATUS_COMPLETE;
3218 wfaEncodeTLV(WFA_STA_P2P_SEND_SERVICE_DISCOVERY_REQ_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3219 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3220
3221 return WFA_SUCCESS;
3222}
3223
3224
3225
3226/*
3227 * wfaStaSendP2pPresenceReq():
3228 */
3229int wfaStaSendP2pPresenceReq(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3230{
3231 dutCmdResponse_t infoResp;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003232 //caStaSendP2pPresenceReq_t *staSendP2pPresenceReq= (caStaSendP2pPresenceReq_t *)caCmdBuf;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003233
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003234 //printf("\n Entry wfaStaSendP2pPresenceReq... ");
3235 //printf("\n The long long Duration: %lld... ",staSendP2pPresenceReq->duration);
3236 //printf("\n The long long interval : %lld.. ",staSendP2pPresenceReq->interval);
Ankur Vachhanic485b712012-02-15 23:29:49 +00003237
Ankur Vachhanic485b712012-02-15 23:29:49 +00003238 infoResp.status = STATUS_COMPLETE;
3239 wfaEncodeTLV(WFA_STA_P2P_SEND_PRESENCE_REQ_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3240 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3241
3242 return WFA_SUCCESS;
3243}
3244
3245/*
3246 * wfaStaSetSleepReq():
3247 */
3248int wfaStaSetSleepReq(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3249{
3250 dutCmdResponse_t infoResp;
3251 /* caStaSetSleep_t *staSetSleepReq= (caStaSetSleep_t *)caCmdBuf; */
3252
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003253 printf("\n Entry wfaStaSetSleepReq... ");
3254 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003255
3256
3257 infoResp.status = STATUS_COMPLETE;
3258 wfaEncodeTLV(WFA_STA_P2P_SET_SLEEP_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3259 *respLen = WFA_TLV_HDR_LEN +4;
3260
3261 return WFA_SUCCESS;
3262}
3263
3264/*
3265 * wfaStaSetOpportunisticPsReq():
3266 */
3267int wfaStaSetOpportunisticPsReq(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3268{
3269 dutCmdResponse_t infoResp;
3270 /* caStaSetOpprPs_t *staSetOpperPsReq= (caStaSetOpprPs_t *)caCmdBuf; uncomment and use it */
3271
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003272 printf("\n Entry wfaStaSetOpportunisticPsReq... ");
3273 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003274
3275
3276 infoResp.status = STATUS_COMPLETE;
3277 wfaEncodeTLV(WFA_STA_P2P_SET_OPPORTUNISTIC_PS_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3278 *respLen = WFA_TLV_HDR_LEN + 4;
3279
3280 return WFA_SUCCESS;
3281}
3282#ifndef WFA_STA_TB
3283/*
3284 * wfaStaPresetParams():
3285 */
3286
3287int wfaStaPresetParams(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3288{
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003289 dutCmdResponse_t infoResp;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003290
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003291 //caStaPresetParameters_t *presetParams = (caStaPresetParameters_t *)caCmdBuf;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003292
3293
3294 DPRINT_INFO(WFA_OUT, "Inside wfaStaPresetParameters function ...\n");
3295
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003296 // Implement the function and its sub commands
3297 infoResp.status = STATUS_COMPLETE;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003298
3299 wfaEncodeTLV(WFA_STA_PRESET_PARAMETERS_RESP_TLV, 4, (BYTE *)&infoResp, respBuf);
3300 *respLen = WFA_TLV_HDR_LEN + 4;
3301
3302 return WFA_SUCCESS;
3303}
3304int wfaStaSet11n(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3305{
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003306
3307 dutCmdResponse_t infoResp;
3308 dutCmdResponse_t *v11nParamsResp = &infoResp;
3309
3310#ifdef WFA_11N_SUPPORT_ONLY
Ankur Vachhanic485b712012-02-15 23:29:49 +00003311
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003312 caSta11n_t * v11nParams = (caSta11n_t *)caCmdBuf;
3313
3314 int st =0; // SUCCESS
Ankur Vachhanic485b712012-02-15 23:29:49 +00003315
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003316 DPRINT_INFO(WFA_OUT, "Inside wfaStaSet11n function....\n");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003317
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003318 if(v11nParams->addba_reject != 0xFF && v11nParams->addba_reject < 2)
3319 {
3320 // implement the funciton
3321 //st = wfaExecuteCLI(gCmdStr);
3322 if(st != 0)
3323 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003324 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003325 strcpy(v11nParamsResp->cmdru.info, "set_addba_reject failed");
3326 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3327 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3328 return FALSE;
3329 }
3330 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003331
3332 if(v11nParams->ampdu != 0xFF && v11nParams->ampdu < 2)
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003333 {
3334 // implement the funciton
3335 //st = wfaExecuteCLI(gCmdStr);
Ankur Vachhanic485b712012-02-15 23:29:49 +00003336
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003337 if(st != 0)
3338 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003339 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003340 strcpy(v11nParamsResp->cmdru.info, "set_ampdu failed");
3341 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3342 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3343 return FALSE;
3344 }
3345 }
3346
Ankur Vachhanic485b712012-02-15 23:29:49 +00003347 if(v11nParams->amsdu != 0xFF && v11nParams->amsdu < 2)
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003348 {
3349 // implement the funciton
3350 //st = wfaExecuteCLI(gCmdStr);
3351 if(st != 0)
3352 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003353 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003354 strcpy(v11nParamsResp->cmdru.info, "set_amsdu failed");
3355 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3356 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3357 return FALSE;
3358 }
3359 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003360
3361 if(v11nParams->greenfield != 0xFF && v11nParams->greenfield < 2)
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003362 {
3363 // implement the funciton
3364 //st = wfaExecuteCLI(gCmdStr);
3365 if(st != 0)
3366 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003367 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003368 strcpy(v11nParamsResp->cmdru.info, "_set_greenfield failed");
3369 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3370 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3371 return FALSE;
3372 }
3373 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003374
3375 if(v11nParams->mcs32!= 0xFF && v11nParams->mcs32 < 2 && v11nParams->mcs_fixedrate[0] != '\0')
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003376 {
3377 // implement the funciton
3378 //st = wfaExecuteCLI(gCmdStr);
3379 if(st != 0)
3380 {
3381 v11nParamsResp->status = STATUS_ERROR;
3382 strcpy(v11nParamsResp->cmdru.info, "set_mcs failed");
3383 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3384 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3385 return FALSE;
3386 }
3387 }
3388 else if (v11nParams->mcs32!= 0xFF && v11nParams->mcs32 < 2 && v11nParams->mcs_fixedrate[0] == '\0')
3389 {
3390 // implement the funciton
3391 //st = wfaExecuteCLI(gCmdStr);
3392 if(st != 0)
3393 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003394 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003395 strcpy(v11nParamsResp->cmdru.info, "set_mcs32 failed");
3396 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3397 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3398 return FALSE;
3399 }
3400 }
3401 else if (v11nParams->mcs32 == 0xFF && v11nParams->mcs_fixedrate[0] != '\0')
3402 {
3403 // implement the funciton
3404 //st = wfaExecuteCLI(gCmdStr);
3405 if(st != 0)
3406 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003407 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003408 strcpy(v11nParamsResp->cmdru.info, "set_mcs32 failed");
3409 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3410 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3411 return FALSE;
3412 }
3413 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003414
3415 if(v11nParams->rifs_test != 0xFF && v11nParams->rifs_test < 2)
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003416 {
3417 // implement the funciton
3418 //st = wfaExecuteCLI(gCmdStr);
3419 if(st != 0)
3420 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003421 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003422 strcpy(v11nParamsResp->cmdru.info, "set_rifs_test failed");
3423 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3424 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3425 return FALSE;
3426 }
3427 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003428
3429 if(v11nParams->sgi20 != 0xFF && v11nParams->sgi20 < 2)
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003430 {
3431 // implement the funciton
3432 //st = wfaExecuteCLI(gCmdStr);
3433 if(st != 0)
3434 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003435 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003436 strcpy(v11nParamsResp->cmdru.info, "set_sgi20 failed");
3437 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3438 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3439 return FALSE;
3440 }
3441 }
3442
3443 if(v11nParams->smps != 0xFFFF)
3444 {
3445 if(v11nParams->smps == 0)
3446 {
3447 // implement the funciton
3448 //st = wfaExecuteCLI(gCmdStr);
Ankur Vachhanic485b712012-02-15 23:29:49 +00003449 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003450 else if(v11nParams->smps == 1)
3451 {
3452 // implement the funciton
3453 //st = wfaExecuteCLI(gCmdStr);
3454 ;
3455 }
3456 else if(v11nParams->smps == 2)
3457 {
3458 // implement the funciton
3459 //st = wfaExecuteCLI(gCmdStr);
3460 ;
3461 }
3462 if(st != 0)
3463 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003464 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003465 strcpy(v11nParamsResp->cmdru.info, "set_smps failed");
3466 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3467 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3468 return FALSE;
3469 }
3470 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003471
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003472 if(v11nParams->stbc_rx != 0xFFFF)
3473 {
3474 // implement the funciton
3475 //st = wfaExecuteCLI(gCmdStr);
3476 if(st != 0)
3477 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003478 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003479 strcpy(v11nParamsResp->cmdru.info, "set_stbc_rx failed");
3480 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3481 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3482 return FALSE;
3483 }
3484 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003485
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003486 if(v11nParams->width[0] != '\0')
3487 {
3488 // implement the funciton
3489 //st = wfaExecuteCLI(gCmdStr);
3490 if(st != 0)
3491 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003492 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003493 strcpy(v11nParamsResp->cmdru.info, "set_11n_channel_width failed");
3494 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3495 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3496 return FALSE;
3497 }
3498 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003499
3500 if(v11nParams->_40_intolerant != 0xFF && v11nParams->_40_intolerant < 2)
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003501 {
3502 // implement the funciton
3503 //st = wfaExecuteCLI(gCmdStr);
3504 if(st != 0)
3505 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003506 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003507 strcpy(v11nParamsResp->cmdru.info, "set_40_intolerant failed");
3508 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3509 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3510 return FALSE;
3511 }
3512 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003513
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003514 if(v11nParams->txsp_stream != 0 && v11nParams->txsp_stream <4)
3515 {
3516 // implement the funciton
3517 //st = wfaExecuteCLI(gCmdStr);
3518 if(st != 0)
3519 {
3520 v11nParamsResp->status = STATUS_ERROR;
3521 strcpy(v11nParamsResp->cmdru.info, "set_txsp_stream failed");
3522 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3523 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3524 return FALSE;
3525 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003526
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003527 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003528
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003529 if(v11nParams->rxsp_stream != 0 && v11nParams->rxsp_stream < 4)
3530 {
3531 // implement the funciton
3532 //st = wfaExecuteCLI(gCmdStr);
3533 if(st != 0)
3534 {
3535 v11nParamsResp->status = STATUS_ERROR;
3536 strcpy(v11nParamsResp->cmdru.info, "set_rxsp_stream failed");
3537 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3538 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3539 return FALSE;
3540 }
3541 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003542
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003543#endif
Ankur Vachhanic485b712012-02-15 23:29:49 +00003544
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003545 v11nParamsResp->status = STATUS_COMPLETE;
3546 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, 4, (BYTE *)v11nParamsResp, respBuf);
3547 *respLen = WFA_TLV_HDR_LEN + 4;
3548 return WFA_SUCCESS;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003549}
3550#endif
3551/*
3552 * wfaStaAddArpTableEntry():
3553 */
3554int wfaStaAddArpTableEntry(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3555{
3556 dutCmdResponse_t infoResp;
3557 /* caStaAddARPTableEntry_t *staAddARPTableEntry= (caStaAddARPTableEntry_t *)caCmdBuf; uncomment and use it */
3558
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003559 printf("\n Entry wfastaAddARPTableEntry... ");
3560 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003561
3562 infoResp.status = STATUS_COMPLETE;
3563 wfaEncodeTLV(WFA_STA_P2P_ADD_ARP_TABLE_ENTRY_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3564 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3565
3566 return WFA_SUCCESS;
3567}
3568
3569/*
3570 * wfaStaBlockICMPResponse():
3571 */
3572int wfaStaBlockICMPResponse(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3573{
3574 dutCmdResponse_t infoResp;
3575 /* caStaBlockICMPResponse_t *staAddARPTableEntry= (caStaBlockICMPResponse_t *)caCmdBuf; uncomment and use it */
3576
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003577 printf("\n Entry wfaStaBlockICMPResponse... ");
3578 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003579
3580 infoResp.status = STATUS_COMPLETE;
3581 wfaEncodeTLV(WFA_STA_P2P_BLOCK_ICMP_RESPONSE_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3582 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3583
3584 return WFA_SUCCESS;
3585}
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003586
3587/*
3588 * wfaStaSetRadio():
3589 */
3590
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00003591int wfaStaSetRadio(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3592{
3593 dutCommand_t *setRadio = (dutCommand_t *)caCmdBuf;
3594 dutCmdResponse_t *staCmdResp = &gGenericResp;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00003595 caStaSetRadio_t *sr = &setRadio->cmdsu.sr;
3596
3597 if(sr->mode == WFA_OFF)
3598 {
3599 // turn radio off
3600 }
3601 else
3602 {
3603 // always turn the radio on
3604 }
3605
3606 staCmdResp->status = STATUS_COMPLETE;
3607 wfaEncodeTLV(WFA_STA_SET_RADIO_RESP_TLV, 4, (BYTE *)staCmdResp, respBuf);
3608 *respLen = WFA_TLV_HDR_LEN + 4;
3609
3610 return WFA_SUCCESS;
3611}
3612
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003613/*
3614 * wfaStaSetRFeature():
3615 */
3616
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00003617int wfaStaSetRFeature(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3618{
3619 dutCommand_t *dutCmd = (dutCommand_t *)caCmdBuf;
3620 caStaRFeat_t *rfeat = &dutCmd->cmdsu.rfeat;
3621 dutCmdResponse_t *caResp = &gGenericResp;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00003622
3623 if(strcasecmp(rfeat->prog, "tdls") == 0)
3624 {
3625
3626
3627 }
3628
3629 caResp->status = STATUS_COMPLETE;
3630 wfaEncodeTLV(WFA_STA_SET_RFEATURE_RESP_TLV, 4, (BYTE *)caResp, respBuf);
3631 *respLen = WFA_TLV_HDR_LEN + 4;
3632
3633 return WFA_SUCCESS;
3634}
3635
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003636/*
3637 * wfaStaStartWfdConnection():
3638 */
3639int wfaStaStartWfdConnection(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3640{
3641 dutCmdResponse_t infoResp;
3642 //caStaStartWfdConn_t *staStartWfdConn= (caStaStartWfdConn_t *)caCmdBuf; //uncomment and use it
3643
3644 printf("\n Entry wfaStaStartWfdConnection... ");
3645
3646
3647 // Fetch the GrpId and WFD session and return
3648 strcpy(&infoResp.cmdru.wfdConnInfo.wfdSessionId[0], "1234567890");
3649 strcpy(&infoResp.cmdru.wfdConnInfo.p2pGrpId[0], "WIFI_DISPLAY");
3650 strcpy(&infoResp.cmdru.wfdConnInfo.result[0], "GO");
3651
3652 infoResp.status = STATUS_COMPLETE;
3653 wfaEncodeTLV(WFA_STA_START_WFD_CONNECTION_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3654 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3655
3656 return WFA_SUCCESS;
3657}
3658/*
3659 * wfaStaCliCommand():
3660 */
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00003661
Ankur Vachhanic485b712012-02-15 23:29:49 +00003662int wfaStaCliCommand(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3663{
3664
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003665 char cmdName[32];
3666 char *pcmdStr=NULL, *str;
3667 int st;
3668 char CmdStr[WFA_CMD_STR_SZ];
3669 FILE *wfaCliFd;
3670 char wfaCliBuff[64];
3671 char retstr[256];
3672 int CmdReturnFlag;
3673 char tmp[256];
3674 FILE * sh_pipe;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003675
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003676 caStaCliCmdResp_t infoResp;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003677
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003678 printf("\n Entry wfaStaCliCommand... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003679
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003680 printf("The command Received: %s",caCmdBuf);
Ankur Vachhanic485b712012-02-15 23:29:49 +00003681
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003682 memcpy(cmdName, strtok_r((char *)caCmdBuf, ",", (char **)&pcmdStr), 32);
Ankur Vachhanic485b712012-02-15 23:29:49 +00003683
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003684 sprintf(CmdStr, "%s",cmdName);
3685
3686 for(;;)
3687 {
3688 str = strtok_r(NULL, ",", &pcmdStr);
3689 if(str == NULL || str[0] == '\0')
3690 break;
3691 else
3692 {
3693 sprintf(CmdStr, "%s /%s",CmdStr,str);
3694 str = strtok_r(NULL, ",", &pcmdStr);
3695 sprintf(CmdStr, "%s %s",CmdStr,str);
3696 }
3697 }
3698
3699 CmdReturnFlag =0;
3700 // check the return process
3701 wfaCliFd=fopen("/etc/WfaEndpoint/wfa_cli.txt","r");
3702 if(wfaCliFd!= NULL)
3703 {
3704 while(fgets(wfaCliBuff, 64, wfaCliFd) != NULL)
3705 {
3706 //printf("\nLine read from CLI file : %s",wfaCliBuff);
3707 if(ferror(wfaCliFd))
3708 break;
3709
3710 str=strtok(wfaCliBuff,"-");
3711 if(strcmp(str,cmdName) == 0)
3712 {
3713 str=strtok(NULL,",");
3714 if(strcmp(str,"TRUE") == 0)
3715 CmdReturnFlag =1;
3716
3717 break;
3718 }
3719 }
3720 fclose(wfaCliFd);
3721 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003722
3723
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003724 //printf("\n Command Return Flag : %d",CmdReturnFlag);
3725 st = 1;
3726 memset(&retstr[0],'\0',255);
3727 memset(&tmp[0],'\0',255);
Ankur Vachhanic485b712012-02-15 23:29:49 +00003728
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003729 sprintf(gCmdStr, "%s", CmdStr);
3730 printf("\nCLI Command -- %s\n", gCmdStr);
Ankur Vachhanic485b712012-02-15 23:29:49 +00003731
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003732 sh_pipe = popen(gCmdStr,"r");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003733
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003734 if(!sh_pipe)
3735 {
3736 printf ("Error in opening pipe");
3737 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003738
3739
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003740 //tmp_val=getdelim(&retstr,255,"\n",sh_pipe);
3741 if (fgets(&retstr[0], 255, sh_pipe) == NULL)
3742 {
3743 printf("Getting NULL string\n");
3744 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003745
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003746 if(pclose(sh_pipe) != 0)
3747 {
3748 printf("Error in closing shell cmd pipe");
3749 }
3750 sleep(2);
Ankur Vachhanic485b712012-02-15 23:29:49 +00003751
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003752 printf("CLI retun value- %s\n",retstr);
Ankur Vachhanic485b712012-02-15 23:29:49 +00003753
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003754 memcpy(tmp, strtok_r((char *)retstr, "-", (char **)&pcmdStr), 2);
3755 printf("\ncli status - %s",tmp);
3756 if(strlen(tmp) > 0)
3757 st = atoi(tmp);
3758
3759 infoResp.resFlag=CmdReturnFlag;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003760
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003761 switch(st)
3762 {
3763 case 0:
3764 infoResp.status = STATUS_COMPLETE;
3765 if (CmdReturnFlag)
3766 {
3767 str=strtok_r(NULL, "\n", (char **)&pcmdStr);
3768 strncpy(tmp,str, 255);
3769 printf("\nresult - %s",tmp);
3770 if(tmp != NULL)
3771 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003772 memset(&infoResp.result[0],'\0',WFA_CLI_CMD_RESP_LEN-1);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003773 strncpy(&infoResp.result[0], tmp,(strlen(tmp) < WFA_CLI_CMD_RESP_LEN ) ? strlen(tmp) : (WFA_CLI_CMD_RESP_LEN-1) );
3774 printf("Return CLI result to CA: %s****\n", &infoResp.result[0]);
3775 }
3776 else
3777 strcpy(&infoResp.result[0], "ENV_VAR_NOT_DEFINED");
3778 }
3779 break;
3780 case 1:
3781 infoResp.status = STATUS_ERROR;
3782 break;
3783 case 2:
3784 infoResp.status = STATUS_INVALID;
3785 break;
3786 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003787
3788 wfaEncodeTLV(WFA_STA_CLI_CMD_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3789 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3790
3791 printf("\nExit from CLI function\n");
3792 return TRUE;
3793
3794
3795}
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003796/*
3797 * wfaStaConnectGoStartWfd():
3798 */
3799
3800int wfaStaConnectGoStartWfd(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3801{
3802 dutCmdResponse_t infoResp;
3803// caStaConnectGoStartWfd_t *staConnecGoStartWfd= (caStaConnectGoStartWfd_t *)caCmdBuf; //uncomment and use it
3804
3805 printf("\n Entry wfaStaConnectGoStartWfd... ");
3806
3807 // connect the specified GO and then establish the wfd session
3808
3809 // Fetch WFD session and return
3810 strcpy(&infoResp.cmdru.wfdConnInfo.wfdSessionId[0], "1234567890");
3811
3812 infoResp.status = STATUS_COMPLETE;
3813 wfaEncodeTLV(WFA_STA_CONNECT_GO_START_WFD_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3814 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3815
3816 return WFA_SUCCESS;
3817}
3818
3819/*
3820 * wfaStaGenerateEvent():
3821 */
3822
3823int wfaStaGenerateEvent(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3824{
3825 dutCmdResponse_t infoResp;
3826 caStaGenEvent_t *staGenerateEvent= (caStaGenEvent_t *)caCmdBuf; //uncomment and use it
3827 caWfdStaGenEvent_t *wfdGenEvent;
3828
3829 printf("\n Entry wfaStaGenerateEvent... ");
3830
3831
3832 // Geneate the specified action and return with complete/error.
3833 if(staGenerateEvent->program == PROG_TYPE_WFD)
3834 {
3835 wfdGenEvent = &staGenerateEvent->wfdEvent;
3836 if(wfdGenEvent ->type == eUibcGen)
3837 {
3838 }
3839 else if(wfdGenEvent ->type == eUibcHid)
3840 {
3841 }
3842 else if(wfdGenEvent ->type == eFrameSkip)
3843 {
3844
3845 }
3846 else if(wfdGenEvent ->type == eI2cRead)
3847 {
3848 }
3849 else if(wfdGenEvent ->type == eI2cWrite)
3850 {
3851 }
3852 else if(wfdGenEvent ->type == eInputContent)
3853 {
3854 }
3855 else if(wfdGenEvent ->type == eIdrReq)
3856 {
3857 }
3858 }
3859
3860 infoResp.status = STATUS_COMPLETE;
3861 wfaEncodeTLV(WFA_STA_GENERATE_EVENT_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3862 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3863
3864 return WFA_SUCCESS;
3865}
3866
3867
3868
3869
3870/*
3871 * wfaStaReinvokeWfdSession():
3872 */
3873
3874int wfaStaReinvokeWfdSession(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3875{
3876 dutCmdResponse_t infoResp;
3877// caStaReinvokeWfdSession_t *staReinvokeSession= (caStaReinvokeWfdSession_t *)caCmdBuf; //uncomment and use it
3878
3879 printf("\n Entry wfaStaReinvokeWfdSession... ");
3880
3881 // Reinvoke the WFD session by accepting the p2p invitation or sending p2p invitation
3882
3883
3884 infoResp.status = STATUS_COMPLETE;
3885 wfaEncodeTLV(WFA_STA_REINVOKE_WFD_SESSION_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3886 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3887
3888 return WFA_SUCCESS;
3889}
3890
3891
3892int wfaStaGetParameter(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3893{
3894 dutCmdResponse_t infoResp;
3895 caStaGetParameter_t *staGetParam= (caStaGetParameter_t *)caCmdBuf; //uncomment and use it
3896
3897
3898 caStaGetParameterResp_t *paramList = &infoResp.cmdru.getParamValue;
3899
3900 printf("\n Entry wfaStaGetParameter... ");
3901
3902 // Check the program type
3903 if(staGetParam->program == PROG_TYPE_WFD)
3904 {
3905 if(staGetParam->getParamValue == eDiscoveredDevList )
3906 {
3907 // Get the discovered devices, make space seperated list and return, check list is not bigger than 128 bytes.
3908 paramList->getParamType = eDiscoveredDevList;
3909 strcpy((char *)&paramList->devList, "11:22:33:44:55:66 22:33:44:55:66:77 33:44:55:66:77:88");
3910 }
3911 }
3912
3913
3914 infoResp.status = STATUS_COMPLETE;
3915 wfaEncodeTLV(WFA_STA_GET_PARAMETER_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3916 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3917
3918 return WFA_SUCCESS;
3919}
3920
Ankur Vachhanic485b712012-02-15 23:29:49 +00003921