[PATCH] DBus: Add RemoveClient method to remove a client from local GO

Purushottam Kushwaha p.kushwaha
Tue Jun 16 04:35:56 PDT 2015


This is equivalent to p2p_remove_client command on control interface
It can be used to remove the specified client [as object path or
string format interface address] from all groups (operating and
persistent) from the local GO.
Argument(s): peer[object path] OR iface[string format MAC address]

Signed-off-by: Purushottam Kushwaha <p.kushwaha at samsung.com>
Signed-off-by: Jijo Jacob <jijo.jacob at samsung.com>
---
 doc/dbus.doxygen                            | 17 +++++++++
 wpa_supplicant/dbus/dbus_new.c              |  7 ++++
 wpa_supplicant/dbus/dbus_new_handlers_p2p.c | 58 +++++++++++++++++++++++++++++
 wpa_supplicant/dbus/dbus_new_handlers_p2p.h |  3 ++
 4 files changed, 85 insertions(+)

diff --git a/doc/dbus.doxygen b/doc/dbus.doxygen
index 7355dbb..1b1af1d 100644
--- a/doc/dbus.doxygen
+++ b/doc/dbus.doxygen
@@ -1119,6 +1119,23 @@ Interface for performing P2P (Wi-Fi Peer-to-Peer) P2P Device operations.
   </li>
 
   <li>
+    <h3>RemoveClient ( a{sv} : args ) --> nothing</h3>
+    <p>Remove the client from all groups (operating and persistent) from the local GO. </p>
+    <h4>Arguments</h4>
+    <dl>
+      <dt>a{sv} : args</dt>
+      <dd>
+	A dictionary with parameters for removing a client
+	<table>
+	<tr><th>Key</th><th>Value type</th><th>Description</th><th>Required</th></tr>
+	<tr><td>peer</td><td>o</td><td>Object path for peer's P2P device address</td><td>yes</td></tr>
+	<tr><td>iface</td><td>s</td><td>Interface address[MAC Address format] of peer to be disconnected format. Required if object path is not provided</td><td>no</td></tr>
+	</table>
+      </dd>
+    </dl>
+  </li>
+
+  <li>
     <h3>Flush ( nothing ) --> nothing</h3>
     <p>Flush P2P peer table and state.</p>
   </li>
diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
index 0696666..fca1534 100644
--- a/wpa_supplicant/dbus/dbus_new.c
+++ b/wpa_supplicant/dbus/dbus_new.c
@@ -2721,6 +2721,13 @@ static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = {
 		  END_ARGS
 	  }
 	},
+	{ "RemoveClient", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+	  (WPADBusMethodHandler) wpas_dbus_handler_p2p_remove_client,
+	  {
+		  { "args", "a{sv}", ARG_IN },
+		  END_ARGS
+	  }
+	},
 	{ "Flush", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
 	  (WPADBusMethodHandler) wpas_dbus_handler_p2p_flush,
 	  {
diff --git a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
index 56e9033..2a0a26d 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
@@ -415,6 +415,64 @@ static dbus_bool_t wpa_dbus_p2p_check_enabled(struct wpa_supplicant *wpa_s,
 	return TRUE;
 }
 
+DBusMessage * wpas_dbus_handler_p2p_remove_client(DBusMessage *message,
+                                               struct wpa_supplicant *wpa_s)
+{
+	DBusMessageIter iter_dict;
+	DBusMessage *reply = NULL;
+	DBusMessageIter iter;
+	struct wpa_dbus_dict_entry entry;
+	char *peer_object_path = NULL;
+	char *interface_addr = NULL;
+	u8 peer_addr[ETH_ALEN];
+	int iface = 0;
+
+	if (!wpa_dbus_p2p_check_enabled(wpa_s, message, &reply, NULL))
+		return reply;
+
+	dbus_message_iter_init(message, &iter);
+
+	if (!wpa_dbus_dict_open_read(&iter, &iter_dict, NULL))
+		goto err;
+
+	while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
+		if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
+			goto err;
+
+		if (os_strcmp(entry.key, "peer") == 0 &&
+		    entry.type == DBUS_TYPE_OBJECT_PATH) {
+			peer_object_path = os_strdup(entry.str_value);
+			wpa_dbus_dict_entry_clear(&entry);
+		} else if (os_strcmp(entry.key, "iface") == 0 &&
+			   entry.type == DBUS_TYPE_STRING) {
+			interface_addr = os_strdup(entry.str_value);
+			iface = 1;
+			wpa_dbus_dict_entry_clear(&entry);
+		} else {
+			wpa_dbus_dict_entry_clear(&entry);
+			goto err;
+		}
+	}
+
+	if(peer_object_path &&
+	   (parse_peer_object_path(peer_object_path, peer_addr) < 0
+	     || !p2p_peer_known(wpa_s->global->p2p, peer_addr)))
+		goto err;
+	else if(iface && hwaddr_aton(interface_addr, peer_addr) < 0)
+		goto err;
+
+        wpas_p2p_remove_client(wpa_s, peer_addr, iface);
+	reply = NULL;
+out:
+	os_free(peer_object_path);
+	os_free(interface_addr);
+	return reply;
+err:
+	reply =  wpas_dbus_error_invalid_args(message,
+				"Invalid address format");
+	goto out;
+}
+
 
 DBusMessage * wpas_dbus_handler_p2p_flush(DBusMessage *message,
 					  struct wpa_supplicant *wpa_s)
diff --git a/wpa_supplicant/dbus/dbus_new_handlers_p2p.h b/wpa_supplicant/dbus/dbus_new_handlers_p2p.h
index d0953f1..0992eef 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers_p2p.h
+++ b/wpa_supplicant/dbus/dbus_new_handlers_p2p.h
@@ -27,6 +27,9 @@ DBusMessage *wpas_dbus_handler_p2p_stop_find(
 DBusMessage *wpas_dbus_handler_p2p_rejectpeer(
 	DBusMessage *message, struct wpa_supplicant *wpa_s);
 
+DBusMessage *wpas_dbus_handler_p2p_remove_client(
+	DBusMessage *message, struct wpa_supplicant *wpa_s);
+
 DBusMessage *wpas_dbus_handler_p2p_listen(
 	DBusMessage *message, struct wpa_supplicant *wpa_s);
 
-- 
1.9.1



More information about the Hostap mailing list