[PATCH 1/2] P2P: Enable P2P capability advertisement on D-Bus
Sane, Jayant
jayant.sane
Tue May 24 16:31:57 PDT 2011
Append "P2P" to capability information if supported by device.
Signed-off-by: Reinette Chatre <reinette.chatre at intel.com>
Signed-off-by: Jayant Sane <jayant.sane at intel.com>
---
Note: This patch applies on top of "0011-DBus-add-support-for-P2P-primitives.patch"
being maintained at
http://johannes.sipsolutions.net/patches/hostap/p2p-dbus-9/
wpa_supplicant/dbus/dbus_new_handlers.c | 38 ++++++++++++++++++++++++++----
1 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c
index 08d0f15..4336a3a 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers.c
@@ -1699,8 +1699,6 @@ DBusMessage * wpas_dbus_getter_capabilities(DBusMessage *message,
DBusMessageIter iter_dict_entry, iter_dict_val, iter_array,
variant_iter;
const char *scans[] = { "active", "passive", "ssid" };
- const char *modes[] = { "infrastructure", "ad-hoc", "ap" };
- int n = sizeof(modes) / sizeof(char *);
if (message == NULL)
reply = dbus_message_new(DBUS_MESSAGE_TYPE_SIGNAL);
@@ -1971,11 +1969,41 @@ DBusMessage * wpas_dbus_getter_capabilities(DBusMessage *message,
goto nomem;
/***** Modes */
- if (res < 0 || !(capa.flags & WPA_DRIVER_FLAGS_AP))
- n--; /* exclude ap mode if it is not supported by the driver */
- if (!wpa_dbus_dict_append_string_array(&iter_dict, "Modes", modes, n))
+ if (!wpa_dbus_dict_begin_string_array(&iter_dict, "Modes",
+ &iter_dict_entry,
+ &iter_dict_val,
+ &iter_array))
goto nomem;
+ if (!wpa_dbus_dict_string_array_add_element(
+ &iter_array, "infrastructure"))
+ goto nomem;
+
+ if (!wpa_dbus_dict_string_array_add_element(
+ &iter_array, "ad-hoc"))
+ goto nomem;
+
+ if (res >= 0) {
+ if (capa.flags & (WPA_DRIVER_FLAGS_AP)) {
+ if (!wpa_dbus_dict_string_array_add_element(
+ &iter_array, "ap"))
+ goto nomem;
+ }
+
+ if (capa.flags & (WPA_DRIVER_FLAGS_P2P_CAPABLE)) {
+ if (!wpa_dbus_dict_string_array_add_element(
+ &iter_array, "p2p"))
+ goto nomem;
+ }
+ }
+
+ if (!wpa_dbus_dict_end_string_array(&iter_dict,
+ &iter_dict_entry,
+ &iter_dict_val,
+ &iter_array))
+ goto nomem;
+ /***** Modes end*/
+
if (!wpa_dbus_dict_close_write(&variant_iter, &iter_dict))
goto nomem;
if (!dbus_message_iter_close_container(&iter, &variant_iter))
--
1.7.1
More information about the Hostap
mailing list