@@ -3126,10 +3126,37 @@ static const struct wpa_dbus_property_desc wpas_dbus_p2p_group_properties[] = {
wpas_dbus_getter_p2p_group_members,
NULL
},
- { "Properties",
- WPAS_DBUS_NEW_IFACE_P2P_GROUP, "a{sv}",
- wpas_dbus_getter_p2p_group_properties,
- wpas_dbus_setter_p2p_group_properties
+ { "Group", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "o",
+ wpas_dbus_getter_p2p_group,
+ NULL
+ },
+ { "Role", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "s",
+ wpas_dbus_getter_p2p_role,
+ NULL
+ },
+ { "SSID", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "ay",
+ wpas_dbus_getter_p2p_group_ssid,
+ NULL
+ },
+ { "BSSID", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "ay",
+ wpas_dbus_getter_p2p_group_bssid,
+ NULL
+ },
+ { "Frequency", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "q",
+ wpas_dbus_getter_p2p_group_frequency,
+ NULL
+ },
+ { "Passphrase", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "s",
+ wpas_dbus_getter_p2p_group_passphrase,
+ NULL
+ },
+ { "PSK", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "ay",
+ wpas_dbus_getter_p2p_group_psk,
+ NULL
+ },
+ { "WPSVendorExtensions", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "aay",
+ wpas_dbus_getter_p2p_group_vendor_ext,
+ NULL
},
{ NULL, NULL, NULL, NULL, NULL }
};
@@ -3251,10 +3278,6 @@ void wpas_dbus_unregister_p2p_group(struct wpa_supplicant *wpa_s,
static const struct wpa_dbus_property_desc
wpas_dbus_p2p_groupmember_properties[] = {
- { "Properties", WPAS_DBUS_NEW_IFACE_P2P_GROUPMEMBER, "a{sv}",
- wpas_dbus_getter_p2p_group_properties,
- NULL
- },
{ NULL, NULL, NULL, NULL, NULL }
};
@@ -1798,9 +1798,11 @@ dbus_bool_t wpas_dbus_getter_p2p_group_members(DBusMessageIter *iter,
const u8 *addr;
dbus_bool_t success = FALSE;
- /* Ensure we are a GO */
- if (wpa_s->wpa_state != WPA_COMPLETED)
- return FALSE;
+ /* Verify correct role for this property */
+ if (wpas_get_p2p_role(wpa_s) != WPAS_P2P_ROLE_GO) {
+ return wpas_dbus_simple_array_property_getter(
+ iter, DBUS_TYPE_OBJECT_PATH, NULL, 0, error);
+ }
ssid = wpa_s->conf->ssid;
/* At present WPAS P2P_GO mode only applicable for p2p_go */
@@ -1848,166 +1850,140 @@ out_of_memory:
}
-dbus_bool_t wpas_dbus_getter_p2p_group_properties(DBusMessageIter *iter,
- DBusError *error,
- void *user_data)
+dbus_bool_t wpas_dbus_getter_p2p_group_ssid(DBusMessageIter *iter,
+ DBusError *error, void *user_data)
{
struct wpa_supplicant *wpa_s = user_data;
- DBusMessageIter variant_iter, dict_iter;
- struct hostapd_data *hapd = NULL;
- const struct wpabuf *vendor_ext[MAX_WPS_VENDOR_EXTENSIONS];
- int num_vendor_ext = 0;
- int i;
- u8 role = wpas_get_p2p_role(wpa_s);
- u16 op_freq = 0;
- u8 *p_bssid = NULL;
- char *role_name = NULL;
-
- if (!wpa_s->current_ssid)
+ if (wpa_s->current_ssid == NULL)
return FALSE;
+ return wpas_dbus_simple_array_property_getter(
+ iter, DBUS_TYPE_BYTE, wpa_s->current_ssid->ssid,
+ wpa_s->current_ssid->ssid_len, error);
+}
- /* Check current role and adjust information accordingly */
- switch (role) {
- case WPAS_P2P_ROLE_CLIENT:
- /* go_params is only valid for a client */
- if (wpa_s->go_params) {
- op_freq = wpa_s->go_params->freq;
- p_bssid = wpa_s->current_ssid->bssid;
- role_name = "client";
- } else
+
+dbus_bool_t wpas_dbus_getter_p2p_group_bssid(DBusMessageIter *iter,
+ DBusError *error,
+ void *user_data)
+{
+ struct wpa_supplicant *wpa_s = user_data;
+ u8 role = wpas_get_p2p_role(wpa_s);
+ u8 *p_bssid;
+
+ if (role == WPAS_P2P_ROLE_CLIENT) {
+ if (wpa_s->current_ssid == NULL)
return FALSE;
- break;
- case WPAS_P2P_ROLE_GO:
- /* ap_iface is only valid for a GO */
- if (wpa_s->ap_iface) {
- hapd = wpa_s->ap_iface->bss[0];
- p_bssid = hapd->own_addr;
- op_freq = wpa_s->ap_iface->freq;
- role_name = "GO";
- } else
+ p_bssid = wpa_s->current_ssid->bssid;
+ } else {
+ if (wpa_s->ap_iface == NULL)
return FALSE;
- break;
- default:
- /* Error condition; this should NEVER occur */
- return FALSE;
+ p_bssid = wpa_s->ap_iface->bss[0]->own_addr;
}
- if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
- "a{sv}", &variant_iter) ||
- !wpa_dbus_dict_open_write(&variant_iter, &dict_iter))
- goto err_no_mem;
- /* Provide the SSID */
- if (!wpa_dbus_dict_append_byte_array(
- &dict_iter, "SSID",
- (const char *) wpa_s->current_ssid->ssid,
- wpa_s->current_ssid->ssid_len))
- goto err_no_mem;
- /* Provide the BSSID */
- if (p_bssid &&
- !wpa_dbus_dict_append_byte_array(&dict_iter, "BSSID",
- (const char *) p_bssid, ETH_ALEN))
- goto err_no_mem;
- /* Provide the role within the group */
- if (role_name &&
- !wpa_dbus_dict_append_string(&dict_iter, "Role", role_name))
- goto err_no_mem;
- /* Provide the operational frequency */
- if (!wpa_dbus_dict_append_uint16(&dict_iter, "Frequency", op_freq))
- goto err_no_mem;
+ return wpas_dbus_simple_array_property_getter(iter, DBUS_TYPE_BYTE,
+ p_bssid, ETH_ALEN,
+ error);
+}
- /* Additional information for group owners */
- if (role == WPAS_P2P_ROLE_GO) {
- /* Provide the passphrase */
- if (!wpa_dbus_dict_append_string(&dict_iter, "Passphrase",
- wpa_s->current_ssid->passphrase))
- goto err_no_mem;
- /* Parse WPS Vendor Extensions sent in Beacon/Probe Response */
- for (i = 0; hapd && i < MAX_WPS_VENDOR_EXTENSIONS; i++) {
- if (hapd->conf->wps_vendor_ext[i] == NULL)
- continue;
- vendor_ext[num_vendor_ext++] =
- hapd->conf->wps_vendor_ext[i];
- }
- if (!wpa_dbus_dict_append_wpabuf_array(&dict_iter,
- "WPSVendorExtensions",
- vendor_ext, num_vendor_ext))
- goto err_no_mem;
- } else {
- /* If not a GO, provide the PSK */
- if (!wpa_dbus_dict_append_byte_array(
- &dict_iter, "PSK",
- (const char *) wpa_s->current_ssid->psk, 32))
- goto err_no_mem;
- }
- if (!wpa_dbus_dict_close_write(&variant_iter, &dict_iter) ||
- !dbus_message_iter_close_container(iter, &variant_iter))
- goto err_no_mem;
+dbus_bool_t wpas_dbus_getter_p2p_group_frequency(DBusMessageIter *iter,
+ DBusError *error,
+ void *user_data)
+{
+ struct wpa_supplicant *wpa_s = user_data;
+ u16 op_freq;
+ u8 role = wpas_get_p2p_role(wpa_s);
- return TRUE;
+ if (role == WPAS_P2P_ROLE_CLIENT) {
+ if (wpa_s->go_params == NULL)
+ return FALSE;
+ op_freq = wpa_s->go_params->freq;
+ } else {
+ if (wpa_s->ap_iface == NULL)
+ return FALSE;
+ op_freq = wpa_s->ap_iface->freq;
+ }
-err_no_mem:
- dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
- return FALSE;
+ return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_UINT16,
+ &op_freq, error);
}
-dbus_bool_t wpas_dbus_setter_p2p_group_properties(DBusMessageIter *iter,
+dbus_bool_t wpas_dbus_getter_p2p_group_passphrase(DBusMessageIter *iter,
DBusError *error,
void *user_data)
{
struct wpa_supplicant *wpa_s = user_data;
- DBusMessageIter variant_iter, iter_dict;
- struct wpa_dbus_dict_entry entry = { .type = DBUS_TYPE_STRING };
- unsigned int i;
- struct hostapd_data *hapd = NULL;
+ u8 role = wpas_get_p2p_role(wpa_s);
+ char *p_pass = NULL;
- if (wpas_get_p2p_role(wpa_s) == WPAS_P2P_ROLE_GO &&
- wpa_s->ap_iface != NULL)
- hapd = wpa_s->ap_iface->bss[0];
- else
- return FALSE;
+ /* Verify correct role for this property */
+ if (role == WPAS_P2P_ROLE_GO) {
+ if (wpa_s->current_ssid == NULL)
+ return FALSE;
+ p_pass = wpa_s->current_ssid->passphrase;
+ } else
+ p_pass = "";
- dbus_message_iter_recurse(iter, &variant_iter);
- if (!wpa_dbus_dict_open_read(&variant_iter, &iter_dict, error))
- return FALSE;
+ return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
+ &p_pass, error);
- while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
- if (!wpa_dbus_dict_get_entry(&iter_dict, &entry)) {
- dbus_set_error_const(error, DBUS_ERROR_INVALID_ARGS,
- "invalid message format");
+}
+
+dbus_bool_t wpas_dbus_getter_p2p_group_psk(DBusMessageIter *iter,
+ DBusError *error, void *user_data)
+{
+ struct wpa_supplicant *wpa_s = user_data;
+ u8 role = wpas_get_p2p_role(wpa_s);
+ u8 *p_psk = NULL;
+ u8 psk_len = 0;
+
+ /* Verify correct role for this property */
+ if (role == WPAS_P2P_ROLE_CLIENT) {
+ if (wpa_s->current_ssid == NULL)
return FALSE;
- }
+ p_psk = wpa_s->current_ssid->psk;
+ psk_len = 32;
+ }
- if (os_strcmp(entry.key, "WPSVendorExtensions") == 0) {
- if (entry.type != DBUS_TYPE_ARRAY ||
- entry.array_type != WPAS_DBUS_TYPE_BINARRAY ||
- entry.array_len > MAX_WPS_VENDOR_EXTENSIONS)
- goto error;
+ return wpas_dbus_simple_array_property_getter(iter, DBUS_TYPE_BYTE,
+ &p_psk, psk_len, error);
+}
- for (i = 0; i < MAX_WPS_VENDOR_EXTENSIONS; i++) {
- if (i < entry.array_len) {
- hapd->conf->wps_vendor_ext[i] =
- entry.binarray_value[i];
- entry.binarray_value[i] = NULL;
- } else
- hapd->conf->wps_vendor_ext[i] = NULL;
- }
- hostapd_update_wps(hapd);
- } else
- goto error;
+dbus_bool_t wpas_dbus_getter_p2p_group_vendor_ext(DBusMessageIter *iter,
+ DBusError *error,
+ void *user_data)
+{
+ struct wpa_supplicant *wpa_s = user_data;
+ struct hostapd_data *hapd;
+ struct wpabuf *vendor_ext[MAX_WPS_VENDOR_EXTENSIONS];
+ int num_vendor_ext = 0;
+ int i;
- wpa_dbus_dict_entry_clear(&entry);
- }
+ /* Verify correct role for this property */
+ if (wpas_get_p2p_role(wpa_s) == WPAS_P2P_ROLE_GO) {
+ if (wpa_s->ap_iface == NULL)
+ return FALSE;
+ hapd = wpa_s->ap_iface->bss[0];
- return TRUE;
+ /* Parse WPS Vendor Extensions sent in Beacon/Probe Response */
+ for (i = 0; i < MAX_WPS_VENDOR_EXTENSIONS; i++) {
+ if (hapd->conf->wps_vendor_ext[i] == NULL)
+ vendor_ext[i] = NULL;
+ else {
+ vendor_ext[num_vendor_ext++] =
+ hapd->conf->wps_vendor_ext[i];
+ }
+ }
+ }
-error:
- wpa_dbus_dict_entry_clear(&entry);
- dbus_set_error_const(error, DBUS_ERROR_INVALID_ARGS,
- "invalid message format");
- return FALSE;
+ /* Return vendor extensions or no data */
+ return wpas_dbus_simple_array_array_property_getter(iter,
+ DBUS_TYPE_BYTE,
+ vendor_ext,
+ num_vendor_ext,
+ error);
}
@@ -161,11 +161,27 @@ dbus_bool_t wpas_dbus_getter_p2p_group_members(DBusMessageIter *iter,
DBusError *error,
void *user_data);
-dbus_bool_t wpas_dbus_getter_p2p_group_properties(DBusMessageIter *iter,
+dbus_bool_t wpas_dbus_getter_p2p_group_ssid(DBusMessageIter *iter,
+ DBusError *error,
+ void *user_data);
+
+dbus_bool_t wpas_dbus_getter_p2p_group_bssid(DBusMessageIter *iter,
+ DBusError *error,
+ void *user_data);
+
+dbus_bool_t wpas_dbus_getter_p2p_group_frequency(DBusMessageIter *iter,
+ DBusError *error,
+ void *user_data);
+
+dbus_bool_t wpas_dbus_getter_p2p_group_passphrase(DBusMessageIter *iter,
DBusError *error,
void *user_data);
-dbus_bool_t wpas_dbus_setter_p2p_group_properties(DBusMessageIter *iter,
+dbus_bool_t wpas_dbus_getter_p2p_group_psk(DBusMessageIter *iter,
+ DBusError *error,
+ void *user_data);
+
+dbus_bool_t wpas_dbus_getter_p2p_group_vendor_ext(DBusMessageIter *iter,
DBusError *error,
void *user_data);