Lines Matching +full:pin +full:- +full:ctrl +full:- +full:enable

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