libnm: create NMIPConfig as parent of NMIP4Config and NMIP6Config
authorDan Winship <danw@gnome.org>
Wed, 22 Oct 2014 17:48:18 +0000 (13:48 -0400)
committerDan Winship <danw@gnome.org>
Fri, 7 Nov 2014 12:49:40 +0000 (07:49 -0500)
Create NMIPConfig as the parent of NMIP4Config and NMIP6Config, and
remove the two subclasses from the public API; while it's convenient
to still have both internally, they are now identical to the outside
world.

20 files changed:
clients/cli/common.c
clients/cli/common.h
clients/cli/connections.c
clients/cli/devices.c
docs/libnm/Makefile.am
docs/libnm/libnm-docs.xml
libnm/Makefile.am
libnm/NetworkManager.h
libnm/libnm.ver
libnm/nm-active-connection.c
libnm/nm-active-connection.h
libnm/nm-device.c
libnm/nm-device.h
libnm/nm-ip-config.c [new file with mode: 0644]
libnm/nm-ip-config.h [new file with mode: 0644]
libnm/nm-ip4-config.c
libnm/nm-ip4-config.h
libnm/nm-ip6-config.c
libnm/nm-ip6-config.h
libnm/nm-types.h

index 2c56976..5493b16 100644 (file)
@@ -76,7 +76,7 @@ NmcOutputField nmc_fields_dhcp6_config[] = {
 
 
 gboolean
-print_ip4_config (NMIP4Config *cfg4,
+print_ip4_config (NMIPConfig *cfg4,
                   NmCli *nmc,
                   const char *group_prefix,
                   const char *one_field)
@@ -103,8 +103,8 @@ print_ip4_config (NMIP4Config *cfg4,
        g_ptr_array_add (nmc->output_data, arr);
 
        /* addresses */
-       ptr_array = nm_ip4_config_get_addresses (cfg4);
-       gw = nm_ip4_config_get_gateway (cfg4);
+       ptr_array = nm_ip_config_get_addresses (cfg4);
+       gw = nm_ip_config_get_gateway (cfg4);
        if (ptr_array) {
                addr_arr = g_new (char *, ptr_array->len + 1);
                for (i = 0; i < ptr_array->len; i++) {
@@ -119,7 +119,7 @@ print_ip4_config (NMIP4Config *cfg4,
        }
 
        /* routes */
-       ptr_array = nm_ip4_config_get_routes (cfg4);
+       ptr_array = nm_ip_config_get_routes (cfg4);
        if (ptr_array) {
                route_arr = g_new (char *, ptr_array->len + 1);
                for (i = 0; i < ptr_array->len; i++) {
@@ -140,13 +140,13 @@ print_ip4_config (NMIP4Config *cfg4,
        }
 
        /* DNS */
-       dns_arr = g_strdupv ((char **) nm_ip4_config_get_nameservers (cfg4));
+       dns_arr = g_strdupv ((char **) nm_ip_config_get_nameservers (cfg4));
 
        /* domains */
-       domain_arr = g_strdupv ((char **) nm_ip4_config_get_domains (cfg4));
+       domain_arr = g_strdupv ((char **) nm_ip_config_get_domains (cfg4));
 
        /* WINS */
-       wins_arr = g_strdupv ((char **) nm_ip4_config_get_wins_servers (cfg4));
+       wins_arr = g_strdupv ((char **) nm_ip_config_get_wins_servers (cfg4));
 
        arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
        set_val_strc (arr, 0, group_prefix);
@@ -166,7 +166,7 @@ print_ip4_config (NMIP4Config *cfg4,
 }
 
 gboolean
-print_ip6_config (NMIP6Config *cfg6,
+print_ip6_config (NMIPConfig *cfg6,
                   NmCli *nmc,
                   const char *group_prefix,
                   const char *one_field)
@@ -192,8 +192,8 @@ print_ip6_config (NMIP6Config *cfg6,
        g_ptr_array_add (nmc->output_data, arr);
 
        /* addresses */
-       ptr_array = nm_ip6_config_get_addresses (cfg6);
-       gw = nm_ip6_config_get_gateway (cfg6);
+       ptr_array = nm_ip_config_get_addresses (cfg6);
+       gw = nm_ip_config_get_gateway (cfg6);
        if (ptr_array) {
                addr_arr = g_new (char *, ptr_array->len + 1);
                for (i = 0; i < ptr_array->len; i++) {
@@ -208,7 +208,7 @@ print_ip6_config (NMIP6Config *cfg6,
        }
 
        /* routes */
-       ptr_array = nm_ip6_config_get_routes (cfg6);
+       ptr_array = nm_ip_config_get_routes (cfg6);
        if (ptr_array) {
                route_arr = g_new (char *, ptr_array->len + 1);
                for (i = 0; i < ptr_array->len; i++) {
@@ -229,10 +229,10 @@ print_ip6_config (NMIP6Config *cfg6,
        }
 
        /* DNS */
-       dns_arr = g_strdupv ((char **) nm_ip6_config_get_nameservers (cfg6));
+       dns_arr = g_strdupv ((char **) nm_ip_config_get_nameservers (cfg6));
 
        /* domains */
-       domain_arr = g_strdupv ((char **) nm_ip6_config_get_domains (cfg6));
+       domain_arr = g_strdupv ((char **) nm_ip_config_get_domains (cfg6));
 
        arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
        set_val_strc (arr, 0, group_prefix);
index bf881bf..2787b19 100644 (file)
@@ -24,8 +24,8 @@
 
 #include "nmcli.h"
 
-gboolean print_ip4_config (NMIP4Config *cfg4, NmCli *nmc, const char *group_prefix, const char *one_field);
-gboolean print_ip6_config (NMIP6Config *cfg6, NmCli *nmc, const char *group_prefix, const char *one_field);
+gboolean print_ip4_config (NMIPConfig *cfg4, NmCli *nmc, const char *group_prefix, const char *one_field);
+gboolean print_ip6_config (NMIPConfig *cfg6, NmCli *nmc, const char *group_prefix, const char *one_field);
 gboolean print_dhcp4_config (NMDhcp4Config *dhcp4, NmCli *nmc, const char *group_prefix, const char *one_field);
 gboolean print_dhcp6_config (NMDhcp6Config *dhcp6, NmCli *nmc, const char *group_prefix, const char *one_field);
 
index 969adb8..35e88b4 100644 (file)
@@ -1128,7 +1128,7 @@ nmc_active_connection_details (NMActiveConnection *acon, NmCli *nmc)
                /* IP4 */
                if (strcasecmp (nmc_fields_con_active_details_groups[group_idx].name,  nmc_fields_con_active_details_groups[1].name) == 0) {
                        gboolean b1 = FALSE;
-                       NMIP4Config *cfg4 = nm_active_connection_get_ip4_config (acon);
+                       NMIPConfig *cfg4 = nm_active_connection_get_ip4_config (acon);
 
                        b1 = print_ip4_config (cfg4, nmc, "IP4", group_fld);
                        was_output = was_output || b1;
@@ -1146,7 +1146,7 @@ nmc_active_connection_details (NMActiveConnection *acon, NmCli *nmc)
                /* IP6 */
                if (strcasecmp (nmc_fields_con_active_details_groups[group_idx].name,  nmc_fields_con_active_details_groups[3].name) == 0) {
                        gboolean b1 = FALSE;
-                       NMIP6Config *cfg6 = nm_active_connection_get_ip6_config (acon);
+                       NMIPConfig *cfg6 = nm_active_connection_get_ip6_config (acon);
 
                        b1 = print_ip6_config (cfg6, nmc, "IP6", group_fld);
                        was_output = was_output || b1;
index c073ec2..371c05b 100644 (file)
@@ -767,8 +767,7 @@ show_device_info (NMDevice *device, NmCli *nmc)
        NmcOutputField *tmpl, *arr;
        size_t tmpl_len;
        gboolean was_output = FALSE;
-       NMIP4Config *cfg4;
-       NMIP6Config *cfg6;
+       NMIPConfig *cfg4, *cfg6;
        NMDhcp4Config *dhcp4;
        NMDhcp6Config *dhcp6;
        const char *base_hdr = _("Device details");
index 1e1e9ae..0c82e75 100644 (file)
@@ -34,6 +34,8 @@ IGNORE_HFILES= \
        nm-dbus-helpers-private.h \
        nm-core-internal.h \
        nm-device-private.h \
+       nm-ip4-config.h \
+       nm-ip6-config.h \
        nm-manager.h \
        nm-object-cache.h \
        nm-object-private.h \
index 130c690..c60b472 100644 (file)
     <xi:include href="xml/nm-remote-connection.xml"/>
     <xi:include href="xml/nm-access-point.xml"/>
     <xi:include href="xml/nm-wimax-nsp.xml"/>
-    <xi:include href="xml/nm-ip4-config.xml"/>
-    <xi:include href="xml/nm-ip6-config.xml"/>
+    <xi:include href="xml/nm-ip-config.xml"/>
     <xi:include href="xml/nm-dhcp4-config.xml"/>
     <xi:include href="xml/nm-dhcp6-config.xml"/>
   </chapter>
index e14dc83..3656cdd 100644 (file)
@@ -46,8 +46,7 @@ libnminclude_hfiles =                 \
        nm-dhcp4-config.h               \
        nm-dhcp6-config.h               \
        nm-enum-types.h                 \
-       nm-ip4-config.h                 \
-       nm-ip6-config.h                 \
+       nm-ip-config.h                  \
        nm-object.h                     \
        nm-remote-connection.h          \
        nm-secret-agent.h               \
@@ -66,6 +65,8 @@ libnminclude_HEADERS =                        \
 libnm_la_private_headers =             \
        nm-dbus-helpers.h               \
        nm-device-private.h             \
+       nm-ip4-config.h                 \
+       nm-ip6-config.h                 \
        nm-manager.h                    \
        nm-object-cache.h               \
        nm-object-private.h             \
@@ -94,6 +95,7 @@ libnm_la_csources =                   \
        nm-dhcp4-config.c               \
        nm-dhcp6-config.c               \
        nm-enum-types.c                 \
+       nm-ip-config.c                  \
        nm-ip4-config.c                 \
        nm-ip6-config.c                 \
        nm-manager.c                    \
index d112e33..7604e77 100644 (file)
@@ -46,8 +46,7 @@
 #include <nm-dhcp4-config.h>
 #include <nm-dhcp6-config.h>
 #include <nm-enum-types.h>
-#include <nm-ip4-config.h>
-#include <nm-ip6-config.h>
+#include <nm-ip-config.h>
 #include <nm-object.h>
 #include <nm-remote-connection.h>
 #include <nm-secret-agent.h>
index 952b1dc..50ee710 100644 (file)
@@ -268,21 +268,6 @@ global:
        nm_dhcp6_config_get_one_option;
        nm_dhcp6_config_get_options;
        nm_dhcp6_config_get_type;
-       nm_ip4_config_get_addresses;
-       nm_ip4_config_get_domains;
-       nm_ip4_config_get_gateway;
-       nm_ip4_config_get_nameservers;
-       nm_ip4_config_get_routes;
-       nm_ip4_config_get_searches;
-       nm_ip4_config_get_type;
-       nm_ip4_config_get_wins_servers;
-       nm_ip6_config_get_addresses;
-       nm_ip6_config_get_domains;
-       nm_ip6_config_get_gateway;
-       nm_ip6_config_get_nameservers;
-       nm_ip6_config_get_routes;
-       nm_ip6_config_get_searches;
-       nm_ip6_config_get_type;
        nm_ip_address_equal;
        nm_ip_address_get_address;
        nm_ip_address_get_address_binary;
@@ -299,6 +284,15 @@ global:
        nm_ip_address_set_attribute;
        nm_ip_address_set_prefix;
        nm_ip_address_unref;
+       nm_ip_config_get_addresses;
+       nm_ip_config_get_domains;
+       nm_ip_config_get_family;
+       nm_ip_config_get_gateway;
+       nm_ip_config_get_nameservers;
+       nm_ip_config_get_routes;
+       nm_ip_config_get_searches;
+       nm_ip_config_get_type;
+       nm_ip_config_get_wins_servers;
        nm_ip_route_equal;
        nm_ip_route_get_attribute;
        nm_ip_route_get_attribute_names;
index 742b270..3551afe 100644 (file)
@@ -57,10 +57,10 @@ typedef struct {
        GPtrArray *devices;
        NMActiveConnectionState state;
        gboolean is_default;
-       NMIP4Config *ip4_config;
+       NMIPConfig *ip4_config;
        NMDhcp4Config *dhcp4_config;
        gboolean is_default6;
-       NMIP6Config *ip6_config;
+       NMIPConfig *ip6_config;
        NMDhcp6Config *dhcp6_config;
        gboolean is_vpn;
        NMDevice *master;
@@ -242,13 +242,12 @@ nm_active_connection_get_default (NMActiveConnection *connection)
  * nm_active_connection_get_ip4_config:
  * @connection: an #NMActiveConnection
  *
- * Gets the current #NMIP4Config associated with the #NMActiveConnection.
+ * Gets the current IPv4 #NMIPConfig associated with the #NMActiveConnection.
  *
- * Returns: (transfer none): the #NMIP4Config, or %NULL if the
- *   connection is not in the %NM_ACTIVE_CONNECTION_STATE_ACTIVATED
- *   state.
+ * Returns: (transfer none): the IPv4 #NMIPConfig, or %NULL if the connection is
+ *   not in the %NM_ACTIVE_CONNECTION_STATE_ACTIVATED state.
  **/
-NMIP4Config *
+NMIPConfig *
 nm_active_connection_get_ip4_config (NMActiveConnection *connection)
 {
        g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
@@ -296,13 +295,12 @@ nm_active_connection_get_default6 (NMActiveConnection *connection)
  * nm_active_connection_get_ip6_config:
  * @connection: an #NMActiveConnection
  *
- * Gets the current #NMIP6Config associated with the #NMActiveConnection.
+ * Gets the current IPv6 #NMIPConfig associated with the #NMActiveConnection.
  *
- * Returns: (transfer none): the #NMIP6Config, or %NULL if the
- *   connection is not in the %NM_ACTIVE_CONNECTION_STATE_ACTIVATED
- *   state.
+ * Returns: (transfer none): the IPv6 #NMIPConfig, or %NULL if the connection is
+ *   not in the %NM_ACTIVE_CONNECTION_STATE_ACTIVATED state.
  **/
-NMIP6Config *
+NMIPConfig *
 nm_active_connection_get_ip6_config (NMActiveConnection *connection)
 {
        g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
@@ -631,12 +629,12 @@ nm_active_connection_class_init (NMActiveConnectionClass *ap_class)
        /**
         * NMActiveConnection:ip4-config:
         *
-        * The #NMIP4Config of the connection.
+        * The IPv4 #NMIPConfig of the connection.
         **/
        g_object_class_install_property
                (object_class, PROP_IP4_CONFIG,
                 g_param_spec_object (NM_ACTIVE_CONNECTION_IP4_CONFIG, "", "",
-                                     NM_TYPE_IP4_CONFIG,
+                                     NM_TYPE_IP_CONFIG,
                                      G_PARAM_READABLE |
                                      G_PARAM_STATIC_STRINGS));
 
@@ -667,12 +665,12 @@ nm_active_connection_class_init (NMActiveConnectionClass *ap_class)
        /**
         * NMActiveConnection:ip6-config:
         *
-        * The #NMIP6Config of the connection.
+        * The IPv6 #NMIPConfig of the connection.
         **/
        g_object_class_install_property
                (object_class, PROP_IP6_CONFIG,
                 g_param_spec_object (NM_ACTIVE_CONNECTION_IP6_CONFIG, "", "",
-                                     NM_TYPE_IP6_CONFIG,
+                                     NM_TYPE_IP_CONFIG,
                                      G_PARAM_READABLE |
                                      G_PARAM_STATIC_STRINGS));
 
index ef8dd19..b6b31d9 100644 (file)
@@ -75,10 +75,10 @@ const GPtrArray         *nm_active_connection_get_devices              (NMActive
 NMActiveConnectionState  nm_active_connection_get_state                (NMActiveConnection *connection);
 NMDevice                *nm_active_connection_get_master               (NMActiveConnection *connection);
 gboolean                 nm_active_connection_get_default              (NMActiveConnection *connection);
-NMIP4Config             *nm_active_connection_get_ip4_config           (NMActiveConnection *connection);
+NMIPConfig              *nm_active_connection_get_ip4_config           (NMActiveConnection *connection);
 NMDhcp4Config           *nm_active_connection_get_dhcp4_config         (NMActiveConnection *connection);
 gboolean                 nm_active_connection_get_default6             (NMActiveConnection *connection);
-NMIP6Config             *nm_active_connection_get_ip6_config           (NMActiveConnection *connection);
+NMIPConfig              *nm_active_connection_get_ip6_config           (NMActiveConnection *connection);
 NMDhcp6Config           *nm_active_connection_get_dhcp6_config         (NMActiveConnection *connection);
 gboolean                 nm_active_connection_get_vpn                  (NMActiveConnection *connection);
 
index 5a1caf6..16f88d9 100644 (file)
@@ -83,9 +83,9 @@ typedef struct {
        gboolean managed;
        gboolean firmware_missing;
        gboolean autoconnect;
-       NMIP4Config *ip4_config;
+       NMIPConfig *ip4_config;
        NMDhcp4Config *dhcp4_config;
-       NMIP6Config *ip6_config;
+       NMIPConfig *ip6_config;
        NMDhcp6Config *dhcp6_config;
        NMDeviceState state;
        NMDeviceState last_seen_state;
@@ -651,7 +651,7 @@ nm_device_class_init (NMDeviceClass *device_class)
        g_object_class_install_property
                (object_class, PROP_IP4_CONFIG,
                 g_param_spec_object (NM_DEVICE_IP4_CONFIG, "", "",
-                                     NM_TYPE_IP4_CONFIG,
+                                     NM_TYPE_IP_CONFIG,
                                      G_PARAM_READABLE |
                                      G_PARAM_STATIC_STRINGS));
 
@@ -670,12 +670,12 @@ nm_device_class_init (NMDeviceClass *device_class)
        /**
         * NMDevice:ip6-config:
         *
-        * The #NMIP6Config of the device.
+        * The IPv6 #NMIPConfig of the device.
         **/
        g_object_class_install_property
                (object_class, PROP_IP6_CONFIG,
                 g_param_spec_object (NM_DEVICE_IP6_CONFIG, "", "",
-                                     NM_TYPE_IP6_CONFIG,
+                                     NM_TYPE_IP_CONFIG,
                                      G_PARAM_READABLE |
                                      G_PARAM_STATIC_STRINGS));
 
@@ -1106,15 +1106,15 @@ nm_device_get_firmware_missing (NMDevice *device)
  * nm_device_get_ip4_config:
  * @device: a #NMDevice
  *
- * Gets the current #NMIP4Config associated with the #NMDevice.
+ * Gets the current IPv4 #NMIPConfig associated with the #NMDevice.
  *
- * Note that as of NetworkManager 0.9.10, you can alternatively use
- * nm_active_connection_get_ip4_config(), which also works with VPN
- * connections.
+ * You can alternatively use nm_active_connection_get_ip4_config(), which also
+ * works with VPN connections.
  *
- * Returns: (transfer none): the #NMIP4Config or %NULL if the device is not activated.
+ * Returns: (transfer none): the IPv4 #NMIPConfig, or %NULL if the device is not
+ * activated.
  **/
-NMIP4Config *
+NMIPConfig *
 nm_device_get_ip4_config (NMDevice *device)
 {
        g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
@@ -1147,15 +1147,14 @@ nm_device_get_dhcp4_config (NMDevice *device)
  * nm_device_get_ip6_config:
  * @device: a #NMDevice
  *
- * Gets the current #NMIP6Config associated with the #NMDevice.
+ * Gets the current IPv6 #NMIPConfig associated with the #NMDevice.
  *
- * Note that as of NetworkManager 0.9.10, you can alternatively use
- * nm_active_connection_get_ip6_config(), which also works with VPN
- * connections.
+ * You can alternatively use nm_active_connection_get_ip6_config(), which also
+ * works with VPN connections.
  *
- * Returns: (transfer none): the #NMIP6Config or %NULL if the device is not activated.
+ * Returns: (transfer none): the IPv6 #NMIPConfig or %NULL if the device is not activated.
  **/
-NMIP6Config *
+NMIPConfig *
 nm_device_get_ip6_config (NMDevice *device)
 {
        g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
index 412dff3..2b103e5 100644 (file)
@@ -104,9 +104,9 @@ gboolean             nm_device_get_managed          (NMDevice *device);
 gboolean             nm_device_get_autoconnect      (NMDevice *device);
 void                 nm_device_set_autoconnect      (NMDevice *device, gboolean autoconnect);
 gboolean             nm_device_get_firmware_missing (NMDevice *device);
-NMIP4Config *        nm_device_get_ip4_config       (NMDevice *device);
+NMIPConfig *         nm_device_get_ip4_config       (NMDevice *device);
 NMDhcp4Config *      nm_device_get_dhcp4_config     (NMDevice *device);
-NMIP6Config *        nm_device_get_ip6_config       (NMDevice *device);
+NMIPConfig *         nm_device_get_ip6_config       (NMDevice *device);
 NMDhcp6Config *      nm_device_get_dhcp6_config     (NMDevice *device);
 NMDeviceState        nm_device_get_state            (NMDevice *device);
 NMDeviceStateReason  nm_device_get_state_reason     (NMDevice *device);
diff --git a/libnm/nm-ip-config.c b/libnm/nm-ip-config.c
new file mode 100644 (file)
index 0000000..fb50ac0
--- /dev/null
@@ -0,0 +1,498 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ *
+ * Copyright 2007 - 2011 Novell, Inc.
+ * Copyright 2008 - 2014 Red Hat, Inc.
+ */
+
+#include <string.h>
+
+#include "nm-ip-config.h"
+#include "nm-ip4-config.h"
+#include "nm-ip6-config.h"
+#include "nm-setting-ip-config.h"
+#include "nm-dbus-interface.h"
+#include "nm-object-private.h"
+#include "nm-utils.h"
+#include "nm-core-internal.h"
+
+G_DEFINE_ABSTRACT_TYPE (NMIPConfig, nm_ip_config, NM_TYPE_OBJECT)
+
+#define NM_IP_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_IP_CONFIG, NMIPConfigPrivate))
+
+typedef struct {
+       char *gateway;
+       GPtrArray *addresses;
+       GPtrArray *routes;
+       char **nameservers;
+       char **domains;
+       char **searches;
+       char **wins;
+
+       gboolean new_style_data;
+} NMIPConfigPrivate;
+
+enum {
+       PROP_0,
+       PROP_FAMILY,
+       PROP_GATEWAY,
+       PROP_ADDRESSES,
+       PROP_ROUTES,
+       PROP_NAMESERVERS,
+       PROP_DOMAINS,
+       PROP_SEARCHES,
+       PROP_WINS_SERVERS,
+
+       LAST_PROP
+};
+
+static void
+nm_ip_config_init (NMIPConfig *config)
+{
+       NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE (config);
+
+       priv->addresses = g_ptr_array_new ();
+       priv->routes = g_ptr_array_new ();
+       priv->nameservers = g_new0 (char *, 1);
+       priv->domains = g_new0 (char *, 1);
+       priv->searches = g_new0 (char *, 1);
+       priv->wins = g_new0 (char *, 1);
+}
+
+static gboolean
+demarshal_ip_addresses (NMObject *object, GParamSpec *pspec, GVariant *value, gpointer field)
+{
+       NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE (object);
+
+       if (priv->new_style_data)
+               return TRUE;
+
+       g_ptr_array_unref (priv->addresses);
+       if (NM_IS_IP4_CONFIG (object))
+               priv->addresses = nm_utils_ip4_addresses_from_variant (value, NULL);
+       else
+               priv->addresses = nm_utils_ip6_addresses_from_variant (value, NULL);
+       _nm_object_queue_notify (object, NM_IP_CONFIG_ADDRESSES);
+
+       return TRUE;
+}
+
+static gboolean
+demarshal_ip_address_data (NMObject *object, GParamSpec *pspec, GVariant *value, gpointer field)
+{
+       NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE (object);
+
+       priv->new_style_data = TRUE;
+
+       g_ptr_array_unref (priv->addresses);
+       if (NM_IS_IP4_CONFIG (object))
+               priv->addresses = nm_utils_ip_addresses_from_variant (value, AF_INET);
+       else
+               priv->addresses = nm_utils_ip_addresses_from_variant (value, AF_INET6);
+       _nm_object_queue_notify (object, NM_IP_CONFIG_ADDRESSES);
+
+       return TRUE;
+}
+
+static gboolean
+demarshal_ip_array (NMObject *object, GParamSpec *pspec, GVariant *value, gpointer field)
+{
+       char ***obj_field;
+
+       obj_field = field;
+       if (*obj_field)
+               g_strfreev (*obj_field);
+
+       if (NM_IS_IP4_CONFIG (object))
+               *obj_field = nm_utils_ip4_dns_from_variant (value);
+       else
+               *obj_field = nm_utils_ip6_dns_from_variant (value);
+
+       _nm_object_queue_notify (object, pspec->name);
+       return TRUE;
+}
+
+static gboolean
+demarshal_ip_routes (NMObject *object, GParamSpec *pspec, GVariant *value, gpointer field)
+{
+       NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE (object);
+
+       if (priv->new_style_data)
+               return TRUE;
+
+       g_ptr_array_unref (priv->routes);
+       if (NM_IS_IP4_CONFIG (object))
+               priv->routes = nm_utils_ip4_routes_from_variant (value);
+       else
+               priv->routes = nm_utils_ip6_routes_from_variant (value);
+       _nm_object_queue_notify (object, NM_IP_CONFIG_ROUTES);
+
+       return TRUE;
+}
+
+static gboolean
+demarshal_ip_route_data (NMObject *object, GParamSpec *pspec, GVariant *value, gpointer field)
+{
+       NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE (object);
+
+       priv->new_style_data = TRUE;
+
+       g_ptr_array_unref (priv->routes);
+       if (NM_IS_IP4_CONFIG (object))
+               priv->routes = nm_utils_ip_routes_from_variant (value, AF_INET);
+       else
+               priv->routes = nm_utils_ip_routes_from_variant (value, AF_INET6);
+       _nm_object_queue_notify (object, NM_IP_CONFIG_ROUTES);
+
+       return TRUE;
+}
+
+static void
+init_dbus (NMObject *object)
+{
+       NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE (object);
+       const NMPropertiesInfo property_info[] = {
+               { NM_IP_CONFIG_GATEWAY,      &priv->gateway, },
+               { NM_IP_CONFIG_ADDRESSES,    &priv->addresses, demarshal_ip_addresses },
+               { "address-data",            &priv->addresses, demarshal_ip_address_data },
+               { NM_IP_CONFIG_ROUTES,       &priv->routes, demarshal_ip_routes },
+               { "route-data",              &priv->routes, demarshal_ip_route_data },
+               { NM_IP_CONFIG_NAMESERVERS,  &priv->nameservers, demarshal_ip_array },
+               { NM_IP_CONFIG_DOMAINS,      &priv->domains, },
+               { NM_IP_CONFIG_SEARCHES,     &priv->searches, },
+               { NM_IP_CONFIG_WINS_SERVERS, &priv->wins, demarshal_ip_array },
+               { NULL },
+       };
+
+       NM_OBJECT_CLASS (nm_ip_config_parent_class)->init_dbus (object);
+
+       _nm_object_register_properties (object,
+                                       (NM_IS_IP4_CONFIG (object) ?
+                                        NM_DBUS_INTERFACE_IP4_CONFIG :
+                                        NM_DBUS_INTERFACE_IP6_CONFIG),
+                                       property_info);
+}
+
+static void
+finalize (GObject *object)
+{
+       NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE (object);
+
+       g_free (priv->gateway);
+
+       g_ptr_array_unref (priv->addresses);
+       g_ptr_array_unref (priv->routes);
+
+       g_strfreev (priv->nameservers);
+       g_strfreev (priv->domains);
+       g_strfreev (priv->searches);
+       g_strfreev (priv->wins);
+
+       G_OBJECT_CLASS (nm_ip_config_parent_class)->finalize (object);
+}
+
+static void
+get_property (GObject *object,
+              guint prop_id,
+              GValue *value,
+              GParamSpec *pspec)
+{
+       NMIPConfig *self = NM_IP_CONFIG (object);
+
+       switch (prop_id) {
+       case PROP_FAMILY:
+               g_value_set_int (value, nm_ip_config_get_family (self));
+               break;
+       case PROP_GATEWAY:
+               g_value_set_string (value, nm_ip_config_get_gateway (self));
+               break;
+       case PROP_ADDRESSES:
+               g_value_take_boxed (value, _nm_utils_copy_array (nm_ip_config_get_addresses (self),
+                                                                (NMUtilsCopyFunc) nm_ip_address_dup,
+                                                                (GDestroyNotify) nm_ip_address_unref));
+               break;
+       case PROP_ROUTES:
+               g_value_take_boxed (value, _nm_utils_copy_array (nm_ip_config_get_routes (self),
+                                                                (NMUtilsCopyFunc) nm_ip_route_dup,
+                                                                (GDestroyNotify) nm_ip_route_unref));
+               break;
+       case PROP_NAMESERVERS:
+               g_value_set_boxed (value, (char **) nm_ip_config_get_nameservers (self));
+               break;
+       case PROP_DOMAINS:
+               g_value_set_boxed (value, (char **) nm_ip_config_get_domains (self));
+               break;
+       case PROP_SEARCHES:
+               g_value_set_boxed (value, (char **) nm_ip_config_get_searches (self));
+               break;
+       case PROP_WINS_SERVERS:
+               g_value_set_boxed (value, (char **) nm_ip_config_get_wins_servers (self));
+               break;
+       default:
+               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+               break;
+       }
+}
+
+static void
+nm_ip_config_class_init (NMIPConfigClass *config_class)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (config_class);
+       NMObjectClass *nm_object_class = NM_OBJECT_CLASS (config_class);
+
+       g_type_class_add_private (config_class, sizeof (NMIPConfigPrivate));
+
+       /* virtual methods */
+       object_class->get_property = get_property;
+       object_class->finalize = finalize;
+
+       nm_object_class->init_dbus = init_dbus;
+
+       /* properties */
+
+       /**
+        * NMIPConfig:family:
+        *
+        * The IP address family of the configuration; either %AF_INET or %AF_INET6.
+        **/
+       g_object_class_install_property
+           (object_class, PROP_FAMILY,
+            g_param_spec_int (NM_IP_CONFIG_FAMILY, "", "",
+                              0, 255, AF_UNSPEC,
+                              G_PARAM_READABLE |
+                              G_PARAM_STATIC_STRINGS));
+
+       /**
+        * NMIPConfig:gateway:
+        *
+        * The IP gateway address of the configuration as string.
+        **/
+       g_object_class_install_property
+               (object_class, PROP_GATEWAY,
+                g_param_spec_string (NM_IP_CONFIG_GATEWAY, "", "",
+                                     NULL,
+                                     G_PARAM_READABLE |
+                                     G_PARAM_STATIC_STRINGS));
+
+       /**
+        * NMIPConfig:addresses:
+        *
+        * A #GPtrArray containing the addresses (#NMIPAddress) of the configuration.
+        **/
+       g_object_class_install_property
+           (object_class, PROP_ADDRESSES,
+            g_param_spec_boxed (NM_IP_CONFIG_ADDRESSES, "", "",
+                                G_TYPE_PTR_ARRAY,
+                                G_PARAM_READABLE |
+                                G_PARAM_STATIC_STRINGS));
+
+       /**
+        * NMIPConfig:routes:
+        *
+        * A #GPtrArray containing the routes (#NMIPRoute) of the configuration.
+        **/
+       g_object_class_install_property
+           (object_class, PROP_ROUTES,
+            g_param_spec_boxed (NM_IP_CONFIG_ROUTES, "", "",
+                                G_TYPE_PTR_ARRAY,
+                                G_PARAM_READABLE |
+                                G_PARAM_STATIC_STRINGS));
+
+       /**
+        * NMIPConfig:nameservers:
+        *
+        * The array containing name server IP addresses of the configuration.
+        **/
+       g_object_class_install_property
+           (object_class, PROP_NAMESERVERS,
+            g_param_spec_boxed (NM_IP_CONFIG_NAMESERVERS, "", "",
+                                G_TYPE_STRV,
+                                G_PARAM_READABLE |
+                                G_PARAM_STATIC_STRINGS));
+
+       /**
+        * NMIPConfig:domains:
+        *
+        * The array containing domain strings of the configuration.
+        **/
+       g_object_class_install_property
+           (object_class, PROP_DOMAINS,
+            g_param_spec_boxed (NM_IP_CONFIG_DOMAINS, "", "",
+                                G_TYPE_STRV,
+                                G_PARAM_READABLE |
+                                G_PARAM_STATIC_STRINGS));
+
+       /**
+        * NMIPConfig:searches:
+        *
+        * The array containing DNS search strings of the configuration.
+        **/
+       g_object_class_install_property
+           (object_class, PROP_SEARCHES,
+            g_param_spec_boxed (NM_IP_CONFIG_SEARCHES, "", "",
+                                G_TYPE_STRV,
+                                G_PARAM_READABLE |
+                                G_PARAM_STATIC_STRINGS));
+
+       /**
+        * NMIPConfig:wins-servers:
+        *
+        * The array containing WINS server IP addresses of the configuration.
+        * (This will always be empty for IPv6 configurations.)
+        **/
+       g_object_class_install_property
+           (object_class, PROP_WINS_SERVERS,
+            g_param_spec_boxed (NM_IP_CONFIG_WINS_SERVERS, "", "",
+                                G_TYPE_STRV,
+                                G_PARAM_READABLE |
+                                G_PARAM_STATIC_STRINGS));
+}
+
+/**
+ * nm_ip_config_get_family:
+ * @config: a #NMIPConfig
+ *
+ * Gets the IP address family
+ *
+ * Returns: the IP address family; either %AF_INET or %AF_INET6
+ **/
+int
+nm_ip_config_get_family (NMIPConfig *config)
+{
+       g_return_val_if_fail (NM_IS_IP_CONFIG (config), AF_UNSPEC);
+
+       return NM_IS_IP4_CONFIG (config) ? AF_INET : AF_INET6;
+}
+
+/**
+ * nm_ip_config_get_gateway:
+ * @config: a #NMIPConfig
+ *
+ * Gets the IP gateway address.
+ *
+ * Returns: (transfer none): the IP address of the gateway.
+ **/
+const char *
+nm_ip_config_get_gateway (NMIPConfig *config)
+{
+       g_return_val_if_fail (NM_IS_IP_CONFIG (config), NULL);
+
+       return NM_IP_CONFIG_GET_PRIVATE (config)->gateway;
+}
+
+/**
+ * nm_ip_config_get_addresses:
+ * @config: a #NMIPConfig
+ *
+ * Gets the IP addresses (containing the address, prefix, and gateway).
+ *
+ * Returns: (element-type NMIPAddress) (transfer none): the #GPtrArray
+ * containing #NMIPAddress<!-- -->es.  This is the internal copy used by the
+ * configuration and must not be modified.
+ **/
+GPtrArray *
+nm_ip_config_get_addresses (NMIPConfig *config)
+{
+       g_return_val_if_fail (NM_IS_IP_CONFIG (config), NULL);
+
+       return NM_IP_CONFIG_GET_PRIVATE (config)->addresses;
+}
+
+/**
+ * nm_ip_config_get_nameservers:
+ * @config: a #NMIPConfig
+ *
+ * Gets the domain name servers (DNS).
+ *
+ * Returns: (transfer none): the array of nameserver IP addresses
+ **/
+const char * const *
+nm_ip_config_get_nameservers (NMIPConfig *config)
+{
+       g_return_val_if_fail (NM_IS_IP_CONFIG (config), NULL);
+
+       return (const char * const *) NM_IP_CONFIG_GET_PRIVATE (config)->nameservers;
+}
+
+/**
+ * nm_ip_config_get_domains:
+ * @config: a #NMIPConfig
+ *
+ * Gets the domain names.
+ *
+ * Returns: (transfer none): the array of domains.
+ * (This is never %NULL, though it may be 0-length).
+ **/
+const char * const *
+nm_ip_config_get_domains (NMIPConfig *config)
+{
+       g_return_val_if_fail (NM_IS_IP_CONFIG (config), NULL);
+
+       return (const char * const *) NM_IP_CONFIG_GET_PRIVATE (config)->domains;
+}
+
+/**
+ * nm_ip_config_get_searches:
+ * @config: a #NMIPConfig
+ *
+ * Gets the DNS searches.
+ *
+ * Returns: (transfer none): the array of DNS search strings.
+ * (This is never %NULL, though it may be 0-length).
+ **/
+const char * const *
+nm_ip_config_get_searches (NMIPConfig *config)
+{
+       g_return_val_if_fail (NM_IS_IP_CONFIG (config), NULL);
+
+       return (const char * const *) NM_IP_CONFIG_GET_PRIVATE (config)->searches;
+}
+
+/**
+ * nm_ip_config_get_wins_servers:
+ * @config: a #NMIPConfig
+ *
+ * Gets the Windows Internet Name Service servers (WINS).
+ *
+ * Returns: (transfer none): the arry of WINS server IP address strings.
+ * (This is never %NULL, though it may be 0-length.)
+ **/
+const char * const *
+nm_ip_config_get_wins_servers (NMIPConfig *config)
+{
+       g_return_val_if_fail (NM_IS_IP_CONFIG (config), NULL);
+
+       return (const char * const *) NM_IP_CONFIG_GET_PRIVATE (config)->wins;
+}
+
+/**
+ * nm_ip_config_get_routes:
+ * @config: a #NMIPConfig
+ *
+ * Gets the routes.
+ *
+ * Returns: (element-type NMIPRoute) (transfer none): the #GPtrArray containing
+ * #NMIPRoutes. This is the internal copy used by the configuration, and must
+ * not be modified.
+ **/
+GPtrArray *
+nm_ip_config_get_routes (NMIPConfig *config)
+{
+       g_return_val_if_fail (NM_IS_IP_CONFIG (config), NULL);
+
+       return NM_IP_CONFIG_GET_PRIVATE (config)->routes;
+}
diff --git a/libnm/nm-ip-config.h b/libnm/nm-ip-config.h
new file mode 100644 (file)
index 0000000..815135a
--- /dev/null
@@ -0,0 +1,73 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ *
+ * Copyright 2007 - 2008 Novell, Inc.
+ * Copyright 2008 - 2014 Red Hat, Inc.
+ */
+
+#ifndef __NM_IP_CONFIG_H__
+#define __NM_IP_CONFIG_H__
+
+#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION)
+#error "Only <NetworkManager.h> can be included directly."
+#endif
+
+#include <nm-object.h>
+
+G_BEGIN_DECLS
+
+#define NM_TYPE_IP_CONFIG            (nm_ip_config_get_type ())
+#define NM_IP_CONFIG(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IP_CONFIG, NMIPConfig))
+#define NM_IP_CONFIG_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_IP_CONFIG, NMIPConfigClass))
+#define NM_IS_IP_CONFIG(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_IP_CONFIG))
+#define NM_IS_IP_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_IP_CONFIG))
+#define NM_IP_CONFIG_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_IP_CONFIG, NMIPConfigClass))
+
+struct _NMIPConfig {
+       NMObject parent;
+};
+
+typedef struct {
+       NMObjectClass parent;
+
+       /*< private >*/
+       gpointer padding[8];
+} NMIPConfigClass;
+
+#define NM_IP_CONFIG_FAMILY "family"
+#define NM_IP_CONFIG_GATEWAY "gateway"
+#define NM_IP_CONFIG_ADDRESSES "addresses"
+#define NM_IP_CONFIG_ROUTES "routes"
+#define NM_IP_CONFIG_NAMESERVERS "nameservers"
+#define NM_IP_CONFIG_DOMAINS "domains"
+#define NM_IP_CONFIG_SEARCHES "searches"
+#define NM_IP_CONFIG_WINS_SERVERS "wins-servers"
+
+GType nm_ip_config_get_type (void);
+
+int                 nm_ip_config_get_family       (NMIPConfig *config);
+const char *        nm_ip_config_get_gateway      (NMIPConfig *config);
+GPtrArray *         nm_ip_config_get_addresses    (NMIPConfig *config);
+GPtrArray *         nm_ip_config_get_routes       (NMIPConfig *config);
+const char * const *nm_ip_config_get_nameservers  (NMIPConfig *config);
+const char * const *nm_ip_config_get_domains      (NMIPConfig *config);
+const char * const *nm_ip_config_get_searches     (NMIPConfig *config);
+const char * const *nm_ip_config_get_wins_servers (NMIPConfig *config);
+
+G_END_DECLS
+
+#endif /* __NM_IP_CONFIG_H__ */
index d242fe5..8a7e007 100644 (file)
  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02110-1301 USA.
  *
- * Copyright 2007 - 2011 Novell, Inc.
- * Copyright 2008 Red Hat, Inc.
+ * Copyright 2014 Red Hat, Inc.
  */
 
-#include <string.h>
-
-#include <nm-setting-ip4-config.h>
 #include "nm-ip4-config.h"
-#include "nm-dbus-interface.h"
 #include "nm-object-private.h"
-#include "nm-utils.h"
-#include "nm-core-internal.h"
-
-G_DEFINE_TYPE (NMIP4Config, nm_ip4_config, NM_TYPE_OBJECT)
-
-#define NM_IP4_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_IP4_CONFIG, NMIP4ConfigPrivate))
-
-typedef struct {
-       char *gateway;
-       GPtrArray *addresses;
-       GPtrArray *routes;
-       char **nameservers;
-       char **domains;
-       char **searches;
-       char **wins;
 
-       gboolean new_style_data;
-} NMIP4ConfigPrivate;
-
-enum {
-       PROP_0,
-       PROP_GATEWAY,
-       PROP_ADDRESSES,
-       PROP_ROUTES,
-       PROP_NAMESERVERS,
-       PROP_DOMAINS,
-       PROP_SEARCHES,
-       PROP_WINS_SERVERS,
-
-       LAST_PROP
-};
+G_DEFINE_TYPE (NMIP4Config, nm_ip4_config, NM_TYPE_IP_CONFIG)
 
 static void
 nm_ip4_config_init (NMIP4Config *config)
 {
-       NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
-
-       priv->addresses = g_ptr_array_new ();
-       priv->routes = g_ptr_array_new ();
-       priv->nameservers = g_new0 (char *, 1);
-       priv->domains = g_new0 (char *, 1);
-       priv->searches = g_new0 (char *, 1);
-       priv->wins = g_new0 (char *, 1);
-}
-
-static gboolean
-demarshal_ip4_addresses (NMObject *object, GParamSpec *pspec, GVariant *value, gpointer field)
-{
-       NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object);
-
-       if (priv->new_style_data)
-               return TRUE;
-
-       g_ptr_array_unref (priv->addresses);
-       priv->addresses = nm_utils_ip4_addresses_from_variant (value, NULL);
-       _nm_object_queue_notify (object, NM_IP4_CONFIG_ADDRESSES);
-
-       return TRUE;
-}
-
-static gboolean
-demarshal_ip4_address_data (NMObject *object, GParamSpec *pspec, GVariant *value, gpointer field)
-{
-       NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object);
-
-       priv->new_style_data = TRUE;
-
-       g_ptr_array_unref (priv->addresses);
-       priv->addresses = nm_utils_ip_addresses_from_variant (value, AF_INET);
-       _nm_object_queue_notify (object, NM_IP4_CONFIG_ADDRESSES);
-
-       return TRUE;
-}
-
-static gboolean
-demarshal_ip4_array (NMObject *object, GParamSpec *pspec, GVariant *value, gpointer field)
-{
-       char ***obj_field;
-
-       obj_field = field;
-       if (*obj_field)
-               g_strfreev (*obj_field);
-
-       *obj_field = nm_utils_ip4_dns_from_variant (value);
-
-       _nm_object_queue_notify (object, pspec->name);
-       return TRUE;
-}
-
-static gboolean
-demarshal_ip4_routes (NMObject *object, GParamSpec *pspec, GVariant *value, gpointer field)
-{
-       NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object);
-
-       if (priv->new_style_data)
-               return TRUE;
-
-       g_ptr_array_unref (priv->routes);
-       priv->routes = nm_utils_ip4_routes_from_variant (value);
-       _nm_object_queue_notify (object, NM_IP4_CONFIG_ROUTES);
-
-       return TRUE;
-}
-
-static gboolean
-demarshal_ip4_route_data (NMObject *object, GParamSpec *pspec, GVariant *value, gpointer field)
-{
-       NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object);
-
-       priv->new_style_data = TRUE;
-
-       g_ptr_array_unref (priv->routes);
-       priv->routes = nm_utils_ip_routes_from_variant (value, AF_INET);
-       _nm_object_queue_notify (object, NM_IP4_CONFIG_ROUTES);
-
-       return TRUE;
-}
-
-static void
-init_dbus (NMObject *object)
-{
-       NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object);
-       const NMPropertiesInfo property_info[] = {
-               { NM_IP4_CONFIG_GATEWAY,      &priv->gateway, },
-               { NM_IP4_CONFIG_ADDRESSES,    &priv->addresses, demarshal_ip4_addresses },
-               { "address-data",             &priv->addresses, demarshal_ip4_address_data },
-               { NM_IP4_CONFIG_ROUTES,       &priv->routes, demarshal_ip4_routes },
-               { "route-data",               &priv->routes, demarshal_ip4_route_data },
-               { NM_IP4_CONFIG_NAMESERVERS,  &priv->nameservers, demarshal_ip4_array },
-               { NM_IP4_CONFIG_DOMAINS,      &priv->domains, },
-               { NM_IP4_CONFIG_SEARCHES,     &priv->searches, },
-               { NM_IP4_CONFIG_WINS_SERVERS, &priv->wins, demarshal_ip4_array },
-               { NULL },
-       };
-
-       NM_OBJECT_CLASS (nm_ip4_config_parent_class)->init_dbus (object);
-
-       _nm_object_register_properties (object,
-                                       NM_DBUS_INTERFACE_IP4_CONFIG,
-                                       property_info);
-}
-
-static void
-finalize (GObject *object)
-{
-       NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object);
-
-       g_free (priv->gateway);
-
-       g_ptr_array_unref (priv->addresses);
-       g_ptr_array_unref (priv->routes);
-
-       g_strfreev (priv->nameservers);
-       g_strfreev (priv->domains);
-       g_strfreev (priv->searches);
-       g_strfreev (priv->wins);
-
-       G_OBJECT_CLASS (nm_ip4_config_parent_class)->finalize (object);
-}
-
-static void
-get_property (GObject *object,
-              guint prop_id,
-              GValue *value,
-              GParamSpec *pspec)
-{
-       NMIP4Config *self = NM_IP4_CONFIG (object);
-
-       switch (prop_id) {
-       case PROP_GATEWAY:
-               g_value_set_string (value, nm_ip4_config_get_gateway (self));
-               break;
-       case PROP_ADDRESSES:
-               g_value_take_boxed (value, _nm_utils_copy_array (nm_ip4_config_get_addresses (self),
-                                                                (NMUtilsCopyFunc) nm_ip_address_dup,
-                                                                (GDestroyNotify) nm_ip_address_unref));
-               break;
-       case PROP_ROUTES:
-               g_value_take_boxed (value, _nm_utils_copy_array (nm_ip4_config_get_routes (self),
-                                                                (NMUtilsCopyFunc) nm_ip_route_dup,
-                                                                (GDestroyNotify) nm_ip_route_unref));
-               break;
-       case PROP_NAMESERVERS:
-               g_value_set_boxed (value, (char **) nm_ip4_config_get_nameservers (self));
-               break;
-       case PROP_DOMAINS:
-               g_value_set_boxed (value, (char **) nm_ip4_config_get_domains (self));
-               break;
-       case PROP_SEARCHES:
-               g_value_set_boxed (value, (char **) nm_ip4_config_get_searches (self));
-               break;
-       case PROP_WINS_SERVERS:
-               g_value_set_boxed (value, (char **) nm_ip4_config_get_wins_servers (self));
-               break;
-       default:
-               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-               break;
-       }
 }
 
 static void
 nm_ip4_config_class_init (NMIP4ConfigClass *config_class)
 {
-       GObjectClass *object_class = G_OBJECT_CLASS (config_class);
        NMObjectClass *nm_object_class = NM_OBJECT_CLASS (config_class);
 
-       g_type_class_add_private (config_class, sizeof (NMIP4ConfigPrivate));
-
        _nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_IP4_CONFIG);
-
-       /* virtual methods */
-       object_class->get_property = get_property;
-       object_class->finalize = finalize;
-
-       nm_object_class->init_dbus = init_dbus;
-
-       /* properties */
-
-       /**
-        * NMIP4Config:gateway:
-        *
-        * The IP4 gateway address of the configuration as string.
-        **/
-       g_object_class_install_property
-           (object_class, PROP_GATEWAY,
-            g_param_spec_string (NM_IP4_CONFIG_GATEWAY, "", "",
-                                 NULL,
-                                 G_PARAM_READABLE |
-                                 G_PARAM_STATIC_STRINGS));
-
-       /**
-        * NMIP4Config:addresses:
-        *
-        * A #GPtrArray containing the addresses (#NMIPAddress) of the configuration.
-        **/
-       g_object_class_install_property
-           (object_class, PROP_ADDRESSES,
-            g_param_spec_boxed (NM_IP4_CONFIG_ADDRESSES, "", "",
-                                G_TYPE_PTR_ARRAY,
-                                G_PARAM_READABLE |
-                                G_PARAM_STATIC_STRINGS));
-
-       /**
-        * NMIP4Config:routes:
-        *
-        * A #GPtrArray containing the routes (#NMIPRoute) of the configuration.
-        **/
-       g_object_class_install_property
-           (object_class, PROP_ROUTES,
-            g_param_spec_boxed (NM_IP4_CONFIG_ROUTES, "", "",
-                                G_TYPE_PTR_ARRAY,
-                                G_PARAM_READABLE |
-                                G_PARAM_STATIC_STRINGS));
-
-       /**
-        * NMIP4Config:nameservers:
-        *
-        * The array containing name server IP addresses of the configuration.
-        **/
-       g_object_class_install_property
-           (object_class, PROP_NAMESERVERS,
-            g_param_spec_boxed (NM_IP4_CONFIG_NAMESERVERS, "", "",
-                                G_TYPE_STRV,
-                                G_PARAM_READABLE |
-                                G_PARAM_STATIC_STRINGS));
-
-       /**
-        * NMIP4Config:domains:
-        *
-        * The array containing domain strings of the configuration.
-        **/
-       g_object_class_install_property
-           (object_class, PROP_DOMAINS,
-            g_param_spec_boxed (NM_IP4_CONFIG_DOMAINS, "", "",
-                                G_TYPE_STRV,
-                                G_PARAM_READABLE |
-                                G_PARAM_STATIC_STRINGS));
-
-       /**
-        * NMIP4Config:searches:
-        *
-        * The array containing DNS search strings of the configuration.
-        **/
-       g_object_class_install_property
-           (object_class, PROP_SEARCHES,
-            g_param_spec_boxed (NM_IP4_CONFIG_SEARCHES, "", "",
-                                G_TYPE_STRV,
-                                G_PARAM_READABLE |
-                                G_PARAM_STATIC_STRINGS));
-
-       /**
-        * NMIP4Config:wins-servers:
-        *
-        * The array containing WINS server IP addresses of the configuration.
-        **/
-       g_object_class_install_property
-           (object_class, PROP_WINS_SERVERS,
-            g_param_spec_boxed (NM_IP4_CONFIG_WINS_SERVERS, "", "",
-                                G_TYPE_STRV,
-                                G_PARAM_READABLE |
-                                G_PARAM_STATIC_STRINGS));
-}
-
-/**
- * nm_ip4_config_get_gateway:
- * @config: a #NMIP4Config
- *
- * Gets the IP4 gateway address.
- *
- * Returns: (transfer none): the IP4 address of the gateway.
- **/
-const char *
-nm_ip4_config_get_gateway (NMIP4Config *config)
-{
-       g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
-
-       return NM_IP4_CONFIG_GET_PRIVATE (config)->gateway;
-}
-
-/**
- * nm_ip4_config_get_addresses:
- * @config: a #NMIP4Config
- *
- * Gets the IP4 addresses (containing the address, prefix, and gateway).
- *
- * Returns: (element-type NMIPAddress) (transfer none): the #GPtrArray
- * containing #NMIPAddress<!-- -->es.  This is the internal copy used by the
- * configuration and must not be modified.
- **/
-GPtrArray *
-nm_ip4_config_get_addresses (NMIP4Config *config)
-{
-       g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
-
-       return NM_IP4_CONFIG_GET_PRIVATE (config)->addresses;
-}
-
-/**
- * nm_ip4_config_get_nameservers:
- * @config: a #NMIP4Config
- *
- * Gets the domain name servers (DNS).
- *
- * Returns: (transfer none): the array of nameserver IP addresses
- **/
-const char * const *
-nm_ip4_config_get_nameservers (NMIP4Config *config)
-{
-       g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
-
-       return (const char * const *) NM_IP4_CONFIG_GET_PRIVATE (config)->nameservers;
-}
-
-/**
- * nm_ip4_config_get_domains:
- * @config: a #NMIP4Config
- *
- * Gets the domain names.
- *
- * Returns: (transfer none): the array of domains.
- * (This is never %NULL, though it may be 0-length).
- **/
-const char * const *
-nm_ip4_config_get_domains (NMIP4Config *config)
-{
-       g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
-
-       return (const char * const *) NM_IP4_CONFIG_GET_PRIVATE (config)->domains;
-}
-
-/**
- * nm_ip4_config_get_searches:
- * @config: a #NMIP4Config
- *
- * Gets the DNS searches.
- *
- * Returns: (transfer none): the array of DNS search strings.
- * (This is never %NULL, though it may be 0-length).
- **/
-const char * const *
-nm_ip4_config_get_searches (NMIP4Config *config)
-{
-       g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
-
-       return (const char * const *) NM_IP4_CONFIG_GET_PRIVATE (config)->searches;
-}
-
-/**
- * nm_ip4_config_get_wins_servers:
- * @config: a #NMIP4Config
- *
- * Gets the Windows Internet Name Service servers (WINS).
- *
- * Returns: (element-type guint32) (transfer none): the #GArray containing #guint32s.
- * This is the internal copy used by the configuration and must not be
- * modified.
- **/
-const char * const *
-nm_ip4_config_get_wins_servers (NMIP4Config *config)
-{
-       g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
-
-       return (const char * const *) NM_IP4_CONFIG_GET_PRIVATE (config)->wins;
-}
-
-/**
- * nm_ip4_config_get_routes:
- * @config: a #NMIP4Config
- *
- * Gets the routes.
- *
- * Returns: (element-type NMIPRoute) (transfer none): the #GPtrArray containing
- * #NMIPRoutes. This is the internal copy used by the configuration, and must
- * not be modified.
- **/
-GPtrArray *
-nm_ip4_config_get_routes (NMIP4Config *config)
-{
-       g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
-
-       return NM_IP4_CONFIG_GET_PRIVATE (config)->routes;
 }
index a933a5e..e2a18e0 100644 (file)
 #ifndef __NM_IP4_CONFIG_H__
 #define __NM_IP4_CONFIG_H__
 
-#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION)
-#error "Only <NetworkManager.h> can be included directly."
-#endif
-
-#include <nm-object.h>
+#include <nm-ip-config.h>
 
 G_BEGIN_DECLS
 
@@ -37,35 +33,19 @@ G_BEGIN_DECLS
 #define NM_IS_IP4_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_IP4_CONFIG))
 #define NM_IP4_CONFIG_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_IP4_CONFIG, NMIP4ConfigClass))
 
-struct _NMIP4Config {
-       NMObject parent;
-};
+typedef struct {
+       NMIPConfig parent;
+} NMIP4Config;
 
 typedef struct {
-       NMObjectClass parent;
+       NMIPConfigClass parent;
 
        /*< private >*/
        gpointer padding[4];
 } NMIP4ConfigClass;
 
-#define NM_IP4_CONFIG_GATEWAY "gateway"
-#define NM_IP4_CONFIG_ADDRESSES "addresses"
-#define NM_IP4_CONFIG_ROUTES "routes"
-#define NM_IP4_CONFIG_NAMESERVERS "nameservers"
-#define NM_IP4_CONFIG_DOMAINS "domains"
-#define NM_IP4_CONFIG_SEARCHES "searches"
-#define NM_IP4_CONFIG_WINS_SERVERS "wins-servers"
-
 GType nm_ip4_config_get_type (void);
 
-const char *        nm_ip4_config_get_gateway      (NMIP4Config *config);
-GPtrArray *         nm_ip4_config_get_addresses    (NMIP4Config *config);
-GPtrArray *         nm_ip4_config_get_routes       (NMIP4Config *config);
-const char * const *nm_ip4_config_get_nameservers  (NMIP4Config *config);
-const char * const *nm_ip4_config_get_domains      (NMIP4Config *config);
-const char * const *nm_ip4_config_get_searches     (NMIP4Config *config);
-const char * const *nm_ip4_config_get_wins_servers (NMIP4Config *config);
-
 G_END_DECLS
 
 #endif /* __NM_IP4_CONFIG_H__ */
index 7318f5f..cd64e75 100644 (file)
  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02110-1301 USA.
  *
- * Copyright 2007 - 2008 Novell, Inc.
- * Copyright 2008 - 2014 Red Hat, Inc.
+ * Copyright 2014 Red Hat, Inc.
  */
 
-#include <string.h>
-
-#include <nm-setting-ip6-config.h>
 #include "nm-ip6-config.h"
-#include "nm-dbus-interface.h"
 #include "nm-object-private.h"
-#include "nm-utils.h"
-#include "nm-core-internal.h"
-
-G_DEFINE_TYPE (NMIP6Config, nm_ip6_config, NM_TYPE_OBJECT)
-
-#define NM_IP6_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_IP6_CONFIG, NMIP6ConfigPrivate))
-
-typedef struct {
-       char *gateway;
-       GPtrArray *addresses;
-       GPtrArray *routes;
-       char **nameservers;
-       char **domains;
-       char **searches;
-
-       gboolean new_style_data;
-} NMIP6ConfigPrivate;
-
-enum {
-       PROP_0,
-       PROP_GATEWAY,
-       PROP_ADDRESSES,
-       PROP_ROUTES,
-       PROP_NAMESERVERS,
-       PROP_DOMAINS,
-       PROP_SEARCHES,
-
-       LAST_PROP
-};
-
-static gboolean
-demarshal_ip6_addresses (NMObject *object, GParamSpec *pspec, GVariant *value, gpointer field)
-{
-       NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (object);
-
-       if (priv->new_style_data)
-               return TRUE;
-
-       g_ptr_array_unref (priv->addresses);
-       priv->addresses = nm_utils_ip6_addresses_from_variant (value, NULL);
-       _nm_object_queue_notify (object, NM_IP6_CONFIG_ADDRESSES);
-
-       return TRUE;
-}
-
-static gboolean
-demarshal_ip6_address_data (NMObject *object, GParamSpec *pspec, GVariant *value, gpointer field)
-{
-       NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (object);
-
-       priv->new_style_data = TRUE;
-
-       g_ptr_array_unref (priv->addresses);
-       priv->addresses = nm_utils_ip_addresses_from_variant (value, AF_INET6);
-       _nm_object_queue_notify (object, NM_IP6_CONFIG_ADDRESSES);
-
-       return TRUE;
-}
-
-static gboolean
-demarshal_ip6_nameserver_array (NMObject *object, GParamSpec *pspec, GVariant *value, gpointer field)
-{
-       char ***obj_field;
-
-       obj_field = field;
-       if (*obj_field)
-               g_strfreev (*obj_field);
-
-       *obj_field = nm_utils_ip6_dns_from_variant (value);
-
-       _nm_object_queue_notify (object, pspec->name);
-       return TRUE;
-}
-
-static gboolean
-demarshal_ip6_routes (NMObject *object, GParamSpec *pspec, GVariant *value, gpointer field)
-{
-       NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (object);
-
-       if (priv->new_style_data)
-               return TRUE;
-
-       g_ptr_array_unref (priv->routes);
-       priv->routes = nm_utils_ip6_routes_from_variant (value);
-       _nm_object_queue_notify (object, NM_IP6_CONFIG_ROUTES);
-
-       return TRUE;
-}
-
-static gboolean
-demarshal_ip6_route_data (NMObject *object, GParamSpec *pspec, GVariant *value, gpointer field)
-{
-       NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (object);
 
-       priv->new_style_data = TRUE;
-
-       g_ptr_array_unref (priv->routes);
-       priv->routes = nm_utils_ip_routes_from_variant (value, AF_INET6);
-       _nm_object_queue_notify (object, NM_IP6_CONFIG_ROUTES);
-
-       return TRUE;
-}
-
-static void
-init_dbus (NMObject *object)
-{
-       NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (object);
-       const NMPropertiesInfo property_info[] = {
-               { NM_IP6_CONFIG_GATEWAY,      &priv->gateway, },
-               { NM_IP6_CONFIG_ADDRESSES,    &priv->addresses, demarshal_ip6_addresses },
-               { "address-data",             &priv->addresses, demarshal_ip6_address_data },
-               { NM_IP6_CONFIG_ROUTES,       &priv->routes, demarshal_ip6_routes },
-               { "route-data",               &priv->routes, demarshal_ip6_route_data },
-               { NM_IP6_CONFIG_NAMESERVERS,  &priv->nameservers, demarshal_ip6_nameserver_array },
-               { NM_IP6_CONFIG_DOMAINS,      &priv->domains, },
-               { NM_IP6_CONFIG_SEARCHES,     &priv->searches, },
-               { NULL },
-       };
-
-       NM_OBJECT_CLASS (nm_ip6_config_parent_class)->init_dbus (object);
-
-       _nm_object_register_properties (object,
-                                       NM_DBUS_INTERFACE_IP6_CONFIG,
-                                       property_info);
-}
-
-/**
- * nm_ip6_config_get_gateway:
- * @config: a #NMIP6Config
- *
- * Gets the IP6 gateway.
- *
- * Returns: (transfer none): the IPv6 gateway of the configuration.
- **/
-const char *
-nm_ip6_config_get_gateway (NMIP6Config *config)
-{
-       g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL);
-
-       return NM_IP6_CONFIG_GET_PRIVATE (config)->gateway;
-}
-
-/**
- * nm_ip6_config_get_addresses:
- * @config: a #NMIP6Config
- *
- * Gets the IP6 addresses (containing the address, prefix, and gateway).
- *
- * Returns: (element-type NMIPAddress) (transfer none): the #GPtrArray
- * containing #NMIPAddress<!-- -->es. This is the internal copy used by the
- * configuration and must not be modified.
- **/
-GPtrArray *
-nm_ip6_config_get_addresses (NMIP6Config *config)
-{
-       g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL);
-
-       return NM_IP6_CONFIG_GET_PRIVATE (config)->addresses;
-}
-
-/**
- * nm_ip6_config_get_nameservers:
- * @config: a #NMIP6Config
- *
- * Gets the domain name servers (DNS).
- *
- * Returns: (transfer none): the array of nameserver IP addresses
- **/
-const char * const *
-nm_ip6_config_get_nameservers (NMIP6Config *config)
-{
-       g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL);
-
-       return (const char * const *) NM_IP6_CONFIG_GET_PRIVATE (config)->nameservers;
-}
-
-/**
- * nm_ip6_config_get_domains:
- * @config: a #NMIP6Config
- *
- * Gets the domain names.
- *
- * Returns: (transfer none): the array of domains.
- * (This is never %NULL, though it may be 0-length).
- **/
-const char * const *
-nm_ip6_config_get_domains (NMIP6Config *config)
-{
-       g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL);
-
-       return (const char * const *) NM_IP6_CONFIG_GET_PRIVATE (config)->domains;
-}
-
-/**
- * nm_ip6_config_get_searches:
- * @config: a #NMIP6Config
- *
- * Gets the DNS search strings.
- *
- * Returns: (transfer none): the array of DNS search strings.
- * (This is never %NULL, though it may be 0-length).
- **/
-const char * const *
-nm_ip6_config_get_searches (NMIP6Config *config)
-{
-       g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL);
-
-       return (const char * const *) NM_IP6_CONFIG_GET_PRIVATE (config)->searches;
-}
-
-/**
- * nm_ip6_config_get_routes:
- * @config: a #NMIP6Config
- *
- * Gets the routes.
- *
- * Returns: (element-type NMIPRoute) (transfer none): the #GPtrArray containing
- * #NMIPRoutes. This is the internal copy used by the configuration, and must
- * not be modified.
- **/
-GPtrArray *
-nm_ip6_config_get_routes (NMIP6Config *config)
-{
-       g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL);
-
-       return NM_IP6_CONFIG_GET_PRIVATE (config)->routes;
-}
-
-static void
-finalize (GObject *object)
-{
-       NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (object);
-
-       g_free (priv->gateway);
-
-       g_ptr_array_unref (priv->addresses);
-       g_ptr_array_unref (priv->routes);
-
-       g_strfreev (priv->nameservers);
-       g_strfreev (priv->domains);
-       g_strfreev (priv->searches);
-
-       G_OBJECT_CLASS (nm_ip6_config_parent_class)->finalize (object);
-}
-
-static void
-get_property (GObject *object,
-              guint prop_id,
-              GValue *value,
-              GParamSpec *pspec)
-{
-       NMIP6Config *self = NM_IP6_CONFIG (object);
-
-       switch (prop_id) {
-       case PROP_GATEWAY:
-               g_value_set_string (value, nm_ip6_config_get_gateway (self));
-               break;
-       case PROP_ADDRESSES:
-               g_value_take_boxed (value, _nm_utils_copy_array (nm_ip6_config_get_addresses (self),
-                                                                (NMUtilsCopyFunc) nm_ip_address_dup,
-                                                                (GDestroyNotify) nm_ip_address_unref));
-               break;
-       case PROP_ROUTES:
-               g_value_take_boxed (value, _nm_utils_copy_array (nm_ip6_config_get_routes (self),
-                                                                (NMUtilsCopyFunc) nm_ip_route_dup,
-                                                                (GDestroyNotify) nm_ip_route_unref));
-               break;
-       case PROP_NAMESERVERS:
-               g_value_set_boxed (value, (char **) nm_ip6_config_get_nameservers (self));
-               break;
-       case PROP_DOMAINS:
-               g_value_set_boxed (value, (char **) nm_ip6_config_get_domains (self));
-               break;
-       case PROP_SEARCHES:
-               g_value_set_boxed (value, (char **) nm_ip6_config_get_searches (self));
-               break;
-       default:
-               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-               break;
-       }
-}
+G_DEFINE_TYPE (NMIP6Config, nm_ip6_config, NM_TYPE_IP_CONFIG)
 
 static void
 nm_ip6_config_init (NMIP6Config *config)
 {
-       NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
-
-       priv->addresses = g_ptr_array_new ();
-       priv->routes = g_ptr_array_new ();
-       priv->nameservers = g_new0 (char *, 1);
-       priv->domains = g_new0 (char *, 1);
-       priv->searches = g_new0 (char *, 1);
 }
 
 static void
 nm_ip6_config_class_init (NMIP6ConfigClass *config_class)
 {
-       GObjectClass *object_class = G_OBJECT_CLASS (config_class);
        NMObjectClass *nm_object_class = NM_OBJECT_CLASS (config_class);
 
-       g_type_class_add_private (config_class, sizeof (NMIP6ConfigPrivate));
-
        _nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_IP6_CONFIG);
-
-       /* virtual methods */
-       object_class->get_property = get_property;
-       object_class->finalize = finalize;
-
-       nm_object_class->init_dbus = init_dbus;
-
-       /* properties */
-
-       /**
-        * NMIP6Config:gateway:
-        *
-        * The IPv6 gateway as string
-        **/
-       g_object_class_install_property
-           (object_class, PROP_GATEWAY,
-            g_param_spec_string (NM_IP6_CONFIG_GATEWAY, "", "",
-                                 NULL,
-                                 G_PARAM_READABLE |
-                                 G_PARAM_STATIC_STRINGS));
-
-       /**
-        * NMIP6Config:addresses:
-        *
-        * The #GPtrArray containing the IPv6 addresses (#NMIPAddress).
-        **/
-       g_object_class_install_property
-           (object_class, PROP_ADDRESSES,
-            g_param_spec_boxed (NM_IP6_CONFIG_ADDRESSES, "", "",
-                                G_TYPE_PTR_ARRAY,
-                                G_PARAM_READABLE |
-                                G_PARAM_STATIC_STRINGS));
-
-       /**
-        * NMIP6Config:routes:
-        *
-        * The #GPtrArray containing the IPv6 routes (#NMIPRoute).
-        **/
-       g_object_class_install_property
-           (object_class, PROP_ROUTES,
-            g_param_spec_boxed (NM_IP6_CONFIG_ROUTES, "", "",
-                                G_TYPE_PTR_ARRAY,
-                                G_PARAM_READABLE |
-                                G_PARAM_STATIC_STRINGS));
-
-       /**
-        * NMIP6Config:nameservers:
-        *
-        * The #GPtrArray containing elements of type 'struct ip6_addr' which
-        * contain the addresses of nameservers of the configuration.
-        **/
-       g_object_class_install_property
-           (object_class, PROP_NAMESERVERS,
-            g_param_spec_boxed (NM_IP6_CONFIG_NAMESERVERS, "", "",
-                                G_TYPE_STRV,
-                                G_PARAM_READABLE |
-                                G_PARAM_STATIC_STRINGS));
-
-       /**
-        * NMIP6Config:domains:
-        *
-        * The #GPtrArray containing domain strings of the configuration.
-        **/
-       g_object_class_install_property
-           (object_class, PROP_DOMAINS,
-            g_param_spec_boxed (NM_IP6_CONFIG_DOMAINS, "", "",
-                                G_TYPE_STRV,
-                                G_PARAM_READABLE |
-                                G_PARAM_STATIC_STRINGS));
-
-       /**
-        * NMIP6Config:searches:
-        *
-        * The #GPtrArray containing dns search strings of the configuration.
-        **/
-       g_object_class_install_property
-           (object_class, PROP_SEARCHES,
-            g_param_spec_boxed (NM_IP6_CONFIG_SEARCHES, "", "",
-                                G_TYPE_STRV,
-                                G_PARAM_READABLE |
-                                G_PARAM_STATIC_STRINGS));
-
 }
index 2c98633..1953476 100644 (file)
 #ifndef __NM_IP6_CONFIG_H__
 #define __NM_IP6_CONFIG_H__
 
-#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION)
-#error "Only <NetworkManager.h> can be included directly."
-#endif
-
-#include <nm-object.h>
+#include <nm-ip-config.h>
 
 G_BEGIN_DECLS
 
@@ -37,33 +33,19 @@ G_BEGIN_DECLS
 #define NM_IS_IP6_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_IP6_CONFIG))
 #define NM_IP6_CONFIG_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_IP6_CONFIG, NMIP6ConfigClass))
 
-struct _NMIP6Config {
-       NMObject parent;
-};
+typedef struct {
+       NMIPConfig parent;
+} NMIP6Config;
 
 typedef struct {
-       NMObjectClass parent;
+       NMIPConfigClass parent;
 
        /*< private >*/
        gpointer padding[4];
 } NMIP6ConfigClass;
 
-#define NM_IP6_CONFIG_GATEWAY "gateway"
-#define NM_IP6_CONFIG_ADDRESSES "addresses"
-#define NM_IP6_CONFIG_ROUTES "routes"
-#define NM_IP6_CONFIG_NAMESERVERS "nameservers"
-#define NM_IP6_CONFIG_DOMAINS "domains"
-#define NM_IP6_CONFIG_SEARCHES "searches"
-
 GType nm_ip6_config_get_type (void);
 
-const char *           nm_ip6_config_get_gateway         (NMIP6Config *config);
-GPtrArray *            nm_ip6_config_get_addresses       (NMIP6Config *config);
-GPtrArray *            nm_ip6_config_get_routes          (NMIP6Config *config);
-const char * const *   nm_ip6_config_get_nameservers     (NMIP6Config *config);
-const char * const *   nm_ip6_config_get_domains         (NMIP6Config *config);
-const char * const *   nm_ip6_config_get_searches        (NMIP6Config *config);
-
 G_END_DECLS
 
 #endif /* __NM_IP6_CONFIG_H__ */
index 940a329..eb92203 100644 (file)
@@ -45,8 +45,7 @@ typedef struct _NMDeviceWifi        NMDeviceWifi;
 typedef struct _NMDeviceWimax       NMDeviceWimax;
 typedef struct _NMDhcp4Config       NMDhcp4Config;
 typedef struct _NMDhcp6Config       NMDhcp6Config;
-typedef struct _NMIP4Config         NMIP4Config;
-typedef struct _NMIP6Config         NMIP6Config;
+typedef struct _NMIPConfig          NMIPConfig;
 typedef struct _NMObject            NMObject;
 typedef struct _NMRemoteConnection  NMRemoteConnection;
 typedef struct _NMSecretAgent       NMSecretAgent;