Commit 98375657 authored by Dan Winship's avatar Dan Winship

libnm-core: improve NMSettingIP4Config / NMSettingIP6Config property types

Make the :addresses and :routes properties be GPtrArrays of
NMIP4Address, etc, rather than just reflecting the D-Bus data.

Make the :dns properties be arrays of strings rather than arrays of
binary IP addresses (and update the corresponding APIs as well).
parent 9ed6bd2b
...@@ -789,9 +789,6 @@ vpn_data_item (const char *key, const char *value, gpointer user_data) ...@@ -789,9 +789,6 @@ vpn_data_item (const char *key, const char *value, gpointer user_data)
GValue val = G_VALUE_INIT; \ GValue val = G_VALUE_INIT; \
g_value_init (&val, G_TYPE_STRING); \ g_value_init (&val, G_TYPE_STRING); \
g_object_get_property (G_OBJECT (setting), property_name, &val); \ g_object_get_property (G_OBJECT (setting), property_name, &val); \
/* Getters return allocated values, and returning the string \
* the GValue copied from the object without unsetting the \
* GValue fulfills that requirement. */ \
s = g_value_dup_string (&val); \ s = g_value_dup_string (&val); \
g_value_unset (&val); \ g_value_unset (&val); \
return s; \ return s; \
...@@ -1200,8 +1197,82 @@ DEFINE_GETTER (nmc_property_ib_get_parent, NM_SETTING_INFINIBAND_PARENT) ...@@ -1200,8 +1197,82 @@ DEFINE_GETTER (nmc_property_ib_get_parent, NM_SETTING_INFINIBAND_PARENT)
DEFINE_GETTER (nmc_property_ipv4_get_method, NM_SETTING_IP4_CONFIG_METHOD) DEFINE_GETTER (nmc_property_ipv4_get_method, NM_SETTING_IP4_CONFIG_METHOD)
DEFINE_GETTER (nmc_property_ipv4_get_dns, NM_SETTING_IP4_CONFIG_DNS) DEFINE_GETTER (nmc_property_ipv4_get_dns, NM_SETTING_IP4_CONFIG_DNS)
DEFINE_GETTER (nmc_property_ipv4_get_dns_search, NM_SETTING_IP4_CONFIG_DNS_SEARCH) DEFINE_GETTER (nmc_property_ipv4_get_dns_search, NM_SETTING_IP4_CONFIG_DNS_SEARCH)
DEFINE_GETTER (nmc_property_ipv4_get_addresses, NM_SETTING_IP4_CONFIG_ADDRESSES)
DEFINE_GETTER (nmc_property_ipv4_get_routes, NM_SETTING_IP4_CONFIG_ROUTES) static char *
nmc_property_ipv4_get_addresses (NMSetting *setting)
{
NMSettingIP4Config *s_ip4 = NM_SETTING_IP4_CONFIG (setting);
GString *printable;
guint32 num_addresses, i;
NMIP4Address *addr;
char buf[INET_ADDRSTRLEN];
printable = g_string_new (NULL);
num_addresses = nm_setting_ip4_config_get_num_addresses (s_ip4);
for (i = 0; i < num_addresses; i++) {
addr = nm_setting_ip4_config_get_address (s_ip4, i);
if (printable->len > 0)
g_string_append (printable, "; ");
g_string_append (printable, "{ ");
nm_utils_inet4_ntop (nm_ip4_address_get_address (addr), buf);
g_string_append_printf (printable, "ip = %s", buf);
g_string_append_printf (printable, "/%u", nm_ip4_address_get_prefix (addr));
if (nm_ip4_address_get_gateway (addr)) {
nm_utils_inet4_ntop (nm_ip4_address_get_gateway (addr), buf);
g_string_append_printf (printable, ", gw = %s", buf);
}
g_string_append (printable, " }");
}
return g_string_free (printable, FALSE);
}
static char *
nmc_property_ipv4_get_routes (NMSetting *setting)
{
NMSettingIP4Config *s_ip4 = NM_SETTING_IP4_CONFIG (setting);
GString *printable;
guint32 num_routes, i;
NMIP4Route *route;
char buf[INET_ADDRSTRLEN];
printable = g_string_new (NULL);
num_routes = nm_setting_ip4_config_get_num_routes (s_ip4);
for (i = 0; i < num_routes; i++) {
route = nm_setting_ip4_config_get_route (s_ip4, i);
if (printable->len > 0)
g_string_append (printable, "; ");
g_string_append (printable, "{ ");
nm_utils_inet4_ntop (nm_ip4_route_get_dest (route), buf);
g_string_append_printf (printable, "ip = %s", buf);
g_string_append_printf (printable, "/%u", nm_ip4_route_get_prefix (route));
if (nm_ip4_route_get_next_hop (route)) {
nm_utils_inet4_ntop (nm_ip4_route_get_next_hop (route), buf);
g_string_append_printf (printable, ", nh = %s", buf);
}
if (nm_ip4_route_get_metric (route))
g_string_append_printf (printable, ", mt = %u", nm_ip4_route_get_metric (route));
g_string_append (printable, " }");
}
return g_string_free (printable, FALSE);
}
DEFINE_GETTER (nmc_property_ipv4_get_ignore_auto_routes, NM_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES) DEFINE_GETTER (nmc_property_ipv4_get_ignore_auto_routes, NM_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES)
DEFINE_GETTER (nmc_property_ipv4_get_ignore_auto_dns, NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS) DEFINE_GETTER (nmc_property_ipv4_get_ignore_auto_dns, NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS)
DEFINE_GETTER (nmc_property_ipv4_get_dhcp_client_id, NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID) DEFINE_GETTER (nmc_property_ipv4_get_dhcp_client_id, NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID)
...@@ -1214,8 +1285,82 @@ DEFINE_GETTER (nmc_property_ipv4_get_may_fail, NM_SETTING_IP4_CONFIG_MAY_FAIL) ...@@ -1214,8 +1285,82 @@ DEFINE_GETTER (nmc_property_ipv4_get_may_fail, NM_SETTING_IP4_CONFIG_MAY_FAIL)
DEFINE_GETTER (nmc_property_ipv6_get_method, NM_SETTING_IP6_CONFIG_METHOD) DEFINE_GETTER (nmc_property_ipv6_get_method, NM_SETTING_IP6_CONFIG_METHOD)
DEFINE_GETTER (nmc_property_ipv6_get_dns, NM_SETTING_IP6_CONFIG_DNS) DEFINE_GETTER (nmc_property_ipv6_get_dns, NM_SETTING_IP6_CONFIG_DNS)
DEFINE_GETTER (nmc_property_ipv6_get_dns_search, NM_SETTING_IP6_CONFIG_DNS_SEARCH) DEFINE_GETTER (nmc_property_ipv6_get_dns_search, NM_SETTING_IP6_CONFIG_DNS_SEARCH)
DEFINE_GETTER (nmc_property_ipv6_get_addresses, NM_SETTING_IP6_CONFIG_ADDRESSES)
DEFINE_GETTER (nmc_property_ipv6_get_routes, NM_SETTING_IP6_CONFIG_ROUTES) static char *
nmc_property_ipv6_get_addresses (NMSetting *setting)
{
NMSettingIP6Config *s_ip6 = NM_SETTING_IP6_CONFIG (setting);
GString *printable;
guint32 num_addresses, i;
NMIP6Address *addr;
char buf[INET6_ADDRSTRLEN];
printable = g_string_new (NULL);
num_addresses = nm_setting_ip6_config_get_num_addresses (s_ip6);
for (i = 0; i < num_addresses; i++) {
addr = nm_setting_ip6_config_get_address (s_ip6, i);
if (printable->len > 0)
g_string_append (printable, "; ");
g_string_append (printable, "{ ");
nm_utils_inet6_ntop (nm_ip6_address_get_address (addr), buf);
g_string_append_printf (printable, "ip = %s", buf);
g_string_append_printf (printable, "/%u", nm_ip6_address_get_prefix (addr));
if (nm_ip6_address_get_gateway (addr)) {
nm_utils_inet6_ntop (nm_ip6_address_get_gateway (addr), buf);
g_string_append_printf (printable, ", gw = %s", buf);
}
g_string_append (printable, " }");
}
return g_string_free (printable, FALSE);
}
static char *
nmc_property_ipv6_get_routes (NMSetting *setting)
{
NMSettingIP6Config *s_ip6 = NM_SETTING_IP6_CONFIG (setting);
GString *printable;
guint32 num_routes, i;
NMIP6Route *route;
char buf[INET6_ADDRSTRLEN];
printable = g_string_new (NULL);
num_routes = nm_setting_ip6_config_get_num_routes (s_ip6);
for (i = 0; i < num_routes; i++) {
route = nm_setting_ip6_config_get_route (s_ip6, i);
if (printable->len > 0)
g_string_append (printable, "; ");
g_string_append (printable, "{ ");
nm_utils_inet6_ntop (nm_ip6_route_get_dest (route), buf);
g_string_append_printf (printable, "ip = %s", buf);
g_string_append_printf (printable, "/%u", nm_ip6_route_get_prefix (route));
if (nm_ip6_route_get_next_hop (route)) {
nm_utils_inet6_ntop (nm_ip6_route_get_next_hop (route), buf);
g_string_append_printf (printable, ", nh = %s", buf);
}
if (nm_ip6_route_get_metric (route))
g_string_append_printf (printable, ", mt = %u", nm_ip6_route_get_metric (route));
g_string_append (printable, " }");
}
return g_string_free (printable, FALSE);
}
DEFINE_GETTER (nmc_property_ipv6_get_ignore_auto_routes, NM_SETTING_IP6_CONFIG_IGNORE_AUTO_ROUTES) DEFINE_GETTER (nmc_property_ipv6_get_ignore_auto_routes, NM_SETTING_IP6_CONFIG_IGNORE_AUTO_ROUTES)
DEFINE_GETTER (nmc_property_ipv6_get_ignore_auto_dns, NM_SETTING_IP6_CONFIG_IGNORE_AUTO_DNS) DEFINE_GETTER (nmc_property_ipv6_get_ignore_auto_dns, NM_SETTING_IP6_CONFIG_IGNORE_AUTO_DNS)
DEFINE_GETTER (nmc_property_ipv6_get_never_default, NM_SETTING_IP6_CONFIG_NEVER_DEFAULT) DEFINE_GETTER (nmc_property_ipv6_get_never_default, NM_SETTING_IP6_CONFIG_NEVER_DEFAULT)
...@@ -2885,19 +3030,20 @@ DEFINE_ALLOWED_VAL_FUNC (nmc_property_ipv4_allowed_method, ipv4_valid_methods) ...@@ -2885,19 +3030,20 @@ DEFINE_ALLOWED_VAL_FUNC (nmc_property_ipv4_allowed_method, ipv4_valid_methods)
static gboolean static gboolean
nmc_property_ipv4_set_dns (NMSetting *setting, const char *prop, const char *val, GError **error) nmc_property_ipv4_set_dns (NMSetting *setting, const char *prop, const char *val, GError **error)
{ {
char **strv = NULL, **iter; char **strv = NULL, **iter, *addr;
guint32 ip4_addr; guint32 ip4_addr;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
strv = nmc_strsplit_set (val, " \t,", 0); strv = nmc_strsplit_set (val, " \t,", 0);
for (iter = strv; iter && *iter; iter++) { for (iter = strv; iter && *iter; iter++) {
if (inet_pton (AF_INET, g_strstrip (*iter), &ip4_addr) < 1) { addr = g_strstrip (*iter);
g_set_error (error, 1, 0, _("invalid IPv4 address '%s'"), *iter); if (inet_pton (AF_INET, addr, &ip4_addr) < 1) {
g_set_error (error, 1, 0, _("invalid IPv4 address '%s'"), addr);
g_strfreev (strv); g_strfreev (strv);
return FALSE; return FALSE;
} }
nm_setting_ip4_config_add_dns (NM_SETTING_IP4_CONFIG (setting), ip4_addr); nm_setting_ip4_config_add_dns (NM_SETTING_IP4_CONFIG (setting), addr);
} }
g_strfreev (strv); g_strfreev (strv);
return TRUE; return TRUE;
...@@ -2916,7 +3062,7 @@ _validate_and_remove_ipv4_dns (NMSettingIP4Config *setting, ...@@ -2916,7 +3062,7 @@ _validate_and_remove_ipv4_dns (NMSettingIP4Config *setting,
return FALSE; return FALSE;
} }
ret = nm_setting_ip4_config_remove_dns_by_value (setting, ip4_addr); ret = nm_setting_ip4_config_remove_dns_by_value (setting, dns);
if (!ret) if (!ret)
g_set_error (error, 1, 0, _("the property doesn't contain DNS server '%s'"), dns); g_set_error (error, 1, 0, _("the property doesn't contain DNS server '%s'"), dns);
return ret; return ret;
...@@ -3230,19 +3376,20 @@ DEFINE_ALLOWED_VAL_FUNC (nmc_property_ipv6_allowed_method, ipv6_valid_methods) ...@@ -3230,19 +3376,20 @@ DEFINE_ALLOWED_VAL_FUNC (nmc_property_ipv6_allowed_method, ipv6_valid_methods)
static gboolean static gboolean
nmc_property_ipv6_set_dns (NMSetting *setting, const char *prop, const char *val, GError **error) nmc_property_ipv6_set_dns (NMSetting *setting, const char *prop, const char *val, GError **error)
{ {
char **strv = NULL, **iter; char **strv = NULL, **iter, *addr;
struct in6_addr ip6_addr; struct in6_addr ip6_addr;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
strv = nmc_strsplit_set (val, " \t,", 0); strv = nmc_strsplit_set (val, " \t,", 0);
for (iter = strv; iter && *iter; iter++) { for (iter = strv; iter && *iter; iter++) {
if (inet_pton (AF_INET6, g_strstrip (*iter), &ip6_addr) < 1) { addr = g_strstrip (*iter);
g_set_error (error, 1, 0, _("invalid IPv6 address '%s'"), *iter); if (inet_pton (AF_INET6, addr, &ip6_addr) < 1) {
g_set_error (error, 1, 0, _("invalid IPv6 address '%s'"), addr);
g_strfreev (strv); g_strfreev (strv);
return FALSE; return FALSE;
} }
nm_setting_ip6_config_add_dns (NM_SETTING_IP6_CONFIG (setting), &ip6_addr); nm_setting_ip6_config_add_dns (NM_SETTING_IP6_CONFIG (setting), addr);
} }
g_strfreev (strv); g_strfreev (strv);
return TRUE; return TRUE;
...@@ -3261,7 +3408,7 @@ _validate_and_remove_ipv6_dns (NMSettingIP6Config *setting, ...@@ -3261,7 +3408,7 @@ _validate_and_remove_ipv6_dns (NMSettingIP6Config *setting,
return FALSE; return FALSE;
} }
ret = nm_setting_ip6_config_remove_dns_by_value (setting, &ip6_addr); ret = nm_setting_ip6_config_remove_dns_by_value (setting, dns);
if (!ret) if (!ret)
g_set_error (error, 1, 0, _("the property doesn't contain DNS server '%s'"), dns); g_set_error (error, 1, 0, _("the property doesn't contain DNS server '%s'"), dns);
return ret; return ret;
......
This diff is collapsed.
...@@ -47,7 +47,7 @@ typedef struct { ...@@ -47,7 +47,7 @@ typedef struct {
int ip_entry_width; int ip_entry_width;
int metric_entry_width; int metric_entry_width;
GSList *routes; GPtrArray *routes;
NmtNewtWidget *list; NmtNewtWidget *list;
} NmtRouteTablePrivate; } NmtRouteTablePrivate;
...@@ -87,7 +87,7 @@ route_list_transform_to_route (GBinding *binding, ...@@ -87,7 +87,7 @@ route_list_transform_to_route (GBinding *binding,
int n = GPOINTER_TO_INT (user_data); int n = GPOINTER_TO_INT (user_data);
gpointer route; gpointer route;
route = g_slist_nth_data (priv->routes, n); route = priv->routes->pdata[n];
if (route) if (route)
g_value_set_boxed (target_value, route); g_value_set_boxed (target_value, route);
return route != NULL; return route != NULL;
...@@ -102,31 +102,25 @@ route_list_transform_from_route (GBinding *binding, ...@@ -102,31 +102,25 @@ route_list_transform_from_route (GBinding *binding,
NmtRouteTable *table = NMT_ROUTE_TABLE (g_binding_get_source (binding)); NmtRouteTable *table = NMT_ROUTE_TABLE (g_binding_get_source (binding));
NmtRouteTablePrivate *priv = NMT_ROUTE_TABLE_GET_PRIVATE (table); NmtRouteTablePrivate *priv = NMT_ROUTE_TABLE_GET_PRIVATE (table);
int n = GPOINTER_TO_INT (user_data); int n = GPOINTER_TO_INT (user_data);
GSList *routes, *nth; GPtrArray *routes;
gpointer route;
nth = g_slist_nth (priv->routes, n); if (n >= priv->routes->len)
if (!nth)
return FALSE; return FALSE;
route = priv->routes->pdata[n];
routes = priv->routes; routes = priv->routes;
priv->routes = NULL; priv->routes = NULL;
if (nth->data) { if (route) {
if (priv->family == AF_INET) if (priv->family == AF_INET)
nm_ip4_route_unref (nth->data); nm_ip4_route_unref (route);
else if (priv->family == AF_INET6) else if (priv->family == AF_INET6)
nm_ip6_route_unref (nth->data); nm_ip6_route_unref (route);
}
nth->data = g_value_dup_boxed (source_value);
if (priv->family == AF_INET) {
nm_utils_ip4_routes_to_gvalue (routes, target_value);
g_slist_free_full (routes, (GDestroyNotify) nm_ip4_route_unref);
} else if (priv->family == AF_INET6) {
nm_utils_ip6_routes_to_gvalue (routes, target_value);
g_slist_free_full (routes, (GDestroyNotify) nm_ip6_route_unref);
} }
routes->pdata[n] = g_value_dup_boxed (source_value);
g_value_take_boxed (target_value, routes);
return TRUE; return TRUE;
} }
...@@ -171,16 +165,16 @@ add_route (NmtWidgetList *list, ...@@ -171,16 +165,16 @@ add_route (NmtWidgetList *list,
route = nm_ip4_route_new (); route = nm_ip4_route_new ();
nm_ip4_route_set_prefix (route, 32); nm_ip4_route_set_prefix (route, 32);
priv->routes = g_slist_append (priv->routes, route); g_ptr_array_add (priv->routes, route);
nmt_widget_list_set_length (list, g_slist_length (priv->routes)); nmt_widget_list_set_length (list, priv->routes->len);
g_object_notify (table, "ip4-routes"); g_object_notify (table, "ip4-routes");
} else { } else {
NMIP6Route *route; NMIP6Route *route;
route = nm_ip6_route_new (); route = nm_ip6_route_new ();
nm_ip6_route_set_prefix (route, 128); nm_ip6_route_set_prefix (route, 128);
priv->routes = g_slist_append (priv->routes, route); g_ptr_array_add (priv->routes, route);
nmt_widget_list_set_length (list, g_slist_length (priv->routes)); nmt_widget_list_set_length (list, priv->routes->len);
g_object_notify (table, "ip6-routes"); g_object_notify (table, "ip6-routes");
} }
} }
...@@ -191,16 +185,14 @@ remove_route (NmtWidgetList *list, ...@@ -191,16 +185,14 @@ remove_route (NmtWidgetList *list,
gpointer table) gpointer table)
{ {
NmtRouteTablePrivate *priv = NMT_ROUTE_TABLE_GET_PRIVATE (table); NmtRouteTablePrivate *priv = NMT_ROUTE_TABLE_GET_PRIVATE (table);
GSList *nth;
gpointer route; gpointer route;
nth = g_slist_nth (priv->routes, num); if (num >= priv->routes->len)
if (!nth)
return; return;
route = nth->data; route = priv->routes->pdata[num];
priv->routes = g_slist_delete_link (priv->routes, nth); g_ptr_array_remove_index (priv->routes, num);
nmt_widget_list_set_length (list, g_slist_length (priv->routes)); nmt_widget_list_set_length (list, priv->routes->len);
if (priv->family == AF_INET) { if (priv->family == AF_INET) {
nm_ip4_route_unref (route); nm_ip4_route_unref (route);
...@@ -271,10 +263,7 @@ nmt_route_table_finalize (GObject *object) ...@@ -271,10 +263,7 @@ nmt_route_table_finalize (GObject *object)
{ {
NmtRouteTablePrivate *priv = NMT_ROUTE_TABLE_GET_PRIVATE (object); NmtRouteTablePrivate *priv = NMT_ROUTE_TABLE_GET_PRIVATE (object);
if (priv->family == AF_INET) g_ptr_array_unref (priv->routes);
g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip4_route_unref);
else if (priv->family == AF_INET6)
g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip6_route_unref);
G_OBJECT_CLASS (nmt_route_table_parent_class)->finalize (object); G_OBJECT_CLASS (nmt_route_table_parent_class)->finalize (object);
} }
...@@ -286,24 +275,36 @@ nmt_route_table_set_property (GObject *object, ...@@ -286,24 +275,36 @@ nmt_route_table_set_property (GObject *object,
GParamSpec *pspec) GParamSpec *pspec)
{ {
NmtRouteTablePrivate *priv = NMT_ROUTE_TABLE_GET_PRIVATE (object); NmtRouteTablePrivate *priv = NMT_ROUTE_TABLE_GET_PRIVATE (object);
GPtrArray *array;
int i;
switch (prop_id) { switch (prop_id) {
case PROP_FAMILY: case PROP_FAMILY:
priv->family = g_value_get_int (value); priv->family = g_value_get_int (value);
if (priv->family == AF_INET)
priv->routes = g_ptr_array_new_with_free_func ((GDestroyNotify) nm_ip4_route_unref);
else
priv->routes = g_ptr_array_new_with_free_func ((GDestroyNotify) nm_ip6_route_unref);
break; break;
case PROP_IP4_ROUTES: case PROP_IP4_ROUTES:
g_return_if_fail (priv->family == AF_INET); g_return_if_fail (priv->family == AF_INET);
g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip4_route_unref); array = g_value_get_boxed (value);
priv->routes = nm_utils_ip4_routes_from_gvalue (value); g_ptr_array_set_size (priv->routes, 0);
nmt_widget_list_set_length (NMT_WIDGET_LIST (priv->list), for (i = 0; i < array->len; i++) {
g_slist_length (priv->routes)); nm_ip4_route_ref (array->pdata[i]);
g_ptr_array_add (priv->routes, array->pdata[i]);
}
nmt_widget_list_set_length (NMT_WIDGET_LIST (priv->list), priv->routes->len);
break; break;
case PROP_IP6_ROUTES: case PROP_IP6_ROUTES:
g_return_if_fail (priv->family == AF_INET6); g_return_if_fail (priv->family == AF_INET6);
g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip6_route_unref); array = g_value_get_boxed (value);
priv->routes = nm_utils_ip6_routes_from_gvalue (value); g_ptr_array_set_size (priv->routes, 0);
nmt_widget_list_set_length (NMT_WIDGET_LIST (priv->list), for (i = 0; i < array->len; i++) {
g_slist_length (priv->routes)); nm_ip6_route_ref (array->pdata[i]);
g_ptr_array_add (priv->routes, array->pdata[i]);
}
nmt_widget_list_set_length (NMT_WIDGET_LIST (priv->list), priv->routes->len);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
...@@ -325,11 +326,11 @@ nmt_route_table_get_property (GObject *object, ...@@ -325,11 +326,11 @@ nmt_route_table_get_property (GObject *object,
break; break;
case PROP_IP4_ROUTES: case PROP_IP4_ROUTES:
g_return_if_fail (priv->family == AF_INET); g_return_if_fail (priv->family == AF_INET);
nm_utils_ip4_routes_to_gvalue (priv->routes, value); g_value_set_boxed (value, priv->routes);
break; break;
case PROP_IP6_ROUTES: case PROP_IP6_ROUTES:
g_return_if_fail (priv->family == AF_INET6); g_return_if_fail (priv->family == AF_INET6);
nm_utils_ip6_routes_to_gvalue (priv->routes, value); g_value_set_boxed (value, priv->routes);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
...@@ -337,11 +338,6 @@ nmt_route_table_get_property (GObject *object, ...@@ -337,11 +338,6 @@ nmt_route_table_get_property (GObject *object,
} }
} }
#define DBUS_TYPE_G_ARRAY_OF_UINT (dbus_g_type_get_collection ("GArray", G_TYPE_UINT))
#define DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_ARRAY_OF_UINT))
#define DBUS_TYPE_G_IP6_ROUTE (dbus_g_type_get_struct ("GValueArray", DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT, DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT, G_TYPE_INVALID))
#define DBUS_TYPE_G_ARRAY_OF_IP6_ROUTE (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_IP6_ROUTE))
static void static void
nmt_route_table_class_init (NmtRouteTableClass *table_class) nmt_route_table_class_init (NmtRouteTableClass *table_class)
{ {
...@@ -373,11 +369,13 @@ nmt_route_table_class_init (NmtRouteTableClass *table_class) ...@@ -373,11 +369,13 @@ nmt_route_table_class_init (NmtRouteTableClass *table_class)
* #NMSettingIP4Config:routes. * #NMSettingIP4Config:routes.
* *
* Only valid if #NmtRouteTable:family is %AF_INET * Only valid if #NmtRouteTable:family is %AF_INET
*
* Element-type: NMIP4Route
*/ */
g_object_class_install_property g_object_class_install_property
(object_class, PROP_IP4_ROUTES, (object_class, PROP_IP4_ROUTES,
g_param_spec_boxed ("ip4-routes", "", "", g_param_spec_boxed ("ip4-routes", "", "",
DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT, G_TYPE_PTR_ARRAY,
G_PARAM_READWRITE | G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS)); G_PARAM_STATIC_STRINGS));
/** /**
...@@ -387,11 +385,13 @@ nmt_route_table_class_init (NmtRouteTableClass *table_class) ...@@ -387,11 +385,13 @@ nmt_route_table_class_init (NmtRouteTableClass *table_class)
* #NMSettingIP6Config:routes. * #NMSettingIP6Config:routes.
* *
* Only valid if #NmtRouteTable:family is %AF_INET6 * Only valid if #NmtRouteTable:family is %AF_INET6
*
* Element-type: NMIP6Route
*/ */
g_object_class_install_property g_object_class_install_property
(object_class, PROP_IP6_ROUTES, (object_class, PROP_IP6_ROUTES,
g_param_spec_boxed ("ip6-routes", "", "", g_param_spec_boxed ("ip6-routes", "", "",
DBUS_TYPE_G_ARRAY_OF_IP6_ROUTE, G_TYPE_PTR_ARRAY,
G_PARAM_READWRITE | G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS)); G_PARAM_STATIC_STRINGS));
} }
...@@ -65,5 +65,12 @@ GSList * _nm_utils_hash_values_to_slist (GHashTable *hash); ...@@ -65,5 +65,12 @@ GSList * _nm_utils_hash_values_to_slist (GHashTable *hash);
GHashTable *_nm_utils_copy_strdict (GHashTable *strdict); GHashTable *_nm_utils_copy_strdict (GHashTable *strdict);
typedef gpointer (*NMUtilsCopyFunc) (gpointer);
GPtrArray *_nm_utils_copy_slist_to_array (const GSList *list,
NMUtilsCopyFunc copy_func,
GDestroyNotify unref_func);
GSList *_nm_utils_copy_array_to_slist (const GPtrArray *array,
NMUtilsCopyFunc copy_func);
#endif #endif
...@@ -68,7 +68,7 @@ NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_IP4_CONFIG) ...@@ -68,7 +68,7 @@ NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_IP4_CONFIG)