From patchwork Wed May 2 21:39:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: P2P: Cleanup p2p_invite argument passing for ctrl interface Date: Wed, 02 May 2012 11:39:09 -0000 From: nirav shah X-Patchwork-Id: 156555 Message-Id: <1335994749-29305-1-git-send-email-nirav.j2.shah@intel.com> To: hostap@lists.shmoo.com The p2p_invite api requires group interface name or persistent group id with peer address to which the invitation is to be sent. However ctrl interface documentation and argument check function does not mandate this. Enforcing this in the ctrl interface. Signed-hostap: Nirav Shah intended-for: hostap-1 --- wpa_supplicant/wpa_cli.c | 13 ++++++------- 1 files changed, 6 insertions(+), 7 deletions(-) diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c index 18759ab..13be3d4 100644 --- a/wpa_supplicant/wpa_cli.c +++ b/wpa_supplicant/wpa_cli.c @@ -2368,20 +2368,18 @@ static int wpa_cli_cmd_p2p_invite(struct wpa_ctrl *ctrl, char cmd[128]; int res; - if (argc < 1) { - printf("Invalid P2P_INVITE command: needs at least one " - "argument\n"); + if (argc < 2) { + printf("Invalid P2P_INVITE command: needs at least two " + "arguments\n"); return -1; } if (argc > 2) res = os_snprintf(cmd, sizeof(cmd), "P2P_INVITE %s %s %s", argv[0], argv[1], argv[2]); - else if (argc > 1) + else res = os_snprintf(cmd, sizeof(cmd), "P2P_INVITE %s %s", argv[0], argv[1]); - else - res = os_snprintf(cmd, sizeof(cmd), "P2P_INVITE %s", argv[0]); if (res < 0 || (size_t) res >= sizeof(cmd)) return -1; cmd[sizeof(cmd) - 1] = '\0'; @@ -3067,7 +3065,8 @@ static struct wpa_cli_cmd wpa_cli_commands[] = { " = reject connection attempts from a specific peer" }, { "p2p_invite", wpa_cli_cmd_p2p_invite, cli_cmd_flag_none, - " [peer=addr] = invite peer" }, + "[persistent=id|group=ifname] [peer=addr] = invite specified " + "peer to the group" }, { "p2p_peers", wpa_cli_cmd_p2p_peers, cli_cmd_flag_none, "[discovered] = list known (optionally, only fully discovered) P2P " "peers" },