diff options
author | Dan Williams <dcbw@redhat.com> | 2008-05-06 21:53:22 +0000 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2008-05-06 21:53:22 +0000 |
commit | 51503b2d5f4e891de39c2081d0ccb01c41fa258d (patch) | |
tree | e2bf11108d40e970679ccd9542f0d6ec46ec160a /libnm-glib/nm-ip4-config.c | |
parent | 3cbc245395b19982add4d7d394cb9c6b03b2109d (diff) | |
download | NetworkManager-51503b2d5f4e891de39c2081d0ccb01c41fa258d.tar.gz |
2008-05-06 Dan Williams <dcbw@redhat.com>
* src/dhcp-manager/nm-dhcp-manager.c
- (nm_dhcp_manager_get_ip4_config): clean up; update for changes to
NMIP4Config to support multiple IP addresses
* src/NetworkManagerUtils.c
- (nm_utils_merge_ip4_config): update for multiple IP addresses
* src/nm-ip4-config.c
src/nm-ip4-config.h
- Store a list of IPv4 address/netmask/gateway tuples
- (nm_ip4_config_get_gateway, nm_ip4_config_set_gateway,
nm_ip4_config_get_netmask, nm_ip4_config_set_netmask,
nm_ip4_config_get_broadcast, nm_ip4_config_set_broadcast,
nm_ip4_config_set_address): remove
- (nm_ip4_config_take_address, nm_ip4_config_add_address,
nm_ip4_config_replace_address, nm_ip4_config_get_num_addresses):
new functions; handle multiple IPv4 addresses
* src/nm-device.c
src/ppp-manager/nm-ppp-manager.c
src/vpn-manager/nm-vpn-connection.c
src/NetworkManagerPolicy.c
test/nm-tool.c
libnm-glib/libnm-glib-test.c
- update for changes to NMIP4Config for multiple IPv4 addresses
* src/NetworkManagerSystem.c
- (nm_system_device_set_ip4_route): don't add the route if any address
is on the same subnet as the destination
- (check_one_address): ignore the exact match, just match family and
interface index
- (add_ip4_addresses): add all IPv4 addresses in an NMIP4Config to
an interface
- (nm_system_device_set_from_ip4_config): use add_ip4_addresses()
- (nm_system_vpn_device_set_from_ip4_config): use add_ip4_addresses()
* introspection/nm-ip4-config.xml
- Remove 'address', 'gateway', 'netmask', and 'broadcast' properties
- Add 'addresses' property which is an array of (uuu) tuples of
address/netmask/gateway
* libnm-util/nm-setting-ip4-config.c
- (set_property): use ip-address <-> GValue converters from nm-utils.c
* libnm-glib/nm-ip4-config.c
libnm-glib/nm-ip4-config.h
- Handle D-Bus interface changes to support multiple IP addresses
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3637 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
Diffstat (limited to 'libnm-glib/nm-ip4-config.c')
-rw-r--r-- | libnm-glib/nm-ip4-config.c | 152 |
1 files changed, 43 insertions, 109 deletions
diff --git a/libnm-glib/nm-ip4-config.c b/libnm-glib/nm-ip4-config.c index 51426c8a7a..6eb2c522c9 100644 --- a/libnm-glib/nm-ip4-config.c +++ b/libnm-glib/nm-ip4-config.c @@ -4,6 +4,7 @@ #include "NetworkManager.h" #include "nm-types-private.h" #include "nm-object-private.h" +#include "nm-utils.h" G_DEFINE_TYPE (NMIP4Config, nm_ip4_config, NM_TYPE_OBJECT) @@ -12,10 +13,7 @@ G_DEFINE_TYPE (NMIP4Config, nm_ip4_config, NM_TYPE_OBJECT) typedef struct { DBusGProxy *proxy; - guint32 address; - guint32 gateway; - guint32 netmask; - guint32 broadcast; + GSList *addresses; char *hostname; GArray *nameservers; GPtrArray *domains; @@ -25,10 +23,7 @@ typedef struct { enum { PROP_0, - PROP_ADDRESS, - PROP_GATEWAY, - PROP_NETMASK, - PROP_BROADCAST, + PROP_ADDRESSES, PROP_HOSTNAME, PROP_NAMESERVERS, PROP_DOMAINS, @@ -44,6 +39,21 @@ nm_ip4_config_init (NMIP4Config *config) } static gboolean +demarshal_ip4_address_array (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) +{ + NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object); + + g_slist_foreach (priv->addresses, (GFunc) g_free, NULL); + g_slist_free (priv->addresses); + priv->addresses = NULL; + + priv->addresses = nm_utils_ip4_addresses_from_gvalue (value); + nm_object_queue_notify (object, NM_IP4_CONFIG_ADDRESSES); + + return TRUE; +} + +static gboolean demarshal_ip4_array (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) { if (!nm_uint_array_demarshal (value, (GArray **) field)) @@ -71,10 +81,7 @@ register_for_property_changed (NMIP4Config *config) { NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config); const NMPropertiesChangedInfo property_changed_info[] = { - { NM_IP4_CONFIG_ADDRESS, nm_object_demarshal_generic, &priv->address }, - { NM_IP4_CONFIG_GATEWAY, nm_object_demarshal_generic, &priv->gateway }, - { NM_IP4_CONFIG_NETMASK, nm_object_demarshal_generic, &priv->netmask }, - { NM_IP4_CONFIG_BROADCAST, nm_object_demarshal_generic, &priv->broadcast }, + { NM_IP4_CONFIG_ADDRESSES, demarshal_ip4_address_array, &priv->addresses }, { NM_IP4_CONFIG_HOSTNAME, nm_object_demarshal_generic, &priv->hostname }, { NM_IP4_CONFIG_NAMESERVERS, demarshal_ip4_array, &priv->nameservers }, { NM_IP4_CONFIG_DOMAINS, demarshal_domains, &priv->domains }, @@ -121,6 +128,9 @@ finalize (GObject *object) { NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object); + g_slist_foreach (priv->addresses, (GFunc) g_free, NULL); + g_slist_free (priv->addresses); + g_free (priv->hostname); g_free (priv->nis_domain); if (priv->nameservers) @@ -143,19 +153,11 @@ get_property (GObject *object, GParamSpec *pspec) { NMIP4Config *self = NM_IP4_CONFIG (object); + NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (self); switch (prop_id) { - case PROP_ADDRESS: - g_value_set_uint (value, nm_ip4_config_get_address (self)); - break; - case PROP_GATEWAY: - g_value_set_uint (value, nm_ip4_config_get_gateway (self)); - break; - case PROP_NETMASK: - g_value_set_uint (value, nm_ip4_config_get_netmask (self)); - break; - case PROP_BROADCAST: - g_value_set_uint (value, nm_ip4_config_get_broadcast (self)); + case PROP_ADDRESSES: + nm_utils_ip4_addresses_to_gvalue (priv->addresses, value); break; case PROP_HOSTNAME: g_value_set_string (value, nm_ip4_config_get_hostname (self)); @@ -192,36 +194,11 @@ nm_ip4_config_class_init (NMIP4ConfigClass *config_class) /* properties */ g_object_class_install_property - (object_class, PROP_ADDRESS, - g_param_spec_uint (NM_IP4_CONFIG_ADDRESS, - "Address", - "Address", - 0, G_MAXUINT32, 0, - G_PARAM_READABLE)); - - g_object_class_install_property - (object_class, PROP_GATEWAY, - g_param_spec_uint (NM_IP4_CONFIG_GATEWAY, - "Gateway", - "Gateway", - 0, G_MAXUINT32, 0, - G_PARAM_READABLE)); - - g_object_class_install_property - (object_class, PROP_NETMASK, - g_param_spec_uint (NM_IP4_CONFIG_NETMASK, - "Netmask", - "Netmask", - 0, G_MAXUINT32, 0, - G_PARAM_READABLE)); - - g_object_class_install_property - (object_class, PROP_BROADCAST, - g_param_spec_uint (NM_IP4_CONFIG_BROADCAST, - "Broadcast", - "Broadcast", - 0, G_MAXUINT32, 0, - G_PARAM_READABLE)); + (object_class, PROP_ADDRESSES, + g_param_spec_pointer (NM_IP4_CONFIG_ADDRESSES, + "Addresses", + "Addresses", + G_PARAM_READABLE)); g_object_class_install_property (object_class, PROP_HOSTNAME, @@ -273,72 +250,29 @@ nm_ip4_config_new (DBusGConnection *connection, const char *object_path) NULL); } -guint32 -nm_ip4_config_get_address (NMIP4Config *config) -{ - NMIP4ConfigPrivate *priv; - - g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0); - - priv = NM_IP4_CONFIG_GET_PRIVATE (config); - if (!priv->address) { - priv->address = nm_object_get_uint_property (NM_OBJECT (config), - NM_DBUS_INTERFACE_IP4_CONFIG, - "Address"); - } - - return priv->address; -} - -guint32 -nm_ip4_config_get_gateway (NMIP4Config *config) +const GSList * +nm_ip4_config_get_addresses (NMIP4Config *config) { NMIP4ConfigPrivate *priv; + GValue value = { 0, }; g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0); priv = NM_IP4_CONFIG_GET_PRIVATE (config); - if (!priv->gateway) { - priv->gateway = nm_object_get_uint_property (NM_OBJECT (config), - NM_DBUS_INTERFACE_IP4_CONFIG, - "Gateway"); - } - - return priv->gateway; -} - -guint32 -nm_ip4_config_get_netmask (NMIP4Config *config) -{ - NMIP4ConfigPrivate *priv; + if (priv->addresses) + return priv->addresses; - g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0); - - priv = NM_IP4_CONFIG_GET_PRIVATE (config); - if (!priv->netmask) { - priv->netmask = nm_object_get_uint_property (NM_OBJECT (config), - NM_DBUS_INTERFACE_IP4_CONFIG, - "Netmask"); + if (!nm_object_get_property (NM_OBJECT (config), + "org.freedesktop.DBus.Properties", + "Addresses", + &value)) { + return NULL; } - return priv->netmask; -} - -guint32 -nm_ip4_config_get_broadcast (NMIP4Config *config) -{ - NMIP4ConfigPrivate *priv; - - g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0); - - priv = NM_IP4_CONFIG_GET_PRIVATE (config); - if (!priv->broadcast) { - priv->broadcast = nm_object_get_uint_property (NM_OBJECT (config), - NM_DBUS_INTERFACE_IP4_CONFIG, - "Broadcast"); - } + demarshal_ip4_address_array (NM_OBJECT (config), NULL, &value, &priv->addresses); + g_value_unset (&value); - return priv->broadcast; + return priv->addresses; } const char * |