diff options
| author | Michael Biebl <biebl@debian.org> | 2019-03-26 23:25:23 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2019-03-26 23:25:23 +0100 |
| commit | 9a6dcbf895f9da01768e64b73cec88c16157d91e (patch) | |
| tree | a359958930d731e9f1b59344642e10754419fe84 /libnm-core/nm-setting-ip4-config.c | |
| parent | 964ae8cc391520440cf5aa13e2b9cc34850ea6c2 (diff) | |
New upstream version 1.16.0 upstream/1.16.0
Diffstat (limited to 'libnm-core/nm-setting-ip4-config.c')
| -rw-r--r-- | libnm-core/nm-setting-ip4-config.c | 229 |
1 files changed, 120 insertions, 109 deletions
diff --git a/libnm-core/nm-setting-ip4-config.c b/libnm-core/nm-setting-ip4-config.c index 36765484..dd3b79b7 100644 --- a/libnm-core/nm-setting-ip4-config.c +++ b/libnm-core/nm-setting-ip4-config.c @@ -21,9 +21,8 @@ #include "nm-default.h" -#include <string.h> - #include "nm-setting-ip4-config.h" + #include "nm-setting-private.h" /** @@ -50,35 +49,23 @@ * connection. **/ -G_DEFINE_TYPE (NMSettingIP4Config, nm_setting_ip4_config, NM_TYPE_SETTING_IP_CONFIG) +/*****************************************************************************/ -#define NM_SETTING_IP4_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_IP4_CONFIG, NMSettingIP4ConfigPrivate)) +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_DHCP_CLIENT_ID, + PROP_DHCP_FQDN, +); typedef struct { char *dhcp_client_id; char *dhcp_fqdn; } NMSettingIP4ConfigPrivate; -enum { - PROP_0, - PROP_DHCP_CLIENT_ID, - PROP_DHCP_FQDN, +G_DEFINE_TYPE (NMSettingIP4Config, nm_setting_ip4_config, NM_TYPE_SETTING_IP_CONFIG) - LAST_PROP -}; +#define NM_SETTING_IP4_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_IP4_CONFIG, NMSettingIP4ConfigPrivate)) -/** - * nm_setting_ip4_config_new: - * - * Creates a new #NMSettingIP4Config object with default values. - * - * Returns: (transfer full): the new empty #NMSettingIP4Config object - **/ -NMSetting * -nm_setting_ip4_config_new (void) -{ - return (NMSetting *) g_object_new (NM_TYPE_SETTING_IP4_CONFIG, NULL); -} +/*****************************************************************************/ /** * nm_setting_ip4_config_get_dhcp_client_id: @@ -252,62 +239,6 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) return TRUE; } -static void -nm_setting_ip4_config_init (NMSettingIP4Config *setting) -{ -} - -static void -finalize (GObject *object) -{ - NMSettingIP4ConfigPrivate *priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (object); - - g_free (priv->dhcp_client_id); - g_free (priv->dhcp_fqdn); - - G_OBJECT_CLASS (nm_setting_ip4_config_parent_class)->finalize (object); -} - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - NMSettingIP4ConfigPrivate *priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_DHCP_CLIENT_ID: - g_free (priv->dhcp_client_id); - priv->dhcp_client_id = g_value_dup_string (value); - break; - case PROP_DHCP_FQDN: - g_free (priv->dhcp_fqdn); - priv->dhcp_fqdn = g_value_dup_string (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - NMSettingIP4Config *s_ip4 = NM_SETTING_IP4_CONFIG (object); - - switch (prop_id) { - case PROP_DHCP_CLIENT_ID: - g_value_set_string (value, nm_setting_ip4_config_get_dhcp_client_id (s_ip4)); - break; - case PROP_DHCP_FQDN: - g_value_set_string (value, nm_setting_ip4_config_get_dhcp_fqdn (s_ip4)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - static GVariant * ip4_dns_to_dbus (const GValue *prop_value) { @@ -376,9 +307,11 @@ ip4_addresses_set (NMSetting *setting, } static GVariant * -ip4_address_labels_get (NMSetting *setting, +ip4_address_labels_get (const NMSettInfoSetting *sett_info, + guint property_idx, NMConnection *connection, - const char *property) + NMSetting *setting, + NMConnectionSerializationFlags flags) { NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG (setting); gboolean have_labels = FALSE; @@ -386,6 +319,9 @@ ip4_address_labels_get (NMSetting *setting, GVariant *ret; int num_addrs, i; + if (flags & NM_CONNECTION_SERIALIZE_ONLY_SECRETS) + return NULL; + num_addrs = nm_setting_ip_config_get_num_addresses (s_ip); for (i = 0; i < num_addrs; i++) { NMIPAddress *addr = nm_setting_ip_config_get_address (s_ip, i); @@ -414,18 +350,19 @@ ip4_address_labels_get (NMSetting *setting, } static GVariant * -ip4_address_data_get (NMSetting *setting, +ip4_address_data_get (const NMSettInfoSetting *sett_info, + guint property_idx, NMConnection *connection, - const char *property) + NMSetting *setting, + NMConnectionSerializationFlags flags) { - GPtrArray *addrs; - GVariant *ret; + gs_unref_ptrarray GPtrArray *addrs = NULL; - g_object_get (setting, NM_SETTING_IP_CONFIG_ADDRESSES, &addrs, NULL); - ret = nm_utils_ip_addresses_to_variant (addrs); - g_ptr_array_unref (addrs); + if (flags & NM_CONNECTION_SERIALIZE_ONLY_SECRETS) + return NULL; - return ret; + g_object_get (setting, NM_SETTING_IP_CONFIG_ADDRESSES, &addrs, NULL); + return nm_utils_ip_addresses_to_variant (addrs); } static gboolean @@ -486,18 +423,19 @@ ip4_routes_set (NMSetting *setting, } static GVariant * -ip4_route_data_get (NMSetting *setting, +ip4_route_data_get (const NMSettInfoSetting *sett_info, + guint property_idx, NMConnection *connection, - const char *property) + NMSetting *setting, + NMConnectionSerializationFlags flags) { - GPtrArray *routes; - GVariant *ret; + gs_unref_ptrarray GPtrArray *routes = NULL; - g_object_get (setting, NM_SETTING_IP_CONFIG_ROUTES, &routes, NULL); - ret = nm_utils_ip_routes_to_variant (routes); - g_ptr_array_unref (routes); + if (flags & NM_CONNECTION_SERIALIZE_ONLY_SECRETS) + return NULL; - return ret; + g_object_get (setting, NM_SETTING_IP_CONFIG_ROUTES, &routes, NULL); + return nm_utils_ip_routes_to_variant (routes); } static gboolean @@ -522,6 +460,79 @@ ip4_route_data_set (NMSetting *setting, return TRUE; } +/*****************************************************************************/ + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + NMSettingIP4Config *s_ip4 = NM_SETTING_IP4_CONFIG (object); + + switch (prop_id) { + case PROP_DHCP_CLIENT_ID: + g_value_set_string (value, nm_setting_ip4_config_get_dhcp_client_id (s_ip4)); + break; + case PROP_DHCP_FQDN: + g_value_set_string (value, nm_setting_ip4_config_get_dhcp_fqdn (s_ip4)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + NMSettingIP4ConfigPrivate *priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (object); + + switch (prop_id) { + case PROP_DHCP_CLIENT_ID: + g_free (priv->dhcp_client_id); + priv->dhcp_client_id = g_value_dup_string (value); + break; + case PROP_DHCP_FQDN: + g_free (priv->dhcp_fqdn); + priv->dhcp_fqdn = g_value_dup_string (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +/*****************************************************************************/ + +static void +nm_setting_ip4_config_init (NMSettingIP4Config *setting) +{ +} + +/** + * nm_setting_ip4_config_new: + * + * Creates a new #NMSettingIP4Config object with default values. + * + * Returns: (transfer full): the new empty #NMSettingIP4Config object + **/ +NMSetting * +nm_setting_ip4_config_new (void) +{ + return (NMSetting *) g_object_new (NM_TYPE_SETTING_IP4_CONFIG, NULL); +} + +static void +finalize (GObject *object) +{ + NMSettingIP4ConfigPrivate *priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (object); + + g_free (priv->dhcp_client_id); + g_free (priv->dhcp_fqdn); + + G_OBJECT_CLASS (nm_setting_ip4_config_parent_class)->finalize (object); +} + static void nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *klass) { @@ -531,8 +542,8 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *klass) g_type_class_add_private (setting_class, sizeof (NMSettingIP4ConfigPrivate)); - 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; @@ -740,12 +751,11 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *klass) * example: DHCP_CLIENT_ID=ax-srv-1; DHCP_CLIENT_ID=01:44:44:44:44:44:44 * ---end--- */ - g_object_class_install_property - (object_class, PROP_DHCP_CLIENT_ID, - g_param_spec_string (NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, "", "", - NULL, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS)); + obj_properties[PROP_DHCP_CLIENT_ID] = + g_param_spec_string (NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, "", "", + NULL, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); /* ---ifcfg-rh--- * property: dad-timeout @@ -784,12 +794,11 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *klass) * example: DHCP_FQDN=foo.bar.com * ---end--- */ - g_object_class_install_property - (object_class, PROP_DHCP_FQDN, - g_param_spec_string (NM_SETTING_IP4_CONFIG_DHCP_FQDN, "", "", - NULL, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS)); + obj_properties[PROP_DHCP_FQDN] = + g_param_spec_string (NM_SETTING_IP4_CONFIG_DHCP_FQDN, "", "", + NULL, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); /* IP4-specific property overrides */ @@ -895,6 +904,8 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *klass) ip4_route_data_get, ip4_route_data_set); + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); + _nm_setting_class_commit_full (setting_class, NM_META_SETTING_TYPE_IP4_CONFIG, NULL, properties_override); } |