Lines Matching +full:ctrl +full:- +full:len

2  * hostapd - command line interface for hostapd daemon
3 * Copyright (c) 2004-2022, Jouni Malinen <j@w1.fi>
24 "Copyright (c) 2004-2024, Jouni Malinen <j@w1.fi> and contributors";
48 static void update_stations(struct wpa_ctrl *ctrl);
57 "usage: hostapd_cli [-p<path>] [-i<ifname>] [-hvBr] " in usage()
58 "[-a<path>] \\\n" in usage()
59 " [-P<pid file>] [-G<ping interval>] [command..]\n" in usage()
62 " -h help (show this usage text)\n" in usage()
63 " -v shown version information\n" in usage()
64 " -p<path> path to find control sockets (default: " in usage()
66 " -s<dir_path> dir path to open client sockets (default: " in usage()
68 " -a<file> run in daemon mode executing the action file " in usage()
71 " -r try to reconnect when client socket is " in usage()
73 " This is useful only when used with -a.\n" in usage()
74 " -B run a daemon in the background\n" in usage()
75 " -i<ifname> Interface to listen on (default: first " in usage()
82 static void register_event_handler(struct wpa_ctrl *ctrl) in register_event_handler() argument
88 !eloop_register_read_sock(wpa_ctrl_get_fd(ctrl), in register_event_handler()
95 static void unregister_event_handler(struct wpa_ctrl *ctrl) in unregister_event_handler() argument
100 eloop_unregister_read_sock(wpa_ctrl_get_fd(ctrl)); in unregister_event_handler()
162 return -1; in hostapd_cli_reconnect()
168 return -1; in hostapd_cli_reconnect()
172 return -1; in hostapd_cli_reconnect()
186 static void hostapd_cli_msg_cb(char *msg, size_t len) in hostapd_cli_msg_cb() argument
193 static int _wpa_ctrl_command(struct wpa_ctrl *ctrl, const char *cmd, int print) in _wpa_ctrl_command() argument
196 size_t len; in _wpa_ctrl_command() local
200 printf("Not connected to hostapd - command dropped.\n"); in _wpa_ctrl_command()
201 return -1; in _wpa_ctrl_command()
203 len = sizeof(buf) - 1; in _wpa_ctrl_command()
204 ret = wpa_ctrl_request(ctrl, cmd, strlen(cmd), buf, &len, in _wpa_ctrl_command()
206 if (ret == -2) { in _wpa_ctrl_command()
208 return -2; in _wpa_ctrl_command()
211 return -1; in _wpa_ctrl_command()
214 buf[len] = '\0'; in _wpa_ctrl_command()
221 static inline int wpa_ctrl_command(struct wpa_ctrl *ctrl, const char *cmd) in wpa_ctrl_command() argument
223 return _wpa_ctrl_command(ctrl, cmd, 1); in wpa_ctrl_command()
227 static int hostapd_cli_cmd(struct wpa_ctrl *ctrl, const char *cmd, in hostapd_cli_cmd() argument
233 printf("Invalid %s command - at least %d argument%s required.\n", in hostapd_cli_cmd()
235 return -1; in hostapd_cli_cmd()
238 return -1; in hostapd_cli_cmd()
239 return wpa_ctrl_command(ctrl, buf); in hostapd_cli_cmd()
243 static int hostapd_cli_cmd_ping(struct wpa_ctrl *ctrl, int argc, char *argv[]) in hostapd_cli_cmd_ping() argument
245 return wpa_ctrl_command(ctrl, "PING"); in hostapd_cli_cmd_ping()
249 static int hostapd_cli_cmd_relog(struct wpa_ctrl *ctrl, int argc, char *argv[]) in hostapd_cli_cmd_relog() argument
251 return wpa_ctrl_command(ctrl, "RELOG"); in hostapd_cli_cmd_relog()
255 static int hostapd_cli_cmd_close_log(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_close_log() argument
258 return wpa_ctrl_command(ctrl, "CLOSE_LOG"); in hostapd_cli_cmd_close_log()
262 static int hostapd_cli_cmd_status(struct wpa_ctrl *ctrl, int argc, char *argv[]) in hostapd_cli_cmd_status() argument
265 return wpa_ctrl_command(ctrl, "STATUS-DRIVER"); in hostapd_cli_cmd_status()
266 return wpa_ctrl_command(ctrl, "STATUS"); in hostapd_cli_cmd_status()
270 static int hostapd_cli_cmd_mib(struct wpa_ctrl *ctrl, int argc, char *argv[]) in hostapd_cli_cmd_mib() argument
275 return wpa_ctrl_command(ctrl, buf); in hostapd_cli_cmd_mib()
277 return wpa_ctrl_command(ctrl, "MIB"); in hostapd_cli_cmd_mib()
285 size_t len; in hostapd_cli_exec() local
288 len = os_strlen(arg1) + os_strlen(arg2) + 2; in hostapd_cli_exec()
289 arg = os_malloc(len); in hostapd_cli_exec()
291 return -1; in hostapd_cli_exec()
292 os_snprintf(arg, len, "%s %s", arg1, arg2); in hostapd_cli_exec()
300 static void hostapd_cli_action_process(char *msg, size_t len) in hostapd_cli_action_process() argument
317 static void hostapd_cli_action_cb(char *msg, size_t len) in hostapd_cli_action_cb() argument
319 hostapd_cli_action_process(msg, len); in hostapd_cli_action_cb()
323 static int hostapd_cli_cmd_sta(struct wpa_ctrl *ctrl, int argc, char *argv[]) in hostapd_cli_cmd_sta() argument
327 printf("Invalid 'sta' command - at least one argument, STA " in hostapd_cli_cmd_sta()
329 return -1; in hostapd_cli_cmd_sta()
335 return wpa_ctrl_command(ctrl, buf); in hostapd_cli_cmd_sta()
354 static int hostapd_cli_cmd_new_sta(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_new_sta() argument
359 printf("Invalid 'new_sta' command - exactly one argument, STA " in hostapd_cli_cmd_new_sta()
361 return -1; in hostapd_cli_cmd_new_sta()
364 return wpa_ctrl_command(ctrl, buf); in hostapd_cli_cmd_new_sta()
368 static int hostapd_cli_cmd_deauthenticate(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_deauthenticate() argument
373 printf("Invalid 'deauthenticate' command - exactly one " in hostapd_cli_cmd_deauthenticate()
375 return -1; in hostapd_cli_cmd_deauthenticate()
382 return wpa_ctrl_command(ctrl, buf); in hostapd_cli_cmd_deauthenticate()
386 static int hostapd_cli_cmd_disassociate(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_disassociate() argument
391 printf("Invalid 'disassociate' command - exactly one " in hostapd_cli_cmd_disassociate()
393 return -1; in hostapd_cli_cmd_disassociate()
400 return wpa_ctrl_command(ctrl, buf); in hostapd_cli_cmd_disassociate()
405 static int hostapd_cli_cmd_signature(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_signature() argument
411 printf("Invalid 'signature' command - exactly one argument, STA address, is required.\n"); in hostapd_cli_cmd_signature()
412 return -1; in hostapd_cli_cmd_signature()
415 return wpa_ctrl_command(ctrl, buf); in hostapd_cli_cmd_signature()
420 static int hostapd_cli_cmd_sa_query(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_sa_query() argument
425 printf("Invalid 'sa_query' command - exactly one argument, " in hostapd_cli_cmd_sa_query()
427 return -1; in hostapd_cli_cmd_sa_query()
430 return wpa_ctrl_command(ctrl, buf); in hostapd_cli_cmd_sa_query()
435 static int hostapd_cli_cmd_wps_pin(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_wps_pin() argument
440 printf("Invalid 'wps_pin' command - at least two arguments, " in hostapd_cli_cmd_wps_pin()
442 return -1; in hostapd_cli_cmd_wps_pin()
452 return wpa_ctrl_command(ctrl, buf); in hostapd_cli_cmd_wps_pin()
456 static int hostapd_cli_cmd_wps_check_pin(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_wps_check_pin() argument
464 "- PIN to be verified\n"); in hostapd_cli_cmd_wps_check_pin()
465 return -1; in hostapd_cli_cmd_wps_check_pin()
476 return -1; in hostapd_cli_cmd_wps_check_pin()
478 return wpa_ctrl_command(ctrl, cmd); in hostapd_cli_cmd_wps_check_pin()
482 static int hostapd_cli_cmd_wps_pbc(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_wps_pbc() argument
485 return wpa_ctrl_command(ctrl, "WPS_PBC"); in hostapd_cli_cmd_wps_pbc()
489 static int hostapd_cli_cmd_wps_cancel(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_wps_cancel() argument
492 return wpa_ctrl_command(ctrl, "WPS_CANCEL"); in hostapd_cli_cmd_wps_cancel()
497 static int hostapd_cli_cmd_wps_nfc_tag_read(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_wps_nfc_tag_read() argument
505 printf("Invalid 'wps_nfc_tag_read' command - one argument " in hostapd_cli_cmd_wps_nfc_tag_read()
507 return -1; in hostapd_cli_cmd_wps_nfc_tag_read()
513 return -1; in hostapd_cli_cmd_wps_nfc_tag_read()
516 ret = wpa_ctrl_command(ctrl, buf); in hostapd_cli_cmd_wps_nfc_tag_read()
523 static int hostapd_cli_cmd_wps_nfc_config_token(struct wpa_ctrl *ctrl, in hostapd_cli_cmd_wps_nfc_config_token() argument
530 printf("Invalid 'wps_nfc_config_token' command - one argument " in hostapd_cli_cmd_wps_nfc_config_token()
532 return -1; in hostapd_cli_cmd_wps_nfc_config_token()
539 return -1; in hostapd_cli_cmd_wps_nfc_config_token()
541 return wpa_ctrl_command(ctrl, cmd); in hostapd_cli_cmd_wps_nfc_config_token()
545 static int hostapd_cli_cmd_wps_nfc_token(struct wpa_ctrl *ctrl, in hostapd_cli_cmd_wps_nfc_token() argument
552 printf("Invalid 'wps_nfc_token' command - one argument is " in hostapd_cli_cmd_wps_nfc_token()
554 return -1; in hostapd_cli_cmd_wps_nfc_token()
560 return -1; in hostapd_cli_cmd_wps_nfc_token()
562 return wpa_ctrl_command(ctrl, cmd); in hostapd_cli_cmd_wps_nfc_token()
566 static int hostapd_cli_cmd_nfc_get_handover_sel(struct wpa_ctrl *ctrl, in hostapd_cli_cmd_nfc_get_handover_sel() argument
573 printf("Invalid 'nfc_get_handover_sel' command - two arguments " in hostapd_cli_cmd_nfc_get_handover_sel()
575 return -1; in hostapd_cli_cmd_nfc_get_handover_sel()
582 return -1; in hostapd_cli_cmd_nfc_get_handover_sel()
584 return wpa_ctrl_command(ctrl, cmd); in hostapd_cli_cmd_nfc_get_handover_sel()
590 static int hostapd_cli_cmd_wps_ap_pin(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_wps_ap_pin() argument
595 printf("Invalid 'wps_ap_pin' command - at least one argument " in hostapd_cli_cmd_wps_ap_pin()
597 return -1; in hostapd_cli_cmd_wps_ap_pin()
607 return wpa_ctrl_command(ctrl, buf); in hostapd_cli_cmd_wps_ap_pin()
611 static int hostapd_cli_cmd_wps_get_status(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_wps_get_status() argument
614 return wpa_ctrl_command(ctrl, "WPS_GET_STATUS"); in hostapd_cli_cmd_wps_get_status()
618 static int hostapd_cli_cmd_wps_config(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_wps_config() argument
627 printf("Invalid 'wps_config' command - at least two arguments " in hostapd_cli_cmd_wps_config()
629 return -1; in hostapd_cli_cmd_wps_config()
658 return wpa_ctrl_command(ctrl, buf); in hostapd_cli_cmd_wps_config()
663 static int hostapd_cli_cmd_disassoc_imminent(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_disassoc_imminent() argument
670 printf("Invalid 'disassoc_imminent' command - two arguments " in hostapd_cli_cmd_disassoc_imminent()
672 return -1; in hostapd_cli_cmd_disassoc_imminent()
678 return -1; in hostapd_cli_cmd_disassoc_imminent()
679 return wpa_ctrl_command(ctrl, buf); in hostapd_cli_cmd_disassoc_imminent()
683 static int hostapd_cli_cmd_ess_disassoc(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_ess_disassoc() argument
690 printf("Invalid 'ess_disassoc' command - three arguments (STA " in hostapd_cli_cmd_ess_disassoc()
692 return -1; in hostapd_cli_cmd_ess_disassoc()
698 return -1; in hostapd_cli_cmd_ess_disassoc()
699 return wpa_ctrl_command(ctrl, buf); in hostapd_cli_cmd_ess_disassoc()
703 static int hostapd_cli_cmd_bss_tm_req(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_bss_tm_req() argument
710 printf("Invalid 'bss_tm_req' command - at least one argument (STA addr) is needed\n"); in hostapd_cli_cmd_bss_tm_req()
711 return -1; in hostapd_cli_cmd_bss_tm_req()
716 return -1; in hostapd_cli_cmd_bss_tm_req()
721 res = os_snprintf(tmp, sizeof(buf) - total, " %s", argv[i]); in hostapd_cli_cmd_bss_tm_req()
722 if (os_snprintf_error(sizeof(buf) - total, res)) in hostapd_cli_cmd_bss_tm_req()
723 return -1; in hostapd_cli_cmd_bss_tm_req()
726 return wpa_ctrl_command(ctrl, buf); in hostapd_cli_cmd_bss_tm_req()
730 static int hostapd_cli_cmd_get_config(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_get_config() argument
733 return wpa_ctrl_command(ctrl, "GET_CONFIG"); in hostapd_cli_cmd_get_config()
737 static int wpa_ctrl_command_sta(struct wpa_ctrl *ctrl, const char *cmd, in wpa_ctrl_command_sta() argument
741 size_t len; in wpa_ctrl_command_sta() local
745 printf("Not connected to hostapd - command dropped.\n"); in wpa_ctrl_command_sta()
746 return -1; in wpa_ctrl_command_sta()
748 len = sizeof(buf) - 1; in wpa_ctrl_command_sta()
749 ret = wpa_ctrl_request(ctrl, cmd, strlen(cmd), buf, &len, in wpa_ctrl_command_sta()
751 if (ret == -2) { in wpa_ctrl_command_sta()
753 return -2; in wpa_ctrl_command_sta()
756 return -1; in wpa_ctrl_command_sta()
759 buf[len] = '\0'; in wpa_ctrl_command_sta()
761 return -1; in wpa_ctrl_command_sta()
774 static int hostapd_cli_cmd_all_sta(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_all_sta() argument
779 if (wpa_ctrl_command_sta(ctrl, "STA-FIRST", addr, sizeof(addr), 1)) in hostapd_cli_cmd_all_sta()
782 snprintf(cmd, sizeof(cmd), "STA-NEXT %s", addr); in hostapd_cli_cmd_all_sta()
783 } while (wpa_ctrl_command_sta(ctrl, cmd, addr, sizeof(addr), 1) == 0); in hostapd_cli_cmd_all_sta()
785 return -1; in hostapd_cli_cmd_all_sta()
789 static int hostapd_cli_cmd_list_sta(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_list_sta() argument
794 if (wpa_ctrl_command_sta(ctrl, "STA-FIRST", addr, sizeof(addr), 0)) in hostapd_cli_cmd_list_sta()
799 os_snprintf(cmd, sizeof(cmd), "STA-NEXT %s", addr); in hostapd_cli_cmd_list_sta()
800 } while (wpa_ctrl_command_sta(ctrl, cmd, addr, sizeof(addr), 0) == 0); in hostapd_cli_cmd_list_sta()
806 static int hostapd_cli_cmd_help(struct wpa_ctrl *ctrl, int argc, char *argv[]) in hostapd_cli_cmd_help() argument
828 static int hostapd_cli_cmd_license(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_license() argument
836 static int hostapd_cli_cmd_set_qos_map_set(struct wpa_ctrl *ctrl, in hostapd_cli_cmd_set_qos_map_set() argument
843 printf("Invalid 'set_qos_map_set' command - " in hostapd_cli_cmd_set_qos_map_set()
846 return -1; in hostapd_cli_cmd_set_qos_map_set()
851 return -1; in hostapd_cli_cmd_set_qos_map_set()
852 return wpa_ctrl_command(ctrl, buf); in hostapd_cli_cmd_set_qos_map_set()
856 static int hostapd_cli_cmd_send_qos_map_conf(struct wpa_ctrl *ctrl, in hostapd_cli_cmd_send_qos_map_conf() argument
863 printf("Invalid 'send_qos_map_conf' command - " in hostapd_cli_cmd_send_qos_map_conf()
865 return -1; in hostapd_cli_cmd_send_qos_map_conf()
870 return -1; in hostapd_cli_cmd_send_qos_map_conf()
871 return wpa_ctrl_command(ctrl, buf); in hostapd_cli_cmd_send_qos_map_conf()
875 static int hostapd_cli_cmd_hs20_wnm_notif(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_hs20_wnm_notif() argument
882 printf("Invalid 'hs20_wnm_notif' command - two arguments (STA " in hostapd_cli_cmd_hs20_wnm_notif()
884 return -1; in hostapd_cli_cmd_hs20_wnm_notif()
890 return -1; in hostapd_cli_cmd_hs20_wnm_notif()
891 return wpa_ctrl_command(ctrl, buf); in hostapd_cli_cmd_hs20_wnm_notif()
895 static int hostapd_cli_cmd_hs20_deauth_req(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_hs20_deauth_req() argument
902 …printf("Invalid 'hs20_deauth_req' command - at least three arguments (STA addr, Code, Re-auth Dela… in hostapd_cli_cmd_hs20_deauth_req()
903 return -1; in hostapd_cli_cmd_hs20_deauth_req()
915 return -1; in hostapd_cli_cmd_hs20_deauth_req()
916 return wpa_ctrl_command(ctrl, buf); in hostapd_cli_cmd_hs20_deauth_req()
920 static int hostapd_cli_cmd_quit(struct wpa_ctrl *ctrl, int argc, char *argv[]) in hostapd_cli_cmd_quit() argument
929 static int hostapd_cli_cmd_level(struct wpa_ctrl *ctrl, int argc, char *argv[]) in hostapd_cli_cmd_level() argument
938 return wpa_ctrl_command(ctrl, cmd); in hostapd_cli_cmd_level()
942 static void update_stations(struct wpa_ctrl *ctrl) in update_stations() argument
946 if (!ctrl || !interactive) in update_stations()
951 if (wpa_ctrl_command_sta(ctrl, "STA-FIRST", addr, sizeof(addr), 0)) in update_stations()
956 os_snprintf(cmd, sizeof(cmd), "STA-NEXT %s", addr); in update_stations()
957 } while (wpa_ctrl_command_sta(ctrl, cmd, addr, sizeof(addr), 0) == 0); in update_stations()
961 static void hostapd_cli_get_interfaces(struct wpa_ctrl *ctrl, in hostapd_cli_get_interfaces() argument
967 if (!ctrl || !interfaces) in hostapd_cli_get_interfaces()
974 if (strcmp(dent->d_name, ".") == 0 || in hostapd_cli_get_interfaces()
975 strcmp(dent->d_name, "..") == 0) in hostapd_cli_get_interfaces()
977 cli_txt_list_add(interfaces, dent->d_name); in hostapd_cli_get_interfaces()
983 static void hostapd_cli_list_interfaces(struct wpa_ctrl *ctrl) in hostapd_cli_list_interfaces() argument
997 if (strcmp(dent->d_name, ".") == 0 || in hostapd_cli_list_interfaces()
998 strcmp(dent->d_name, "..") == 0) in hostapd_cli_list_interfaces()
1000 printf("%s\n", dent->d_name); in hostapd_cli_list_interfaces()
1006 static int hostapd_cli_cmd_interface(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_interface() argument
1010 hostapd_cli_list_interfaces(ctrl); in hostapd_cli_cmd_interface()
1014 printf("Could not connect to interface '%s' - re-trying\n", in hostapd_cli_cmd_interface()
1039 static int hostapd_cli_cmd_set(struct wpa_ctrl *ctrl, int argc, char *argv[]) in hostapd_cli_cmd_set() argument
1047 return -1; in hostapd_cli_cmd_set()
1053 return -1; in hostapd_cli_cmd_set()
1055 return wpa_ctrl_command(ctrl, cmd); in hostapd_cli_cmd_set()
1097 static int hostapd_cli_cmd_get(struct wpa_ctrl *ctrl, int argc, char *argv[]) in hostapd_cli_cmd_get() argument
1105 return -1; in hostapd_cli_cmd_get()
1111 return -1; in hostapd_cli_cmd_get()
1113 return wpa_ctrl_command(ctrl, cmd); in hostapd_cli_cmd_get()
1143 static int hostapd_cli_cmd_fst(struct wpa_ctrl *ctrl, int argc, char *argv[]) in hostapd_cli_cmd_fst() argument
1152 return -1; in hostapd_cli_cmd_fst()
1155 total = os_snprintf(cmd, sizeof(cmd), "FST-MANAGER"); in hostapd_cli_cmd_fst()
1158 res = os_snprintf(cmd + total, sizeof(cmd) - total, " %s", in hostapd_cli_cmd_fst()
1160 if (os_snprintf_error(sizeof(cmd) - total, res)) { in hostapd_cli_cmd_fst()
1162 return -1; in hostapd_cli_cmd_fst()
1166 return wpa_ctrl_command(ctrl, cmd); in hostapd_cli_cmd_fst()
1172 static int hostapd_cli_cmd_color_change(struct wpa_ctrl *ctrl, in hostapd_cli_cmd_color_change() argument
1175 return hostapd_cli_cmd(ctrl, "COLOR_CHANGE", 1, argc, argv); in hostapd_cli_cmd_color_change()
1180 static int hostapd_cli_cmd_chan_switch(struct wpa_ctrl *ctrl, in hostapd_cli_cmd_chan_switch() argument
1195 return -1; in hostapd_cli_cmd_chan_switch()
1202 return -1; in hostapd_cli_cmd_chan_switch()
1208 res = os_snprintf(tmp, sizeof(cmd) - total, " %s", argv[i]); in hostapd_cli_cmd_chan_switch()
1209 if (os_snprintf_error(sizeof(cmd) - total, res)) { in hostapd_cli_cmd_chan_switch()
1211 return -1; in hostapd_cli_cmd_chan_switch()
1215 return wpa_ctrl_command(ctrl, cmd); in hostapd_cli_cmd_chan_switch()
1219 static int hostapd_cli_cmd_notify_cw_change(struct wpa_ctrl *ctrl, in hostapd_cli_cmd_notify_cw_change() argument
1222 return hostapd_cli_cmd(ctrl, "NOTIFY_CW_CHANGE", 1, argc, argv); in hostapd_cli_cmd_notify_cw_change()
1226 static int hostapd_cli_cmd_enable(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_enable() argument
1229 return wpa_ctrl_command(ctrl, "ENABLE"); in hostapd_cli_cmd_enable()
1233 static int hostapd_cli_cmd_reload(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_reload() argument
1236 return wpa_ctrl_command(ctrl, "RELOAD"); in hostapd_cli_cmd_reload()
1240 static int hostapd_cli_cmd_reload_bss(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_reload_bss() argument
1243 return wpa_ctrl_command(ctrl, "RELOAD_BSS"); in hostapd_cli_cmd_reload_bss()
1247 static int hostapd_cli_cmd_reload_config(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_reload_config() argument
1250 return wpa_ctrl_command(ctrl, "RELOAD_CONFIG"); in hostapd_cli_cmd_reload_config()
1254 static int hostapd_cli_cmd_disable(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_disable() argument
1257 return wpa_ctrl_command(ctrl, "DISABLE"); in hostapd_cli_cmd_disable()
1261 static int hostapd_cli_cmd_enable_mld(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_enable_mld() argument
1264 return wpa_ctrl_command(ctrl, "ENABLE_MLD"); in hostapd_cli_cmd_enable_mld()
1268 static int hostapd_cli_cmd_disable_mld(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_disable_mld() argument
1271 return wpa_ctrl_command(ctrl, "DISABLE_MLD"); in hostapd_cli_cmd_disable_mld()
1275 static int hostapd_cli_cmd_update_beacon(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_update_beacon() argument
1278 return wpa_ctrl_command(ctrl, "UPDATE_BEACON"); in hostapd_cli_cmd_update_beacon()
1282 static int hostapd_cli_cmd_stop_ap(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_stop_ap() argument
1285 return wpa_ctrl_command(ctrl, "STOP_AP"); in hostapd_cli_cmd_stop_ap()
1289 static int hostapd_cli_cmd_vendor(struct wpa_ctrl *ctrl, int argc, char *argv[]) in hostapd_cli_cmd_vendor() argument
1297 return -1; in hostapd_cli_cmd_vendor()
1305 return -1; in hostapd_cli_cmd_vendor()
1307 return wpa_ctrl_command(ctrl, cmd); in hostapd_cli_cmd_vendor()
1311 static int hostapd_cli_cmd_erp_flush(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_erp_flush() argument
1314 return wpa_ctrl_command(ctrl, "ERP_FLUSH"); in hostapd_cli_cmd_erp_flush()
1318 static int hostapd_cli_cmd_log_level(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_log_level() argument
1331 return -1; in hostapd_cli_cmd_log_level()
1333 return wpa_ctrl_command(ctrl, cmd); in hostapd_cli_cmd_log_level()
1337 static int hostapd_cli_cmd_raw(struct wpa_ctrl *ctrl, int argc, char *argv[]) in hostapd_cli_cmd_raw() argument
1340 return -1; in hostapd_cli_cmd_raw()
1341 return hostapd_cli_cmd(ctrl, argv[0], 0, argc - 1, &argv[1]); in hostapd_cli_cmd_raw()
1345 static int hostapd_cli_cmd_pmksa(struct wpa_ctrl *ctrl, int argc, char *argv[]) in hostapd_cli_cmd_pmksa() argument
1347 return wpa_ctrl_command(ctrl, "PMKSA"); in hostapd_cli_cmd_pmksa()
1351 static int hostapd_cli_cmd_pmksa_flush(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_pmksa_flush() argument
1354 return wpa_ctrl_command(ctrl, "PMKSA_FLUSH"); in hostapd_cli_cmd_pmksa_flush()
1358 static int hostapd_cli_cmd_set_neighbor(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_set_neighbor() argument
1365 printf("Invalid set_neighbor command: needs 3-6 arguments\n"); in hostapd_cli_cmd_set_neighbor()
1366 return -1; in hostapd_cli_cmd_set_neighbor()
1374 return -1; in hostapd_cli_cmd_set_neighbor()
1376 return wpa_ctrl_command(ctrl, cmd); in hostapd_cli_cmd_set_neighbor()
1380 static int hostapd_cli_cmd_show_neighbor(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_show_neighbor() argument
1383 return wpa_ctrl_command(ctrl, "SHOW_NEIGHBOR"); in hostapd_cli_cmd_show_neighbor()
1387 static int hostapd_cli_cmd_remove_neighbor(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_remove_neighbor() argument
1390 return hostapd_cli_cmd(ctrl, "REMOVE_NEIGHBOR", 1, argc, argv); in hostapd_cli_cmd_remove_neighbor()
1394 static int hostapd_cli_cmd_req_lci(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_req_lci() argument
1401 printf("Invalid req_lci command - requires destination address\n"); in hostapd_cli_cmd_req_lci()
1402 return -1; in hostapd_cli_cmd_req_lci()
1408 return -1; in hostapd_cli_cmd_req_lci()
1410 return wpa_ctrl_command(ctrl, cmd); in hostapd_cli_cmd_req_lci()
1414 static int hostapd_cli_cmd_req_range(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_req_range() argument
1418 …printf("Invalid req_range command: needs at least 4 arguments - dest address, randomization interv… in hostapd_cli_cmd_req_range()
1419 return -1; in hostapd_cli_cmd_req_range()
1422 return hostapd_cli_cmd(ctrl, "REQ_RANGE", 4, argc, argv); in hostapd_cli_cmd_req_range()
1426 static int hostapd_cli_cmd_driver_flags(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_driver_flags() argument
1429 return wpa_ctrl_command(ctrl, "DRIVER_FLAGS"); in hostapd_cli_cmd_driver_flags()
1433 static int hostapd_cli_cmd_driver_flags2(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_driver_flags2() argument
1436 return wpa_ctrl_command(ctrl, "DRIVER_FLAGS2"); in hostapd_cli_cmd_driver_flags2()
1442 static int hostapd_cli_cmd_dpp_qr_code(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_dpp_qr_code() argument
1445 return hostapd_cli_cmd(ctrl, "DPP_QR_CODE", 1, argc, argv); in hostapd_cli_cmd_dpp_qr_code()
1449 static int hostapd_cli_cmd_dpp_bootstrap_gen(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_dpp_bootstrap_gen() argument
1452 return hostapd_cli_cmd(ctrl, "DPP_BOOTSTRAP_GEN", 1, argc, argv); in hostapd_cli_cmd_dpp_bootstrap_gen()
1456 static int hostapd_cli_cmd_dpp_bootstrap_remove(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_dpp_bootstrap_remove() argument
1459 return hostapd_cli_cmd(ctrl, "DPP_BOOTSTRAP_REMOVE", 1, argc, argv); in hostapd_cli_cmd_dpp_bootstrap_remove()
1463 static int hostapd_cli_cmd_dpp_bootstrap_get_uri(struct wpa_ctrl *ctrl, in hostapd_cli_cmd_dpp_bootstrap_get_uri() argument
1466 return hostapd_cli_cmd(ctrl, "DPP_BOOTSTRAP_GET_URI", 1, argc, argv); in hostapd_cli_cmd_dpp_bootstrap_get_uri()
1470 static int hostapd_cli_cmd_dpp_bootstrap_info(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_dpp_bootstrap_info() argument
1473 return hostapd_cli_cmd(ctrl, "DPP_BOOTSTRAP_INFO", 1, argc, argv); in hostapd_cli_cmd_dpp_bootstrap_info()
1477 static int hostapd_cli_cmd_dpp_bootstrap_set(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_dpp_bootstrap_set() argument
1480 return hostapd_cli_cmd(ctrl, "DPP_BOOTSTRAP_SET", 1, argc, argv); in hostapd_cli_cmd_dpp_bootstrap_set()
1484 static int hostapd_cli_cmd_dpp_auth_init(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_dpp_auth_init() argument
1487 return hostapd_cli_cmd(ctrl, "DPP_AUTH_INIT", 1, argc, argv); in hostapd_cli_cmd_dpp_auth_init()
1491 static int hostapd_cli_cmd_dpp_listen(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_dpp_listen() argument
1494 return hostapd_cli_cmd(ctrl, "DPP_LISTEN", 1, argc, argv); in hostapd_cli_cmd_dpp_listen()
1498 static int hostapd_cli_cmd_dpp_stop_listen(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_dpp_stop_listen() argument
1501 return wpa_ctrl_command(ctrl, "DPP_STOP_LISTEN"); in hostapd_cli_cmd_dpp_stop_listen()
1505 static int hostapd_cli_cmd_dpp_configurator_add(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_dpp_configurator_add() argument
1508 return hostapd_cli_cmd(ctrl, "DPP_CONFIGURATOR_ADD", 0, argc, argv); in hostapd_cli_cmd_dpp_configurator_add()
1512 static int hostapd_cli_cmd_dpp_configurator_remove(struct wpa_ctrl *ctrl, in hostapd_cli_cmd_dpp_configurator_remove() argument
1515 return hostapd_cli_cmd(ctrl, "DPP_CONFIGURATOR_REMOVE", 1, argc, argv); in hostapd_cli_cmd_dpp_configurator_remove()
1519 static int hostapd_cli_cmd_dpp_configurator_get_key(struct wpa_ctrl *ctrl, in hostapd_cli_cmd_dpp_configurator_get_key() argument
1522 return hostapd_cli_cmd(ctrl, "DPP_CONFIGURATOR_GET_KEY", 1, argc, argv); in hostapd_cli_cmd_dpp_configurator_get_key()
1526 static int hostapd_cli_cmd_dpp_configurator_sign(struct wpa_ctrl *ctrl, in hostapd_cli_cmd_dpp_configurator_sign() argument
1529 return hostapd_cli_cmd(ctrl, "DPP_CONFIGURATOR_SIGN", 1, argc, argv); in hostapd_cli_cmd_dpp_configurator_sign()
1533 static int hostapd_cli_cmd_dpp_pkex_add(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_dpp_pkex_add() argument
1536 return hostapd_cli_cmd(ctrl, "DPP_PKEX_ADD", 1, argc, argv); in hostapd_cli_cmd_dpp_pkex_add()
1540 static int hostapd_cli_cmd_dpp_pkex_remove(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_dpp_pkex_remove() argument
1543 return hostapd_cli_cmd(ctrl, "DPP_PKEX_REMOVE", 1, argc, argv); in hostapd_cli_cmd_dpp_pkex_remove()
1549 static int hostapd_cli_cmd_dpp_controller_start(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_dpp_controller_start() argument
1552 return hostapd_cli_cmd(ctrl, "DPP_CONTROLLER_START", 0, argc, argv); in hostapd_cli_cmd_dpp_controller_start()
1556 static int hostapd_cli_cmd_dpp_controller_stop(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_dpp_controller_stop() argument
1559 return wpa_ctrl_command(ctrl, "DPP_CONTROLLER_STOP"); in hostapd_cli_cmd_dpp_controller_stop()
1563 static int hostapd_cli_cmd_dpp_chirp(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_dpp_chirp() argument
1566 return hostapd_cli_cmd(ctrl, "DPP_CHIRP", 1, argc, argv); in hostapd_cli_cmd_dpp_chirp()
1570 static int hostapd_cli_cmd_dpp_stop_chirp(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_dpp_stop_chirp() argument
1573 return wpa_ctrl_command(ctrl, "DPP_STOP_CHIRP"); in hostapd_cli_cmd_dpp_stop_chirp()
1580 static int hostapd_cli_cmd_dpp_push_button(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_dpp_push_button() argument
1583 return hostapd_cli_cmd(ctrl, "DPP_PUSH_BUTTON", 0, argc, argv); in hostapd_cli_cmd_dpp_push_button()
1589 static int hostapd_cli_cmd_accept_macacl(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_accept_macacl() argument
1592 return hostapd_cli_cmd(ctrl, "ACCEPT_ACL", 1, argc, argv); in hostapd_cli_cmd_accept_macacl()
1596 static int hostapd_cli_cmd_deny_macacl(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_deny_macacl() argument
1599 return hostapd_cli_cmd(ctrl, "DENY_ACL", 1, argc, argv); in hostapd_cli_cmd_deny_macacl()
1603 static int hostapd_cli_cmd_poll_sta(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_poll_sta() argument
1606 return hostapd_cli_cmd(ctrl, "POLL_STA", 1, argc, argv); in hostapd_cli_cmd_poll_sta()
1610 static int hostapd_cli_cmd_req_beacon(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_req_beacon() argument
1613 return hostapd_cli_cmd(ctrl, "REQ_BEACON", 2, argc, argv); in hostapd_cli_cmd_req_beacon()
1617 static int hostapd_cli_cmd_req_link_measurement(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_req_link_measurement() argument
1620 return hostapd_cli_cmd(ctrl, "REQ_LINK_MEASUREMENT", 1, argc, argv); in hostapd_cli_cmd_req_link_measurement()
1624 static int hostapd_cli_cmd_reload_wpa_psk(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_reload_wpa_psk() argument
1627 return wpa_ctrl_command(ctrl, "RELOAD_WPA_PSK"); in hostapd_cli_cmd_reload_wpa_psk()
1633 static int hostapd_cli_cmd_get_rxkhs(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_get_rxkhs() argument
1636 return wpa_ctrl_command(ctrl, "GET_RXKHS"); in hostapd_cli_cmd_get_rxkhs()
1640 static int hostapd_cli_cmd_reload_rxkhs(struct wpa_ctrl *ctrl, int argc, in hostapd_cli_cmd_reload_rxkhs() argument
1643 return wpa_ctrl_command(ctrl, "RELOAD_RXKHS"); in hostapd_cli_cmd_reload_rxkhs()
1650 static int hostapd_cli_cmd_driver(struct wpa_ctrl *ctrl, int argc, char *argv[]) in hostapd_cli_cmd_driver() argument
1652 return hostapd_cli_cmd(ctrl, "DRIVER", 1, argc, argv); in hostapd_cli_cmd_driver()
1659 int (*handler)(struct wpa_ctrl *ctrl, int argc, char *argv[]);
1735 "<params...> = send FST-MANAGER control interface command" },
1764 "<channel_width> = 0 - 20 MHz, 1 - 40 MHz, 2 - 80 MHz, 3 - 160 MHz" },
1767 " = send WNM-Notification Subscription Remediation Request" },
1769 "<addr> <code (0/1)> <Re-auth-Delay(sec)> [url]\n"
1770 " = send WNM-Notification imminent deauthentication indication" },
1898 if (cmd->usage == NULL) in print_cmd_help()
1900 fprintf(stream, "%s%s ", pad, cmd->cmd); in print_cmd_help()
1901 for (n = 0; (c = cmd->usage[n]); n++) { in print_cmd_help()
1922 static void wpa_request(struct wpa_ctrl *ctrl, int argc, char *argv[]) in wpa_request() argument
1929 while (cmd->cmd) { in wpa_request()
1930 if (strncasecmp(cmd->cmd, argv[0], strlen(argv[0])) == 0) { in wpa_request()
1932 if (os_strcasecmp(cmd->cmd, argv[0]) == 0) { in wpa_request()
1945 while (cmd->cmd) { in wpa_request()
1946 if (strncasecmp(cmd->cmd, argv[0], strlen(argv[0])) == in wpa_request()
1948 printf(" %s", cmd->cmd); in wpa_request()
1956 match->handler(ctrl, argc - 1, &argv[1]); in wpa_request()
1989 static void hostapd_cli_recv_pending(struct wpa_ctrl *ctrl, int in_read, in hostapd_cli_recv_pending() argument
1995 while (wpa_ctrl_pending(ctrl)) { in hostapd_cli_recv_pending()
1997 size_t len = sizeof(buf) - 1; in hostapd_cli_recv_pending() local
1998 if (wpa_ctrl_recv(ctrl, buf, &len) == 0) { in hostapd_cli_recv_pending()
1999 buf[len] = '\0'; in hostapd_cli_recv_pending()
2001 hostapd_cli_action_process(buf, len); in hostapd_cli_recv_pending()
2026 printf("Connection to hostapd lost - trying to reconnect\n"); in hostapd_cli_ping()
2030 printf("Connection to hostapd re-established\n"); in hostapd_cli_ping()
2116 cmd[end - str] = '\0'; in hostapd_cli_edit_completion_cb()
2168 struct wpa_ctrl *ctrl = eloop_ctx; in hostapd_cli_action_ping() local
2170 size_t len; in hostapd_cli_action_ping() local
2173 len = sizeof(buf) - 1; in hostapd_cli_action_ping()
2174 if (wpa_ctrl_request(ctrl, "PING", 4, buf, &len, in hostapd_cli_action_ping()
2176 len < 4 || os_memcmp(buf, "PONG", 4) != 0) { in hostapd_cli_action_ping()
2177 printf("hostapd did not reply to PING command - exiting\n"); in hostapd_cli_action_ping()
2182 ctrl, NULL); in hostapd_cli_action_ping()
2189 struct wpa_ctrl *ctrl = eloop_ctx; in hostapd_cli_action_receive() local
2191 hostapd_cli_recv_pending(ctrl, 0, 1); in hostapd_cli_action_receive()
2195 static void hostapd_cli_action(struct wpa_ctrl *ctrl) in hostapd_cli_action() argument
2199 fd = wpa_ctrl_get_fd(ctrl); in hostapd_cli_action()
2201 ctrl, NULL); in hostapd_cli_action()
2202 eloop_register_read_sock(fd, hostapd_cli_action_receive, ctrl, NULL); in hostapd_cli_action()
2204 eloop_cancel_timeout(hostapd_cli_action_ping, ctrl, NULL); in hostapd_cli_action()
2217 return -1; in main()
2257 return -1; in main()
2268 return -1; in main()
2276 if (os_strcmp(dent->d_name, ".") == 0 in main()
2278 os_strcmp(dent->d_name, "..") == 0) in main()
2281 dent->d_name); in main()
2282 ctrl_ifname = os_strdup(dent->d_name); in main()
2295 perror("Failed to connect to hostapd - " in main()
2297 return -1; in main()
2301 printf("Could not connect to hostapd - re-trying\n"); in main()
2311 return -1; in main()
2313 return -1; in main()
2326 wpa_request(ctrl_conn, argc - optind, &argv[optind]); in main()
2339 return -1; in main()