2011-06-12 18:08:19 -04:00
|
|
|
/*
|
|
|
|
* WPA Supplicant / dbus-based control interface (P2P)
|
2012-05-07 06:07:22 -04:00
|
|
|
* Copyright (c) 2011-2012, Intel Corporation
|
2011-06-12 18:08:19 -04:00
|
|
|
*
|
2012-05-07 06:07:22 -04:00
|
|
|
* This software may be distributed under the terms of the BSD license.
|
|
|
|
* See README for more details.
|
2011-06-12 18:08:19 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "includes.h"
|
|
|
|
|
|
|
|
#include "utils/includes.h"
|
|
|
|
#include "common.h"
|
|
|
|
#include "../config.h"
|
|
|
|
#include "../wpa_supplicant_i.h"
|
|
|
|
#include "../wps_supplicant.h"
|
2011-06-24 04:20:19 -04:00
|
|
|
#include "../notify.h"
|
2011-06-12 18:08:19 -04:00
|
|
|
#include "dbus_new_helpers.h"
|
|
|
|
#include "dbus_new.h"
|
|
|
|
#include "dbus_new_handlers.h"
|
|
|
|
#include "dbus_new_handlers_p2p.h"
|
|
|
|
#include "dbus_dict_helpers.h"
|
|
|
|
#include "p2p/p2p.h"
|
|
|
|
#include "common/ieee802_11_defs.h"
|
|
|
|
#include "ap/hostapd.h"
|
|
|
|
#include "ap/ap_config.h"
|
|
|
|
#include "ap/wps_hostapd.h"
|
|
|
|
|
|
|
|
#include "../p2p_supplicant.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parses out the mac address from the peer object path.
|
|
|
|
* @peer_path - object path of the form
|
|
|
|
* /fi/w1/wpa_supplicant1/Interfaces/n/Peers/00112233445566 (no colons)
|
|
|
|
* @addr - out param must be of ETH_ALEN size
|
|
|
|
* Returns 0 if valid (including MAC), -1 otherwise
|
|
|
|
*/
|
|
|
|
static int parse_peer_object_path(char *peer_path, u8 addr[ETH_ALEN])
|
|
|
|
{
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
if (!peer_path)
|
|
|
|
return -1;
|
2012-03-31 14:13:53 -04:00
|
|
|
p = os_strrchr(peer_path, '/');
|
2011-06-12 18:08:19 -04:00
|
|
|
if (!p)
|
|
|
|
return -1;
|
|
|
|
p++;
|
|
|
|
return hwaddr_compact_aton(p, addr);
|
|
|
|
}
|
|
|
|
|
2011-06-24 04:20:19 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* wpas_dbus_error_persistent_group_unknown - Return a new PersistentGroupUnknown
|
|
|
|
* error message
|
|
|
|
* @message: Pointer to incoming dbus message this error refers to
|
|
|
|
* Returns: a dbus error message
|
|
|
|
*
|
|
|
|
* Convenience function to create and return an invalid persistent group error.
|
|
|
|
*/
|
|
|
|
static DBusMessage * wpas_dbus_error_persistent_group_unknown(
|
|
|
|
DBusMessage *message)
|
|
|
|
{
|
|
|
|
return dbus_message_new_error(message, WPAS_DBUS_ERROR_NETWORK_UNKNOWN,
|
|
|
|
"There is no such persistent group in "
|
|
|
|
"this P2P device.");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
DBusMessage * wpas_dbus_handler_p2p_find(DBusMessage *message,
|
|
|
|
struct wpa_supplicant *wpa_s)
|
2011-06-12 18:08:19 -04:00
|
|
|
{
|
|
|
|
struct wpa_dbus_dict_entry entry;
|
|
|
|
DBusMessage *reply = NULL;
|
|
|
|
DBusMessageIter iter;
|
|
|
|
DBusMessageIter iter_dict;
|
|
|
|
unsigned int timeout = 0;
|
|
|
|
enum p2p_discovery_type type = P2P_FIND_ONLY_SOCIAL;
|
|
|
|
int num_req_dev_types = 0;
|
|
|
|
unsigned int i;
|
|
|
|
u8 *req_dev_types = NULL;
|
|
|
|
|
|
|
|
dbus_message_iter_init(message, &iter);
|
2011-07-15 07:39:07 -04:00
|
|
|
entry.key = NULL;
|
2011-06-12 18:08:19 -04:00
|
|
|
|
2011-07-29 14:25:39 -04:00
|
|
|
if (!wpa_dbus_dict_open_read(&iter, &iter_dict, NULL))
|
2011-06-12 18:08:19 -04:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
|
|
|
|
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (!os_strcmp(entry.key, "Timeout") &&
|
|
|
|
(entry.type == DBUS_TYPE_INT32)) {
|
|
|
|
timeout = entry.uint32_value;
|
|
|
|
} else if (os_strcmp(entry.key, "RequestedDeviceTypes") == 0) {
|
|
|
|
if ((entry.type != DBUS_TYPE_ARRAY) ||
|
|
|
|
(entry.array_type != WPAS_DBUS_TYPE_BINARRAY))
|
|
|
|
goto error_clear;
|
|
|
|
|
2011-10-16 06:19:33 -04:00
|
|
|
os_free(req_dev_types);
|
2011-06-12 18:08:19 -04:00
|
|
|
req_dev_types =
|
|
|
|
os_malloc(WPS_DEV_TYPE_LEN * entry.array_len);
|
|
|
|
if (!req_dev_types)
|
|
|
|
goto error_clear;
|
|
|
|
|
|
|
|
for (i = 0; i < entry.array_len; i++) {
|
|
|
|
if (wpabuf_len(entry.binarray_value[i]) !=
|
|
|
|
WPS_DEV_TYPE_LEN)
|
|
|
|
goto error_clear;
|
|
|
|
os_memcpy(req_dev_types + i * WPS_DEV_TYPE_LEN,
|
|
|
|
wpabuf_head(entry.binarray_value[i]),
|
|
|
|
WPS_DEV_TYPE_LEN);
|
|
|
|
}
|
|
|
|
num_req_dev_types = entry.array_len;
|
2011-08-26 19:55:58 -04:00
|
|
|
} else if (!os_strcmp(entry.key, "DiscoveryType") &&
|
|
|
|
(entry.type == DBUS_TYPE_STRING)) {
|
|
|
|
if (!os_strcmp(entry.str_value, "start_with_full"))
|
|
|
|
type = P2P_FIND_START_WITH_FULL;
|
|
|
|
else if (!os_strcmp(entry.str_value, "social"))
|
|
|
|
type = P2P_FIND_ONLY_SOCIAL;
|
|
|
|
else if (!os_strcmp(entry.str_value, "progressive"))
|
|
|
|
type = P2P_FIND_PROGRESSIVE;
|
|
|
|
else
|
|
|
|
goto error_clear;
|
2011-06-12 18:08:19 -04:00
|
|
|
} else
|
|
|
|
goto error_clear;
|
|
|
|
wpa_dbus_dict_entry_clear(&entry);
|
|
|
|
}
|
|
|
|
|
2012-01-08 12:25:29 -05:00
|
|
|
wpas_p2p_find(wpa_s, timeout, type, num_req_dev_types, req_dev_types,
|
2012-08-23 11:20:58 -04:00
|
|
|
NULL, 0);
|
2011-07-15 09:33:21 -04:00
|
|
|
os_free(req_dev_types);
|
2011-06-12 18:08:19 -04:00
|
|
|
return reply;
|
|
|
|
|
|
|
|
error_clear:
|
|
|
|
wpa_dbus_dict_entry_clear(&entry);
|
|
|
|
error:
|
2011-07-15 09:33:21 -04:00
|
|
|
os_free(req_dev_types);
|
2011-06-12 18:08:19 -04:00
|
|
|
reply = wpas_dbus_error_invalid_args(message, entry.key);
|
|
|
|
return reply;
|
|
|
|
}
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
|
|
|
|
DBusMessage * wpas_dbus_handler_p2p_stop_find(DBusMessage *message,
|
|
|
|
struct wpa_supplicant *wpa_s)
|
2011-06-12 18:08:19 -04:00
|
|
|
{
|
|
|
|
wpas_p2p_stop_find(wpa_s);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
|
|
|
|
DBusMessage * wpas_dbus_handler_p2p_rejectpeer(DBusMessage *message,
|
|
|
|
struct wpa_supplicant *wpa_s)
|
2011-06-12 18:08:19 -04:00
|
|
|
{
|
|
|
|
DBusMessageIter iter;
|
|
|
|
char *peer_object_path = NULL;
|
|
|
|
u8 peer_addr[ETH_ALEN];
|
|
|
|
|
|
|
|
dbus_message_iter_init(message, &iter);
|
|
|
|
dbus_message_iter_get_basic(&iter, &peer_object_path);
|
|
|
|
|
|
|
|
if (parse_peer_object_path(peer_object_path, peer_addr) < 0)
|
|
|
|
return wpas_dbus_error_invalid_args(message, NULL);
|
|
|
|
|
|
|
|
if (wpas_p2p_reject(wpa_s, peer_addr) < 0)
|
|
|
|
return wpas_dbus_error_unknown_error(message,
|
|
|
|
"Failed to call wpas_p2p_reject method.");
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
|
|
|
|
DBusMessage * wpas_dbus_handler_p2p_listen(DBusMessage *message,
|
|
|
|
struct wpa_supplicant *wpa_s)
|
2011-06-12 18:08:19 -04:00
|
|
|
{
|
|
|
|
dbus_int32_t timeout = 0;
|
|
|
|
|
|
|
|
if (!dbus_message_get_args(message, NULL, DBUS_TYPE_INT32, &timeout,
|
|
|
|
DBUS_TYPE_INVALID))
|
|
|
|
return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (wpas_p2p_listen(wpa_s, (unsigned int)timeout))
|
|
|
|
return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
|
|
|
|
DBusMessage * wpas_dbus_handler_p2p_extendedlisten(
|
|
|
|
DBusMessage *message, struct wpa_supplicant *wpa_s)
|
2011-06-12 18:08:19 -04:00
|
|
|
{
|
|
|
|
unsigned int period = 0, interval = 0;
|
|
|
|
struct wpa_dbus_dict_entry entry;
|
|
|
|
DBusMessageIter iter;
|
|
|
|
DBusMessageIter iter_dict;
|
|
|
|
|
|
|
|
dbus_message_iter_init(message, &iter);
|
2011-07-15 07:39:07 -04:00
|
|
|
entry.key = NULL;
|
2011-06-12 18:08:19 -04:00
|
|
|
|
2011-07-29 14:25:39 -04:00
|
|
|
if (!wpa_dbus_dict_open_read(&iter, &iter_dict, NULL))
|
2011-06-12 18:08:19 -04:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
|
|
|
|
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
|
|
|
|
goto error;
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
if (!os_strcmp(entry.key, "period") &&
|
2011-06-12 18:08:19 -04:00
|
|
|
(entry.type == DBUS_TYPE_INT32))
|
|
|
|
period = entry.uint32_value;
|
2011-07-15 07:18:29 -04:00
|
|
|
else if (!os_strcmp(entry.key, "interval") &&
|
2011-06-12 18:08:19 -04:00
|
|
|
(entry.type == DBUS_TYPE_INT32))
|
|
|
|
interval = entry.uint32_value;
|
|
|
|
else
|
|
|
|
goto error_clear;
|
|
|
|
wpa_dbus_dict_entry_clear(&entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wpas_p2p_ext_listen(wpa_s, period, interval))
|
2011-07-15 07:18:29 -04:00
|
|
|
return wpas_dbus_error_unknown_error(
|
|
|
|
message, "failed to initiate a p2p_ext_listen.");
|
2011-06-12 18:08:19 -04:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
error_clear:
|
|
|
|
wpa_dbus_dict_entry_clear(&entry);
|
|
|
|
error:
|
|
|
|
return wpas_dbus_error_invalid_args(message, entry.key);
|
|
|
|
}
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
|
|
|
|
DBusMessage * wpas_dbus_handler_p2p_presence_request(
|
|
|
|
DBusMessage *message, struct wpa_supplicant *wpa_s)
|
2011-06-12 18:08:19 -04:00
|
|
|
{
|
|
|
|
unsigned int dur1 = 0, int1 = 0, dur2 = 0, int2 = 0;
|
|
|
|
struct wpa_dbus_dict_entry entry;
|
|
|
|
DBusMessageIter iter;
|
|
|
|
DBusMessageIter iter_dict;
|
|
|
|
|
|
|
|
dbus_message_iter_init(message, &iter);
|
2011-07-15 07:39:07 -04:00
|
|
|
entry.key = NULL;
|
2011-06-12 18:08:19 -04:00
|
|
|
|
2011-07-29 14:25:39 -04:00
|
|
|
if (!wpa_dbus_dict_open_read(&iter, &iter_dict, NULL))
|
2011-06-12 18:08:19 -04:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
|
|
|
|
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
|
|
|
|
goto error;
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
if (!os_strcmp(entry.key, "duration1") &&
|
2011-06-12 18:08:19 -04:00
|
|
|
(entry.type == DBUS_TYPE_INT32))
|
|
|
|
dur1 = entry.uint32_value;
|
2011-07-15 07:18:29 -04:00
|
|
|
else if (!os_strcmp(entry.key, "interval1") &&
|
2011-06-12 18:08:19 -04:00
|
|
|
entry.type == DBUS_TYPE_INT32)
|
|
|
|
int1 = entry.uint32_value;
|
2011-07-15 07:18:29 -04:00
|
|
|
else if (!os_strcmp(entry.key, "duration2") &&
|
2011-06-12 18:08:19 -04:00
|
|
|
entry.type == DBUS_TYPE_INT32)
|
|
|
|
dur2 = entry.uint32_value;
|
2011-07-15 07:18:29 -04:00
|
|
|
else if (!os_strcmp(entry.key, "interval2") &&
|
2011-06-12 18:08:19 -04:00
|
|
|
entry.type == DBUS_TYPE_INT32)
|
|
|
|
int2 = entry.uint32_value;
|
|
|
|
else
|
|
|
|
goto error_clear;
|
|
|
|
|
|
|
|
wpa_dbus_dict_entry_clear(&entry);
|
|
|
|
}
|
|
|
|
if (wpas_p2p_presence_req(wpa_s, dur1, int1, dur2, int2) < 0)
|
|
|
|
return wpas_dbus_error_unknown_error(message,
|
|
|
|
"Failed to invoke presence request.");
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
error_clear:
|
|
|
|
wpa_dbus_dict_entry_clear(&entry);
|
|
|
|
error:
|
|
|
|
return wpas_dbus_error_invalid_args(message, entry.key);
|
|
|
|
}
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
|
|
|
|
DBusMessage * wpas_dbus_handler_p2p_group_add(DBusMessage *message,
|
|
|
|
struct wpa_supplicant *wpa_s)
|
2011-06-12 18:08:19 -04:00
|
|
|
{
|
|
|
|
DBusMessageIter iter_dict;
|
|
|
|
DBusMessage *reply = NULL;
|
|
|
|
DBusMessageIter iter;
|
|
|
|
struct wpa_dbus_dict_entry entry;
|
2011-06-24 04:20:19 -04:00
|
|
|
char *pg_object_path = NULL;
|
2011-06-12 18:08:19 -04:00
|
|
|
int persistent_group = 0;
|
|
|
|
int freq = 0;
|
|
|
|
char *iface = NULL;
|
|
|
|
char *net_id_str = NULL;
|
|
|
|
unsigned int group_id = 0;
|
|
|
|
struct wpa_ssid *ssid;
|
|
|
|
|
|
|
|
dbus_message_iter_init(message, &iter);
|
|
|
|
|
2011-07-29 14:25:39 -04:00
|
|
|
if (!wpa_dbus_dict_open_read(&iter, &iter_dict, NULL))
|
2011-06-12 18:08:19 -04:00
|
|
|
goto inv_args;
|
|
|
|
|
|
|
|
while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
|
|
|
|
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
|
|
|
|
goto inv_args;
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
if (!os_strcmp(entry.key, "persistent") &&
|
2011-06-12 18:08:19 -04:00
|
|
|
(entry.type == DBUS_TYPE_BOOLEAN)) {
|
|
|
|
persistent_group = (entry.bool_value == TRUE) ? 1 : 0;
|
2011-07-15 07:18:29 -04:00
|
|
|
} else if (!os_strcmp(entry.key, "frequency") &&
|
2011-06-12 18:08:19 -04:00
|
|
|
(entry.type == DBUS_TYPE_INT32)) {
|
|
|
|
freq = entry.int32_value;
|
|
|
|
if (freq <= 0)
|
|
|
|
goto inv_args_clear;
|
2011-07-15 07:18:29 -04:00
|
|
|
} else if (!os_strcmp(entry.key, "persistent_group_object") &&
|
2011-06-12 18:08:19 -04:00
|
|
|
entry.type == DBUS_TYPE_OBJECT_PATH)
|
2011-06-24 04:20:19 -04:00
|
|
|
pg_object_path = os_strdup(entry.str_value);
|
2011-06-12 18:08:19 -04:00
|
|
|
else
|
|
|
|
goto inv_args_clear;
|
|
|
|
|
|
|
|
wpa_dbus_dict_entry_clear(&entry);
|
|
|
|
}
|
|
|
|
|
2011-06-24 04:20:19 -04:00
|
|
|
if (pg_object_path != NULL) {
|
2011-06-12 18:08:19 -04:00
|
|
|
/*
|
2011-06-24 04:20:19 -04:00
|
|
|
* A persistent group Object Path is defined meaning we want
|
|
|
|
* to re-invoke a persistent group.
|
2011-06-12 18:08:19 -04:00
|
|
|
*/
|
|
|
|
|
2011-06-24 04:20:19 -04:00
|
|
|
iface = wpas_dbus_new_decompose_object_path(pg_object_path, 1,
|
2011-06-12 18:08:19 -04:00
|
|
|
&net_id_str, NULL);
|
|
|
|
if (iface == NULL ||
|
|
|
|
os_strcmp(iface, wpa_s->dbus_new_path) != 0) {
|
|
|
|
reply =
|
|
|
|
wpas_dbus_error_invalid_args(message,
|
2011-06-24 04:20:19 -04:00
|
|
|
pg_object_path);
|
2011-06-12 18:08:19 -04:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
group_id = strtoul(net_id_str, NULL, 10);
|
|
|
|
if (errno == EINVAL) {
|
|
|
|
reply = wpas_dbus_error_invalid_args(
|
2011-06-24 04:20:19 -04:00
|
|
|
message, pg_object_path);
|
2011-06-12 18:08:19 -04:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2011-09-21 17:43:59 -04:00
|
|
|
/* Get the SSID structure from the persistent group id */
|
2011-06-12 18:08:19 -04:00
|
|
|
ssid = wpa_config_get_network(wpa_s->conf, group_id);
|
|
|
|
if (ssid == NULL || ssid->disabled != 2)
|
|
|
|
goto inv_args;
|
|
|
|
|
2012-08-15 15:53:01 -04:00
|
|
|
if (wpas_p2p_group_add_persistent(wpa_s, ssid, 0, freq, 0)) {
|
2011-07-15 07:18:29 -04:00
|
|
|
reply = wpas_dbus_error_unknown_error(
|
|
|
|
message,
|
|
|
|
"Failed to reinvoke a persistent group");
|
2011-06-12 18:08:19 -04:00
|
|
|
goto out;
|
|
|
|
}
|
2012-08-15 15:53:01 -04:00
|
|
|
} else if (wpas_p2p_group_add(wpa_s, persistent_group, freq, 0))
|
2011-06-12 18:08:19 -04:00
|
|
|
goto inv_args;
|
|
|
|
|
|
|
|
out:
|
2011-06-24 04:20:19 -04:00
|
|
|
os_free(pg_object_path);
|
2011-06-12 18:08:19 -04:00
|
|
|
os_free(net_id_str);
|
|
|
|
os_free(iface);
|
|
|
|
return reply;
|
|
|
|
inv_args_clear:
|
|
|
|
wpa_dbus_dict_entry_clear(&entry);
|
|
|
|
inv_args:
|
|
|
|
reply = wpas_dbus_error_invalid_args(message, NULL);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
|
|
|
|
DBusMessage * wpas_dbus_handler_p2p_disconnect(DBusMessage *message,
|
|
|
|
struct wpa_supplicant *wpa_s)
|
2011-06-12 18:08:19 -04:00
|
|
|
{
|
|
|
|
if (wpas_p2p_disconnect(wpa_s))
|
|
|
|
return wpas_dbus_error_unknown_error(message,
|
|
|
|
"failed to disconnect");
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
|
2011-07-29 15:59:54 -04:00
|
|
|
static dbus_bool_t wpa_dbus_p2p_check_enabled(struct wpa_supplicant *wpa_s,
|
|
|
|
DBusMessage *message,
|
|
|
|
DBusMessage **out_reply,
|
|
|
|
DBusError *error)
|
|
|
|
{
|
|
|
|
/* Return an error message or an error if P2P isn't available */
|
|
|
|
if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) {
|
|
|
|
if (out_reply) {
|
|
|
|
*out_reply = dbus_message_new_error(
|
|
|
|
message, DBUS_ERROR_FAILED,
|
|
|
|
"P2P is not available for this interface");
|
|
|
|
}
|
|
|
|
dbus_set_error_const(error, DBUS_ERROR_FAILED,
|
|
|
|
"P2P is not available for this "
|
|
|
|
"interface");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
DBusMessage * wpas_dbus_handler_p2p_flush(DBusMessage *message,
|
|
|
|
struct wpa_supplicant *wpa_s)
|
2011-06-12 18:08:19 -04:00
|
|
|
{
|
2011-07-29 15:59:54 -04:00
|
|
|
DBusMessage *reply = NULL;
|
|
|
|
|
|
|
|
if (!wpa_dbus_p2p_check_enabled(wpa_s, message, &reply, NULL))
|
|
|
|
return reply;
|
|
|
|
|
2011-06-12 18:08:19 -04:00
|
|
|
os_memset(wpa_s->p2p_auth_invite, 0, ETH_ALEN);
|
|
|
|
wpa_s->force_long_sd = 0;
|
|
|
|
p2p_flush(wpa_s->global->p2p);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
|
|
|
|
DBusMessage * wpas_dbus_handler_p2p_connect(DBusMessage *message,
|
|
|
|
struct wpa_supplicant *wpa_s)
|
2011-06-12 18:08:19 -04:00
|
|
|
{
|
|
|
|
DBusMessageIter iter_dict;
|
|
|
|
DBusMessage *reply = NULL;
|
|
|
|
DBusMessageIter iter;
|
|
|
|
struct wpa_dbus_dict_entry entry;
|
|
|
|
char *peer_object_path = NULL;
|
|
|
|
int persistent_group = 0;
|
|
|
|
int join = 0;
|
|
|
|
int authorize_only = 0;
|
|
|
|
int go_intent = -1;
|
|
|
|
int freq = 0;
|
|
|
|
u8 addr[ETH_ALEN];
|
|
|
|
char *pin = NULL;
|
|
|
|
enum p2p_wps_method wps_method = WPS_NOT_READY;
|
|
|
|
int new_pin;
|
|
|
|
char *err_msg = NULL;
|
|
|
|
char *iface = NULL;
|
|
|
|
|
2011-07-29 15:59:54 -04:00
|
|
|
if (!wpa_dbus_p2p_check_enabled(wpa_s, message, &reply, NULL))
|
|
|
|
return reply;
|
|
|
|
|
2011-06-12 18:08:19 -04:00
|
|
|
dbus_message_iter_init(message, &iter);
|
|
|
|
|
2011-07-29 14:25:39 -04:00
|
|
|
if (!wpa_dbus_dict_open_read(&iter, &iter_dict, NULL))
|
2011-06-12 18:08:19 -04:00
|
|
|
goto inv_args;
|
|
|
|
|
|
|
|
while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
|
|
|
|
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
|
|
|
|
goto inv_args;
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
if (!os_strcmp(entry.key, "peer") &&
|
2011-06-12 18:08:19 -04:00
|
|
|
(entry.type == DBUS_TYPE_OBJECT_PATH)) {
|
|
|
|
peer_object_path = os_strdup(entry.str_value);
|
2011-07-15 07:18:29 -04:00
|
|
|
} else if (!os_strcmp(entry.key, "persistent") &&
|
2011-06-12 18:08:19 -04:00
|
|
|
(entry.type == DBUS_TYPE_BOOLEAN)) {
|
|
|
|
persistent_group = (entry.bool_value == TRUE) ? 1 : 0;
|
2011-07-15 07:18:29 -04:00
|
|
|
} else if (!os_strcmp(entry.key, "join") &&
|
2011-06-12 18:08:19 -04:00
|
|
|
(entry.type == DBUS_TYPE_BOOLEAN)) {
|
|
|
|
join = (entry.bool_value == TRUE) ? 1 : 0;
|
2011-07-15 07:18:29 -04:00
|
|
|
} else if (!os_strcmp(entry.key, "authorize_only") &&
|
2011-06-12 18:08:19 -04:00
|
|
|
(entry.type == DBUS_TYPE_BOOLEAN)) {
|
|
|
|
authorize_only = (entry.bool_value == TRUE) ? 1 : 0;
|
2011-07-15 07:18:29 -04:00
|
|
|
} else if (!os_strcmp(entry.key, "frequency") &&
|
2011-06-12 18:08:19 -04:00
|
|
|
(entry.type == DBUS_TYPE_INT32)) {
|
|
|
|
freq = entry.int32_value;
|
|
|
|
if (freq <= 0)
|
|
|
|
goto inv_args_clear;
|
2011-07-15 07:18:29 -04:00
|
|
|
} else if (!os_strcmp(entry.key, "go_intent") &&
|
2011-06-12 18:08:19 -04:00
|
|
|
(entry.type == DBUS_TYPE_INT32)) {
|
|
|
|
go_intent = entry.int32_value;
|
|
|
|
if ((go_intent < 0) || (go_intent > 15))
|
|
|
|
goto inv_args_clear;
|
2011-07-15 07:18:29 -04:00
|
|
|
} else if (!os_strcmp(entry.key, "wps_method") &&
|
2011-06-12 18:08:19 -04:00
|
|
|
(entry.type == DBUS_TYPE_STRING)) {
|
2011-07-15 07:18:29 -04:00
|
|
|
if (!os_strcmp(entry.str_value, "pbc"))
|
2011-06-12 18:08:19 -04:00
|
|
|
wps_method = WPS_PBC;
|
2011-07-15 07:18:29 -04:00
|
|
|
else if (!os_strcmp(entry.str_value, "pin"))
|
2011-06-12 18:08:19 -04:00
|
|
|
wps_method = WPS_PIN_DISPLAY;
|
2011-07-15 07:18:29 -04:00
|
|
|
else if (!os_strcmp(entry.str_value, "display"))
|
2011-06-12 18:08:19 -04:00
|
|
|
wps_method = WPS_PIN_DISPLAY;
|
2011-07-15 07:18:29 -04:00
|
|
|
else if (!os_strcmp(entry.str_value, "keypad"))
|
2011-06-12 18:08:19 -04:00
|
|
|
wps_method = WPS_PIN_KEYPAD;
|
|
|
|
else
|
|
|
|
goto inv_args_clear;
|
2011-07-15 07:18:29 -04:00
|
|
|
} else if (!os_strcmp(entry.key, "pin") &&
|
2011-06-12 18:08:19 -04:00
|
|
|
(entry.type == DBUS_TYPE_STRING)) {
|
|
|
|
pin = os_strdup(entry.str_value);
|
|
|
|
} else
|
|
|
|
goto inv_args_clear;
|
|
|
|
|
|
|
|
wpa_dbus_dict_entry_clear(&entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!peer_object_path || (wps_method == WPS_NOT_READY) ||
|
|
|
|
(parse_peer_object_path(peer_object_path, addr) < 0) ||
|
2011-12-22 14:04:41 -05:00
|
|
|
!p2p_peer_known(wpa_s->global->p2p, addr))
|
2011-06-12 18:08:19 -04:00
|
|
|
goto inv_args;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Validate the wps_method specified and the pin value.
|
|
|
|
*/
|
2011-09-08 09:40:03 -04:00
|
|
|
if ((!pin || !pin[0]) && (wps_method == WPS_PIN_KEYPAD))
|
2011-06-12 18:08:19 -04:00
|
|
|
goto inv_args;
|
|
|
|
|
|
|
|
new_pin = wpas_p2p_connect(wpa_s, addr, pin, wps_method,
|
2012-04-13 09:04:36 -04:00
|
|
|
persistent_group, 0, join, authorize_only,
|
2012-08-15 16:07:44 -04:00
|
|
|
go_intent, freq, -1, 0, 0);
|
2011-06-12 18:08:19 -04:00
|
|
|
|
|
|
|
if (new_pin >= 0) {
|
2011-09-13 12:27:29 -04:00
|
|
|
char npin[9];
|
|
|
|
char *generated_pin;
|
|
|
|
os_snprintf(npin, sizeof(npin), "%08d", new_pin);
|
|
|
|
generated_pin = npin;
|
2011-06-12 18:08:19 -04:00
|
|
|
reply = dbus_message_new_method_return(message);
|
2011-09-13 12:27:29 -04:00
|
|
|
dbus_message_append_args(reply, DBUS_TYPE_STRING,
|
|
|
|
&generated_pin, DBUS_TYPE_INVALID);
|
2011-06-12 18:08:19 -04:00
|
|
|
} else {
|
|
|
|
switch (new_pin) {
|
|
|
|
case -2:
|
2011-07-15 07:41:01 -04:00
|
|
|
err_msg = "connect failed due to channel "
|
|
|
|
"unavailability.";
|
2011-06-12 18:08:19 -04:00
|
|
|
iface = WPAS_DBUS_ERROR_CONNECT_CHANNEL_UNAVAILABLE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case -3:
|
2011-07-15 07:41:01 -04:00
|
|
|
err_msg = "connect failed due to unsupported channel.";
|
2011-06-12 18:08:19 -04:00
|
|
|
iface = WPAS_DBUS_ERROR_CONNECT_CHANNEL_UNSUPPORTED;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2011-07-15 07:41:01 -04:00
|
|
|
err_msg = "connect failed due to unspecified error.";
|
2011-06-12 18:08:19 -04:00
|
|
|
iface = WPAS_DBUS_ERROR_CONNECT_UNSPECIFIED_ERROR;
|
|
|
|
break;
|
|
|
|
}
|
2011-07-15 07:41:01 -04:00
|
|
|
|
2011-06-12 18:08:19 -04:00
|
|
|
/*
|
2011-07-15 07:41:01 -04:00
|
|
|
* TODO:
|
2011-06-12 18:08:19 -04:00
|
|
|
* Do we need specialized errors corresponding to above
|
|
|
|
* error conditions as against just returning a different
|
|
|
|
* error message?
|
|
|
|
*/
|
|
|
|
reply = dbus_message_new_error(message, iface, err_msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
os_free(peer_object_path);
|
|
|
|
os_free(pin);
|
|
|
|
return reply;
|
|
|
|
inv_args_clear:
|
|
|
|
wpa_dbus_dict_entry_clear(&entry);
|
|
|
|
inv_args:
|
|
|
|
reply = wpas_dbus_error_invalid_args(message, NULL);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
|
|
|
|
DBusMessage * wpas_dbus_handler_p2p_invite(DBusMessage *message,
|
|
|
|
struct wpa_supplicant *wpa_s)
|
2011-06-12 18:08:19 -04:00
|
|
|
{
|
|
|
|
DBusMessageIter iter_dict;
|
|
|
|
DBusMessage *reply = NULL;
|
|
|
|
DBusMessageIter iter;
|
|
|
|
struct wpa_dbus_dict_entry entry;
|
|
|
|
char *peer_object_path = NULL;
|
2011-06-24 04:20:19 -04:00
|
|
|
char *pg_object_path = NULL;
|
2011-06-12 18:08:19 -04:00
|
|
|
char *iface = NULL;
|
|
|
|
char *net_id_str = NULL;
|
|
|
|
u8 peer_addr[ETH_ALEN];
|
|
|
|
unsigned int group_id = 0;
|
|
|
|
int persistent = 0;
|
|
|
|
struct wpa_ssid *ssid;
|
|
|
|
|
2011-07-29 15:59:54 -04:00
|
|
|
if (!wpa_dbus_p2p_check_enabled(wpa_s, message, &reply, NULL))
|
|
|
|
return reply;
|
|
|
|
|
2011-06-12 18:08:19 -04:00
|
|
|
dbus_message_iter_init(message, &iter);
|
|
|
|
|
2011-07-29 14:25:39 -04:00
|
|
|
if (!wpa_dbus_dict_open_read(&iter, &iter_dict, NULL))
|
2011-06-12 18:08:19 -04:00
|
|
|
goto err;
|
|
|
|
|
|
|
|
while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
|
|
|
|
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
|
|
|
|
goto err;
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
if (!os_strcmp(entry.key, "peer") &&
|
2011-06-12 18:08:19 -04:00
|
|
|
(entry.type == DBUS_TYPE_OBJECT_PATH)) {
|
|
|
|
peer_object_path = os_strdup(entry.str_value);
|
|
|
|
wpa_dbus_dict_entry_clear(&entry);
|
2011-07-15 07:18:29 -04:00
|
|
|
} else if (!os_strcmp(entry.key, "persistent_group_object") &&
|
2011-06-12 18:08:19 -04:00
|
|
|
(entry.type == DBUS_TYPE_OBJECT_PATH)) {
|
2011-06-24 04:20:19 -04:00
|
|
|
pg_object_path = os_strdup(entry.str_value);
|
2011-06-12 18:08:19 -04:00
|
|
|
persistent = 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) ||
|
2011-12-22 14:04:41 -05:00
|
|
|
!p2p_peer_known(wpa_s->global->p2p, peer_addr)) {
|
2011-06-12 18:08:19 -04:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (persistent) {
|
|
|
|
/*
|
|
|
|
* A group ID is defined meaning we want to re-invoke a
|
2011-09-21 17:43:59 -04:00
|
|
|
* persistent group
|
2011-06-12 18:08:19 -04:00
|
|
|
*/
|
|
|
|
|
2011-06-24 04:20:19 -04:00
|
|
|
iface = wpas_dbus_new_decompose_object_path(pg_object_path, 1,
|
2011-06-12 18:08:19 -04:00
|
|
|
&net_id_str, NULL);
|
|
|
|
if (iface == NULL ||
|
|
|
|
os_strcmp(iface, wpa_s->dbus_new_path) != 0) {
|
2011-07-15 07:18:29 -04:00
|
|
|
reply = wpas_dbus_error_invalid_args(message,
|
|
|
|
pg_object_path);
|
2011-06-12 18:08:19 -04:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
group_id = strtoul(net_id_str, NULL, 10);
|
|
|
|
if (errno == EINVAL) {
|
|
|
|
reply = wpas_dbus_error_invalid_args(
|
2011-07-15 07:18:29 -04:00
|
|
|
message, pg_object_path);
|
2011-06-12 18:08:19 -04:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2011-09-21 17:43:59 -04:00
|
|
|
/* Get the SSID structure from the persistent group id */
|
2011-06-12 18:08:19 -04:00
|
|
|
ssid = wpa_config_get_network(wpa_s->conf, group_id);
|
|
|
|
if (ssid == NULL || ssid->disabled != 2)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
if (wpas_p2p_invite(wpa_s, peer_addr, ssid, NULL) < 0) {
|
|
|
|
reply = wpas_dbus_error_unknown_error(
|
2011-07-15 07:18:29 -04:00
|
|
|
message,
|
|
|
|
"Failed to reinvoke a persistent group");
|
2011-06-12 18:08:19 -04:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* No group ID means propose to a peer to join my active group
|
|
|
|
*/
|
|
|
|
if (wpas_p2p_invite_group(wpa_s, wpa_s->ifname,
|
2011-07-15 07:18:29 -04:00
|
|
|
peer_addr, NULL)) {
|
2011-06-12 18:08:19 -04:00
|
|
|
reply = wpas_dbus_error_unknown_error(
|
2011-07-15 07:18:29 -04:00
|
|
|
message, "Failed to join to an active group");
|
2011-06-12 18:08:19 -04:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
2011-06-24 04:20:19 -04:00
|
|
|
os_free(pg_object_path);
|
2011-06-12 18:08:19 -04:00
|
|
|
os_free(peer_object_path);
|
|
|
|
return reply;
|
|
|
|
|
|
|
|
err:
|
|
|
|
reply = wpas_dbus_error_invalid_args(message, NULL);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
|
|
|
|
DBusMessage * wpas_dbus_handler_p2p_prov_disc_req(DBusMessage *message,
|
|
|
|
struct wpa_supplicant *wpa_s)
|
2011-06-12 18:08:19 -04:00
|
|
|
{
|
|
|
|
DBusMessageIter iter;
|
|
|
|
char *peer_object_path = NULL;
|
|
|
|
char *config_method = NULL;
|
|
|
|
u8 peer_addr[ETH_ALEN];
|
|
|
|
|
|
|
|
dbus_message_iter_init(message, &iter);
|
|
|
|
dbus_message_iter_get_basic(&iter, &peer_object_path);
|
|
|
|
|
|
|
|
if (parse_peer_object_path(peer_object_path, peer_addr) < 0)
|
|
|
|
return wpas_dbus_error_invalid_args(message, NULL);
|
|
|
|
|
|
|
|
dbus_message_iter_next(&iter);
|
|
|
|
dbus_message_iter_get_basic(&iter, &config_method);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Validation checks on config_method are being duplicated here
|
|
|
|
* to be able to return invalid args reply since the error code
|
|
|
|
* from p2p module are not granular enough (yet).
|
|
|
|
*/
|
|
|
|
if (os_strcmp(config_method, "display") &&
|
|
|
|
os_strcmp(config_method, "keypad") &&
|
|
|
|
os_strcmp(config_method, "pbc") &&
|
|
|
|
os_strcmp(config_method, "pushbutton"))
|
|
|
|
return wpas_dbus_error_invalid_args(message, NULL);
|
|
|
|
|
2012-04-26 10:13:03 -04:00
|
|
|
if (wpas_p2p_prov_disc(wpa_s, peer_addr, config_method,
|
|
|
|
WPAS_P2P_PD_FOR_GO_NEG) < 0)
|
2011-06-12 18:08:19 -04:00
|
|
|
return wpas_dbus_error_unknown_error(message,
|
|
|
|
"Failed to send provision discovery request");
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
|
2011-06-12 18:08:19 -04:00
|
|
|
/*
|
|
|
|
* P2P Device property accessor methods.
|
|
|
|
*/
|
|
|
|
|
2012-04-14 13:52:59 -04:00
|
|
|
dbus_bool_t wpas_dbus_getter_p2p_device_config(DBusMessageIter *iter,
|
|
|
|
DBusError *error,
|
|
|
|
void *user_data)
|
2011-06-12 18:08:19 -04:00
|
|
|
{
|
2011-07-29 14:25:39 -04:00
|
|
|
struct wpa_supplicant *wpa_s = user_data;
|
|
|
|
DBusMessageIter variant_iter, dict_iter;
|
2011-07-04 13:27:53 -04:00
|
|
|
DBusMessageIter iter_secdev_dict_entry, iter_secdev_dict_val,
|
|
|
|
iter_secdev_dict_array;
|
2011-06-12 18:08:19 -04:00
|
|
|
const char *dev_name;
|
|
|
|
int num_vendor_extensions = 0;
|
|
|
|
int i;
|
|
|
|
const struct wpabuf *vendor_ext[P2P_MAX_WPS_VENDOR_EXT];
|
|
|
|
|
2011-07-29 15:59:54 -04:00
|
|
|
if (!wpa_dbus_p2p_check_enabled(wpa_s, NULL, NULL, error))
|
|
|
|
return FALSE;
|
|
|
|
|
2011-07-29 14:25:39 -04:00
|
|
|
if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
|
2011-06-12 18:08:19 -04:00
|
|
|
"a{sv}", &variant_iter) ||
|
|
|
|
!wpa_dbus_dict_open_write(&variant_iter, &dict_iter))
|
|
|
|
goto err_no_mem;
|
|
|
|
|
|
|
|
/* DeviceName */
|
|
|
|
dev_name = wpa_s->conf->device_name;
|
|
|
|
if (dev_name &&
|
|
|
|
!wpa_dbus_dict_append_string(&dict_iter, "DeviceName", dev_name))
|
|
|
|
goto err_no_mem;
|
|
|
|
|
|
|
|
/* Primary device type */
|
|
|
|
if (!wpa_dbus_dict_append_byte_array(&dict_iter, "PrimaryDeviceType",
|
|
|
|
(char *)wpa_s->conf->device_type,
|
|
|
|
WPS_DEV_TYPE_LEN))
|
|
|
|
goto err_no_mem;
|
|
|
|
|
|
|
|
/* Secondary device types */
|
2011-07-04 13:27:53 -04:00
|
|
|
if (wpa_s->conf->num_sec_device_types) {
|
|
|
|
if (!wpa_dbus_dict_begin_array(&dict_iter,
|
|
|
|
"SecondaryDeviceTypes",
|
|
|
|
DBUS_TYPE_ARRAY_AS_STRING
|
|
|
|
DBUS_TYPE_BYTE_AS_STRING,
|
|
|
|
&iter_secdev_dict_entry,
|
|
|
|
&iter_secdev_dict_val,
|
|
|
|
&iter_secdev_dict_array))
|
|
|
|
goto err_no_mem;
|
|
|
|
|
|
|
|
for (i = 0; i < wpa_s->conf->num_sec_device_types; i++)
|
|
|
|
wpa_dbus_dict_bin_array_add_element(
|
|
|
|
&iter_secdev_dict_array,
|
|
|
|
wpa_s->conf->sec_device_type[i],
|
|
|
|
WPS_DEV_TYPE_LEN);
|
|
|
|
|
|
|
|
if (!wpa_dbus_dict_end_array(&dict_iter,
|
|
|
|
&iter_secdev_dict_entry,
|
|
|
|
&iter_secdev_dict_val,
|
|
|
|
&iter_secdev_dict_array))
|
|
|
|
goto err_no_mem;
|
2011-06-12 18:08:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Vendor Extensions */
|
|
|
|
for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
|
|
|
|
if (wpa_s->conf->wps_vendor_ext[i] == NULL)
|
|
|
|
continue;
|
|
|
|
vendor_ext[num_vendor_extensions++] =
|
|
|
|
wpa_s->conf->wps_vendor_ext[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (num_vendor_extensions &&
|
|
|
|
!wpa_dbus_dict_append_wpabuf_array(&dict_iter,
|
|
|
|
"VendorExtension",
|
|
|
|
vendor_ext,
|
|
|
|
num_vendor_extensions))
|
|
|
|
goto err_no_mem;
|
|
|
|
|
|
|
|
/* GO Intent */
|
|
|
|
if (!wpa_dbus_dict_append_uint32(&dict_iter, "GOIntent",
|
|
|
|
wpa_s->conf->p2p_go_intent))
|
|
|
|
goto err_no_mem;
|
|
|
|
|
2011-09-21 17:43:59 -04:00
|
|
|
/* Persistent Reconnect */
|
2012-04-14 13:52:59 -04:00
|
|
|
if (!wpa_dbus_dict_append_bool(&dict_iter, "PersistentReconnect",
|
2011-06-12 18:08:19 -04:00
|
|
|
wpa_s->conf->persistent_reconnect))
|
|
|
|
goto err_no_mem;
|
|
|
|
|
|
|
|
/* Listen Reg Class */
|
|
|
|
if (!wpa_dbus_dict_append_uint32(&dict_iter, "ListenRegClass",
|
|
|
|
wpa_s->conf->p2p_listen_reg_class))
|
|
|
|
goto err_no_mem;
|
|
|
|
|
|
|
|
/* Listen Channel */
|
|
|
|
if (!wpa_dbus_dict_append_uint32(&dict_iter, "ListenChannel",
|
|
|
|
wpa_s->conf->p2p_listen_channel))
|
|
|
|
goto err_no_mem;
|
|
|
|
|
|
|
|
/* Oper Reg Class */
|
|
|
|
if (!wpa_dbus_dict_append_uint32(&dict_iter, "OperRegClass",
|
|
|
|
wpa_s->conf->p2p_oper_reg_class))
|
|
|
|
goto err_no_mem;
|
|
|
|
|
|
|
|
/* Oper Channel */
|
|
|
|
if (!wpa_dbus_dict_append_uint32(&dict_iter, "OperChannel",
|
|
|
|
wpa_s->conf->p2p_oper_channel))
|
|
|
|
goto err_no_mem;
|
|
|
|
|
|
|
|
/* SSID Postfix */
|
|
|
|
if (wpa_s->conf->p2p_ssid_postfix &&
|
|
|
|
!wpa_dbus_dict_append_string(&dict_iter, "SsidPostfix",
|
|
|
|
wpa_s->conf->p2p_ssid_postfix))
|
|
|
|
goto err_no_mem;
|
|
|
|
|
|
|
|
/* Intra Bss */
|
|
|
|
if (!wpa_dbus_dict_append_bool(&dict_iter, "IntraBss",
|
|
|
|
wpa_s->conf->p2p_intra_bss))
|
|
|
|
goto err_no_mem;
|
|
|
|
|
|
|
|
/* Group Idle */
|
|
|
|
if (!wpa_dbus_dict_append_uint32(&dict_iter, "GroupIdle",
|
|
|
|
wpa_s->conf->p2p_group_idle))
|
|
|
|
goto err_no_mem;
|
|
|
|
|
2011-06-23 14:35:20 -04:00
|
|
|
/* Dissasociation low ack */
|
|
|
|
if (!wpa_dbus_dict_append_uint32(&dict_iter, "disassoc_low_ack",
|
|
|
|
wpa_s->conf->disassoc_low_ack))
|
|
|
|
goto err_no_mem;
|
|
|
|
|
2011-06-12 18:08:19 -04:00
|
|
|
if (!wpa_dbus_dict_close_write(&variant_iter, &dict_iter) ||
|
2011-07-29 14:25:39 -04:00
|
|
|
!dbus_message_iter_close_container(iter, &variant_iter))
|
2011-06-12 18:08:19 -04:00
|
|
|
goto err_no_mem;
|
|
|
|
|
2011-07-29 14:25:39 -04:00
|
|
|
return TRUE;
|
|
|
|
|
2011-06-12 18:08:19 -04:00
|
|
|
err_no_mem:
|
2011-07-29 14:25:39 -04:00
|
|
|
dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
|
|
|
|
return FALSE;
|
2011-06-12 18:08:19 -04:00
|
|
|
}
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
|
2012-04-14 13:52:59 -04:00
|
|
|
dbus_bool_t wpas_dbus_setter_p2p_device_config(DBusMessageIter *iter,
|
|
|
|
DBusError *error,
|
|
|
|
void *user_data)
|
2011-06-12 18:08:19 -04:00
|
|
|
{
|
2011-07-29 14:25:39 -04:00
|
|
|
struct wpa_supplicant *wpa_s = user_data;
|
|
|
|
DBusMessageIter variant_iter, iter_dict;
|
2011-06-12 18:08:19 -04:00
|
|
|
struct wpa_dbus_dict_entry entry = {.type = DBUS_TYPE_STRING };
|
|
|
|
unsigned int i;
|
|
|
|
|
2011-07-29 15:59:54 -04:00
|
|
|
if (!wpa_dbus_p2p_check_enabled(wpa_s, NULL, NULL, error))
|
|
|
|
return FALSE;
|
|
|
|
|
2011-07-29 14:25:39 -04:00
|
|
|
dbus_message_iter_recurse(iter, &variant_iter);
|
|
|
|
if (!wpa_dbus_dict_open_read(&variant_iter, &iter_dict, error))
|
|
|
|
return FALSE;
|
2011-06-12 18:08:19 -04:00
|
|
|
|
|
|
|
while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
|
2011-07-29 14:25:39 -04:00
|
|
|
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry)) {
|
|
|
|
dbus_set_error_const(error, DBUS_ERROR_INVALID_ARGS,
|
|
|
|
"invalid message format");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-06-12 18:08:19 -04:00
|
|
|
|
|
|
|
if (os_strcmp(entry.key, "DeviceName") == 0) {
|
|
|
|
char *devname;
|
|
|
|
|
|
|
|
if (entry.type != DBUS_TYPE_STRING)
|
2011-07-29 14:25:39 -04:00
|
|
|
goto error;
|
2011-06-12 18:08:19 -04:00
|
|
|
|
|
|
|
devname = os_strdup(entry.str_value);
|
|
|
|
if (devname == NULL)
|
|
|
|
goto err_no_mem_clear;
|
|
|
|
|
|
|
|
os_free(wpa_s->conf->device_name);
|
|
|
|
wpa_s->conf->device_name = devname;
|
|
|
|
|
|
|
|
wpa_s->conf->changed_parameters |=
|
2011-07-15 07:18:29 -04:00
|
|
|
CFG_CHANGED_DEVICE_NAME;
|
2011-06-12 18:08:19 -04:00
|
|
|
} else if (os_strcmp(entry.key, "PrimaryDeviceType") == 0) {
|
|
|
|
if (entry.type != DBUS_TYPE_ARRAY ||
|
|
|
|
entry.array_type != DBUS_TYPE_BYTE ||
|
|
|
|
entry.array_len != WPS_DEV_TYPE_LEN)
|
2011-07-29 14:25:39 -04:00
|
|
|
goto error;
|
2011-06-12 18:08:19 -04:00
|
|
|
|
|
|
|
os_memcpy(wpa_s->conf->device_type,
|
|
|
|
entry.bytearray_value,
|
|
|
|
WPS_DEV_TYPE_LEN);
|
|
|
|
wpa_s->conf->changed_parameters |=
|
|
|
|
CFG_CHANGED_DEVICE_TYPE;
|
|
|
|
} else if (os_strcmp(entry.key, "SecondaryDeviceTypes") == 0) {
|
|
|
|
if (entry.type != DBUS_TYPE_ARRAY ||
|
|
|
|
entry.array_type != WPAS_DBUS_TYPE_BINARRAY ||
|
|
|
|
entry.array_len > MAX_SEC_DEVICE_TYPES)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
for (i = 0; i < entry.array_len; i++)
|
2011-07-15 07:18:29 -04:00
|
|
|
if (wpabuf_len(entry.binarray_value[i]) !=
|
|
|
|
WPS_DEV_TYPE_LEN)
|
2011-06-12 18:08:19 -04:00
|
|
|
goto err_no_mem_clear;
|
|
|
|
for (i = 0; i < entry.array_len; i++)
|
|
|
|
os_memcpy(wpa_s->conf->sec_device_type[i],
|
|
|
|
wpabuf_head(entry.binarray_value[i]),
|
|
|
|
WPS_DEV_TYPE_LEN);
|
|
|
|
wpa_s->conf->num_sec_device_types = entry.array_len;
|
|
|
|
wpa_s->conf->changed_parameters |=
|
|
|
|
CFG_CHANGED_SEC_DEVICE_TYPE;
|
|
|
|
} else if (os_strcmp(entry.key, "VendorExtension") == 0) {
|
|
|
|
if ((entry.type != DBUS_TYPE_ARRAY) ||
|
|
|
|
(entry.array_type != WPAS_DBUS_TYPE_BINARRAY) ||
|
|
|
|
(entry.array_len > P2P_MAX_WPS_VENDOR_EXT))
|
2011-07-29 14:25:39 -04:00
|
|
|
goto error;
|
2011-06-12 18:08:19 -04:00
|
|
|
|
|
|
|
wpa_s->conf->changed_parameters |=
|
2011-07-15 07:18:29 -04:00
|
|
|
CFG_CHANGED_VENDOR_EXTENSION;
|
2011-06-12 18:08:19 -04:00
|
|
|
|
|
|
|
for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
|
|
|
|
wpabuf_free(wpa_s->conf->wps_vendor_ext[i]);
|
|
|
|
if (i < entry.array_len) {
|
|
|
|
wpa_s->conf->wps_vendor_ext[i] =
|
|
|
|
entry.binarray_value[i];
|
|
|
|
entry.binarray_value[i] = NULL;
|
|
|
|
} else
|
|
|
|
wpa_s->conf->wps_vendor_ext[i] = NULL;
|
|
|
|
}
|
|
|
|
} else if ((os_strcmp(entry.key, "GOIntent") == 0) &&
|
|
|
|
(entry.type == DBUS_TYPE_UINT32) &&
|
|
|
|
(entry.uint32_value <= 15))
|
|
|
|
wpa_s->conf->p2p_go_intent = entry.uint32_value;
|
2012-04-14 13:52:59 -04:00
|
|
|
else if ((os_strcmp(entry.key, "PersistentReconnect") == 0) &&
|
2011-06-12 18:08:19 -04:00
|
|
|
(entry.type == DBUS_TYPE_BOOLEAN))
|
|
|
|
wpa_s->conf->persistent_reconnect = entry.bool_value;
|
|
|
|
else if ((os_strcmp(entry.key, "ListenRegClass") == 0) &&
|
2011-06-25 05:08:43 -04:00
|
|
|
(entry.type == DBUS_TYPE_UINT32)) {
|
2011-06-12 18:08:19 -04:00
|
|
|
wpa_s->conf->p2p_listen_reg_class = entry.uint32_value;
|
2011-06-25 05:08:43 -04:00
|
|
|
wpa_s->conf->changed_parameters |=
|
|
|
|
CFG_CHANGED_P2P_LISTEN_CHANNEL;
|
|
|
|
} else if ((os_strcmp(entry.key, "ListenChannel") == 0) &&
|
|
|
|
(entry.type == DBUS_TYPE_UINT32)) {
|
2011-06-12 18:08:19 -04:00
|
|
|
wpa_s->conf->p2p_listen_channel = entry.uint32_value;
|
2011-06-25 05:08:43 -04:00
|
|
|
wpa_s->conf->changed_parameters |=
|
|
|
|
CFG_CHANGED_P2P_LISTEN_CHANNEL;
|
|
|
|
} else if ((os_strcmp(entry.key, "OperRegClass") == 0) &&
|
|
|
|
(entry.type == DBUS_TYPE_UINT32)) {
|
2011-06-12 18:08:19 -04:00
|
|
|
wpa_s->conf->p2p_oper_reg_class = entry.uint32_value;
|
2011-06-25 05:08:43 -04:00
|
|
|
wpa_s->conf->changed_parameters |=
|
|
|
|
CFG_CHANGED_P2P_OPER_CHANNEL;
|
|
|
|
} else if ((os_strcmp(entry.key, "OperChannel") == 0) &&
|
|
|
|
(entry.type == DBUS_TYPE_UINT32)) {
|
2011-06-12 18:08:19 -04:00
|
|
|
wpa_s->conf->p2p_oper_channel = entry.uint32_value;
|
2011-06-25 05:08:43 -04:00
|
|
|
wpa_s->conf->changed_parameters |=
|
|
|
|
CFG_CHANGED_P2P_OPER_CHANNEL;
|
|
|
|
} else if (os_strcmp(entry.key, "SsidPostfix") == 0) {
|
2011-06-12 18:08:19 -04:00
|
|
|
char *postfix;
|
|
|
|
|
|
|
|
if (entry.type != DBUS_TYPE_STRING)
|
2011-07-29 14:25:39 -04:00
|
|
|
goto error;
|
2011-06-12 18:08:19 -04:00
|
|
|
|
|
|
|
postfix = os_strdup(entry.str_value);
|
|
|
|
if (!postfix)
|
|
|
|
goto err_no_mem_clear;
|
|
|
|
|
|
|
|
os_free(wpa_s->conf->p2p_ssid_postfix);
|
|
|
|
wpa_s->conf->p2p_ssid_postfix = postfix;
|
|
|
|
|
|
|
|
wpa_s->conf->changed_parameters |=
|
|
|
|
CFG_CHANGED_P2P_SSID_POSTFIX;
|
|
|
|
} else if ((os_strcmp(entry.key, "IntraBss") == 0) &&
|
|
|
|
(entry.type == DBUS_TYPE_BOOLEAN)) {
|
|
|
|
wpa_s->conf->p2p_intra_bss = entry.bool_value;
|
|
|
|
wpa_s->conf->changed_parameters |=
|
2011-07-15 07:18:29 -04:00
|
|
|
CFG_CHANGED_P2P_INTRA_BSS;
|
2011-06-12 18:08:19 -04:00
|
|
|
} else if ((os_strcmp(entry.key, "GroupIdle") == 0) &&
|
|
|
|
(entry.type == DBUS_TYPE_UINT32))
|
|
|
|
wpa_s->conf->p2p_group_idle = entry.uint32_value;
|
2011-06-23 14:35:20 -04:00
|
|
|
else if (os_strcmp(entry.key, "disassoc_low_ack") == 0 &&
|
|
|
|
entry.type == DBUS_TYPE_UINT32)
|
|
|
|
wpa_s->conf->disassoc_low_ack = entry.uint32_value;
|
2011-06-12 18:08:19 -04:00
|
|
|
else
|
2011-07-29 14:25:39 -04:00
|
|
|
goto error;
|
2011-06-12 18:08:19 -04:00
|
|
|
|
|
|
|
wpa_dbus_dict_entry_clear(&entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wpa_s->conf->changed_parameters) {
|
|
|
|
/* Some changed parameters requires to update config*/
|
|
|
|
wpa_supplicant_update_config(wpa_s);
|
|
|
|
}
|
|
|
|
|
2011-07-29 14:25:39 -04:00
|
|
|
return TRUE;
|
2011-06-12 18:08:19 -04:00
|
|
|
|
|
|
|
error:
|
2011-07-29 14:25:39 -04:00
|
|
|
dbus_set_error_const(error, DBUS_ERROR_INVALID_ARGS,
|
|
|
|
"invalid message format");
|
2011-06-12 18:08:19 -04:00
|
|
|
wpa_dbus_dict_entry_clear(&entry);
|
2011-07-29 14:25:39 -04:00
|
|
|
return FALSE;
|
2011-06-12 18:08:19 -04:00
|
|
|
|
|
|
|
err_no_mem_clear:
|
2011-07-29 14:25:39 -04:00
|
|
|
dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
|
2011-06-12 18:08:19 -04:00
|
|
|
wpa_dbus_dict_entry_clear(&entry);
|
2011-07-29 14:25:39 -04:00
|
|
|
return FALSE;
|
2011-06-12 18:08:19 -04:00
|
|
|
}
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
|
2011-07-29 14:25:39 -04:00
|
|
|
dbus_bool_t wpas_dbus_getter_p2p_peers(DBusMessageIter *iter, DBusError *error,
|
|
|
|
void *user_data)
|
2011-06-12 18:08:19 -04:00
|
|
|
{
|
2011-07-29 14:25:39 -04:00
|
|
|
struct wpa_supplicant *wpa_s = user_data;
|
2011-06-12 18:08:19 -04:00
|
|
|
struct p2p_data *p2p = wpa_s->global->p2p;
|
|
|
|
int next = 0, i = 0;
|
|
|
|
int num = 0, out_of_mem = 0;
|
|
|
|
const u8 *addr;
|
|
|
|
const struct p2p_peer_info *peer_info = NULL;
|
2011-07-29 14:25:39 -04:00
|
|
|
dbus_bool_t success = FALSE;
|
2011-06-12 18:08:19 -04:00
|
|
|
|
|
|
|
struct dl_list peer_objpath_list;
|
|
|
|
struct peer_objpath_node {
|
|
|
|
struct dl_list list;
|
|
|
|
char path[WPAS_DBUS_OBJECT_PATH_MAX];
|
|
|
|
} *node, *tmp;
|
|
|
|
|
|
|
|
char **peer_obj_paths = NULL;
|
|
|
|
|
2011-07-29 15:59:54 -04:00
|
|
|
if (!wpa_dbus_p2p_check_enabled(wpa_s, NULL, NULL, error))
|
|
|
|
return FALSE;
|
|
|
|
|
2011-06-12 18:08:19 -04:00
|
|
|
dl_list_init(&peer_objpath_list);
|
|
|
|
|
|
|
|
/* Get the first peer info */
|
|
|
|
peer_info = p2p_get_peer_found(p2p, NULL, next);
|
|
|
|
|
|
|
|
/* Get next and accumulate them */
|
|
|
|
next = 1;
|
|
|
|
while (peer_info != NULL) {
|
|
|
|
node = os_zalloc(sizeof(struct peer_objpath_node));
|
|
|
|
if (!node) {
|
|
|
|
out_of_mem = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
addr = peer_info->p2p_device_addr;
|
|
|
|
os_snprintf(node->path, WPAS_DBUS_OBJECT_PATH_MAX,
|
|
|
|
"%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
|
|
|
|
"/" COMPACT_MACSTR,
|
|
|
|
wpa_s->dbus_new_path, MAC2STR(addr));
|
|
|
|
dl_list_add_tail(&peer_objpath_list, &node->list);
|
|
|
|
num++;
|
|
|
|
|
|
|
|
peer_info = p2p_get_peer_found(p2p, addr, next);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now construct the peer object paths in a form suitable for
|
|
|
|
* array_property_getter helper below.
|
|
|
|
*/
|
2012-08-13 13:44:21 -04:00
|
|
|
peer_obj_paths = os_calloc(num, sizeof(char *));
|
2011-06-12 18:08:19 -04:00
|
|
|
|
|
|
|
if (!peer_obj_paths) {
|
|
|
|
out_of_mem = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
dl_list_for_each_safe(node, tmp, &peer_objpath_list,
|
|
|
|
struct peer_objpath_node, list)
|
|
|
|
peer_obj_paths[i++] = node->path;
|
|
|
|
|
2011-07-29 14:25:39 -04:00
|
|
|
success = wpas_dbus_simple_array_property_getter(iter,
|
|
|
|
DBUS_TYPE_OBJECT_PATH,
|
|
|
|
peer_obj_paths, num,
|
|
|
|
error);
|
2011-06-12 18:08:19 -04:00
|
|
|
|
|
|
|
error:
|
|
|
|
if (peer_obj_paths)
|
|
|
|
os_free(peer_obj_paths);
|
|
|
|
|
|
|
|
dl_list_for_each_safe(node, tmp, &peer_objpath_list,
|
|
|
|
struct peer_objpath_node, list) {
|
|
|
|
dl_list_del(&node->list);
|
|
|
|
os_free(node);
|
|
|
|
}
|
|
|
|
if (out_of_mem)
|
2011-07-29 14:25:39 -04:00
|
|
|
dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
|
2011-06-12 18:08:19 -04:00
|
|
|
|
2011-07-29 14:25:39 -04:00
|
|
|
return success;
|
2011-06-12 18:08:19 -04:00
|
|
|
}
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
|
2011-06-12 18:08:19 -04:00
|
|
|
enum wpas_p2p_role {
|
|
|
|
WPAS_P2P_ROLE_DEVICE,
|
|
|
|
WPAS_P2P_ROLE_GO,
|
|
|
|
WPAS_P2P_ROLE_CLIENT,
|
|
|
|
};
|
|
|
|
|
|
|
|
static enum wpas_p2p_role wpas_get_p2p_role(struct wpa_supplicant *wpa_s)
|
|
|
|
{
|
|
|
|
struct wpa_ssid *ssid = wpa_s->current_ssid;
|
|
|
|
|
|
|
|
if (!ssid)
|
|
|
|
return WPAS_P2P_ROLE_DEVICE;
|
|
|
|
if (wpa_s->wpa_state != WPA_COMPLETED)
|
|
|
|
return WPAS_P2P_ROLE_DEVICE;
|
|
|
|
|
|
|
|
switch (ssid->mode) {
|
|
|
|
case WPAS_MODE_P2P_GO:
|
|
|
|
case WPAS_MODE_P2P_GROUP_FORMATION:
|
|
|
|
return WPAS_P2P_ROLE_GO;
|
|
|
|
case WPAS_MODE_INFRA:
|
|
|
|
if (ssid->p2p_group)
|
|
|
|
return WPAS_P2P_ROLE_CLIENT;
|
|
|
|
return WPAS_P2P_ROLE_DEVICE;
|
|
|
|
default:
|
|
|
|
return WPAS_P2P_ROLE_DEVICE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
|
2011-07-29 14:25:39 -04:00
|
|
|
dbus_bool_t wpas_dbus_getter_p2p_role(DBusMessageIter *iter, DBusError *error,
|
|
|
|
void *user_data)
|
2011-06-12 18:08:19 -04:00
|
|
|
{
|
2011-07-29 14:25:39 -04:00
|
|
|
struct wpa_supplicant *wpa_s = user_data;
|
2011-06-12 18:08:19 -04:00
|
|
|
char *str;
|
|
|
|
|
|
|
|
switch (wpas_get_p2p_role(wpa_s)) {
|
|
|
|
case WPAS_P2P_ROLE_GO:
|
|
|
|
str = "GO";
|
|
|
|
break;
|
|
|
|
case WPAS_P2P_ROLE_CLIENT:
|
|
|
|
str = "client";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
str = "device";
|
|
|
|
}
|
|
|
|
|
2011-07-29 14:25:39 -04:00
|
|
|
return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING, &str,
|
|
|
|
error);
|
2011-06-12 18:08:19 -04:00
|
|
|
}
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
|
2011-07-29 14:25:39 -04:00
|
|
|
dbus_bool_t wpas_dbus_getter_p2p_group(DBusMessageIter *iter, DBusError *error,
|
|
|
|
void *user_data)
|
2011-06-12 18:08:19 -04:00
|
|
|
{
|
2011-07-29 14:25:39 -04:00
|
|
|
struct wpa_supplicant *wpa_s = user_data;
|
2012-04-14 13:48:26 -04:00
|
|
|
char path_buf[WPAS_DBUS_OBJECT_PATH_MAX];
|
|
|
|
char *dbus_groupobj_path = path_buf;
|
2011-07-29 14:25:39 -04:00
|
|
|
|
2011-06-12 18:08:19 -04:00
|
|
|
if (wpa_s->dbus_groupobj_path == NULL)
|
2012-04-14 13:48:26 -04:00
|
|
|
os_snprintf(dbus_groupobj_path, WPAS_DBUS_OBJECT_PATH_MAX,
|
|
|
|
"/");
|
|
|
|
else
|
|
|
|
os_snprintf(dbus_groupobj_path, WPAS_DBUS_OBJECT_PATH_MAX,
|
|
|
|
"%s", wpa_s->dbus_groupobj_path);
|
2011-06-12 18:08:19 -04:00
|
|
|
|
2011-07-29 14:25:39 -04:00
|
|
|
return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_OBJECT_PATH,
|
2012-04-14 13:48:26 -04:00
|
|
|
&dbus_groupobj_path, error);
|
2011-06-12 18:08:19 -04:00
|
|
|
}
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
|
2011-07-29 14:25:39 -04:00
|
|
|
dbus_bool_t wpas_dbus_getter_p2p_peergo(DBusMessageIter *iter,
|
|
|
|
DBusError *error, void *user_data)
|
2011-06-12 18:08:19 -04:00
|
|
|
{
|
2011-07-29 14:25:39 -04:00
|
|
|
struct wpa_supplicant *wpa_s = user_data;
|
2011-06-12 18:08:19 -04:00
|
|
|
char go_peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
|
|
|
|
|
|
|
|
if (wpas_get_p2p_role(wpa_s) != WPAS_P2P_ROLE_CLIENT)
|
2012-04-14 13:48:26 -04:00
|
|
|
os_snprintf(go_peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX, "/");
|
|
|
|
else
|
|
|
|
os_snprintf(go_peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
|
|
|
|
"%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
|
|
|
|
COMPACT_MACSTR,
|
|
|
|
wpa_s->dbus_new_path, MAC2STR(wpa_s->go_dev_addr));
|
2011-06-12 18:08:19 -04:00
|
|
|
|
|
|
|
path = go_peer_obj_path;
|
2011-07-29 14:25:39 -04:00
|
|
|
return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_OBJECT_PATH,
|
|
|
|
&path, error);
|
2011-06-12 18:08:19 -04:00
|
|
|
}
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
|
2011-06-12 18:08:19 -04:00
|
|
|
/*
|
|
|
|
* Peer object properties accessor methods
|
|
|
|
*/
|
|
|
|
|
2012-02-11 04:36:50 -05:00
|
|
|
dbus_bool_t wpas_dbus_getter_p2p_peer_device_name(DBusMessageIter *iter,
|
|
|
|
DBusError *error,
|
|
|
|
void *user_data)
|
2011-06-12 18:08:19 -04:00
|
|
|
{
|
2011-07-29 14:25:39 -04:00
|
|
|
struct peer_handler_args *peer_args = user_data;
|
2012-02-11 04:36:50 -05:00
|
|
|
const struct p2p_peer_info *info;
|
|
|
|
char *tmp;
|
2011-06-12 18:08:19 -04:00
|
|
|
|
2011-07-29 15:59:54 -04:00
|
|
|
if (!wpa_dbus_p2p_check_enabled(peer_args->wpa_s, NULL, NULL, error))
|
|
|
|
return FALSE;
|
|
|
|
|
2011-06-12 18:08:19 -04:00
|
|
|
/* get the peer info */
|
|
|
|
info = p2p_get_peer_found(peer_args->wpa_s->global->p2p,
|
|
|
|
peer_args->p2p_device_addr, 0);
|
2011-07-29 14:25:39 -04:00
|
|
|
if (info == NULL) {
|
2012-02-11 04:36:50 -05:00
|
|
|
dbus_set_error(error, DBUS_ERROR_FAILED,
|
|
|
|
"failed to find peer");
|
2011-07-29 14:25:39 -04:00
|
|
|
return FALSE;
|
|
|
|
}
|
2011-06-12 18:08:19 -04:00
|
|
|
|
2012-02-11 04:36:50 -05:00
|
|
|
tmp = os_strdup(info->device_name);
|
|
|
|
if (!tmp) {
|
|
|
|
dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-06-12 18:08:19 -04:00
|
|
|
|
2012-02-11 04:36:50 -05:00
|
|
|
if (!wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING, &tmp,
|
|
|
|
error)) {
|
|
|
|
dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
|
|
|
|
os_free(tmp);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
os_free(tmp);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dbus_bool_t wpas_dbus_getter_p2p_peer_primary_device_type(
|
|
|
|
DBusMessageIter *iter, DBusError *error, void *user_data)
|
|
|
|
{
|
|
|
|
struct peer_handler_args *peer_args = user_data;
|
|
|
|
const struct p2p_peer_info *info;
|
|
|
|
|
|
|
|
info = p2p_get_peer_found(peer_args->wpa_s->global->p2p,
|
|
|
|
peer_args->p2p_device_addr, 0);
|
|
|
|
if (info == NULL) {
|
|
|
|
dbus_set_error(error, DBUS_ERROR_FAILED,
|
|
|
|
"failed to find peer");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!wpas_dbus_simple_array_property_getter(iter, DBUS_TYPE_BYTE,
|
|
|
|
(char *)
|
|
|
|
info->pri_dev_type,
|
|
|
|
WPS_DEV_TYPE_LEN, error)) {
|
|
|
|
dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dbus_bool_t wpas_dbus_getter_p2p_peer_config_method(DBusMessageIter *iter,
|
|
|
|
DBusError *error,
|
|
|
|
void *user_data)
|
|
|
|
{
|
|
|
|
struct peer_handler_args *peer_args = user_data;
|
|
|
|
const struct p2p_peer_info *info;
|
|
|
|
|
|
|
|
info = p2p_get_peer_found(peer_args->wpa_s->global->p2p,
|
|
|
|
peer_args->p2p_device_addr, 0);
|
|
|
|
if (info == NULL) {
|
|
|
|
dbus_set_error(error, DBUS_ERROR_FAILED,
|
|
|
|
"failed to find peer");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!wpas_dbus_simple_property_getter(iter, DBUS_TYPE_UINT16,
|
|
|
|
&info->config_methods, error)) {
|
|
|
|
dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dbus_bool_t wpas_dbus_getter_p2p_peer_level(DBusMessageIter *iter,
|
|
|
|
DBusError *error,
|
|
|
|
void *user_data)
|
|
|
|
{
|
|
|
|
struct peer_handler_args *peer_args = user_data;
|
|
|
|
const struct p2p_peer_info *info;
|
|
|
|
|
|
|
|
info = p2p_get_peer_found(peer_args->wpa_s->global->p2p,
|
|
|
|
peer_args->p2p_device_addr, 0);
|
|
|
|
if (info == NULL) {
|
|
|
|
dbus_set_error(error, DBUS_ERROR_FAILED,
|
|
|
|
"failed to find peer");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!wpas_dbus_simple_property_getter(iter, DBUS_TYPE_INT32,
|
|
|
|
&info->level, error)) {
|
|
|
|
dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dbus_bool_t wpas_dbus_getter_p2p_peer_device_capability(DBusMessageIter *iter,
|
|
|
|
DBusError *error,
|
|
|
|
void *user_data)
|
|
|
|
{
|
|
|
|
struct peer_handler_args *peer_args = user_data;
|
|
|
|
const struct p2p_peer_info *info;
|
|
|
|
|
|
|
|
info = p2p_get_peer_found(peer_args->wpa_s->global->p2p,
|
|
|
|
peer_args->p2p_device_addr, 0);
|
|
|
|
if (info == NULL) {
|
|
|
|
dbus_set_error(error, DBUS_ERROR_FAILED,
|
|
|
|
"failed to find peer");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!wpas_dbus_simple_property_getter(iter, DBUS_TYPE_BYTE,
|
|
|
|
&info->dev_capab, error)) {
|
|
|
|
dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dbus_bool_t wpas_dbus_getter_p2p_peer_group_capability(DBusMessageIter *iter,
|
|
|
|
DBusError *error,
|
|
|
|
void *user_data)
|
|
|
|
{
|
|
|
|
struct peer_handler_args *peer_args = user_data;
|
|
|
|
const struct p2p_peer_info *info;
|
|
|
|
|
|
|
|
info = p2p_get_peer_found(peer_args->wpa_s->global->p2p,
|
|
|
|
peer_args->p2p_device_addr, 0);
|
|
|
|
if (info == NULL) {
|
|
|
|
dbus_set_error(error, DBUS_ERROR_FAILED,
|
|
|
|
"failed to find peer");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!wpas_dbus_simple_property_getter(iter, DBUS_TYPE_BYTE,
|
|
|
|
&info->group_capab, error)) {
|
|
|
|
dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dbus_bool_t wpas_dbus_getter_p2p_peer_secondary_device_types(
|
|
|
|
DBusMessageIter *iter, DBusError *error, void *user_data)
|
|
|
|
{
|
|
|
|
struct peer_handler_args *peer_args = user_data;
|
|
|
|
const struct p2p_peer_info *info;
|
2012-02-25 03:50:13 -05:00
|
|
|
DBusMessageIter variant_iter, array_iter;
|
2012-02-11 04:36:50 -05:00
|
|
|
|
|
|
|
info = p2p_get_peer_found(peer_args->wpa_s->global->p2p,
|
|
|
|
peer_args->p2p_device_addr, 0);
|
|
|
|
if (info == NULL) {
|
|
|
|
dbus_set_error(error, DBUS_ERROR_FAILED,
|
|
|
|
"failed to find peer");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-06-12 18:08:19 -04:00
|
|
|
|
2012-02-25 03:50:13 -05:00
|
|
|
if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
|
|
|
|
DBUS_TYPE_ARRAY_AS_STRING
|
|
|
|
DBUS_TYPE_ARRAY_AS_STRING
|
|
|
|
DBUS_TYPE_BYTE_AS_STRING,
|
|
|
|
&variant_iter)) {
|
|
|
|
dbus_set_error(error, DBUS_ERROR_FAILED,
|
|
|
|
"%s: failed to construct message 1", __func__);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!dbus_message_iter_open_container(&variant_iter, DBUS_TYPE_ARRAY,
|
|
|
|
DBUS_TYPE_ARRAY_AS_STRING
|
|
|
|
DBUS_TYPE_BYTE_AS_STRING,
|
|
|
|
&array_iter)) {
|
|
|
|
dbus_set_error(error, DBUS_ERROR_FAILED,
|
|
|
|
"%s: failed to construct message 2", __func__);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-06-12 18:08:19 -04:00
|
|
|
if (info->wps_sec_dev_type_list_len) {
|
2011-08-06 14:34:11 -04:00
|
|
|
const u8 *sec_dev_type_list = info->wps_sec_dev_type_list;
|
2012-02-25 03:50:13 -05:00
|
|
|
int num_sec_device_types =
|
|
|
|
info->wps_sec_dev_type_list_len / WPS_DEV_TYPE_LEN;
|
|
|
|
int i;
|
|
|
|
DBusMessageIter inner_array_iter;
|
|
|
|
|
|
|
|
for (i = 0; i < num_sec_device_types; i++) {
|
|
|
|
if (!dbus_message_iter_open_container(
|
|
|
|
&array_iter, DBUS_TYPE_ARRAY,
|
|
|
|
DBUS_TYPE_BYTE_AS_STRING,
|
|
|
|
&inner_array_iter)) {
|
|
|
|
dbus_set_error(error, DBUS_ERROR_FAILED,
|
|
|
|
"%s: failed to construct "
|
|
|
|
"message 3 (%d)",
|
|
|
|
__func__, i);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-06-12 18:08:19 -04:00
|
|
|
|
2012-02-25 03:50:13 -05:00
|
|
|
if (!dbus_message_iter_append_fixed_array(
|
|
|
|
&inner_array_iter, DBUS_TYPE_BYTE,
|
|
|
|
&sec_dev_type_list, WPS_DEV_TYPE_LEN)) {
|
|
|
|
dbus_set_error(error, DBUS_ERROR_FAILED,
|
|
|
|
"%s: failed to construct "
|
|
|
|
"message 4 (%d)",
|
|
|
|
__func__, i);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!dbus_message_iter_close_container(
|
|
|
|
&array_iter, &inner_array_iter)) {
|
|
|
|
dbus_set_error(error, DBUS_ERROR_FAILED,
|
|
|
|
"%s: failed to construct "
|
|
|
|
"message 5 (%d)",
|
|
|
|
__func__, i);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
sec_dev_type_list += WPS_DEV_TYPE_LEN;
|
|
|
|
}
|
2012-02-11 04:36:50 -05:00
|
|
|
}
|
|
|
|
|
2012-02-25 03:50:13 -05:00
|
|
|
if (!dbus_message_iter_close_container(&variant_iter, &array_iter)) {
|
|
|
|
dbus_set_error(error, DBUS_ERROR_FAILED,
|
|
|
|
"%s: failed to construct message 6", __func__);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2012-02-11 04:36:50 -05:00
|
|
|
|
2012-02-25 03:50:13 -05:00
|
|
|
if (!dbus_message_iter_close_container(iter, &variant_iter)) {
|
|
|
|
dbus_set_error(error, DBUS_ERROR_FAILED,
|
|
|
|
"%s: failed to construct message 7", __func__);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2012-02-11 04:36:50 -05:00
|
|
|
|
2012-02-25 03:50:13 -05:00
|
|
|
return TRUE;
|
2012-02-11 04:36:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dbus_bool_t wpas_dbus_getter_p2p_peer_vendor_extension(DBusMessageIter *iter,
|
|
|
|
DBusError *error,
|
|
|
|
void *user_data)
|
|
|
|
{
|
2012-02-25 03:50:13 -05:00
|
|
|
struct wpabuf *vendor_extension[P2P_MAX_WPS_VENDOR_EXT];
|
2012-02-11 04:36:50 -05:00
|
|
|
int i, num;
|
|
|
|
struct peer_handler_args *peer_args = user_data;
|
|
|
|
const struct p2p_peer_info *info;
|
|
|
|
|
|
|
|
info = p2p_get_peer_found(peer_args->wpa_s->global->p2p,
|
|
|
|
peer_args->p2p_device_addr, 0);
|
|
|
|
if (info == NULL) {
|
|
|
|
dbus_set_error(error, DBUS_ERROR_FAILED,
|
|
|
|
"failed to find peer");
|
|
|
|
return FALSE;
|
2011-06-12 18:08:19 -04:00
|
|
|
}
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
/* Add WPS vendor extensions attribute */
|
|
|
|
for (i = 0, num = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
|
|
|
|
if (info->wps_vendor_ext[i] == NULL)
|
|
|
|
continue;
|
|
|
|
vendor_extension[num] = info->wps_vendor_ext[i];
|
|
|
|
num++;
|
2011-06-12 18:08:19 -04:00
|
|
|
}
|
|
|
|
|
2012-02-25 03:50:13 -05:00
|
|
|
if (!wpas_dbus_simple_array_array_property_getter(iter, DBUS_TYPE_BYTE,
|
|
|
|
vendor_extension,
|
|
|
|
num, error))
|
2012-02-11 04:36:50 -05:00
|
|
|
return FALSE;
|
2011-06-12 18:08:19 -04:00
|
|
|
|
2011-07-29 14:25:39 -04:00
|
|
|
return TRUE;
|
2011-06-12 18:08:19 -04:00
|
|
|
}
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
|
2011-07-29 14:25:39 -04:00
|
|
|
dbus_bool_t wpas_dbus_getter_p2p_peer_ies(DBusMessageIter *iter,
|
|
|
|
DBusError *error, void *user_data)
|
2011-06-12 18:08:19 -04:00
|
|
|
{
|
2012-02-25 03:54:11 -05:00
|
|
|
dbus_bool_t success;
|
2011-07-29 14:25:39 -04:00
|
|
|
/* struct peer_handler_args *peer_args = user_data; */
|
|
|
|
|
2012-02-25 03:54:11 -05:00
|
|
|
success = wpas_dbus_simple_array_property_getter(iter, DBUS_TYPE_BYTE,
|
|
|
|
NULL, 0, error);
|
|
|
|
return success;
|
2011-06-12 18:08:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-23 14:25:13 -04:00
|
|
|
/**
|
2011-09-21 17:43:59 -04:00
|
|
|
* wpas_dbus_getter_persistent_groups - Get array of persistent group objects
|
2011-07-29 14:25:39 -04:00
|
|
|
* @iter: Pointer to incoming dbus message iter
|
|
|
|
* @error: Location to store error on failure
|
|
|
|
* @user_data: Function specific data
|
|
|
|
* Returns: TRUE on success, FALSE on failure
|
2011-06-23 14:25:13 -04:00
|
|
|
*
|
2011-07-29 14:25:39 -04:00
|
|
|
* Getter for "PersistentGroups" property.
|
2011-06-23 14:25:13 -04:00
|
|
|
*/
|
2011-07-29 14:25:39 -04:00
|
|
|
dbus_bool_t wpas_dbus_getter_persistent_groups(DBusMessageIter *iter,
|
|
|
|
DBusError *error,
|
|
|
|
void *user_data)
|
2011-06-23 14:25:13 -04:00
|
|
|
{
|
2011-07-29 14:25:39 -04:00
|
|
|
struct wpa_supplicant *wpa_s = user_data;
|
2011-06-23 14:25:13 -04:00
|
|
|
struct wpa_ssid *ssid;
|
|
|
|
char **paths;
|
|
|
|
unsigned int i = 0, num = 0;
|
2011-07-29 14:25:39 -04:00
|
|
|
dbus_bool_t success = FALSE;
|
2011-06-23 14:25:13 -04:00
|
|
|
|
|
|
|
if (wpa_s->conf == NULL) {
|
2011-06-24 04:20:19 -04:00
|
|
|
wpa_printf(MSG_ERROR, "dbus: %s: "
|
|
|
|
"An error occurred getting persistent groups list",
|
|
|
|
__func__);
|
2011-07-29 14:25:39 -04:00
|
|
|
dbus_set_error_const(error, DBUS_ERROR_FAILED, "an error "
|
|
|
|
"occurred getting persistent groups list");
|
|
|
|
return FALSE;
|
2011-06-23 14:25:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next)
|
|
|
|
if (network_is_persistent_group(ssid))
|
|
|
|
num++;
|
|
|
|
|
2012-08-13 13:44:21 -04:00
|
|
|
paths = os_calloc(num, sizeof(char *));
|
2011-06-23 14:25:13 -04:00
|
|
|
if (!paths) {
|
2011-07-29 14:25:39 -04:00
|
|
|
dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
|
|
|
|
return FALSE;
|
2011-06-23 14:25:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Loop through configured networks and append object path of each */
|
|
|
|
for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) {
|
|
|
|
if (!network_is_persistent_group(ssid))
|
|
|
|
continue;
|
|
|
|
paths[i] = os_zalloc(WPAS_DBUS_OBJECT_PATH_MAX);
|
|
|
|
if (paths[i] == NULL) {
|
2011-07-29 14:25:39 -04:00
|
|
|
dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY,
|
|
|
|
"no memory");
|
2011-06-23 14:25:13 -04:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
/* Construct the object path for this network. */
|
|
|
|
os_snprintf(paths[i++], WPAS_DBUS_OBJECT_PATH_MAX,
|
|
|
|
"%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART "/%d",
|
|
|
|
wpa_s->dbus_new_path, ssid->id);
|
|
|
|
}
|
|
|
|
|
2011-07-29 14:25:39 -04:00
|
|
|
success = wpas_dbus_simple_array_property_getter(iter,
|
|
|
|
DBUS_TYPE_OBJECT_PATH,
|
|
|
|
paths, num, error);
|
2011-06-23 14:25:13 -04:00
|
|
|
|
|
|
|
out:
|
|
|
|
while (i)
|
|
|
|
os_free(paths[--i]);
|
|
|
|
os_free(paths);
|
2011-07-29 14:25:39 -04:00
|
|
|
return success;
|
2011-06-23 14:25:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpas_dbus_getter_persistent_group_properties - Get options for a persistent
|
|
|
|
* group
|
2011-07-29 14:25:39 -04:00
|
|
|
* @iter: Pointer to incoming dbus message iter
|
|
|
|
* @error: Location to store error on failure
|
|
|
|
* @user_data: Function specific data
|
|
|
|
* Returns: TRUE on success, FALSE on failure
|
2011-06-23 14:25:13 -04:00
|
|
|
*
|
|
|
|
* Getter for "Properties" property of a persistent group.
|
|
|
|
*/
|
2011-07-29 14:25:39 -04:00
|
|
|
dbus_bool_t wpas_dbus_getter_persistent_group_properties(DBusMessageIter *iter,
|
|
|
|
DBusError *error,
|
|
|
|
void *user_data)
|
2011-06-23 14:25:13 -04:00
|
|
|
{
|
2011-07-29 14:25:39 -04:00
|
|
|
struct network_handler_args *net = user_data;
|
|
|
|
|
|
|
|
/* Leveraging the fact that persistent group object is still
|
2011-06-23 14:25:13 -04:00
|
|
|
* represented in same manner as network within.
|
|
|
|
*/
|
2011-07-29 14:25:39 -04:00
|
|
|
return wpas_dbus_getter_network_properties(iter, error, net);
|
2011-06-23 14:25:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-24 04:20:19 -04:00
|
|
|
/**
|
|
|
|
* wpas_dbus_setter_persistent_group_properties - Get options for a persistent
|
|
|
|
* group
|
2011-07-29 14:25:39 -04:00
|
|
|
* @iter: Pointer to incoming dbus message iter
|
|
|
|
* @error: Location to store error on failure
|
|
|
|
* @user_data: Function specific data
|
|
|
|
* Returns: TRUE on success, FALSE on failure
|
2011-06-24 04:20:19 -04:00
|
|
|
*
|
|
|
|
* Setter for "Properties" property of a persistent group.
|
|
|
|
*/
|
2011-07-29 14:25:39 -04:00
|
|
|
dbus_bool_t wpas_dbus_setter_persistent_group_properties(DBusMessageIter *iter,
|
|
|
|
DBusError *error,
|
|
|
|
void *user_data)
|
2011-06-24 04:20:19 -04:00
|
|
|
{
|
2011-07-29 14:25:39 -04:00
|
|
|
struct network_handler_args *net = user_data;
|
2011-06-24 04:20:19 -04:00
|
|
|
struct wpa_ssid *ssid = net->ssid;
|
2011-07-29 14:25:39 -04:00
|
|
|
DBusMessageIter variant_iter;
|
2011-06-24 04:20:19 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Leveraging the fact that persistent group object is still
|
|
|
|
* represented in same manner as network within.
|
|
|
|
*/
|
2011-07-29 14:25:39 -04:00
|
|
|
dbus_message_iter_recurse(iter, &variant_iter);
|
|
|
|
return set_network_properties(net->wpa_s, ssid, &variant_iter, error);
|
2011-06-24 04:20:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpas_dbus_new_iface_add_persistent_group - Add a new configured
|
|
|
|
* persistent_group
|
|
|
|
* @message: Pointer to incoming dbus message
|
|
|
|
* @wpa_s: wpa_supplicant structure for a network interface
|
|
|
|
* Returns: A dbus message containing the object path of the new
|
|
|
|
* persistent group
|
|
|
|
*
|
|
|
|
* Handler function for "AddPersistentGroup" method call of a P2P Device
|
|
|
|
* interface.
|
|
|
|
*/
|
|
|
|
DBusMessage * wpas_dbus_handler_add_persistent_group(
|
|
|
|
DBusMessage *message, struct wpa_supplicant *wpa_s)
|
|
|
|
{
|
|
|
|
DBusMessage *reply = NULL;
|
|
|
|
DBusMessageIter iter;
|
|
|
|
struct wpa_ssid *ssid = NULL;
|
|
|
|
char path_buf[WPAS_DBUS_OBJECT_PATH_MAX], *path = path_buf;
|
2011-07-29 14:25:39 -04:00
|
|
|
DBusError error;
|
2011-06-24 04:20:19 -04:00
|
|
|
|
|
|
|
dbus_message_iter_init(message, &iter);
|
|
|
|
|
|
|
|
ssid = wpa_config_add_network(wpa_s->conf);
|
|
|
|
if (ssid == NULL) {
|
|
|
|
wpa_printf(MSG_ERROR, "dbus: %s: "
|
|
|
|
"Cannot add new persistent group", __func__);
|
|
|
|
reply = wpas_dbus_error_unknown_error(
|
|
|
|
message,
|
|
|
|
"wpa_supplicant could not add "
|
|
|
|
"a persistent group on this interface.");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Mark the ssid as being a persistent group before the notification */
|
|
|
|
ssid->disabled = 2;
|
|
|
|
ssid->p2p_persistent_group = 1;
|
|
|
|
wpas_notify_persistent_group_added(wpa_s, ssid);
|
|
|
|
|
|
|
|
wpa_config_set_network_defaults(ssid);
|
|
|
|
|
2011-07-29 14:25:39 -04:00
|
|
|
dbus_error_init(&error);
|
|
|
|
if (!set_network_properties(wpa_s, ssid, &iter, &error)) {
|
2011-06-24 04:20:19 -04:00
|
|
|
wpa_printf(MSG_DEBUG, "dbus: %s: "
|
|
|
|
"Control interface could not set persistent group "
|
|
|
|
"properties", __func__);
|
2011-07-29 14:25:39 -04:00
|
|
|
reply = wpas_dbus_reply_new_from_error(message, &error,
|
|
|
|
DBUS_ERROR_INVALID_ARGS,
|
|
|
|
"Failed to set network "
|
|
|
|
"properties");
|
|
|
|
dbus_error_free(&error);
|
2011-06-24 04:20:19 -04:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Construct the object path for this network. */
|
|
|
|
os_snprintf(path, WPAS_DBUS_OBJECT_PATH_MAX,
|
|
|
|
"%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART "/%d",
|
|
|
|
wpa_s->dbus_new_path, ssid->id);
|
|
|
|
|
|
|
|
reply = dbus_message_new_method_return(message);
|
|
|
|
if (reply == NULL) {
|
|
|
|
reply = dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
|
|
|
|
NULL);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
if (!dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &path,
|
|
|
|
DBUS_TYPE_INVALID)) {
|
|
|
|
dbus_message_unref(reply);
|
|
|
|
reply = dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
|
|
|
|
NULL);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
return reply;
|
|
|
|
|
|
|
|
err:
|
|
|
|
if (ssid) {
|
|
|
|
wpas_notify_persistent_group_removed(wpa_s, ssid);
|
|
|
|
wpa_config_remove_network(wpa_s->conf, ssid->id);
|
|
|
|
}
|
|
|
|
return reply;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpas_dbus_handler_remove_persistent_group - Remove a configured persistent
|
|
|
|
* group
|
|
|
|
* @message: Pointer to incoming dbus message
|
|
|
|
* @wpa_s: wpa_supplicant structure for a network interface
|
|
|
|
* Returns: NULL on success or dbus error on failure
|
|
|
|
*
|
|
|
|
* Handler function for "RemovePersistentGroup" method call of a P2P Device
|
|
|
|
* interface.
|
|
|
|
*/
|
|
|
|
DBusMessage * wpas_dbus_handler_remove_persistent_group(
|
|
|
|
DBusMessage *message, struct wpa_supplicant *wpa_s)
|
|
|
|
{
|
|
|
|
DBusMessage *reply = NULL;
|
|
|
|
const char *op;
|
|
|
|
char *iface = NULL, *persistent_group_id = NULL;
|
|
|
|
int id;
|
|
|
|
struct wpa_ssid *ssid;
|
|
|
|
|
|
|
|
dbus_message_get_args(message, NULL, DBUS_TYPE_OBJECT_PATH, &op,
|
|
|
|
DBUS_TYPE_INVALID);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Extract the network ID and ensure the network is actually a child of
|
|
|
|
* this interface.
|
|
|
|
*/
|
|
|
|
iface = wpas_dbus_new_decompose_object_path(op, 1,
|
|
|
|
&persistent_group_id,
|
|
|
|
NULL);
|
|
|
|
if (iface == NULL || os_strcmp(iface, wpa_s->dbus_new_path) != 0) {
|
|
|
|
reply = wpas_dbus_error_invalid_args(message, op);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
id = strtoul(persistent_group_id, NULL, 10);
|
|
|
|
if (errno == EINVAL) {
|
|
|
|
reply = wpas_dbus_error_invalid_args(message, op);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
ssid = wpa_config_get_network(wpa_s->conf, id);
|
|
|
|
if (ssid == NULL) {
|
|
|
|
reply = wpas_dbus_error_persistent_group_unknown(message);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
wpas_notify_persistent_group_removed(wpa_s, ssid);
|
|
|
|
|
|
|
|
if (wpa_config_remove_network(wpa_s->conf, id) < 0) {
|
|
|
|
wpa_printf(MSG_ERROR, "dbus: %s: "
|
|
|
|
"error occurred when removing persistent group %d",
|
|
|
|
__func__, id);
|
|
|
|
reply = wpas_dbus_error_unknown_error(
|
|
|
|
message,
|
|
|
|
"error removing the specified persistent group on "
|
|
|
|
"this interface.");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
os_free(iface);
|
|
|
|
os_free(persistent_group_id);
|
|
|
|
return reply;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void remove_persistent_group(struct wpa_supplicant *wpa_s,
|
|
|
|
struct wpa_ssid *ssid)
|
|
|
|
{
|
|
|
|
wpas_notify_persistent_group_removed(wpa_s, ssid);
|
|
|
|
|
|
|
|
if (wpa_config_remove_network(wpa_s->conf, ssid->id) < 0) {
|
|
|
|
wpa_printf(MSG_ERROR, "dbus: %s: "
|
|
|
|
"error occurred when removing persistent group %d",
|
|
|
|
__func__, ssid->id);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpas_dbus_handler_remove_all_persistent_groups - Remove all configured
|
|
|
|
* persistent groups
|
|
|
|
* @message: Pointer to incoming dbus message
|
|
|
|
* @wpa_s: wpa_supplicant structure for a network interface
|
|
|
|
* Returns: NULL on success or dbus error on failure
|
|
|
|
*
|
|
|
|
* Handler function for "RemoveAllPersistentGroups" method call of a
|
|
|
|
* P2P Device interface.
|
|
|
|
*/
|
|
|
|
DBusMessage * wpas_dbus_handler_remove_all_persistent_groups(
|
|
|
|
DBusMessage *message, struct wpa_supplicant *wpa_s)
|
|
|
|
{
|
|
|
|
struct wpa_ssid *ssid, *next;
|
|
|
|
struct wpa_config *config;
|
|
|
|
|
|
|
|
config = wpa_s->conf;
|
|
|
|
ssid = config->ssid;
|
|
|
|
while (ssid) {
|
|
|
|
next = ssid->next;
|
|
|
|
if (network_is_persistent_group(ssid))
|
|
|
|
remove_persistent_group(wpa_s, ssid);
|
|
|
|
ssid = next;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-12 18:08:19 -04:00
|
|
|
/*
|
|
|
|
* Group object properties accessor methods
|
|
|
|
*/
|
|
|
|
|
2011-07-29 14:25:39 -04:00
|
|
|
dbus_bool_t wpas_dbus_getter_p2p_group_members(DBusMessageIter *iter,
|
|
|
|
DBusError *error,
|
|
|
|
void *user_data)
|
2011-06-12 18:08:19 -04:00
|
|
|
{
|
2011-07-29 14:25:39 -04:00
|
|
|
struct wpa_supplicant *wpa_s = user_data;
|
2011-06-12 18:08:19 -04:00
|
|
|
struct wpa_ssid *ssid;
|
|
|
|
unsigned int num_members;
|
|
|
|
char **paths;
|
|
|
|
unsigned int i;
|
|
|
|
void *next = NULL;
|
|
|
|
const u8 *addr;
|
2011-07-29 14:25:39 -04:00
|
|
|
dbus_bool_t success = FALSE;
|
2011-06-12 18:08:19 -04:00
|
|
|
|
2012-03-05 10:25:08 -05:00
|
|
|
/* 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);
|
|
|
|
}
|
2011-06-12 18:08:19 -04:00
|
|
|
|
|
|
|
ssid = wpa_s->conf->ssid;
|
|
|
|
/* At present WPAS P2P_GO mode only applicable for p2p_go */
|
|
|
|
if (ssid->mode != WPAS_MODE_P2P_GO &&
|
|
|
|
ssid->mode != WPAS_MODE_AP &&
|
|
|
|
ssid->mode != WPAS_MODE_P2P_GROUP_FORMATION)
|
2011-07-29 14:25:39 -04:00
|
|
|
return FALSE;
|
2011-06-12 18:08:19 -04:00
|
|
|
|
|
|
|
num_members = p2p_get_group_num_members(wpa_s->p2p_group);
|
|
|
|
|
2012-08-13 13:44:21 -04:00
|
|
|
paths = os_calloc(num_members, sizeof(char *));
|
2011-06-12 18:08:19 -04:00
|
|
|
if (!paths)
|
|
|
|
goto out_of_memory;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while ((addr = p2p_iterate_group_members(wpa_s->p2p_group, &next))) {
|
|
|
|
paths[i] = os_zalloc(WPAS_DBUS_OBJECT_PATH_MAX);
|
|
|
|
if (!paths[i])
|
|
|
|
goto out_of_memory;
|
|
|
|
os_snprintf(paths[i], WPAS_DBUS_OBJECT_PATH_MAX,
|
|
|
|
"%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART
|
|
|
|
"/" COMPACT_MACSTR,
|
|
|
|
wpa_s->dbus_groupobj_path, MAC2STR(addr));
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2011-07-29 14:25:39 -04:00
|
|
|
success = wpas_dbus_simple_array_property_getter(iter,
|
|
|
|
DBUS_TYPE_OBJECT_PATH,
|
|
|
|
paths, num_members,
|
|
|
|
error);
|
2011-06-12 18:08:19 -04:00
|
|
|
|
|
|
|
for (i = 0; i < num_members; i++)
|
|
|
|
os_free(paths[i]);
|
|
|
|
os_free(paths);
|
2011-07-29 14:25:39 -04:00
|
|
|
return success;
|
2011-07-15 07:03:41 -04:00
|
|
|
|
2011-06-12 18:08:19 -04:00
|
|
|
out_of_memory:
|
2011-07-29 14:25:39 -04:00
|
|
|
dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
|
2011-07-15 07:03:41 -04:00
|
|
|
if (paths) {
|
|
|
|
for (i = 0; i < num_members; i++)
|
|
|
|
os_free(paths[i]);
|
|
|
|
os_free(paths);
|
|
|
|
}
|
2011-07-29 14:25:39 -04:00
|
|
|
return FALSE;
|
2011-06-12 18:08:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-05 10:25:08 -05:00
|
|
|
dbus_bool_t wpas_dbus_getter_p2p_group_ssid(DBusMessageIter *iter,
|
|
|
|
DBusError *error, void *user_data)
|
|
|
|
{
|
|
|
|
struct wpa_supplicant *wpa_s = user_data;
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dbus_bool_t wpas_dbus_getter_p2p_group_bssid(DBusMessageIter *iter,
|
|
|
|
DBusError *error,
|
|
|
|
void *user_data)
|
2011-06-12 18:08:19 -04:00
|
|
|
{
|
2011-07-29 14:25:39 -04:00
|
|
|
struct wpa_supplicant *wpa_s = user_data;
|
2012-02-04 06:08:12 -05:00
|
|
|
u8 role = wpas_get_p2p_role(wpa_s);
|
2012-03-05 10:25:08 -05:00
|
|
|
u8 *p_bssid;
|
2011-06-12 18:08:19 -04:00
|
|
|
|
2012-03-05 10:25:08 -05:00
|
|
|
if (role == WPAS_P2P_ROLE_CLIENT) {
|
|
|
|
if (wpa_s->current_ssid == NULL)
|
|
|
|
return FALSE;
|
|
|
|
p_bssid = wpa_s->current_ssid->bssid;
|
|
|
|
} else {
|
|
|
|
if (wpa_s->ap_iface == NULL)
|
|
|
|
return FALSE;
|
|
|
|
p_bssid = wpa_s->ap_iface->bss[0]->own_addr;
|
|
|
|
}
|
2012-02-04 06:08:12 -05:00
|
|
|
|
2012-03-05 10:25:08 -05:00
|
|
|
return wpas_dbus_simple_array_property_getter(iter, DBUS_TYPE_BYTE,
|
|
|
|
p_bssid, ETH_ALEN,
|
|
|
|
error);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
if (role == WPAS_P2P_ROLE_CLIENT) {
|
|
|
|
if (wpa_s->go_params == NULL)
|
2012-02-04 06:08:12 -05:00
|
|
|
return FALSE;
|
2012-03-05 10:25:08 -05:00
|
|
|
op_freq = wpa_s->go_params->freq;
|
|
|
|
} else {
|
|
|
|
if (wpa_s->ap_iface == NULL)
|
2012-02-04 06:08:12 -05:00
|
|
|
return FALSE;
|
2012-03-05 10:25:08 -05:00
|
|
|
op_freq = wpa_s->ap_iface->freq;
|
2011-06-12 18:08:19 -04:00
|
|
|
}
|
|
|
|
|
2012-03-05 10:25:08 -05:00
|
|
|
return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_UINT16,
|
|
|
|
&op_freq, error);
|
|
|
|
}
|
|
|
|
|
2011-06-12 18:08:19 -04:00
|
|
|
|
2012-03-05 10:25:08 -05:00
|
|
|
dbus_bool_t wpas_dbus_getter_p2p_group_passphrase(DBusMessageIter *iter,
|
|
|
|
DBusError *error,
|
|
|
|
void *user_data)
|
|
|
|
{
|
|
|
|
struct wpa_supplicant *wpa_s = user_data;
|
|
|
|
u8 role = wpas_get_p2p_role(wpa_s);
|
|
|
|
char *p_pass = NULL;
|
|
|
|
|
|
|
|
/* Verify correct role for this property */
|
2012-02-04 06:08:12 -05:00
|
|
|
if (role == WPAS_P2P_ROLE_GO) {
|
2012-03-05 10:25:08 -05:00
|
|
|
if (wpa_s->current_ssid == NULL)
|
|
|
|
return FALSE;
|
|
|
|
p_pass = wpa_s->current_ssid->passphrase;
|
|
|
|
} else
|
|
|
|
p_pass = "";
|
|
|
|
|
|
|
|
return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
|
|
|
|
&p_pass, error);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
return wpas_dbus_simple_array_property_getter(iter, DBUS_TYPE_BYTE,
|
|
|
|
&p_psk, psk_len, 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;
|
|
|
|
|
|
|
|
/* 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];
|
|
|
|
|
2012-02-04 06:08:12 -05:00
|
|
|
/* Parse WPS Vendor Extensions sent in Beacon/Probe Response */
|
2012-03-05 10:25:08 -05:00
|
|
|
for (i = 0; i < MAX_WPS_VENDOR_EXTENSIONS; i++) {
|
2012-02-04 06:08:12 -05:00
|
|
|
if (hapd->conf->wps_vendor_ext[i] == NULL)
|
2012-03-05 10:25:08 -05:00
|
|
|
vendor_ext[i] = NULL;
|
|
|
|
else {
|
|
|
|
vendor_ext[num_vendor_ext++] =
|
|
|
|
hapd->conf->wps_vendor_ext[i];
|
|
|
|
}
|
2012-02-04 06:08:12 -05:00
|
|
|
}
|
2011-06-12 18:08:19 -04:00
|
|
|
}
|
|
|
|
|
2012-03-05 10:25:08 -05:00
|
|
|
/* Return vendor extensions or no data */
|
|
|
|
return wpas_dbus_simple_array_array_property_getter(iter,
|
|
|
|
DBUS_TYPE_BYTE,
|
|
|
|
vendor_ext,
|
|
|
|
num_vendor_ext,
|
|
|
|
error);
|
2011-06-12 18:08:19 -04:00
|
|
|
}
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
|
2012-03-05 10:25:08 -05:00
|
|
|
dbus_bool_t wpas_dbus_setter_p2p_group_vendor_ext(DBusMessageIter *iter,
|
2011-07-29 14:25:39 -04:00
|
|
|
DBusError *error,
|
|
|
|
void *user_data)
|
2011-06-12 18:08:19 -04:00
|
|
|
{
|
2011-07-29 14:25:39 -04:00
|
|
|
struct wpa_supplicant *wpa_s = user_data;
|
|
|
|
DBusMessageIter variant_iter, iter_dict;
|
2011-07-15 07:18:29 -04:00
|
|
|
struct wpa_dbus_dict_entry entry = { .type = DBUS_TYPE_STRING };
|
2011-06-12 18:08:19 -04:00
|
|
|
unsigned int i;
|
2012-02-04 06:13:59 -05:00
|
|
|
struct hostapd_data *hapd = NULL;
|
2011-06-12 18:08:19 -04:00
|
|
|
|
2012-02-04 06:13:59 -05:00
|
|
|
if (wpas_get_p2p_role(wpa_s) == WPAS_P2P_ROLE_GO &&
|
|
|
|
wpa_s->ap_iface != NULL)
|
|
|
|
hapd = wpa_s->ap_iface->bss[0];
|
|
|
|
else
|
2011-07-29 14:25:39 -04:00
|
|
|
return FALSE;
|
2011-06-12 18:08:19 -04:00
|
|
|
|
2011-07-29 14:25:39 -04:00
|
|
|
dbus_message_iter_recurse(iter, &variant_iter);
|
|
|
|
if (!wpa_dbus_dict_open_read(&variant_iter, &iter_dict, error))
|
|
|
|
return FALSE;
|
2011-06-12 18:08:19 -04:00
|
|
|
|
|
|
|
while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
|
|
|
|
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry)) {
|
2011-07-29 14:25:39 -04:00
|
|
|
dbus_set_error_const(error, DBUS_ERROR_INVALID_ARGS,
|
|
|
|
"invalid message format");
|
|
|
|
return FALSE;
|
2011-06-12 18:08:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
wpa_dbus_dict_entry_clear(&entry);
|
|
|
|
}
|
|
|
|
|
2011-07-29 14:25:39 -04:00
|
|
|
return TRUE;
|
2011-06-12 18:08:19 -04:00
|
|
|
|
|
|
|
error:
|
|
|
|
wpa_dbus_dict_entry_clear(&entry);
|
2011-07-29 14:25:39 -04:00
|
|
|
dbus_set_error_const(error, DBUS_ERROR_INVALID_ARGS,
|
|
|
|
"invalid message format");
|
|
|
|
return FALSE;
|
2011-06-12 18:08:19 -04:00
|
|
|
}
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
|
|
|
|
DBusMessage * wpas_dbus_handler_p2p_add_service(DBusMessage *message,
|
|
|
|
struct wpa_supplicant *wpa_s)
|
2011-06-12 18:08:19 -04:00
|
|
|
{
|
|
|
|
DBusMessageIter iter_dict;
|
|
|
|
DBusMessage *reply = NULL;
|
|
|
|
DBusMessageIter iter;
|
|
|
|
struct wpa_dbus_dict_entry entry;
|
|
|
|
int upnp = 0;
|
|
|
|
int bonjour = 0;
|
|
|
|
char *service = NULL;
|
|
|
|
struct wpabuf *query = NULL;
|
|
|
|
struct wpabuf *resp = NULL;
|
|
|
|
u8 version = 0;
|
|
|
|
|
|
|
|
dbus_message_iter_init(message, &iter);
|
|
|
|
|
2011-07-29 14:25:39 -04:00
|
|
|
if (!wpa_dbus_dict_open_read(&iter, &iter_dict, NULL))
|
2011-06-12 18:08:19 -04:00
|
|
|
goto error;
|
|
|
|
|
2012-04-21 11:28:10 -04:00
|
|
|
while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
|
2011-06-12 18:08:19 -04:00
|
|
|
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
|
|
|
|
goto error;
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
if (!os_strcmp(entry.key, "service_type") &&
|
2011-06-12 18:08:19 -04:00
|
|
|
(entry.type == DBUS_TYPE_STRING)) {
|
2011-07-15 07:18:29 -04:00
|
|
|
if (!os_strcmp(entry.str_value, "upnp"))
|
2011-06-12 18:08:19 -04:00
|
|
|
upnp = 1;
|
2011-07-15 07:18:29 -04:00
|
|
|
else if (!os_strcmp(entry.str_value, "bonjour"))
|
2011-06-12 18:08:19 -04:00
|
|
|
bonjour = 1;
|
|
|
|
else
|
|
|
|
goto error_clear;
|
2012-04-21 11:28:10 -04:00
|
|
|
} else if (!os_strcmp(entry.key, "version") &&
|
|
|
|
entry.type == DBUS_TYPE_INT32) {
|
|
|
|
version = entry.uint32_value;
|
|
|
|
} else if (!os_strcmp(entry.key, "service") &&
|
|
|
|
(entry.type == DBUS_TYPE_STRING)) {
|
|
|
|
service = os_strdup(entry.str_value);
|
|
|
|
} else if (!os_strcmp(entry.key, "query")) {
|
|
|
|
if ((entry.type != DBUS_TYPE_ARRAY) ||
|
|
|
|
(entry.array_type != DBUS_TYPE_BYTE))
|
|
|
|
goto error_clear;
|
|
|
|
query = wpabuf_alloc_copy(
|
|
|
|
entry.bytearray_value,
|
|
|
|
entry.array_len);
|
|
|
|
} else if (!os_strcmp(entry.key, "response")) {
|
|
|
|
if ((entry.type != DBUS_TYPE_ARRAY) ||
|
|
|
|
(entry.array_type != DBUS_TYPE_BYTE))
|
|
|
|
goto error_clear;
|
|
|
|
resp = wpabuf_alloc_copy(entry.bytearray_value,
|
|
|
|
entry.array_len);
|
2011-06-12 18:08:19 -04:00
|
|
|
}
|
2012-04-21 11:28:10 -04:00
|
|
|
wpa_dbus_dict_entry_clear(&entry);
|
2011-06-12 18:08:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (upnp == 1) {
|
|
|
|
if (version <= 0 || service == NULL)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (wpas_p2p_service_add_upnp(wpa_s, version, service) != 0)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
os_free(service);
|
2012-04-21 11:28:10 -04:00
|
|
|
service = NULL;
|
2011-06-12 18:08:19 -04:00
|
|
|
} else if (bonjour == 1) {
|
|
|
|
if (query == NULL || resp == NULL)
|
|
|
|
goto error;
|
|
|
|
|
2012-04-21 11:28:10 -04:00
|
|
|
if (wpas_p2p_service_add_bonjour(wpa_s, query, resp) < 0)
|
2011-06-12 18:08:19 -04:00
|
|
|
goto error;
|
2012-04-21 11:28:10 -04:00
|
|
|
query = NULL;
|
|
|
|
resp = NULL;
|
2011-06-12 18:08:19 -04:00
|
|
|
} else
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
return reply;
|
|
|
|
error_clear:
|
|
|
|
wpa_dbus_dict_entry_clear(&entry);
|
|
|
|
error:
|
2012-04-21 11:28:10 -04:00
|
|
|
os_free(service);
|
|
|
|
wpabuf_free(query);
|
|
|
|
wpabuf_free(resp);
|
2011-06-12 18:08:19 -04:00
|
|
|
return wpas_dbus_error_invalid_args(message, NULL);
|
|
|
|
}
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
|
|
|
|
DBusMessage * wpas_dbus_handler_p2p_delete_service(
|
|
|
|
DBusMessage *message, struct wpa_supplicant *wpa_s)
|
2011-06-12 18:08:19 -04:00
|
|
|
{
|
|
|
|
DBusMessageIter iter_dict;
|
|
|
|
DBusMessage *reply = NULL;
|
|
|
|
DBusMessageIter iter;
|
|
|
|
struct wpa_dbus_dict_entry entry;
|
|
|
|
int upnp = 0;
|
|
|
|
int bonjour = 0;
|
|
|
|
int ret = 0;
|
|
|
|
char *service = NULL;
|
|
|
|
struct wpabuf *query = NULL;
|
|
|
|
u8 version = 0;
|
|
|
|
|
|
|
|
dbus_message_iter_init(message, &iter);
|
|
|
|
|
2011-07-29 14:25:39 -04:00
|
|
|
if (!wpa_dbus_dict_open_read(&iter, &iter_dict, NULL))
|
2011-06-12 18:08:19 -04:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
|
|
|
|
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
|
|
|
|
goto error;
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
if (!os_strcmp(entry.key, "service_type") &&
|
2011-06-12 18:08:19 -04:00
|
|
|
(entry.type == DBUS_TYPE_STRING)) {
|
2011-07-15 07:18:29 -04:00
|
|
|
if (!os_strcmp(entry.str_value, "upnp"))
|
2011-06-12 18:08:19 -04:00
|
|
|
upnp = 1;
|
2011-07-15 07:18:29 -04:00
|
|
|
else if (!os_strcmp(entry.str_value, "bonjour"))
|
2011-06-12 18:08:19 -04:00
|
|
|
bonjour = 1;
|
|
|
|
else
|
|
|
|
goto error_clear;
|
|
|
|
wpa_dbus_dict_entry_clear(&entry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (upnp == 1) {
|
|
|
|
while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
|
|
|
|
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
|
|
|
|
goto error;
|
2011-07-15 07:18:29 -04:00
|
|
|
if (!os_strcmp(entry.key, "version") &&
|
2011-06-12 18:08:19 -04:00
|
|
|
entry.type == DBUS_TYPE_INT32)
|
|
|
|
version = entry.uint32_value;
|
2011-07-15 07:18:29 -04:00
|
|
|
else if (!os_strcmp(entry.key, "service") &&
|
2011-06-12 18:08:19 -04:00
|
|
|
entry.type == DBUS_TYPE_STRING)
|
|
|
|
service = os_strdup(entry.str_value);
|
|
|
|
else
|
|
|
|
goto error_clear;
|
|
|
|
|
|
|
|
wpa_dbus_dict_entry_clear(&entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (version <= 0 || service == NULL)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
ret = wpas_p2p_service_del_upnp(wpa_s, version, service);
|
|
|
|
os_free(service);
|
|
|
|
if (ret != 0)
|
|
|
|
goto error;
|
|
|
|
} else if (bonjour == 1) {
|
|
|
|
while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
|
|
|
|
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
|
|
|
|
goto error;
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
if (!os_strcmp(entry.key, "query")) {
|
2011-06-12 18:08:19 -04:00
|
|
|
if ((entry.type != DBUS_TYPE_ARRAY) ||
|
|
|
|
(entry.array_type != DBUS_TYPE_BYTE))
|
|
|
|
goto error_clear;
|
2011-07-15 07:18:29 -04:00
|
|
|
query = wpabuf_alloc_copy(
|
|
|
|
entry.bytearray_value,
|
|
|
|
entry.array_len);
|
2011-06-12 18:08:19 -04:00
|
|
|
} else
|
|
|
|
goto error_clear;
|
|
|
|
|
|
|
|
wpa_dbus_dict_entry_clear(&entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (query == NULL)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
ret = wpas_p2p_service_del_bonjour(wpa_s, query);
|
|
|
|
if (ret != 0)
|
|
|
|
goto error;
|
|
|
|
wpabuf_free(query);
|
|
|
|
} else
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
return reply;
|
|
|
|
error_clear:
|
|
|
|
wpa_dbus_dict_entry_clear(&entry);
|
|
|
|
error:
|
|
|
|
return wpas_dbus_error_invalid_args(message, NULL);
|
|
|
|
}
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
|
|
|
|
DBusMessage * wpas_dbus_handler_p2p_flush_service(DBusMessage *message,
|
|
|
|
struct wpa_supplicant *wpa_s)
|
2011-06-12 18:08:19 -04:00
|
|
|
{
|
|
|
|
wpas_p2p_service_flush(wpa_s);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
|
|
|
|
DBusMessage * wpas_dbus_handler_p2p_service_sd_req(
|
|
|
|
DBusMessage *message, struct wpa_supplicant *wpa_s)
|
2011-06-12 18:08:19 -04:00
|
|
|
{
|
|
|
|
DBusMessageIter iter_dict;
|
|
|
|
DBusMessage *reply = NULL;
|
|
|
|
DBusMessageIter iter;
|
|
|
|
struct wpa_dbus_dict_entry entry;
|
|
|
|
int upnp = 0;
|
|
|
|
char *service = NULL;
|
|
|
|
char *peer_object_path = NULL;
|
|
|
|
struct wpabuf *tlv = NULL;
|
|
|
|
u8 version = 0;
|
|
|
|
u64 ref = 0;
|
2012-04-14 14:06:16 -04:00
|
|
|
u8 addr_buf[ETH_ALEN], *addr;
|
2011-06-12 18:08:19 -04:00
|
|
|
|
|
|
|
dbus_message_iter_init(message, &iter);
|
|
|
|
|
2011-07-29 14:25:39 -04:00
|
|
|
if (!wpa_dbus_dict_open_read(&iter, &iter_dict, NULL))
|
2011-06-12 18:08:19 -04:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
|
|
|
|
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
|
|
|
|
goto error;
|
2011-07-15 07:18:29 -04:00
|
|
|
if (!os_strcmp(entry.key, "peer_object") &&
|
2011-06-12 18:08:19 -04:00
|
|
|
entry.type == DBUS_TYPE_OBJECT_PATH) {
|
|
|
|
peer_object_path = os_strdup(entry.str_value);
|
2011-07-15 07:18:29 -04:00
|
|
|
} else if (!os_strcmp(entry.key, "service_type") &&
|
2011-06-12 18:08:19 -04:00
|
|
|
entry.type == DBUS_TYPE_STRING) {
|
2011-07-15 07:18:29 -04:00
|
|
|
if (!os_strcmp(entry.str_value, "upnp"))
|
2011-06-12 18:08:19 -04:00
|
|
|
upnp = 1;
|
|
|
|
else
|
|
|
|
goto error_clear;
|
2011-07-15 07:18:29 -04:00
|
|
|
} else if (!os_strcmp(entry.key, "version") &&
|
2011-06-12 18:08:19 -04:00
|
|
|
entry.type == DBUS_TYPE_INT32) {
|
|
|
|
version = entry.uint32_value;
|
2011-07-15 07:18:29 -04:00
|
|
|
} else if (!os_strcmp(entry.key, "service") &&
|
2011-06-12 18:08:19 -04:00
|
|
|
entry.type == DBUS_TYPE_STRING) {
|
|
|
|
service = os_strdup(entry.str_value);
|
2011-07-15 07:18:29 -04:00
|
|
|
} else if (!os_strcmp(entry.key, "tlv")) {
|
2011-06-12 18:08:19 -04:00
|
|
|
if (entry.type != DBUS_TYPE_ARRAY ||
|
|
|
|
entry.array_type != DBUS_TYPE_BYTE)
|
|
|
|
goto error_clear;
|
|
|
|
tlv = wpabuf_alloc_copy(entry.bytearray_value,
|
|
|
|
entry.array_len);
|
|
|
|
} else
|
|
|
|
goto error_clear;
|
|
|
|
|
|
|
|
wpa_dbus_dict_entry_clear(&entry);
|
|
|
|
}
|
|
|
|
|
2012-04-14 14:06:16 -04:00
|
|
|
if (!peer_object_path) {
|
|
|
|
addr = NULL;
|
|
|
|
} else {
|
|
|
|
if (parse_peer_object_path(peer_object_path, addr_buf) < 0 ||
|
|
|
|
!p2p_peer_known(wpa_s->global->p2p, addr_buf))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
addr = addr_buf;
|
|
|
|
}
|
2011-06-12 18:08:19 -04:00
|
|
|
|
|
|
|
if (upnp == 1) {
|
|
|
|
if (version <= 0 || service == NULL)
|
|
|
|
goto error;
|
|
|
|
|
2011-12-11 11:06:34 -05:00
|
|
|
ref = wpas_p2p_sd_request_upnp(wpa_s, addr, version, service);
|
2011-06-12 18:08:19 -04:00
|
|
|
} else {
|
|
|
|
if (tlv == NULL)
|
|
|
|
goto error;
|
2011-12-11 11:06:34 -05:00
|
|
|
ref = wpas_p2p_sd_request(wpa_s, addr, tlv);
|
2011-06-12 18:08:19 -04:00
|
|
|
wpabuf_free(tlv);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ref != 0) {
|
|
|
|
reply = dbus_message_new_method_return(message);
|
|
|
|
dbus_message_append_args(reply, DBUS_TYPE_UINT64,
|
|
|
|
&ref, DBUS_TYPE_INVALID);
|
|
|
|
} else {
|
2011-07-15 07:18:29 -04:00
|
|
|
reply = wpas_dbus_error_unknown_error(
|
|
|
|
message, "Unable to send SD request");
|
2011-06-12 18:08:19 -04:00
|
|
|
}
|
|
|
|
out:
|
|
|
|
os_free(service);
|
|
|
|
os_free(peer_object_path);
|
|
|
|
return reply;
|
|
|
|
error_clear:
|
|
|
|
wpa_dbus_dict_entry_clear(&entry);
|
|
|
|
error:
|
|
|
|
if (tlv)
|
|
|
|
wpabuf_free(tlv);
|
|
|
|
reply = wpas_dbus_error_invalid_args(message, NULL);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
|
|
|
|
DBusMessage * wpas_dbus_handler_p2p_service_sd_res(
|
2011-06-12 18:08:19 -04:00
|
|
|
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;
|
|
|
|
struct wpabuf *tlv = NULL;
|
|
|
|
int freq = 0;
|
|
|
|
int dlg_tok = 0;
|
|
|
|
u8 addr[ETH_ALEN];
|
|
|
|
|
|
|
|
dbus_message_iter_init(message, &iter);
|
|
|
|
|
2011-07-29 14:25:39 -04:00
|
|
|
if (!wpa_dbus_dict_open_read(&iter, &iter_dict, NULL))
|
2011-06-12 18:08:19 -04:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
|
|
|
|
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
|
|
|
|
goto error;
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
if (!os_strcmp(entry.key, "peer_object") &&
|
2011-06-12 18:08:19 -04:00
|
|
|
entry.type == DBUS_TYPE_OBJECT_PATH) {
|
|
|
|
peer_object_path = os_strdup(entry.str_value);
|
2011-07-15 07:18:29 -04:00
|
|
|
} else if (!os_strcmp(entry.key, "frequency") &&
|
2011-06-12 18:08:19 -04:00
|
|
|
entry.type == DBUS_TYPE_INT32) {
|
|
|
|
freq = entry.uint32_value;
|
2011-07-15 07:18:29 -04:00
|
|
|
} else if (!os_strcmp(entry.key, "dialog_token") &&
|
2011-06-12 18:08:19 -04:00
|
|
|
entry.type == DBUS_TYPE_UINT32) {
|
|
|
|
dlg_tok = entry.uint32_value;
|
2011-07-15 07:18:29 -04:00
|
|
|
} else if (!os_strcmp(entry.key, "tlvs")) {
|
2011-06-12 18:08:19 -04:00
|
|
|
if (entry.type != DBUS_TYPE_ARRAY ||
|
|
|
|
entry.array_type != DBUS_TYPE_BYTE)
|
|
|
|
goto error_clear;
|
|
|
|
tlv = wpabuf_alloc_copy(entry.bytearray_value,
|
|
|
|
entry.array_len);
|
|
|
|
} else
|
|
|
|
goto error_clear;
|
|
|
|
|
|
|
|
wpa_dbus_dict_entry_clear(&entry);
|
|
|
|
}
|
|
|
|
if (!peer_object_path ||
|
|
|
|
(parse_peer_object_path(peer_object_path, addr) < 0) ||
|
2011-12-22 14:04:41 -05:00
|
|
|
!p2p_peer_known(wpa_s->global->p2p, addr))
|
2011-06-12 18:08:19 -04:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (tlv == NULL)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
wpas_p2p_sd_response(wpa_s, freq, addr, (u8) dlg_tok, tlv);
|
|
|
|
wpabuf_free(tlv);
|
|
|
|
out:
|
|
|
|
os_free(peer_object_path);
|
|
|
|
return reply;
|
|
|
|
error_clear:
|
|
|
|
wpa_dbus_dict_entry_clear(&entry);
|
|
|
|
error:
|
|
|
|
reply = wpas_dbus_error_invalid_args(message, NULL);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
|
|
|
|
DBusMessage * wpas_dbus_handler_p2p_service_sd_cancel_req(
|
|
|
|
DBusMessage *message, struct wpa_supplicant *wpa_s)
|
2011-06-12 18:08:19 -04:00
|
|
|
{
|
|
|
|
DBusMessageIter iter;
|
|
|
|
u64 req = 0;
|
|
|
|
|
|
|
|
dbus_message_iter_init(message, &iter);
|
|
|
|
dbus_message_iter_get_basic(&iter, &req);
|
|
|
|
|
|
|
|
if (req == 0)
|
|
|
|
goto error;
|
|
|
|
|
2011-12-11 11:06:34 -05:00
|
|
|
if (!wpas_p2p_sd_cancel_request(wpa_s, req))
|
2011-06-12 18:08:19 -04:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
error:
|
|
|
|
return wpas_dbus_error_invalid_args(message, NULL);
|
|
|
|
}
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
|
|
|
|
DBusMessage * wpas_dbus_handler_p2p_service_update(
|
|
|
|
DBusMessage *message, struct wpa_supplicant *wpa_s)
|
2011-06-12 18:08:19 -04:00
|
|
|
{
|
|
|
|
wpas_p2p_sd_service_update(wpa_s);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-07-15 07:18:29 -04:00
|
|
|
|
|
|
|
DBusMessage * wpas_dbus_handler_p2p_serv_disc_external(
|
|
|
|
DBusMessage *message, struct wpa_supplicant *wpa_s)
|
2011-06-12 18:08:19 -04:00
|
|
|
{
|
|
|
|
DBusMessageIter iter;
|
|
|
|
int ext = 0;
|
|
|
|
|
|
|
|
dbus_message_iter_init(message, &iter);
|
|
|
|
dbus_message_iter_get_basic(&iter, &ext);
|
|
|
|
|
|
|
|
wpa_s->p2p_sd_over_ctrl_iface = ext;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
}
|