Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Sigma Control API DUT (station/AP) |
| 3 | * Copyright (c) 2010, Atheros Communications, Inc. |
Jouni Malinen | a3a88ad | 2019-02-19 12:17:31 +0200 | [diff] [blame] | 4 | * Copyright (c) 2019, The Linux Foundation |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5 | * All Rights Reserved. |
| 6 | * Licensed under the Clear BSD license. See README for more details. |
| 7 | */ |
| 8 | |
| 9 | #include "sigma_dut.h" |
| 10 | |
| 11 | |
Jouni Malinen | a3a88ad | 2019-02-19 12:17:31 +0200 | [diff] [blame] | 12 | static enum sigma_cmd_result cmd_power_switch_ctrl(struct sigma_dut *dut, |
| 13 | struct sigma_conn *conn, |
| 14 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 15 | { |
Jouni Malinen | a3a88ad | 2019-02-19 12:17:31 +0200 | [diff] [blame] | 16 | return SUCCESS_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 17 | } |
| 18 | |
| 19 | |
Jouni Malinen | a3a88ad | 2019-02-19 12:17:31 +0200 | [diff] [blame] | 20 | static enum sigma_cmd_result cmd_power_switch_reset(struct sigma_dut *dut, |
| 21 | struct sigma_conn *conn, |
| 22 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 23 | { |
| 24 | if (system("killall hostapd") == 0) { |
| 25 | int i; |
| 26 | |
| 27 | /* Wait some time to allow hostapd to complete cleanup before |
| 28 | * starting a new process */ |
| 29 | for (i = 0; i < 10; i++) { |
| 30 | usleep(500000); |
| 31 | if (system("pidof hostapd") != 0) |
| 32 | break; |
| 33 | } |
| 34 | } |
Jouni Malinen | a3a88ad | 2019-02-19 12:17:31 +0200 | [diff] [blame] | 35 | return SUCCESS_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | |
Jouni Malinen | a3a88ad | 2019-02-19 12:17:31 +0200 | [diff] [blame] | 39 | static enum sigma_cmd_result cmd_powerswitch(struct sigma_dut *dut, |
| 40 | struct sigma_conn *conn, |
| 41 | struct sigma_cmd *cmd) |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 42 | { |
Jouni Malinen | a3a88ad | 2019-02-19 12:17:31 +0200 | [diff] [blame] | 43 | return SUCCESS_SEND_STATUS; |
Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | |
| 47 | void powerswitch_register_cmds(void) |
| 48 | { |
| 49 | sigma_dut_reg_cmd("power_switch_ctrl", NULL, cmd_power_switch_ctrl); |
| 50 | sigma_dut_reg_cmd("power_switch_reset", NULL, cmd_power_switch_reset); |
| 51 | sigma_dut_reg_cmd("PowerSwitch", NULL, cmd_powerswitch); |
| 52 | } |