Commit 2c31b549 authored by Dan Williams's avatar Dan Williams

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

	* libnm-glib/nm-ip4-config.c
	  libnm-glib/nm-ip4-config.h
		- Add 'routes' property

	* libnm-util/nm-setting-vpn.c
	  libnm-util/nm-setting-vpn.h
		- Remove 'routes' property

	* libnm-util/nm-setting-ip4-config.c
	  libnm-util/nm-setting-ip4-config.h
		- 'ignore-dhcp-dns' renamed to 'ignore-auto-dns'
		- Add 'ignore-auto-routes' property
		- 'routes' exposed over D-Bus is now an array of array of uint (4) to 
			accomodate route metrics
		- 'routes' exposed in C is now a list of NMSettingIP4Route structures

	* libnm-util/nm-utils.c
	  libnm-util/nm-utils.h
		- Add helpers for marshalling IP4 routes

	* src/NetworkManagerUtils.c
		- (nm_utils_merge_ip4_config): handle property renames and new route
			structure

	* src/NetworkManagerSystem.c
		- (nm_system_device_set_ip4_route, nm_system_device_set_from_ip4_config,
		   nm_system_vpn_device_set_from_ip4_config): respect route metrics

	* src/dhcp-manager/nm-dhcp-manager.c
		- (nm_dhcp_manager_get_ip4_config): handle new route structure

	* system-settings/plugins/ifcfg-fedora/reader.c
	  system-settings/plugins/ifcfg-fedora/writer.c
		- Handle routes separately from addresses now that routes have a different
			format

	* introspection/nm-ip4-config.xml
	  src/nm-ip4-config.c
	  src/nm-ip4-config.h
		- Rename internal routing functions
		- 'static-routes' renamed to 'routes'



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3898 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
parent 2f3820c6
2008-08-06 Dan Williams <dcbw@redhat.com>
* libnm-glib/nm-ip4-config.c
libnm-glib/nm-ip4-config.h
- Add 'routes' property
* libnm-util/nm-setting-vpn.c
libnm-util/nm-setting-vpn.h
- Remove 'routes' property
* libnm-util/nm-setting-ip4-config.c
libnm-util/nm-setting-ip4-config.h
- 'ignore-dhcp-dns' renamed to 'ignore-auto-dns'
- Add 'ignore-auto-routes' property
- 'routes' exposed over D-Bus is now an array of array of uint (4) to
accomodate route metrics
- 'routes' exposed in C is now a list of NMSettingIP4Route structures
* libnm-util/nm-utils.c
libnm-util/nm-utils.h
- Add helpers for marshalling IP4 routes
* src/NetworkManagerUtils.c
- (nm_utils_merge_ip4_config): handle property renames and new route
structure
* src/NetworkManagerSystem.c
- (nm_system_device_set_ip4_route, nm_system_device_set_from_ip4_config,
nm_system_vpn_device_set_from_ip4_config): respect route metrics
* src/dhcp-manager/nm-dhcp-manager.c
- (nm_dhcp_manager_get_ip4_config): handle new route structure
* system-settings/plugins/ifcfg-fedora/reader.c
system-settings/plugins/ifcfg-fedora/writer.c
- Handle routes separately from addresses now that routes have a different
format
* introspection/nm-ip4-config.xml
src/nm-ip4-config.c
src/nm-ip4-config.h
- Rename internal routing functions
- 'static-routes' renamed to 'routes'
2008-08-04 Dan Williams <dcbw@redhat.com>
Patch from Sjoerd Simons <sjoerd.simons@collabora.co.uk>
......
......@@ -3,7 +3,7 @@
<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
<interface name="org.freedesktop.NetworkManager.IP4Config">
<property name="Addresses" type="aau" access="read">
<tp:docstring>Tuples of IPv4 address/prefix/gateway. The gateway is optional, if not given should be 0.</tp:docstring>
<tp:docstring>Tuples of IPv4 address/prefix/gateway.</tp:docstring>
</property>
<property name="Hostname" type="s" access="read">
<tp:docstring>The hostname associated with this IPv4 address. FIXME: what about multiple hostnames?</tp:docstring>
......@@ -20,6 +20,9 @@
<property name="NisServers" type="au" access="read">
<tp:docstring>The NIS servers associated with this address.</tp:docstring>
</property>
<property name="Routes" type="aau" access="read">
<tp:docstring>Tuples of IPv4 route/prefix/next-hop/metric.</tp:docstring>
</property>
</interface>
</node>
......@@ -19,6 +19,7 @@ typedef struct {
GPtrArray *domains;
char *nis_domain;
GArray *nis_servers;
GSList *routes;
} NMIP4ConfigPrivate;
enum {
......@@ -29,6 +30,7 @@ enum {
PROP_DOMAINS,
PROP_NIS_DOMAIN,
PROP_NIS_SERVERS,
PROP_ROUTES,
LAST_PROP
};
......@@ -76,6 +78,21 @@ demarshal_domains (NMObject *object, GParamSpec *pspec, GValue *value, gpointer
return TRUE;
}
static gboolean
demarshal_ip4_routes_array (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field)
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object);
g_slist_foreach (priv->routes, (GFunc) g_free, NULL);
g_slist_free (priv->routes);
priv->routes = NULL;
priv->routes = nm_utils_ip4_routes_from_gvalue (value);
nm_object_queue_notify (object, NM_IP4_CONFIG_ROUTES);
return TRUE;
}
static void
register_for_property_changed (NMIP4Config *config)
{
......@@ -87,6 +104,7 @@ register_for_property_changed (NMIP4Config *config)
{ NM_IP4_CONFIG_DOMAINS, demarshal_domains, &priv->domains },
{ NM_IP4_CONFIG_NIS_DOMAIN, nm_object_demarshal_generic, &priv->nis_domain },
{ NM_IP4_CONFIG_NIS_SERVERS, demarshal_ip4_array, &priv->nis_servers },
{ NM_IP4_CONFIG_ROUTES, demarshal_ip4_routes_array, &priv->routes },
{ NULL },
};
......@@ -131,6 +149,9 @@ finalize (GObject *object)
g_slist_foreach (priv->addresses, (GFunc) g_free, NULL);
g_slist_free (priv->addresses);
g_slist_foreach (priv->routes, (GFunc) g_free, NULL);
g_slist_free (priv->routes);
g_free (priv->hostname);
g_free (priv->nis_domain);
if (priv->nameservers)
......@@ -174,6 +195,9 @@ get_property (GObject *object,
case PROP_NIS_SERVERS:
g_value_set_boxed (value, nm_ip4_config_get_nis_servers (self));
break;
case PROP_ROUTES:
nm_utils_ip4_routes_to_gvalue (priv->routes, value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -239,6 +263,13 @@ nm_ip4_config_class_init (NMIP4ConfigClass *config_class)
"NIS servers",
NM_TYPE_UINT_ARRAY,
G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_ROUTES,
g_param_spec_pointer (NM_IP4_CONFIG_ROUTES,
"Routes",
"Routes",
G_PARAM_READABLE));
}
GObject *
......@@ -366,7 +397,7 @@ nm_ip4_config_get_nis_domain (NMIP4Config *config)
return priv->nis_domain;
}
GArray *
const GArray *
nm_ip4_config_get_nis_servers (NMIP4Config *config)
{
NMIP4ConfigPrivate *priv;
......@@ -392,3 +423,29 @@ nm_ip4_config_get_nis_servers (NMIP4Config *config)
return priv->nis_servers;
}
const GSList *
nm_ip4_config_get_routes (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->routes)
return priv->routes;
if (!nm_object_get_property (NM_OBJECT (config),
"org.freedesktop.DBus.Properties",
"Routes",
&value)) {
return NULL;
}
demarshal_ip4_routes_array (NM_OBJECT (config), NULL, &value, &priv->routes);
g_value_unset (&value);
return priv->routes;
}
......@@ -29,6 +29,7 @@ typedef struct {
#define NM_IP4_CONFIG_DOMAINS "domains"
#define NM_IP4_CONFIG_NIS_DOMAIN "nis-domain"
#define NM_IP4_CONFIG_NIS_SERVERS "nis-servers"
#define NM_IP4_CONFIG_ROUTES "routes"
GType nm_ip4_config_get_type (void);
......@@ -39,7 +40,8 @@ const char * nm_ip4_config_get_hostname (NMIP4Config *config);
const GArray * nm_ip4_config_get_nameservers (NMIP4Config *config);
const GPtrArray *nm_ip4_config_get_domains (NMIP4Config *config);
const char * nm_ip4_config_get_nis_domain (NMIP4Config *config);
GArray * nm_ip4_config_get_nis_servers (NMIP4Config *config);
const GArray * nm_ip4_config_get_nis_servers (NMIP4Config *config);
const GSList * nm_ip4_config_get_routes (NMIP4Config *config);
G_END_DECLS
......
......@@ -76,7 +76,8 @@ enum {
PROP_DNS_SEARCH,
PROP_ADDRESSES,
PROP_ROUTES,
PROP_IGNORE_DHCP_DNS,
PROP_IGNORE_AUTO_ROUTES,
PROP_IGNORE_AUTO_DNS,
PROP_DHCP_CLIENT_ID,
PROP_DHCP_HOSTNAME,
......@@ -186,9 +187,9 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
/* Validate routes */
for (iter = self->routes, i = 0; iter; iter = g_slist_next (iter), i++) {
NMSettingIP4Address *addr = (NMSettingIP4Address *) iter->data;
NMSettingIP4Route *route = (NMSettingIP4Route *) iter->data;
if (!addr->address) {
if (!route->address) {
g_set_error (error,
NM_SETTING_IP4_CONFIG_ERROR,
NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY,
......@@ -196,7 +197,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
return FALSE;
}
if (!addr->prefix || addr->prefix > 32) {
if (!route->prefix || route->prefix > 32) {
g_set_error (error,
NM_SETTING_IP4_CONFIG_ERROR,
NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY,
......@@ -258,10 +259,13 @@ set_property (GObject *object, guint prop_id,
break;
case PROP_ROUTES:
nm_utils_slist_free (setting->routes, g_free);
setting->routes = nm_utils_ip4_addresses_from_gvalue (value);
setting->routes = nm_utils_ip4_routes_from_gvalue (value);
break;
case PROP_IGNORE_DHCP_DNS:
setting->ignore_dhcp_dns = g_value_get_boolean (value);
case PROP_IGNORE_AUTO_ROUTES:
setting->ignore_auto_routes = g_value_get_boolean (value);
break;
case PROP_IGNORE_AUTO_DNS:
setting->ignore_auto_dns = g_value_get_boolean (value);
break;
case PROP_DHCP_CLIENT_ID:
g_free (setting->dhcp_client_id);
......@@ -297,10 +301,13 @@ get_property (GObject *object, guint prop_id,
nm_utils_ip4_addresses_to_gvalue (setting->addresses, value);
break;
case PROP_ROUTES:
nm_utils_ip4_addresses_to_gvalue (setting->routes, value);
nm_utils_ip4_routes_to_gvalue (setting->routes, value);
break;
case PROP_IGNORE_AUTO_ROUTES:
g_value_set_boolean (value, setting->ignore_auto_routes);
break;
case PROP_IGNORE_DHCP_DNS:
g_value_set_boolean (value, setting->ignore_dhcp_dns);
case PROP_IGNORE_AUTO_DNS:
g_value_set_boolean (value, setting->ignore_auto_dns);
break;
case PROP_DHCP_CLIENT_ID:
g_value_set_string (value, setting->dhcp_client_id);
......@@ -363,15 +370,23 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
(object_class, PROP_ROUTES,
nm_param_spec_specialized (NM_SETTING_IP4_CONFIG_ROUTES,
"Routes",
"List of NMSettingIP4Addresses",
"List of NMSettingIP4Routes",
DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT,
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
g_object_class_install_property
(object_class, PROP_IGNORE_DHCP_DNS,
g_param_spec_boolean (NM_SETTING_IP4_CONFIG_IGNORE_DHCP_DNS,
"Ignore DHCP DNS",
"Ignore DHCP DNS",
(object_class, PROP_IGNORE_AUTO_ROUTES,
g_param_spec_boolean (NM_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES,
"Ignore automatic routes",
"Ignore automatic routes",
FALSE,
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
g_object_class_install_property
(object_class, PROP_IGNORE_AUTO_DNS,
g_param_spec_boolean (NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS,
"Ignore automatic DNS",
"Ignore automatic DNS",
FALSE,
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
......
......@@ -53,14 +53,15 @@ GType nm_setting_ip4_config_error_get_type (void);
#define NM_SETTING_IP4_CONFIG_ERROR nm_setting_ip4_config_error_quark ()
GQuark nm_setting_ip4_config_error_quark (void);
#define NM_SETTING_IP4_CONFIG_METHOD "method"
#define NM_SETTING_IP4_CONFIG_DNS "dns"
#define NM_SETTING_IP4_CONFIG_DNS_SEARCH "dns-search"
#define NM_SETTING_IP4_CONFIG_ADDRESSES "addresses"
#define NM_SETTING_IP4_CONFIG_ROUTES "routes"
#define NM_SETTING_IP4_CONFIG_IGNORE_DHCP_DNS "ignore-dhcp-dns"
#define NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID "dhcp-client-id"
#define NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME "dhcp-hostname"
#define NM_SETTING_IP4_CONFIG_METHOD "method"
#define NM_SETTING_IP4_CONFIG_DNS "dns"
#define NM_SETTING_IP4_CONFIG_DNS_SEARCH "dns-search"
#define NM_SETTING_IP4_CONFIG_ADDRESSES "addresses"
#define NM_SETTING_IP4_CONFIG_ROUTES "routes"
#define NM_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES "ignore-auto-routes"
#define NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS "ignore-auto-dns"
#define NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID "dhcp-client-id"
#define NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME "dhcp-hostname"
#define NM_SETTING_IP4_CONFIG_METHOD_AUTO "auto"
#define NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL "link-local"
......@@ -73,6 +74,13 @@ typedef struct {
guint32 gateway; /* network byte order */
} NMSettingIP4Address;
typedef struct {
guint32 address; /* network byte order */
guint32 prefix;
guint32 next_hop; /* network byte order */
guint32 metric; /* lower metric == more preferred */
} NMSettingIP4Route;
typedef struct {
NMSetting parent;
......@@ -80,8 +88,9 @@ typedef struct {
GArray *dns; /* array of guint32; elements in network byte order */
GSList *dns_search; /* list of strings */
GSList *addresses; /* array of NMSettingIP4Address */
GSList *routes; /* array of NMSettingIP4Address */
gboolean ignore_dhcp_dns;
GSList *routes; /* array of NMSettingIP4Route */
gboolean ignore_auto_routes;
gboolean ignore_auto_dns;
char *dhcp_client_id;
char *dhcp_hostname;
} NMSettingIP4Config;
......
......@@ -70,7 +70,6 @@ enum {
PROP_0,
PROP_SERVICE_TYPE,
PROP_USER_NAME,
PROP_ROUTES,
LAST_PROP
};
......@@ -127,7 +126,6 @@ finalize (GObject *object)
g_free (self->service_type);
g_free (self->user_name);
nm_utils_slist_free (self->routes, g_free);
G_OBJECT_CLASS (nm_setting_vpn_parent_class)->finalize (object);
}
......@@ -147,10 +145,6 @@ set_property (GObject *object, guint prop_id,
g_free (setting->user_name);
setting->user_name = g_value_dup_string (value);
break;
case PROP_ROUTES:
nm_utils_slist_free (setting->routes, g_free);
setting->routes = g_value_dup_boxed (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -170,9 +164,6 @@ get_property (GObject *object, guint prop_id,
case PROP_USER_NAME:
g_value_set_string (value, setting->user_name);
break;
case PROP_ROUTES:
g_value_set_boxed (value, setting->routes);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -207,12 +198,4 @@ nm_setting_vpn_class_init (NMSettingVPNClass *setting_class)
"User name",
NULL,
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
g_object_class_install_property
(object_class, PROP_ROUTES,
nm_param_spec_specialized (NM_SETTING_VPN_ROUTES,
"Routes",
"Routes",
DBUS_TYPE_G_LIST_OF_STRING,
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
}
......@@ -54,14 +54,12 @@ GQuark nm_setting_vpn_error_quark (void);
#define NM_SETTING_VPN_SERVICE_TYPE "service-type"
#define NM_SETTING_VPN_USER_NAME "user-name"
#define NM_SETTING_VPN_ROUTES "routes"
typedef struct {
NMSetting parent;
char *service_type;
char *user_name;
GSList *routes;
} NMSettingVPN;
typedef struct {
......
......@@ -859,6 +859,58 @@ nm_utils_ip4_addresses_to_gvalue (GSList *list, GValue *value)
g_value_take_boxed (value, addresses);
}
GSList *
nm_utils_ip4_routes_from_gvalue (const GValue *value)
{
GPtrArray *routes;
int i;
GSList *list = NULL;
routes = (GPtrArray *) g_value_get_boxed (value);
for (i = 0; routes && (i < routes->len); i++) {
GArray *array = (GArray *) g_ptr_array_index (routes, i);
NMSettingIP4Route *route;
if (array->len != 4) {
nm_warning ("Ignoring invalid IP4 route");
continue;
}
route = g_malloc0 (sizeof (NMSettingIP4Route));
route->address = g_array_index (array, guint32, 0);
route->prefix = g_array_index (array, guint32, 1);
route->next_hop = g_array_index (array, guint32, 2);
route->metric = g_array_index (array, guint32, 3);
list = g_slist_prepend (list, route);
}
return g_slist_reverse (list);
}
void
nm_utils_ip4_routes_to_gvalue (GSList *list, GValue *value)
{
GPtrArray *routes;
GSList *iter;
routes = g_ptr_array_new ();
for (iter = list; iter; iter = iter->next) {
NMSettingIP4Route *route = (NMSettingIP4Route *) iter->data;
GArray *array;
array = g_array_sized_new (FALSE, TRUE, sizeof (guint32), 3);
g_array_append_val (array, route->address);
g_array_append_val (array, route->prefix);
g_array_append_val (array, route->next_hop);
g_array_append_val (array, route->metric);
g_ptr_array_add (routes, array);
}
g_value_take_boxed (value, routes);
}
/*
* nm_utils_ip4_netmask_to_prefix
*
......
......@@ -187,6 +187,9 @@ gboolean nm_utils_security_valid (NMUtilsSecurityType type,
GSList *nm_utils_ip4_addresses_from_gvalue (const GValue *value);
void nm_utils_ip4_addresses_to_gvalue (GSList *list, GValue *value);
GSList *nm_utils_ip4_routes_from_gvalue (const GValue *value);
void nm_utils_ip4_routes_to_gvalue (GSList *list, GValue *value);
guint32 nm_utils_ip4_netmask_to_prefix (guint32 ip4_netmask);
guint32 nm_utils_ip4_prefix_to_netmask (guint32 ip4_prefix);
......
......@@ -107,6 +107,7 @@ nm_system_device_set_ip4_route (const char *iface,
guint32 ip4_dest,
guint32 ip4_prefix,
guint32 ip4_gateway,
guint32 metric,
int mss)
{
struct nl_handle *nlh;
......@@ -148,6 +149,10 @@ nm_system_device_set_ip4_route (const char *iface,
}
}
/* Metric */
if (metric)
rtnl_route_set_prio (route, metric);
/* Add the route */
err = rtnl_route_add (nlh, route, 0);
if (err == -ESRCH && ip4_gateway) {
......@@ -284,14 +289,15 @@ nm_system_device_set_from_ip4_config (const char *iface,
sleep (1);
len = nm_ip4_config_get_num_static_routes (config);
len = nm_ip4_config_get_num_routes (config);
for (i = 0; i < len; i++) {
const NMSettingIP4Address *route = nm_ip4_config_get_static_route (config, i);
const NMSettingIP4Route *route = nm_ip4_config_get_route (config, i);
nm_system_device_set_ip4_route (iface, config,
route->address,
route->prefix,
route->gateway,
route->next_hop,
route->metric,
nm_ip4_config_get_mss (config));
}
......@@ -344,7 +350,7 @@ nm_system_vpn_device_set_from_ip4_config (NMDevice *active_device,
}
nm_system_device_set_ip4_route (nm_device_get_ip_iface (active_device),
ad_config, vpn_gw, 32, ad_gw,
ad_config, vpn_gw, 32, ad_gw, 0,
nm_ip4_config_get_mss (config));
}
}
......@@ -362,14 +368,15 @@ nm_system_vpn_device_set_from_ip4_config (NMDevice *active_device,
nm_system_device_set_mtu (iface, nm_ip4_config_get_mtu (config));
/* Set routes */
num = nm_ip4_config_get_num_static_routes (config);
num = nm_ip4_config_get_num_routes (config);
for (i = 0; i < num; i++) {
const NMSettingIP4Address *route = nm_ip4_config_get_static_route (config, i);
const NMSettingIP4Route *route = nm_ip4_config_get_route (config, i);
nm_system_device_set_ip4_route (iface, config,
route->address,
route->prefix,
route->gateway,
route->next_hop,
route->metric,
nm_ip4_config_get_mss (config));
}
......
......@@ -278,11 +278,14 @@ nm_utils_merge_ip4_config (NMIP4Config *ip4_config, NMSettingIP4Config *setting)
if (!setting)
return; /* Defaults are just fine */
if (setting->ignore_dhcp_dns) {
if (setting->ignore_auto_dns) {
nm_ip4_config_reset_nameservers (ip4_config);
nm_ip4_config_reset_searches (ip4_config);
}
if (setting->ignore_auto_routes)
nm_ip4_config_reset_routes (ip4_config);
if (setting->dns) {
int i, j;
......@@ -344,25 +347,27 @@ nm_utils_merge_ip4_config (NMIP4Config *ip4_config, NMSettingIP4Config *setting)
nm_ip4_config_add_address (ip4_config, setting_addr);
}
/* IPv4 static routes */
/* IPv4 routes */
for (iter = setting->routes; iter; iter = g_slist_next (iter)) {
NMSettingIP4Address *setting_route = (NMSettingIP4Address *) iter->data;
NMSettingIP4Route *setting_route = (NMSettingIP4Route *) iter->data;
guint32 i, num;
num = nm_ip4_config_get_num_static_routes (ip4_config);
num = nm_ip4_config_get_num_routes (ip4_config);
for (i = 0; i < num; i++) {
const NMSettingIP4Address *cfg_route;
cfg_route = nm_ip4_config_get_static_route (ip4_config, i);
/* Dupe, override with user-specified address */
if (cfg_route->address == setting_route->address) {
nm_ip4_config_replace_static_route (ip4_config, i, setting_route);
const NMSettingIP4Route *cfg_route;
cfg_route = nm_ip4_config_get_route (ip4_config, i);
/* Dupe, override with user-specified route */
if ( (cfg_route->address == setting_route->address)
&& (cfg_route->prefix == setting_route->prefix)
&& (cfg_route->next_hop == setting_route->next_hop)) {
nm_ip4_config_replace_route (ip4_config, i, setting_route);
break;
}
}
if (i == num)
nm_ip4_config_add_static_route (ip4_config, setting_route);
nm_ip4_config_add_route (ip4_config, setting_route);
}
}
......
......@@ -829,6 +829,7 @@ nm_dhcp_manager_get_ip4_config (NMDHCPManager *manager,
char **s;
for (s = searches; *s; s += 2) {
NMSettingIP4Route *route;
struct in_addr rt_addr;
struct in_addr rt_route;
......@@ -843,13 +844,12 @@ nm_dhcp_manager_get_ip4_config (NMDHCPManager *manager,
// FIXME: ensure the IP addresse and route are sane
addr = g_malloc0 (sizeof (NMSettingIP4Address));
addr->address = (guint32) rt_addr.s_addr;
addr->prefix = 32; /* 255.255.255.255 */
addr->gateway = (guint32) rt_route.s_addr;
route = g_malloc0 (sizeof (NMSettingIP4Route));
route->address = (guint32) rt_addr.s_addr;
route->prefix = 32; /* 255.255.255.255 */
route->next_hop = (guint32) rt_route.s_addr;
nm_ip4_config_take_static_route (ip4_config, addr);
addr = NULL;
nm_ip4_config_take_route (ip4_config, route);
nm_info (" static route %s gw %s", *s, *(s + 1));
}
} else {
......
......@@ -58,7 +58,7 @@ typedef struct {
gchar *hostname;
gchar *nis_domain;
GArray *nis_servers;
GSList *static_routes;
GSList *routes;
} NMIP4ConfigPrivate;
......@@ -70,7 +70,7 @@ enum {
PROP_DOMAINS,
PROP_NIS_DOMAIN,
PROP_NIS_SERVERS,
PROP_STATIC_ROUTES,
PROP_ROUTES,
LAST_PROP
};
......@@ -133,13 +133,13 @@ NMIP4Config *nm_ip4_config_copy (NMIP4Config *src_config)
for (i = 0; i < len; i++)
nm_ip4_config_add_nis_server (dst_config, nm_ip4_config_get_nis_server (src_config, i));
for (iter = src_priv->static_routes; iter; iter = g_slist_next (iter)) {
NMSettingIP4Address *src_addr = (NMSettingIP4Address *) iter->data;
NMSettingIP4Address *dst_addr;
for (iter = src_priv->routes; iter; iter = g_slist_next (iter)) {
NMSettingIP4Route *src_route = (NMSettingIP4Route *) iter->data;
NMSettingIP4Route *dst_route;