diff options
author | Thomas Haller <thaller@redhat.com> | 2017-03-08 14:11:22 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-03-16 18:27:33 +0100 |
commit | 3ce6cbb4a1c674b86a7e065dd27ef1ee16c392ec (patch) | |
tree | a953f95789d721a79322a6ccbc13b702aeb34ec2 /src/nm-dispatcher.c | |
parent | 8987de7cc083d7763c4cc3a357ec11a7672e19e7 (diff) | |
download | NetworkManager-3ce6cbb4a1c674b86a7e065dd27ef1ee16c392ec.tar.gz |
core/dispatcher: pass act-request to device dispatcher calls
Currently, we determine NMD_CONNECTION_PROPS_EXTERNAL based
on the settings connection. That is not optimal, because whether
a connection is assumed or externally managed, should be really a
property of the active-connection. So, in the this will change soon
and we would need yet another argument to nm_dispatcher_call().
Instead, drop the settings-connection and applied-connection
arguments and fetch them from the device as needed (but allow
to pass a specific act-request argument to explicitly state
which active connection to use).
Also, rename nm_dispatcher_call() to nm_dispatcher_call_device(),
it this is not a generic dispatcher call, but it is particularly
related to device events. Likewise, rename nm_dispatcher_call_sync()
to nm_dispatcher_call_device_sync().
Diffstat (limited to 'src/nm-dispatcher.c')
-rw-r--r-- | src/nm-dispatcher.c | 65 |
1 files changed, 43 insertions, 22 deletions
diff --git a/src/nm-dispatcher.c b/src/nm-dispatcher.c index 561950cff9..0b9f45cc8e 100644 --- a/src/nm-dispatcher.c +++ b/src/nm-dispatcher.c @@ -21,14 +21,16 @@ #include "nm-default.h" +#include "nm-dispatcher.h" + #include <string.h> #include <errno.h> -#include "nm-dispatcher.h" #include "nm-dispatcher-api.h" #include "NetworkManagerUtils.h" #include "nm-utils.h" #include "nm-connectivity.h" +#include "nm-act-request.h" #include "devices/nm-device.h" #include "nm-dhcp4-config.h" #include "nm-dhcp6-config.h" @@ -715,41 +717,50 @@ nm_dispatcher_call_hostname (NMDispatcherFunc callback, } /** - * nm_dispatcher_call: + * nm_dispatcher_call_device: * @action: the %NMDispatcherAction - * @settings_connection: the #NMSettingsConnection the action applies to - * @applied_connection: the currently applied connection * @device: the #NMDevice the action applies to + * @act_request: the #NMActRequest for the action. If %NULL, use the + * current request of the device. * @callback: a caller-supplied callback to execute when done * @user_data: caller-supplied pointer passed to @callback * @out_call_id: on success, a call identifier which can be passed to * nm_dispatcher_call_cancel() * - * This method always invokes the dispatcher action asynchronously. To ignore + * This method always invokes the device dispatcher action asynchronously. To ignore * the result, pass %NULL to @callback. * * Returns: %TRUE if the action was dispatched, %FALSE on failure */ gboolean -nm_dispatcher_call (NMDispatcherAction action, - NMSettingsConnection *settings_connection, - NMConnection *applied_connection, - NMDevice *device, - NMDispatcherFunc callback, - gpointer user_data, - guint *out_call_id) +nm_dispatcher_call_device (NMDispatcherAction action, + NMDevice *device, + NMActRequest *act_request, + NMDispatcherFunc callback, + gpointer user_data, + guint *out_call_id) { - return _dispatcher_call (action, FALSE, settings_connection, applied_connection, device, + nm_assert (NM_IS_DEVICE (device)); + if (!act_request) { + act_request = nm_device_get_act_request (device); + if (!act_request) + return FALSE; + } + nm_assert (NM_IN_SET (nm_active_connection_get_device (NM_ACTIVE_CONNECTION (act_request)), NULL, device)); + return _dispatcher_call (action, FALSE, + nm_act_request_get_settings_connection (act_request), + nm_act_request_get_applied_connection (act_request), + device, NM_CONNECTIVITY_UNKNOWN, NULL, NULL, NULL, NULL, callback, user_data, out_call_id); } /** - * nm_dispatcher_call_sync(): + * nm_dispatcher_call_device_sync(): * @action: the %NMDispatcherAction - * @settings_connection: the #NMSettingsConnection the action applies to - * @applied_connection: the currently applied connection * @device: the #NMDevice the action applies to + * @act_request: the #NMActRequest for the action. If %NULL, use the + * current request of the device. * * This method always invokes the dispatcher action synchronously and it may * take a long time to return. @@ -757,13 +768,23 @@ nm_dispatcher_call (NMDispatcherAction action, * Returns: %TRUE if the action was dispatched, %FALSE on failure */ gboolean -nm_dispatcher_call_sync (NMDispatcherAction action, - NMSettingsConnection *settings_connection, - NMConnection *applied_connection, - NMDevice *device) +nm_dispatcher_call_device_sync (NMDispatcherAction action, + NMDevice *device, + NMActRequest *act_request) { - return _dispatcher_call (action, TRUE, settings_connection, applied_connection, device, - NM_CONNECTIVITY_UNKNOWN, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + nm_assert (NM_IS_DEVICE (device)); + if (!act_request) { + act_request = nm_device_get_act_request (device); + if (!act_request) + return FALSE; + } + nm_assert (NM_IN_SET (nm_active_connection_get_device (NM_ACTIVE_CONNECTION (act_request)), NULL, device)); + return _dispatcher_call (action, TRUE, + nm_act_request_get_settings_connection (act_request), + nm_act_request_get_applied_connection (act_request), + device, + NM_CONNECTIVITY_UNKNOWN, NULL, NULL, NULL, NULL, + NULL, NULL, NULL); } /** |