bsd: Get rid of printf size_t warnings with 64-bit builds
[wpasupplicant] / hostapd / hostapd_cli.c
index d4d7a3f..84e8641 100644 (file)
@@ -87,9 +87,11 @@ static const char *commands_help =
 "   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_pin <uuid> <pin> [timeout]  add WPS Enrollee PIN (Device Password)\n"
 "   wps_pbc              indicate button pushed to initiate PBC\n"
+#ifdef CONFIG_WPS_OOB
 "   wps_oob <type> <path> <method>  use WPS with out-of-band (UFD)\n"
+#endif /* CONFIG_WPS_OOB */
 #endif /* CONFIG_WPS */
 "   help                 show this usage help\n"
 "   interface [ifname]   show interfaces/select interface\n"
@@ -261,12 +263,16 @@ static int hostapd_cli_cmd_wps_pin(struct wpa_ctrl *ctrl, int argc,
                                   char *argv[])
 {
        char buf[64];
-       if (argc != 2) {
-               printf("Invalid 'wps_pin' command - exactly two arguments, "
+       if (argc < 2) {
+               printf("Invalid 'wps_pin' command - at least two arguments, "
                       "UUID and PIN, are required.\n");
                return -1;
        }
-       snprintf(buf, sizeof(buf), "WPS_PIN %s %s", argv[0], argv[1]);
+       if (argc > 2)
+               snprintf(buf, sizeof(buf), "WPS_PIN %s %s %s",
+                        argv[0], argv[1], argv[2]);
+       else
+               snprintf(buf, sizeof(buf), "WPS_PIN %s %s", argv[0], argv[1]);
        return wpa_ctrl_command(ctrl, buf);
 }
 
@@ -278,29 +284,38 @@ static int hostapd_cli_cmd_wps_pbc(struct wpa_ctrl *ctrl, int argc,
 }
 
 
+#ifdef CONFIG_WPS_OOB
 static int hostapd_cli_cmd_wps_oob(struct wpa_ctrl *ctrl, int argc,
                                   char *argv[])
 {
        char cmd[256];
        int res;
 
-       if (argc != 3) {
-               printf("Invalid WPS_OOB command: need three arguments:\n"
-                      "- OOB_DEV_TYPE: use 'ufd'\n"
-                      "- OOB_PATH: path of OOB device like '/mnt'\n"
-                      "- OOB_METHOD: OOB method 'pin-e' or 'pin-r', "
-                      "'cred'\n");
+       if (argc != 3 && argc != 4) {
+               printf("Invalid WPS_OOB command: need three or four "
+                      "arguments:\n"
+                      "- DEV_TYPE: use 'ufd' or 'nfc'\n"
+                      "- PATH: path of OOB device like '/mnt'\n"
+                      "- METHOD: OOB method 'pin-e' or 'pin-r', "
+                      "'cred'\n"
+                      "- DEV_NAME: (only for NFC) device name like "
+                      "'pn531'\n");
                return -1;
        }
 
-       res = os_snprintf(cmd, sizeof(cmd), "WPS_OOB %s %s %s",
-                         argv[0], argv[1], argv[2]);
+       if (argc == 3)
+               res = os_snprintf(cmd, sizeof(cmd), "WPS_OOB %s %s %s",
+                                 argv[0], argv[1], argv[2]);
+       else
+               res = os_snprintf(cmd, sizeof(cmd), "WPS_OOB %s %s %s %s",
+                                 argv[0], argv[1], argv[2], argv[3]);
        if (res < 0 || (size_t) res >= sizeof(cmd) - 1) {
                printf("Too long WPS_OOB command.\n");
                return -1;
        }
        return wpa_ctrl_command(ctrl, cmd);
 }
+#endif /* CONFIG_WPS_OOB */
 #endif /* CONFIG_WPS */
 
 
@@ -458,7 +473,9 @@ static struct hostapd_cli_cmd hostapd_cli_commands[] = {
 #ifdef CONFIG_WPS
        { "wps_pin", hostapd_cli_cmd_wps_pin },
        { "wps_pbc", hostapd_cli_cmd_wps_pbc },
+#ifdef CONFIG_WPS_OOB
        { "wps_oob", hostapd_cli_cmd_wps_oob },
+#endif /* CONFIG_WPS_OOB */
 #endif /* CONFIG_WPS */
        { "help", hostapd_cli_cmd_help },
        { "interface", hostapd_cli_cmd_interface },