dbus: Redirect P2P request to the managment device if present
In case of a P2P management device being present, it will be up to that interface to handle P2P requests. Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
parent
bb3df9a569
commit
745d62322b
2 changed files with 122 additions and 11 deletions
|
@ -950,15 +950,20 @@ void wpas_dbus_signal_p2p_group_removed(struct wpa_supplicant *wpa_s,
|
|||
DBusMessage *msg;
|
||||
DBusMessageIter iter, dict_iter;
|
||||
struct wpas_dbus_priv *iface = wpa_s->global->dbus;
|
||||
struct wpa_supplicant *parent;
|
||||
|
||||
/* Do nothing if the control interface is not turned on */
|
||||
if (iface == NULL)
|
||||
return;
|
||||
|
||||
parent = wpa_s->parent;
|
||||
if (parent->p2p_mgmt)
|
||||
parent = parent->parent;
|
||||
|
||||
if (!wpa_s->dbus_groupobj_path)
|
||||
return;
|
||||
|
||||
msg = dbus_message_new_signal(wpa_s->parent->dbus_new_path,
|
||||
msg = dbus_message_new_signal(parent->dbus_new_path,
|
||||
WPAS_DBUS_NEW_IFACE_P2PDEVICE,
|
||||
"GroupFinished");
|
||||
if (msg == NULL)
|
||||
|
@ -1034,6 +1039,9 @@ void wpas_dbus_signal_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
|
|||
if (iface == NULL)
|
||||
return;
|
||||
|
||||
if (wpa_s->p2p_mgmt)
|
||||
wpa_s = wpa_s->parent;
|
||||
|
||||
if (request || !status) {
|
||||
if (config_methods & WPS_CONFIG_DISPLAY)
|
||||
_signal = request ?
|
||||
|
@ -1119,6 +1127,9 @@ void wpas_dbus_signal_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
|
|||
if (iface == NULL)
|
||||
return;
|
||||
|
||||
if (wpa_s->p2p_mgmt)
|
||||
wpa_s = wpa_s->parent;
|
||||
|
||||
os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
|
||||
"%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
|
||||
wpa_s->dbus_new_path, MAC2STR(src));
|
||||
|
@ -1245,8 +1256,13 @@ void wpas_dbus_signal_p2p_group_started(struct wpa_supplicant *wpa_s,
|
|||
DBusMessage *msg;
|
||||
DBusMessageIter iter, dict_iter;
|
||||
struct wpas_dbus_priv *iface;
|
||||
struct wpa_supplicant *parent;
|
||||
|
||||
iface = wpa_s->parent->global->dbus;
|
||||
parent = wpa_s->parent;
|
||||
if (parent->p2p_mgmt)
|
||||
parent = parent->parent;
|
||||
|
||||
iface = parent->global->dbus;
|
||||
|
||||
/* Do nothing if the control interface is not turned on */
|
||||
if (iface == NULL)
|
||||
|
@ -1256,7 +1272,7 @@ void wpas_dbus_signal_p2p_group_started(struct wpa_supplicant *wpa_s,
|
|||
return;
|
||||
|
||||
/* New interface has been created for this group */
|
||||
msg = dbus_message_new_signal(wpa_s->parent->dbus_new_path,
|
||||
msg = dbus_message_new_signal(parent->dbus_new_path,
|
||||
WPAS_DBUS_NEW_IFACE_P2PDEVICE,
|
||||
"GroupStarted");
|
||||
if (msg == NULL)
|
||||
|
@ -1315,6 +1331,9 @@ void wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant *wpa_s,
|
|||
|
||||
iface = wpa_s->global->dbus;
|
||||
|
||||
if (wpa_s->p2p_mgmt)
|
||||
wpa_s = wpa_s->parent;
|
||||
|
||||
os_memset(freqs, 0, sizeof(freqs));
|
||||
/* Do nothing if the control interface is not turned on */
|
||||
if (iface == NULL)
|
||||
|
@ -1441,6 +1460,9 @@ void wpas_dbus_signal_p2p_invitation_result(struct wpa_supplicant *wpa_s,
|
|||
if (iface == NULL)
|
||||
return;
|
||||
|
||||
if (wpa_s->p2p_mgmt)
|
||||
wpa_s = wpa_s->parent;
|
||||
|
||||
msg = dbus_message_new_signal(wpa_s->dbus_new_path,
|
||||
WPAS_DBUS_NEW_IFACE_P2PDEVICE,
|
||||
"InvitationResult");
|
||||
|
@ -1486,6 +1508,7 @@ void wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s,
|
|||
DBusMessage *msg;
|
||||
DBusMessageIter iter;
|
||||
char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
|
||||
struct wpa_supplicant *parent;
|
||||
|
||||
iface = wpa_s->global->dbus;
|
||||
|
||||
|
@ -1496,10 +1519,14 @@ void wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s,
|
|||
if (!wpa_s->dbus_groupobj_path)
|
||||
return;
|
||||
|
||||
parent = wpa_s->parent;
|
||||
if (parent->p2p_mgmt)
|
||||
parent = parent->parent;
|
||||
|
||||
os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
|
||||
"%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
|
||||
COMPACT_MACSTR,
|
||||
wpa_s->parent->dbus_new_path, MAC2STR(peer_addr));
|
||||
parent->dbus_new_path, MAC2STR(peer_addr));
|
||||
|
||||
msg = dbus_message_new_signal(wpa_s->dbus_groupobj_path,
|
||||
WPAS_DBUS_NEW_IFACE_P2P_GROUP,
|
||||
|
@ -1516,7 +1543,7 @@ void wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s,
|
|||
dbus_connection_send(iface->con, msg, NULL);
|
||||
dbus_message_unref(msg);
|
||||
|
||||
wpas_dbus_signal_peer_groups_changed(wpa_s->parent, peer_addr);
|
||||
wpas_dbus_signal_peer_groups_changed(parent, peer_addr);
|
||||
|
||||
return;
|
||||
|
||||
|
@ -1542,6 +1569,7 @@ void wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant *wpa_s,
|
|||
DBusMessage *msg;
|
||||
DBusMessageIter iter;
|
||||
char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
|
||||
struct wpa_supplicant *parent;
|
||||
|
||||
iface = wpa_s->global->dbus;
|
||||
|
||||
|
@ -1552,10 +1580,14 @@ void wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant *wpa_s,
|
|||
if (!wpa_s->dbus_groupobj_path)
|
||||
return;
|
||||
|
||||
parent = wpa_s->parent;
|
||||
if (parent->p2p_mgmt)
|
||||
parent = parent->parent;
|
||||
|
||||
os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
|
||||
"%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
|
||||
COMPACT_MACSTR,
|
||||
wpa_s->dbus_groupobj_path, MAC2STR(peer_addr));
|
||||
parent->dbus_new_path, MAC2STR(peer_addr));
|
||||
|
||||
msg = dbus_message_new_signal(wpa_s->dbus_groupobj_path,
|
||||
WPAS_DBUS_NEW_IFACE_P2P_GROUP,
|
||||
|
@ -1572,7 +1604,7 @@ void wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant *wpa_s,
|
|||
dbus_connection_send(iface->con, msg, NULL);
|
||||
dbus_message_unref(msg);
|
||||
|
||||
wpas_dbus_signal_peer_groups_changed(wpa_s->parent, peer_addr);
|
||||
wpas_dbus_signal_peer_groups_changed(parent, peer_addr);
|
||||
|
||||
return;
|
||||
|
||||
|
@ -1611,6 +1643,9 @@ void wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant *wpa_s,
|
|||
if (iface == NULL)
|
||||
return;
|
||||
|
||||
if (wpa_s->p2p_mgmt)
|
||||
wpa_s = wpa_s->parent;
|
||||
|
||||
msg = dbus_message_new_signal(wpa_s->dbus_new_path,
|
||||
WPAS_DBUS_NEW_IFACE_P2PDEVICE,
|
||||
"ServiceDiscoveryRequest");
|
||||
|
@ -1680,9 +1715,12 @@ void wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant *wpa_s,
|
|||
if (iface == NULL)
|
||||
return;
|
||||
|
||||
if (wpa_s->p2p_mgmt)
|
||||
wpa_s = wpa_s->parent;
|
||||
|
||||
msg = dbus_message_new_signal(wpa_s->dbus_new_path,
|
||||
WPAS_DBUS_NEW_IFACE_P2PDEVICE,
|
||||
"ServiceDiscoveryResponse");
|
||||
"ServiceDiscoveryResponse");
|
||||
if (msg == NULL)
|
||||
return;
|
||||
|
||||
|
@ -1744,6 +1782,9 @@ static void wpas_dbus_signal_persistent_group(struct wpa_supplicant *wpa_s,
|
|||
if (iface == NULL)
|
||||
return;
|
||||
|
||||
if (wpa_s->p2p_mgmt)
|
||||
wpa_s = wpa_s->parent;
|
||||
|
||||
os_snprintf(pgrp_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
|
||||
"%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART "/%u",
|
||||
wpa_s->dbus_new_path, id);
|
||||
|
@ -1832,6 +1873,9 @@ void wpas_dbus_signal_p2p_wps_failed(struct wpa_supplicant *wpa_s,
|
|||
if (iface == NULL)
|
||||
return;
|
||||
|
||||
if (wpa_s->p2p_mgmt)
|
||||
wpa_s = wpa_s->parent;
|
||||
|
||||
msg = dbus_message_new_signal(wpa_s->dbus_new_path,
|
||||
WPAS_DBUS_NEW_IFACE_P2PDEVICE,
|
||||
"WpsFailed");
|
||||
|
@ -3415,6 +3459,9 @@ static void wpas_dbus_signal_peer(struct wpa_supplicant *wpa_s,
|
|||
DBusMessageIter iter;
|
||||
char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
|
||||
|
||||
if (wpa_s->p2p_mgmt)
|
||||
wpa_s = wpa_s->parent;
|
||||
|
||||
iface = wpa_s->global->dbus;
|
||||
|
||||
/* Do nothing if the control interface is not turned on */
|
||||
|
@ -3500,6 +3547,9 @@ int wpas_dbus_register_peer(struct wpa_supplicant *wpa_s, const u8 *dev_addr)
|
|||
if (ctrl_iface == NULL)
|
||||
return 0;
|
||||
|
||||
if (wpa_s->p2p_mgmt)
|
||||
wpa_s = wpa_s->parent;
|
||||
|
||||
os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
|
||||
"%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
|
||||
wpa_s->dbus_new_path, MAC2STR(dev_addr));
|
||||
|
@ -3559,6 +3609,10 @@ int wpas_dbus_unregister_peer(struct wpa_supplicant *wpa_s,
|
|||
if (wpa_s == NULL || wpa_s->global == NULL ||
|
||||
wpa_s->dbus_new_path == NULL)
|
||||
return 0;
|
||||
|
||||
if (wpa_s->p2p_mgmt)
|
||||
wpa_s = wpa_s->parent;
|
||||
|
||||
ctrl_iface = wpa_s->global->dbus;
|
||||
if (ctrl_iface == NULL)
|
||||
return 0;
|
||||
|
@ -3580,6 +3634,9 @@ void wpas_dbus_signal_peer_groups_changed(struct wpa_supplicant *wpa_s,
|
|||
{
|
||||
char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
|
||||
|
||||
if (wpa_s->p2p_mgmt)
|
||||
wpa_s = wpa_s->parent;
|
||||
|
||||
os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
|
||||
"%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
|
||||
wpa_s->dbus_new_path, MAC2STR(dev_addr));
|
||||
|
@ -3723,6 +3780,9 @@ void wpas_dbus_unregister_p2p_group(struct wpa_supplicant *wpa_s,
|
|||
if (wpa_s == NULL || wpa_s->global == NULL)
|
||||
return;
|
||||
|
||||
if (wpa_s->p2p_mgmt)
|
||||
wpa_s = wpa_s->parent;
|
||||
|
||||
ctrl_iface = wpa_s->global->dbus;
|
||||
if (ctrl_iface == NULL)
|
||||
return;
|
||||
|
@ -3783,6 +3843,9 @@ int wpas_dbus_register_persistent_group(struct wpa_supplicant *wpa_s,
|
|||
if (ssid->disabled != 2 && !ssid->p2p_persistent_group)
|
||||
return -1; /* should we return w/o complaining? */
|
||||
|
||||
if (wpa_s->p2p_mgmt)
|
||||
wpa_s = wpa_s->parent;
|
||||
|
||||
ctrl_iface = wpa_s->global->dbus;
|
||||
if (ctrl_iface == NULL)
|
||||
return 0;
|
||||
|
@ -3862,6 +3925,10 @@ int wpas_dbus_unregister_persistent_group(struct wpa_supplicant *wpa_s,
|
|||
if (wpa_s == NULL || wpa_s->global == NULL ||
|
||||
wpa_s->dbus_new_path == NULL)
|
||||
return 0;
|
||||
|
||||
if (wpa_s->p2p_mgmt)
|
||||
wpa_s = wpa_s->parent;
|
||||
|
||||
ctrl_iface = wpa_s->global->dbus;
|
||||
if (ctrl_iface == NULL)
|
||||
return 0;
|
||||
|
|
|
@ -127,6 +127,9 @@ DBusMessage * wpas_dbus_handler_p2p_find(DBusMessage *message,
|
|||
wpa_dbus_dict_entry_clear(&entry);
|
||||
}
|
||||
|
||||
if (wpa_s->p2p_dev)
|
||||
wpa_s = wpa_s->p2p_dev;
|
||||
|
||||
wpas_p2p_find(wpa_s, timeout, type, num_req_dev_types, req_dev_types,
|
||||
NULL, 0);
|
||||
os_free(req_dev_types);
|
||||
|
@ -144,6 +147,9 @@ error:
|
|||
DBusMessage * wpas_dbus_handler_p2p_stop_find(DBusMessage *message,
|
||||
struct wpa_supplicant *wpa_s)
|
||||
{
|
||||
if (wpa_s->p2p_dev)
|
||||
wpa_s = wpa_s->p2p_dev;
|
||||
|
||||
wpas_p2p_stop_find(wpa_s);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -162,6 +168,9 @@ DBusMessage * wpas_dbus_handler_p2p_rejectpeer(DBusMessage *message,
|
|||
if (parse_peer_object_path(peer_object_path, peer_addr) < 0)
|
||||
return wpas_dbus_error_invalid_args(message, NULL);
|
||||
|
||||
if (wpa_s->p2p_dev)
|
||||
wpa_s = wpa_s->p2p_dev;
|
||||
|
||||
if (wpas_p2p_reject(wpa_s, peer_addr) < 0)
|
||||
return wpas_dbus_error_unknown_error(message,
|
||||
"Failed to call wpas_p2p_reject method.");
|
||||
|
@ -180,6 +189,9 @@ DBusMessage * wpas_dbus_handler_p2p_listen(DBusMessage *message,
|
|||
return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
|
||||
NULL);
|
||||
|
||||
if (wpa_s->p2p_dev)
|
||||
wpa_s = wpa_s->p2p_dev;
|
||||
|
||||
if (wpas_p2p_listen(wpa_s, (unsigned int)timeout))
|
||||
return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
|
||||
NULL);
|
||||
|
@ -217,6 +229,9 @@ DBusMessage * wpas_dbus_handler_p2p_extendedlisten(
|
|||
wpa_dbus_dict_entry_clear(&entry);
|
||||
}
|
||||
|
||||
if (wpa_s->p2p_dev)
|
||||
wpa_s = wpa_s->p2p_dev;
|
||||
|
||||
if (wpas_p2p_ext_listen(wpa_s, period, interval))
|
||||
return wpas_dbus_error_unknown_error(
|
||||
message, "failed to initiate a p2p_ext_listen.");
|
||||
|
@ -265,6 +280,10 @@ DBusMessage * wpas_dbus_handler_p2p_presence_request(
|
|||
|
||||
wpa_dbus_dict_entry_clear(&entry);
|
||||
}
|
||||
|
||||
if (wpa_s->p2p_dev)
|
||||
wpa_s = wpa_s->p2p_dev;
|
||||
|
||||
if (wpas_p2p_presence_req(wpa_s, dur1, int1, dur2, int2) < 0)
|
||||
return wpas_dbus_error_unknown_error(message,
|
||||
"Failed to invoke presence request.");
|
||||
|
@ -319,6 +338,9 @@ DBusMessage * wpas_dbus_handler_p2p_group_add(DBusMessage *message,
|
|||
wpa_dbus_dict_entry_clear(&entry);
|
||||
}
|
||||
|
||||
if (wpa_s->p2p_dev)
|
||||
wpa_s = wpa_s->p2p_dev;
|
||||
|
||||
if (pg_object_path != NULL) {
|
||||
/*
|
||||
* A persistent group Object Path is defined meaning we want
|
||||
|
@ -410,6 +432,9 @@ DBusMessage * wpas_dbus_handler_p2p_flush(DBusMessage *message,
|
|||
if (!wpa_dbus_p2p_check_enabled(wpa_s, message, &reply, NULL))
|
||||
return reply;
|
||||
|
||||
if (wpa_s->p2p_dev)
|
||||
wpa_s = wpa_s->p2p_dev;
|
||||
|
||||
os_memset(wpa_s->p2p_auth_invite, 0, ETH_ALEN);
|
||||
wpa_s->force_long_sd = 0;
|
||||
p2p_flush(wpa_s->global->p2p);
|
||||
|
@ -504,6 +529,9 @@ DBusMessage * wpas_dbus_handler_p2p_connect(DBusMessage *message,
|
|||
if ((!pin || !pin[0]) && (wps_method == WPS_PIN_KEYPAD))
|
||||
goto inv_args;
|
||||
|
||||
if (wpa_s->p2p_dev)
|
||||
wpa_s = wpa_s->p2p_dev;
|
||||
|
||||
new_pin = wpas_p2p_connect(wpa_s, addr, pin, wps_method,
|
||||
persistent_group, 0, join, authorize_only,
|
||||
go_intent, freq, -1, 0, 0, 0);
|
||||
|
@ -605,6 +633,9 @@ DBusMessage * wpas_dbus_handler_p2p_invite(DBusMessage *message,
|
|||
goto err;
|
||||
}
|
||||
|
||||
if (wpa_s->p2p_dev)
|
||||
wpa_s = wpa_s->p2p_dev;
|
||||
|
||||
if (persistent) {
|
||||
/*
|
||||
* A group ID is defined meaning we want to re-invoke a
|
||||
|
@ -690,6 +721,9 @@ DBusMessage * wpas_dbus_handler_p2p_prov_disc_req(DBusMessage *message,
|
|||
os_strcmp(config_method, "pushbutton"))
|
||||
return wpas_dbus_error_invalid_args(message, NULL);
|
||||
|
||||
if (wpa_s->p2p_dev)
|
||||
wpa_s = wpa_s->p2p_dev;
|
||||
|
||||
if (wpas_p2p_prov_disc(wpa_s, peer_addr, config_method,
|
||||
WPAS_P2P_PD_FOR_GO_NEG) < 0)
|
||||
return wpas_dbus_error_unknown_error(message,
|
||||
|
@ -719,6 +753,9 @@ dbus_bool_t wpas_dbus_getter_p2p_device_config(DBusMessageIter *iter,
|
|||
if (!wpa_dbus_p2p_check_enabled(wpa_s, NULL, NULL, error))
|
||||
return FALSE;
|
||||
|
||||
if (wpa_s->p2p_dev)
|
||||
wpa_s = wpa_s->p2p_dev;
|
||||
|
||||
if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
|
||||
"a{sv}", &variant_iter) ||
|
||||
!wpa_dbus_dict_open_write(&variant_iter, &dict_iter))
|
||||
|
@ -860,6 +897,9 @@ dbus_bool_t wpas_dbus_setter_p2p_device_config(DBusMessageIter *iter,
|
|||
if (!wpa_dbus_p2p_check_enabled(wpa_s, NULL, NULL, error))
|
||||
return FALSE;
|
||||
|
||||
if (wpa_s->p2p_dev)
|
||||
wpa_s = wpa_s->p2p_dev;
|
||||
|
||||
dbus_message_iter_recurse(iter, &variant_iter);
|
||||
if (!wpa_dbus_dict_open_read(&variant_iter, &iter_dict, error))
|
||||
return FALSE;
|
||||
|
@ -1583,7 +1623,7 @@ dbus_bool_t wpas_dbus_getter_p2p_peer_groups(DBusMessageIter *iter,
|
|||
struct peer_handler_args *peer_args = user_data;
|
||||
const struct p2p_peer_info *info;
|
||||
struct peer_group_data data;
|
||||
struct wpa_supplicant *wpa_s_go;
|
||||
struct wpa_supplicant *wpa_s, *wpa_s_go;
|
||||
dbus_bool_t success = FALSE;
|
||||
|
||||
info = p2p_get_peer_found(peer_args->wpa_s->global->p2p,
|
||||
|
@ -1595,8 +1635,12 @@ dbus_bool_t wpas_dbus_getter_p2p_peer_groups(DBusMessageIter *iter,
|
|||
}
|
||||
|
||||
os_memset(&data, 0, sizeof(data));
|
||||
wpa_s_go = wpas_get_p2p_client_iface(peer_args->wpa_s,
|
||||
info->p2p_device_addr);
|
||||
|
||||
wpa_s = peer_args->wpa_s;
|
||||
if (wpa_s->p2p_dev)
|
||||
wpa_s = wpa_s->p2p_dev;
|
||||
|
||||
wpa_s_go = wpas_get_p2p_client_iface(wpa_s, info->p2p_device_addr);
|
||||
if (wpa_s_go) {
|
||||
data.paths = os_calloc(1, sizeof(char *));
|
||||
if (data.paths == NULL)
|
||||
|
|
Loading…
Reference in a new issue