1 /*
2 * Copyright (c) 2023 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 /* @file
8 * @brief wpa_cli implementation for Zephyr OS
9 */
10
11 #include <zephyr/kernel.h>
12 #include <zephyr/shell/shell.h>
13 #include <zephyr/init.h>
14
15 #include "wpa_cli_zephyr.h"
16 #ifdef CONFIG_WIFI_NM_HOSTAPD_AP
17 #include "hostapd_cli_zephyr.h"
18 #endif
19
cmd_wpa_cli(const struct shell * sh,size_t argc,const char * argv[])20 static int cmd_wpa_cli(const struct shell *sh,
21 size_t argc,
22 const char *argv[])
23 {
24 ARG_UNUSED(sh);
25
26 if (argc == 1) {
27 shell_error(sh, "Missing argument");
28 return -EINVAL;
29 }
30
31 argv[argc] = "interactive";
32 argc++;
33
34 /* Remove wpa_cli from the argument list */
35 return zephyr_wpa_ctrl_zephyr_cmd(argc - 1, &argv[1]);
36 }
37
38 #ifdef CONFIG_WIFI_NM_HOSTAPD_AP
cmd_hostapd_cli(const struct shell * sh,size_t argc,const char * argv[])39 static int cmd_hostapd_cli(const struct shell *sh, size_t argc, const char *argv[])
40 {
41 ARG_UNUSED(sh);
42
43 if (argc == 1) {
44 shell_error(sh, "Missing argument");
45 return -EINVAL;
46 }
47
48 argv[argc] = "interactive";
49 argc++;
50
51 /* Remove hostapd_cli from the argument list */
52 return zephyr_hostapd_ctrl_zephyr_cmd(argc - 1, &argv[1]);
53 }
54 #endif
55
56 /* Persisting with "wpa_cli" naming for compatibility with Wi-Fi
57 * certification applications and scripts.
58 */
59 SHELL_CMD_REGISTER(wpa_cli,
60 NULL,
61 "wpa_cli commands (only for internal use)",
62 cmd_wpa_cli);
63 #ifdef CONFIG_WIFI_NM_HOSTAPD_AP
64 SHELL_CMD_REGISTER(hostapd_cli, NULL, "hostapd_cli commands (only for internal use)",
65 cmd_hostapd_cli);
66 #endif
67