diff mbox

P2P: Cleanup p2p_invite argument passing for ctrl interface

Message ID 1335994749-29305-1-git-send-email-nirav.j2.shah@intel.com
State Rejected
Headers show

Commit Message

nirav shah May 2, 2012, 9:39 p.m. UTC
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 <nirav.j2.shah@intel.com>
intended-for: hostap-1
---
 wpa_supplicant/wpa_cli.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

Comments

Jouni Malinen June 23, 2012, 10:01 p.m. UTC | #1
On Wed, May 02, 2012 at 02:39:09PM -0700, nirav shah wrote:
> The p2p_invite api requires group interface name or persistent
> group id with peer address to which the invitation is to be sent.

It does not require the peer address if it is already known which is the
case with re-invocation of a persistent group where the local end is the
P2P client (GO address is available in the configuration).

> However ctrl interface documentation and argument check function
> does not mandate this. Enforcing this in the ctrl interface.

This would break a valid use case of "p2p_invite persistent=<id>".
diff mbox

Patch

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[] = {
 	  "<addr> = reject connection attempts from a specific peer" },
 	{ "p2p_invite", wpa_cli_cmd_p2p_invite,
 	  cli_cmd_flag_none,
-	  "<cmd> [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" },