summaryrefslogtreecommitdiff
path: root/libnm-core/nm-setting-ip6-config.c
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2014-10-21 08:33:18 -0400
committerDan Winship <danw@gnome.org>2014-11-07 07:49:40 -0500
commitd16905df633ceea08c93b6e982f660627d06ff34 (patch)
tree2578344aa6e4fcbfb0191c85880fbdc8d5845a0e /libnm-core/nm-setting-ip6-config.c
parentf17699f4e3dacb9358a8503c8b15efe3cb852b48 (diff)
downloadNetworkManager-d16905df633ceea08c93b6e982f660627d06ff34.tar.gz
libnm-core, libnm, core: add AddressData and RouteData properties
Add AddressData and RouteData properties to NMSettingIPConfig and NMIP[46]Config. These are like the existing "addresses" and "routes" properties, but using strings and containing additional attributes, like NMIPAddress and NMIPRoute. This only affects the D-Bus representations; there are no API changes to NMSettingIP{,4,6}Config or NMIP{4,6}Config as a result of this; the additional information is just added to the existing 'addresses' and 'routes' properties. NMSettingIP4Config and NMSettingIP6Config now always generate both old-style data ('addresses', 'address-labels', 'routes') and new-style data ('address-data', 'gateway', 'route-data') when serializing to D-Bus, for backward compatibility. When deserializing, they will fill in the 'addresses' and 'routes' properties from the new-style data if it is present (ignoring the old-style data), or from the old-style data if the new-style isn't present. The daemon-side NMIP4Config and NMIP6Config always emit changes for both 'Addresses'/'Routes' and 'AddressData'/'RouteData'. The libnm-side classes initially listen for changes on both properties, but start ignoring the 'Addresses' and 'Routes' properties once they know the daemon is also providing 'AddressData' and 'RouteData'.
Diffstat (limited to 'libnm-core/nm-setting-ip6-config.c')
-rw-r--r--libnm-core/nm-setting-ip6-config.c121
1 files changed, 109 insertions, 12 deletions
diff --git a/libnm-core/nm-setting-ip6-config.c b/libnm-core/nm-setting-ip6-config.c
index 9e3001157e..6e3ff6164e 100644
--- a/libnm-core/nm-setting-ip6-config.c
+++ b/libnm-core/nm-setting-ip6-config.c
@@ -214,9 +214,14 @@ ip6_addresses_set (NMSetting *setting,
GVariant *s_ip6;
char *gateway = NULL;
- addrs = nm_utils_ip6_addresses_from_variant (value, &gateway);
-
s_ip6 = g_variant_lookup_value (connection_dict, NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_VARIANT_TYPE_SETTING);
+ /* If 'address-data' is set then ignore 'addresses' */
+ if (g_variant_lookup (s_ip6, "address-data", "aa{sv}", NULL)) {
+ g_variant_unref (s_ip6);
+ return;
+ }
+
+ addrs = nm_utils_ip6_addresses_from_variant (value, &gateway);
if (gateway && !g_variant_lookup (s_ip6, "gateway", "s", NULL)) {
g_object_set (setting,
@@ -232,16 +237,95 @@ ip6_addresses_set (NMSetting *setting,
}
static GVariant *
-ip6_routes_to_dbus (const GValue *prop_value)
+ip6_address_data_get (NMSetting *setting,
+ NMConnection *connection,
+ const char *property)
+{
+ GPtrArray *addrs;
+ GVariant *ret;
+
+ g_object_get (setting, NM_SETTING_IP_CONFIG_ADDRESSES, &addrs, NULL);
+ ret = nm_utils_ip_addresses_to_variant (addrs);
+ g_ptr_array_unref (addrs);
+
+ return ret;
+}
+
+static void
+ip6_address_data_set (NMSetting *setting,
+ GVariant *connection_dict,
+ const char *property,
+ GVariant *value)
+{
+ GPtrArray *addrs;
+
+ addrs = nm_utils_ip_addresses_from_variant (value, AF_INET6);
+ g_object_set (setting, NM_SETTING_IP_CONFIG_ADDRESSES, addrs, NULL);
+ g_ptr_array_unref (addrs);
+}
+
+static GVariant *
+ip6_routes_get (NMSetting *setting,
+ const char *property)
+{
+ GPtrArray *routes;
+ GVariant *ret;
+
+ g_object_get (setting, property, &routes, NULL);
+ ret = nm_utils_ip6_routes_to_variant (routes);
+ g_ptr_array_unref (routes);
+
+ return ret;
+}
+
+static void
+ip6_routes_set (NMSetting *setting,
+ GVariant *connection_dict,
+ const char *property,
+ GVariant *value)
+{
+ GPtrArray *routes;
+ GVariant *s_ip6;
+
+ s_ip6 = g_variant_lookup_value (connection_dict, NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_VARIANT_TYPE_SETTING);
+ /* If 'route-data' is set then ignore 'routes' */
+ if (g_variant_lookup (s_ip6, "route-data", "aa{sv}", NULL)) {
+ g_variant_unref (s_ip6);
+ return;
+ }
+ g_variant_unref (s_ip6);
+
+ routes = nm_utils_ip6_routes_from_variant (value);
+ g_object_set (setting, property, routes, NULL);
+ g_ptr_array_unref (routes);
+}
+
+static GVariant *
+ip6_route_data_get (NMSetting *setting,
+ NMConnection *connection,
+ const char *property)
{
- return nm_utils_ip6_routes_to_variant (g_value_get_boxed (prop_value));
+ GPtrArray *routes;
+ GVariant *ret;
+
+ g_object_get (setting, NM_SETTING_IP_CONFIG_ROUTES, &routes, NULL);
+ ret = nm_utils_ip_routes_to_variant (routes);
+ g_ptr_array_unref (routes);
+
+ return ret;
}
static void
-ip6_routes_from_dbus (GVariant *dbus_value,
- GValue *prop_value)
+ip6_route_data_set (NMSetting *setting,
+ GVariant *connection_dict,
+ const char *property,
+ GVariant *value)
{
- g_value_take_boxed (prop_value, nm_utils_ip6_routes_from_variant (dbus_value));
+ GPtrArray *routes;
+
+ routes = nm_utils_ip_routes_from_variant (value, AF_INET6);
+ g_object_set (setting, NM_SETTING_IP_CONFIG_ROUTES, routes, NULL);
+ g_ptr_array_unref (routes);
}
static void
@@ -324,9 +408,22 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *ip6_class)
ip6_addresses_set,
NULL);
- _nm_setting_class_transform_property (setting_class,
- NM_SETTING_IP_CONFIG_ROUTES,
- G_VARIANT_TYPE ("a(ayuayu)"),
- ip6_routes_to_dbus,
- ip6_routes_from_dbus);
+ _nm_setting_class_add_dbus_only_property (setting_class,
+ "address-data",
+ G_VARIANT_TYPE ("aa{sv}"),
+ ip6_address_data_get,
+ ip6_address_data_set);
+
+ _nm_setting_class_override_property (setting_class,
+ NM_SETTING_IP_CONFIG_ROUTES,
+ G_VARIANT_TYPE ("a(ayuayu)"),
+ ip6_routes_get,
+ ip6_routes_set,
+ NULL);
+
+ _nm_setting_class_add_dbus_only_property (setting_class,
+ "route-data",
+ G_VARIANT_TYPE ("aa{sv}"),
+ ip6_route_data_get,
+ ip6_route_data_set);
}