Commit ce7fc351 authored by Thomas Haller's avatar Thomas Haller
parent 627ad6f8
......@@ -1058,6 +1058,7 @@ typedef struct {
GPtrArray *dns_search; /* array of domain name strings */
GPtrArray *addresses; /* array of NMIPAddress */
GPtrArray *routes; /* array of NMIPRoute */
gint64 route_metric;
char *gateway;
gboolean ignore_auto_routes;
gboolean ignore_auto_dns;
......@@ -1075,6 +1076,7 @@ enum {
PROP_ADDRESSES,
PROP_GATEWAY,
PROP_ROUTES,
PROP_ROUTE_METRIC,
PROP_IGNORE_AUTO_ROUTES,
PROP_IGNORE_AUTO_DNS,
PROP_DHCP_HOSTNAME,
......@@ -1671,6 +1673,25 @@ nm_setting_ip_config_clear_routes (NMSettingIPConfig *setting)
g_object_notify (G_OBJECT (setting), NM_SETTING_IP_CONFIG_ROUTES);
}
/**
* nm_setting_ip_config_get_route_metric:
* @setting: the #NMSettingIPConfig
*
* Returns the value contained in the #NMSettingIPConfig:route-metric
* property.
*
* Returns: the route metric that is used for routes that don't explicitly
* specify a metric. See #NMSettingIPConfig:route-metric for more details.
**/
gint64
nm_setting_ip_config_get_route_metric (NMSettingIPConfig *setting)
{
g_return_val_if_fail (NM_IS_SETTING_IP_CONFIG (setting), -1);
return NM_SETTING_IP_CONFIG_GET_PRIVATE (setting)->route_metric;
}
/**
* nm_setting_ip_config_get_ignore_auto_routes:
* @setting: the #NMSettingIPConfig
......@@ -1984,6 +2005,9 @@ set_property (GObject *object, guint prop_id,
(NMUtilsCopyFunc) nm_ip_route_dup,
(GDestroyNotify) nm_ip_route_unref);
break;
case PROP_ROUTE_METRIC:
priv->route_metric = g_value_get_int64 (value);
break;
case PROP_IGNORE_AUTO_ROUTES:
priv->ignore_auto_routes = g_value_get_boolean (value);
break;
......@@ -2039,6 +2063,9 @@ get_property (GObject *object, guint prop_id,
(NMUtilsCopyFunc) nm_ip_route_dup,
(GDestroyNotify) nm_ip_route_unref));
break;
case PROP_ROUTE_METRIC:
g_value_set_int64 (value, priv->route_metric);
break;
case PROP_IGNORE_AUTO_ROUTES:
g_value_set_boolean (value, nm_setting_ip_config_get_ignore_auto_routes (setting));
break;
......@@ -2173,6 +2200,28 @@ nm_setting_ip_config_class_init (NMSettingIPConfigClass *setting_class)
NM_SETTING_PARAM_INFERRABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMSettingIPConfig:route-metric:
*
* The default metric for routes that don't explicitly specify a metric.
* The default value -1 means that the metric is choosen automatically
* based on the device type.
* The metric applies to dynamic routes, manual (static) routes that
* don't have an explicit metric setting, address prefix routes, and
* the default route.
* Note that for IPv6, the kernel accepts accepts zero (0) but coerces
* it to 1024 (user default). Hence, setting this value to zero effectively
* mean setting it to 1024.
* For IPv4, zero is a regular value for the metric.
**/
g_object_class_install_property
(object_class, PROP_ROUTE_METRIC,
g_param_spec_int64 (NM_SETTING_IP_CONFIG_ROUTE_METRIC, "", "",
-1, G_MAXUINT32, -1,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS));
/**
* NMSettingIPConfig:ignore-auto-routes:
*
......
......@@ -136,6 +136,7 @@ void nm_ip_route_set_attribute (NMIPRoute *route,
#define NM_SETTING_IP_CONFIG_ADDRESSES "addresses"
#define NM_SETTING_IP_CONFIG_GATEWAY "gateway"
#define NM_SETTING_IP_CONFIG_ROUTES "routes"
#define NM_SETTING_IP_CONFIG_ROUTE_METRIC "route-metric"
#define NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES "ignore-auto-routes"
#define NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS "ignore-auto-dns"
#define NM_SETTING_IP_CONFIG_DHCP_HOSTNAME "dhcp-hostname"
......@@ -204,6 +205,8 @@ gboolean nm_setting_ip_config_remove_route_by_value (NMSettingIPConfig
NMIPRoute *route);
void nm_setting_ip_config_clear_routes (NMSettingIPConfig *setting);
gint64 nm_setting_ip_config_get_route_metric (NMSettingIPConfig *setting);
gboolean nm_setting_ip_config_get_ignore_auto_routes (NMSettingIPConfig *setting);
gboolean nm_setting_ip_config_get_ignore_auto_dns (NMSettingIPConfig *setting);
......
......@@ -1701,9 +1701,10 @@ test_connection_diff_a_only (void)
{ NM_SETTING_IP_CONFIG_ADDRESSES, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP_CONFIG_GATEWAY, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP_CONFIG_ROUTES, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP_CONFIG_ROUTE_METRIC, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP_CONFIG_NEVER_DEFAULT, NM_SETTING_DIFF_RESULT_IN_A },
......
......@@ -48,7 +48,11 @@ identifier_key = '{%s}identifier' % ns_map['c']
nick_key = '{%s}nick' % ns_map['glib']
symbol_prefix_key = '{%s}symbol-prefix' % ns_map['c']
constants = { 'TRUE': 'TRUE', 'FALSE': 'FALSE', 'NULL': 'NULL' }
constants = {
'TRUE': 'TRUE',
'FALSE': 'FALSE',
'G_MAXUINT32': 'G_MAXUINT32',
'NULL': 'NULL' }
setting_names = {}
def init_constants(girxml):
......
......@@ -367,6 +367,7 @@ global:
nm_setting_ip4_config_get_num_dns_searches;
nm_setting_ip4_config_get_num_routes;
nm_setting_ip4_config_get_route;
nm_setting_ip4_config_get_route_metric;
nm_setting_ip4_config_get_type;
nm_setting_ip4_config_new;
nm_setting_ip4_config_remove_address;
......@@ -402,6 +403,7 @@ global:
nm_setting_ip6_config_get_num_dns_searches;
nm_setting_ip6_config_get_num_routes;
nm_setting_ip6_config_get_route;
nm_setting_ip6_config_get_route_metric;
nm_setting_ip6_config_get_type;
nm_setting_ip6_config_new;
nm_setting_ip6_config_privacy_get_type;
......
......@@ -76,6 +76,7 @@ typedef struct {
GSList *dns_search; /* list of strings */
GSList *addresses; /* array of NMIP4Address */
GSList *routes; /* array of NMIP4Route */
gint64 route_metric;
gboolean ignore_auto_routes;
gboolean ignore_auto_dns;
char *dhcp_client_id;
......@@ -92,6 +93,7 @@ enum {
PROP_DNS_SEARCH,
PROP_ADDRESSES,
PROP_ROUTES,
PROP_ROUTE_METRIC,
PROP_IGNORE_AUTO_ROUTES,
PROP_IGNORE_AUTO_DNS,
PROP_DHCP_CLIENT_ID,
......@@ -688,6 +690,26 @@ nm_setting_ip4_config_clear_routes (NMSettingIP4Config *setting)
g_object_notify (G_OBJECT (setting), NM_SETTING_IP4_CONFIG_ROUTES);
}
/**
* nm_setting_ip4_config_get_route_metric:
* @setting: the #NMSettingIP4Config
*
* Returns the value contained in the #NMSettingIP4Config:route-metric
* property.
*
* Returns: the route metric that is used for IPv4 routes that don't explicitly
* specify a metric. See #NMSettingIP4Config:route-metric for more details.
*
* Since: 1.0
**/
gint64
nm_setting_ip4_config_get_route_metric (NMSettingIP4Config *setting)
{
g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), -1);
return NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->route_metric;
}
/**
* nm_setting_ip4_config_get_ignore_auto_routes:
* @setting: the #NMSettingIP4Config
......@@ -1018,6 +1040,9 @@ set_property (GObject *object, guint prop_id,
g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip4_route_unref);
priv->routes = nm_utils_ip4_routes_from_gvalue (value);
break;
case PROP_ROUTE_METRIC:
priv->route_metric = g_value_get_int64 (value);
break;
case PROP_IGNORE_AUTO_ROUTES:
priv->ignore_auto_routes = g_value_get_boolean (value);
break;
......@@ -1070,6 +1095,9 @@ get_property (GObject *object, guint prop_id,
case PROP_ROUTES:
nm_utils_ip4_routes_to_gvalue (priv->routes, value);
break;
case PROP_ROUTE_METRIC:
g_value_set_int64 (value, priv->route_metric);
break;
case PROP_IGNORE_AUTO_ROUTES:
g_value_set_boolean (value, nm_setting_ip4_config_get_ignore_auto_routes (setting));
break;
......@@ -1275,6 +1303,28 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
NM_SETTING_PARAM_INFERRABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMSettingIP4Config:route-metric:
*
* The default metric for routes that don't explicitly specify a metric.
* The default value -1 means that the metric is choosen automatically
* based on the device type.
* The metric applies to dynamic routes, manual (static) routes that
* don't have an explicit metric setting, address prefix routes, and
* the default route.
* As the linux kernel accepts zero (0) as a valid metric, zero is
* a valid value.
*
* Since: 1.0
**/
g_object_class_install_property
(object_class, PROP_ROUTE_METRIC,
g_param_spec_int64 (NM_SETTING_IP4_CONFIG_ROUTE_METRIC, "", "",
-1, G_MAXUINT32, -1,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS));
/**
* NMSettingIP4Config:ignore-auto-routes:
*
......
......@@ -60,6 +60,7 @@ GQuark nm_setting_ip4_config_error_quark (void);
#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_ROUTE_METRIC "route-metric"
#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"
......@@ -214,6 +215,9 @@ NM_AVAILABLE_IN_0_9_10
gboolean nm_setting_ip4_config_remove_route_by_value (NMSettingIP4Config *setting, NMIP4Route *route);
void nm_setting_ip4_config_clear_routes (NMSettingIP4Config *setting);
NM_AVAILABLE_IN_1_0
gint64 nm_setting_ip4_config_get_route_metric (NMSettingIP4Config *setting);
gboolean nm_setting_ip4_config_get_ignore_auto_routes (NMSettingIP4Config *setting);
gboolean nm_setting_ip4_config_get_ignore_auto_dns (NMSettingIP4Config *setting);
const char * nm_setting_ip4_config_get_dhcp_client_id (NMSettingIP4Config *setting);
......
......@@ -75,6 +75,7 @@ typedef struct {
GSList *dns_search; /* list of strings */
GSList *addresses; /* array of NMIP6Address */
GSList *routes; /* array of NMIP6Route */
gint64 route_metric;
gboolean ignore_auto_routes;
gboolean ignore_auto_dns;
gboolean never_default;
......@@ -91,6 +92,7 @@ enum {
PROP_DNS_SEARCH,
PROP_ADDRESSES,
PROP_ROUTES,
PROP_ROUTE_METRIC,
PROP_IGNORE_AUTO_ROUTES,
PROP_IGNORE_AUTO_DNS,
PROP_NEVER_DEFAULT,
......@@ -708,6 +710,26 @@ nm_setting_ip6_config_clear_routes (NMSettingIP6Config *setting)
g_object_notify (G_OBJECT (setting), NM_SETTING_IP6_CONFIG_ROUTES);
}
/**
* nm_setting_ip6_config_get_route_metric:
* @setting: the #NMSettingIP4Config
*
* Returns the value contained in the #NMSettingIP6Config:route-metric
* property.
*
* Returns: the route metric that is used for IPv6 routes that don't explicitly
* specify a metric. See #NMSettingIP6Config:route-metric for more details.
*
* Since: 1.0
**/
gint64
nm_setting_ip6_config_get_route_metric (NMSettingIP6Config *setting)
{
g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), -1);
return NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting)->route_metric;
}
/**
* nm_setting_ip6_config_get_ignore_auto_routes:
* @setting: the #NMSettingIP6Config
......@@ -927,6 +949,9 @@ set_property (GObject *object, guint prop_id,
g_slist_free_full (priv->routes, g_free);
priv->routes = nm_utils_ip6_routes_from_gvalue (value);
break;
case PROP_ROUTE_METRIC:
priv->route_metric = g_value_get_int64 (value);
break;
case PROP_IGNORE_AUTO_ROUTES:
priv->ignore_auto_routes = g_value_get_boolean (value);
break;
......@@ -974,6 +999,9 @@ get_property (GObject *object, guint prop_id,
case PROP_ROUTES:
nm_utils_ip6_routes_to_gvalue (priv->routes, value);
break;
case PROP_ROUTE_METRIC:
g_value_set_int64 (value, priv->route_metric);
break;
case PROP_IGNORE_AUTO_ROUTES:
g_value_set_boolean (value, priv->ignore_auto_routes);
break;
......@@ -1186,6 +1214,28 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *setting_class)
NM_SETTING_PARAM_INFERRABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMSettingIP6Config:route-metric:
*
* The default metric for routes that don't explicitly specify a metric.
* The default value -1 means that the metric is choosen automatically
* based on the device type.
* The metric applies to dynamic routes, manual (static) routes that
* don't have an explicit metric setting, address prefix routes, and
* the default route.
* As the linux kernel replaces zero (0) by 1024 (user-default), setting
* this property to 0 means effectively setting it to 1024.
*
* Since: 1.0
**/
g_object_class_install_property
(object_class, PROP_ROUTE_METRIC,
g_param_spec_int64 (NM_SETTING_IP6_CONFIG_ROUTE_METRIC, "", "",
-1, G_MAXUINT32, -1,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS));
/**
* NMSettingIP6Config:ignore-auto-routes:
*
......
......@@ -61,6 +61,7 @@ GQuark nm_setting_ip6_config_error_quark (void);
#define NM_SETTING_IP6_CONFIG_DNS_SEARCH "dns-search"
#define NM_SETTING_IP6_CONFIG_ADDRESSES "addresses"
#define NM_SETTING_IP6_CONFIG_ROUTES "routes"
#define NM_SETTING_IP6_CONFIG_ROUTE_METRIC "route-metric"
#define NM_SETTING_IP6_CONFIG_IGNORE_AUTO_ROUTES "ignore-auto-routes"
#define NM_SETTING_IP6_CONFIG_IGNORE_AUTO_DNS "ignore-auto-dns"
#define NM_SETTING_IP6_CONFIG_NEVER_DEFAULT "never-default"
......@@ -245,6 +246,9 @@ gboolean nm_setting_ip6_config_remove_route_by_value (NMSettingIP
void nm_setting_ip6_config_clear_routes (NMSettingIP6Config *setting);
gboolean nm_setting_ip6_config_get_ignore_auto_routes (NMSettingIP6Config *setting);
NM_AVAILABLE_IN_1_0
gint64 nm_setting_ip6_config_get_route_metric (NMSettingIP6Config *setting);
gboolean nm_setting_ip6_config_get_ignore_auto_dns (NMSettingIP6Config *setting);
const char * nm_setting_ip6_config_get_dhcp_hostname (NMSettingIP6Config *setting);
gboolean nm_setting_ip6_config_get_never_default (NMSettingIP6Config *setting);
......
......@@ -1268,6 +1268,7 @@ test_connection_diff_a_only (void)
{ NM_SETTING_IP4_CONFIG_DNS_SEARCH, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP4_CONFIG_ADDRESSES, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP4_CONFIG_ROUTES, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP4_CONFIG_ROUTE_METRIC, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, NM_SETTING_DIFF_RESULT_IN_A },
......
......@@ -572,6 +572,7 @@ global:
nm_setting_ip_config_get_num_dns_searches;
nm_setting_ip_config_get_num_routes;
nm_setting_ip_config_get_route;
nm_setting_ip_config_get_route_metric;
nm_setting_ip_config_get_type;
nm_setting_ip_config_remove_address;
nm_setting_ip_config_remove_address_by_value;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment