diff options
Diffstat (limited to 'libnm-core/nm-setting-vlan.c')
| -rw-r--r-- | libnm-core/nm-setting-vlan.c | 221 |
1 files changed, 111 insertions, 110 deletions
diff --git a/libnm-core/nm-setting-vlan.c b/libnm-core/nm-setting-vlan.c index 1b61da55..5b8a49d4 100644 --- a/libnm-core/nm-setting-vlan.c +++ b/libnm-core/nm-setting-vlan.c @@ -24,7 +24,6 @@ #include "nm-setting-vlan.h" #include <stdlib.h> -#include <string.h> #include "nm-utils.h" #include "nm-core-types-internal.h" @@ -41,9 +40,15 @@ * necessary for connection to VLAN interfaces. **/ -G_DEFINE_TYPE (NMSettingVlan, nm_setting_vlan, NM_TYPE_SETTING) +/*****************************************************************************/ -#define NM_SETTING_VLAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_VLAN, NMSettingVlanPrivate)) +NM_GOBJECT_PROPERTIES_DEFINE (NMSettingVlan, + PROP_PARENT, + PROP_ID, + PROP_FLAGS, + PROP_INGRESS_PRIORITY_MAP, + PROP_EGRESS_PRIORITY_MAP, +); typedef struct { char *parent; @@ -53,33 +58,16 @@ typedef struct { GSList *egress_priority_map; } NMSettingVlanPrivate; -enum { - PROP_0, - PROP_PARENT, - PROP_ID, - PROP_FLAGS, - PROP_INGRESS_PRIORITY_MAP, - PROP_EGRESS_PRIORITY_MAP, - LAST_PROP -}; +G_DEFINE_TYPE (NMSettingVlan, nm_setting_vlan, NM_TYPE_SETTING) + +#define NM_SETTING_VLAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_VLAN, NMSettingVlanPrivate)) + +/*****************************************************************************/ #define MAX_SKB_PRIO G_MAXUINT32 #define MAX_8021P_PRIO 7 /* Max 802.1p priority */ /** - * nm_setting_vlan_new: - * - * Creates a new #NMSettingVlan object with default values. - * - * Returns: (transfer full): the new empty #NMSettingVlan object - **/ -NMSetting * -nm_setting_vlan_new (void) -{ - return (NMSetting *) g_object_new (NM_TYPE_SETTING_VLAN, NULL); -} - -/** * nm_setting_vlan_get_parent: * @setting: the #NMSettingVlan * @@ -214,10 +202,10 @@ set_map (NMSettingVlan *self, NMVlanPriorityMap map, GSList *list) if (map == NM_VLAN_INGRESS_MAP) { NM_SETTING_VLAN_GET_PRIVATE (self)->ingress_priority_map = list; - g_object_notify (G_OBJECT (self), NM_SETTING_VLAN_INGRESS_PRIORITY_MAP); + _notify (self, PROP_INGRESS_PRIORITY_MAP); } else if (map == NM_VLAN_EGRESS_MAP) { NM_SETTING_VLAN_GET_PRIVATE (self)->egress_priority_map = list; - g_object_notify (G_OBJECT (self), NM_SETTING_VLAN_EGRESS_PRIORITY_MAP); + _notify (self, PROP_EGRESS_PRIORITY_MAP); } else g_assert_not_reached (); } @@ -273,9 +261,9 @@ nm_setting_vlan_add_priority_str (NMSettingVlan *setting, if (check_replace_duplicate_priority (list, item->from, item->to)) { g_free (item); if (map == NM_VLAN_INGRESS_MAP) - g_object_notify (G_OBJECT (setting), NM_SETTING_VLAN_INGRESS_PRIORITY_MAP); + _notify (setting, PROP_INGRESS_PRIORITY_MAP); else - g_object_notify (G_OBJECT (setting), NM_SETTING_VLAN_EGRESS_PRIORITY_MAP); + _notify (setting, PROP_EGRESS_PRIORITY_MAP); return TRUE; } @@ -377,9 +365,9 @@ nm_setting_vlan_add_priority (NMSettingVlan *setting, list = get_map (setting, map); if (check_replace_duplicate_priority (list, from, to)) { if (map == NM_VLAN_INGRESS_MAP) - g_object_notify (G_OBJECT (setting), NM_SETTING_VLAN_INGRESS_PRIORITY_MAP); + _notify (setting, PROP_INGRESS_PRIORITY_MAP); else - g_object_notify (G_OBJECT (setting), NM_SETTING_VLAN_EGRESS_PRIORITY_MAP); + _notify (setting, PROP_EGRESS_PRIORITY_MAP); return TRUE; } @@ -593,11 +581,6 @@ nm_setting_vlan_clear_priorities (NMSettingVlan *setting, NMVlanPriorityMap map) /*****************************************************************************/ -static void -nm_setting_vlan_init (NMSettingVlan *setting) -{ -} - static int verify (NMSetting *setting, NMConnection *connection, GError **error) { @@ -736,38 +719,6 @@ priority_strv_to_maplist (NMVlanPriorityMap map, char **strv) return g_slist_sort (list, prio_map_compare); } -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - NMSettingVlan *setting = NM_SETTING_VLAN (object); - NMSettingVlanPrivate *priv = NM_SETTING_VLAN_GET_PRIVATE (setting); - - switch (prop_id) { - case PROP_PARENT: - g_free (priv->parent); - priv->parent = g_value_dup_string (value); - break; - case PROP_ID: - priv->id = g_value_get_uint (value); - break; - case PROP_FLAGS: - priv->flags = g_value_get_flags (value); - break; - case PROP_INGRESS_PRIORITY_MAP: - g_slist_free_full (priv->ingress_priority_map, g_free); - priv->ingress_priority_map = priority_strv_to_maplist (NM_VLAN_INGRESS_MAP, g_value_get_boxed (value)); - break; - case PROP_EGRESS_PRIORITY_MAP: - g_slist_free_full (priv->egress_priority_map, g_free); - priv->egress_priority_map = priority_strv_to_maplist (NM_VLAN_EGRESS_MAP, g_value_get_boxed (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - static char ** priority_maplist_to_strv (GSList *list) { @@ -786,6 +737,8 @@ priority_maplist_to_strv (GSList *list) return (char **) g_ptr_array_free (strv, FALSE); } +/*****************************************************************************/ + static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) @@ -816,6 +769,58 @@ get_property (GObject *object, guint prop_id, } static void +set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + NMSettingVlan *setting = NM_SETTING_VLAN (object); + NMSettingVlanPrivate *priv = NM_SETTING_VLAN_GET_PRIVATE (setting); + + switch (prop_id) { + case PROP_PARENT: + g_free (priv->parent); + priv->parent = g_value_dup_string (value); + break; + case PROP_ID: + priv->id = g_value_get_uint (value); + break; + case PROP_FLAGS: + priv->flags = g_value_get_flags (value); + break; + case PROP_INGRESS_PRIORITY_MAP: + g_slist_free_full (priv->ingress_priority_map, g_free); + priv->ingress_priority_map = priority_strv_to_maplist (NM_VLAN_INGRESS_MAP, g_value_get_boxed (value)); + break; + case PROP_EGRESS_PRIORITY_MAP: + g_slist_free_full (priv->egress_priority_map, g_free); + priv->egress_priority_map = priority_strv_to_maplist (NM_VLAN_EGRESS_MAP, g_value_get_boxed (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +/*****************************************************************************/ + +static void +nm_setting_vlan_init (NMSettingVlan *setting) +{ +} + +/** + * nm_setting_vlan_new: + * + * Creates a new #NMSettingVlan object with default values. + * + * Returns: (transfer full): the new empty #NMSettingVlan object + **/ +NMSetting * +nm_setting_vlan_new (void) +{ + return (NMSetting *) g_object_new (NM_TYPE_SETTING_VLAN, NULL); +} + +static void finalize (GObject *object) { NMSettingVlan *setting = NM_SETTING_VLAN (object); @@ -837,8 +842,8 @@ nm_setting_vlan_class_init (NMSettingVlanClass *klass) g_type_class_add_private (klass, sizeof (NMSettingVlanPrivate)); - object_class->set_property = set_property; object_class->get_property = get_property; + object_class->set_property = set_property; object_class->finalize = finalize; setting_class->verify = verify; @@ -857,14 +862,13 @@ nm_setting_vlan_class_init (NMSettingVlanClass *klass) * description: Parent interface of the VLAN. * ---end--- */ - g_object_class_install_property - (object_class, PROP_PARENT, - g_param_spec_string (NM_SETTING_VLAN_PARENT, "", "", - NULL, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT | - NM_SETTING_PARAM_INFERRABLE | - G_PARAM_STATIC_STRINGS)); + obj_properties[PROP_PARENT] = + g_param_spec_string (NM_SETTING_VLAN_PARENT, "", "", + NULL, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT | + NM_SETTING_PARAM_INFERRABLE | + G_PARAM_STATIC_STRINGS); /** * NMSettingVlan:id: @@ -878,14 +882,13 @@ nm_setting_vlan_class_init (NMSettingVlanClass *klass) * description: VLAN identifier. * ---end--- */ - g_object_class_install_property - (object_class, PROP_ID, - g_param_spec_uint (NM_SETTING_VLAN_ID, "", "", - 0, 4095, 0, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT | - NM_SETTING_PARAM_INFERRABLE | - G_PARAM_STATIC_STRINGS)); + obj_properties[PROP_ID] = + g_param_spec_uint (NM_SETTING_VLAN_ID, "", "", + 0, 4095, 0, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT | + NM_SETTING_PARAM_INFERRABLE | + G_PARAM_STATIC_STRINGS); /** * NMSettingVlan:flags: @@ -909,19 +912,17 @@ nm_setting_vlan_class_init (NMSettingVlanClass *klass) * description: VLAN flags. * ---end--- */ - g_object_class_install_property - (object_class, PROP_FLAGS, - g_param_spec_flags (NM_SETTING_VLAN_FLAGS, "", "", - NM_TYPE_VLAN_FLAGS, - NM_VLAN_FLAG_REORDER_HEADERS, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT | - NM_SETTING_PARAM_INFERRABLE | - G_PARAM_STATIC_STRINGS)); + obj_properties[PROP_FLAGS] = + g_param_spec_flags (NM_SETTING_VLAN_FLAGS, "", "", + NM_TYPE_VLAN_FLAGS, + NM_VLAN_FLAG_REORDER_HEADERS, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT | + NM_SETTING_PARAM_INFERRABLE | + G_PARAM_STATIC_STRINGS); _properties_override_add_override (properties_override, - g_object_class_find_property (G_OBJECT_CLASS (setting_class), - NM_SETTING_VLAN_FLAGS), + obj_properties[PROP_FLAGS], NULL, _override_flags_get, NULL, @@ -941,13 +942,12 @@ nm_setting_vlan_class_init (NMSettingVlanClass *klass) * example: VLAN_INGRESS_PRIORITY_MAP=4:2,3:5 * ---end--- */ - g_object_class_install_property - (object_class, PROP_INGRESS_PRIORITY_MAP, - g_param_spec_boxed (NM_SETTING_VLAN_INGRESS_PRIORITY_MAP, "", "", - G_TYPE_STRV, - G_PARAM_READWRITE | - NM_SETTING_PARAM_INFERRABLE | - G_PARAM_STATIC_STRINGS)); + obj_properties[PROP_INGRESS_PRIORITY_MAP] = + g_param_spec_boxed (NM_SETTING_VLAN_INGRESS_PRIORITY_MAP, "", "", + G_TYPE_STRV, + G_PARAM_READWRITE | + NM_SETTING_PARAM_INFERRABLE | + G_PARAM_STATIC_STRINGS); /** * NMSettingVlan:egress-priority-map: @@ -963,13 +963,12 @@ nm_setting_vlan_class_init (NMSettingVlanClass *klass) * example: VLAN_EGRESS_PRIORITY_MAP=5:4,4:1,3:7 * ---end--- */ - g_object_class_install_property - (object_class, PROP_EGRESS_PRIORITY_MAP, - g_param_spec_boxed (NM_SETTING_VLAN_EGRESS_PRIORITY_MAP, "", "", - G_TYPE_STRV, - G_PARAM_READWRITE | - NM_SETTING_PARAM_INFERRABLE | - G_PARAM_STATIC_STRINGS)); + obj_properties[PROP_EGRESS_PRIORITY_MAP] = + g_param_spec_boxed (NM_SETTING_VLAN_EGRESS_PRIORITY_MAP, "", "", + G_TYPE_STRV, + G_PARAM_READWRITE | + NM_SETTING_PARAM_INFERRABLE | + G_PARAM_STATIC_STRINGS); /* ---ifcfg-rh--- * property: interface-name @@ -993,6 +992,8 @@ nm_setting_vlan_class_init (NMSettingVlanClass *klass) _nm_setting_get_deprecated_virtual_interface_name, NULL); + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); + _nm_setting_class_commit_full (setting_class, NM_META_SETTING_TYPE_VLAN, NULL, properties_override); } |