mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-03-21 18:00:38 +01:00
2008-02-20 Dan Williams <dcbw@redhat.com>
* libnm-util/nm-connection.c libnm-util/nm-connection.h - (nm_connection_compare): accept compare flags and pass them to the setting compare function * libnm-util/nm-setting.c libnm-util/nm-setting.h - (nm_setting_compare): accept compare flags; ignore properties that are marked fuzzy * libnm-util/nm-setting-connection.c libnm-util/nm-setting-wireless.c libnm-util/nm-setting-ppp.c libnm-util/nm-setting-wired.c - Mark some setting properties as ignorable when doing a fuzzy compare * src/nm-device.c - (device_activation_precheck): use exact compare git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3336 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
f53230715e
commit
316abd62fd
10 changed files with 69 additions and 23 deletions
21
ChangeLog
21
ChangeLog
|
|
@ -1,3 +1,24 @@
|
|||
2008-02-20 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* libnm-util/nm-connection.c
|
||||
libnm-util/nm-connection.h
|
||||
- (nm_connection_compare): accept compare flags and pass them to the
|
||||
setting compare function
|
||||
|
||||
* libnm-util/nm-setting.c
|
||||
libnm-util/nm-setting.h
|
||||
- (nm_setting_compare): accept compare flags; ignore properties that are
|
||||
marked fuzzy
|
||||
|
||||
* libnm-util/nm-setting-connection.c
|
||||
libnm-util/nm-setting-wireless.c
|
||||
libnm-util/nm-setting-ppp.c
|
||||
libnm-util/nm-setting-wired.c
|
||||
- Mark some setting properties as ignorable when doing a fuzzy compare
|
||||
|
||||
* src/nm-device.c
|
||||
- (device_activation_precheck): use exact compare
|
||||
|
||||
2008-02-20 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* src/NetworkManagerPolicy.c
|
||||
|
|
|
|||
|
|
@ -205,6 +205,7 @@ nm_connection_replace_settings (NMConnection *connection,
|
|||
typedef struct {
|
||||
NMConnection *other;
|
||||
gboolean failed;
|
||||
NMSettingCompareFlags flags;
|
||||
} CompareConnectionInfo;
|
||||
|
||||
static void
|
||||
|
|
@ -219,16 +220,18 @@ compare_one_setting (gpointer key, gpointer value, gpointer user_data)
|
|||
|
||||
other_setting = nm_connection_get_setting (info->other, G_OBJECT_TYPE (setting));
|
||||
if (other_setting)
|
||||
info->failed = nm_setting_compare (setting, other_setting) ? FALSE : TRUE;
|
||||
info->failed = nm_setting_compare (setting, other_setting, info->flags) ? FALSE : TRUE;
|
||||
else
|
||||
info->failed = TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_connection_compare (NMConnection *connection, NMConnection *other)
|
||||
nm_connection_compare (NMConnection *connection,
|
||||
NMConnection *other,
|
||||
NMSettingCompareFlags flags)
|
||||
{
|
||||
NMConnectionPrivate *priv;
|
||||
CompareConnectionInfo info = { other, FALSE };
|
||||
CompareConnectionInfo info = { other, FALSE, flags };
|
||||
|
||||
if (!connection && !other)
|
||||
return TRUE;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,8 @@ gboolean nm_connection_replace_settings (NMConnection *connection,
|
|||
GHashTable *new_settings);
|
||||
|
||||
gboolean nm_connection_compare (NMConnection *connection,
|
||||
NMConnection *other);
|
||||
NMConnection *other,
|
||||
NMSettingCompareFlags flags);
|
||||
|
||||
gboolean nm_connection_verify (NMConnection *connection);
|
||||
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
|
|||
"ID",
|
||||
"User-readable connection identifier/name",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_TYPE,
|
||||
|
|
@ -160,7 +160,7 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
|
|||
"Autoconnect",
|
||||
"Connection autoconnect",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_TIMESTAMP,
|
||||
|
|
@ -168,7 +168,7 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
|
|||
"Timestamp",
|
||||
"Connection timestamp",
|
||||
0, G_MAXUINT64, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_LOCKDOWN,
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"No BSD compression",
|
||||
"No BSD compression",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_NODEFLATE,
|
||||
|
|
@ -234,7 +234,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"No deflate",
|
||||
"No deflate",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_REQUIRE_MPPE,
|
||||
|
|
@ -290,7 +290,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"Baud",
|
||||
"Baud",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_MRU,
|
||||
|
|
@ -306,7 +306,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"MTU",
|
||||
"MTU",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_LCP_ECHO_FAILURE,
|
||||
|
|
@ -314,7 +314,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"LCP echo failure",
|
||||
"LCP echo failure",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_LCP_ECHO_INTERVAL,
|
||||
|
|
@ -322,5 +322,5 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"LCP echo interval",
|
||||
"LCP echo interval",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -195,6 +195,6 @@ nm_setting_wired_class_init (NMSettingWiredClass *setting_class)
|
|||
"MTU",
|
||||
"MTU",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | G_PARAM_CONSTRUCT));
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -475,7 +475,7 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class)
|
|||
"Rate",
|
||||
"Rate",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_TX_POWER,
|
||||
|
|
@ -483,7 +483,7 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class)
|
|||
"TX Power",
|
||||
"TX Power",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_MAC_ADDRESS,
|
||||
|
|
@ -507,7 +507,7 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class)
|
|||
"MTU",
|
||||
"MTU",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_SEC,
|
||||
|
|
|
|||
|
|
@ -144,7 +144,9 @@ nm_setting_verify (NMSetting *setting, GSList *all_settings)
|
|||
}
|
||||
|
||||
gboolean
|
||||
nm_setting_compare (NMSetting *setting, NMSetting *other)
|
||||
nm_setting_compare (NMSetting *setting,
|
||||
NMSetting *other,
|
||||
NMSettingCompareFlags flags)
|
||||
{
|
||||
GParamSpec **property_specs;
|
||||
guint n_property_specs;
|
||||
|
|
@ -167,6 +169,13 @@ nm_setting_compare (NMSetting *setting, NMSetting *other)
|
|||
GValue value1 = { 0 };
|
||||
GValue value2 = { 0 };
|
||||
|
||||
/* Fuzzy compare ignores properties defined with the FUZZY_IGNORE flag */
|
||||
if ( (flags & COMPARE_FLAGS_FUZZY)
|
||||
&& (prop_spec->flags & NM_SETTING_PARAM_FUZZY_IGNORE)) {
|
||||
different = TRUE;
|
||||
continue;
|
||||
}
|
||||
|
||||
g_value_init (&value1, prop_spec->value_type);
|
||||
g_object_get_property (G_OBJECT (setting), prop_spec->name, &value1);
|
||||
|
||||
|
|
|
|||
|
|
@ -15,9 +15,10 @@ G_BEGIN_DECLS
|
|||
#define NM_IS_SETTING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_SETTING))
|
||||
#define NM_SETTING_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING, NMSettingClass))
|
||||
|
||||
#define NM_SETTING_PARAM_SERIALIZE (1 << (0 + G_PARAM_USER_SHIFT))
|
||||
#define NM_SETTING_PARAM_REQUIRED (1 << (1 + G_PARAM_USER_SHIFT))
|
||||
#define NM_SETTING_PARAM_SECRET (1 << (2 + G_PARAM_USER_SHIFT))
|
||||
#define NM_SETTING_PARAM_SERIALIZE (1 << (0 + G_PARAM_USER_SHIFT))
|
||||
#define NM_SETTING_PARAM_REQUIRED (1 << (1 + G_PARAM_USER_SHIFT))
|
||||
#define NM_SETTING_PARAM_SECRET (1 << (2 + G_PARAM_USER_SHIFT))
|
||||
#define NM_SETTING_PARAM_FUZZY_IGNORE (1 << (3 + G_PARAM_USER_SHIFT))
|
||||
|
||||
#define NM_SETTING_NAME "name"
|
||||
|
||||
|
|
@ -59,8 +60,18 @@ const char *nm_setting_get_name (NMSetting *setting);
|
|||
gboolean nm_setting_verify (NMSetting *setting,
|
||||
GSList *all_settings);
|
||||
|
||||
|
||||
typedef enum {
|
||||
/* Match all attributes exactly */
|
||||
COMPARE_FLAGS_EXACT = 0x00,
|
||||
|
||||
/* Match only important attributes, like SSID, type, security settings, etc */
|
||||
COMPARE_FLAGS_FUZZY = 0x01,
|
||||
} NMSettingCompareFlags;
|
||||
|
||||
gboolean nm_setting_compare (NMSetting *setting,
|
||||
NMSetting *other);
|
||||
NMSetting *other,
|
||||
NMSettingCompareFlags flags);
|
||||
|
||||
void nm_setting_enumerate_values (NMSetting *setting,
|
||||
NMSettingValueIterFn func,
|
||||
|
|
|
|||
|
|
@ -1154,8 +1154,9 @@ device_activation_precheck (NMDevice *self, NMConnection *connection, GError **e
|
|||
if (!nm_device_is_activating (self))
|
||||
return TRUE;
|
||||
|
||||
// FIXME: why not just check connection path & service?
|
||||
current_connection = nm_act_request_get_connection (nm_device_get_act_request (self));
|
||||
if (nm_connection_compare (connection, current_connection)) {
|
||||
if (nm_connection_compare (connection, current_connection, COMPARE_FLAGS_EXACT)) {
|
||||
/* Already activating or activated with the same connection */
|
||||
g_set_error (error,
|
||||
NM_DEVICE_INTERFACE_ERROR,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue