mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-06-19 11:18:28 +02:00
wifi: remove NMSupplicantInfo pending call tracking struct
The sole purpose of this structure was to track in-progress D-Bus pending calls, so that they could be selectively canceled if the supplicant got disconnected during assocation (canceling only assocation-related calls) or if the supplicant went away (canceling both assocation-related and general calls). But its only benefit over NMCallStore alone was knowing which list of pending calls to remove the current pending call from, and we can just explicitly do that in the code instead. Thus, the SupplicantInfo structure is removed and replaced with explicitly adding and removing the pending calls from the call store. (The DBusGProxy is not referenced by dbus_g_proxy_begin_call(), the caller is expected to hold a reference to the proxy for as long as necessary, and when the proxy is destroyed, all its pending calls will be canceled. Since the supplicant interface owns the proxies, there's no possibility that the proxy will outlive the supplicant interface and thus call back into it when its dead. The old code referenced the supplicant interface over the life of the pending call, but that's not necessary.)
This commit is contained in:
parent
1666b0c306
commit
309ecf4f90
1 changed files with 116 additions and 195 deletions
|
|
@ -99,6 +99,7 @@ typedef struct {
|
|||
gboolean scanning;
|
||||
|
||||
DBusGProxy * wpas_proxy;
|
||||
DBusGProxy * introspect_proxy;
|
||||
DBusGProxy * iface_proxy;
|
||||
DBusGProxy * props_proxy;
|
||||
char * net_path;
|
||||
|
|
@ -112,70 +113,6 @@ typedef struct {
|
|||
gboolean disposed;
|
||||
} NMSupplicantInterfacePrivate;
|
||||
|
||||
typedef struct {
|
||||
NMSupplicantInterface *interface;
|
||||
DBusGProxy *proxy;
|
||||
NMCallStore *store;
|
||||
DBusGProxyCall *call;
|
||||
gboolean disposing;
|
||||
} NMSupplicantInfo;
|
||||
|
||||
static NMSupplicantInfo *
|
||||
nm_supplicant_info_new (NMSupplicantInterface *interface,
|
||||
DBusGProxy *proxy,
|
||||
NMCallStore *store)
|
||||
{
|
||||
NMSupplicantInfo *info;
|
||||
|
||||
info = g_slice_new0 (NMSupplicantInfo);
|
||||
info->interface = g_object_ref (interface);
|
||||
info->proxy = g_object_ref (proxy);
|
||||
info->store = store;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
static void
|
||||
nm_supplicant_info_set_call (NMSupplicantInfo *info, DBusGProxyCall *call)
|
||||
{
|
||||
g_return_if_fail (info != NULL);
|
||||
g_return_if_fail (call != NULL);
|
||||
|
||||
nm_call_store_add (info->store, info->proxy, call);
|
||||
info->call = call;
|
||||
}
|
||||
|
||||
static void
|
||||
nm_supplicant_info_destroy (gpointer user_data)
|
||||
{
|
||||
NMSupplicantInfo *info = (NMSupplicantInfo *) user_data;
|
||||
|
||||
/* Guard against double-disposal; since DBusGProxy doesn't guard against
|
||||
* double-disposal, we could infinite loop here if we're in the middle of
|
||||
* some wpa_supplicant D-Bus calls. When the supplicant dies we'll dispose
|
||||
* of the proxy, which kills all its pending calls, which brings us here.
|
||||
* Then when we unref the proxy here, its dispose() function will get called
|
||||
* again, and we get right back here until we segfault because our callstack
|
||||
* is too long.
|
||||
*/
|
||||
if (!info->disposing) {
|
||||
info->disposing = TRUE;
|
||||
|
||||
if (info->call) {
|
||||
nm_call_store_remove (info->store, info->proxy, info->call);
|
||||
info->call = NULL;
|
||||
}
|
||||
|
||||
g_object_unref (info->proxy);
|
||||
info->proxy = NULL;
|
||||
g_object_unref (info->interface);
|
||||
info->interface = NULL;
|
||||
|
||||
memset (info, 0, sizeof (NMSupplicantInfo));
|
||||
g_slice_free (NMSupplicantInfo, info);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
emit_error_helper (NMSupplicantInterface *self,
|
||||
GError *err)
|
||||
|
|
@ -199,14 +136,16 @@ signal_new_bss (NMSupplicantInterface *self,
|
|||
static void
|
||||
bssid_properties_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
||||
{
|
||||
NMSupplicantInfo *info = (NMSupplicantInfo *) user_data;
|
||||
NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data);
|
||||
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
||||
GError *error = NULL;
|
||||
GHashTable *props = NULL;
|
||||
|
||||
nm_call_store_remove (priv->other_pcalls, proxy, call_id);
|
||||
if (dbus_g_proxy_end_call (proxy, call_id, &error,
|
||||
DBUS_TYPE_G_MAP_OF_VARIANT, &props,
|
||||
G_TYPE_INVALID)) {
|
||||
signal_new_bss (info->interface, dbus_g_proxy_get_path (proxy), props);
|
||||
signal_new_bss (self, dbus_g_proxy_get_path (proxy), props);
|
||||
g_hash_table_destroy (props);
|
||||
} else {
|
||||
if (!strstr (error->message, "The BSSID requested was invalid")) {
|
||||
|
|
@ -241,7 +180,6 @@ handle_new_bss (NMSupplicantInterface *self,
|
|||
{
|
||||
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
||||
DBusGProxy *bss_proxy;
|
||||
NMSupplicantInfo *info;
|
||||
DBusGProxyCall *call;
|
||||
|
||||
g_return_if_fail (object_path != NULL);
|
||||
|
|
@ -272,14 +210,13 @@ handle_new_bss (NMSupplicantInterface *self,
|
|||
if (props) {
|
||||
signal_new_bss (self, object_path, props);
|
||||
} else {
|
||||
info = nm_supplicant_info_new (self, bss_proxy, priv->other_pcalls);
|
||||
call = dbus_g_proxy_begin_call (bss_proxy, "GetAll",
|
||||
bssid_properties_cb,
|
||||
info,
|
||||
nm_supplicant_info_destroy,
|
||||
self,
|
||||
NULL,
|
||||
G_TYPE_STRING, WPAS_DBUS_IFACE_BSS,
|
||||
G_TYPE_INVALID);
|
||||
nm_supplicant_info_set_call (info, call);
|
||||
nm_call_store_add (priv->other_pcalls, bss_proxy, call);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -577,38 +514,38 @@ iface_check_ready (NMSupplicantInterface *self)
|
|||
static void
|
||||
iface_get_props_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
||||
{
|
||||
NMSupplicantInfo *info = (NMSupplicantInfo *) user_data;
|
||||
NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data);
|
||||
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
||||
GHashTable *props = NULL;
|
||||
GError *error = NULL;
|
||||
|
||||
nm_call_store_remove (priv->other_pcalls, proxy, call_id);
|
||||
if (dbus_g_proxy_end_call (proxy, call_id, &error,
|
||||
DBUS_TYPE_G_MAP_OF_VARIANT, &props,
|
||||
G_TYPE_INVALID)) {
|
||||
wpas_iface_properties_changed (NULL, props, info->interface);
|
||||
wpas_iface_properties_changed (NULL, props, self);
|
||||
g_hash_table_destroy (props);
|
||||
} else {
|
||||
nm_log_warn (LOGD_SUPPLICANT, "could not get interface properties: %s.",
|
||||
error && error->message ? error->message : "(unknown)");
|
||||
g_clear_error (&error);
|
||||
}
|
||||
iface_check_ready (info->interface);
|
||||
iface_check_ready (self);
|
||||
}
|
||||
|
||||
static void
|
||||
wpas_iface_get_props (NMSupplicantInterface *self)
|
||||
{
|
||||
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
||||
NMSupplicantInfo *info;
|
||||
DBusGProxyCall *call;
|
||||
|
||||
info = nm_supplicant_info_new (self, priv->props_proxy, priv->other_pcalls);
|
||||
call = dbus_g_proxy_begin_call (priv->props_proxy, "GetAll",
|
||||
iface_get_props_cb,
|
||||
info,
|
||||
nm_supplicant_info_destroy,
|
||||
self,
|
||||
NULL,
|
||||
G_TYPE_STRING, WPAS_DBUS_IFACE_INTERFACE,
|
||||
G_TYPE_INVALID);
|
||||
nm_supplicant_info_set_call (info, call);
|
||||
nm_call_store_add (priv->other_pcalls, priv->props_proxy, call);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
@ -657,10 +594,11 @@ wpas_iface_network_request (DBusGProxy *proxy,
|
|||
static void
|
||||
iface_check_netreply_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
||||
{
|
||||
NMSupplicantInfo *info = (NMSupplicantInfo *) user_data;
|
||||
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (info->interface);
|
||||
NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data);
|
||||
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
||||
GError *error = NULL;
|
||||
|
||||
nm_call_store_remove (priv->other_pcalls, proxy, call_id);
|
||||
if ( dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID)
|
||||
|| dbus_g_error_has_name (error, "fi.w1.wpa_supplicant1.InvalidArgs")) {
|
||||
/* We know NetworkReply is supported if the NetworkReply method returned
|
||||
|
|
@ -676,27 +614,25 @@ iface_check_netreply_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer us
|
|||
}
|
||||
g_clear_error (&error);
|
||||
|
||||
iface_check_ready (info->interface);
|
||||
iface_check_ready (self);
|
||||
}
|
||||
|
||||
static void
|
||||
wpas_iface_check_network_reply (NMSupplicantInterface *self)
|
||||
{
|
||||
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
||||
NMSupplicantInfo *info;
|
||||
DBusGProxyCall *call;
|
||||
|
||||
priv->ready_count++;
|
||||
info = nm_supplicant_info_new (self, priv->iface_proxy, priv->other_pcalls);
|
||||
call = dbus_g_proxy_begin_call (priv->iface_proxy, "NetworkReply",
|
||||
iface_check_netreply_cb,
|
||||
info,
|
||||
nm_supplicant_info_destroy,
|
||||
self,
|
||||
NULL,
|
||||
DBUS_TYPE_G_OBJECT_PATH, "/foobaraasdfasdf",
|
||||
G_TYPE_STRING, "foobar",
|
||||
G_TYPE_STRING, "foobar",
|
||||
G_TYPE_INVALID);
|
||||
nm_supplicant_info_set_call (info, call);
|
||||
nm_call_store_add (priv->other_pcalls, priv->iface_proxy, call);
|
||||
}
|
||||
|
||||
ApSupport
|
||||
|
|
@ -721,11 +657,12 @@ nm_supplicant_interface_set_ap_support (NMSupplicantInterface *self,
|
|||
static void
|
||||
iface_check_ap_mode_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
||||
{
|
||||
NMSupplicantInfo *info = (NMSupplicantInfo *) user_data;
|
||||
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (info->interface);
|
||||
NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data);
|
||||
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
||||
char *data;
|
||||
|
||||
/* The ProbeRequest method only exists if AP mode has been enabled */
|
||||
nm_call_store_remove (priv->other_pcalls, proxy, call_id);
|
||||
if (dbus_g_proxy_end_call (proxy, call_id, NULL,
|
||||
G_TYPE_STRING,
|
||||
&data,
|
||||
|
|
@ -735,38 +672,28 @@ iface_check_ap_mode_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer use
|
|||
g_free (data);
|
||||
}
|
||||
|
||||
iface_check_ready (info->interface);
|
||||
iface_check_ready (self);
|
||||
}
|
||||
|
||||
static void
|
||||
wpas_iface_check_ap_mode (NMSupplicantInterface *self)
|
||||
{
|
||||
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
||||
NMSupplicantInfo *info;
|
||||
DBusGProxyCall *call;
|
||||
DBusGProxy *proxy;
|
||||
|
||||
priv->ready_count++;
|
||||
|
||||
proxy = dbus_g_proxy_new_for_name (nm_dbus_manager_get_connection (priv->dbus_mgr),
|
||||
WPAS_DBUS_SERVICE,
|
||||
priv->object_path,
|
||||
DBUS_INTERFACE_INTROSPECTABLE);
|
||||
|
||||
info = nm_supplicant_info_new (self, proxy, priv->other_pcalls);
|
||||
g_object_unref (proxy);
|
||||
|
||||
/* If the global supplicant capabilities property is not present, we can
|
||||
* fall back to checking whether the ProbeRequest method is supported. If
|
||||
* neither of these works we have no way of determining if AP mode is
|
||||
* supported or not. hostap 1.0 and earlier don't support either of these.
|
||||
*/
|
||||
call = dbus_g_proxy_begin_call (proxy, "Introspect",
|
||||
call = dbus_g_proxy_begin_call (priv->introspect_proxy, "Introspect",
|
||||
iface_check_ap_mode_cb,
|
||||
info,
|
||||
nm_supplicant_info_destroy,
|
||||
self,
|
||||
NULL,
|
||||
G_TYPE_INVALID);
|
||||
nm_supplicant_info_set_call (info, call);
|
||||
nm_call_store_add (priv->other_pcalls, priv->introspect_proxy, call);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -836,6 +763,11 @@ interface_add_done (NMSupplicantInterface *self, char *path)
|
|||
self,
|
||||
NULL);
|
||||
|
||||
priv->introspect_proxy = dbus_g_proxy_new_for_name (nm_dbus_manager_get_connection (priv->dbus_mgr),
|
||||
WPAS_DBUS_SERVICE,
|
||||
priv->object_path,
|
||||
DBUS_INTERFACE_INTROSPECTABLE);
|
||||
|
||||
priv->props_proxy = dbus_g_proxy_new_for_name (nm_dbus_manager_get_connection (priv->dbus_mgr),
|
||||
WPAS_DBUS_SERVICE,
|
||||
path,
|
||||
|
|
@ -851,24 +783,23 @@ interface_add_done (NMSupplicantInterface *self, char *path)
|
|||
}
|
||||
|
||||
static void
|
||||
interface_get_cb (DBusGProxy *proxy,
|
||||
DBusGProxyCall *call_id,
|
||||
gpointer user_data)
|
||||
interface_get_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
||||
{
|
||||
NMSupplicantInfo *info = (NMSupplicantInfo *) user_data;
|
||||
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (info->interface);
|
||||
NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data);
|
||||
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
||||
GError *error = NULL;
|
||||
char *path = NULL;
|
||||
|
||||
nm_call_store_remove (priv->other_pcalls, proxy, call_id);
|
||||
if (dbus_g_proxy_end_call (proxy, call_id, &error,
|
||||
DBUS_TYPE_G_OBJECT_PATH, &path,
|
||||
G_TYPE_INVALID)) {
|
||||
interface_add_done (info->interface, path);
|
||||
interface_add_done (self, path);
|
||||
} else {
|
||||
nm_log_err (LOGD_SUPPLICANT, "(%s): error getting interface: %s",
|
||||
priv->dev, error->message);
|
||||
g_clear_error (&error);
|
||||
set_state (info->interface, NM_SUPPLICANT_INTERFACE_STATE_DOWN);
|
||||
set_state (self, NM_SUPPLICANT_INTERFACE_STATE_DOWN);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -876,37 +807,34 @@ static void
|
|||
interface_get (NMSupplicantInterface *self)
|
||||
{
|
||||
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
||||
NMSupplicantInfo *info;
|
||||
DBusGProxyCall *call;
|
||||
|
||||
info = nm_supplicant_info_new (self, priv->wpas_proxy, priv->other_pcalls);
|
||||
call = dbus_g_proxy_begin_call (priv->wpas_proxy, "GetInterface",
|
||||
interface_get_cb,
|
||||
info,
|
||||
nm_supplicant_info_destroy,
|
||||
self,
|
||||
NULL,
|
||||
G_TYPE_STRING, priv->dev,
|
||||
G_TYPE_INVALID);
|
||||
nm_supplicant_info_set_call (info, call);
|
||||
nm_call_store_add (priv->other_pcalls, priv->wpas_proxy, call);
|
||||
}
|
||||
|
||||
static void
|
||||
interface_add_cb (DBusGProxy *proxy,
|
||||
DBusGProxyCall *call_id,
|
||||
gpointer user_data)
|
||||
interface_add_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
||||
{
|
||||
NMSupplicantInfo *info = (NMSupplicantInfo *) user_data;
|
||||
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (info->interface);
|
||||
NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data);
|
||||
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
||||
GError *error = NULL;
|
||||
char *path = NULL;
|
||||
|
||||
nm_call_store_remove (priv->other_pcalls, proxy, call_id);
|
||||
if (dbus_g_proxy_end_call (proxy, call_id, &error,
|
||||
DBUS_TYPE_G_OBJECT_PATH, &path,
|
||||
G_TYPE_INVALID)) {
|
||||
interface_add_done (info->interface, path);
|
||||
interface_add_done (self, path);
|
||||
} else {
|
||||
if (dbus_g_error_has_name (error, WPAS_ERROR_EXISTS_ERROR)) {
|
||||
/* Interface already added, just get its object path */
|
||||
interface_get (info->interface);
|
||||
interface_get (self);
|
||||
} else if ( g_error_matches (error, DBUS_GERROR, DBUS_GERROR_SERVICE_UNKNOWN)
|
||||
|| g_error_matches (error, DBUS_GERROR, DBUS_GERROR_SPAWN_EXEC_FAILED)
|
||||
|| g_error_matches (error, DBUS_GERROR, DBUS_GERROR_SPAWN_FORK_FAILED)
|
||||
|
|
@ -919,11 +847,11 @@ interface_add_cb (DBusGProxy *proxy,
|
|||
*/
|
||||
nm_log_dbg (LOGD_SUPPLICANT, "(%s): failed to activate supplicant: %s",
|
||||
priv->dev, error->message);
|
||||
set_state (info->interface, NM_SUPPLICANT_INTERFACE_STATE_INIT);
|
||||
set_state (self, NM_SUPPLICANT_INTERFACE_STATE_INIT);
|
||||
} else {
|
||||
nm_log_err (LOGD_SUPPLICANT, "(%s): error adding interface: %s",
|
||||
priv->dev, error->message);
|
||||
set_state (info->interface, NM_SUPPLICANT_INTERFACE_STATE_DOWN);
|
||||
set_state (self, NM_SUPPLICANT_INTERFACE_STATE_DOWN);
|
||||
}
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
|
@ -940,9 +868,9 @@ interface_add (NMSupplicantInterface *self, gboolean is_wireless)
|
|||
{
|
||||
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
||||
DBusGProxyCall *call;
|
||||
NMSupplicantInfo *info;
|
||||
GHashTable *hash;
|
||||
GValue *driver, *ifname;
|
||||
GValue driver = G_VALUE_INIT;
|
||||
GValue ifname = G_VALUE_INIT;
|
||||
|
||||
/* Can only start the interface from INIT state */
|
||||
g_return_if_fail (priv->state == NM_SUPPLICANT_INTERFACE_STATE_INIT);
|
||||
|
|
@ -957,34 +885,27 @@ interface_add (NMSupplicantInterface *self, gboolean is_wireless)
|
|||
* when the supplicant has started.
|
||||
*/
|
||||
|
||||
info = nm_supplicant_info_new (self, priv->wpas_proxy, priv->other_pcalls);
|
||||
|
||||
hash = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
|
||||
driver = g_new0 (GValue, 1);
|
||||
g_value_init (driver, G_TYPE_STRING);
|
||||
g_value_set_string (driver, is_wireless ? DEFAULT_WIFI_DRIVER : "wired");
|
||||
g_hash_table_insert (hash, "Driver", driver);
|
||||
g_value_init (&driver, G_TYPE_STRING);
|
||||
g_value_set_string (&driver, is_wireless ? DEFAULT_WIFI_DRIVER : "wired");
|
||||
g_hash_table_insert (hash, "Driver", &driver);
|
||||
|
||||
ifname = g_new0 (GValue, 1);
|
||||
g_value_init (ifname, G_TYPE_STRING);
|
||||
g_value_set_string (ifname, priv->dev);
|
||||
g_hash_table_insert (hash, "Ifname", ifname);
|
||||
g_value_init (&ifname, G_TYPE_STRING);
|
||||
g_value_set_string (&ifname, priv->dev);
|
||||
g_hash_table_insert (hash, "Ifname", &ifname);
|
||||
|
||||
call = dbus_g_proxy_begin_call (priv->wpas_proxy, "CreateInterface",
|
||||
interface_add_cb,
|
||||
info,
|
||||
nm_supplicant_info_destroy,
|
||||
self,
|
||||
NULL,
|
||||
DBUS_TYPE_G_MAP_OF_VARIANT, hash,
|
||||
G_TYPE_INVALID);
|
||||
nm_call_store_add (priv->other_pcalls, priv->wpas_proxy, call);
|
||||
|
||||
g_hash_table_destroy (hash);
|
||||
g_value_unset (driver);
|
||||
g_free (driver);
|
||||
g_value_unset (ifname);
|
||||
g_free (ifname);
|
||||
|
||||
nm_supplicant_info_set_call (info, call);
|
||||
g_value_unset (&driver);
|
||||
g_value_unset (&ifname);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1073,12 +994,14 @@ nm_supplicant_interface_disconnect (NMSupplicantInterface * self)
|
|||
static void
|
||||
select_network_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
||||
{
|
||||
NMSupplicantInfo *info = (NMSupplicantInfo *) user_data;
|
||||
NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data);
|
||||
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
||||
GError *err = NULL;
|
||||
|
||||
nm_call_store_remove (priv->assoc_pcalls, proxy, call_id);
|
||||
if (!dbus_g_proxy_end_call (proxy, call_id, &err, G_TYPE_INVALID)) {
|
||||
nm_log_warn (LOGD_SUPPLICANT, "Couldn't select network config: %s.", err->message);
|
||||
emit_error_helper (info->interface, err);
|
||||
emit_error_helper (self, err);
|
||||
g_error_free (err);
|
||||
}
|
||||
}
|
||||
|
|
@ -1088,61 +1011,59 @@ call_select_network (NMSupplicantInterface *self)
|
|||
{
|
||||
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
||||
DBusGProxyCall *call;
|
||||
NMSupplicantInfo *info;
|
||||
|
||||
/* We only select the network after all blobs (if any) have been set */
|
||||
if (priv->blobs_left > 0)
|
||||
return;
|
||||
|
||||
info = nm_supplicant_info_new (self, priv->iface_proxy, priv->assoc_pcalls);
|
||||
call = dbus_g_proxy_begin_call (priv->iface_proxy, "SelectNetwork",
|
||||
select_network_cb,
|
||||
info,
|
||||
nm_supplicant_info_destroy,
|
||||
DBUS_TYPE_G_OBJECT_PATH, priv->net_path,
|
||||
G_TYPE_INVALID);
|
||||
nm_supplicant_info_set_call (info, call);
|
||||
if (priv->blobs_left == 0) {
|
||||
call = dbus_g_proxy_begin_call (priv->iface_proxy, "SelectNetwork",
|
||||
select_network_cb,
|
||||
self,
|
||||
NULL,
|
||||
DBUS_TYPE_G_OBJECT_PATH, priv->net_path,
|
||||
G_TYPE_INVALID);
|
||||
nm_call_store_add (priv->assoc_pcalls, priv->iface_proxy, call);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
add_blob_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
||||
{
|
||||
NMSupplicantInfo *info = (NMSupplicantInfo *) user_data;
|
||||
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (info->interface);
|
||||
NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data);
|
||||
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
||||
GError *err = NULL;
|
||||
guint tmp;
|
||||
|
||||
priv->blobs_left--;
|
||||
|
||||
nm_call_store_remove (priv->assoc_pcalls, proxy, call_id);
|
||||
if (!dbus_g_proxy_end_call (proxy, call_id, &err, G_TYPE_UINT, &tmp, G_TYPE_INVALID)) {
|
||||
nm_log_warn (LOGD_SUPPLICANT, "Couldn't set network certificates: %s.", err->message);
|
||||
emit_error_helper (info->interface, err);
|
||||
emit_error_helper (self, err);
|
||||
g_error_free (err);
|
||||
} else
|
||||
call_select_network (info->interface);
|
||||
call_select_network (self);
|
||||
}
|
||||
|
||||
static void
|
||||
add_network_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
||||
{
|
||||
NMSupplicantInfo *info = (NMSupplicantInfo *) user_data;
|
||||
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (info->interface);
|
||||
NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data);
|
||||
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
||||
GError *err = NULL;
|
||||
GHashTable *blobs;
|
||||
GHashTableIter iter;
|
||||
gpointer name, data;
|
||||
DBusGProxyCall *call;
|
||||
NMSupplicantInfo *blob_info;
|
||||
|
||||
g_free (priv->net_path);
|
||||
priv->net_path = NULL;
|
||||
|
||||
nm_call_store_remove (priv->assoc_pcalls, proxy, call_id);
|
||||
if (!dbus_g_proxy_end_call (proxy, call_id, &err,
|
||||
DBUS_TYPE_G_OBJECT_PATH, &priv->net_path,
|
||||
G_TYPE_INVALID)) {
|
||||
nm_log_warn (LOGD_SUPPLICANT, "Couldn't add a network to the supplicant interface: %s.",
|
||||
err->message);
|
||||
emit_error_helper (info->interface, err);
|
||||
emit_error_helper (self, err);
|
||||
g_error_free (err);
|
||||
return;
|
||||
}
|
||||
|
|
@ -1152,33 +1073,33 @@ add_network_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
|||
priv->blobs_left = g_hash_table_size (blobs);
|
||||
g_hash_table_iter_init (&iter, blobs);
|
||||
while (g_hash_table_iter_next (&iter, &name, &data)) {
|
||||
blob_info = nm_supplicant_info_new (info->interface, priv->iface_proxy, priv->assoc_pcalls);
|
||||
call = dbus_g_proxy_begin_call (priv->iface_proxy, "AddBlob",
|
||||
add_blob_cb,
|
||||
blob_info,
|
||||
nm_supplicant_info_destroy,
|
||||
self,
|
||||
NULL,
|
||||
DBUS_TYPE_STRING, name,
|
||||
DBUS_TYPE_G_UCHAR_ARRAY, blobs,
|
||||
G_TYPE_INVALID);
|
||||
nm_supplicant_info_set_call (blob_info, call);
|
||||
nm_call_store_add (priv->assoc_pcalls, priv->iface_proxy, call);
|
||||
}
|
||||
|
||||
call_select_network (info->interface);
|
||||
call_select_network (self);
|
||||
}
|
||||
|
||||
static void
|
||||
set_ap_scan_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
||||
{
|
||||
NMSupplicantInfo *info = (NMSupplicantInfo *) user_data;
|
||||
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (info->interface);
|
||||
NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data);
|
||||
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
||||
GError *err = NULL;
|
||||
DBusGProxyCall *call;
|
||||
GHashTable *config_hash;
|
||||
|
||||
nm_call_store_remove (priv->assoc_pcalls, proxy, call_id);
|
||||
if (!dbus_g_proxy_end_call (proxy, call_id, &err, G_TYPE_INVALID)) {
|
||||
nm_log_warn (LOGD_SUPPLICANT, "Couldn't send AP scan mode to the supplicant interface: %s.",
|
||||
err->message);
|
||||
emit_error_helper (info->interface, err);
|
||||
emit_error_helper (self, err);
|
||||
g_error_free (err);
|
||||
return;
|
||||
}
|
||||
|
|
@ -1186,24 +1107,22 @@ set_ap_scan_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
|||
nm_log_info (LOGD_SUPPLICANT, "Config: set interface ap_scan to %d",
|
||||
nm_supplicant_config_get_ap_scan (priv->cfg));
|
||||
|
||||
info = nm_supplicant_info_new (info->interface, priv->iface_proxy, info->store);
|
||||
config_hash = nm_supplicant_config_get_hash (priv->cfg);
|
||||
call = dbus_g_proxy_begin_call (priv->iface_proxy, "AddNetwork",
|
||||
add_network_cb,
|
||||
info,
|
||||
nm_supplicant_info_destroy,
|
||||
self,
|
||||
NULL,
|
||||
DBUS_TYPE_G_MAP_OF_VARIANT, config_hash,
|
||||
G_TYPE_INVALID);
|
||||
g_hash_table_destroy (config_hash);
|
||||
nm_supplicant_info_set_call (info, call);
|
||||
nm_call_store_add (priv->assoc_pcalls, priv->iface_proxy, call);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_supplicant_interface_set_config (NMSupplicantInterface * self,
|
||||
NMSupplicantConfig * cfg)
|
||||
nm_supplicant_interface_set_config (NMSupplicantInterface *self,
|
||||
NMSupplicantConfig *cfg)
|
||||
{
|
||||
NMSupplicantInterfacePrivate *priv;
|
||||
NMSupplicantInfo *info;
|
||||
DBusGProxyCall *call;
|
||||
GValue value = G_VALUE_INIT;
|
||||
|
||||
|
|
@ -1233,16 +1152,15 @@ nm_supplicant_interface_set_config (NMSupplicantInterface * self,
|
|||
g_value_init (&value, G_TYPE_UINT);
|
||||
g_value_set_uint (&value, nm_supplicant_config_get_ap_scan (priv->cfg));
|
||||
|
||||
info = nm_supplicant_info_new (self, priv->props_proxy, priv->other_pcalls);
|
||||
call = dbus_g_proxy_begin_call (priv->props_proxy, "Set",
|
||||
set_ap_scan_cb,
|
||||
info,
|
||||
nm_supplicant_info_destroy,
|
||||
self,
|
||||
NULL,
|
||||
G_TYPE_STRING, WPAS_DBUS_IFACE_INTERFACE,
|
||||
G_TYPE_STRING, "ApScan",
|
||||
G_TYPE_VALUE, &value,
|
||||
G_TYPE_INVALID);
|
||||
nm_supplicant_info_set_call (info, call);
|
||||
nm_call_store_add (priv->assoc_pcalls, priv->props_proxy, call);
|
||||
|
||||
g_value_unset (&value);
|
||||
return call != NULL;
|
||||
|
|
@ -1251,13 +1169,15 @@ nm_supplicant_interface_set_config (NMSupplicantInterface * self,
|
|||
static void
|
||||
scan_request_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
||||
{
|
||||
NMSupplicantInfo *info = (NMSupplicantInfo *) user_data;
|
||||
NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data);
|
||||
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
|
||||
GError *err = NULL;
|
||||
|
||||
if (!dbus_g_proxy_end_call (proxy, call_id, &err, G_TYPE_INVALID)) {
|
||||
nm_call_store_remove (priv->other_pcalls, proxy, call_id);
|
||||
if (!dbus_g_proxy_end_call (proxy, call_id, &err, G_TYPE_INVALID))
|
||||
nm_log_warn (LOGD_SUPPLICANT, "Could not get scan request result: %s", err->message);
|
||||
}
|
||||
g_signal_emit (info->interface, signals[SCAN_DONE], 0, err ? FALSE : TRUE);
|
||||
|
||||
g_signal_emit (self, signals[SCAN_DONE], 0, err ? FALSE : TRUE);
|
||||
g_clear_error (&err);
|
||||
}
|
||||
|
||||
|
|
@ -1294,7 +1214,6 @@ gboolean
|
|||
nm_supplicant_interface_request_scan (NMSupplicantInterface *self, const GPtrArray *ssids)
|
||||
{
|
||||
NMSupplicantInterfacePrivate *priv;
|
||||
NMSupplicantInfo *info;
|
||||
DBusGProxyCall *call;
|
||||
GHashTable *hash;
|
||||
|
||||
|
|
@ -1308,15 +1227,14 @@ nm_supplicant_interface_request_scan (NMSupplicantInterface *self, const GPtrArr
|
|||
if (ssids)
|
||||
g_hash_table_insert (hash, "SSIDs", byte_array_array_to_gvalue (ssids));
|
||||
|
||||
info = nm_supplicant_info_new (self, priv->iface_proxy, priv->other_pcalls);
|
||||
call = dbus_g_proxy_begin_call (priv->iface_proxy, "Scan",
|
||||
scan_request_cb,
|
||||
info,
|
||||
nm_supplicant_info_destroy,
|
||||
self,
|
||||
NULL,
|
||||
DBUS_TYPE_G_MAP_OF_VARIANT, hash,
|
||||
G_TYPE_INVALID);
|
||||
g_hash_table_destroy (hash);
|
||||
nm_supplicant_info_set_call (info, call);
|
||||
nm_call_store_add (priv->other_pcalls, priv->iface_proxy, call);
|
||||
|
||||
return call != NULL;
|
||||
}
|
||||
|
|
@ -1512,6 +1430,9 @@ dispose (GObject *object)
|
|||
|
||||
g_free (priv->net_path);
|
||||
|
||||
if (priv->introspect_proxy)
|
||||
g_object_unref (priv->introspect_proxy);
|
||||
|
||||
if (priv->wpas_proxy)
|
||||
g_object_unref (priv->wpas_proxy);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue