[PATCH 2/3] channel and frequency added in interface capability properties on dbus

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



new helper function is added which will fill container of typer array of int32

Signed-off-by: Avichal Agarwal <avichal.a@xxxxxxxxxxx>
Signed-off-by: Mayank Haarit <mayank.h@xxxxxxxxxxx>
Signed-off-by: Kyeong-Chae Lim <kcya.lim@xxxxxxxxxxx>
---
 wpa_supplicant/dbus/dbus_dict_helpers.c | 56 +++++++++++++++++++++++++++++++++
 wpa_supplicant/dbus/dbus_dict_helpers.h |  5 +++
 2 files changed, 61 insertions(+)

diff --git a/wpa_supplicant/dbus/dbus_dict_helpers.c b/wpa_supplicant/dbus/dbus_dict_helpers.c
index e4e9b8d..fc17c34 100644
--- a/wpa_supplicant/dbus/dbus_dict_helpers.c
+++ b/wpa_supplicant/dbus/dbus_dict_helpers.c
@@ -184,6 +184,40 @@ static dbus_bool_t _wpa_dbus_add_dict_entry_byte_array(
 }
 
 
+static dbus_bool_t _wpa_dbus_add_dict_entry_int32_array(
+	DBusMessageIter *iter_dict, const char *key,
+	int *value, const dbus_uint32_t value_len)
+{
+	DBusMessageIter iter_dict_entry, iter_dict_val, iter_array;
+	dbus_uint32_t i;
+
+	if (!_wpa_dbus_add_dict_entry_start(iter_dict, &iter_dict_entry,
+					    key, DBUS_TYPE_ARRAY) ||
+	    !dbus_message_iter_open_container(&iter_dict_entry,
+					      DBUS_TYPE_VARIANT,
+					      DBUS_TYPE_ARRAY_AS_STRING
+					      DBUS_TYPE_INT32_AS_STRING,
+					      &iter_dict_val) ||
+	    !dbus_message_iter_open_container(&iter_dict_val, DBUS_TYPE_ARRAY,
+					      DBUS_TYPE_INT32_AS_STRING,
+					      &iter_array))
+		return FALSE;
+
+	for (i = 0; i < value_len; i++) {
+		if (!dbus_message_iter_append_basic(&iter_array,
+						    DBUS_TYPE_INT32,
+						    &(value[i])))
+			return FALSE;
+	}
+
+	if (!dbus_message_iter_close_container(&iter_dict_val, &iter_array))
+		return FALSE;
+
+	return _wpa_dbus_add_dict_entry_end(iter_dict, &iter_dict_entry,
+					    &iter_dict_val);
+}
+
+
 /**
  * Add a string entry to the dict.
  *
@@ -341,6 +375,28 @@ dbus_bool_t wpa_dbus_dict_append_byte_array(DBusMessageIter *iter_dict,
 						   value_len);
 }
 
+/**
+ * Add a int32 array entry to the dict.
+ *
+ * @param iter_dict A valid DBusMessageIter returned from
+ *    wpa_dbus_dict_open_write()
+ * @param key The key of the dict item
+ * @param value The byte array
+ * @param value_len The length of the int array
+ * @return TRUE on success, FALSE on failure
+ *
+ */
+dbus_bool_t wpa_dbus_dict_append_int32_array(DBusMessageIter *iter_dict,
+					    const char *key,
+					    int *value,
+					    const dbus_uint32_t value_len)
+{
+	if (!key || (!value && value_len != 0))
+		return FALSE;
+	return _wpa_dbus_add_dict_entry_int32_array(iter_dict, key, value,
+						   value_len);
+}
+
 
 /**
  * Begin an array entry in the dict
diff --git a/wpa_supplicant/dbus/dbus_dict_helpers.h b/wpa_supplicant/dbus/dbus_dict_helpers.h
index 94a0efd..c6bef90 100644
--- a/wpa_supplicant/dbus/dbus_dict_helpers.h
+++ b/wpa_supplicant/dbus/dbus_dict_helpers.h
@@ -55,6 +55,11 @@ dbus_bool_t wpa_dbus_dict_append_byte_array(DBusMessageIter *iter_dict,
 					    const char *value,
 					    const dbus_uint32_t value_len);
 
+dbus_bool_t wpa_dbus_dict_append_int32_array(DBusMessageIter *iter_dict,
+					    const char *key,
+					    int *value,
+					    const dbus_uint32_t value_len);
+
 /* Manual construction and addition of array elements */
 dbus_bool_t wpa_dbus_dict_begin_array(DBusMessageIter *iter_dict,
 				      const char *key, const char *type,
-- 
2.7.4


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux