UPnP: Removed shadowed variable
[wpasupplicant] / hostapd / hostapd_cli.c
index e5285ae..2614113 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * hostapd - command line interface for hostapd daemon
- * Copyright (c) 2004-2008, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2004-2009, Jouni Malinen <j@w1.fi>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -22,7 +22,7 @@
 
 static const char *hostapd_cli_version =
 "hostapd_cli v" VERSION_STR "\n"
-"Copyright (c) 2004-2008, Jouni Malinen <j@w1.fi> and contributors";
+"Copyright (c) 2004-2009, Jouni Malinen <j@w1.fi> and contributors";
 
 
 static const char *hostapd_cli_license =
@@ -83,6 +83,9 @@ static const char *commands_help =
 "   sta <addr>           get MIB variables for one station\n"
 "   all_sta              get MIB variables for all stations\n"
 "   new_sta <addr>       add a new station\n"
+#ifdef CONFIG_IEEE80211W
+"   sa_query <addr>      send SA Query to a station\n"
+#endif /* CONFIG_IEEE80211W */
 #ifdef CONFIG_WPS
 "   wps_pin <uuid> <pin> add WPS Enrollee PIN (Device Password)\n"
 "   wps_pbc              indicate button pushed to initiate PBC\n"
@@ -98,6 +101,7 @@ static int hostapd_cli_quit = 0;
 static int hostapd_cli_attached = 0;
 static const char *ctrl_iface_dir = "/var/run/hostapd";
 static char *ctrl_ifname = NULL;
+static int ping_interval = 5;
 
 
 static void usage(void)
@@ -106,7 +110,8 @@ static void usage(void)
        fprintf(stderr, 
                "\n"    
                "usage: hostapd_cli [-p<path>] [-i<ifname>] [-hv] "
-               "[command..]\n"
+               "[-G<ping interval>] \\\n"
+               "        [command..]\n"
                "\n"
                "Options:\n"
                "   -h           help (show this usage text)\n"
@@ -234,6 +239,22 @@ static int hostapd_cli_cmd_new_sta(struct wpa_ctrl *ctrl, int argc,
 }
 
 
+#ifdef CONFIG_IEEE80211W
+static int hostapd_cli_cmd_sa_query(struct wpa_ctrl *ctrl, int argc,
+                                   char *argv[])
+{
+       char buf[64];
+       if (argc != 1) {
+               printf("Invalid 'sa_query' command - exactly one argument, "
+                      "STA address, is required.\n");
+               return -1;
+       }
+       snprintf(buf, sizeof(buf), "SA_QUERY %s", argv[0]);
+       return wpa_ctrl_command(ctrl, buf);
+}
+#endif /* CONFIG_IEEE80211W */
+
+
 #ifdef CONFIG_WPS
 static int hostapd_cli_cmd_wps_pin(struct wpa_ctrl *ctrl, int argc,
                                   char *argv[])
@@ -405,6 +426,9 @@ static struct hostapd_cli_cmd hostapd_cli_commands[] = {
        { "sta", hostapd_cli_cmd_sta },
        { "all_sta", hostapd_cli_cmd_all_sta },
        { "new_sta", hostapd_cli_cmd_new_sta },
+#ifdef CONFIG_IEEE80211W
+       { "sa_query", hostapd_cli_cmd_sa_query },
+#endif /* CONFIG_IEEE80211W */
 #ifdef CONFIG_WPS
        { "wps_pin", hostapd_cli_cmd_wps_pin },
        { "wps_pbc", hostapd_cli_cmd_wps_pbc },
@@ -485,7 +509,7 @@ static void hostapd_cli_interactive(void)
        do {
                hostapd_cli_recv_pending(ctrl_conn, 0);
                printf("> ");
-               alarm(1);
+               alarm(ping_interval);
                res = fgets(cmd, sizeof(cmd), stdin);
                alarm(0);
                if (res == NULL)
@@ -547,7 +571,7 @@ static void hostapd_cli_alarm(int sig)
        }
        if (ctrl_conn)
                hostapd_cli_recv_pending(ctrl_conn, 1);
-       alarm(1);
+       alarm(ping_interval);
 }
 
 
@@ -558,10 +582,13 @@ int main(int argc, char *argv[])
        int c;
 
        for (;;) {
-               c = getopt(argc, argv, "hi:p:v");
+               c = getopt(argc, argv, "hG:i:p:v");
                if (c < 0)
                        break;
                switch (c) {
+               case 'G':
+                       ping_interval = atoi(optarg);
+                       break;
                case 'h':
                        usage();
                        return 0;