2008-08-10 Dan Williams <dcbw@redhat.com>

* src/nm-ip4-config.c
		- (get_property): use common ip4 address/route conversion functions
		- (nm_ip4_config_replace_address, nm_ip4_config_replace_route): should
			copy the new route here, not take ownership



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3919 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams
2008-08-10 22:37:21 +00:00
parent 72daa78098
commit 0758aa478e
2 changed files with 19 additions and 35 deletions

View File

@@ -1,3 +1,10 @@
2008-08-10 Dan Williams <dcbw@redhat.com>
* src/nm-ip4-config.c
- (get_property): use common ip4 address/route conversion functions
- (nm_ip4_config_replace_address, nm_ip4_config_replace_route): should
copy the new route here, not take ownership
2008-08-08 Tambet Ingo <tambet@gmail.com> 2008-08-08 Tambet Ingo <tambet@gmail.com>
* system-settings/plugins/ifcfg-suse/parser.c (make_ip4_setting): * system-settings/plugins/ifcfg-suse/parser.c (make_ip4_setting):

View File

@@ -126,6 +126,7 @@ nm_ip4_config_replace_address (NMIP4Config *config,
NMSettingIP4Address *new_address) NMSettingIP4Address *new_address)
{ {
NMIP4ConfigPrivate *priv; NMIP4ConfigPrivate *priv;
NMSettingIP4Address *copy;
GSList *old; GSList *old;
g_return_if_fail (NM_IS_IP4_CONFIG (config)); g_return_if_fail (NM_IS_IP4_CONFIG (config));
@@ -133,9 +134,11 @@ nm_ip4_config_replace_address (NMIP4Config *config,
priv = NM_IP4_CONFIG_GET_PRIVATE (config); priv = NM_IP4_CONFIG_GET_PRIVATE (config);
old = g_slist_nth (priv->addresses, i); old = g_slist_nth (priv->addresses, i);
g_return_if_fail (old != NULL); g_return_if_fail (old != NULL);
g_free (old->data); g_free (old->data);
old->data = new_address;
copy = g_malloc0 (sizeof (NMSettingIP4Address));
memcpy (copy, new_address, sizeof (NMSettingIP4Address));
old->data = copy;
} }
const NMSettingIP4Address *nm_ip4_config_get_address (NMIP4Config *config, guint i) const NMSettingIP4Address *nm_ip4_config_get_address (NMIP4Config *config, guint i)
@@ -252,6 +255,7 @@ nm_ip4_config_replace_route (NMIP4Config *config,
NMSettingIP4Route *new_route) NMSettingIP4Route *new_route)
{ {
NMIP4ConfigPrivate *priv; NMIP4ConfigPrivate *priv;
NMSettingIP4Route *copy;
GSList *old; GSList *old;
g_return_if_fail (NM_IS_IP4_CONFIG (config)); g_return_if_fail (NM_IS_IP4_CONFIG (config));
@@ -259,9 +263,11 @@ nm_ip4_config_replace_route (NMIP4Config *config,
priv = NM_IP4_CONFIG_GET_PRIVATE (config); priv = NM_IP4_CONFIG_GET_PRIVATE (config);
old = g_slist_nth (priv->routes, i); old = g_slist_nth (priv->routes, i);
g_return_if_fail (old != NULL); g_return_if_fail (old != NULL);
g_free (old->data); g_free (old->data);
old->data = new_route;
copy = g_malloc0 (sizeof (NMSettingIP4Route));
memcpy (copy, new_route, sizeof (NMSettingIP4Route));
old->data = copy;
} }
const NMSettingIP4Route * const NMSettingIP4Route *
@@ -490,35 +496,6 @@ finalize (GObject *object)
nm_utils_slist_free (priv->routes, g_free); nm_utils_slist_free (priv->routes, g_free);
} }
static void
ip4_addresses_to_gvalue (GSList *list, GValue *value)
{
GPtrArray *addresses;
GSList *iter;
addresses = g_ptr_array_new ();
for (iter = list; iter; iter = iter->next) {
NMSettingIP4Address *ip4_addr = (NMSettingIP4Address *) iter->data;
GArray *array;
const guint32 empty_val = 0;
array = g_array_sized_new (FALSE, TRUE, sizeof (guint32), 3);
g_array_append_val (array, ip4_addr->address);
g_array_append_val (array, ip4_addr->prefix);
if (ip4_addr->gateway)
g_array_append_val (array, ip4_addr->gateway);
else
g_array_append_val (array, empty_val);
g_ptr_array_add (addresses, array);
}
g_value_take_boxed (value, addresses);
}
static void static void
get_property (GObject *object, guint prop_id, get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec) GValue *value, GParamSpec *pspec)
@@ -527,7 +504,7 @@ get_property (GObject *object, guint prop_id,
switch (prop_id) { switch (prop_id) {
case PROP_ADDRESSES: case PROP_ADDRESSES:
ip4_addresses_to_gvalue (priv->addresses, value); nm_utils_ip4_addresses_to_gvalue (priv->addresses, value);
break; break;
case PROP_HOSTNAME: case PROP_HOSTNAME:
g_value_set_string (value, priv->hostname); g_value_set_string (value, priv->hostname);
@@ -539,7 +516,7 @@ get_property (GObject *object, guint prop_id,
g_value_set_boxed (value, priv->domains); g_value_set_boxed (value, priv->domains);
break; break;
case PROP_ROUTES: case PROP_ROUTES:
ip4_addresses_to_gvalue (priv->routes, value); nm_utils_ip4_routes_to_gvalue (priv->routes, value);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);