Commit 2d1b85f8 authored by Thomas Haller's avatar Thomas Haller

core: merge branch 'th/assume-vs-unmanaged-bgo746440'

This branch only does part of what bgo#746440 is about.
But it's a large and necessary step towards the full
solution. It cleanups tracking of whether to assume
a device, treat it as external or fully manage it.

Future work will need to fine tune the behavior.

https://bugzilla.gnome.org/show_bug.cgi?id=746440
https://bugzilla.redhat.com/show_bug.cgi?id=1394579
parents b07f6712 850c9779
......@@ -233,21 +233,34 @@ NM_G_ERROR_MSG (GError *error)
#define _NM_IN_SET_EVAL_16(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_15 (op, _x, __VA_ARGS__)
#define _NM_IN_SET_EVAL_N2(op, _x, n, ...) (_NM_IN_SET_EVAL_##n(op, _x, __VA_ARGS__))
#define _NM_IN_SET_EVAL_N(op, x, n, ...) \
#define _NM_IN_SET_EVAL_N(op, type, x, n, ...) \
({ \
typeof(x) _x = (x); \
type _x = (x); \
\
/* trigger a -Wenum-compare warning */ \
nm_assert (TRUE || _x == (x)); \
\
!!_NM_IN_SET_EVAL_N2(op, _x, n, __VA_ARGS__); \
})
#define _NM_IN_SET(op, type, x, ...) _NM_IN_SET_EVAL_N(op, type, x, NM_NARG (__VA_ARGS__), __VA_ARGS__)
/* Beware that this does short-circuit evaluation (use "||" instead of "|")
* which has a possibly unexpected non-function-like behavior.
* Use NM_IN_SET_SE if you need all arguments to be evaluted. */
#define NM_IN_SET(x, ...) _NM_IN_SET_EVAL_N(||, x, NM_NARG (__VA_ARGS__), __VA_ARGS__)
#define NM_IN_SET(x, ...) _NM_IN_SET(||, typeof (x), x, __VA_ARGS__)
/* "SE" stands for "side-effect". Contrary to NM_IN_SET(), this does not do
* short-circuit evaluation, which can make a difference if the arguments have
* side-effects. */
#define NM_IN_SET_SE(x, ...) _NM_IN_SET_EVAL_N(|, x, NM_NARG (__VA_ARGS__), __VA_ARGS__)
#define NM_IN_SET_SE(x, ...) _NM_IN_SET(|, typeof (x), x, __VA_ARGS__)
/* the *_TYPED forms allow to explicitly select the type of "x". This is useful
* if "x" doesn't support typeof (bitfields) or you want to gracefully convert
* a type using automatic type conversion rules (but not forcing the conversion
* with a cast). */
#define NM_IN_SET_TYPED(type, x, ...) _NM_IN_SET(||, type, x, __VA_ARGS__)
#define NM_IN_SET_SE_TYPED(type, x, ...) _NM_IN_SET(|, type, x, __VA_ARGS__)
/*****************************************************************************/
......@@ -278,8 +291,8 @@ _NM_IN_STRSET_streq (const char *x, const char *s)
#define _NM_IN_STRSET_EVAL_N(op, x, n, ...) \
({ \
const char *_x = (x); \
( ((_x == NULL) && _NM_IN_SET_EVAL_N2 (op, (const char *) NULL, n, __VA_ARGS__)) \
|| ((_x != NULL) && _NM_IN_STRSET_EVAL_N2 (op, _x, n, __VA_ARGS__)) \
( ((_x == NULL) && _NM_IN_SET_EVAL_N2 (op, ((const char *) NULL), n, __VA_ARGS__)) \
|| ((_x != NULL) && _NM_IN_STRSET_EVAL_N2 (op, _x, n, __VA_ARGS__)) \
); \
})
......
......@@ -370,9 +370,9 @@ route_compare (NMIPRoute *route1, NMIPRoute *route2, gint64 default_metric)
}
static int
route_ptr_compare (const void *a, const void *b)
route_ptr_compare (const void *a, const void *b, gpointer metric)
{
return route_compare (*(NMIPRoute **) a, *(NMIPRoute **) b, -1);
return route_compare (*(NMIPRoute **) a, *(NMIPRoute **) b, *((gint64 *) metric));
}
static gboolean
......@@ -384,6 +384,7 @@ check_ip_routes (NMConnection *orig,
{
gs_free NMIPRoute **routes1 = NULL, **routes2 = NULL;
NMSettingIPConfig *s_ip1, *s_ip2;
gint64 m;
const char *s_name;
GHashTable *props;
guint i, num;
......@@ -415,8 +416,12 @@ check_ip_routes (NMConnection *orig,
routes2[i] = nm_setting_ip_config_get_route (s_ip2, i);
}
qsort (routes1, num, sizeof (NMIPRoute *), route_ptr_compare);
qsort (routes2, num, sizeof (NMIPRoute *), route_ptr_compare);
m = nm_setting_ip_config_get_route_metric (s_ip2);
if (m != -1)
default_metric = m;
g_qsort_with_data (routes1, num, sizeof (NMIPRoute *), route_ptr_compare, &default_metric);
g_qsort_with_data (routes2, num, sizeof (NMIPRoute *), route_ptr_compare, &default_metric);
for (i = 0; i < num; i++) {
if (route_compare (routes1[i], routes2[i], default_metric))
......@@ -710,7 +715,7 @@ check_possible_match (NMConnection *orig,
* matches well enough.
*/
NMConnection *
nm_utils_match_connection (GSList *connections,
nm_utils_match_connection (NMConnection *const*connections,
NMConnection *original,
gboolean device_has_carrier,
gint64 default_v4_metric,
......@@ -719,10 +724,12 @@ nm_utils_match_connection (GSList *connections,
gpointer match_filter_data)
{
NMConnection *best_match = NULL;
GSList *iter;
for (iter = connections; iter; iter = iter->next) {
NMConnection *candidate = NM_CONNECTION (iter->data);
if (!connections)
return NULL;
for (; *connections; connections++) {
NMConnection *candidate = NM_CONNECTION (*connections);
GHashTable *diffs = NULL;
if (match_filter_func) {
......
......@@ -39,7 +39,7 @@ void nm_utils_complete_generic (NMPlatform *platform,
typedef gboolean (NMUtilsMatchFilterFunc) (NMConnection *connection, gpointer user_data);
NMConnection *nm_utils_match_connection (GSList *connections,
NMConnection *nm_utils_match_connection (NMConnection *const*connections,
NMConnection *original,
gboolean device_has_carrier,
gint64 default_v4_metric,
......
......@@ -90,13 +90,14 @@ parent_hwaddr_maybe_changed (NMDevice *parent,
GParamSpec *pspec,
gpointer user_data)
{
NMDeviceVlan *self = NM_DEVICE_VLAN (user_data);
NMDevice *device = NM_DEVICE (user_data);
NMDeviceVlan *self = NM_DEVICE_VLAN (device);
NMConnection *connection;
const char *new_mac, *old_mac;
NMSettingIPConfig *s_ip6;
/* Never touch assumed devices */
if (nm_device_uses_assumed_connection ((NMDevice *) self))
if (nm_device_sys_iface_state_is_external_or_assume (device))
return;
connection = nm_device_get_applied_connection ((NMDevice *) self);
......
This diff is collapsed.
......@@ -30,6 +30,13 @@
#include "nm-rfkill-manager.h"
#include "NetworkManagerUtils.h"
typedef enum {
NM_DEVICE_SYS_IFACE_STATE_EXTERNAL,
NM_DEVICE_SYS_IFACE_STATE_ASSUME,
NM_DEVICE_SYS_IFACE_STATE_MANAGED,
NM_DEVICE_SYS_IFACE_STATE_REMOVED,
} NMDeviceSysIfaceState;
static inline NMDeviceStateReason
nm_device_state_reason_check (NMDeviceStateReason reason)
{
......@@ -489,8 +496,6 @@ gboolean nm_device_complete_connection (NMDevice *device,
gboolean nm_device_check_connection_compatible (NMDevice *device, NMConnection *connection);
gboolean nm_device_check_slave_connection_compatible (NMDevice *device, NMConnection *connection);
gboolean nm_device_uses_assumed_connection (NMDevice *device);
gboolean nm_device_unmanage_on_quit (NMDevice *self);
gboolean nm_device_spec_match_list (NMDevice *device, const GSList *specs);
......@@ -595,6 +600,7 @@ gboolean nm_device_has_capability (NMDevice *self, NMDeviceCapabilities caps);
gboolean nm_device_realize_start (NMDevice *device,
const NMPlatformLink *plink,
NMUnmanFlagOp unmanaged_user_explicit,
gboolean *out_compatible,
GError **error);
void nm_device_realize_finish (NMDevice *self,
......@@ -611,6 +617,13 @@ gboolean nm_device_get_autoconnect (NMDevice *device);
void nm_device_set_autoconnect_intern (NMDevice *device, gboolean autoconnect);
void nm_device_emit_recheck_auto_activate (NMDevice *device);
NMDeviceSysIfaceState nm_device_sys_iface_state_get (NMDevice *device);
gboolean nm_device_sys_iface_state_is_external (NMDevice *self);
gboolean nm_device_sys_iface_state_is_external_or_assume (NMDevice *self);
void nm_device_sys_iface_state_set (NMDevice *device, NMDeviceSysIfaceState sys_iface_state);
void nm_device_state_changed (NMDevice *device,
NMDeviceState state,
NMDeviceStateReason reason);
......
......@@ -416,7 +416,7 @@ teamd_dbus_appeared (GDBusConnection *connection,
success = teamd_read_config (device);
if (success)
nm_device_activate_schedule_stage2_device_config (device);
else if (!nm_device_uses_assumed_connection (device))
else if (!nm_device_sys_iface_state_is_external_or_assume (device))
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_TEAMD_CONTROL_FAILED);
}
}
......
......@@ -543,6 +543,7 @@ nm_act_request_init (NMActRequest *req)
* @specific_object: the object path of the specific object (ie, WiFi access point,
* etc) that will be used to activate @connection and @device
* @subject: the #NMAuthSubject representing the requestor of the activation
* @activation_type: the #NMActivationType.
* @device: the device/interface to configure according to @connection
*
* Creates a new device-based activation request. If an applied connection is
......@@ -555,6 +556,7 @@ nm_act_request_new (NMSettingsConnection *settings_connection,
NMConnection *applied_connection,
const char *specific_object,
NMAuthSubject *subject,
NMActivationType activation_type,
NMDevice *device)
{
g_return_val_if_fail (!settings_connection || NM_IS_SETTINGS_CONNECTION (settings_connection), NULL);
......@@ -567,6 +569,7 @@ nm_act_request_new (NMSettingsConnection *settings_connection,
NM_ACTIVE_CONNECTION_INT_DEVICE, device,
NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT, specific_object,
NM_ACTIVE_CONNECTION_INT_SUBJECT, subject,
NM_ACTIVE_CONNECTION_INT_ACTIVATION_TYPE, (int) activation_type,
NULL);
}
......
......@@ -40,6 +40,7 @@ NMActRequest *nm_act_request_new (NMSettingsConnection *settings_connec
NMConnection *applied_connection,
const char *specific_object,
NMAuthSubject *subject,
NMActivationType activation_type,
NMDevice *device);
NMSettingsConnection *nm_act_request_get_settings_connection (NMActRequest *req);
......
......@@ -44,20 +44,20 @@ typedef struct _NMActiveConnectionPrivate {
char *pending_activation_id;
gboolean is_default;
gboolean is_default6;
NMActiveConnectionState state;
gboolean state_set;
gboolean vpn;
bool is_default:1;
bool is_default6:1;
bool state_set:1;
bool vpn:1;
bool master_ready:1;
NMActivationType activation_type:3;
NMAuthSubject *subject;
NMActiveConnection *master;
gboolean master_ready;
NMActiveConnection *parent;
gboolean assumed;
NMAuthChain *chain;
const char *wifi_shared_permission;
NMActiveConnectionAuthResultFunc result_func;
......@@ -88,6 +88,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMActiveConnection,
PROP_INT_SUBJECT,
PROP_INT_MASTER,
PROP_INT_MASTER_READY,
PROP_INT_ACTIVATION_TYPE,
);
enum {
......@@ -102,8 +103,15 @@ G_DEFINE_ABSTRACT_TYPE (NMActiveConnection, nm_active_connection, NM_TYPE_EXPORT
#define NM_ACTIVE_CONNECTION_GET_PRIVATE(self) _NM_GET_PRIVATE_PTR(self, NMActiveConnection, NM_IS_ACTIVE_CONNECTION)
/*****************************************************************************/
static void check_master_ready (NMActiveConnection *self);
static void _device_cleanup (NMActiveConnection *self);
static void _settings_connection_notify_flags (NMSettingsConnection *settings_connection,
GParamSpec *param,
NMActiveConnection *self);
static void _set_activation_type (NMActiveConnection *self,
NMActivationType activation_type);
/*****************************************************************************/
......@@ -181,12 +189,15 @@ _set_settings_connection (NMActiveConnection *self, NMSettingsConnection *connec
if (priv->settings_connection) {
g_signal_handlers_disconnect_by_func (priv->settings_connection, _settings_connection_updated, self);
g_signal_handlers_disconnect_by_func (priv->settings_connection, _settings_connection_removed, self);
g_signal_handlers_disconnect_by_func (priv->settings_connection, _settings_connection_notify_flags, self);
g_clear_object (&priv->settings_connection);
}
if (connection) {
priv->settings_connection = g_object_ref (connection);
g_signal_connect (connection, NM_SETTINGS_CONNECTION_UPDATED_INTERNAL, (GCallback) _settings_connection_updated, self);
g_signal_connect (connection, NM_SETTINGS_CONNECTION_REMOVED, (GCallback) _settings_connection_removed, self);
if (nm_active_connection_get_activation_type (self) == NM_ACTIVATION_TYPE_EXTERNAL)
g_signal_connect (connection, "notify::"NM_SETTINGS_CONNECTION_FLAGS, (GCallback) _settings_connection_notify_flags, self);
}
}
......@@ -214,6 +225,14 @@ nm_active_connection_set_state (NMActiveConnection *self,
state_to_string (new_state),
state_to_string (priv->state));
if ( new_state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED
&& priv->activation_type == NM_ACTIVATION_TYPE_ASSUME) {
/* assuming connections mean to gracefully take over an externally
* configured device. Once activation is complete, an assumed
* activation *is* the same as a full activation. */
_set_activation_type (self, NM_ACTIVATION_TYPE_MANAGED);
}
old_state = priv->state;
priv->state = new_state;
priv->state_set = TRUE;
......@@ -566,7 +585,7 @@ nm_active_connection_set_device (NMActiveConnection *self, NMDevice *device)
g_signal_connect (device, "notify::" NM_DEVICE_METERED,
G_CALLBACK (device_metered_changed), self);
if (!priv->assumed) {
if (priv->activation_type != NM_ACTIVATION_TYPE_EXTERNAL) {
priv->pending_activation_id = g_strdup_printf (NM_PENDING_ACTIONPREFIX_ACTIVATION"%p", (void *)self);
nm_device_add_pending_action (device, priv->pending_activation_id, TRUE);
}
......@@ -712,24 +731,55 @@ nm_active_connection_set_master (NMActiveConnection *self, NMActiveConnection *m
check_master_ready (self);
}
void
nm_active_connection_set_assumed (NMActiveConnection *self, gboolean assumed)
NMActivationType
nm_active_connection_get_activation_type (NMActiveConnection *self)
{
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (self), NM_ACTIVATION_TYPE_MANAGED);
return NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->activation_type;
}
static void
_set_activation_type (NMActiveConnection *self,
NMActivationType activation_type)
{
NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
g_return_if_fail (priv->assumed == FALSE);
priv->assumed = assumed;
if (priv->activation_type == activation_type)
return;
if (priv->pending_activation_id) {
nm_device_remove_pending_action (priv->device, priv->pending_activation_id, TRUE);
g_clear_pointer (&priv->pending_activation_id, g_free);
}
_LOGD ("update activation type from %s to %s",
nm_activation_type_to_string (priv->activation_type),
nm_activation_type_to_string (activation_type));
priv->activation_type = activation_type;
if ( priv->activation_type == NM_ACTIVATION_TYPE_MANAGED
&& priv->device
&& self == NM_ACTIVE_CONNECTION (nm_device_get_act_request (priv->device))
&& NM_IN_SET (nm_device_sys_iface_state_get (priv->device),
NM_DEVICE_SYS_IFACE_STATE_EXTERNAL,
NM_DEVICE_SYS_IFACE_STATE_ASSUME))
nm_device_sys_iface_state_set (priv->device, NM_DEVICE_SYS_IFACE_STATE_MANAGED);
}
gboolean
nm_active_connection_get_assumed (NMActiveConnection *self)
/*****************************************************************************/
static void
_settings_connection_notify_flags (NMSettingsConnection *settings_connection,
GParamSpec *param,
NMActiveConnection *self)
{
return NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->assumed;
nm_assert (NM_IS_ACTIVE_CONNECTION (self));
nm_assert (NM_IS_SETTINGS_CONNECTION (settings_connection));
nm_assert (nm_active_connection_get_activation_type (self) == NM_ACTIVATION_TYPE_EXTERNAL);
nm_assert (NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->settings_connection == settings_connection);
if (nm_settings_connection_get_nm_generated (settings_connection))
return;
g_signal_handlers_disconnect_by_func (settings_connection, _settings_connection_notify_flags, self);
_set_activation_type (self, NM_ACTIVATION_TYPE_MANAGED);
nm_device_reapply_settings_immediately (nm_active_connection_get_device (self));
}
/*****************************************************************************/
......@@ -1058,6 +1108,7 @@ set_property (GObject *object, guint prop_id,
const char *tmp;
NMSettingsConnection *con;
NMConnection *acon;
int i;
switch (prop_id) {
case PROP_INT_SETTINGS_CONNECTION:
......@@ -1082,6 +1133,15 @@ set_property (GObject *object, guint prop_id,
case PROP_INT_MASTER:
nm_active_connection_set_master (self, g_value_get_object (value));
break;
case PROP_INT_ACTIVATION_TYPE:
/* construct-only */
i = g_value_get_int (value);
if (!NM_IN_SET (i, NM_ACTIVATION_TYPE_MANAGED,
NM_ACTIVATION_TYPE_ASSUME,
NM_ACTIVATION_TYPE_EXTERNAL))
g_return_if_reached ();
priv->activation_type = (NMActivationType) i;
break;
case PROP_SPECIFIC_OBJECT:
tmp = g_value_get_string (value);
/* NM uses "/" to mean NULL */
......@@ -1117,6 +1177,7 @@ nm_active_connection_init (NMActiveConnection *self)
_LOGT ("creating");
priv->activation_type = NM_ACTIVATION_TYPE_MANAGED;
priv->version_id = _version_id_new ();
}
......@@ -1128,15 +1189,16 @@ constructed (GObject *object)
G_OBJECT_CLASS (nm_active_connection_parent_class)->constructed (object);
if (!priv->applied_connection && priv->settings_connection) {
priv->applied_connection =
nm_simple_connection_new_clone ((NMConnection *) priv->settings_connection);
}
if (!priv->applied_connection && priv->settings_connection)
priv->applied_connection = nm_simple_connection_new_clone (NM_CONNECTION (priv->settings_connection));
if (priv->applied_connection)
nm_connection_clear_secrets (priv->applied_connection);
_LOGD ("constructed (%s, version-id %llu)", G_OBJECT_TYPE_NAME (self), (unsigned long long) priv->version_id);
_LOGD ("constructed (%s, version-id %llu, type %s)",
G_OBJECT_TYPE_NAME (self),
(unsigned long long) priv->version_id,
nm_activation_type_to_string (priv->activation_type));
g_return_if_fail (priv->subject);
}
......@@ -1321,6 +1383,15 @@ nm_active_connection_class_init (NMActiveConnectionClass *ac_class)
FALSE, G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS);
obj_properties[PROP_INT_ACTIVATION_TYPE] =
g_param_spec_int (NM_ACTIVE_CONNECTION_INT_ACTIVATION_TYPE, "", "",
NM_ACTIVATION_TYPE_MANAGED,
NM_ACTIVATION_TYPE_EXTERNAL,
NM_ACTIVATION_TYPE_MANAGED,
G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
signals[DEVICE_CHANGED] =
......
......@@ -55,6 +55,7 @@
#define NM_ACTIVE_CONNECTION_INT_SUBJECT "int-subject"
#define NM_ACTIVE_CONNECTION_INT_MASTER "int-master"
#define NM_ACTIVE_CONNECTION_INT_MASTER_READY "int-master-ready"
#define NM_ACTIVE_CONNECTION_INT_ACTIVATION_TYPE "int-activation-type"
/* Internal signals*/
#define NM_ACTIVE_CONNECTION_DEVICE_CHANGED "device-changed"
......@@ -158,10 +159,7 @@ void nm_active_connection_set_master (NMActiveConnection *self,
void nm_active_connection_set_parent (NMActiveConnection *self,
NMActiveConnection *parent);
void nm_active_connection_set_assumed (NMActiveConnection *self,
gboolean assumed);
gboolean nm_active_connection_get_assumed (NMActiveConnection *self);
NMActivationType nm_active_connection_get_activation_type (NMActiveConnection *self);
void nm_active_connection_clear_secrets (NMActiveConnection *self);
......
......@@ -281,6 +281,7 @@ activate:
NULL,
device,
subject,
NM_ACTIVATION_TYPE_MANAGED,
&local_error)) {
_LOGW ("rollback: reactivation of connection %s/%s failed: %s",
nm_connection_get_id ((NMConnection *) connection),
......
......@@ -105,8 +105,7 @@ update_state (NMConnectivity *self, NMConnectivityState state)
priv->state = state;
_notify (self, PROP_STATE);
/* Notify dispatcher scripts of a connectivity state change */
nm_dispatcher_call_connectivity (DISPATCHER_ACTION_CONNECTIVITY_CHANGE, state);
nm_dispatcher_call_connectivity (state, NULL, NULL, NULL);
}
}
......
......@@ -4339,3 +4339,12 @@ nm_utils_format_con_diff_for_audit (GHashTable *diff)
return g_string_free (str, FALSE);
}
/*****************************************************************************/
NM_UTILS_LOOKUP_STR_DEFINE (nm_activation_type_to_string, NMActivationType,
NM_UTILS_LOOKUP_DEFAULT_WARN ("(unknown)"),
NM_UTILS_LOOKUP_STR_ITEM (NM_ACTIVATION_TYPE_MANAGED, "managed"),
NM_UTILS_LOOKUP_STR_ITEM (NM_ACTIVATION_TYPE_ASSUME, "assume"),
NM_UTILS_LOOKUP_STR_ITEM (NM_ACTIVATION_TYPE_EXTERNAL, "external"),
)
......@@ -472,4 +472,10 @@ char **nm_utils_read_plugin_paths (const char *dirname, const char *prefix);
char *nm_utils_format_con_diff_for_audit (GHashTable *diff);
/*****************************************************************************/
const char *nm_activation_type_to_string (NMActivationType activation_type);
/*****************************************************************************/
#endif /* __NM_CORE_UTILS_H__ */
This diff is collapsed.
......@@ -19,44 +19,44 @@
* Copyright (C) 2005 - 2008 Novell, Inc.
*/
#ifndef __NETWORKMANAGER_DISPATCHER_H__
#define __NETWORKMANAGER_DISPATCHER_H__
#include <stdio.h>
#ifndef __NM_DISPATCHER_H__
#define __NM_DISPATCHER_H__
#include "nm-connection.h"
typedef enum {
DISPATCHER_ACTION_HOSTNAME,
DISPATCHER_ACTION_PRE_UP,
DISPATCHER_ACTION_UP,
DISPATCHER_ACTION_PRE_DOWN,
DISPATCHER_ACTION_DOWN,
DISPATCHER_ACTION_VPN_PRE_UP,
DISPATCHER_ACTION_VPN_UP,
DISPATCHER_ACTION_VPN_PRE_DOWN,
DISPATCHER_ACTION_VPN_DOWN,
DISPATCHER_ACTION_DHCP4_CHANGE,
DISPATCHER_ACTION_DHCP6_CHANGE,
DISPATCHER_ACTION_CONNECTIVITY_CHANGE
} DispatcherAction;
NM_DISPATCHER_ACTION_HOSTNAME,
NM_DISPATCHER_ACTION_PRE_UP,
NM_DISPATCHER_ACTION_UP,
NM_DISPATCHER_ACTION_PRE_DOWN,
NM_DISPATCHER_ACTION_DOWN,
NM_DISPATCHER_ACTION_VPN_PRE_UP,
NM_DISPATCHER_ACTION_VPN_UP,
NM_DISPATCHER_ACTION_VPN_PRE_DOWN,
NM_DISPATCHER_ACTION_VPN_DOWN,
NM_DISPATCHER_ACTION_DHCP4_CHANGE,
NM_DISPATCHER_ACTION_DHCP6_CHANGE,
NM_DISPATCHER_ACTION_CONNECTIVITY_CHANGE
} NMDispatcherAction;
typedef void (*NMDispatcherFunc) (guint call_id, gpointer user_data);
typedef void (*DispatcherFunc) (guint call_id, gpointer user_data);
gboolean nm_dispatcher_call_hostname (NMDispatcherFunc callback,
gpointer user_data,
guint *out_call_id);
gboolean nm_dispatcher_call (DispatcherAction action,
NMSettingsConnection *settings_connection,
NMConnection *applied_connection,
NMDevice *device,
DispatcherFunc callback,
gpointer user_data,
guint *out_call_id);
gboolean nm_dispatcher_call_device (NMDispatcherAction action,
NMDevice *device,
NMActRequest *act_request,
NMDispatcherFunc callback,
gpointer user_data,
guint *out_call_id);
gboolean nm_dispatcher_call_sync (DispatcherAction action,
NMSettingsConnection *settings_connection,
NMConnection *applied_connection,
NMDevice *device);
gboolean nm_dispatcher_call_device_sync (NMDispatcherAction action,
NMDevice *device,
NMActRequest *act_request);
gboolean nm_dispatcher_call_vpn (DispatcherAction action,
gboolean nm_dispatcher_call_vpn (NMDispatcherAction action,
NMSettingsConnection *settings_connection,
NMConnection *applied_connection,
NMDevice *parent_device,
......@@ -64,11 +64,11 @@ gboolean nm_dispatcher_call_vpn (DispatcherAction action,
NMProxyConfig *vpn_proxy_config,
NMIP4Config *vpn_ip4_config,
NMIP6Config *vpn_ip6_config,
DispatcherFunc callback,
NMDispatcherFunc callback,
gpointer user_data,
guint *out_call_id);
gboolean nm_dispatcher_call_vpn_sync (DispatcherAction action,
gboolean nm_dispatcher_call_vpn_sync (NMDispatcherAction action,
NMSettingsConnection *settings_connection,
NMConnection *applied_connection,
NMDevice *parent_device,
......@@ -77,11 +77,14 @@ gboolean nm_dispatcher_call_vpn_sync (DispatcherAction action,
NMIP4Config *vpn_ip4_config,
NMIP6Config *vpn_ip6_config);
gboolean nm_dispatcher_call_connectivity (DispatcherAction action,
NMConnectivityState state);
gboolean nm_dispatcher_call_connectivity (NMConnectivityState state,
NMDispatcherFunc callback,
gpointer user_data,
guint *out_call_id);
void nm_dispatcher_call_cancel (guint call_id);
void nm_dispatcher_init (void);
#endif /* __NETWORKMANAGER_DISPATCHER_H__ */
#endif /* __NM_DISPATCHER_H__ */
This diff is collapsed.
......@@ -115,6 +115,7 @@ NMActiveConnection *nm_manager_activate_connection (NMManager *manager,
const char *specific_object,
NMDevice *device,
NMAuthSubject *subject,
NMActivationType activation_type,
GError **error);
gboolean nm_manager_deactivate_connection (NMManager *manager,
......
......@@ -428,7 +428,7 @@ settings_set_hostname_cb (const char *hostname,
}
if (!ret)
nm_dispatcher_call (DISPATCHER_ACTION_HOSTNAME, NULL, NULL, NULL, NULL, NULL, NULL);
nm_dispatcher_call_hostname (NULL, NULL, NULL);
}
static void
......@@ -1023,6 +1023,7 @@ auto_activate_device (NMPolicy *self,
specific_object,
device,
subject,
NM_ACTIVATION_TYPE_MANAGED,
&error)) {
_LOGI (LOGD_DEVICE, "connection '%s' auto-activation failed: (%d) %s",
nm_settings_connection_get_id (best_connection),
......@@ -1433,6 +1434,7 @@ activate_secondary_connections (NMPolicy *self,
nm_exported_object_get_path (NM_EXPORTED_OBJECT (req)),
device,
nm_active_connection_get_subject (NM_ACTIVE_CONNECTION (req)),
NM_ACTIVATION_TYPE_MANAGED,
&error);
if (ac)
secondary_ac_list = g_slist_append (secondary_ac_list, g_object_ref (ac));
......@@ -1846,6 +1848,7 @@ vpn_connection_retry_after_failure (NMVpnConnection *vpn, NMPolicy *self)
NULL,
NULL,
nm_active_connection_get_subject (ac),
NM_ACTIVATION_TYPE_MANAGED,
&error)) {
_LOGW (LOGD_DEVICE, "VPN '%s' reconnect failed: %s",
nm_settings_connection_get_id (connection),
......
......@@ -55,6 +55,22 @@ typedef struct _NMSleepMonitor NMSleepMonitor;
typedef struct _NMLldpListener NMLldpListener;
typedef struct _NMConfigDeviceStateData NMConfigDeviceStateData;
/*****************************************************************************/
typedef enum {
/* Do a full activation. */
NM_ACTIVATION_TYPE_MANAGED = 0,
/* gracefully/seamlessly take over the device. This leaves additional
* IP addresses and does not restore missing manual addresses. */
NM_ACTIVATION_TYPE_ASSUME = 1,
/* external activation. This device is not managed by NM, instead
* a in-memory connection is generated and NM pretends the device
* to be active, but it doesn't do anything really. */
NM_ACTIVATION_TYPE_EXTERNAL = 2,
} NMActivationType;
typedef enum {
/* In priority order; higher number == higher priority */
......