blob: 5f41297bab603253f62ec09c4701a823c4e8118e [file] [log] [blame]
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001/****************************************************************************
Dake Zhao97708202014-11-26 13:59:04 -08002(c) Copyright 2014 Wi-Fi Alliance. All Rights Reserved
3
Dake Zhao0a832172015-01-06 11:08:47 -08004Permission to use, copy, modify, and/or distribute this software for any purpose with or
5without fee is hereby granted, provided that the above copyright notice and this permission
Dake Zhao97708202014-11-26 13:59:04 -08006notice appear in all copies.
7
Dake Zhao0a832172015-01-06 11:08:47 -08008THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
12FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
13NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
Dake Zhao97708202014-11-26 13:59:04 -080014THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
16******************************************************************************/
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +000017
Dake Zhao0a832172015-01-06 11:08:47 -080018/*
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +000019 * File: wfa_cs.c -- configuration and setup
Dake Zhao0a832172015-01-06 11:08:47 -080020 * This file contains all implementation for the dut setup and control
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +000021 * functions, such as network interfaces, ip address and wireless specific
22 * setup with its supplicant.
23 *
24 * The current implementation is to show how these functions
Dake Zhao0a832172015-01-06 11:08:47 -080025 * should be defined in order to support the Agent Control/Test Manager
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +000026 * control commands. To simplify the current work and avoid any GPL licenses,
27 * the functions mostly invoke shell commands by calling linux system call,
Dake Zhao0a832172015-01-06 11:08:47 -080028 * system("<commands>").
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +000029 *
30 * It depends on the differnt device and platform, vendors can choice their
31 * own ways to interact its systems, supplicants and process these commands
32 * such as using the native APIs.
33 *
Dake Zhao0a832172015-01-06 11:08:47 -080034 *
35 */
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +000036#include <stdio.h>
37#include <unistd.h>
38#include <string.h>
39#include <stdlib.h>
40#include <sys/socket.h>
41#include <arpa/inet.h>
42#include <linux/types.h>
43#include <linux/socket.h>
44#include <poll.h>
45
46#include "wfa_portall.h"
47#include "wfa_debug.h"
48#include "wfa_ver.h"
49#include "wfa_main.h"
50#include "wfa_types.h"
51#include "wfa_ca.h"
52#include "wfa_tlv.h"
53#include "wfa_sock.h"
54#include "wfa_tg.h"
55#include "wfa_cmds.h"
56#include "wfa_rsp.h"
57#include "wfa_utils.h"
58#ifdef WFA_WMM_PS_EXT
59#include "wfa_wmmps.h"
60#endif
61
62#define CERTIFICATES_PATH "/etc/wpa_supplicant"
63
64/* Some device may only support UDP ECHO, activate this line */
65//#define WFA_PING_UDP_ECHO_ONLY 1
66
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -080067#define WFA_ENABLED 1
68
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +000069extern unsigned short wfa_defined_debug;
70int wfaExecuteCLI(char *CLI);
71
72/* Since the two definitions are used all over the CA function */
73char gCmdStr[WFA_CMD_STR_SZ];
74dutCmdResponse_t gGenericResp;
75int wfaTGSetPrio(int sockfd, int tgClass);
76void create_apts_msg(int msg, unsigned int txbuf[],int id);
77
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -080078int sret = 0;
79
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +000080extern char e2eResults[];
Dake Zhao862c94b2014-12-08 14:35:35 -080081
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +000082FILE *e2efp = NULL;
83int chk_ret_status()
84{
85 char *ret = getenv(WFA_RET_ENV);
86
87 if(*ret == '1')
Dake Zhao0a832172015-01-06 11:08:47 -080088 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +000089 else
Dake Zhao0a832172015-01-06 11:08:47 -080090 return WFA_FAILURE;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +000091}
92
93/*
94 * agtCmdProcGetVersion(): response "ca_get_version" command to controller
95 * input: cmd --- not used
96 * valLen -- not used
97 * output: parms -- a buffer to store the version info response.
98 */
99int agtCmdProcGetVersion(int len, BYTE *parms, int *respLen, BYTE *respBuf)
100{
101 dutCmdResponse_t *getverResp = &gGenericResp;
102
103 DPRINT_INFO(WFA_OUT, "entering agtCmdProcGetVersion ...\n");
104
105 getverResp->status = STATUS_COMPLETE;
106 wSTRNCPY(getverResp->cmdru.version, WFA_SYSTEM_VER, WFA_VERNAM_LEN);
107
108 wfaEncodeTLV(WFA_GET_VERSION_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)getverResp, respBuf);
109
110 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
111
112 return WFA_SUCCESS;
113}
114
115/*
116 * wfaStaAssociate():
Dake Zhao0a832172015-01-06 11:08:47 -0800117 * The function is to force the station wireless I/F to re/associate
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000118 * with the AP.
119 */
120int wfaStaAssociate(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
121{
Dake Zhao0a832172015-01-06 11:08:47 -0800122 dutCommand_t *assoc = (dutCommand_t *)caCmdBuf;
123 char *ifname = assoc->intf;
124 dutCmdResponse_t *staAssocResp = &gGenericResp;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000125
Dake Zhao0a832172015-01-06 11:08:47 -0800126 DPRINT_INFO(WFA_OUT, "entering wfaStaAssociate ...\n");
127 /*
128 * if bssid appears, station should associate with the specific
129 * BSSID AP at its initial association.
130 * If it is different to the current associating AP, it will be forced to
131 * roam the new AP
132 */
133 if(assoc->cmdsu.assoc.bssid[0] != '\0')
134 {
135 /* if (the first association) */
136 /* just do initial association to the BSSID */
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000137
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000138
Dake Zhao0a832172015-01-06 11:08:47 -0800139 /* else (station already associate to an AP) */
140 /* Do forced roaming */
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000141
Dake Zhao0a832172015-01-06 11:08:47 -0800142 }
143 else
144 {
145 /* use 'ifconfig' command to bring down the interface (linux specific) */
Ray Wangd11ca032015-05-29 18:25:46 -0700146 //sprintf(gCmdStr, "ifconfig %s down", ifname);
147 //sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000148
Dake Zhao0a832172015-01-06 11:08:47 -0800149 /* use 'ifconfig' command to bring up the interface (linux specific) */
Ray Wangd11ca032015-05-29 18:25:46 -0700150 //sprintf(gCmdStr, "ifconfig %s up", ifname);
151 //sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000152
Dake Zhao0a832172015-01-06 11:08:47 -0800153 /*
154 * use 'wpa_cli' command to force a 802.11 re/associate
155 * (wpa_supplicant specific)
156 */
157 sprintf(gCmdStr, "wpa_cli -i%s reassociate", ifname);
158 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000159 }
160
161 /*
162 * Then report back to control PC for completion.
163 * This does not have failed/error status. The result only tells
164 * a completion.
165 */
166 staAssocResp->status = STATUS_COMPLETE;
Dake Zhao0a832172015-01-06 11:08:47 -0800167 wfaEncodeTLV(WFA_STA_ASSOCIATE_RESP_TLV, 4, (BYTE *)staAssocResp, respBuf);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000168 *respLen = WFA_TLV_HDR_LEN + 4;
169
Dake Zhao0a832172015-01-06 11:08:47 -0800170 return WFA_SUCCESS;
171}
172
173/*
174 * wfaStaReAssociate():
175 * The function is to force the station wireless I/F to re/associate
176 * with the AP.
177 */
178int wfaStaReAssociate(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
179{
180 dutCommand_t *assoc = (dutCommand_t *)caCmdBuf;
181 char *ifname = assoc->intf;
182 dutCmdResponse_t *staAssocResp = &gGenericResp;
183
184 DPRINT_INFO(WFA_OUT, "entering wfaStaAssociate ...\n");
185 /*
186 * if bssid appears, station should associate with the specific
187 * BSSID AP at its initial association.
188 * If it is different to the current associating AP, it will be forced to
189 * roam the new AP
190 */
191 if(assoc->cmdsu.assoc.bssid[0] != '\0')
192 {
193 /* if (the first association) */
194 /* just do initial association to the BSSID */
195
196
197 /* else (station already associate to an AP) */
198 /* Do forced roaming */
199
200 }
201 else
202 {
203 /* use 'ifconfig' command to bring down the interface (linux specific) */
204 sprintf(gCmdStr, "ifconfig %s down", ifname);
205 sret = system(gCmdStr);
206
207 /* use 'ifconfig' command to bring up the interface (linux specific) */
208 sprintf(gCmdStr, "ifconfig %s up", ifname);
209
210 /*
211 * use 'wpa_cli' command to force a 802.11 re/associate
212 * (wpa_supplicant specific)
213 */
214 sprintf(gCmdStr, "wpa_cli -i%s reassociate", ifname);
215 sret = system(gCmdStr);
216 }
217
218 /*
219 * Then report back to control PC for completion.
220 * This does not have failed/error status. The result only tells
221 * a completion.
222 */
223 staAssocResp->status = STATUS_COMPLETE;
224 wfaEncodeTLV(WFA_STA_ASSOCIATE_RESP_TLV, 4, (BYTE *)staAssocResp, respBuf);
225 *respLen = WFA_TLV_HDR_LEN + 4;
226
227 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000228}
229
230/*
231 * wfaStaIsConnected():
Dake Zhao0a832172015-01-06 11:08:47 -0800232 * The function is to check whether the station's wireless I/F has
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000233 * already connected to an AP.
234 */
235int wfaStaIsConnected(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
236{
Dake Zhao0a832172015-01-06 11:08:47 -0800237 dutCommand_t *connStat = (dutCommand_t *)caCmdBuf;
238 dutCmdResponse_t *staConnectResp = &gGenericResp;
239 char *ifname = connStat->intf;
240 FILE *tmpfile = NULL;
241 char result[32];
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000242
243
Dake Zhao0a832172015-01-06 11:08:47 -0800244 DPRINT_INFO(WFA_OUT, "Entering isConnected ...\n");
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000245
246#ifdef WFA_NEW_CLI_FORMAT
Dake Zhao0a832172015-01-06 11:08:47 -0800247 sprintf(gCmdStr, "wfa_chkconnect %s\n", ifname);
248 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000249
Dake Zhao0a832172015-01-06 11:08:47 -0800250 if(chk_ret_status() == WFA_SUCCESS)
251 staConnectResp->cmdru.connected = 1;
252 else
253 staConnectResp->cmdru.connected = 0;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000254#else
Dake Zhao0a832172015-01-06 11:08:47 -0800255 /*
256 * use 'wpa_cli' command to check the interface status
257 * none, scanning or complete (wpa_supplicant specific)
258 */
259 sprintf(gCmdStr, "/sbin/wpa_cli -i%s status | grep ^wpa_state= | cut -f2- -d= > /tmp/.isConnected", ifname);
260 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000261
Dake Zhao0a832172015-01-06 11:08:47 -0800262 /*
263 * the status is saved in a file. Open the file and check it.
264 */
265 tmpfile = fopen("/tmp/.isConnected", "r+");
266 if(tmpfile == NULL)
267 {
268 staConnectResp->status = STATUS_ERROR;
269 wfaEncodeTLV(WFA_STA_IS_CONNECTED_RESP_TLV, 4, (BYTE *)staConnectResp, respBuf);
270 *respLen = WFA_TLV_HDR_LEN + 4;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000271
Dake Zhao0a832172015-01-06 11:08:47 -0800272 DPRINT_ERR(WFA_ERR, "file open failed\n");
273 return WFA_FAILURE;
274 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000275
Dake Zhao0a832172015-01-06 11:08:47 -0800276 sret = fscanf(tmpfile, "%s", (char *)result);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000277
Dake Zhao0a832172015-01-06 11:08:47 -0800278 if(strncmp(result, "COMPLETED", 9) == 0)
279 staConnectResp->cmdru.connected = 1;
280 else
281 staConnectResp->cmdru.connected = 0;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000282#endif
283
Dake Zhao0a832172015-01-06 11:08:47 -0800284 /*
285 * Report back the status: Complete or Failed.
286 */
287 staConnectResp->status = STATUS_COMPLETE;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000288
Dake Zhao0a832172015-01-06 11:08:47 -0800289 wfaEncodeTLV(WFA_STA_IS_CONNECTED_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)staConnectResp, respBuf);
290 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
291
292 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000293}
294
295/*
296 * wfaStaGetIpConfig():
297 * This function is to retriev the ip info including
298 * 1. dhcp enable
299 * 2. ip address
Dake Zhao0a832172015-01-06 11:08:47 -0800300 * 3. mask
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000301 * 4. primary-dns
302 * 5. secondary-dns
303 *
304 * The current implementation is to use a script to find these information
Dake Zhao0a832172015-01-06 11:08:47 -0800305 * and store them in a file.
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000306 */
307int wfaStaGetIpConfig(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
308{
309 int slen, ret, i = 0;
310 dutCommand_t *getIpConf = (dutCommand_t *)caCmdBuf;
Dake Zhao0a832172015-01-06 11:08:47 -0800311 dutCmdResponse_t *ipconfigResp = &gGenericResp;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000312 char *ifname = getIpConf->intf;
313 caStaGetIpConfigResp_t *ifinfo = &ipconfigResp->cmdru.getIfconfig;
314
315 FILE *tmpfd;
316 char string[256];
317 char *str;
318
319 /*
320 * check a script file (the current implementation specific)
321 */
322 ret = access("/usr/local/sbin/getipconfig.sh", F_OK);
323 if(ret == -1)
324 {
Dake Zhao0a832172015-01-06 11:08:47 -0800325 ipconfigResp->status = STATUS_ERROR;
326 wfaEncodeTLV(WFA_STA_GET_IP_CONFIG_RESP_TLV, 4, (BYTE *)ipconfigResp, respBuf);
327 *respLen = WFA_TLV_HDR_LEN + 4;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000328
Dake Zhao0a832172015-01-06 11:08:47 -0800329 DPRINT_ERR(WFA_ERR, "file not exist\n");
330 return WFA_FAILURE;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000331
332 }
333
334 strcpy(ifinfo->dns[0], "0");
335 strcpy(ifinfo->dns[1], "0");
Dake Zhao0a832172015-01-06 11:08:47 -0800336
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000337 /*
Dake Zhao0a832172015-01-06 11:08:47 -0800338 * Run the script file "getipconfig.sh" to check the ip status
339 * (current implementation specific).
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000340 * note: "getipconfig.sh" is only defined for the current implementation
341 */
Dake Zhao0a832172015-01-06 11:08:47 -0800342 sprintf(gCmdStr, "getipconfig.sh /tmp/ipconfig.txt %s\n", ifname);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000343
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800344 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000345
346 /* open the output result and scan/retrieve the info */
347 tmpfd = fopen("/tmp/ipconfig.txt", "r+");
348
349 if(tmpfd == NULL)
350 {
Dake Zhao0a832172015-01-06 11:08:47 -0800351 ipconfigResp->status = STATUS_ERROR;
352 wfaEncodeTLV(WFA_STA_GET_IP_CONFIG_RESP_TLV, 4, (BYTE *)ipconfigResp, respBuf);
353 *respLen = WFA_TLV_HDR_LEN + 4;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000354
Dake Zhao0a832172015-01-06 11:08:47 -0800355 DPRINT_ERR(WFA_ERR, "file open failed\n");
356 return WFA_FAILURE;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000357 }
358
359 for(;;)
360 {
361 if(fgets(string, 256, tmpfd) == NULL)
Dake Zhao0a832172015-01-06 11:08:47 -0800362 break;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000363
364 /* check dhcp enabled */
365 if(strncmp(string, "dhcpcli", 7) ==0)
366 {
367 str = strtok(string, "=");
368 str = strtok(NULL, "=");
369 if(str != NULL)
Dake Zhao0a832172015-01-06 11:08:47 -0800370 ifinfo->isDhcp = 1;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000371 else
Dake Zhao0a832172015-01-06 11:08:47 -0800372 ifinfo->isDhcp = 0;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000373 }
374
375 /* find out the ip address */
376 if(strncmp(string, "ipaddr", 6) == 0)
377 {
378 str = strtok(string, "=");
379 str = strtok(NULL, " ");
380 if(str != NULL)
381 {
Dake Zhao0a832172015-01-06 11:08:47 -0800382 wSTRNCPY(ifinfo->ipaddr, str, 15);
Dake Zhao97708202014-11-26 13:59:04 -0800383
Dake Zhao0a832172015-01-06 11:08:47 -0800384 ifinfo->ipaddr[15]='\0';
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000385 }
386 else
Dake Zhao0a832172015-01-06 11:08:47 -0800387 wSTRNCPY(ifinfo->ipaddr, "none", 15);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000388 }
389
390 /* check the mask */
391 if(strncmp(string, "mask", 4) == 0)
392 {
393 char ttstr[16];
394 char *ttp = ttstr;
395
396 str = strtok_r(string, "=", &ttp);
397 if(*ttp != '\0')
398 {
Dake Zhao0a832172015-01-06 11:08:47 -0800399 strcpy(ifinfo->mask, ttp);
400 slen = strlen(ifinfo->mask);
401 ifinfo->mask[slen-1] = '\0';
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000402 }
403 else
Dake Zhao0a832172015-01-06 11:08:47 -0800404 strcpy(ifinfo->mask, "none");
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000405 }
406
407 /* find out the dns server ip address */
408 if(strncmp(string, "nameserv", 8) == 0)
409 {
410 char ttstr[16];
411 char *ttp = ttstr;
Dake Zhao0a832172015-01-06 11:08:47 -0800412
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000413 str = strtok_r(string, " ", &ttp);
414 if(str != NULL && i < 2)
415 {
Dake Zhao0a832172015-01-06 11:08:47 -0800416 strcpy(ifinfo->dns[i], ttp);
417 slen = strlen(ifinfo->dns[i]);
418 ifinfo->dns[i][slen-1] = '\0';
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000419 }
420 else
Dake Zhao0a832172015-01-06 11:08:47 -0800421 strcpy(ifinfo->dns[i], "none");
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000422
423 i++;
424 }
Dake Zhao0a832172015-01-06 11:08:47 -0800425 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000426
Dake Zhao0a832172015-01-06 11:08:47 -0800427 /*
428 * Report back the results
429 */
430 ipconfigResp->status = STATUS_COMPLETE;
431 wfaEncodeTLV(WFA_STA_GET_IP_CONFIG_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)ipconfigResp, respBuf);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000432
Dake Zhao0a832172015-01-06 11:08:47 -0800433 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000434
435#if 0
Dake Zhao0a832172015-01-06 11:08:47 -0800436 DPRINT_INFO(WFA_OUT, "%i %i %s %s %s %s %i\n", ipconfigResp->status,
437 ifinfo->isDhcp, ifinfo->ipaddr, ifinfo->mask,
438 ifinfo->dns[0], ifinfo->dns[1], *respLen);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000439#endif
440
Dake Zhao0a832172015-01-06 11:08:47 -0800441 fclose(tmpfd);
442 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000443}
444
445/*
446 * wfaStaSetIpConfig():
447 * The function is to set the ip configuration to a wireless I/F.
448 * 1. IP address
449 * 2. Mac address
450 * 3. default gateway
Dake Zhao0a832172015-01-06 11:08:47 -0800451 * 4. dns nameserver (pri and sec).
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000452 */
453int wfaStaSetIpConfig(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
454{
Dake Zhao0a832172015-01-06 11:08:47 -0800455 dutCommand_t *setIpConf = (dutCommand_t *)caCmdBuf;
456 caStaSetIpConfig_t *ipconfig = &setIpConf->cmdsu.ipconfig;
457 dutCmdResponse_t *staSetIpResp = &gGenericResp;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000458
Dake Zhao0a832172015-01-06 11:08:47 -0800459 DPRINT_INFO(WFA_OUT, "entering wfaStaSetIpConfig ...\n");
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000460
Dake Zhao0a832172015-01-06 11:08:47 -0800461 /*
462 * Use command 'ifconfig' to configure the interface ip address, mask.
463 * (Linux specific).
464 */
465 sprintf(gCmdStr, "/sbin/ifconfig %s %s netmask %s > /dev/null 2>&1 ", ipconfig->intf, ipconfig->ipaddr, ipconfig->mask);
466 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000467
Dake Zhao0a832172015-01-06 11:08:47 -0800468 /* use command 'route add' to set set gatewway (linux specific) */
469 if(ipconfig->defGateway[0] != '\0')
470 {
471 sprintf(gCmdStr, "/sbin/route add default gw %s > /dev/null 2>&1", ipconfig->defGateway);
472 sret = system(gCmdStr);
473 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000474
Dake Zhao0a832172015-01-06 11:08:47 -0800475 /* set dns (linux specific) */
476 sprintf(gCmdStr, "cp /etc/resolv.conf /tmp/resolv.conf.bk");
477 sret = system(gCmdStr);
478 sprintf(gCmdStr, "echo nameserv %s > /etc/resolv.conf", ipconfig->pri_dns);
479 sret = system(gCmdStr);
480 sprintf(gCmdStr, "echo nameserv %s >> /etc/resolv.conf", ipconfig->sec_dns);
481 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000482
Dake Zhao0a832172015-01-06 11:08:47 -0800483 /*
484 * report status
485 */
486 staSetIpResp->status = STATUS_COMPLETE;
487 wfaEncodeTLV(WFA_STA_SET_IP_CONFIG_RESP_TLV, 4, (BYTE *)staSetIpResp, respBuf);
488 *respLen = WFA_TLV_HDR_LEN + 4;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000489
Dake Zhao0a832172015-01-06 11:08:47 -0800490 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000491}
492
493/*
494 * wfaStaVerifyIpConnection():
495 * The function is to verify if the station has IP connection with an AP by
496 * send ICMP/pings to the AP.
Dake Zhao0a832172015-01-06 11:08:47 -0800497 */
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000498int wfaStaVerifyIpConnection(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
499{
Dake Zhao0a832172015-01-06 11:08:47 -0800500 dutCommand_t *verip = (dutCommand_t *)caCmdBuf;
501 dutCmdResponse_t *verifyIpResp = &gGenericResp;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000502
503#ifndef WFA_PING_UDP_ECHO_ONLY
Dake Zhao0a832172015-01-06 11:08:47 -0800504 char strout[64], *pcnt;
505 FILE *tmpfile;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000506
Dake Zhao0a832172015-01-06 11:08:47 -0800507 DPRINT_INFO(WFA_OUT, "Entering wfaStaVerifyIpConnection ...\n");
508
509 /* set timeout value in case not set */
510 if(verip->cmdsu.verifyIp.timeout <= 0)
511 {
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000512 verip->cmdsu.verifyIp.timeout = 10;
Dake Zhao0a832172015-01-06 11:08:47 -0800513 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000514
Dake Zhao0a832172015-01-06 11:08:47 -0800515 /* execute the ping command and pipe the result to a tmp file */
516 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);
517 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000518
Dake Zhao0a832172015-01-06 11:08:47 -0800519 /* scan/check the output */
520 tmpfile = fopen("/tmp/pingout.txt", "r+");
521 if(tmpfile == NULL)
522 {
523 verifyIpResp->status = STATUS_ERROR;
524 wfaEncodeTLV(WFA_STA_VERIFY_IP_CONNECTION_RESP_TLV, 4, (BYTE *)verifyIpResp, respBuf);
525 *respLen = WFA_TLV_HDR_LEN + 4;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000526
Dake Zhao0a832172015-01-06 11:08:47 -0800527 DPRINT_ERR(WFA_ERR, "file open failed\n");
528 return WFA_FAILURE;
529 }
530
531 verifyIpResp->status = STATUS_COMPLETE;
532 if(fscanf(tmpfile, "%s", strout) == EOF)
533 verifyIpResp->cmdru.connected = 0;
534 else
535 {
536 pcnt = strtok(strout, "%");
537
538 /* if the loss rate is 100%, not able to connect */
539 if(atoi(pcnt) == 100)
540 verifyIpResp->cmdru.connected = 0;
541 else
542 verifyIpResp->cmdru.connected = 1;
543 }
544
545 fclose(tmpfile);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000546#else
Dake Zhao0a832172015-01-06 11:08:47 -0800547 int btSockfd;
548 struct pollfd fds[2];
549 int timeout = 2000;
550 char anyBuf[64];
551 struct sockaddr_in toAddr;
552 int done = 1, cnt = 0, ret, nbytes;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000553
Dake Zhao0a832172015-01-06 11:08:47 -0800554 verifyIpResp->status = STATUS_COMPLETE;
555 verifyIpResp->cmdru.connected = 0;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000556
Dake Zhao0a832172015-01-06 11:08:47 -0800557 btSockfd = wfaCreateUDPSock("127.0.0.1", WFA_UDP_ECHO_PORT);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000558
Dake Zhao0a832172015-01-06 11:08:47 -0800559 if(btSockfd == -1)
560 {
561 verifyIpResp->status = STATUS_ERROR;
562 wfaEncodeTLV(WFA_STA_VERIFY_IP_CONNECTION_RESP_TLV, 4, (BYTE *)verifyIpResp, respBuf);
563 *respLen = WFA_TLV_HDR_LEN + 4;
564 return WFA_FAILURE;;
565 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000566
Dake Zhao0a832172015-01-06 11:08:47 -0800567 toAddr.sin_family = AF_INET;
568 toAddr.sin_addr.s_addr = inet_addr(verip->cmdsu.verifyIp.dipaddr);
569 toAddr.sin_port = htons(WFA_UDP_ECHO_PORT);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000570
Dake Zhao0a832172015-01-06 11:08:47 -0800571 while(done)
572 {
573 wfaTrafficSendTo(btSockfd, (char *)anyBuf, 64, (struct sockaddr *)&toAddr);
574 cnt++;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000575
Dake Zhao0a832172015-01-06 11:08:47 -0800576 fds[0].fd = btSockfd;
577 fds[0].events = POLLIN | POLLOUT;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000578
Dake Zhao0a832172015-01-06 11:08:47 -0800579 ret = poll(fds, 1, timeout);
580 switch(ret)
581 {
582 case 0:
583 /* it is time out, count a packet lost*/
584 break;
585 case -1:
586 /* it is an error */
587 default:
588 {
589 switch(fds[0].revents)
590 {
591 case POLLIN:
592 case POLLPRI:
593 case POLLOUT:
594 nbytes = wfaTrafficRecv(btSockfd, (char *)anyBuf, (struct sockaddr *)&toAddr);
595 if(nbytes != 0)
596 verifyIpResp->cmdru.connected = 1;
597 done = 0;
598 break;
599 default:
600 /* errors but not care */
601 ;
602 }
603 }
604 }
605 if(cnt == 3)
606 {
607 done = 0;
608 }
609 }
610
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000611#endif
612
Dake Zhao0a832172015-01-06 11:08:47 -0800613 wfaEncodeTLV(WFA_STA_VERIFY_IP_CONNECTION_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)verifyIpResp, respBuf);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000614
Dake Zhao0a832172015-01-06 11:08:47 -0800615 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
616
617 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000618}
619
620/*
621 * wfaStaGetMacAddress()
622 * This function is to retrieve the MAC address of a wireless I/F.
623 */
624int wfaStaGetMacAddress(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
625{
626 dutCommand_t *getMac = (dutCommand_t *)caCmdBuf;
627 dutCmdResponse_t *getmacResp = &gGenericResp;
628 char *str;
629 char *ifname = getMac->intf;
630
631 FILE *tmpfd;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800632 char string[257];
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000633
634 DPRINT_INFO(WFA_OUT, "Entering wfaStaGetMacAddress ...\n");
635 /*
636 * run the script "getipconfig.sh" to find out the mac
637 */
Dake Zhao0a832172015-01-06 11:08:47 -0800638 sprintf(gCmdStr, "ifconfig %s > /tmp/ipconfig.txt ", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800639 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000640
641 tmpfd = fopen("/tmp/ipconfig.txt", "r+");
642 if(tmpfd == NULL)
643 {
Dake Zhao0a832172015-01-06 11:08:47 -0800644 getmacResp->status = STATUS_ERROR;
645 wfaEncodeTLV(WFA_STA_GET_MAC_ADDRESS_RESP_TLV, 4, (BYTE *)getmacResp, respBuf);
646 *respLen = WFA_TLV_HDR_LEN + 4;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000647
Dake Zhao0a832172015-01-06 11:08:47 -0800648 DPRINT_ERR(WFA_ERR, "file open failed\n");
649 return WFA_FAILURE;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000650 }
651
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800652 if(fgets((char *)&string[0], 256, tmpfd) == NULL)
653 {
Dake Zhao0a832172015-01-06 11:08:47 -0800654 getmacResp->status = STATUS_ERROR;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000655 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800656
657 str = strtok(string, " ");
658 while(str && ((strcmp(str,"HWaddr")) != 0))
659 {
Dake Zhao0a832172015-01-06 11:08:47 -0800660 str = strtok(NULL, " ");
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800661 }
Dake Zhao0a832172015-01-06 11:08:47 -0800662
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800663 /* get mac */
664 if(str)
665 {
666 str = strtok(NULL, " ");
667 strcpy(getmacResp->cmdru.mac, str);
668 getmacResp->status = STATUS_COMPLETE;
669 }
Dake Zhao0a832172015-01-06 11:08:47 -0800670
671 wfaEncodeTLV(WFA_STA_GET_MAC_ADDRESS_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)getmacResp, respBuf);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000672
673 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
674
675 fclose(tmpfd);
676 return WFA_SUCCESS;
677}
678
679/*
680 * wfaStaGetStats():
Dake Zhao0a832172015-01-06 11:08:47 -0800681 * The function is to retrieve the statistics of the I/F's layer 2 txFrames,
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000682 * rxFrames, txMulticast, rxMulticast, fcsErrors/crc, and txRetries.
Dake Zhao0a832172015-01-06 11:08:47 -0800683 * Currently there is not definition how to use these info.
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000684 */
685int wfaStaGetStats(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
686{
Dake Zhao0a832172015-01-06 11:08:47 -0800687 dutCmdResponse_t *statsResp = &gGenericResp;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000688
Dake Zhao0a832172015-01-06 11:08:47 -0800689 /* this is never used, you can skip this call */
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000690
Dake Zhao0a832172015-01-06 11:08:47 -0800691 statsResp->status = STATUS_ERROR;
692 wfaEncodeTLV(WFA_STA_GET_STATS_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)statsResp, respBuf);
693 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000694
695
Dake Zhao0a832172015-01-06 11:08:47 -0800696 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000697}
698
699/*
700 * wfaSetEncryption():
701 * The function is to set the wireless interface with WEP or none.
702 *
Dake Zhao0a832172015-01-06 11:08:47 -0800703 * Since WEP is optional test, current function is only used for
704 * resetting the Security to NONE/Plaintext (OPEN). To test WEP,
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000705 * this function should be replaced by the next one (wfaSetEncryption1())
706 *
Dake Zhao0a832172015-01-06 11:08:47 -0800707 * Input parameters:
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000708 * 1. I/F
709 * 2. ssid
710 * 3. encpType - wep or none
711 * Optional:
712 * 4. key1
713 * 5. key2
714 * 6. key3
715 * 7. key4
716 * 8. activeKey Index
717 */
718
719int wfaSetEncryption1(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
720{
Dake Zhao0a832172015-01-06 11:08:47 -0800721 caStaSetEncryption_t *setEncryp = (caStaSetEncryption_t *)caCmdBuf;
722 dutCmdResponse_t *setEncrypResp = &gGenericResp;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000723
Dake Zhao0a832172015-01-06 11:08:47 -0800724 /*
725 * disable the network first
726 */
727 sprintf(gCmdStr, "wpa_cli -i %s disable_network 0", setEncryp->intf);
728 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000729
Dake Zhao0a832172015-01-06 11:08:47 -0800730 /*
731 * set SSID
732 */
733 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 ssid '\"%s\"'", setEncryp->intf, setEncryp->ssid);
734 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000735
Dake Zhao0a832172015-01-06 11:08:47 -0800736 /*
737 * Tell the supplicant for infrastructure mode (1)
738 */
739 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 mode 0", setEncryp->intf);
740 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000741
Dake Zhao0a832172015-01-06 11:08:47 -0800742 /*
743 * set Key management to NONE (NO WPA) for plaintext or WEP
744 */
745 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt NONE", setEncryp->intf);
746 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000747
Dake Zhao0a832172015-01-06 11:08:47 -0800748 sprintf(gCmdStr, "wpa_cli -i %s enable_network 0", setEncryp->intf);
749 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000750
Dake Zhao0a832172015-01-06 11:08:47 -0800751 setEncrypResp->status = STATUS_COMPLETE;
752 wfaEncodeTLV(WFA_STA_SET_ENCRYPTION_RESP_TLV, 4, (BYTE *)setEncrypResp, respBuf);
753 *respLen = WFA_TLV_HDR_LEN + 4;
754
755 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000756}
757
758/*
759 * Since WEP is optional, this function could be used to replace
Dake Zhao0a832172015-01-06 11:08:47 -0800760 * wfaSetEncryption() if necessary.
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000761 */
762int wfaSetEncryption(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
763{
Dake Zhao0a832172015-01-06 11:08:47 -0800764 caStaSetEncryption_t *setEncryp = (caStaSetEncryption_t *)caCmdBuf;
765 dutCmdResponse_t *setEncrypResp = &gGenericResp;
766 int i;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000767
Dake Zhao0a832172015-01-06 11:08:47 -0800768 /*
769 * disable the network first
770 */
771 sprintf(gCmdStr, "wpa_cli -i %s disable_network 0", setEncryp->intf);
772 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000773
Dake Zhao0a832172015-01-06 11:08:47 -0800774 /*
775 * set SSID
776 */
777 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 ssid '\"%s\"'", setEncryp->intf, setEncryp->ssid);
778 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000779
Dake Zhao0a832172015-01-06 11:08:47 -0800780 /*
781 * Tell the supplicant for infrastructure mode (1)
782 */
783 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 mode 0", setEncryp->intf);
784 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000785
Dake Zhao0a832172015-01-06 11:08:47 -0800786 /*
787 * set Key management to NONE (NO WPA) for plaintext or WEP
788 */
789 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt NONE", setEncryp->intf);
790 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000791
Dake Zhao0a832172015-01-06 11:08:47 -0800792 /* set keys */
793 if(setEncryp->encpType == 1)
794 {
795 for(i=0; i<4; i++)
796 {
797 if(setEncryp->keys[i][0] != '\0')
798 {
799 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 wep_key%i %s",
800 setEncryp->intf, i, setEncryp->keys[i]);
801 sret = system(gCmdStr);
802 }
803 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000804
Dake Zhao0a832172015-01-06 11:08:47 -0800805 /* set active key */
806 i = setEncryp->activeKeyIdx;
807 if(setEncryp->keys[i][0] != '\0')
808 {
809 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 wep_tx_keyidx %i",
810 setEncryp->intf, setEncryp->activeKeyIdx);
811 sret = system(gCmdStr);
812 }
813 }
814 else /* clearly remove the keys -- reported by p.schwann */
815 {
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000816
Dake Zhao0a832172015-01-06 11:08:47 -0800817 for(i = 0; i < 4; i++)
818 {
819 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 wep_key%i \"\"", setEncryp->intf, i);
820 sret = system(gCmdStr);
821 }
822 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000823
Dake Zhao0a832172015-01-06 11:08:47 -0800824 sprintf(gCmdStr, "wpa_cli -i %s enable_network 0", setEncryp->intf);
825 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000826
Dake Zhao0a832172015-01-06 11:08:47 -0800827 setEncrypResp->status = STATUS_COMPLETE;
828 wfaEncodeTLV(WFA_STA_SET_ENCRYPTION_RESP_TLV, 4, (BYTE *)setEncrypResp, respBuf);
829 *respLen = WFA_TLV_HDR_LEN + 4;
830
831 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000832}
833
834int wfaStaSetSecurity(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
835{
836 int ret = WFA_SUCCESS;
837
838 return ret;
839}
840
841/*
842 * wfaStaSetEapTLS():
843 * This is to set
844 * 1. ssid
845 * 2. encrypType - tkip or aes-ccmp
846 * 3. keyManagementType - wpa or wpa2
847 * 4. trustedRootCA
848 * 5. clientCertificate
849 */
850int wfaStaSetEapTLS(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
851{
Dake Zhao0a832172015-01-06 11:08:47 -0800852 caStaSetEapTLS_t *setTLS = (caStaSetEapTLS_t *)caCmdBuf;
853 char *ifname = setTLS->intf;
854 dutCmdResponse_t *setEapTlsResp = &gGenericResp;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000855
Dake Zhao0a832172015-01-06 11:08:47 -0800856 DPRINT_INFO(WFA_OUT, "Entering wfaStaSetEapTLS ...\n");
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000857
Dake Zhao0a832172015-01-06 11:08:47 -0800858 /*
859 * need to store the trustedROOTCA and clientCertificate into a file first.
860 */
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000861#ifdef WFA_NEW_CLI_FORMAT
Dake Zhao0a832172015-01-06 11:08:47 -0800862 sprintf(gCmdStr, "wfa_set_eaptls -i %s %s %s %s", ifname, setTLS->ssid, setTLS->trustedRootCA, setTLS->clientCertificate);
863 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000864#else
865
Dake Zhao0a832172015-01-06 11:08:47 -0800866 sprintf(gCmdStr, "wpa_cli -i %s disable_network 0", ifname);
867 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000868
Dake Zhao0a832172015-01-06 11:08:47 -0800869 /* ssid */
870 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 ssid '\"%s\"'", ifname, setTLS->ssid);
871 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000872
Dake Zhao0a832172015-01-06 11:08:47 -0800873 /* key management */
874 if(strcasecmp(setTLS->keyMgmtType, "wpa2-sha256") == 0)
875 {
876 }
877 else if(strcasecmp(setTLS->keyMgmtType, "wpa2-eap") == 0)
878 {
879 }
880 else if(strcasecmp(setTLS->keyMgmtType, "wpa2-ft") == 0)
881 {
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000882
Dake Zhao0a832172015-01-06 11:08:47 -0800883 }
884 else if(strcasecmp(setTLS->keyMgmtType, "wpa") == 0)
885 {
886 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt WPA-EAP", ifname);
887 }
888 else if(strcasecmp(setTLS->keyMgmtType, "wpa2") == 0)
889 {
890 // to take all and device to pick any one supported.
891 }
892 else
893 {
894 // ??
895 }
896 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000897
Dake Zhao0a832172015-01-06 11:08:47 -0800898 /* protocol WPA */
899 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 proto WPA", ifname);
900 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000901
Dake Zhao0a832172015-01-06 11:08:47 -0800902 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 eap TLS", ifname);
903 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000904
Dake Zhao0a832172015-01-06 11:08:47 -0800905 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 ca_cert '\"%s\"'", ifname, setTLS->trustedRootCA);
906 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000907
Dake Zhao0a832172015-01-06 11:08:47 -0800908 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 identity '\"wifi-user@wifilabs.local\"'", ifname);
909 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000910
Dake Zhao0a832172015-01-06 11:08:47 -0800911 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 private_key '\"%s/%s\"'", ifname, CERTIFICATES_PATH, setTLS->clientCertificate);
912 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000913
Dake Zhao0a832172015-01-06 11:08:47 -0800914 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 private_key_passwd '\"wifi\"'", ifname);
915 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000916
Dake Zhao0a832172015-01-06 11:08:47 -0800917 sprintf(gCmdStr, "wpa_cli -i %s enable_network 0", ifname);
918 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000919#endif
920
Dake Zhao0a832172015-01-06 11:08:47 -0800921 setEapTlsResp->status = STATUS_COMPLETE;
922 wfaEncodeTLV(WFA_STA_SET_EAPTLS_RESP_TLV, 4, (BYTE *)setEapTlsResp, respBuf);
923 *respLen = WFA_TLV_HDR_LEN + 4;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000924
Dake Zhao0a832172015-01-06 11:08:47 -0800925 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000926}
927
928/*
Dake Zhao0a832172015-01-06 11:08:47 -0800929 * The function is to set
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000930 * 1. ssid
931 * 2. passPhrase
932 * 3. keyMangementType - wpa/wpa2
933 * 4. encrypType - tkip or aes-ccmp
934 */
935int wfaStaSetPSK(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
Dake Zhao0a832172015-01-06 11:08:47 -0800936{
937 /*Incompleted function*/
938 dutCmdResponse_t *setPskResp = &gGenericResp;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000939
Dake Zhaob7ed41a2014-12-04 11:24:58 -0800940#ifndef WFA_PC_CONSOLE
Dake Zhao0a832172015-01-06 11:08:47 -0800941 caStaSetPSK_t *setPSK = (caStaSetPSK_t *)caCmdBuf;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000942#ifdef WFA_NEW_CLI_FORMAT
Dake Zhao0a832172015-01-06 11:08:47 -0800943 sprintf(gCmdStr, "wfa_set_psk %s %s %s", setPSK->intf, setPSK->ssid, setPSK->passphrase);
944 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000945#else
Dake Zhao0a832172015-01-06 11:08:47 -0800946 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 ssid '\"%s\"'", setPSK->intf, setPSK->ssid);
947 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000948
Dake Zhao0a832172015-01-06 11:08:47 -0800949 if(strcasecmp(setPSK->keyMgmtType, "wpa2-sha256") == 0)
950 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt WPA2-SHA256", setPSK->intf);
951 else if(strcasecmp(setPSK->keyMgmtType, "wpa2") == 0)
952 {
953 // take all and device to pick it supported.
954 }
955 else if(strcasecmp(setPSK->keyMgmtType, "wpa2-psk") == 0)
956 {
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000957
Dake Zhao0a832172015-01-06 11:08:47 -0800958 }
959 else if(strcasecmp(setPSK->keyMgmtType, "wpa2-ft") == 0)
960 {
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000961
Dake Zhao0a832172015-01-06 11:08:47 -0800962 }
963 else if (strcasecmp(setPSK->keyMgmtType, "wpa2-wpa-psk") == 0)
964 {
Ray Wang9c508692014-04-01 17:04:59 -0700965
Dake Zhao0a832172015-01-06 11:08:47 -0800966 }
967 else
968 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt WPA-PSK", setPSK->intf);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -0800969
Dake Zhao0a832172015-01-06 11:08:47 -0800970 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000971
Dake Zhao0a832172015-01-06 11:08:47 -0800972 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 psk '\"%s\"'", setPSK->intf, setPSK->passphrase);
973 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000974
Dake Zhao0a832172015-01-06 11:08:47 -0800975 sprintf(gCmdStr, "wpa_cli -i %s enable_network 0", setPSK->intf);
976 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000977
Dake Zhao0a832172015-01-06 11:08:47 -0800978 /* if PMF enable */
979 if(setPSK->pmf == WFA_ENABLED || setPSK->pmf == WFA_OPTIONAL)
980 {
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000981
Dake Zhao0a832172015-01-06 11:08:47 -0800982 }
983 else if(setPSK->pmf == WFA_REQUIRED)
984 {
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000985
Dake Zhao0a832172015-01-06 11:08:47 -0800986 }
987 else if(setPSK->pmf == WFA_F_REQUIRED)
988 {
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +0000989
Dake Zhao0a832172015-01-06 11:08:47 -0800990 }
991 else if(setPSK->pmf == WFA_F_DISABLED)
992 {
993
994 }
995 else
996 {
997 /* Disable PMF */
998
999 }
1000
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001001#endif
1002
Dake Zhaob7ed41a2014-12-04 11:24:58 -08001003#endif
1004
Dake Zhao0a832172015-01-06 11:08:47 -08001005 setPskResp->status = STATUS_COMPLETE;
1006 wfaEncodeTLV(WFA_STA_SET_PSK_RESP_TLV, 4, (BYTE *)setPskResp, respBuf);
1007 *respLen = WFA_TLV_HDR_LEN + 4;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001008
Dake Zhao0a832172015-01-06 11:08:47 -08001009 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001010}
1011
1012/*
Dake Zhao0a832172015-01-06 11:08:47 -08001013 * wfaStaGetInfo():
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001014 * Get vendor specific information in name/value pair by a wireless I/F.
1015 */
1016int wfaStaGetInfo(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1017{
Dake Zhao0a832172015-01-06 11:08:47 -08001018 dutCmdResponse_t infoResp;
1019 dutCommand_t *getInfo = (dutCommand_t *)caCmdBuf;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001020
Dake Zhao0a832172015-01-06 11:08:47 -08001021 /*
1022 * Normally this is called to retrieve the vendor information
1023 * from a interface, no implement yet
1024 */
1025 sprintf(infoResp.cmdru.info, "interface,%s,vendor,XXX,cardtype,802.11a/b/g", getInfo->intf);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001026
Dake Zhao0a832172015-01-06 11:08:47 -08001027 infoResp.status = STATUS_COMPLETE;
1028 wfaEncodeTLV(WFA_STA_GET_INFO_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
1029 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
1030
1031 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001032}
1033
1034/*
1035 * wfaStaSetEapTTLS():
1036 * This is to set
1037 * 1. ssid
1038 * 2. username
1039 * 3. passwd
1040 * 4. encrypType - tkip or aes-ccmp
1041 * 5. keyManagementType - wpa or wpa2
1042 * 6. trustedRootCA
1043 */
1044int wfaStaSetEapTTLS(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1045{
Dake Zhao0a832172015-01-06 11:08:47 -08001046 caStaSetEapTTLS_t *setTTLS = (caStaSetEapTTLS_t *)caCmdBuf;
1047 char *ifname = setTTLS->intf;
1048 dutCmdResponse_t *setEapTtlsResp = &gGenericResp;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001049
1050#ifdef WFA_NEW_CLI_FORMAT
Dake Zhao0a832172015-01-06 11:08:47 -08001051 sprintf(gCmdStr, "wfa_set_eapttls %s %s %s %s %s", ifname, setTTLS->ssid, setTTLS->username, setTTLS->passwd, setTTLS->trustedRootCA);
1052 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001053#else
1054
Dake Zhao0a832172015-01-06 11:08:47 -08001055 sprintf(gCmdStr, "wpa_cli -i %s disable_network 0", ifname);
1056 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001057
Dake Zhao0a832172015-01-06 11:08:47 -08001058 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 ssid '\"%s\"'", ifname, setTTLS->ssid);
1059 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001060
Dake Zhao0a832172015-01-06 11:08:47 -08001061 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 identity '\"%s\"'", ifname, setTTLS->username);
1062 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001063
Dake Zhao0a832172015-01-06 11:08:47 -08001064 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 password '\"%s\"'", ifname, setTTLS->passwd);
1065 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001066
Dake Zhao0a832172015-01-06 11:08:47 -08001067 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt WPA-EAP", ifname);
1068 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001069
Dake Zhao0a832172015-01-06 11:08:47 -08001070 /* This may not need to set. if it is not set, default to take all */
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001071// sprintf(cmdStr, "wpa_cli -i %s set_network 0 pairwise '\"%s\"", ifname, setTTLS->encrptype);
Dake Zhao0a832172015-01-06 11:08:47 -08001072 if(strcasecmp(setTTLS->keyMgmtType, "wpa2-sha256") == 0)
1073 {
1074 }
1075 else if(strcasecmp(setTTLS->keyMgmtType, "wpa2-eap") == 0)
1076 {
1077 }
1078 else if(strcasecmp(setTTLS->keyMgmtType, "wpa2-ft") == 0)
1079 {
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001080
Dake Zhao0a832172015-01-06 11:08:47 -08001081 }
1082 else if(strcasecmp(setTTLS->keyMgmtType, "wpa") == 0)
1083 {
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001084
Dake Zhao0a832172015-01-06 11:08:47 -08001085 }
1086 else if(strcasecmp(setTTLS->keyMgmtType, "wpa2") == 0)
1087 {
1088 // to take all and device to pick one it supported
1089 }
1090 else
1091 {
1092 // ??
1093 }
1094 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001095
Dake Zhao0a832172015-01-06 11:08:47 -08001096 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 eap TTLS", ifname);
1097 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001098
Dake Zhao0a832172015-01-06 11:08:47 -08001099 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 ca_cert '\"%s/%s\"'", ifname, CERTIFICATES_PATH, setTTLS->trustedRootCA);
1100 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001101
Dake Zhao0a832172015-01-06 11:08:47 -08001102 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 proto WPA", ifname);
1103 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001104
Dake Zhao0a832172015-01-06 11:08:47 -08001105 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 phase2 '\"auth=MSCHAPV2\"'", ifname);
1106 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001107
Dake Zhao0a832172015-01-06 11:08:47 -08001108 sprintf(gCmdStr, "wpa_cli -i %s enable_network 0", ifname);
1109 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001110#endif
1111
Dake Zhao0a832172015-01-06 11:08:47 -08001112 setEapTtlsResp->status = STATUS_COMPLETE;
1113 wfaEncodeTLV(WFA_STA_SET_EAPTTLS_RESP_TLV, 4, (BYTE *)setEapTtlsResp, respBuf);
1114 *respLen = WFA_TLV_HDR_LEN + 4;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001115
Dake Zhao0a832172015-01-06 11:08:47 -08001116 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001117}
1118
1119/*
1120 * wfaStaSetEapSIM():
1121 * This is to set
1122 * 1. ssid
1123 * 2. user name
1124 * 3. passwd
1125 * 4. encrypType - tkip or aes-ccmp
1126 * 5. keyMangementType - wpa or wpa2
1127 */
1128int wfaStaSetEapSIM(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1129{
Dake Zhao0a832172015-01-06 11:08:47 -08001130 caStaSetEapSIM_t *setSIM = (caStaSetEapSIM_t *)caCmdBuf;
1131 char *ifname = setSIM->intf;
1132 dutCmdResponse_t *setEapSimResp = &gGenericResp;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001133
1134#ifdef WFA_NEW_CLI_FORMAT
Dake Zhao0a832172015-01-06 11:08:47 -08001135 sprintf(gCmdStr, "wfa_set_eapsim %s %s %s %s", ifname, setSIM->ssid, setSIM->username, setSIM->encrptype);
1136 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001137#else
1138
Dake Zhao0a832172015-01-06 11:08:47 -08001139 sprintf(gCmdStr, "wpa_cli -i %s disable_network 0", ifname);
1140 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001141
Dake Zhao0a832172015-01-06 11:08:47 -08001142 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 ssid '\"%s\"'", ifname, setSIM->ssid);
1143 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001144
1145
Dake Zhao0a832172015-01-06 11:08:47 -08001146 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 identity '\"%s\"'", ifname, setSIM->username);
1147 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001148
Dake Zhao0a832172015-01-06 11:08:47 -08001149 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 pairwise '\"%s\"'", ifname, setSIM->encrptype);
1150 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001151
Dake Zhao0a832172015-01-06 11:08:47 -08001152 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 eap SIM", ifname);
1153 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001154
Dake Zhao0a832172015-01-06 11:08:47 -08001155 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 proto WPA", ifname);
1156 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001157
Dake Zhao0a832172015-01-06 11:08:47 -08001158 sprintf(gCmdStr, "wpa_cli -i %s enable_network 0", ifname);
1159 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001160
Dake Zhao0a832172015-01-06 11:08:47 -08001161 if(strcasecmp(setSIM->keyMgmtType, "wpa2-sha256") == 0)
1162 {
1163 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt WPA-SHA256", ifname);
1164 }
1165 else if(strcasecmp(setSIM->keyMgmtType, "wpa2-eap") == 0)
1166 {
1167 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt WPA-EAP", ifname);
1168 }
1169 else if(strcasecmp(setSIM->keyMgmtType, "wpa2-ft") == 0)
1170 {
1171 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt WPA-FT", ifname);
1172 }
1173 else if(strcasecmp(setSIM->keyMgmtType, "wpa") == 0)
1174 {
1175 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt WPA-EAP", ifname);
1176 }
1177 else if(strcasecmp(setSIM->keyMgmtType, "wpa2") == 0)
1178 {
1179 // take all and device to pick one which is supported.
1180 }
1181 else
1182 {
1183 // ??
1184 }
1185 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001186
1187#endif
1188
Dake Zhao0a832172015-01-06 11:08:47 -08001189 setEapSimResp->status = STATUS_COMPLETE;
1190 wfaEncodeTLV(WFA_STA_SET_EAPSIM_RESP_TLV, 4, (BYTE *)setEapSimResp, respBuf);
1191 *respLen = WFA_TLV_HDR_LEN + 4;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001192
Dake Zhao0a832172015-01-06 11:08:47 -08001193 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001194}
1195
1196/*
1197 * wfaStaSetPEAP()
1198 * This is to set
1199 * 1. ssid
1200 * 2. user name
1201 * 3. passwd
1202 * 4. encryType - tkip or aes-ccmp
1203 * 5. keyMgmtType - wpa or wpa2
1204 * 6. trustedRootCA
1205 * 7. innerEAP
1206 * 8. peapVersion
1207 */
1208int wfaStaSetPEAP(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1209{
Dake Zhao0a832172015-01-06 11:08:47 -08001210 caStaSetEapPEAP_t *setPEAP = (caStaSetEapPEAP_t *)caCmdBuf;
1211 char *ifname = setPEAP->intf;
1212 dutCmdResponse_t *setPeapResp = &gGenericResp;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001213
1214#ifdef WFA_NEW_CLI_FORMAT
Dake Zhao0a832172015-01-06 11:08:47 -08001215 sprintf(gCmdStr, "wfa_set_peap %s %s %s %s %s %s %i %s", ifname, setPEAP->ssid, setPEAP->username,
1216 setPEAP->passwd, setPEAP->trustedRootCA,
1217 setPEAP->encrptype, setPEAP->peapVersion,
1218 setPEAP->innerEAP);
1219 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001220#else
1221
Dake Zhao0a832172015-01-06 11:08:47 -08001222 sprintf(gCmdStr, "wpa_cli -i %s disable_network 0", ifname);
1223 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001224
Dake Zhao0a832172015-01-06 11:08:47 -08001225 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 ssid '\"%s\"'", ifname, setPEAP->ssid);
1226 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001227
Dake Zhao0a832172015-01-06 11:08:47 -08001228 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 eap PEAP", ifname);
1229 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001230
Dake Zhao0a832172015-01-06 11:08:47 -08001231 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 anonymous_identity '\"anonymous\"' ", ifname);
1232 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001233
Dake Zhao0a832172015-01-06 11:08:47 -08001234 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 identity '\"%s\"'", ifname, setPEAP->username);
1235 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001236
Dake Zhao0a832172015-01-06 11:08:47 -08001237 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 password '\"%s\"'", ifname, setPEAP->passwd);
1238 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001239
Dake Zhao0a832172015-01-06 11:08:47 -08001240 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 ca_cert '\"%s/%s\"'", ifname, CERTIFICATES_PATH, setPEAP->trustedRootCA);
1241 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001242
Dake Zhao0a832172015-01-06 11:08:47 -08001243 if(strcasecmp(setPEAP->keyMgmtType, "wpa2-sha256") == 0)
1244 {
1245 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt WPA-SHA256", ifname);
1246 }
1247 else if(strcasecmp(setPEAP->keyMgmtType, "wpa2-eap") == 0)
1248 {
1249 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt WPA-EAP", ifname);
1250 }
1251 else if(strcasecmp(setPEAP->keyMgmtType, "wpa2-ft") == 0)
1252 {
1253 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt WPA-FT", ifname);
1254 }
1255 else if(strcasecmp(setPEAP->keyMgmtType, "wpa") == 0)
1256 {
1257 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt WPA-EAP", ifname);
1258 }
1259 else if(strcasecmp(setPEAP->keyMgmtType, "wpa2") == 0)
1260 {
1261 // take all and device to pick one which is supported.
1262 }
1263 else
1264 {
1265 // ??
1266 }
1267 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001268
Dake Zhao0a832172015-01-06 11:08:47 -08001269 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 phase1 '\"peaplabel=%i\"'", ifname, setPEAP->peapVersion);
1270 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001271
Dake Zhao0a832172015-01-06 11:08:47 -08001272 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 phase2 '\"auth=%s\"'", ifname, setPEAP->innerEAP);
1273 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001274
Dake Zhao0a832172015-01-06 11:08:47 -08001275 sprintf(gCmdStr, "wpa_cli -i %s enable_network 0", ifname);
1276 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001277#endif
1278
Dake Zhao0a832172015-01-06 11:08:47 -08001279 setPeapResp->status = STATUS_COMPLETE;
1280 wfaEncodeTLV(WFA_STA_SET_PEAP_RESP_TLV, 4, (BYTE *)setPeapResp, respBuf);
1281 *respLen = WFA_TLV_HDR_LEN + 4;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001282
Dake Zhao0a832172015-01-06 11:08:47 -08001283 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001284}
1285
1286/*
1287 * wfaStaSetUAPSD()
1288 * This is to set
1289 * 1. acBE
1290 * 2. acBK
1291 * 3. acVI
1292 * 4. acVO
1293 */
1294int wfaStaSetUAPSD(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1295{
Dake Zhao0a832172015-01-06 11:08:47 -08001296 dutCmdResponse_t *setUAPSDResp = &gGenericResp;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001297#if 0 /* used for only one specific device, need to update to reflect yours */
Dake Zhao0a832172015-01-06 11:08:47 -08001298 caStaSetUAPSD_t *setUAPSD = (caStaSetUAPSD_t *)caCmdBuf;
1299 char *ifname = setUAPSD->intf;
1300 char tmpStr[10];
1301 char line[100];
1302 char *pathl="/etc/Wireless/RT61STA";
1303 BYTE acBE=1;
1304 BYTE acBK=1;
1305 BYTE acVO=1;
1306 BYTE acVI=1;
1307 BYTE APSDCapable;
1308 FILE *pipe;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001309
Dake Zhao0a832172015-01-06 11:08:47 -08001310 /*
1311 * A series of setting need to be done before doing WMM-PS
1312 * Additional steps of configuration may be needed.
1313 */
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001314
Dake Zhao0a832172015-01-06 11:08:47 -08001315 /*
1316 * bring down the interface
1317 */
1318 sprintf(gCmdStr, "ifconfig %s down",ifname);
1319 sret = system(gCmdStr);
1320 /*
1321 * Unload the Driver
1322 */
1323 sprintf(gCmdStr, "rmmod rt61");
1324 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001325#ifndef WFA_WMM_AC
Dake Zhao0a832172015-01-06 11:08:47 -08001326 if(setUAPSD->acBE != 1)
1327 acBE=setUAPSD->acBE = 0;
1328 if(setUAPSD->acBK != 1)
1329 acBK=setUAPSD->acBK = 0;
1330 if(setUAPSD->acVO != 1)
1331 acVO=setUAPSD->acVO = 0;
1332 if(setUAPSD->acVI != 1)
1333 acVI=setUAPSD->acVI = 0;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001334#else
Dake Zhao0a832172015-01-06 11:08:47 -08001335 acBE=setUAPSD->acBE;
1336 acBK=setUAPSD->acBK;
1337 acVO=setUAPSD->acVO;
1338 acVI=setUAPSD->acVI;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001339#endif
1340
Dake Zhao0a832172015-01-06 11:08:47 -08001341 APSDCapable = acBE||acBK||acVO||acVI;
1342 /*
1343 * set other AC parameters
1344 */
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001345
Dake Zhao0a832172015-01-06 11:08:47 -08001346 sprintf(tmpStr,"%d;%d;%d;%d",setUAPSD->acBE,setUAPSD->acBK,setUAPSD->acVI,setUAPSD->acVO);
1347 sprintf(gCmdStr, "sed -e \"s/APSDCapable=.*/APSDCapable=%d/g\" -e \"s/APSDAC=.*/APSDAC=%s/g\" %s/rt61sta.dat >/tmp/wfa_tmp",APSDCapable,tmpStr,pathl);
1348 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001349
Dake Zhao0a832172015-01-06 11:08:47 -08001350 sprintf(gCmdStr, "mv /tmp/wfa_tmp %s/rt61sta.dat",pathl);
1351 sret = system(gCmdStr);
1352 pipe = popen("uname -r", "r");
1353 /* Read into line the output of uname*/
1354 fscanf(pipe,"%s",line);
1355 pclose(pipe);
1356
1357 /*
1358 * load the Driver
1359 */
1360 sprintf(gCmdStr, "insmod /lib/modules/%s/extra/rt61.ko",line);
1361 sret = system(gCmdStr);
1362
1363 sprintf(gCmdStr, "ifconfig %s up",ifname);
1364 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001365#endif
1366
Dake Zhao0a832172015-01-06 11:08:47 -08001367 setUAPSDResp->status = STATUS_COMPLETE;
1368 wfaEncodeTLV(WFA_STA_SET_UAPSD_RESP_TLV, 4, (BYTE *)setUAPSDResp, respBuf);
1369 *respLen = WFA_TLV_HDR_LEN + 4;
1370 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001371}
1372
1373int wfaDeviceGetInfo(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1374{
Dake Zhao0a832172015-01-06 11:08:47 -08001375 dutCommand_t *dutCmd = (dutCommand_t *)caCmdBuf;
1376 caDevInfo_t *devInfo = &dutCmd->cmdsu.dev;
1377 dutCmdResponse_t *infoResp = &gGenericResp;
1378 /*a vendor can fill in the proper info or anything non-disclosure */
1379 caDeviceGetInfoResp_t dinfo = {"WFA Lab", "DemoUnit", WFA_SYSTEM_VER};
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001380
Dake Zhao0a832172015-01-06 11:08:47 -08001381 DPRINT_INFO(WFA_OUT, "Entering wfaDeviceGetInfo ...\n");
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001382
Dake Zhao0a832172015-01-06 11:08:47 -08001383 if(devInfo->fw == 0)
1384 memcpy(&infoResp->cmdru.devInfo, &dinfo, sizeof(caDeviceGetInfoResp_t));
1385 else
1386 {
1387 // Call internal API to pull the version ID */
1388 memcpy(infoResp->cmdru.devInfo.firmware, "NOVERSION", 15);
1389 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001390
Dake Zhao0a832172015-01-06 11:08:47 -08001391 infoResp->status = STATUS_COMPLETE;
1392 wfaEncodeTLV(WFA_DEVICE_GET_INFO_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)infoResp, respBuf);
1393 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001394
Dake Zhao0a832172015-01-06 11:08:47 -08001395 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001396
1397}
1398
1399/*
1400 * This funciton is to retrieve a list of interfaces and return
1401 * the list back to Agent control.
1402 * ********************************************************************
1403 * Note: We intend to make this WLAN interface name as a hardcode name.
1404 * Therefore, for a particular device, you should know and change the name
Dake Zhao0a832172015-01-06 11:08:47 -08001405 * for that device while doing porting. The MACRO "WFA_STAUT_IF" is defined in
1406 * the file "inc/wfa_ca.h". If the device OS is not linux-like, this most
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001407 * likely is hardcoded just for CAPI command responses.
1408 * *******************************************************************
Dake Zhao0a832172015-01-06 11:08:47 -08001409 *
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001410 */
1411int wfaDeviceListIF(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1412{
Dake Zhao0a832172015-01-06 11:08:47 -08001413 dutCmdResponse_t *infoResp = &gGenericResp;
1414 dutCommand_t *ifList = (dutCommand_t *)caCmdBuf;
1415 caDeviceListIFResp_t *ifListResp = &infoResp->cmdru.ifList;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001416
Dake Zhao0a832172015-01-06 11:08:47 -08001417 DPRINT_INFO(WFA_OUT, "Entering wfaDeviceListIF ...\n");
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001418
Dake Zhao0a832172015-01-06 11:08:47 -08001419 switch(ifList->cmdsu.iftype)
1420 {
1421 case IF_80211:
1422 infoResp->status = STATUS_COMPLETE;
1423 ifListResp->iftype = IF_80211;
1424 strcpy(ifListResp->ifs[0], WFA_STAUT_IF);
1425 strcpy(ifListResp->ifs[1], "NULL");
1426 strcpy(ifListResp->ifs[2], "NULL");
1427 break;
1428 case IF_ETH:
1429 infoResp->status = STATUS_COMPLETE;
1430 ifListResp->iftype = IF_ETH;
1431 strcpy(ifListResp->ifs[0], "eth0");
1432 strcpy(ifListResp->ifs[1], "NULL");
1433 strcpy(ifListResp->ifs[2], "NULL");
1434 break;
1435 default:
1436 {
1437 infoResp->status = STATUS_ERROR;
1438 wfaEncodeTLV(WFA_DEVICE_LIST_IF_RESP_TLV, 4, (BYTE *)infoResp, respBuf);
1439 *respLen = WFA_TLV_HDR_LEN + 4;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001440
Dake Zhao0a832172015-01-06 11:08:47 -08001441 return WFA_SUCCESS;
1442 }
1443 }
1444
1445 wfaEncodeTLV(WFA_DEVICE_LIST_IF_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)infoResp, respBuf);
1446 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
1447
1448 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001449}
1450
1451int wfaStaDebugSet(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1452{
Dake Zhao0a832172015-01-06 11:08:47 -08001453 dutCmdResponse_t *debugResp = &gGenericResp;
1454 dutCommand_t *debugSet = (dutCommand_t *)caCmdBuf;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001455
Dake Zhao0a832172015-01-06 11:08:47 -08001456 DPRINT_INFO(WFA_OUT, "Entering wfaStaDebugSet ...\n");
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001457
Dake Zhao0a832172015-01-06 11:08:47 -08001458 if(debugSet->cmdsu.dbg.state == 1) /* enable */
1459 wfa_defined_debug |= debugSet->cmdsu.dbg.level;
1460 else
1461 wfa_defined_debug = (~debugSet->cmdsu.dbg.level & wfa_defined_debug);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001462
Dake Zhao0a832172015-01-06 11:08:47 -08001463 debugResp->status = STATUS_COMPLETE;
1464 wfaEncodeTLV(WFA_STA_GET_INFO_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)debugResp, respBuf);
1465 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001466
1467
Dake Zhao0a832172015-01-06 11:08:47 -08001468 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001469}
1470
1471
1472/*
1473 * wfaStaGetBSSID():
1474 * This function is to retrieve BSSID of a specific wireless I/F.
Dake Zhao0a832172015-01-06 11:08:47 -08001475 */
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001476int wfaStaGetBSSID(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1477{
Dake Zhao0a832172015-01-06 11:08:47 -08001478 char string[64];
1479 char *str;
1480 FILE *tmpfd;
1481 dutCmdResponse_t *bssidResp = &gGenericResp;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001482
Dake Zhao0a832172015-01-06 11:08:47 -08001483 DPRINT_INFO(WFA_OUT, "Entering wfaStaGetBSSID ...\n");
1484 /* retrieve the BSSID */
1485 sprintf(gCmdStr, "wpa_cli status > /tmp/bssid.txt");
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001486
Dake Zhao0a832172015-01-06 11:08:47 -08001487 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001488
Dake Zhao0a832172015-01-06 11:08:47 -08001489 tmpfd = fopen("/tmp/bssid.txt", "r+");
1490 if(tmpfd == NULL)
1491 {
1492 bssidResp->status = STATUS_ERROR;
1493 wfaEncodeTLV(WFA_STA_GET_BSSID_RESP_TLV, 4, (BYTE *)bssidResp, respBuf);
1494 *respLen = WFA_TLV_HDR_LEN + 4;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001495
Dake Zhao0a832172015-01-06 11:08:47 -08001496 DPRINT_ERR(WFA_ERR, "file open failed\n");
1497 return WFA_FAILURE;
1498 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001499
Dake Zhao0a832172015-01-06 11:08:47 -08001500 for(;;)
1501 {
1502 if(fscanf(tmpfd, "%s", string) == EOF)
1503 {
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001504 bssidResp->status = STATUS_COMPLETE;
Dake Zhao0a832172015-01-06 11:08:47 -08001505 strcpy(bssidResp->cmdru.bssid, "00:00:00:00:00:00");
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001506 break;
Dake Zhao0a832172015-01-06 11:08:47 -08001507 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001508
Dake Zhao0a832172015-01-06 11:08:47 -08001509 if(strncmp(string, "bssid", 5) == 0)
1510 {
1511 str = strtok(string, "=");
1512 str = strtok(NULL, "=");
1513 if(str != NULL)
1514 {
1515 strcpy(bssidResp->cmdru.bssid, str);
1516 bssidResp->status = STATUS_COMPLETE;
1517 break;
1518 }
1519 }
1520 }
1521
1522 wfaEncodeTLV(WFA_STA_GET_BSSID_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)bssidResp, respBuf);
1523 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
1524
1525 fclose(tmpfd);
1526 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001527}
1528
1529/*
1530 * wfaStaSetIBSS()
1531 * This is to set
1532 * 1. ssid
1533 * 2. channel
1534 * 3. encrypType - none or wep
1535 * optional
1536 * 4. key1
1537 * 5. key2
1538 * 6. key3
1539 * 7. key4
1540 * 8. activeIndex - 1, 2, 3, or 4
1541 */
1542int wfaStaSetIBSS(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1543{
Dake Zhao0a832172015-01-06 11:08:47 -08001544 caStaSetIBSS_t *setIBSS = (caStaSetIBSS_t *)caCmdBuf;
1545 dutCmdResponse_t *setIbssResp = &gGenericResp;
1546 int i;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001547
Dake Zhao0a832172015-01-06 11:08:47 -08001548 /*
1549 * disable the network first
1550 */
1551 sprintf(gCmdStr, "wpa_cli -i %s disable_network 0", setIBSS->intf);
1552 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001553
Dake Zhao0a832172015-01-06 11:08:47 -08001554 /*
1555 * set SSID
1556 */
1557 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 ssid '\"%s\"'", setIBSS->intf, setIBSS->ssid);
1558 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001559
Dake Zhao0a832172015-01-06 11:08:47 -08001560 /*
1561 * Set channel for IBSS
1562 */
1563 sprintf(gCmdStr, "iwconfig %s channel %i", setIBSS->intf, setIBSS->channel);
1564 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001565
Dake Zhao0a832172015-01-06 11:08:47 -08001566 /*
1567 * Tell the supplicant for IBSS mode (1)
1568 */
1569 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 mode 1", setIBSS->intf);
1570 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001571
Dake Zhao0a832172015-01-06 11:08:47 -08001572 /*
1573 * set Key management to NONE (NO WPA) for plaintext or WEP
1574 */
1575 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt NONE", setIBSS->intf);
1576 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001577
Dake Zhao0a832172015-01-06 11:08:47 -08001578 if(setIBSS->encpType == 1)
1579 {
1580 for(i=0; i<4; i++)
1581 {
1582 if(strlen(setIBSS->keys[i]) ==5 || strlen(setIBSS->keys[i]) == 13)
1583 {
1584 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 wep_key%i \"%s\"",
1585 setIBSS->intf, i, setIBSS->keys[i]);
1586 sret = system(gCmdStr);
1587 }
1588 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001589
Dake Zhao0a832172015-01-06 11:08:47 -08001590 i = setIBSS->activeKeyIdx;
1591 if(strlen(setIBSS->keys[i]) ==5 || strlen(setIBSS->keys[i]) == 13)
1592 {
1593 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 wep_tx_keyidx %i",
1594 setIBSS->intf, setIBSS->activeKeyIdx);
1595 sret = system(gCmdStr);
1596 }
1597 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001598
Dake Zhao0a832172015-01-06 11:08:47 -08001599 sprintf(gCmdStr, "wpa_cli -i %s enable_network 0", setIBSS->intf);
1600 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001601
Dake Zhao0a832172015-01-06 11:08:47 -08001602 setIbssResp->status = STATUS_COMPLETE;
1603 wfaEncodeTLV(WFA_STA_SET_IBSS_RESP_TLV, 4, (BYTE *)setIbssResp, respBuf);
1604 *respLen = WFA_TLV_HDR_LEN + 4;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001605
Dake Zhao0a832172015-01-06 11:08:47 -08001606 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001607}
1608
1609/*
1610 * wfaSetMode():
Dake Zhao0a832172015-01-06 11:08:47 -08001611 * The function is to set the wireless interface with a given mode (possible
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001612 * adhoc)
1613 * Input parameters:
1614 * 1. I/F
1615 * 2. ssid
1616 * 3. mode adhoc or managed
1617 * 4. encType
1618 * 5. channel
1619 * 6. key(s)
1620 * 7. active key
Dake Zhao0a832172015-01-06 11:08:47 -08001621 */
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001622int wfaStaSetMode(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1623{
Dake Zhao0a832172015-01-06 11:08:47 -08001624 caStaSetMode_t *setmode = (caStaSetMode_t *)caCmdBuf;
1625 dutCmdResponse_t *SetModeResp = &gGenericResp;
1626 int i;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001627
Dake Zhao0a832172015-01-06 11:08:47 -08001628 /*
1629 * bring down the interface
1630 */
1631 sprintf(gCmdStr, "ifconfig %s down",setmode->intf);
1632 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001633
Dake Zhao0a832172015-01-06 11:08:47 -08001634 /*
1635 * distroy the interface
1636 */
1637 sprintf(gCmdStr, "wlanconfig %s destroy",setmode->intf);
1638 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001639
1640
Dake Zhao0a832172015-01-06 11:08:47 -08001641 /*
1642 * re-create the interface with the given mode
1643 */
1644 if(setmode->mode == 1)
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001645 sprintf(gCmdStr, "wlanconfig %s create wlandev wifi0 wlanmode adhoc",setmode->intf);
Dake Zhao0a832172015-01-06 11:08:47 -08001646 else
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001647 sprintf(gCmdStr, "wlanconfig %s create wlandev wifi0 wlanmode managed",setmode->intf);
1648
Dake Zhao0a832172015-01-06 11:08:47 -08001649 sret = system(gCmdStr);
1650 if(setmode->encpType == ENCRYPT_WEP)
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001651 {
Dake Zhao0a832172015-01-06 11:08:47 -08001652 int j = setmode->activeKeyIdx;
1653 for(i=0; i<4; i++)
1654 {
1655 if(setmode->keys[i][0] != '\0')
1656 {
1657 sprintf(gCmdStr, "iwconfig %s key s:%s",
1658 setmode->intf, setmode->keys[i]);
1659 sret = system(gCmdStr);
1660 }
1661 /* set active key */
1662 if(setmode->keys[j][0] != '\0')
1663 sprintf(gCmdStr, "iwconfig %s key s:%s",
1664 setmode->intf, setmode->keys[j]);
1665 sret = system(gCmdStr);
1666 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001667
1668 }
Dake Zhao0a832172015-01-06 11:08:47 -08001669 /*
1670 * Set channel for IBSS
1671 */
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001672 if(setmode->channel)
1673 {
Dake Zhao0a832172015-01-06 11:08:47 -08001674 sprintf(gCmdStr, "iwconfig %s channel %i", setmode->intf, setmode->channel);
1675 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001676 }
1677
1678
Dake Zhao0a832172015-01-06 11:08:47 -08001679 /*
1680 * set SSID
1681 */
1682 sprintf(gCmdStr, "iwconfig %s essid %s", setmode->intf, setmode->ssid);
1683 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001684
Dake Zhao0a832172015-01-06 11:08:47 -08001685 /*
1686 * bring up the interface
1687 */
1688 sprintf(gCmdStr, "ifconfig %s up",setmode->intf);
1689 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001690
Dake Zhao0a832172015-01-06 11:08:47 -08001691 SetModeResp->status = STATUS_COMPLETE;
1692 wfaEncodeTLV(WFA_STA_SET_MODE_RESP_TLV, 4, (BYTE *)SetModeResp, respBuf);
1693 *respLen = WFA_TLV_HDR_LEN + 4;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001694
Dake Zhao0a832172015-01-06 11:08:47 -08001695 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001696}
1697
1698int wfaStaSetPwrSave(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1699{
Dake Zhao0a832172015-01-06 11:08:47 -08001700 caStaSetPwrSave_t *setps = (caStaSetPwrSave_t *)caCmdBuf;
1701 dutCmdResponse_t *SetPSResp = &gGenericResp;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001702
Dake Zhao0a832172015-01-06 11:08:47 -08001703 sprintf(gCmdStr, "iwconfig %s power %s", setps->intf, setps->mode);
1704 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001705
1706
Dake Zhao0a832172015-01-06 11:08:47 -08001707 SetPSResp->status = STATUS_COMPLETE;
1708 wfaEncodeTLV(WFA_STA_SET_PWRSAVE_RESP_TLV, 4, (BYTE *)SetPSResp, respBuf);
1709 *respLen = WFA_TLV_HDR_LEN + 4;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001710
Dake Zhao0a832172015-01-06 11:08:47 -08001711 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001712}
1713
1714int wfaStaUpload(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1715{
Dake Zhao0a832172015-01-06 11:08:47 -08001716 caStaUpload_t *upload = &((dutCommand_t *)caCmdBuf)->cmdsu.upload;
1717 dutCmdResponse_t *upLoadResp = &gGenericResp;
1718 caStaUploadResp_t *upld = &upLoadResp->cmdru.uld;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001719
Dake Zhao0a832172015-01-06 11:08:47 -08001720 if(upload->type == WFA_UPLOAD_VHSO_RPT)
1721 {
1722 int rbytes;
1723 /*
1724 * if asked for the first packet, always to open the file
1725 */
1726 if(upload->next == 1)
1727 {
1728 if(e2efp != NULL)
1729 {
1730 fclose(e2efp);
1731 e2efp = NULL;
1732 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001733
Dake Zhao0a832172015-01-06 11:08:47 -08001734 e2efp = fopen(e2eResults, "r");
1735 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001736
Dake Zhao0a832172015-01-06 11:08:47 -08001737 if(e2efp == NULL)
1738 {
1739 upLoadResp->status = STATUS_ERROR;
1740 wfaEncodeTLV(WFA_STA_UPLOAD_RESP_TLV, 4, (BYTE *)upLoadResp, respBuf);
1741 *respLen = WFA_TLV_HDR_LEN + 4;
1742 return WFA_FAILURE;
1743 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001744
Dake Zhao0a832172015-01-06 11:08:47 -08001745 rbytes = fread(upld->bytes, 1, 256, e2efp);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001746
Dake Zhao0a832172015-01-06 11:08:47 -08001747 if(rbytes < 256)
1748 {
1749 /*
1750 * this means no more bytes after this read
1751 */
1752 upld->seqnum = 0;
1753 fclose(e2efp);
1754 e2efp=NULL;
1755 }
1756 else
1757 {
1758 upld->seqnum = upload->next;
1759 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001760
Dake Zhao0a832172015-01-06 11:08:47 -08001761 upld->nbytes = rbytes;
1762
1763 upLoadResp->status = STATUS_COMPLETE;
1764 wfaEncodeTLV(WFA_STA_UPLOAD_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)upLoadResp, respBuf);
1765 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
1766 }
1767 else
1768 {
1769 upLoadResp->status = STATUS_ERROR;
1770 wfaEncodeTLV(WFA_STA_UPLOAD_RESP_TLV, 4, (BYTE *)upLoadResp, respBuf);
1771 *respLen = WFA_TLV_HDR_LEN + 4;
1772 }
1773
1774 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001775}
1776/*
1777 * wfaStaSetWMM()
1778 * TO be ported on a specific plaform for the DUT
1779 * This is to set the WMM related parameters at the DUT.
1780 * Currently the function is used for GROUPS WMM-AC and WMM general configuration for setting RTS Threshhold, Fragmentation threshold and wmm (ON/OFF)
1781 * It is expected that this function will set all the WMM related parametrs for a particular GROUP .
1782 */
1783int wfaStaSetWMM(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1784{
1785#ifdef WFA_WMM_AC
1786 caStaSetWMM_t *setwmm = (caStaSetWMM_t *)caCmdBuf;
1787 char *ifname = setwmm->intf;
1788 dutCmdResponse_t *setwmmResp = &gGenericResp;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001789
1790 switch(setwmm->group)
1791 {
1792 case GROUP_WMMAC:
Dake Zhao0a832172015-01-06 11:08:47 -08001793 if (setwmm->send_trig)
1794 {
1795 int Sockfd;
1796 struct sockaddr_in psToAddr;
1797 unsigned int TxMsg[512];
1798
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001799 Sockfd = wfaCreateUDPSock(setwmm->dipaddr, 12346);
Dake Zhao0a832172015-01-06 11:08:47 -08001800 memset(&psToAddr, 0, sizeof(psToAddr));
1801 psToAddr.sin_family = AF_INET;
1802 psToAddr.sin_addr.s_addr = inet_addr(setwmm->dipaddr);
1803 psToAddr.sin_port = htons(12346);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001804
1805
Dake Zhao0a832172015-01-06 11:08:47 -08001806 switch (setwmm->trig_ac)
1807 {
1808 case WMMAC_AC_VO:
1809 wfaTGSetPrio(Sockfd, 7);
1810 create_apts_msg(APTS_CK_VO, TxMsg, 0);
1811 printf("\r\nSending AC_VO trigger packet\n");
1812 break;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001813
Dake Zhao0a832172015-01-06 11:08:47 -08001814 case WMMAC_AC_VI:
1815 wfaTGSetPrio(Sockfd, 5);
1816 create_apts_msg(APTS_CK_VI, TxMsg, 0);
1817 printf("\r\nSending AC_VI trigger packet\n");
1818 break;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001819
Dake Zhao0a832172015-01-06 11:08:47 -08001820 case WMMAC_AC_BK:
1821 wfaTGSetPrio(Sockfd, 2);
1822 create_apts_msg(APTS_CK_BK, TxMsg, 0);
1823 printf("\r\nSending AC_BK trigger packet\n");
1824 break;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001825
Dake Zhao0a832172015-01-06 11:08:47 -08001826 default:
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001827 case WMMAC_AC_BE:
Dake Zhao0a832172015-01-06 11:08:47 -08001828 wfaTGSetPrio(Sockfd, 0);
1829 create_apts_msg(APTS_CK_BE, TxMsg, 0);
1830 printf("\r\nSending AC_BE trigger packet\n");
1831 break;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001832 }
1833
Dake Zhao0a832172015-01-06 11:08:47 -08001834 sendto(Sockfd, TxMsg, 256, 0, (struct sockaddr *)&psToAddr,
1835 sizeof(struct sockaddr));
1836 close(Sockfd);
1837 usleep(1000000);
1838 }
1839 else if (setwmm->action == WMMAC_ADDTS)
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001840 {
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001841 printf("ADDTS AC PARAMS: dialog id: %d, TID: %d, "
Dake Zhao0a832172015-01-06 11:08:47 -08001842 "DIRECTION: %d, PSB: %d, UP: %d, INFOACK: %d BURST SIZE DEF: %d"
1843 "Fixed %d, MSDU Size: %d, Max MSDU Size %d, "
1844 "MIN SERVICE INTERVAL: %d, MAX SERVICE INTERVAL: %d, "
1845 "INACTIVITY: %d, SUSPENSION %d, SERVICE START TIME: %d, "
1846 "MIN DATARATE: %d, MEAN DATA RATE: %d, PEAK DATA RATE: %d, "
1847 "BURSTSIZE or MSDU Aggreg: %d, DELAY BOUND: %d, PHYRATE: %d, SPLUSBW: %f, "
1848 "MEDIUM TIME: %d, ACCESSCAT: %d\n",
1849 setwmm->actions.addts.dialog_token,
1850 setwmm->actions.addts.tspec.tsinfo.TID,
1851 setwmm->actions.addts.tspec.tsinfo.direction,
1852 setwmm->actions.addts.tspec.tsinfo.PSB,
1853 setwmm->actions.addts.tspec.tsinfo.UP,
1854 setwmm->actions.addts.tspec.tsinfo.infoAck,
1855 setwmm->actions.addts.tspec.tsinfo.bstSzDef,
1856 setwmm->actions.addts.tspec.Fixed,
1857 setwmm->actions.addts.tspec.size,
1858 setwmm->actions.addts.tspec.maxsize,
1859 setwmm->actions.addts.tspec.min_srvc,
1860 setwmm->actions.addts.tspec.max_srvc,
1861 setwmm->actions.addts.tspec.inactivity,
1862 setwmm->actions.addts.tspec.suspension,
1863 setwmm->actions.addts.tspec.srvc_strt_tim,
1864 setwmm->actions.addts.tspec.mindatarate,
1865 setwmm->actions.addts.tspec.meandatarate,
1866 setwmm->actions.addts.tspec.peakdatarate,
1867 setwmm->actions.addts.tspec.burstsize,
1868 setwmm->actions.addts.tspec.delaybound,
1869 setwmm->actions.addts.tspec.PHYrate,
1870 setwmm->actions.addts.tspec.sba,
1871 setwmm->actions.addts.tspec.medium_time,
1872 setwmm->actions.addts.accesscat);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001873
Dake Zhao862c94b2014-12-08 14:35:35 -08001874 //tspec should be set here.
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001875
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001876 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001877 }
1878 else if (setwmm->action == WMMAC_DELTS)
Dake Zhao0a832172015-01-06 11:08:47 -08001879 {
1880 // send del tspec
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001881 }
1882
1883 setwmmResp->status = STATUS_COMPLETE;
1884 break;
1885
1886 case GROUP_WMMCONF:
1887 sprintf(gCmdStr, "iwconfig %s rts %d",
1888 ifname,setwmm->actions.config.rts_thr);
1889
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001890 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001891 sprintf(gCmdStr, "iwconfig %s frag %d",
1892 ifname,setwmm->actions.config.frag_thr);
1893
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001894 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001895 sprintf(gCmdStr, "iwpriv %s wmmcfg %d",
1896 ifname, setwmm->actions.config.wmm);
1897
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001898 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001899 setwmmResp->status = STATUS_COMPLETE;
1900 break;
1901
1902 default:
1903 DPRINT_ERR(WFA_ERR, "The group %d is not supported\n",setwmm->group);
1904 setwmmResp->status = STATUS_ERROR;
1905 break;
1906
1907 }
1908
1909 wfaEncodeTLV(WFA_STA_SET_WMM_RESP_TLV, 4, (BYTE *)setwmmResp, respBuf);
1910 *respLen = WFA_TLV_HDR_LEN + 4;
1911#endif
1912
1913 return WFA_SUCCESS;
1914}
1915
1916int wfaStaSendNeigReq(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1917{
Dake Zhao0a832172015-01-06 11:08:47 -08001918 dutCmdResponse_t *sendNeigReqResp = &gGenericResp;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001919
Dake Zhao0a832172015-01-06 11:08:47 -08001920 /*
1921 * run your device to send NEIGREQ
1922 */
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001923
Dake Zhao0a832172015-01-06 11:08:47 -08001924 sendNeigReqResp->status = STATUS_COMPLETE;
1925 wfaEncodeTLV(WFA_STA_SEND_NEIGREQ_RESP_TLV, 4, (BYTE *)sendNeigReqResp, respBuf);
1926 *respLen = WFA_TLV_HDR_LEN + 4;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001927
Dake Zhao0a832172015-01-06 11:08:47 -08001928 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001929}
1930
1931int wfaStaSetEapFAST(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
1932{
1933 caStaSetEapFAST_t *setFAST= (caStaSetEapFAST_t *)caCmdBuf;
1934 char *ifname = setFAST->intf;
1935 dutCmdResponse_t *setEapFastResp = &gGenericResp;
1936
1937#ifdef WFA_NEW_CLI_FORMAT
1938 sprintf(gCmdStr, "wfa_set_eapfast %s %s %s %s %s %s", ifname, setFAST->ssid, setFAST->username,
Dake Zhao0a832172015-01-06 11:08:47 -08001939 setFAST->passwd, setFAST->pacFileName,
1940 setFAST->innerEAP);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001941 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001942#else
1943
1944 sprintf(gCmdStr, "wpa_cli -i %s disable_network 0", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001945 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001946
1947 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 ssid '\"%s\"'", ifname, setFAST->ssid);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001948 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001949
1950 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 identity '\"%s\"'", ifname, setFAST->username);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001951 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001952
1953 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 password '\"%s\"'", ifname, setFAST->passwd);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001954 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001955
1956 if(strcasecmp(setFAST->keyMgmtType, "wpa2-sha256") == 0)
1957 {
1958 }
1959 else if(strcasecmp(setFAST->keyMgmtType, "wpa2-eap") == 0)
1960 {
1961 }
1962 else if(strcasecmp(setFAST->keyMgmtType, "wpa2-ft") == 0)
1963 {
Dake Zhao0a832172015-01-06 11:08:47 -08001964
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001965 }
1966 else if(strcasecmp(setFAST->keyMgmtType, "wpa") == 0)
1967 {
Dake Zhao0a832172015-01-06 11:08:47 -08001968 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt WPA-EAP", ifname);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001969 }
1970 else if(strcasecmp(setFAST->keyMgmtType, "wpa2") == 0)
1971 {
Dake Zhao0a832172015-01-06 11:08:47 -08001972 // take all and device to pick one which is supported.
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001973 }
1974 else
1975 {
Dake Zhao0a832172015-01-06 11:08:47 -08001976 // ??
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001977 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001978 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001979
1980 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 eap FAST", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001981 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001982
1983 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 -08001984 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001985
1986 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 anonymous_identity '\"anonymous\"'", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001987 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001988
1989 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 phase1 '\"fast_provisioning=1\"'", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001990 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001991
1992 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 phase2 '\"auth=%s\"'", ifname,setFAST->innerEAP);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001993 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001994
1995 sprintf(gCmdStr, "wpa_cli -i %s enable_network 0", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08001996 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00001997#endif
1998
1999 setEapFastResp->status = STATUS_COMPLETE;
2000 wfaEncodeTLV(WFA_STA_SET_EAPFAST_RESP_TLV, 4, (BYTE *)setEapFastResp, respBuf);
2001 *respLen = WFA_TLV_HDR_LEN + 4;
2002
2003 return WFA_SUCCESS;
2004}
2005
2006int wfaStaSetEapAKA(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2007{
2008 caStaSetEapAKA_t *setAKA= (caStaSetEapAKA_t *)caCmdBuf;
2009 char *ifname = setAKA->intf;
2010 dutCmdResponse_t *setEapAkaResp = &gGenericResp;
2011
2012#ifdef WFA_NEW_CLI_FORMAT
2013 sprintf(gCmdStr, "wfa_set_eapaka %s %s %s %s", ifname, setAKA->ssid, setAKA->username, setAKA->passwd);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002014 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002015#else
2016
2017 sprintf(gCmdStr, "wpa_cli -i %s disable_network 0", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002018 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002019
2020 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 ssid '\"%s\"'", ifname, setAKA->ssid);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002021 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002022
2023 if(strcasecmp(setAKA->keyMgmtType, "wpa2-sha256") == 0)
2024 {
2025 }
2026 else if(strcasecmp(setAKA->keyMgmtType, "wpa2-eap") == 0)
2027 {
2028 }
2029 else if(strcasecmp(setAKA->keyMgmtType, "wpa2-ft") == 0)
2030 {
Dake Zhao0a832172015-01-06 11:08:47 -08002031
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002032 }
2033 else if(strcasecmp(setAKA->keyMgmtType, "wpa") == 0)
2034 {
Dake Zhao0a832172015-01-06 11:08:47 -08002035 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 key_mgmt WPA-EAP", ifname);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002036 }
2037 else if(strcasecmp(setAKA->keyMgmtType, "wpa2") == 0)
2038 {
Dake Zhao0a832172015-01-06 11:08:47 -08002039 // take all and device to pick one which is supported.
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002040 }
2041 else
2042 {
Dake Zhao0a832172015-01-06 11:08:47 -08002043 // ??
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002044 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002045 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002046
2047 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 proto WPA2", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002048 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002049 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 proto CCMP", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002050 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002051
2052 sprintf(gCmdStr, "wpa_cli -i %s set_network 0 eap AKA", ifname);
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 phase1 \"result_ind=1\"", 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 identity '\"%s\"'", ifname, setAKA->username);
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 password '\"%s\"'", ifname, setAKA->passwd);
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 enable_network 0", ifname);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002065 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002066#endif
2067
2068 setEapAkaResp->status = STATUS_COMPLETE;
2069 wfaEncodeTLV(WFA_STA_SET_EAPAKA_RESP_TLV, 4, (BYTE *)setEapAkaResp, respBuf);
2070 *respLen = WFA_TLV_HDR_LEN + 4;
2071
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002072 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002073}
2074
Ray Wangd11ca032015-05-29 18:25:46 -07002075/* EAP-AKA' */
2076int wfaStaSetEapAKAPrime(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2077{
2078 caStaSetEapAKAPrime_t *setAKAPrime = (caStaSetEapAKAPrime_t *)caCmdBuf;
2079 char *ifname = setAKAPrime->intf;
2080 dutCmdResponse_t *setEapAkaPrimeResp = &gGenericResp;
2081
2082#ifdef WFA_NEW_CLI_FORMAT
2083 sprintf(gCmdStr, "wfa_set_eapakaprime %s %s %s %s", ifname, setAKAPrime->ssid, setAKAPrime->username, setAKAPrime->passwd);
2084 sret = system(gCmdStr);
2085#else
2086
2087 sprintf(gCmdStr, "wpa_cli -i%s remove_network 0", ifname);
2088 sret = system(gCmdStr);
2089
2090 sprintf(gCmdStr, "wpa_cli -i%s add_network", ifname);
2091 sret = system(gCmdStr);
2092
2093 if(strcasecmp(setAKAPrime->keyMgmtType, "wpa2-sha256") == 0)
2094 {
2095 }
2096 else if(strcasecmp(setAKAPrime->keyMgmtType, "wpa2-eap") == 0)
2097 {
2098 }
2099 else if(strcasecmp(setAKAPrime->keyMgmtType, "wpa2-ft") == 0)
2100 {
2101
2102 }
2103 else if(strcasecmp(setAKAPrime->keyMgmtType, "wpa") == 0)
2104 {
2105 sprintf(gCmdStr, "wpa_cli -i%s set_network 0 key_mgmt WPA-EAP", ifname);
2106 }
2107 else if(strcasecmp(setAKAPrime->keyMgmtType, "wpa2") == 0)
2108 {
2109 // take all and device to pick one which is supported.
2110 sprintf(gCmdStr, "wpa_cli -i%s set_network 0 key_mgmt WPA-EAP", ifname);
2111 }
2112 else
2113 {
2114 // ??
2115 setEapAkaPrimeResp->status = STATUS_INVALID;
2116 strcpy(setEapAkaPrimeResp->cmdru.info, "invalid key management parameter");
2117 wfaEncodeTLV(WFA_STA_SET_EAPAKAPRIME_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)setEapAkaPrimeResp, respBuf);
2118 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
2119 return WFA_FAILURE;
2120 }
2121 sret = system(gCmdStr);
2122
2123 sprintf(gCmdStr, "wpa_cli -i%s set_network 0 pairwise CCMP", ifname);
2124 sret = system(gCmdStr);
2125
2126 sprintf(gCmdStr, "wpa_cli -i%s set_network 0 proto WPA2", ifname);
2127 sret = system(gCmdStr);
2128
2129 sprintf(gCmdStr, "wpa_cli -i%s set_network 0 eap AKA\\'", ifname);
2130 printf("eap command=%s\n", gCmdStr);
2131 sret = system(gCmdStr);
2132
2133 sprintf(gCmdStr, "wpa_cli -i%s set_network 0 phase1 '\"result_ind=1\"'", ifname);
2134 sret = system(gCmdStr);
2135
2136 sprintf(gCmdStr, "wpa_cli -i%s set_network 0 identity '\"%s\"'", ifname, setAKAPrime->username);
2137 printf("user name=%s\n", setAKAPrime->username);
2138 sret = system(gCmdStr);
2139
2140 sprintf(gCmdStr, "wpa_cli -i%s set_network 0 password '\"%s\"'", ifname, setAKAPrime->passwd);
2141 printf("password=%s\n", setAKAPrime->passwd);
2142 sret = system(gCmdStr);
2143
2144 sprintf(gCmdStr, "wpa_cli -i%s set_network 0 ssid '\"%s\"'", ifname, setAKAPrime->ssid);
2145 sret = system(gCmdStr);
2146
2147 sprintf(gCmdStr, "wpa_cli -i%s enable_network 0", ifname);
2148 sret = system(gCmdStr);
2149#endif
2150
2151 setEapAkaPrimeResp->status = STATUS_COMPLETE;
2152 wfaEncodeTLV(WFA_STA_SET_EAPAKAPRIME_RESP_TLV, 4, (BYTE *)setEapAkaPrimeResp, respBuf);
2153 *respLen = WFA_TLV_HDR_LEN + 4;
2154
2155 return WFA_SUCCESS;
2156}
2157
Ray Wangcd483d52015-05-29 19:02:48 -07002158/* EAP-PWD */
2159int wfaStaSetEapPWD(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2160{
2161 caStaSetEapPWD_t *setPWD = (caStaSetEapPWD_t *)caCmdBuf;
2162 char *ifname = setPWD->intf;
2163 dutCmdResponse_t *setEapPWDResp = &gGenericResp;
Ray Wangd11ca032015-05-29 18:25:46 -07002164
Ray Wangcd483d52015-05-29 19:02:48 -07002165#ifdef WFA_NEW_CLI_FORMAT
2166 sprintf(gCmdStr, "wfa_set_eappwd %s %s %s %s", ifname, setPWD->ssid, setPWD->username, setPWD->passwd);
2167 sret = system(gCmdStr);
2168#else
2169
2170 sprintf(gCmdStr, "wpa_cli -i%s remove_network 0", ifname);
2171 sret = system(gCmdStr);
2172
2173 sprintf(gCmdStr, "wpa_cli -i%s add_network", ifname);
2174 sret = system(gCmdStr);
2175
2176 if(strcasecmp(setPWD->keyMgmtType, "wpa2-sha256") == 0)
2177 {
2178 }
2179 else if(strcasecmp(setPWD->keyMgmtType, "wpa2-eap") == 0)
2180 {
2181 }
2182 else if(strcasecmp(setPWD->keyMgmtType, "wpa2-ft") == 0)
2183 {
2184
2185 }
2186 else if(strcasecmp(setPWD->keyMgmtType, "wpa") == 0)
2187 {
2188 sprintf(gCmdStr, "wpa_cli -i%s set_network 0 key_mgmt WPA-EAP", ifname);
2189 }
2190 else if(strcasecmp(setPWD->keyMgmtType, "wpa2") == 0)
2191 {
2192 // take all and device to pick one which is supported.
2193 sprintf(gCmdStr, "wpa_cli -i%s set_network 0 key_mgmt WPA-EAP", ifname);
2194 }
2195 else
2196 {
2197 // ??
2198 setEapPWDResp->status = STATUS_INVALID;
2199 strcpy(setEapPWDResp->cmdru.info, "invalid key management parameter");
2200 wfaEncodeTLV(WFA_STA_SET_EAPPWD_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)setEapPWDResp, respBuf);
2201 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
2202 return WFA_FAILURE;
2203 }
2204 sret = system(gCmdStr);
2205
2206 sprintf(gCmdStr, "wpa_cli -i%s set_network 0 pairwise CCMP", ifname);
2207 sret = system(gCmdStr);
2208
2209 sprintf(gCmdStr, "wpa_cli -i%s set_network 0 proto WPA2", ifname);
2210 sret = system(gCmdStr);
2211
2212 sprintf(gCmdStr, "wpa_cli -i%s set_network 0 eap PWD", ifname);
2213 sret = system(gCmdStr);
2214
2215 sprintf(gCmdStr, "wpa_cli -i%s set_network 0 identity '\"%s\"'", ifname, setPWD->username);
2216 sret = system(gCmdStr);
2217
2218 sprintf(gCmdStr, "wpa_cli -i%s set_network 0 password '\"%s\"'", ifname, setPWD->passwd);
2219 sret = system(gCmdStr);
2220
2221 sprintf(gCmdStr, "wpa_cli -i%s set_network 0 ssid '\"%s\"'", ifname, setPWD->ssid);
2222 sret = system(gCmdStr);
2223
2224 sprintf(gCmdStr, "wpa_cli -i%s enable_network 0", ifname);
2225 sret = system(gCmdStr);
2226#endif
2227
2228 setEapPWDResp->status = STATUS_COMPLETE;
2229 wfaEncodeTLV(WFA_STA_SET_EAPPWD_RESP_TLV, 4, (BYTE *)setEapPWDResp, respBuf);
2230 *respLen = WFA_TLV_HDR_LEN + 4;
2231
2232 return WFA_SUCCESS;
2233}
Ray Wangd11ca032015-05-29 18:25:46 -07002234
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002235int wfaStaSetSystime(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2236{
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002237 caStaSetSystime_t *systime = (caStaSetSystime_t *)caCmdBuf;
2238 dutCmdResponse_t *setSystimeResp = &gGenericResp;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002239
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002240 DPRINT_INFO(WFA_OUT, "Entering wfaStaSetSystime ...\n");
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002241
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002242 sprintf(gCmdStr, "date %d-%d-%d",systime->month,systime->date,systime->year);
2243 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002244
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002245 sprintf(gCmdStr, "time %d:%d:%d", systime->hours,systime->minutes,systime->seconds);
2246 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002247
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002248 setSystimeResp->status = STATUS_COMPLETE;
2249 wfaEncodeTLV(WFA_STA_SET_SYSTIME_RESP_TLV, 4, (BYTE *)setSystimeResp, respBuf);
2250 *respLen = WFA_TLV_HDR_LEN + 4;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002251
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002252 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002253}
2254
2255#ifdef WFA_STA_TB
2256int wfaStaPresetParams(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2257{
Dake Zhao0a832172015-01-06 11:08:47 -08002258 dutCmdResponse_t *PresetParamsResp = &gGenericResp;
2259 caStaPresetParameters_t *presetParams = (caStaPresetParameters_t *)caCmdBuf;
2260 BYTE presetDone = 1;
2261 int st = 0;
Ray Wangd11ca032015-05-29 18:25:46 -07002262 char cmdStr[128];
2263 char string[256];
2264 FILE *tmpfd = NULL;
2265 long val;
2266 char *endptr;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002267
Dake Zhao0a832172015-01-06 11:08:47 -08002268 DPRINT_INFO(WFA_OUT, "Inside wfaStaPresetParameters function ...\n");
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002269
Ray Wangd11ca032015-05-29 18:25:46 -07002270 if (presetParams->supplicant == eWpaSupplicant)
2271 {
2272 st = access("/tmp/processid.txt", F_OK);
2273 if (st != -1)
2274 {
2275 st = remove("/tmp/processid.txt");
2276 }
2277
2278 sprintf(cmdStr, "/usr/local/sbin/findprocess.sh %s /tmp/processid.txt\n", "wpa_supplicant");
2279 st = system(cmdStr);
2280
2281 tmpfd = fopen("/tmp/processid.txt", "r+");
2282 if (tmpfd == NULL)
2283 {
2284 DPRINT_ERR(WFA_ERR, "process id file not exist\n");
2285 return WFA_FAILURE;
2286 }
2287
2288 for (;;)
2289 {
2290 if (fgets(string, 256, tmpfd) == NULL)
2291 break;
2292
2293 errno = 0;
2294 val = strtol(string, &endptr, 10);
2295 if (errno != 0 && val == 0)
2296 {
2297 DPRINT_ERR(WFA_ERR, "strtol error\n");
2298 return WFA_FAILURE;
2299 }
2300
2301 if (endptr == string)
2302 {
2303 DPRINT_ERR(WFA_ERR, "No wpa_supplicant instance was found\n");
2304 }
2305
2306 presetDone = 1;
2307 }
2308 }
2309
Dake Zhao0a832172015-01-06 11:08:47 -08002310 if(presetParams->wmmFlag)
2311 {
2312 st = wfaExecuteCLI(gCmdStr);
2313 switch(st)
2314 {
2315 case 0:
2316 presetDone = 1;
2317 break;
2318 case 1:
2319 presetDone = 0;
2320 break;
2321 case 2:
2322 presetDone = 0;
2323 break;
2324 }
2325 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002326
Dake Zhao0a832172015-01-06 11:08:47 -08002327 if(presetParams->modeFlag != 0)
2328 {
2329 switch(presetParams->wirelessMode)
2330 {
2331 default:
2332 printf("other mode does not need to support\n");
2333 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002334
Dake Zhao0a832172015-01-06 11:08:47 -08002335 st = wfaExecuteCLI(gCmdStr);
2336 switch(st)
2337 {
2338 case 0:
2339 presetDone = 1;
2340 break;
2341 case 1:
2342 presetDone = 0;
2343 case 2:
2344 presetDone = 0;
2345 break;
2346 }
2347 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002348
2349
Dake Zhao0a832172015-01-06 11:08:47 -08002350 if(presetParams->psFlag)
2351 {
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002352
Dake Zhao0a832172015-01-06 11:08:47 -08002353 printf("%s\n", gCmdStr);
2354 sret = system(gCmdStr);
2355 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002356
Dake Zhao0a832172015-01-06 11:08:47 -08002357 /************the followings are used for Voice Enterprise **************/
2358 if(presetParams->program == PROG_TYPE_VENT)
2359 {
2360 if(presetParams->ftoa == eEnable)
2361 {
2362 // enable Fast BSS Transition Over the Air
2363 }
2364 else
2365 {
2366 // disable Fast BSS Transition Over the Air
2367 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002368
Dake Zhao0a832172015-01-06 11:08:47 -08002369 if(presetParams->ftds == eEnable)
2370 {
2371 // enable Fast BSS Transition Over the DS
2372 }
2373 else
2374 {
2375 // disable Fast BSS Transition Over the DS
2376 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002377
Dake Zhao0a832172015-01-06 11:08:47 -08002378 if(presetParams->activescan == eEnable)
2379 {
2380 // Enable Active Scan on STA
2381 }
2382 else
2383 {
2384 // disable Active Scan on STA
2385 }
2386 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002387
Dake Zhao0a832172015-01-06 11:08:47 -08002388 /************the followings are used for Wi-Fi Display *************/
2389 if(presetParams->program == PROG_TYPE_WFD)
2390 {
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002391
Dake Zhao0a832172015-01-06 11:08:47 -08002392 if(presetParams->tdlsFlag)
2393 {
2394 // enable / disable tdls based on tdls
2395 }
2396 if(presetParams->wfdDevTypeFlag)
2397 {
2398 // set WFD device type to source/sink/dual based on wfdDevType
2399 }
2400 if(presetParams->wfdUibcGenFlag)
2401 {
2402 // enable / disable the feature
2403 }
2404 if(presetParams->wfdUibcHidFlag)
2405 {
2406 // enable / disable feature
2407 }
2408 if(presetParams->wfdUiInputFlag)
2409 {
2410 // set the UI input as mentioned
2411 }
2412 if(presetParams->wfdHdcpFlag)
2413 {
2414 // enable / disable feature
2415 }
2416 if(presetParams->wfdFrameSkipFlag)
2417 {
2418 // enable / disable feature
2419 }
2420 if(presetParams->wfdAvChangeFlag)
2421 {
2422 // enable / disable feature
2423 }
2424 if(presetParams->wfdStandByFlag)
2425 {
2426 // enable / disable feature
2427 }
2428 if(presetParams->wfdInVideoFlag)
2429 {
2430 // select the input vide as protecteed or non-protetcted or protected audio
2431 // or unprotected audio etc.
2432 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002433
Dake Zhao0a832172015-01-06 11:08:47 -08002434 if(presetParams->wfdVideoFmatFlag)
2435 {
2436 // set the video format as requested
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002437
Dake Zhao0a832172015-01-06 11:08:47 -08002438 //switch(presetParams->wfdVideoFmt )
2439 //{
2440 // case e640x480p60:
2441 // ;
2442 // default:
2443 // set the mandatory
2444 // }
2445 }
2446 if(presetParams->wfdAudioFmatFlag)
2447 {
2448 // set the Audio format as requested
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002449
Dake Zhao0a832172015-01-06 11:08:47 -08002450 //switch(presetParams->wfdAudioFmt )
2451 //{
2452 // case eMandatoryAudioMode:
2453 // ;
2454 // case eDefaultAudioMode:
2455 // ;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002456
Dake Zhao0a832172015-01-06 11:08:47 -08002457 // default:
2458 // set the mandatory
2459 // }
2460 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002461
Dake Zhao0a832172015-01-06 11:08:47 -08002462 if(presetParams->wfdI2cFlag)
2463 {
2464 // enable / disable feature
2465 }
2466 if(presetParams->wfdVideoRecoveryFlag)
2467 {
2468 // enable / disable feature
2469 }
2470 if(presetParams->wfdPrefDisplayFlag)
2471 {
2472 // enable / disable feature
2473 }
2474 if(presetParams->wfdServiceDiscoveryFlag)
2475 {
2476 // enable / disable feature
2477 }
2478 if(presetParams->wfd3dVideoFlag)
2479 {
2480 // enable / disable feature
2481 }
2482 if(presetParams->wfdMultiTxStreamFlag)
2483 {
2484 // enable / disable feature
2485 }
2486 if(presetParams->wfdTimeSyncFlag)
2487 {
2488 // enable / disable feature
2489 }
2490 if(presetParams->wfdEDIDFlag)
2491 {
2492 // enable / disable feature
2493 }
2494 if(presetParams->wfdUIBCPrepareFlag)
2495 {
2496 // Provdes information to start valid WFD session to check UIBC operation.
2497 }
2498 if(presetParams->wfdCoupledCapFlag)
2499 {
2500 // enable / disable feature
2501 }
2502 if(presetParams->wfdOptionalFeatureFlag)
2503 {
2504 // disable all program specific optional features
2505 }
2506 if(presetParams->wfdSessionAvailFlag)
2507 {
2508 // enable / disable session available bit
2509 }
2510 if(presetParams->wfdDeviceDiscoverabilityFlag)
2511 {
2512 // enable / disable feature
2513 }
2514 }
2515
Dake Zhao655efed2015-03-11 17:39:13 -07002516 if(presetParams->program == PROG_TYPE_WFDS)
2517 {
2518
2519 if(presetParams->wfdsType == eAcceptPD)
2520 {
2521 // preset to accept PD request
2522 if (presetParams->wfdsConnectionCapabilityFlag == 1)
2523 {
2524 // use presetParams->wfdsConnectionCapability and set role accordingly
2525 }
2526
2527 }
2528 if(presetParams->wfdsType == eRejectPD)
2529 {
2530 // preset to Reject PD request
2531 }
2532 if(presetParams->wfdsType == eIgnorePD)
2533 {
2534 // preset to Ignore PD request
2535 }
2536 if(presetParams->wfdsType == eRejectSession)
2537 {
2538 // preset to reject Session request
2539 }
2540
2541 }
2542
2543 if (presetDone)
2544 {
2545 PresetParamsResp->status = STATUS_COMPLETE;
2546 }
2547 else
2548 {
2549 PresetParamsResp->status = STATUS_INVALID;
2550 }
Dake Zhao0a832172015-01-06 11:08:47 -08002551
2552 wfaEncodeTLV(WFA_STA_PRESET_PARAMETERS_RESP_TLV, 4, (BYTE *)PresetParamsResp, respBuf);
2553 *respLen = WFA_TLV_HDR_LEN + 4;
2554
2555 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002556}
2557
2558int wfaStaSet11n(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2559{
2560 dutCmdResponse_t *v11nParamsResp = &gGenericResp;
2561
2562 v11nParamsResp->status = STATUS_COMPLETE;
2563 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, 4, (BYTE *)v11nParamsResp, respBuf);
2564 *respLen = WFA_TLV_HDR_LEN + 4;
2565 return WFA_SUCCESS;
2566}
2567int wfaStaSetWireless(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2568{
2569 dutCmdResponse_t *staWirelessResp = &gGenericResp;
2570
2571 staWirelessResp->status = STATUS_COMPLETE;
2572 wfaEncodeTLV(WFA_STA_SET_WIRELESS_RESP_TLV, 4, (BYTE *)staWirelessResp, respBuf);
2573 *respLen = WFA_TLV_HDR_LEN + 4;
2574 return WFA_SUCCESS;
2575}
2576
2577int wfaStaSendADDBA(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2578{
2579 dutCmdResponse_t *staSendADDBAResp = &gGenericResp;
2580
2581 wfaEncodeTLV(WFA_STA_SET_SEND_ADDBA_RESP_TLV, 4, (BYTE *)staSendADDBAResp, respBuf);
2582 *respLen = WFA_TLV_HDR_LEN + 4;
2583 return WFA_SUCCESS;
2584}
2585
2586int wfaStaSetRIFS(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2587{
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002588 dutCmdResponse_t *staSetRIFSResp = &gGenericResp;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002589
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002590 wfaEncodeTLV(WFA_STA_SET_RIFS_TEST_RESP_TLV, 4, (BYTE *)staSetRIFSResp, respBuf);
2591 *respLen = WFA_TLV_HDR_LEN + 4;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002592
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002593 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002594}
2595
2596int wfaStaSendCoExistMGMT(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2597{
2598 dutCmdResponse_t *staSendMGMTResp = &gGenericResp;
2599
2600 wfaEncodeTLV(WFA_STA_SEND_COEXIST_MGMT_RESP_TLV, 4, (BYTE *)staSendMGMTResp, respBuf);
2601 *respLen = WFA_TLV_HDR_LEN + 4;
2602
2603 return WFA_SUCCESS;
2604
2605}
2606
2607int wfaStaResetDefault(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2608{
Dake Zhao0a832172015-01-06 11:08:47 -08002609 caStaResetDefault_t *reset = (caStaResetDefault_t *)caCmdBuf;
2610 dutCmdResponse_t *ResetResp = &gGenericResp;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002611
2612
Dake Zhao0a832172015-01-06 11:08:47 -08002613 // need to make your own command available for this, here is only an example
2614 sprintf(gCmdStr, "myresetdefault %s program %s", reset->intf, reset->prog);
2615 sret = system(gCmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002616
Dake Zhao0a832172015-01-06 11:08:47 -08002617 ResetResp->status = STATUS_COMPLETE;
2618 wfaEncodeTLV(WFA_STA_RESET_DEFAULT_RESP_TLV, 4, (BYTE *)ResetResp, respBuf);
2619 *respLen = WFA_TLV_HDR_LEN + 4;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002620
Dake Zhao0a832172015-01-06 11:08:47 -08002621 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002622}
2623
2624#else
2625
2626int wfaStaTestBedCmd(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2627{
2628 dutCmdResponse_t *staCmdResp = &gGenericResp;
2629
2630 wfaEncodeTLV(WFA_STA_DISCONNECT_RESP_TLV, 4, (BYTE *)staCmdResp, respBuf);
2631 *respLen = WFA_TLV_HDR_LEN + 4;
2632
2633 return WFA_SUCCESS;
2634}
2635#endif
2636
2637/*
2638 * This is used to send a frame or action frame
2639 */
Ankur Vachhanic485b712012-02-15 23:29:49 +00002640int wfaStaDevSendFrame(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002641{
Dake Zhao0a832172015-01-06 11:08:47 -08002642 dutCommand_t *cmd = (dutCommand_t *)caCmdBuf;
2643 /* uncomment it if needed */
2644 // char *ifname = cmd->intf;
2645 dutCmdResponse_t *devSendResp = &gGenericResp;
2646 caStaDevSendFrame_t *sf = &cmd->cmdsu.sf;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002647
Dake Zhao0a832172015-01-06 11:08:47 -08002648 DPRINT_INFO(WFA_OUT, "Inside wfaStaDevSendFrame function ...\n");
2649 /* processing the frame */
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002650
Dake Zhao0a832172015-01-06 11:08:47 -08002651 switch(sf->program)
2652 {
2653 case PROG_TYPE_PMF:
2654 {
2655 pmfFrame_t *pmf = &sf->frameType.pmf;
2656 switch(pmf->eFrameName)
2657 {
2658 case PMF_TYPE_DISASSOC:
2659 {
2660 /* use the protected to set what type of key to send */
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002661
Dake Zhao0a832172015-01-06 11:08:47 -08002662 }
2663 break;
2664 case PMF_TYPE_DEAUTH:
2665 {
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002666
Dake Zhao0a832172015-01-06 11:08:47 -08002667 }
2668 break;
2669 case PMF_TYPE_SAQUERY:
2670 {
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002671
Dake Zhao0a832172015-01-06 11:08:47 -08002672 }
2673 break;
2674 case PMF_TYPE_AUTH:
2675 {
2676 }
2677 break;
2678 case PMF_TYPE_ASSOCREQ:
2679 {
2680 }
2681 break;
2682 case PMF_TYPE_REASSOCREQ:
2683 {
2684 }
2685 break;
2686 }
2687 }
2688 break;
2689 case PROG_TYPE_TDLS:
2690 {
2691 tdlsFrame_t *tdls = &sf->frameType.tdls;
2692 switch(tdls->eFrameName)
2693 {
2694 case TDLS_TYPE_DISCOVERY:
2695 /* use the peer mac address to send the frame */
2696 break;
2697 case TDLS_TYPE_SETUP:
2698 break;
2699 case TDLS_TYPE_TEARDOWN:
2700 break;
2701 case TDLS_TYPE_CHANNELSWITCH:
2702 break;
2703 case TDLS_TYPE_NULLFRAME:
2704 break;
2705 }
2706 }
2707 break;
2708 case PROG_TYPE_VENT:
2709 {
2710 ventFrame_t *vent = &sf->frameType.vent;
2711 switch(vent->type)
2712 {
2713 case VENT_TYPE_NEIGREQ:
2714 break;
2715 case VENT_TYPE_TRANSMGMT:
2716 break;
2717 }
2718 }
2719 break;
2720 case PROG_TYPE_WFD:
2721 {
2722 wfdFrame_t *wfd = &sf->frameType.wfd;
2723 switch(wfd->eframe)
2724 {
2725 case WFD_FRAME_PRBREQ:
2726 {
2727 /* send probe req */
2728 }
2729 break;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002730
Dake Zhao0a832172015-01-06 11:08:47 -08002731 case WFD_FRAME_PRBREQ_TDLS_REQ:
2732 {
2733 /* send tunneled tdls probe req */
2734 }
2735 break;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002736
Dake Zhao0a832172015-01-06 11:08:47 -08002737 case WFD_FRAME_11V_TIMING_MSR_REQ:
2738 {
2739 /* send 11v timing mearurement request */
2740 }
2741 break;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002742
Dake Zhao0a832172015-01-06 11:08:47 -08002743 case WFD_FRAME_RTSP:
2744 {
2745 /* send WFD RTSP messages*/
2746 // fetch the type of RTSP message and send it.
2747 switch(wfd->eRtspMsgType)
2748 {
2749 case WFD_RTSP_PAUSE:
2750 break;
2751 case WFD_RTSP_PLAY:
2752 //send RTSP PLAY
2753 break;
2754 case WFD_RTSP_TEARDOWN:
2755 //send RTSP TEARDOWN
2756 break;
2757 case WFD_RTSP_TRIG_PAUSE:
2758 //send RTSP TRIGGER PAUSE
2759 break;
2760 case WFD_RTSP_TRIG_PLAY:
2761 //send RTSP TRIGGER PLAY
2762 break;
2763 case WFD_RTSP_TRIG_TEARDOWN:
2764 //send RTSP TRIGGER TEARDOWN
2765 break;
2766 case WFD_RTSP_SET_PARAMETER:
2767 //send RTSP SET PARAMETER
2768 if (wfd->eSetParams == WFD_CAP_UIBC_KEYBOARD)
2769 {
2770 //send RTSP SET PARAMETER message for UIBC keyboard
2771 }
2772 if (wfd->eSetParams == WFD_CAP_UIBC_MOUSE)
2773 {
2774 //send RTSP SET PARAMETER message for UIBC Mouse
2775 }
2776 else if (wfd->eSetParams == WFD_CAP_RE_NEGO)
2777 {
2778 //send RTSP SET PARAMETER message Capability re-negotiation
2779 }
2780 else if (wfd->eSetParams == WFD_STANDBY)
2781 {
2782 //send RTSP SET PARAMETER message for standby
2783 }
2784 else if (wfd->eSetParams == WFD_UIBC_SETTINGS_ENABLE)
2785 {
2786 //send RTSP SET PARAMETER message for UIBC settings enable
2787 }
2788 else if (wfd->eSetParams == WFD_UIBC_SETTINGS_DISABLE)
2789 {
2790 //send RTSP SET PARAMETER message for UIBC settings disable
2791 }
2792 else if (wfd->eSetParams == WFD_ROUTE_AUDIO)
2793 {
2794 //send RTSP SET PARAMETER message for route audio
2795 }
2796 else if (wfd->eSetParams == WFD_3D_VIDEOPARAM)
2797 {
2798 //send RTSP SET PARAMETER message for 3D video parameters
2799 }
2800 else if (wfd->eSetParams == WFD_2D_VIDEOPARAM)
2801 {
2802 //send RTSP SET PARAMETER message for 2D video parameters
2803 }
2804 break;
Dake Zhao97708202014-11-26 13:59:04 -08002805 }
Dake Zhao0a832172015-01-06 11:08:47 -08002806 }
2807 break;
2808 }
2809 }
2810 break;
2811 /* not need to support HS2 release 1, due to very short time period */
2812 case PROG_TYPE_HS2_R2:
2813 {
2814 /* type of frames */
2815 hs2Frame_t *hs2 = &sf->frameType.hs2_r2;
2816 switch(hs2->eframe)
2817 {
2818 case HS2_FRAME_ANQPQuery:
2819 {
Dake Zhao97708202014-11-26 13:59:04 -08002820
Dake Zhao0a832172015-01-06 11:08:47 -08002821 }
2822 break;
2823 case HS2_FRAME_DLSRequest:
2824 {
Dake Zhao97708202014-11-26 13:59:04 -08002825
Dake Zhao0a832172015-01-06 11:08:47 -08002826 }
2827 break;
2828 case HS2_FRAME_GARPReq:
2829 {
Dake Zhao97708202014-11-26 13:59:04 -08002830
Dake Zhao0a832172015-01-06 11:08:47 -08002831 }
2832 break;
2833 case HS2_FRAME_GARPRes:
2834 {
2835 }
2836 break;
2837 case HS2_FRAME_NeighAdv:
2838 {
2839 }
2840 case HS2_FRAME_ARPProbe:
2841 {
2842 }
2843 case HS2_FRAME_ARPAnnounce:
2844 {
Dake Zhao97708202014-11-26 13:59:04 -08002845
Dake Zhao0a832172015-01-06 11:08:47 -08002846 }
2847 break;
2848 case HS2_FRAME_NeighSolicitReq:
2849 {
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002850
Dake Zhao0a832172015-01-06 11:08:47 -08002851 }
2852 break;
2853 case HS2_FRAME_ARPReply:
2854 {
2855
2856 }
2857 break;
2858 }
2859
2860 }/* PROG_TYPE_HS2-R2 */
2861 case PROG_TYPE_GEN:
2862 {
2863 /* General frames */
2864 }
2865
2866
2867 }
2868 devSendResp->status = STATUS_COMPLETE;
2869 wfaEncodeTLV(WFA_STA_DEV_SEND_FRAME_RESP_TLV, 4, (BYTE *)devSendResp, respBuf);
2870 *respLen = WFA_TLV_HDR_LEN + 4;
2871
2872 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002873}
2874
2875/*
2876 * This is used to set a temporary MAC address of an interface
2877 */
2878int wfaStaSetMacAddr(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2879{
Dake Zhao0a832172015-01-06 11:08:47 -08002880 // Uncomment it if needed
2881 //dutCommand_t *cmd = (dutCommand_t *)caCmdBuf;
2882 // char *ifname = cmd->intf;
2883 dutCmdResponse_t *staCmdResp = &gGenericResp;
2884 // Uncomment it if needed
2885 //char *macaddr = &cmd->cmdsu.macaddr[0];
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002886
Dake Zhao0a832172015-01-06 11:08:47 -08002887 wfaEncodeTLV(WFA_STA_SET_MAC_ADDRESS_RESP_TLV, 4, (BYTE *)staCmdResp, respBuf);
2888 *respLen = WFA_TLV_HDR_LEN + 4;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002889
Dake Zhao0a832172015-01-06 11:08:47 -08002890 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002891}
2892
2893
2894int wfaStaDisconnect(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
2895{
2896 //dutCommand_t *disc = (dutCommand_t *)caCmdBuf;
2897 //char *intf = disc->intf;
2898 dutCmdResponse_t *staDiscResp = &gGenericResp;
2899
2900 // stop the supplicant
2901
2902 staDiscResp->status = STATUS_COMPLETE;
2903
2904 wfaEncodeTLV(WFA_STA_DISCONNECT_RESP_TLV, 4, (BYTE *)staDiscResp, respBuf);
2905 *respLen = WFA_TLV_HDR_LEN + 4;
2906
2907 return WFA_SUCCESS;
2908}
2909
2910/* Execute CLI, read the status from Environment variable */
2911int wfaExecuteCLI(char *CLI)
2912{
Dake Zhao0a832172015-01-06 11:08:47 -08002913 char *retstr;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002914
Dake Zhao0a832172015-01-06 11:08:47 -08002915 sret = system(CLI);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002916
Dake Zhao0a832172015-01-06 11:08:47 -08002917 retstr = getenv("WFA_CLI_STATUS");
2918 printf("cli status %s\n", retstr);
2919 return atoi(retstr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002920}
2921
2922/* Supporting Functions */
2923
2924void wfaSendPing(tgPingStart_t *staPing, float *interval, int streamid)
2925{
Dake Zhao97708202014-11-26 13:59:04 -08002926 int totalpkts, tos=-1;
Naveen Kumard549d4b2014-03-13 10:56:56 -07002927 char cmdStr[256];
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002928// char *addr = staPing->dipaddr;
2929#ifdef WFA_PC_CONSOLE
Naveen Kumard549d4b2014-03-13 10:56:56 -07002930 char addr[40];
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002931 char bflag[] = "-b";
2932 char *tmpstr;
2933 int inum=0;
2934#else
2935 char bflag[] = " ";
2936#endif
Dake Zhao0a832172015-01-06 11:08:47 -08002937
Ray Wang9b47f362014-03-19 16:51:10 -07002938 totalpkts = (int)(staPing->duration * staPing->frameRate);
Dake Zhao0a832172015-01-06 11:08:47 -08002939
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002940#ifdef WFA_PC_CONSOLE
2941
2942 printf("\nCS : The Stream ID is %d",streamid);
2943 printf("\nCS :the addr is %s ",addr);
2944 strcpy(addr,staPing->dipaddr);
2945 printf("\nCS :Inside the WFA_PC_CONSLE BLOCK");
2946 printf("\nCS :the addr is %s ",addr);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002947 if (staPing->iptype == 2)
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002948 {
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002949 memset(bflag, 0, strlen(bflag));
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002950 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002951 else
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002952 {
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002953 tmpstr = strtok(addr, ".");
2954 inum = atoi(tmpstr);
2955
2956 printf("interval %f\n", *interval);
2957
2958 if(inum >= 224 && inum <= 239) // multicast
2959 {
2960 }
2961 else // if not MC, check if it is BC address
2962 {
2963 printf("\nCS :Inside the BC address BLOCK");
2964 printf("\nCS :the inum %d",inum);
2965 strtok(NULL, ".");
2966 //strtok(NULL, ".");
2967 tmpstr = strtok(NULL, ".");
2968 printf("tmpstr %s\n", tmpstr);
2969 inum = atoi(tmpstr);
2970 printf("\nCS : The string is %s",tmpstr);
2971 if(inum != 255)
Dake Zhao0a832172015-01-06 11:08:47 -08002972 memset(bflag, 0, strlen(bflag));
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002973 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002974 }
2975#endif
Dake Zhao97708202014-11-26 13:59:04 -08002976 if ( staPing->dscp >= 0)
2977 {
Dake Zhao0a832172015-01-06 11:08:47 -08002978 tos= convertDscpToTos(staPing->dscp);
2979 if (tos < 0)
Dake Zhao97708202014-11-26 13:59:04 -08002980 printf("\nwfaSendPing invalid tos converted, dscp=%d", staPing->dscp);
2981 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00002982 printf("\nCS : The Stream ID is %d",streamid);
Dake Zhao97708202014-11-26 13:59:04 -08002983 printf("IPtype : %i tos=%d",staPing->iptype, tos);
Dake Zhao0a832172015-01-06 11:08:47 -08002984
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002985 if (staPing->iptype == 2)
Dake Zhao0a832172015-01-06 11:08:47 -08002986 {
Dake Zhao97708202014-11-26 13:59:04 -08002987 if ( tos>0)
Dake Zhao0a832172015-01-06 11:08:47 -08002988 sprintf(cmdStr, "echo streamid=%i > /tmp/spout_%d.txt;wfaping6.sh %s %s -i %f -c %i -Q %d -s %i -q >> /tmp/spout_%d.txt 2>/dev/null",
2989 streamid,streamid,bflag, staPing->dipaddr, *interval, totalpkts, tos, staPing->frameSize,streamid);
Dake Zhao97708202014-11-26 13:59:04 -08002990 else
Dake Zhao0a832172015-01-06 11:08:47 -08002991 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",
2992 streamid,streamid,bflag, staPing->dipaddr, *interval, totalpkts, staPing->frameSize,streamid);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08002993 sret = system(cmdStr);
2994 printf("\nCS : The command string is %s",cmdStr);
2995 }
2996 else
2997 {
Dake Zhao97708202014-11-26 13:59:04 -08002998 if (tos > 0)
Dake Zhao0a832172015-01-06 11:08:47 -08002999 sprintf(cmdStr, "echo streamid=%i > /tmp/spout_%d.txt;wfaping.sh %s %s -i %f -c %i -Q %d -s %i -q >> /tmp/spout_%d.txt 2>/dev/null",
3000 streamid,streamid,bflag, staPing->dipaddr, *interval, totalpkts, tos, staPing->frameSize,streamid);
Dake Zhao97708202014-11-26 13:59:04 -08003001 else
Dake Zhao0a832172015-01-06 11:08:47 -08003002 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",
3003 streamid,streamid,bflag, staPing->dipaddr, *interval, totalpkts, staPing->frameSize,streamid);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003004 sret = system(cmdStr);
3005 printf("\nCS : The command string is %s",cmdStr);
Dake Zhao0a832172015-01-06 11:08:47 -08003006 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00003007 sprintf(cmdStr, "updatepid.sh /tmp/spout_%d.txt",streamid);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003008 sret = system(cmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00003009 printf("\nCS : The command string is %s",cmdStr);
3010
3011}
3012
3013int wfaStopPing(dutCmdResponse_t *stpResp, int streamid)
3014{
3015 char strout[256];
3016 FILE *tmpfile = NULL;
3017 char cmdStr[128];
3018 printf("Ping stop id %d\n", streamid);
3019 sprintf(cmdStr, "getpid.sh /tmp/spout_%d.txt /tmp/pid.txt",streamid);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003020 sret = system(cmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00003021
3022 printf("\nCS : The command string is %s",cmdStr);
3023
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003024 sret = system("stoping.sh /tmp/pid.txt ; sleep 2");
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00003025
3026 sprintf(cmdStr, "getpstats.sh /tmp/spout_%d.txt",streamid);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003027 sret = system(cmdStr);
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00003028
3029 printf("\nCS : The command string is %s",cmdStr);
3030
3031 tmpfile = fopen("/tmp/stpsta.txt", "r+");
3032
3033 if(tmpfile == NULL)
3034 {
3035 return WFA_FAILURE;
3036 }
3037
3038 if(fscanf(tmpfile, "%s", strout) != EOF)
3039 {
3040 if(*strout == '\0')
3041 {
3042 stpResp->cmdru.pingStp.sendCnt = 0;
3043 }
3044
3045 else
3046 stpResp->cmdru.pingStp.sendCnt = atoi(strout);
3047 }
3048
3049 printf("after scan sent count %i\n", stpResp->cmdru.pingStp.sendCnt);
3050
3051
3052 if(fscanf(tmpfile, "%s", strout) != EOF)
3053 {
3054 if(*strout == '\0')
3055 {
3056 stpResp->cmdru.pingStp.repliedCnt = 0;
3057 }
3058 else
3059 stpResp->cmdru.pingStp.repliedCnt = atoi(strout);
3060 }
3061 printf("after scan replied count %i\n", stpResp->cmdru.pingStp.repliedCnt);
3062
3063 fclose(tmpfile);
3064
3065 return WFA_SUCCESS;
3066}
3067
Ankur Vachhanic485b712012-02-15 23:29:49 +00003068/*
Dake Zhao0a832172015-01-06 11:08:47 -08003069 * wfaStaGetP2pDevAddress():
Ankur Vachhanic485b712012-02-15 23:29:49 +00003070 */
3071int wfaStaGetP2pDevAddress(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3072{
Dake Zhao0a832172015-01-06 11:08:47 -08003073 dutCmdResponse_t infoResp;
3074 /* dutCommand_t *getInfo = (dutCommand_t *)caCmdBuf; */
Ankur Vachhanic485b712012-02-15 23:29:49 +00003075
Dake Zhao0a832172015-01-06 11:08:47 -08003076 printf("\n Entry wfaStaGetP2pDevAddress... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003077
Dake Zhao0a832172015-01-06 11:08:47 -08003078 // Fetch the device ID and store into infoResp->cmdru.devid
3079 //strcpy(infoResp->cmdru.devid, str);
3080 strcpy(&infoResp.cmdru.devid[0], "ABCDEFGH");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003081
Dake Zhao0a832172015-01-06 11:08:47 -08003082 infoResp.status = STATUS_COMPLETE;
3083 wfaEncodeTLV(WFA_STA_P2P_GET_DEV_ADDRESS_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3084 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3085
3086 return WFA_SUCCESS;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003087}
3088
3089
3090
3091/*
Dake Zhao0a832172015-01-06 11:08:47 -08003092 * wfaStaSetP2p():
Ankur Vachhanic485b712012-02-15 23:29:49 +00003093 */
3094int wfaStaSetP2p(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3095{
Dake Zhao0a832172015-01-06 11:08:47 -08003096 dutCmdResponse_t infoResp;
3097 /* caStaSetP2p_t *getStaSetP2p = (caStaSetP2p_t *)caCmdBuf; uncomment and use it*/
Ankur Vachhanic485b712012-02-15 23:29:49 +00003098
Dake Zhao0a832172015-01-06 11:08:47 -08003099 printf("\n Entry wfaStaSetP2p... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003100
Dake Zhao0a832172015-01-06 11:08:47 -08003101 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003102
Dake Zhao0a832172015-01-06 11:08:47 -08003103 infoResp.status = STATUS_COMPLETE;
3104 wfaEncodeTLV(WFA_STA_P2P_SETP2P_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3105 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3106
3107 return WFA_SUCCESS;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003108}
3109/*
Dake Zhao0a832172015-01-06 11:08:47 -08003110 * wfaStaP2pConnect():
Ankur Vachhanic485b712012-02-15 23:29:49 +00003111 */
3112int wfaStaP2pConnect(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3113{
Dake Zhao0a832172015-01-06 11:08:47 -08003114 dutCmdResponse_t infoResp;
3115 /* caStaP2pConnect_t *getStaP2pConnect = (caStaP2pConnect_t *)caCmdBuf; uncomment and use it */
Ankur Vachhanic485b712012-02-15 23:29:49 +00003116
Dake Zhao0a832172015-01-06 11:08:47 -08003117 printf("\n Entry wfaStaP2pConnect... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003118
Dake Zhao0a832172015-01-06 11:08:47 -08003119 // Implement the function and does not return anything.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003120
Ankur Vachhanic485b712012-02-15 23:29:49 +00003121
Dake Zhao0a832172015-01-06 11:08:47 -08003122 infoResp.status = STATUS_COMPLETE;
3123 wfaEncodeTLV(WFA_STA_P2P_CONNECT_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3124 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3125
3126 return WFA_SUCCESS;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003127}
3128
3129/*
Dake Zhao0a832172015-01-06 11:08:47 -08003130 * wfaStaStartAutoGo():
Ankur Vachhanic485b712012-02-15 23:29:49 +00003131 */
3132int wfaStaStartAutoGo(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3133{
Dake Zhao0a832172015-01-06 11:08:47 -08003134 dutCmdResponse_t infoResp;
3135 //caStaStartAutoGo_t *getStaStartAutoGo = (caStaStartAutoGo_t *)caCmdBuf;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003136
Dake Zhao0a832172015-01-06 11:08:47 -08003137 printf("\n Entry wfaStaStartAutoGo... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003138
Dake Zhao0a832172015-01-06 11:08:47 -08003139 // Fetch the group ID and store into infoResp->cmdru.grpid
3140 strcpy(&infoResp.cmdru.grpid[0], "ABCDEFGH");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003141
Dake Zhao0a832172015-01-06 11:08:47 -08003142 infoResp.status = STATUS_COMPLETE;
3143 wfaEncodeTLV(WFA_STA_P2P_START_AUTO_GO_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3144 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3145
3146 return WFA_SUCCESS;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003147}
3148
3149
3150
3151
3152/*
Dake Zhao0a832172015-01-06 11:08:47 -08003153 * wfaStaP2pStartGrpFormation():
Ankur Vachhanic485b712012-02-15 23:29:49 +00003154 */
3155int wfaStaP2pStartGrpFormation(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3156{
Dake Zhao0a832172015-01-06 11:08:47 -08003157 dutCmdResponse_t infoResp;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003158
Dake Zhao0a832172015-01-06 11:08:47 -08003159 printf("\n Entry wfaStaP2pStartGrpFormation... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003160
Dake Zhao0a832172015-01-06 11:08:47 -08003161 strcpy(infoResp.cmdru.grpFormInfo.result, "CLIENT");
3162 strcpy(infoResp.cmdru.grpFormInfo.grpId, "AA:BB:CC:DD:EE:FF_DIRECT-SSID");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003163
Ankur Vachhanic485b712012-02-15 23:29:49 +00003164
Dake Zhao0a832172015-01-06 11:08:47 -08003165 infoResp.status = STATUS_COMPLETE;
3166 wfaEncodeTLV(WFA_STA_P2P_START_GRP_FORMATION_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3167 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3168
3169 return WFA_SUCCESS;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003170}
3171
3172
3173/*
Dake Zhao0a832172015-01-06 11:08:47 -08003174 * wfaStaP2pDissolve():
Ankur Vachhanic485b712012-02-15 23:29:49 +00003175 */
3176int wfaStaP2pDissolve(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3177{
Dake Zhao0a832172015-01-06 11:08:47 -08003178 dutCmdResponse_t infoResp;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003179
Dake Zhao0a832172015-01-06 11:08:47 -08003180 printf("\n Entry wfaStaP2pDissolve... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003181
Dake Zhao0a832172015-01-06 11:08:47 -08003182 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003183
Dake Zhao0a832172015-01-06 11:08:47 -08003184 infoResp.status = STATUS_COMPLETE;
3185 wfaEncodeTLV(WFA_STA_P2P_DISSOLVE_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3186 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3187
3188 return WFA_SUCCESS;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003189}
3190
3191/*
Dake Zhao0a832172015-01-06 11:08:47 -08003192 * wfaStaSendP2pInvReq():
Ankur Vachhanic485b712012-02-15 23:29:49 +00003193 */
3194int wfaStaSendP2pInvReq(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3195{
Dake Zhao0a832172015-01-06 11:08:47 -08003196 dutCmdResponse_t infoResp;
3197 /* caStaSendP2pInvReq_t *getStaP2pInvReq= (caStaSendP2pInvReq_t *)caCmdBuf; */
Ankur Vachhanic485b712012-02-15 23:29:49 +00003198
Dake Zhao0a832172015-01-06 11:08:47 -08003199 printf("\n Entry wfaStaSendP2pInvReq... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003200
Dake Zhao0a832172015-01-06 11:08:47 -08003201 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003202
Dake Zhao0a832172015-01-06 11:08:47 -08003203 infoResp.status = STATUS_COMPLETE;
3204 wfaEncodeTLV(WFA_STA_P2P_SEND_INV_REQ_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3205 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3206
3207 return WFA_SUCCESS;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003208}
3209
3210
3211/*
Dake Zhao0a832172015-01-06 11:08:47 -08003212 * wfaStaAcceptP2pInvReq():
Ankur Vachhanic485b712012-02-15 23:29:49 +00003213 */
3214int wfaStaAcceptP2pInvReq(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3215{
Dake Zhao0a832172015-01-06 11:08:47 -08003216 dutCmdResponse_t infoResp;
3217 /* uncomment and use it
3218 * caStaAcceptP2pInvReq_t *getStaP2pInvReq= (caStaAcceptP2pInvReq_t *)caCmdBuf;
3219 */
Ankur Vachhanic485b712012-02-15 23:29:49 +00003220
Dake Zhao0a832172015-01-06 11:08:47 -08003221 printf("\n Entry wfaStaAcceptP2pInvReq... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003222
Dake Zhao0a832172015-01-06 11:08:47 -08003223 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003224
Dake Zhao0a832172015-01-06 11:08:47 -08003225 infoResp.status = STATUS_COMPLETE;
3226 wfaEncodeTLV(WFA_STA_P2P_ACCEPT_INV_REQ_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3227 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3228
3229 return WFA_SUCCESS;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003230}
3231
3232
3233/*
Dake Zhao0a832172015-01-06 11:08:47 -08003234 * wfaStaSendP2pProvDisReq():
Ankur Vachhanic485b712012-02-15 23:29:49 +00003235 */
3236int wfaStaSendP2pProvDisReq(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3237{
Dake Zhao0a832172015-01-06 11:08:47 -08003238 dutCmdResponse_t infoResp;
3239 /* uncomment and use it
3240 * caStaSendP2pProvDisReq_t *getStaP2pProvDisReq= (caStaSendP2pProvDisReq_t *)caCmdBuf;
3241 */
Ankur Vachhanic485b712012-02-15 23:29:49 +00003242
Dake Zhao0a832172015-01-06 11:08:47 -08003243 printf("\n Entry wfaStaSendP2pProvDisReq... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003244
Dake Zhao0a832172015-01-06 11:08:47 -08003245 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003246
Dake Zhao0a832172015-01-06 11:08:47 -08003247 infoResp.status = STATUS_COMPLETE;
3248 wfaEncodeTLV(WFA_STA_P2P_SEND_PROV_DIS_REQ_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3249 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3250
3251 return WFA_SUCCESS;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003252}
3253
3254/*
Dake Zhao0a832172015-01-06 11:08:47 -08003255 * wfaStaSetWpsPbc():
Ankur Vachhanic485b712012-02-15 23:29:49 +00003256 */
3257int wfaStaSetWpsPbc(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3258{
Dake Zhao0a832172015-01-06 11:08:47 -08003259 dutCmdResponse_t infoResp;
3260 /* uncomment and use it
3261 * caStaSetWpsPbc_t *getStaSetWpsPbc= (caStaSetWpsPbc_t *)caCmdBuf;
3262 */
Ankur Vachhanic485b712012-02-15 23:29:49 +00003263
Dake Zhao0a832172015-01-06 11:08:47 -08003264 printf("\n Entry wfaStaSetWpsPbc... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003265
Dake Zhao0a832172015-01-06 11:08:47 -08003266 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003267
Dake Zhao0a832172015-01-06 11:08:47 -08003268 infoResp.status = STATUS_COMPLETE;
3269 wfaEncodeTLV(WFA_STA_WPS_SETWPS_PBC_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3270 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3271
3272 return WFA_SUCCESS;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003273}
3274
3275/*
Dake Zhao0a832172015-01-06 11:08:47 -08003276 * wfaStaWpsReadPin():
Ankur Vachhanic485b712012-02-15 23:29:49 +00003277 */
3278int wfaStaWpsReadPin(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3279{
Dake Zhao0a832172015-01-06 11:08:47 -08003280 dutCmdResponse_t infoResp;
3281 /* uncomment and use it
3282 * caStaWpsReadPin_t *getStaWpsReadPin= (caStaWpsReadPin_t *)caCmdBuf;
3283 */
Ankur Vachhanic485b712012-02-15 23:29:49 +00003284
Dake Zhao0a832172015-01-06 11:08:47 -08003285 printf("\n Entry wfaStaWpsReadPin... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003286
Dake Zhao0a832172015-01-06 11:08:47 -08003287 // Fetch the device PIN and put in infoResp->cmdru.wpsPin
3288 //strcpy(infoResp->cmdru.wpsPin, "12345678");
3289 strcpy(&infoResp.cmdru.wpsPin[0], "1234456");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003290
Ankur Vachhanic485b712012-02-15 23:29:49 +00003291
Dake Zhao0a832172015-01-06 11:08:47 -08003292 infoResp.status = STATUS_COMPLETE;
3293 wfaEncodeTLV(WFA_STA_WPS_READ_PIN_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3294 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3295
3296 return WFA_SUCCESS;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003297}
3298
3299
3300
3301/*
Dake Zhao0a832172015-01-06 11:08:47 -08003302 * wfaStaWpsReadLabel():
Ankur Vachhanic485b712012-02-15 23:29:49 +00003303 */
3304int wfaStaWpsReadLabel(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3305{
Dake Zhao0a832172015-01-06 11:08:47 -08003306 dutCmdResponse_t infoResp;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003307
Dake Zhao0a832172015-01-06 11:08:47 -08003308 printf("\n Entry wfaStaWpsReadLabel... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003309
Dake Zhao0a832172015-01-06 11:08:47 -08003310 // Fetch the device Label and put in infoResp->cmdru.wpsPin
3311 //strcpy(infoResp->cmdru.wpsPin, "12345678");
3312 strcpy(&infoResp.cmdru.wpsPin[0], "1234456");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003313
Ankur Vachhanic485b712012-02-15 23:29:49 +00003314
Dake Zhao0a832172015-01-06 11:08:47 -08003315 infoResp.status = STATUS_COMPLETE;
3316 wfaEncodeTLV(WFA_STA_WPS_READ_PIN_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3317 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3318
3319 return WFA_SUCCESS;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003320}
3321
3322
3323/*
Dake Zhao0a832172015-01-06 11:08:47 -08003324 * wfaStaWpsEnterPin():
Ankur Vachhanic485b712012-02-15 23:29:49 +00003325 */
3326int wfaStaWpsEnterPin(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3327{
Dake Zhao0a832172015-01-06 11:08:47 -08003328 dutCmdResponse_t infoResp;
3329 /* uncomment and use it
3330 * caStaWpsEnterPin_t *getStaWpsEnterPin= (caStaWpsEnterPin_t *)caCmdBuf;
3331 */
Ankur Vachhanic485b712012-02-15 23:29:49 +00003332
Dake Zhao0a832172015-01-06 11:08:47 -08003333 printf("\n Entry wfaStaWpsEnterPin... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003334
Dake Zhao0a832172015-01-06 11:08:47 -08003335 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003336
Ankur Vachhanic485b712012-02-15 23:29:49 +00003337
Dake Zhao0a832172015-01-06 11:08:47 -08003338 infoResp.status = STATUS_COMPLETE;
3339 wfaEncodeTLV(WFA_STA_WPS_ENTER_PIN_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3340 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3341
3342 return WFA_SUCCESS;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003343}
3344
3345
3346/*
Dake Zhao0a832172015-01-06 11:08:47 -08003347 * wfaStaGetPsk():
Ankur Vachhanic485b712012-02-15 23:29:49 +00003348 */
3349int wfaStaGetPsk(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3350{
Dake Zhao0a832172015-01-06 11:08:47 -08003351 dutCmdResponse_t infoResp;
3352 /* caStaGetPsk_t *getStaGetPsk= (caStaGetPsk_t *)caCmdBuf; uncomment and use it */
Ankur Vachhanic485b712012-02-15 23:29:49 +00003353
Dake Zhao0a832172015-01-06 11:08:47 -08003354 printf("\n Entry wfaStaGetPsk... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003355
3356
Dake Zhao0a832172015-01-06 11:08:47 -08003357 // Fetch the device PP and SSID and put in infoResp->cmdru.pskInfo
3358 strcpy(&infoResp.cmdru.pskInfo.passPhrase[0], "1234456");
3359 strcpy(&infoResp.cmdru.pskInfo.ssid[0], "WIFI_DIRECT");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003360
Ankur Vachhanic485b712012-02-15 23:29:49 +00003361
Dake Zhao0a832172015-01-06 11:08:47 -08003362 infoResp.status = STATUS_COMPLETE;
3363 wfaEncodeTLV(WFA_STA_P2P_GET_PSK_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3364 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3365
3366 return WFA_SUCCESS;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003367}
3368
3369/*
Dake Zhao0a832172015-01-06 11:08:47 -08003370 * wfaStaP2pReset():
Ankur Vachhanic485b712012-02-15 23:29:49 +00003371 */
3372int wfaStaP2pReset(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3373{
Dake Zhao0a832172015-01-06 11:08:47 -08003374 dutCmdResponse_t infoResp;
3375 /* dutCommand_t *getStaP2pReset= (dutCommand_t *)caCmdBuf; */
Ankur Vachhanic485b712012-02-15 23:29:49 +00003376
Dake Zhao0a832172015-01-06 11:08:47 -08003377 printf("\n Entry wfaStaP2pReset... ");
3378 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003379
Dake Zhao0a832172015-01-06 11:08:47 -08003380 infoResp.status = STATUS_COMPLETE;
3381 wfaEncodeTLV(WFA_STA_P2P_RESET_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3382 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3383
3384 return WFA_SUCCESS;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003385}
3386
3387
3388
3389/*
Dake Zhao0a832172015-01-06 11:08:47 -08003390 * wfaStaGetP2pIpConfig():
Ankur Vachhanic485b712012-02-15 23:29:49 +00003391 */
3392int wfaStaGetP2pIpConfig(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3393{
Dake Zhao0a832172015-01-06 11:08:47 -08003394 dutCmdResponse_t infoResp;
3395 /* caStaGetP2pIpConfig_t *staGetP2pIpConfig= (caStaGetP2pIpConfig_t *)caCmdBuf; */
Ankur Vachhanic485b712012-02-15 23:29:49 +00003396
Dake Zhao0a832172015-01-06 11:08:47 -08003397 caStaGetIpConfigResp_t *ifinfo = &(infoResp.cmdru.getIfconfig);
Ankur Vachhanic485b712012-02-15 23:29:49 +00003398
Dake Zhao0a832172015-01-06 11:08:47 -08003399 printf("\n Entry wfaStaGetP2pIpConfig... ");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003400
Dake Zhao0a832172015-01-06 11:08:47 -08003401 ifinfo->isDhcp =0;
3402 strcpy(&(ifinfo->ipaddr[0]), "192.165.100.111");
3403 strcpy(&(ifinfo->mask[0]), "255.255.255.0");
3404 strcpy(&(ifinfo->dns[0][0]), "192.165.100.1");
3405 strcpy(&(ifinfo->mac[0]), "ba:ba:ba:ba:ba:ba");
3406
3407 infoResp.status = STATUS_COMPLETE;
3408 wfaEncodeTLV(WFA_STA_P2P_GET_IP_CONFIG_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3409 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3410
3411 return WFA_SUCCESS;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003412}
3413
3414
3415
3416
3417/*
Dake Zhao0a832172015-01-06 11:08:47 -08003418 * wfaStaSendServiceDiscoveryReq():
Ankur Vachhanic485b712012-02-15 23:29:49 +00003419 */
3420int wfaStaSendServiceDiscoveryReq(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3421{
Dake Zhao0a832172015-01-06 11:08:47 -08003422 dutCmdResponse_t infoResp;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003423
Dake Zhao0a832172015-01-06 11:08:47 -08003424 printf("\n Entry wfaStaSendServiceDiscoveryReq... ");
3425 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003426
Dake Zhao0a832172015-01-06 11:08:47 -08003427
3428 infoResp.status = STATUS_COMPLETE;
3429 wfaEncodeTLV(WFA_STA_P2P_SEND_SERVICE_DISCOVERY_REQ_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3430 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3431
3432 return WFA_SUCCESS;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003433}
3434
3435
3436
3437/*
Dake Zhao0a832172015-01-06 11:08:47 -08003438 * wfaStaSendP2pPresenceReq():
Ankur Vachhanic485b712012-02-15 23:29:49 +00003439 */
3440int wfaStaSendP2pPresenceReq(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3441{
Dake Zhao0a832172015-01-06 11:08:47 -08003442 dutCmdResponse_t infoResp;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003443
Dake Zhao0a832172015-01-06 11:08:47 -08003444 infoResp.status = STATUS_COMPLETE;
3445 wfaEncodeTLV(WFA_STA_P2P_SEND_PRESENCE_REQ_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3446 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
Ankur Vachhanic485b712012-02-15 23:29:49 +00003447
Dake Zhao0a832172015-01-06 11:08:47 -08003448 return WFA_SUCCESS;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003449}
3450
3451/*
Dake Zhao0a832172015-01-06 11:08:47 -08003452 * wfaStaSetSleepReq():
Ankur Vachhanic485b712012-02-15 23:29:49 +00003453 */
3454int wfaStaSetSleepReq(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3455{
Dake Zhao0a832172015-01-06 11:08:47 -08003456 dutCmdResponse_t infoResp;
3457 /* caStaSetSleep_t *staSetSleepReq= (caStaSetSleep_t *)caCmdBuf; */
Ankur Vachhanic485b712012-02-15 23:29:49 +00003458
Dake Zhao0a832172015-01-06 11:08:47 -08003459 printf("\n Entry wfaStaSetSleepReq... ");
3460 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003461
Dake Zhao0a832172015-01-06 11:08:47 -08003462
3463 infoResp.status = STATUS_COMPLETE;
3464 wfaEncodeTLV(WFA_STA_P2P_SET_SLEEP_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3465 *respLen = WFA_TLV_HDR_LEN +4;
3466
3467 return WFA_SUCCESS;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003468}
3469
3470/*
Dake Zhao0a832172015-01-06 11:08:47 -08003471 * wfaStaSetOpportunisticPsReq():
Ankur Vachhanic485b712012-02-15 23:29:49 +00003472 */
3473int wfaStaSetOpportunisticPsReq(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3474{
Dake Zhao0a832172015-01-06 11:08:47 -08003475 dutCmdResponse_t infoResp;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003476
Dake Zhao0a832172015-01-06 11:08:47 -08003477 printf("\n Entry wfaStaSetOpportunisticPsReq... ");
3478 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003479
Dake Zhao0a832172015-01-06 11:08:47 -08003480
3481 infoResp.status = STATUS_COMPLETE;
3482 wfaEncodeTLV(WFA_STA_P2P_SET_OPPORTUNISTIC_PS_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3483 *respLen = WFA_TLV_HDR_LEN + 4;
3484
3485 return WFA_SUCCESS;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003486}
3487#ifndef WFA_STA_TB
3488/*
Dake Zhao0a832172015-01-06 11:08:47 -08003489 * wfaStaPresetParams():
Ankur Vachhanic485b712012-02-15 23:29:49 +00003490 */
3491
3492int wfaStaPresetParams(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3493{
Dake Zhao0a832172015-01-06 11:08:47 -08003494 dutCmdResponse_t infoResp;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003495
Dake Zhao0a832172015-01-06 11:08:47 -08003496 DPRINT_INFO(WFA_OUT, "Inside wfaStaPresetParameters function ...\n");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003497
Dake Zhao0a832172015-01-06 11:08:47 -08003498 // Implement the function and its sub commands
3499 infoResp.status = STATUS_COMPLETE;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003500
Dake Zhao0a832172015-01-06 11:08:47 -08003501 wfaEncodeTLV(WFA_STA_PRESET_PARAMETERS_RESP_TLV, 4, (BYTE *)&infoResp, respBuf);
3502 *respLen = WFA_TLV_HDR_LEN + 4;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003503
Dake Zhao0a832172015-01-06 11:08:47 -08003504 return WFA_SUCCESS;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003505}
Dake Zhao0a832172015-01-06 11:08:47 -08003506int wfaStaSet11n(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
Ankur Vachhanic485b712012-02-15 23:29:49 +00003507{
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003508
3509 dutCmdResponse_t infoResp;
3510 dutCmdResponse_t *v11nParamsResp = &infoResp;
3511
3512#ifdef WFA_11N_SUPPORT_ONLY
Dake Zhao0a832172015-01-06 11:08:47 -08003513
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003514 caSta11n_t * v11nParams = (caSta11n_t *)caCmdBuf;
3515
3516 int st =0; // SUCCESS
Dake Zhao0a832172015-01-06 11:08:47 -08003517
3518 DPRINT_INFO(WFA_OUT, "Inside wfaStaSet11n function....\n");
Ankur Vachhanic485b712012-02-15 23:29:49 +00003519
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003520 if(v11nParams->addba_reject != 0xFF && v11nParams->addba_reject < 2)
3521 {
Dake Zhao0a832172015-01-06 11:08:47 -08003522 // implement the funciton
3523 if(st != 0)
3524 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003525 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003526 strcpy(v11nParamsResp->cmdru.info, "set_addba_reject failed");
3527 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3528 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3529 return FALSE;
Dake Zhao0a832172015-01-06 11:08:47 -08003530 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003531 }
Dake Zhao0a832172015-01-06 11:08:47 -08003532
Ankur Vachhanic485b712012-02-15 23:29:49 +00003533 if(v11nParams->ampdu != 0xFF && v11nParams->ampdu < 2)
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003534 {
Dake Zhao0a832172015-01-06 11:08:47 -08003535 // implement the funciton
Ankur Vachhanic485b712012-02-15 23:29:49 +00003536
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003537 if(st != 0)
3538 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003539 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003540 strcpy(v11nParamsResp->cmdru.info, "set_ampdu failed");
3541 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3542 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3543 return FALSE;
3544 }
3545 }
3546
Ankur Vachhanic485b712012-02-15 23:29:49 +00003547 if(v11nParams->amsdu != 0xFF && v11nParams->amsdu < 2)
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003548 {
Dake Zhao0a832172015-01-06 11:08:47 -08003549 // implement the funciton
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003550 if(st != 0)
3551 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003552 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003553 strcpy(v11nParamsResp->cmdru.info, "set_amsdu failed");
3554 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3555 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
Dake Zhao0a832172015-01-06 11:08:47 -08003556 return FALSE;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003557 }
3558 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003559
3560 if(v11nParams->greenfield != 0xFF && v11nParams->greenfield < 2)
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003561 {
3562 // implement the funciton
Dake Zhao0a832172015-01-06 11:08:47 -08003563 if(st != 0)
3564 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003565 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003566 strcpy(v11nParamsResp->cmdru.info, "_set_greenfield failed");
3567 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3568 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3569 return FALSE;
Dake Zhao0a832172015-01-06 11:08:47 -08003570 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003571 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003572
3573 if(v11nParams->mcs32!= 0xFF && v11nParams->mcs32 < 2 && v11nParams->mcs_fixedrate[0] != '\0')
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003574 {
Dake Zhao0a832172015-01-06 11:08:47 -08003575 // implement the funciton
3576 //st = wfaExecuteCLI(gCmdStr);
3577 if(st != 0)
3578 {
3579 v11nParamsResp->status = STATUS_ERROR;
3580 strcpy(v11nParamsResp->cmdru.info, "set_mcs failed");
3581 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3582 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3583 return FALSE;
3584 }
3585 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003586 else if (v11nParams->mcs32!= 0xFF && v11nParams->mcs32 < 2 && v11nParams->mcs_fixedrate[0] == '\0')
3587 {
3588 // implement the funciton
Dake Zhao0a832172015-01-06 11:08:47 -08003589 //st = wfaExecuteCLI(gCmdStr);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003590 if(st != 0)
3591 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003592 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003593 strcpy(v11nParamsResp->cmdru.info, "set_mcs32 failed");
Dake Zhao0a832172015-01-06 11:08:47 -08003594 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3595 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003596 return FALSE;
3597 }
Dake Zhao0a832172015-01-06 11:08:47 -08003598 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003599 else if (v11nParams->mcs32 == 0xFF && v11nParams->mcs_fixedrate[0] != '\0')
3600 {
3601 // implement the funciton
Dake Zhao0a832172015-01-06 11:08:47 -08003602 //st = wfaExecuteCLI(gCmdStr);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003603 if(st != 0)
3604 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003605 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003606 strcpy(v11nParamsResp->cmdru.info, "set_mcs32 failed");
Dake Zhao0a832172015-01-06 11:08:47 -08003607 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3608 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003609 return FALSE;
3610 }
3611 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003612
3613 if(v11nParams->rifs_test != 0xFF && v11nParams->rifs_test < 2)
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003614 {
3615 // implement the funciton
Dake Zhao0a832172015-01-06 11:08:47 -08003616 //st = wfaExecuteCLI(gCmdStr);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003617 if(st != 0)
3618 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003619 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003620 strcpy(v11nParamsResp->cmdru.info, "set_rifs_test failed");
Dake Zhao0a832172015-01-06 11:08:47 -08003621 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3622 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003623 return FALSE;
3624 }
3625 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003626
3627 if(v11nParams->sgi20 != 0xFF && v11nParams->sgi20 < 2)
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003628 {
3629 // implement the funciton
Dake Zhao0a832172015-01-06 11:08:47 -08003630 //st = wfaExecuteCLI(gCmdStr);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003631 if(st != 0)
3632 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003633 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003634 strcpy(v11nParamsResp->cmdru.info, "set_sgi20 failed");
3635 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3636 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3637 return FALSE;
3638 }
3639 }
3640
3641 if(v11nParams->smps != 0xFFFF)
3642 {
3643 if(v11nParams->smps == 0)
3644 {
Dake Zhao0a832172015-01-06 11:08:47 -08003645 // implement the funciton
3646 //st = wfaExecuteCLI(gCmdStr);
3647 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003648 else if(v11nParams->smps == 1)
3649 {
Dake Zhao0a832172015-01-06 11:08:47 -08003650 // implement the funciton
3651 //st = wfaExecuteCLI(gCmdStr);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003652 ;
Dake Zhao0a832172015-01-06 11:08:47 -08003653 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003654 else if(v11nParams->smps == 2)
3655 {
Dake Zhao0a832172015-01-06 11:08:47 -08003656 // implement the funciton
3657 //st = wfaExecuteCLI(gCmdStr);
3658 ;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003659 }
3660 if(st != 0)
3661 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003662 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003663 strcpy(v11nParamsResp->cmdru.info, "set_smps failed");
3664 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3665 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3666 return FALSE;
3667 }
3668 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003669
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003670 if(v11nParams->stbc_rx != 0xFFFF)
3671 {
3672 // implement the funciton
Dake Zhao0a832172015-01-06 11:08:47 -08003673 //st = wfaExecuteCLI(gCmdStr);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003674 if(st != 0)
3675 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003676 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003677 strcpy(v11nParamsResp->cmdru.info, "set_stbc_rx failed");
Dake Zhao0a832172015-01-06 11:08:47 -08003678 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3679 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003680 return FALSE;
3681 }
3682 }
Dake Zhao0a832172015-01-06 11:08:47 -08003683
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003684 if(v11nParams->width[0] != '\0')
3685 {
3686 // implement the funciton
Dake Zhao0a832172015-01-06 11:08:47 -08003687 //st = wfaExecuteCLI(gCmdStr);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003688 if(st != 0)
3689 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003690 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003691 strcpy(v11nParamsResp->cmdru.info, "set_11n_channel_width failed");
3692 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3693 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3694 return FALSE;
3695 }
3696 }
Dake Zhao0a832172015-01-06 11:08:47 -08003697
Ankur Vachhanic485b712012-02-15 23:29:49 +00003698 if(v11nParams->_40_intolerant != 0xFF && v11nParams->_40_intolerant < 2)
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003699 {
3700 // implement the funciton
Dake Zhao0a832172015-01-06 11:08:47 -08003701 //st = wfaExecuteCLI(gCmdStr);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003702 if(st != 0)
3703 {
Ankur Vachhanic485b712012-02-15 23:29:49 +00003704 v11nParamsResp->status = STATUS_ERROR;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003705 strcpy(v11nParamsResp->cmdru.info, "set_40_intolerant failed");
3706 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3707 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3708 return FALSE;
3709 }
3710 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003711
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003712 if(v11nParams->txsp_stream != 0 && v11nParams->txsp_stream <4)
3713 {
3714 // implement the funciton
Dake Zhao0a832172015-01-06 11:08:47 -08003715 //st = wfaExecuteCLI(gCmdStr);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003716 if(st != 0)
3717 {
3718 v11nParamsResp->status = STATUS_ERROR;
Dake Zhao0a832172015-01-06 11:08:47 -08003719 strcpy(v11nParamsResp->cmdru.info, "set_txsp_stream failed");
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003720 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3721 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3722 return FALSE;
3723 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003724
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003725 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003726
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003727 if(v11nParams->rxsp_stream != 0 && v11nParams->rxsp_stream < 4)
3728 {
3729 // implement the funciton
Dake Zhao0a832172015-01-06 11:08:47 -08003730 //st = wfaExecuteCLI(gCmdStr);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003731 if(st != 0)
3732 {
3733 v11nParamsResp->status = STATUS_ERROR;
3734 strcpy(v11nParamsResp->cmdru.info, "set_rxsp_stream failed");
3735 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)v11nParamsResp, respBuf);
3736 *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t);
3737 return FALSE;
3738 }
3739 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003740
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003741#endif
Ankur Vachhanic485b712012-02-15 23:29:49 +00003742
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003743 v11nParamsResp->status = STATUS_COMPLETE;
3744 wfaEncodeTLV(WFA_STA_SET_11N_RESP_TLV, 4, (BYTE *)v11nParamsResp, respBuf);
3745 *respLen = WFA_TLV_HDR_LEN + 4;
3746 return WFA_SUCCESS;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003747}
3748#endif
3749/*
Dake Zhao0a832172015-01-06 11:08:47 -08003750 * wfaStaAddArpTableEntry():
Ankur Vachhanic485b712012-02-15 23:29:49 +00003751 */
3752int wfaStaAddArpTableEntry(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3753{
Dake Zhao0a832172015-01-06 11:08:47 -08003754 dutCmdResponse_t infoResp;
3755 /* caStaAddARPTableEntry_t *staAddARPTableEntry= (caStaAddARPTableEntry_t *)caCmdBuf; uncomment and use it */
Ankur Vachhanic485b712012-02-15 23:29:49 +00003756
Dake Zhao0a832172015-01-06 11:08:47 -08003757 printf("\n Entry wfastaAddARPTableEntry... ");
3758 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003759
Dake Zhao0a832172015-01-06 11:08:47 -08003760 infoResp.status = STATUS_COMPLETE;
3761 wfaEncodeTLV(WFA_STA_P2P_ADD_ARP_TABLE_ENTRY_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3762 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3763
3764 return WFA_SUCCESS;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003765}
3766
3767/*
Dake Zhao0a832172015-01-06 11:08:47 -08003768 * wfaStaBlockICMPResponse():
Ankur Vachhanic485b712012-02-15 23:29:49 +00003769 */
3770int wfaStaBlockICMPResponse(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3771{
Dake Zhao0a832172015-01-06 11:08:47 -08003772 dutCmdResponse_t infoResp;
3773 /* caStaBlockICMPResponse_t *staAddARPTableEntry= (caStaBlockICMPResponse_t *)caCmdBuf; uncomment and use it */
Ankur Vachhanic485b712012-02-15 23:29:49 +00003774
Dake Zhao0a832172015-01-06 11:08:47 -08003775 printf("\n Entry wfaStaBlockICMPResponse... ");
3776 // Implement the function and this does not return any thing back.
Ankur Vachhanic485b712012-02-15 23:29:49 +00003777
Dake Zhao0a832172015-01-06 11:08:47 -08003778 infoResp.status = STATUS_COMPLETE;
3779 wfaEncodeTLV(WFA_STA_P2P_BLOCK_ICMP_RESPONSE_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3780 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3781
3782 return WFA_SUCCESS;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003783}
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003784
3785/*
Dake Zhao0a832172015-01-06 11:08:47 -08003786 * wfaStaSetRadio():
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003787 */
3788
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00003789int wfaStaSetRadio(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3790{
3791 dutCommand_t *setRadio = (dutCommand_t *)caCmdBuf;
3792 dutCmdResponse_t *staCmdResp = &gGenericResp;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00003793 caStaSetRadio_t *sr = &setRadio->cmdsu.sr;
3794
3795 if(sr->mode == WFA_OFF)
3796 {
Dake Zhao0a832172015-01-06 11:08:47 -08003797 // turn radio off
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00003798 }
3799 else
3800 {
Dake Zhao0a832172015-01-06 11:08:47 -08003801 // always turn the radio on
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00003802 }
3803
3804 staCmdResp->status = STATUS_COMPLETE;
3805 wfaEncodeTLV(WFA_STA_SET_RADIO_RESP_TLV, 4, (BYTE *)staCmdResp, respBuf);
3806 *respLen = WFA_TLV_HDR_LEN + 4;
3807
3808 return WFA_SUCCESS;
3809}
3810
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003811/*
Dake Zhao0a832172015-01-06 11:08:47 -08003812 * wfaStaSetRFeature():
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003813 */
3814
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00003815int wfaStaSetRFeature(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3816{
Dake Zhao0a832172015-01-06 11:08:47 -08003817 dutCommand_t *dutCmd = (dutCommand_t *)caCmdBuf;
3818 caStaRFeat_t *rfeat = &dutCmd->cmdsu.rfeat;
3819 dutCmdResponse_t *caResp = &gGenericResp;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00003820
Dake Zhao0a832172015-01-06 11:08:47 -08003821 if(strcasecmp(rfeat->prog, "tdls") == 0)
3822 {
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00003823
3824
Dake Zhao0a832172015-01-06 11:08:47 -08003825 }
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00003826
Dake Zhao0a832172015-01-06 11:08:47 -08003827 caResp->status = STATUS_COMPLETE;
3828 wfaEncodeTLV(WFA_STA_SET_RFEATURE_RESP_TLV, 4, (BYTE *)caResp, respBuf);
3829 *respLen = WFA_TLV_HDR_LEN + 4;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00003830
Dake Zhao0a832172015-01-06 11:08:47 -08003831 return WFA_SUCCESS;
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00003832}
3833
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003834/*
Dake Zhao0a832172015-01-06 11:08:47 -08003835 * wfaStaStartWfdConnection():
3836 */
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003837int wfaStaStartWfdConnection(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3838{
Dake Zhao0a832172015-01-06 11:08:47 -08003839 dutCmdResponse_t infoResp;
3840 //caStaStartWfdConn_t *staStartWfdConn= (caStaStartWfdConn_t *)caCmdBuf; //uncomment and use it
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003841
Dake Zhao0a832172015-01-06 11:08:47 -08003842 printf("\n Entry wfaStaStartWfdConnection... ");
3843
3844
3845 // Fetch the GrpId and WFD session and return
3846 strcpy(&infoResp.cmdru.wfdConnInfo.wfdSessionId[0], "1234567890");
3847 strcpy(&infoResp.cmdru.wfdConnInfo.p2pGrpId[0], "WIFI_DISPLAY");
3848 strcpy(&infoResp.cmdru.wfdConnInfo.result[0], "GO");
3849
3850 infoResp.status = STATUS_COMPLETE;
3851 wfaEncodeTLV(WFA_STA_START_WFD_CONNECTION_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
3852 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
3853
3854 return WFA_SUCCESS;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003855}
3856/*
Dake Zhao0a832172015-01-06 11:08:47 -08003857 * wfaStaCliCommand():
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003858 */
Ankur Vachhanie1b4fbc2011-12-26 09:40:02 +00003859
Ankur Vachhanic485b712012-02-15 23:29:49 +00003860int wfaStaCliCommand(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
3861{
Dake Zhao0a832172015-01-06 11:08:47 -08003862 char cmdName[32];
3863 char *pcmdStr=NULL, *str;
3864 int st = 1;
3865 char CmdStr[WFA_CMD_STR_SZ];
3866 FILE *wfaCliFd;
3867 char wfaCliBuff[64];
3868 char retstr[256];
3869 int CmdReturnFlag =0;
3870 char tmp[256];
3871 FILE * sh_pipe;
3872 caStaCliCmdResp_t infoResp;
Ankur Vachhanic485b712012-02-15 23:29:49 +00003873
Dake Zhao0a832172015-01-06 11:08:47 -08003874 printf("\nEntry wfaStaCliCommand; command Received: %s\n",caCmdBuf);
3875 memcpy(cmdName, strtok_r((char *)caCmdBuf, ",", (char **)&pcmdStr), 32);
3876 sprintf(CmdStr, "%s",cmdName);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003877
Dake Zhao0a832172015-01-06 11:08:47 -08003878 for(;;)
3879 {
3880 // construct CLI standard cmd string
3881 str = strtok_r(NULL, ",", &pcmdStr);
3882 if(str == NULL || str[0] == '\0')
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003883 break;
Dake Zhao0a832172015-01-06 11:08:47 -08003884 else
3885 {
3886 sprintf(CmdStr, "%s /%s",CmdStr,str);
3887 str = strtok_r(NULL, ",", &pcmdStr);
3888 sprintf(CmdStr, "%s %s",CmdStr,str);
3889 }
3890 }
3891 // check the return process
3892 wfaCliFd=fopen("/etc/WfaEndpoint/wfa_cli.txt","r");
3893 if(wfaCliFd!= NULL)
3894 {
3895 while(fgets(wfaCliBuff, 64, wfaCliFd) != NULL)
3896 {
3897 //printf("\nLine read from CLI file : %s",wfaCliBuff);
3898 if(ferror(wfaCliFd))
3899 break;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08003900
Dake Zhao0a832172015-01-06 11:08:47 -08003901 str=strtok(wfaCliBuff,"-");
3902 if(strcmp(str,cmdName) == 0)
Dake Zhao97708202014-11-26 13:59:04 -08003903 {
Dake Zhao0a832172015-01-06 11:08:47 -08003904 str=strtok(NULL,",");
3905 if (str != NULL)
3906 {
3907 if(strcmp(str,"TRUE") == 0)
3908 CmdReturnFlag =1;
3909 }
3910 else
3911 printf("ERR wfa_cli.txt, inside line format not end with , or missing TRUE/FALSE\n");
3912 break;
Dake Zhao97708202014-11-26 13:59:04 -08003913 }
Dake Zhao0a832172015-01-06 11:08:47 -08003914 }
3915 fclose(wfaCliFd);
3916 }
3917 else
3918 {
3919 printf("/etc/WfaEndpoint/wfa_cli.txt is not exist\n");
3920 goto cleanup;
3921 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003922
Dake Zhao0a832172015-01-06 11:08:47 -08003923 //printf("\n Command Return Flag : %d",CmdReturnFlag);
3924 memset(&retstr[0],'\0',255);
3925 memset(&tmp[0],'\0',255);
3926 sprintf(gCmdStr, "%s", CmdStr);
3927 printf("\nCLI Command -- %s\n", gCmdStr);
Ankur Vachhanic485b712012-02-15 23:29:49 +00003928
Dake Zhao0a832172015-01-06 11:08:47 -08003929 sh_pipe = popen(gCmdStr,"r");
3930 if(!sh_pipe)
3931 {
3932 printf ("Error in opening pipe\n");
3933 goto cleanup;
3934 }
Dake Zhao97708202014-11-26 13:59:04 -08003935
Dake Zhao0a832172015-01-06 11:08:47 -08003936 sleep(5);
3937 //tmp_val=getdelim(&retstr,255,"\n",sh_pipe);
3938 if (fgets(&retstr[0], 255, sh_pipe) == NULL)
3939 {
3940 printf("Getting NULL string in popen return\n");
3941 goto cleanup;
3942 }
3943 else
3944 printf("popen return str=%s\n",retstr);
3945
3946 sleep(2);
3947 if(pclose(sh_pipe) == -1)
3948 {
3949 printf("Error in closing shell cmd pipe\n");
3950 goto cleanup;
3951 }
3952 sleep(2);
3953
3954 // find status first in output
3955 str = strtok_r((char *)retstr, "-", (char **)&pcmdStr);
3956 if (str != NULL)
3957 {
3958 memset(tmp, 0, 10);
3959 memcpy(tmp, str, 2);
3960 printf("cli status=%s\n",tmp);
3961 if(strlen(tmp) > 0)
3962 st = atoi(tmp);
3963 else printf("Missing status code\n");
3964 }
3965 else
3966 {
3967 printf("wfaStaCliCommand no return code found\n");
3968 }
3969 infoResp.resFlag=CmdReturnFlag;
3970
Dake Zhao97708202014-11-26 13:59:04 -08003971cleanup:
Dake Zhao0a832172015-01-06 11:08:47 -08003972
3973 switch(st)
3974 {
3975 case 0:
3976 infoResp.status = STATUS_COMPLETE;
3977 if (CmdReturnFlag)
3978 {
3979 if((pcmdStr != NULL) && (strlen(pcmdStr) > 0) )
3980 {
3981 memset(&(infoResp.result[0]),'\0',WFA_CLI_CMD_RESP_LEN-1);
Dake Zhao97708202014-11-26 13:59:04 -08003982 strncpy(&infoResp.result[0], pcmdStr ,(strlen(pcmdStr) < WFA_CLI_CMD_RESP_LEN ) ? strlen(pcmdStr) : (WFA_CLI_CMD_RESP_LEN-2) );
Dake Zhao0a832172015-01-06 11:08:47 -08003983 printf("Return CLI result string to CA=%s\n", &(infoResp.result[0]));
3984 }
3985 else
3986 {
Dake Zhao97708202014-11-26 13:59:04 -08003987 strcpy(&infoResp.result[0], "No return string found\n");
Dake Zhao0a832172015-01-06 11:08:47 -08003988 }
3989 }
3990 break;
3991 case 1:
3992 infoResp.status = STATUS_ERROR;
3993 break;
3994 case 2:
3995 infoResp.status = STATUS_INVALID;
3996 break;
3997 }
Ankur Vachhanic485b712012-02-15 23:29:49 +00003998
Dake Zhao0a832172015-01-06 11:08:47 -08003999 wfaEncodeTLV(WFA_STA_CLI_CMD_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
4000 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
Ankur Vachhanic485b712012-02-15 23:29:49 +00004001
Dake Zhao0a832172015-01-06 11:08:47 -08004002 printf("Exit from wfaStaCliCommand\n");
4003 return TRUE;
Ankur Vachhanic485b712012-02-15 23:29:49 +00004004
Ankur Vachhanic485b712012-02-15 23:29:49 +00004005}
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08004006/*
Dake Zhao0a832172015-01-06 11:08:47 -08004007 * wfaStaConnectGoStartWfd():
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08004008 */
4009
4010int wfaStaConnectGoStartWfd(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
4011{
4012 dutCmdResponse_t infoResp;
4013// caStaConnectGoStartWfd_t *staConnecGoStartWfd= (caStaConnectGoStartWfd_t *)caCmdBuf; //uncomment and use it
Dake Zhao0a832172015-01-06 11:08:47 -08004014
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08004015 printf("\n Entry wfaStaConnectGoStartWfd... ");
4016
Dake Zhao0a832172015-01-06 11:08:47 -08004017 // connect the specified GO and then establish the wfd session
4018
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08004019 // Fetch WFD session and return
4020 strcpy(&infoResp.cmdru.wfdConnInfo.wfdSessionId[0], "1234567890");
4021
4022 infoResp.status = STATUS_COMPLETE;
Dake Zhao0a832172015-01-06 11:08:47 -08004023 wfaEncodeTLV(WFA_STA_CONNECT_GO_START_WFD_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08004024 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
Dake Zhao0a832172015-01-06 11:08:47 -08004025
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08004026 return WFA_SUCCESS;
4027}
4028
4029/*
Dake Zhao0a832172015-01-06 11:08:47 -08004030 * wfaStaGenerateEvent():
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08004031 */
4032
4033int wfaStaGenerateEvent(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
4034{
4035 dutCmdResponse_t infoResp;
4036 caStaGenEvent_t *staGenerateEvent= (caStaGenEvent_t *)caCmdBuf; //uncomment and use it
4037 caWfdStaGenEvent_t *wfdGenEvent;
Dake Zhao0a832172015-01-06 11:08:47 -08004038
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08004039 printf("\n Entry wfaStaGenerateEvent... ");
4040
4041
4042 // Geneate the specified action and return with complete/error.
4043 if(staGenerateEvent->program == PROG_TYPE_WFD)
4044 {
4045 wfdGenEvent = &staGenerateEvent->wfdEvent;
4046 if(wfdGenEvent ->type == eUibcGen)
4047 {
Dake Zhao0a832172015-01-06 11:08:47 -08004048 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08004049 else if(wfdGenEvent ->type == eUibcHid)
4050 {
Dake Zhao0a832172015-01-06 11:08:47 -08004051 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08004052 else if(wfdGenEvent ->type == eFrameSkip)
4053 {
4054
4055 }
4056 else if(wfdGenEvent ->type == eI2cRead)
4057 {
4058 }
4059 else if(wfdGenEvent ->type == eI2cWrite)
4060 {
Dake Zhao0a832172015-01-06 11:08:47 -08004061 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08004062 else if(wfdGenEvent ->type == eInputContent)
4063 {
Dake Zhao0a832172015-01-06 11:08:47 -08004064 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08004065 else if(wfdGenEvent ->type == eIdrReq)
4066 {
Dake Zhao0a832172015-01-06 11:08:47 -08004067 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08004068 }
Dake Zhao0a832172015-01-06 11:08:47 -08004069
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08004070 infoResp.status = STATUS_COMPLETE;
Dake Zhao0a832172015-01-06 11:08:47 -08004071 wfaEncodeTLV(WFA_STA_GENERATE_EVENT_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08004072 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
Dake Zhao0a832172015-01-06 11:08:47 -08004073
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08004074 return WFA_SUCCESS;
4075}
4076
Dake Zhao0a832172015-01-06 11:08:47 -08004077
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08004078
4079
4080/*
Dake Zhao0a832172015-01-06 11:08:47 -08004081 * wfaStaReinvokeWfdSession():
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08004082 */
4083
4084int wfaStaReinvokeWfdSession(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
4085{
4086 dutCmdResponse_t infoResp;
4087// caStaReinvokeWfdSession_t *staReinvokeSession= (caStaReinvokeWfdSession_t *)caCmdBuf; //uncomment and use it
Dake Zhao0a832172015-01-06 11:08:47 -08004088
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08004089 printf("\n Entry wfaStaReinvokeWfdSession... ");
4090
4091 // Reinvoke the WFD session by accepting the p2p invitation or sending p2p invitation
Dake Zhao0a832172015-01-06 11:08:47 -08004092
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08004093
4094 infoResp.status = STATUS_COMPLETE;
Dake Zhao0a832172015-01-06 11:08:47 -08004095 wfaEncodeTLV(WFA_STA_REINVOKE_WFD_SESSION_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08004096 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
Dake Zhao0a832172015-01-06 11:08:47 -08004097
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08004098 return WFA_SUCCESS;
4099}
4100
4101
4102int wfaStaGetParameter(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
4103{
Dake Zhao0a832172015-01-06 11:08:47 -08004104 dutCmdResponse_t infoResp;
4105 caStaGetParameter_t *staGetParam= (caStaGetParameter_t *)caCmdBuf; //uncomment and use it
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08004106
4107
Dake Zhao0a832172015-01-06 11:08:47 -08004108 caStaGetParameterResp_t *paramList = &infoResp.cmdru.getParamValue;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08004109
Dake Zhao0a832172015-01-06 11:08:47 -08004110 printf("\n Entry wfaStaGetParameter... ");
4111
4112 // Check the program type
4113 if(staGetParam->program == PROG_TYPE_WFD)
4114 {
4115 if(staGetParam->getParamValue == eDiscoveredDevList )
4116 {
4117 // Get the discovered devices, make space seperated list and return, check list is not bigger than 128 bytes.
4118 paramList->getParamType = eDiscoveredDevList;
4119 strcpy((char *)&paramList->devList, "11:22:33:44:55:66 22:33:44:55:66:77 33:44:55:66:77:88");
4120 }
4121 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08004122
Dake Zhao655efed2015-03-11 17:39:13 -07004123 if(staGetParam->program == PROG_TYPE_WFDS)
4124 {
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08004125
Dake Zhao655efed2015-03-11 17:39:13 -07004126 if(staGetParam->getParamValue == eDiscoveredDevList )
4127 {
4128 // Get the discovered devices, make space seperated list and return, check list is not bigger than 128 bytes.
4129 paramList->getParamType = eDiscoveredDevList;
4130 strcpy((char *)&paramList->devList, "11:22:33:44:55:66 22:33:44:55:66:77 33:44:55:66:77:88");
4131
4132 }
4133 if(staGetParam->getParamValue == eOpenPorts)
4134 {
4135 // Run the port checker tool
4136 // Get all the open ports and make space seperated list and return, check list is not bigger than 128 bytes.
4137 paramList->getParamType = eOpenPorts;
4138 strcpy((char *)&paramList->devList, "22 139 445 68 9700");
4139
4140 }
4141
4142 }
Dake Zhaocda4a1d2015-06-11 10:14:15 -07004143 if(staGetParam->program == PROG_TYPE_NAN)
4144 {
4145 if(staGetParam->getParamValue == eMasterPref )
4146 {
4147 // Get the master preference of the device and return the value
4148 paramList->getParamType = eMasterPref;
4149 strcpy((char *)&paramList->masterPref, "0xff");
4150 }
4151 }
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08004152
Dake Zhao655efed2015-03-11 17:39:13 -07004153 infoResp.status = STATUS_COMPLETE;
4154 wfaEncodeTLV(WFA_STA_GET_PARAMETER_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
4155 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
4156
4157 return WFA_SUCCESS;
Harsh Madhiwalla8e496e02014-02-25 14:54:53 -08004158}
4159
Ankur Vachhanic485b712012-02-15 23:29:49 +00004160
Dake Zhao655efed2015-03-11 17:39:13 -07004161int wfaStaNfcAction(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
4162{
4163
4164 dutCmdResponse_t infoResp;
4165 caStaNfcAction_t *getStaNfcAction = (caStaNfcAction_t *)caCmdBuf; //uncomment and use it
4166
4167 printf("\n Entry wfaStaNfcAction... ");
4168
4169 if(getStaNfcAction->nfcOperation == eNfcHandOver)
4170 {
4171 printf("\n NfcAction - HandOver... ");
4172
4173 }
4174 else if(getStaNfcAction->nfcOperation == eNfcReadTag)
4175 {
4176 printf("\n NfcAction - Read Tag... ");
4177
4178 }
4179 else if(getStaNfcAction->nfcOperation == eNfcWriteSelect)
4180 {
4181 printf("\n NfcAction - Write Select... ");
4182
4183 }
4184 else if(getStaNfcAction->nfcOperation == eNfcWriteConfig)
4185 {
4186 printf("\n NfcAction - Write Config... ");
4187
4188 }
4189 else if(getStaNfcAction->nfcOperation == eNfcWritePasswd)
4190 {
4191 printf("\n NfcAction - Write Password... ");
4192
4193 }
4194 else if(getStaNfcAction->nfcOperation == eNfcWpsHandOver)
4195 {
4196 printf("\n NfcAction - WPS Handover... ");
4197
4198 }
4199
4200 // Fetch the device mode and put in infoResp->cmdru.p2presult
4201 //strcpy(infoResp->cmdru.p2presult, "GO");
4202
4203 // Fetch the device grp id and put in infoResp->cmdru.grpid
4204 //strcpy(infoResp->cmdru.grpid, "AA:BB:CC:DD:EE:FF_DIRECT-SSID");
4205
4206 strcpy(infoResp.cmdru.staNfcAction.result, "CLIENT");
4207 strcpy(infoResp.cmdru.staNfcAction.grpId, "AA:BB:CC:DD:EE:FF_DIRECT-SSID");
4208 infoResp.cmdru.staNfcAction.peerRole = 1;
4209
4210
4211
4212
4213 infoResp.status = STATUS_COMPLETE;
4214 wfaEncodeTLV(WFA_STA_NFC_ACTION_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
4215 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
4216
4217 return WFA_SUCCESS;
4218}
4219
Dake Zhaocda4a1d2015-06-11 10:14:15 -07004220int wfaStaExecAction(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
4221{
4222
4223 dutCmdResponse_t infoResp;
4224 caStaExecAction_t *staExecAction = (caStaExecAction_t *)caCmdBuf; //comment if not used
4225
4226 printf("\n Entry wfaStaExecAction... ");
4227
4228 if(staExecAction->prog == PROG_TYPE_NAN)
4229 {
4230 // Perform necessary configurations and actions
4231 // return the MAC address conditionally as per CAPI specification
4232 }
4233
4234 infoResp.status = STATUS_COMPLETE;
4235 wfaEncodeTLV(WFA_STA_EXEC_ACTION_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
4236 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
4237
4238 return WFA_SUCCESS;
4239}
4240
Dake Zhao655efed2015-03-11 17:39:13 -07004241int wfaStaInvokeCommand(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
4242{
4243
4244 dutCmdResponse_t infoResp;
4245 caStaInvokeCmd_t *staInvokeCmd = (caStaInvokeCmd_t *)caCmdBuf; //uncomment and use it
4246
4247 printf("\n Entry wfaStaInvokeCommand... ");
4248
4249
4250 // based on the command type , invoke API or complete the required procedures
4251 // return the defined parameters based on the command that is received ( example response below)
4252
4253 if(staInvokeCmd->cmdType == ePrimitiveCmdType && staInvokeCmd->InvokeCmds.primtiveType.PrimType == eCmdPrimTypeAdvt )
4254 {
4255 infoResp.cmdru.staInvokeCmd.invokeCmdRspType = eCmdPrimTypeAdvt;
4256 infoResp.cmdru.staInvokeCmd.invokeCmdResp.advRsp.numServInfo = 1;
4257 strcpy(infoResp.cmdru.staInvokeCmd.invokeCmdResp.advRsp.servAdvInfo[0].servName,"org.wi-fi.wfds.send.rx");
4258 infoResp.cmdru.staInvokeCmd.invokeCmdResp.advRsp.servAdvInfo[0].advtID = 0x0000f;
4259 strcpy(infoResp.cmdru.staInvokeCmd.invokeCmdResp.advRsp.servAdvInfo[0].serviceMac,"ab:cd:ef:gh:ij:kl");
4260 }
4261 else if (staInvokeCmd->cmdType == ePrimitiveCmdType && staInvokeCmd->InvokeCmds.primtiveType.PrimType == eCmdPrimTypeSeek)
4262 {
4263 infoResp.cmdru.staInvokeCmd.invokeCmdRspType = eCmdPrimTypeSeek;
4264 infoResp.cmdru.staInvokeCmd.invokeCmdResp.seekRsp.searchID = 0x000ff;
4265 }
4266 else if (staInvokeCmd->cmdType == ePrimitiveCmdType && staInvokeCmd->InvokeCmds.primtiveType.PrimType == eCmdPrimTypeConnSession)
4267 {
4268 infoResp.cmdru.staInvokeCmd.invokeCmdRspType = eCmdPrimTypeConnSession;
4269 infoResp.cmdru.staInvokeCmd.invokeCmdResp.connSessResp.sessionID = 0x000ff;
4270 strcpy(infoResp.cmdru.staInvokeCmd.invokeCmdResp.connSessResp.result,"GO");
4271 strcpy(infoResp.cmdru.staInvokeCmd.invokeCmdResp.connSessResp.grpId,"DIRECT-AB WFADUT");
4272
4273 }
4274 infoResp.status = STATUS_COMPLETE;
4275 wfaEncodeTLV(WFA_STA_INVOKE_CMD_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
4276 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
4277
4278 return WFA_SUCCESS;
4279}
4280
4281
4282int wfaStaManageService(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
4283{
4284
4285 dutCmdResponse_t infoResp;
4286 //caStaMngServ_t *staMngServ = (caStaMngServ_t *)caCmdBuf; //uncomment and use it
4287
4288 printf("\n Entry wfaStaManageService... ");
4289
4290 // based on the manage service type , invoke API's or complete the required procedures
4291 // return the defined parameters based on the command that is received ( example response below)
4292 strcpy(infoResp.cmdru.staManageServ.result, "CLIENT");
4293 strcpy(infoResp.cmdru.staManageServ.grpId, "AA:BB:CC:DD:EE:FF_DIRECT-SSID");
4294 infoResp.cmdru.staManageServ.sessionID = 0x000ff;
4295
4296 infoResp.status = STATUS_COMPLETE;
4297 wfaEncodeTLV(WFA_STA_MANAGE_SERVICE_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
4298 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
4299
4300 return WFA_SUCCESS;
4301}
4302
4303
4304
4305int wfaStaGetEvents(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
4306{
4307
4308 dutCmdResponse_t infoResp;
4309 //caStaGetEvents_t *staGetEvents = (caStaGetEvents_t *)caCmdBuf; //uncomment and use it
4310
4311 printf("\n Entry wfaStaGetEvents... ");
Dake Zhaocda4a1d2015-06-11 10:14:15 -07004312
4313 if(staGetEvents->program == PROG_TYPE_NAN)
4314 {
4315 // Get all the events from the Log file or stored events
4316 // return the received/recorded event details - eventName, remoteInstanceID, localInstanceID, mac
4317 }
Dake Zhao655efed2015-03-11 17:39:13 -07004318
4319 // Get all the event from the Log file or stored events
4320 // return the received/recorded events as space seperated list ( example response below)
4321 strcpy(infoResp.cmdru.staGetEvents.result, "SearchResult SearchTerminated AdvertiseStatus SessionRequest ConnectStatus SessionStatus PortStatus");
4322
4323 infoResp.status = STATUS_COMPLETE;
4324 wfaEncodeTLV(WFA_STA_GET_EVENTS_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
4325 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
4326
4327 return WFA_SUCCESS;
4328}
4329
4330int wfaStaGetEventDetails(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf)
4331{
4332
4333 dutCmdResponse_t infoResp;
4334 caStaGetEventDetails_t *getStaGetEventDetails = (caStaMngServ_t *)caCmdBuf; //uncomment and use it
4335
4336 printf("\n Entry wfaStaGetEventDetails... ");
4337
4338
4339 // based on the Requested Event type
4340 // return the latest corresponding evnet detailed parameters ( example response below)
4341
4342 if(getStaGetEventDetails->eventId== eSearchResult )
4343 {
4344 // fetch from log file or event history for the search result event and return the parameters
4345 infoResp.cmdru.staGetEventDetails.eventID= eSearchResult;
4346
4347 infoResp.cmdru.staGetEventDetails.getEventDetails.searchResult.searchID = 0x00abcd;
4348 strcpy(infoResp.cmdru.staGetEventDetails.getEventDetails.searchResult.serviceMac,"ab:cd:ef:gh:ij:kl");
4349 infoResp.cmdru.staGetEventDetails.getEventDetails.searchResult.advID = 0x00dcba;
4350 strcpy(infoResp.cmdru.staGetEventDetails.getEventDetails.searchResult.serviceName,"org.wi-fi.wfds.send.rx");
4351
4352 infoResp.cmdru.staGetEventDetails.getEventDetails.searchResult.serviceStatus = eServiceAvilable;
4353 }
4354 else if (getStaGetEventDetails->eventId == eSearchTerminated)
4355 { // fetch from log file or event history for the search terminated event and return the parameters
4356 infoResp.cmdru.staGetEventDetails.eventID= eSearchTerminated;
4357 infoResp.cmdru.staGetEventDetails.getEventDetails.searchTerminated.searchID = 0x00abcd;
4358 }
4359 else if (getStaGetEventDetails->eventId == eAdvertiseStatus)
4360 {// fetch from log file or event history for the Advertise Status event and return the parameters
4361 infoResp.cmdru.staGetEventDetails.eventID= eAdvertiseStatus;
4362 infoResp.cmdru.staGetEventDetails.getEventDetails.advStatus.advID = 0x00dcba;
4363
4364 infoResp.cmdru.staGetEventDetails.getEventDetails.advStatus.status = eAdvertised;
4365 }
4366 else if (getStaGetEventDetails->eventId == eSessionRequest)
4367 {// fetch from log file or event history for the session request event and return the parameters
4368 infoResp.cmdru.staGetEventDetails.eventID= eSessionRequest;
4369 infoResp.cmdru.staGetEventDetails.getEventDetails.sessionReq.advID = 0x00dcba;
4370 strcpy(infoResp.cmdru.staGetEventDetails.getEventDetails.sessionReq.sessionMac,"ab:cd:ef:gh:ij:kl");
4371 infoResp.cmdru.staGetEventDetails.getEventDetails.sessionReq.sessionID = 0x00baba;
4372 }
4373 else if (getStaGetEventDetails->eventId ==eSessionStatus )
4374 {// fetch from log file or event history for the session status event and return the parameters
4375 infoResp.cmdru.staGetEventDetails.eventID= eSessionStatus;
4376 infoResp.cmdru.staGetEventDetails.getEventDetails.sessionStatus.sessionID = 0x00baba;
4377 strcpy(infoResp.cmdru.staGetEventDetails.getEventDetails.sessionStatus.sessionMac,"ab:cd:ef:gh:ij:kl");
4378 infoResp.cmdru.staGetEventDetails.getEventDetails.sessionStatus.state = eSessionStateOpen;
4379 }
4380 else if (getStaGetEventDetails->eventId == eConnectStatus)
4381 {
4382 infoResp.cmdru.staGetEventDetails.eventID= eConnectStatus;
4383 infoResp.cmdru.staGetEventDetails.getEventDetails.connStatus.sessionID = 0x00baba;
4384 strcpy(infoResp.cmdru.staGetEventDetails.getEventDetails.connStatus.sessionMac,"ab:cd:ef:gh:ij:kl");
4385 infoResp.cmdru.staGetEventDetails.getEventDetails.connStatus.status = eGroupFormationComplete;
4386
4387 }
4388 else if (getStaGetEventDetails->eventId == ePortStatus)
4389 {
4390 infoResp.cmdru.staGetEventDetails.eventID= ePortStatus;
4391 infoResp.cmdru.staGetEventDetails.getEventDetails.portStatus.sessionID = 0x00baba;
4392 strcpy(infoResp.cmdru.staGetEventDetails.getEventDetails.portStatus.sessionMac,"ab:cd:ef:gh:ij:kl");
4393 infoResp.cmdru.staGetEventDetails.getEventDetails.portStatus.port = 1009;
4394 infoResp.cmdru.staGetEventDetails.getEventDetails.portStatus.status = eLocalPortAllowed;
4395 }
4396
4397
4398
4399 infoResp.status = STATUS_COMPLETE;
4400 wfaEncodeTLV(WFA_STA_GET_EVENT_DETAILS_RESP_TLV, sizeof(infoResp), (BYTE *)&infoResp, respBuf);
4401 *respLen = WFA_TLV_HDR_LEN + sizeof(infoResp);
4402
4403 return WFA_SUCCESS;
4404}
4405
4406
4407
4408