]> git.ipfire.org Git - thirdparty/hostap.git/blobdiff - hostapd/hostapd_cli.c
tests: DPP netAccessKey for reconfig
[thirdparty/hostap.git] / hostapd / hostapd_cli.c
index 23c592a6b0a6160e504824f8974d0d2df2794b03..440664e9b0527ec27ede99742406e547dd588daf 100644 (file)
@@ -54,7 +54,7 @@ static void usage(void)
        fprintf(stderr, "%s\n", hostapd_cli_version);
        fprintf(stderr,
                "\n"
-               "usage: hostapd_cli [-p<path>] [-i<ifname>] [-hvB] "
+               "usage: hostapd_cli [-p<path>] [-i<ifname>] [-hvBr] "
                "[-a<path>] \\\n"
                "                   [-P<pid file>] [-G<ping interval>] [command..]\n"
                "\n"
@@ -68,6 +68,9 @@ static void usage(void)
                "   -a<file>     run in daemon mode executing the action file "
                "based on events\n"
                "                from hostapd\n"
+               "   -r           try to reconnect when client socket is "
+               "disconnected.\n"
+               "                This is useful only when used with -a.\n"
                "   -B           run a daemon in the background\n"
                "   -i<ifname>   Interface to listen on (default: first "
                "interface found in the\n"
@@ -401,7 +404,6 @@ static int hostapd_cli_cmd_signature(struct wpa_ctrl *ctrl, int argc,
 #endif /* CONFIG_TAXONOMY */
 
 
-#ifdef CONFIG_IEEE80211W
 static int hostapd_cli_cmd_sa_query(struct wpa_ctrl *ctrl, int argc,
                                    char *argv[])
 {
@@ -414,7 +416,6 @@ static int hostapd_cli_cmd_sa_query(struct wpa_ctrl *ctrl, int argc,
        snprintf(buf, sizeof(buf), "SA_QUERY %s", argv[0]);
        return wpa_ctrl_command(ctrl, buf);
 }
-#endif /* CONFIG_IEEE80211W */
 
 
 #ifdef CONFIG_WPS
@@ -1214,6 +1215,13 @@ static int hostapd_cli_cmd_disable(struct wpa_ctrl *ctrl, int argc,
 }
 
 
+static int hostapd_cli_cmd_update_beacon(struct wpa_ctrl *ctrl, int argc,
+                                     char *argv[])
+{
+       return wpa_ctrl_command(ctrl, "UPDATE_BEACON");
+}
+
+
 static int hostapd_cli_cmd_vendor(struct wpa_ctrl *ctrl, int argc, char *argv[])
 {
        char cmd[256];
@@ -1304,24 +1312,17 @@ static int hostapd_cli_cmd_set_neighbor(struct wpa_ctrl *ctrl, int argc,
 }
 
 
-static int hostapd_cli_cmd_remove_neighbor(struct wpa_ctrl *ctrl, int argc,
-                                          char *argv[])
+static int hostapd_cli_cmd_show_neighbor(struct wpa_ctrl *ctrl, int argc,
+                                        char *argv[])
 {
-       char cmd[400];
-       int res;
+       return wpa_ctrl_command(ctrl, "SHOW_NEIGHBOR");
+}
 
-       if (argc != 2) {
-               printf("Invalid remove_neighbor command: needs 2 arguments\n");
-               return -1;
-       }
 
-       res = os_snprintf(cmd, sizeof(cmd), "REMOVE_NEIGHBOR %s %s",
-                         argv[0], argv[1]);
-       if (os_snprintf_error(sizeof(cmd), res)) {
-               printf("Too long REMOVE_NEIGHBOR command.\n");
-               return -1;
-       }
-       return wpa_ctrl_command(ctrl, cmd);
+static int hostapd_cli_cmd_remove_neighbor(struct wpa_ctrl *ctrl, int argc,
+                                          char *argv[])
+{
+       return hostapd_cli_cmd(ctrl, "REMOVE_NEIGHBOR", 1, argc, argv);
 }
 
 
@@ -1535,10 +1536,8 @@ static const struct hostapd_cli_cmd hostapd_cli_commands[] = {
        { "signature", hostapd_cli_cmd_signature, hostapd_complete_stations,
          "<addr> = get taxonomy signature for a station" },
 #endif /* CONFIG_TAXONOMY */
-#ifdef CONFIG_IEEE80211W
        { "sa_query", hostapd_cli_cmd_sa_query, hostapd_complete_stations,
          "<addr> = send SA Query to a station" },
-#endif /* CONFIG_IEEE80211W */
 #ifdef CONFIG_WPS
        { "wps_pin", hostapd_cli_cmd_wps_pin, NULL,
          "<uuid> <pin> [timeout] [addr] = add WPS Enrollee PIN" },
@@ -1617,6 +1616,8 @@ static const struct hostapd_cli_cmd hostapd_cli_commands[] = {
          "= reload configuration for current interface" },
        { "disable", hostapd_cli_cmd_disable, NULL,
          "= disable hostapd on current interface" },
+       { "update_beacon", hostapd_cli_cmd_update_beacon, NULL,
+         "= update Beacon frame contents\n"},
        { "erp_flush", hostapd_cli_cmd_erp_flush, NULL,
          "= drop all ERP keys"},
        { "log_level", hostapd_cli_cmd_log_level, NULL,
@@ -1628,8 +1629,10 @@ static const struct hostapd_cli_cmd hostapd_cli_commands[] = {
        { "set_neighbor", hostapd_cli_cmd_set_neighbor, NULL,
          "<addr> <ssid=> <nr=> [lci=] [civic=] [stat]\n"
          "  = add AP to neighbor database" },
+       { "show_neighbor", hostapd_cli_cmd_show_neighbor, NULL,
+         "  = show neighbor database entries" },
        { "remove_neighbor", hostapd_cli_cmd_remove_neighbor, NULL,
-         "<addr> <ssid=> = remove AP from neighbor database" },
+         "<addr> [ssid=<hex>] = remove AP from neighbor database" },
        { "req_lci", hostapd_cli_cmd_req_lci, hostapd_complete_stations,
          "<addr> = send LCI request to a station"},
        { "req_range", hostapd_cli_cmd_req_range, NULL,
@@ -2002,12 +2005,13 @@ int main(int argc, char *argv[])
        int warning_displayed = 0;
        int c;
        int daemonize = 0;
+       int reconnect = 0;
 
        if (os_program_init())
                return -1;
 
        for (;;) {
-               c = getopt(argc, argv, "a:BhG:i:p:P:s:v");
+               c = getopt(argc, argv, "a:BhG:i:p:P:rs:v");
                if (c < 0)
                        break;
                switch (c) {
@@ -2036,6 +2040,9 @@ int main(int argc, char *argv[])
                case 'P':
                        pid_file = optarg;
                        break;
+               case 'r':
+                       reconnect = 1;
+                       break;
                case 's':
                        client_socket_dir = optarg;
                        break;
@@ -2078,8 +2085,7 @@ int main(int argc, char *argv[])
                                printf("Connection established.\n");
                        break;
                }
-
-               if (!interactive) {
+               if (!interactive && !reconnect) {
                        perror("Failed to connect to hostapd - "
                               "wpa_ctrl_open");
                        return -1;
@@ -2097,8 +2103,14 @@ int main(int argc, char *argv[])
                return -1;
        if (daemonize && os_daemonize(pid_file) && eloop_sock_requeue())
                return -1;
-
-       if (interactive)
+       if (reconnect && action_file && ctrl_ifname) {
+               while (!hostapd_cli_quit) {
+                       if (ctrl_conn)
+                               hostapd_cli_action(ctrl_conn);
+                       os_sleep(1, 0);
+                       hostapd_cli_reconnect(ctrl_ifname);
+               }
+       } else if (interactive)
                hostapd_cli_interactive();
        else if (action_file)
                hostapd_cli_action(ctrl_conn);