blob: ada3f90a42ac655c5b99e005b5075660c6e33070 [file] [log] [blame]
Jouni Malinencd4e3c32015-10-29 12:39:56 +02001/*
2 * Sigma Control API DUT (station/AP/sniffer)
Amarnath Hullur Subramanyam9c381f52017-03-17 00:04:41 -07003 * Copyright (c) 2011-2013, 2017, Qualcomm Atheros, Inc.
Jouni Malinena0bf2442019-02-19 12:03:26 +02004 * Copyright (c) 2018-2019, The Linux Foundation
Jouni Malinencd4e3c32015-10-29 12:39:56 +02005 * All Rights Reserved.
6 * Licensed under the Clear BSD license. See README for more details.
7 */
8
9#include "sigma_dut.h"
Kiran Kumar Lokere0128bf92019-04-08 18:36:16 -070010#include <ctype.h>
Amarnath Hullur Subramanyam9c381f52017-03-17 00:04:41 -070011#include "miracast.h"
Anurag Das2052daa2018-08-31 14:35:25 +053012#include <sys/wait.h>
13#include "wpa_ctrl.h"
14#include "wpa_helpers.h"
Jouni Malinencd4e3c32015-10-29 12:39:56 +020015
16
Jouni Malinena0bf2442019-02-19 12:03:26 +020017static enum sigma_cmd_result cmd_dev_send_frame(struct sigma_dut *dut,
18 struct sigma_conn *conn,
19 struct sigma_cmd *cmd)
Jouni Malinencd4e3c32015-10-29 12:39:56 +020020{
Amarnath Hullur Subramanyam9c381f52017-03-17 00:04:41 -070021#ifdef MIRACAST
22 const char *program = get_param(cmd, "Program");
23
24 if (program && (strcasecmp(program, "WFD") == 0 ||
25 strcasecmp(program, "DisplayR2") == 0))
26 return miracast_dev_send_frame(dut, conn, cmd);
27#endif /* MIRACAST */
28
Jouni Malinencd4e3c32015-10-29 12:39:56 +020029 if (dut->mode == SIGMA_MODE_STATION ||
30 dut->mode == SIGMA_MODE_UNKNOWN) {
31 sigma_dut_print(dut, DUT_MSG_DEBUG, "Convert "
32 "dev_send_frame to sta_send_frame");
33 return cmd_sta_send_frame(dut, conn, cmd);
34 }
35
36 if (dut->mode == SIGMA_MODE_AP) {
37 sigma_dut_print(dut, DUT_MSG_DEBUG, "Convert "
38 "dev_send_frame to ap_send_frame");
39 return cmd_ap_send_frame(dut, conn, cmd);
40 }
41
42#ifdef CONFIG_WLANTEST
43 sigma_dut_print(dut, DUT_MSG_DEBUG, "Convert dev_send_frame to "
44 "wlantest_send_frame");
45 return cmd_wlantest_send_frame(dut, conn, cmd);
46#else /* CONFIG_WLANTEST */
47 send_resp(dut, conn, SIGMA_ERROR,
48 "errorCode,Unsupported dev_send_frame");
Jouni Malinena0bf2442019-02-19 12:03:26 +020049 return STATUS_SENT;
Jouni Malinencd4e3c32015-10-29 12:39:56 +020050#endif /* CONFIG_WLANTEST */
51}
52
53
Jouni Malinena0bf2442019-02-19 12:03:26 +020054static enum sigma_cmd_result cmd_dev_set_parameter(struct sigma_dut *dut,
55 struct sigma_conn *conn,
56 struct sigma_cmd *cmd)
Jouni Malinencd4e3c32015-10-29 12:39:56 +020057{
58 const char *device = get_param(cmd, "Device");
59
60 if (device && strcasecmp(device, "STA") == 0) {
61 sigma_dut_print(dut, DUT_MSG_DEBUG, "Convert "
62 "dev_set_parameter to sta_set_parameter");
63 return cmd_sta_set_parameter(dut, conn, cmd);
64 }
65
Jouni Malinena0bf2442019-02-19 12:03:26 +020066 return INVALID_SEND_STATUS;
Jouni Malinencd4e3c32015-10-29 12:39:56 +020067}
68
69
Jouni Malinena0bf2442019-02-19 12:03:26 +020070static enum sigma_cmd_result cmd_dev_exec_action(struct sigma_dut *dut,
71 struct sigma_conn *conn,
72 struct sigma_cmd *cmd)
Amarnath Hullur Subramanyam9c381f52017-03-17 00:04:41 -070073{
Amarnath Hullur Subramanyam9c381f52017-03-17 00:04:41 -070074 const char *program = get_param(cmd, "Program");
75
Jouni Malinend86e5822017-08-29 03:55:32 +030076#ifdef MIRACAST
Amarnath Hullur Subramanyam9c381f52017-03-17 00:04:41 -070077 if (program && (strcasecmp(program, "WFD") == 0 ||
Jouni Malinend86e5822017-08-29 03:55:32 +030078 strcasecmp(program, "DisplayR2") == 0)) {
79 if (get_param(cmd, "interface") == NULL)
Jouni Malinena0bf2442019-02-19 12:03:26 +020080 return INVALID_SEND_STATUS;
Amarnath Hullur Subramanyam9c381f52017-03-17 00:04:41 -070081 return miracast_dev_exec_action(dut, conn, cmd);
Jouni Malinend86e5822017-08-29 03:55:32 +030082 }
Amarnath Hullur Subramanyam9c381f52017-03-17 00:04:41 -070083#endif /* MIRACAST */
84
Jouni Malinend86e5822017-08-29 03:55:32 +030085 if (program && strcasecmp(program, "DPP") == 0)
86 return dpp_dev_exec_action(dut, conn, cmd);
87
Jouni Malinena0bf2442019-02-19 12:03:26 +020088 return ERROR_SEND_STATUS;
Amarnath Hullur Subramanyam9c381f52017-03-17 00:04:41 -070089}
90
91
Jouni Malinena0bf2442019-02-19 12:03:26 +020092static enum sigma_cmd_result cmd_dev_configure_ie(struct sigma_dut *dut,
93 struct sigma_conn *conn,
94 struct sigma_cmd *cmd)
Jouni Malinen3c367e82017-06-23 17:01:47 +030095{
96 const char *ie_name = get_param(cmd, "IE_Name");
97 const char *contents = get_param(cmd, "Contents");
98
99 if (!ie_name || !contents)
Jouni Malinena0bf2442019-02-19 12:03:26 +0200100 return INVALID_SEND_STATUS;
Jouni Malinen3c367e82017-06-23 17:01:47 +0300101
102 if (strcasecmp(ie_name, "RSNE") != 0) {
103 send_resp(dut, conn, SIGMA_ERROR,
104 "errorCode,Unsupported IE_Name value");
Jouni Malinena0bf2442019-02-19 12:03:26 +0200105 return STATUS_SENT;
Jouni Malinen3c367e82017-06-23 17:01:47 +0300106 }
107
108 free(dut->rsne_override);
109 dut->rsne_override = strdup(contents);
110
Jouni Malinena0bf2442019-02-19 12:03:26 +0200111 return dut->rsne_override ? SUCCESS_SEND_STATUS : ERROR_SEND_STATUS;
Jouni Malinen3c367e82017-06-23 17:01:47 +0300112}
113
114
Jouni Malinena0bf2442019-02-19 12:03:26 +0200115static enum sigma_cmd_result cmd_dev_ble_action(struct sigma_dut *dut,
116 struct sigma_conn *conn,
117 struct sigma_cmd *cmd)
Anurag Das2052daa2018-08-31 14:35:25 +0530118{
119#ifdef ANDROID
Anurag Das2052daa2018-08-31 14:35:25 +0530120 const char *ble_op = get_param(cmd, "BLEOp");
121 const char *prog = get_param(cmd, "Prog");
122 const char *service_name = get_param(cmd, "ServiceName");
123 const char *ble_role = get_param(cmd, "BLERole");
124 const char *discovery_type = get_param(cmd, "DiscoveryType");
125 const char *msg_type = get_param(cmd, "messagetype");
126 const char *action = get_param(cmd, "action");
127 const char *M2Transmit = get_param(cmd, "M2Transmit");
128 char *argv[17];
129 pid_t pid;
130
131 if (prog && ble_role && action && msg_type) {
132 send_resp(dut, conn, SIGMA_COMPLETE,
133 "OrgID,0x00,TransDataHeader,0x00,BloomFilterElement,NULL");
Jouni Malinena0bf2442019-02-19 12:03:26 +0200134 return STATUS_SENT;
Anurag Das2052daa2018-08-31 14:35:25 +0530135 }
136 if (!ble_op || !prog || !service_name || !ble_role || !discovery_type) {
137 sigma_dut_print(dut, DUT_MSG_ERROR, "Invalid arguments");
Jouni Malinena0bf2442019-02-19 12:03:26 +0200138 return INVALID_SEND_STATUS;
Anurag Das2052daa2018-08-31 14:35:25 +0530139 }
140
141 if ((strcasecmp(prog, "NAN") != 0)) {
142 sigma_dut_print(dut, DUT_MSG_ERROR, "Program %s not supported",
143 prog);
Jouni Malinena0bf2442019-02-19 12:03:26 +0200144 return INVALID_SEND_STATUS;
Anurag Das2052daa2018-08-31 14:35:25 +0530145 }
146
147 if (strcasecmp(ble_role, "seeker") != 0 &&
148 strcasecmp(ble_role, "provider") != 0 &&
149 strcasecmp(ble_role, "browser") != 0) {
150 sigma_dut_print(dut, DUT_MSG_ERROR, "Invalid BLERole: %s",
151 ble_role);
Jouni Malinena0bf2442019-02-19 12:03:26 +0200152 return INVALID_SEND_STATUS;
Anurag Das2052daa2018-08-31 14:35:25 +0530153 }
154
155 if (strcasecmp(discovery_type, "active") != 0 &&
156 strcasecmp(discovery_type, "passive") != 0) {
157 sigma_dut_print(dut, DUT_MSG_ERROR, "Invalid DiscoveryType: %s",
158 discovery_type);
Jouni Malinena0bf2442019-02-19 12:03:26 +0200159 return INVALID_SEND_STATUS;
Anurag Das2052daa2018-08-31 14:35:25 +0530160 }
161
162 if (!M2Transmit)
163 M2Transmit = "disable";
164
165 argv[0] = "am";
166 argv[1] = "start";
167 argv[2] = "-n";
168 argv[3] = "org.codeaurora.nanservicediscovery/org.codeaurora.nanservicediscovery.MainActivity";
169 argv[4] = "--es";
170 argv[5] = "service";
171 argv[6] = (char *) service_name;
172 argv[7] = "--es";
173 argv[8] = "role";
174 argv[9] = (char *) ble_role;
175 argv[10] = "--es";
176 argv[11] = "scantype";
177 argv[12] = (char *) discovery_type;
178 argv[13] = "--es";
179 argv[14] = "M2Transmit";
180 argv[15] = (char *) M2Transmit;
181 argv[16] = NULL;
182
183 pid = fork();
184 if (pid == -1) {
185 sigma_dut_print(dut, DUT_MSG_ERROR, "fork: %s",
186 strerror(errno));
Jouni Malinena0bf2442019-02-19 12:03:26 +0200187 return ERROR_SEND_STATUS;
Anurag Das2052daa2018-08-31 14:35:25 +0530188 }
189
190 if (pid == 0) {
191 execv("/system/bin/am", argv);
192 sigma_dut_print(dut, DUT_MSG_ERROR, "execv: %s",
193 strerror(errno));
194 exit(0);
Jouni Malinena0bf2442019-02-19 12:03:26 +0200195 return ERROR_SEND_STATUS;
Anurag Das2052daa2018-08-31 14:35:25 +0530196 }
197
198 dut->nanservicediscoveryinprogress = 1;
199#endif /* ANDROID */
200
Jouni Malinena0bf2442019-02-19 12:03:26 +0200201 return SUCCESS_SEND_STATUS;
Anurag Das2052daa2018-08-31 14:35:25 +0530202}
203
204
Kiran Kumar Lokere0128bf92019-04-08 18:36:16 -0700205/* Runtime ID must contain only numbers */
206static int is_runtime_id_valid(struct sigma_dut *dut, const char *val)
207{
208 int i;
209
210 for (i = 0; val[i] != '\0'; i++) {
211 if (!isdigit(val[i])) {
212 sigma_dut_print(dut, DUT_MSG_DEBUG,
213 "Invalid Runtime_ID %s", val);
214 return 0;
215 }
216 }
217
218 return 1;
219}
220
221
222static int build_log_dir(struct sigma_dut *dut, char *dir, size_t dir_size)
223{
224 int res;
225 const char *vendor;
226 int i;
227
228 vendor = dut->vendor_name ? dut->vendor_name : "Qualcomm";
229
230 if (dut->log_file_dir) {
231 res = snprintf(dir, dir_size, "%s/%s", dut->log_file_dir,
232 vendor);
233 } else {
234#ifdef ANDROID
235 res = snprintf(dir, dir_size, "/data/vendor/wifi/%s",
236 vendor);
237#else /* ANDROID */
238 res = snprintf(dir, dir_size, "/var/log/%s", vendor);
239#endif /* ANDROID */
240 }
241
242 if (res < 0 || res >= dir_size)
243 return -1;
244
245 /* Check for valid vendor name in log dir path since the log dir
246 * (/var/log/vendor) is deleted in dev_stop routine. This check is to
247 * avoid any unintended file deletion.
248 */
249 for (i = 0; vendor[i] != '\0'; i++) {
250 if (!isalpha(vendor[i])) {
251 sigma_dut_print(dut, DUT_MSG_DEBUG,
252 "Invalid char %c in vendor name %s",
253 vendor[i], vendor);
254 return -1;
255 }
256 }
257
258 return 0;
259}
260
261
262/* User has to redirect wpa_supplicant logs to the following file. */
263#ifndef WPA_SUPPLICANT_LOG_FILE
264#define WPA_SUPPLICANT_LOG_FILE "/var/log/supplicant_log/wpa_log.txt"
265#endif /* WPA_SUPPLICANT_LOG_FILE */
Anurag Das2052daa2018-08-31 14:35:25 +0530266
Jouni Malinena0bf2442019-02-19 12:03:26 +0200267static enum sigma_cmd_result cmd_dev_start_test(struct sigma_dut *dut,
268 struct sigma_conn *conn,
269 struct sigma_cmd *cmd)
Peng Xua7ac56e2018-06-26 16:07:19 -0700270{
Kiran Kumar Lokere0128bf92019-04-08 18:36:16 -0700271 const char *val;
272 char buf[250];
273 char dir[200];
274 FILE *supp_log;
275 int res;
276
277 val = get_param(cmd, "Runtime_ID");
278 if (!(val && is_runtime_id_valid(dut, val)))
279 return INVALID_SEND_STATUS;
280
281 if (build_log_dir(dut, dir, sizeof(dir)) < 0)
282 return ERROR_SEND_STATUS;
283
284 supp_log = fopen(WPA_SUPPLICANT_LOG_FILE, "r");
285 if (!supp_log) {
286 sigma_dut_print(dut, DUT_MSG_ERROR,
287 "Failed to open wpa_log file %s",
288 WPA_SUPPLICANT_LOG_FILE);
289 } else {
290 /* Get the wpa_supplicant log file size */
291 if (fseek(supp_log, 0, SEEK_END))
292 sigma_dut_print(dut, DUT_MSG_ERROR,
293 "Failed to get file size for read");
294 else
295 dut->wpa_log_size = ftell(supp_log);
296
297 fclose(supp_log);
298 }
299
300 strlcpy(dut->dev_start_test_runtime_id, val,
301 sizeof(dut->dev_start_test_runtime_id));
302 sigma_dut_print(dut, DUT_MSG_DEBUG, "Runtime_ID %s",
303 dut->dev_start_test_runtime_id);
304
305 run_system_wrapper(dut, "rm -rf %s", dir);
306 run_system_wrapper(dut, "mkdir -p %s", dir);
307
308#ifdef ANDROID
309 run_system_wrapper(dut, "logcat -v time > %s/logcat_%s.txt &",
310 dir, dut->dev_start_test_runtime_id);
311#else /* ANDROID */
312 /* Open log file for sigma_dut logs. This is not needed for Android, as
313 * we are already collecting logcat. */
314 res = snprintf(buf, sizeof(buf), "%s/sigma_%s.txt", dir,
315 dut->dev_start_test_runtime_id);
316 if (res >= 0 && res < sizeof(buf)) {
317 if (dut->log_file_fd)
318 fclose(dut->log_file_fd);
319
320 dut->log_file_fd = fopen(buf, "a");
321 if (!dut->log_file_fd)
322 sigma_dut_print(dut, DUT_MSG_ERROR,
323 "Failed to create sigma_dut log %s",
324 buf);
325 }
326
327 run_system_wrapper(dut, "killall -9 cnss_diag_lite");
328 run_system_wrapper(dut,
329 "cnss_diag_lite -c -x 31 > %s/cnss_diag_id_%s.txt &",
330 dir, dut->dev_start_test_runtime_id);
331#endif /* ANDROID */
332
Jouni Malinena0bf2442019-02-19 12:03:26 +0200333 return SUCCESS_SEND_STATUS;
Peng Xua7ac56e2018-06-26 16:07:19 -0700334}
335
336
Kiran Kumar Lokere0128bf92019-04-08 18:36:16 -0700337static int is_allowed_char(char ch)
338{
339 return strchr("./-_", ch) != NULL;
340}
341
342
343static int is_destpath_valid(struct sigma_dut *dut, const char *val)
344{
345 int i;
346
347 for (i = 0; val[i] != '\0'; i++) {
348 if (!(isalnum(val[i]) || is_allowed_char(val[i]))) {
349 sigma_dut_print(dut, DUT_MSG_DEBUG,
350 "Invalid char %c in destpath %s",
351 val[i], val);
352 return 0;
353 }
354 }
355
356 return 1;
357}
358
359
360#ifndef ANDROID
361#define SUPP_LOG_BUFF_SIZE 4 * 1024
362
363static int save_supplicant_log(struct sigma_dut *dut)
364{
365 char dir[200];
366 char buf[300];
367 FILE *wpa_log = NULL;
368 FILE *supp_log;
369 char *buff_ptr = NULL;
370 unsigned int file_size;
371 unsigned int file_size_orig;
372 int status = -1, res;
373
374 if (build_log_dir(dut, dir, sizeof(dir)) < 0)
375 return -1;
376
377 res = snprintf(buf, sizeof(buf), "%s/wpa_supplicant_log_%s.txt", dir,
378 dut->dev_start_test_runtime_id);
379 if (res < 0 || res >= sizeof(buf))
380 return -1;
381
382 supp_log = fopen(WPA_SUPPLICANT_LOG_FILE, "r");
383 if (!supp_log) {
384 sigma_dut_print(dut, DUT_MSG_ERROR,
385 "Failed to open wpa_log file %s",
386 WPA_SUPPLICANT_LOG_FILE);
387 return -1;
388 }
389
390 /* Get the wpa_supplicant log file size */
391 if (fseek(supp_log, 0, SEEK_END)) {
392 sigma_dut_print(dut, DUT_MSG_ERROR,
393 "Failed to get file size for read");
394 goto exit;
395 }
396 file_size_orig = ftell(supp_log);
397
398 if (file_size_orig < dut->wpa_log_size) {
399 sigma_dut_print(dut, DUT_MSG_ERROR,
400 "file size err, new size %u, old size %u",
401 file_size_orig, dut->wpa_log_size);
402 goto exit;
403 }
404
405 /* Get the wpa_supplicant file size for current test */
406 file_size = file_size_orig - dut->wpa_log_size;
407
408 wpa_log = fopen(buf, "w");
409 if (!wpa_log) {
410 sigma_dut_print(dut, DUT_MSG_ERROR,
411 "Failed to create tmp wpa_log file %s", buf);
412 goto exit;
413 }
414
415 if (fseek(supp_log, dut->wpa_log_size, SEEK_SET)) {
416 sigma_dut_print(dut, DUT_MSG_ERROR,
417 "Failed to set wpa_log file ptr for read");
418 goto exit;
419 }
420
421 buff_ptr = malloc(SUPP_LOG_BUFF_SIZE);
422 if (!buff_ptr) {
423 sigma_dut_print(dut, DUT_MSG_ERROR,
424 "Failed to alloc buffer of size %d",
425 SUPP_LOG_BUFF_SIZE);
426 goto exit;
427 }
428
429 /* Read wpa_supplicant log file in 4K byte chunks */
430 do {
431 unsigned int num_bytes_to_read;
432 unsigned int bytes_read;
433
434 num_bytes_to_read = (file_size > SUPP_LOG_BUFF_SIZE) ?
435 SUPP_LOG_BUFF_SIZE : file_size;
436 bytes_read = fread(buff_ptr, 1, num_bytes_to_read, supp_log);
437 if (!bytes_read) {
438 sigma_dut_print(dut, DUT_MSG_ERROR,
439 "Failed to read wpa_supplicant log");
440 goto exit;
441 }
442 if (bytes_read != num_bytes_to_read) {
443 sigma_dut_print(dut, DUT_MSG_DEBUG,
444 "wpa_supplicant log read err, read %d, num_bytes_to_read %d",
445 bytes_read, num_bytes_to_read);
446 goto exit;
447 }
448 fwrite(buff_ptr, 1, bytes_read, wpa_log);
449 file_size -= bytes_read;
450 } while (file_size > 0);
451 status = 0;
452
453exit:
454 if (wpa_log)
455 fclose(wpa_log);
456 fclose(supp_log);
457 free(buff_ptr);
458
459 return status;
460}
461#endif /* !ANDROID */
462
463
Jouni Malinena0bf2442019-02-19 12:03:26 +0200464static enum sigma_cmd_result cmd_dev_stop_test(struct sigma_dut *dut,
465 struct sigma_conn *conn,
466 struct sigma_cmd *cmd)
Peng Xua7ac56e2018-06-26 16:07:19 -0700467{
Kiran Kumar Lokere0128bf92019-04-08 18:36:16 -0700468 const char *val;
469 char buf[300];
470 char out_file[100];
471 char dir[200];
472 int res;
473
474 val = get_param(cmd, "Runtime_ID");
475 if (!val || strcmp(val, dut->dev_start_test_runtime_id) != 0) {
476 sigma_dut_print(dut, DUT_MSG_ERROR, "Invalid runtime id");
477 return ERROR_SEND_STATUS;
478 }
479
480 if (build_log_dir(dut, dir, sizeof(dir)) < 0)
481 return ERROR_SEND_STATUS;
482
483#ifdef ANDROID
484 /* Copy all cnss_diag logs to dir */
485 run_system_wrapper(dut, "cp -a /data/vendor/wifi/wlan_logs/* %s", dir);
486#else /* ANDROID */
487 if (dut->log_file_fd) {
488 fclose(dut->log_file_fd);
489 dut->log_file_fd = NULL;
490 }
491 if (save_supplicant_log(dut))
492 sigma_dut_print(dut, DUT_MSG_ERROR,
493 "Failed to save wpa_supplicant log");
494#endif /* ANDROID */
495
496 res = snprintf(out_file, sizeof(out_file), "%s_%s_%s.tar.gz",
497 dut->vendor_name ? dut->vendor_name : "Qualcomm",
498 dut->model_name ? dut->model_name : "Unknown",
499 dut->dev_start_test_runtime_id);
500 if (res < 0 || res >= sizeof(out_file))
501 return ERROR_SEND_STATUS;
502
503 if (run_system_wrapper(dut, "tar -czvf %s/../%s %s", dir, out_file,
504 dir) < 0) {
505 sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to create tar: %s",
506 buf);
507 return ERROR_SEND_STATUS;
508 }
509
510 val = get_param(cmd, "destpath");
511 if (!(val && is_destpath_valid(dut, val))) {
512 sigma_dut_print(dut, DUT_MSG_DEBUG, "Invalid path for TFTP %s",
513 val);
514 return ERROR_SEND_STATUS;
515 }
516
517 res = snprintf(buf, sizeof(buf), "tftp %s -c put %s/%s %s/%s",
518 inet_ntoa(conn->addr.sin_addr), dir, out_file, val,
519 out_file);
520 if (res < 0 || res >= sizeof(buf))
521 return ERROR_SEND_STATUS;
522 if (run_system_wrapper(dut, buf) < 0) {
523 sigma_dut_print(dut, DUT_MSG_ERROR,
524 "TFTP file transfer failed: %s", buf);
525 return ERROR_SEND_STATUS;
526 }
527 sigma_dut_print(dut, DUT_MSG_DEBUG, "TFTP file transfer: %s", buf);
528 snprintf(buf, sizeof(buf), "filename,%s", out_file);
529 send_resp(dut, conn, SIGMA_COMPLETE, buf);
530 run_system_wrapper(dut, "rm -f %s/../%s", dir, out_file);
531 run_system_wrapper(dut, "rm -rf %s", dir);
532
Jouni Malinena0bf2442019-02-19 12:03:26 +0200533 return SUCCESS_SEND_STATUS;
Peng Xua7ac56e2018-06-26 16:07:19 -0700534}
535
536
Jouni Malinena0bf2442019-02-19 12:03:26 +0200537static enum sigma_cmd_result cmd_dev_get_log(struct sigma_dut *dut,
538 struct sigma_conn *conn,
539 struct sigma_cmd *cmd)
Peng Xua7ac56e2018-06-26 16:07:19 -0700540{
Jouni Malinena0bf2442019-02-19 12:03:26 +0200541 return SUCCESS_SEND_STATUS;
Peng Xua7ac56e2018-06-26 16:07:19 -0700542}
543
544
Jouni Malinen3c367e82017-06-23 17:01:47 +0300545static int req_intf(struct sigma_cmd *cmd)
546{
547 return get_param(cmd, "interface") == NULL ? -1 : 0;
548}
549
550
Anurag Das2052daa2018-08-31 14:35:25 +0530551static int req_role_svcname(struct sigma_cmd *cmd)
552{
553 if (!get_param(cmd, "BLERole"))
554 return -1;
555 if (get_param(cmd, "BLEOp") && !get_param(cmd, "ServiceName"))
556 return -1;
557 return 0;
558}
559
560
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200561static int req_intf_prog(struct sigma_cmd *cmd)
562{
563 if (get_param(cmd, "interface") == NULL)
564 return -1;
565 if (get_param(cmd, "program") == NULL)
566 return -1;
567 return 0;
568}
569
570
Jouni Malinend86e5822017-08-29 03:55:32 +0300571static int req_prog(struct sigma_cmd *cmd)
572{
573 if (get_param(cmd, "program") == NULL)
574 return -1;
575 return 0;
576}
577
578
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200579void dev_register_cmds(void)
580{
Alexei Avshalom Lazar4a3c2f82019-05-02 13:35:37 +0300581 sigma_dut_reg_cmd("dev_send_frame", req_prog, cmd_dev_send_frame);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200582 sigma_dut_reg_cmd("dev_set_parameter", req_intf_prog,
583 cmd_dev_set_parameter);
Jouni Malinend86e5822017-08-29 03:55:32 +0300584 sigma_dut_reg_cmd("dev_exec_action", req_prog,
Amarnath Hullur Subramanyam9c381f52017-03-17 00:04:41 -0700585 cmd_dev_exec_action);
Jouni Malinen3c367e82017-06-23 17:01:47 +0300586 sigma_dut_reg_cmd("dev_configure_ie", req_intf, cmd_dev_configure_ie);
Peng Xua7ac56e2018-06-26 16:07:19 -0700587 sigma_dut_reg_cmd("dev_start_test", NULL, cmd_dev_start_test);
588 sigma_dut_reg_cmd("dev_stop_test", NULL, cmd_dev_stop_test);
589 sigma_dut_reg_cmd("dev_get_log", NULL, cmd_dev_get_log);
Anurag Das2052daa2018-08-31 14:35:25 +0530590 sigma_dut_reg_cmd("dev_ble_action", req_role_svcname,
591 cmd_dev_ble_action);
Jouni Malinencd4e3c32015-10-29 12:39:56 +0200592}