diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2014-10-13 11:52:29 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2014-10-20 12:41:50 +0200 |
commit | 33866e4030bce9bec081474c33e37854efb58ba7 (patch) | |
tree | 775e5642425bf3bcdda992b2fbb1a146b8351218 | |
parent | d60f593b3eb04aaaa4f295bad182aa3e08dd6e78 (diff) | |
download | NetworkManager-33866e4030bce9bec081474c33e37854efb58ba7.tar.gz |
core: Move NMPlatformSource to nm-types.h
...and rename it while at it. It's going to be useful outside nm-platform,
to weight MTU options from various sources.
-rw-r--r-- | include/nm-test-utils.h | 4 | ||||
-rw-r--r-- | src/devices/nm-device.c | 10 | ||||
-rw-r--r-- | src/devices/wwan/nm-modem-broadband.c | 2 | ||||
-rw-r--r-- | src/dhcp-manager/nm-dhcp-dhclient-utils.c | 2 | ||||
-rw-r--r-- | src/dhcp-manager/nm-dhcp-utils.c | 12 | ||||
-rw-r--r-- | src/nm-ip4-config.c | 11 | ||||
-rw-r--r-- | src/nm-ip6-config.c | 11 | ||||
-rw-r--r-- | src/nm-policy.c | 24 | ||||
-rw-r--r-- | src/nm-types.h | 14 | ||||
-rw-r--r-- | src/platform/nm-fake-platform.c | 12 | ||||
-rw-r--r-- | src/platform/nm-linux-platform.c | 38 | ||||
-rw-r--r-- | src/platform/nm-platform.c | 28 | ||||
-rw-r--r-- | src/platform/nm-platform.h | 27 | ||||
-rw-r--r-- | src/platform/tests/platform.c | 4 | ||||
-rw-r--r-- | src/platform/tests/test-cleanup.c | 12 | ||||
-rw-r--r-- | src/platform/tests/test-route.c | 32 | ||||
-rw-r--r-- | src/ppp-manager/nm-ppp-manager.c | 2 | ||||
-rw-r--r-- | src/tests/test-ip4-config.c | 40 | ||||
-rw-r--r-- | src/tests/test-ip6-config.c | 84 | ||||
-rw-r--r-- | src/vpn-manager/nm-vpn-connection.c | 16 |
20 files changed, 191 insertions, 194 deletions
diff --git a/include/nm-test-utils.h b/include/nm-test-utils.h index 12e84b3393..4a38d145b0 100644 --- a/include/nm-test-utils.h +++ b/include/nm-test-utils.h @@ -585,7 +585,7 @@ nmtst_platform_ip6_address (const char *address, const char *peer_address, guint inline static NMPlatformIP6Address * nmtst_platform_ip6_address_full (const char *address, const char *peer_address, guint plen, - int ifindex, NMPlatformSource source, guint32 timestamp, + int ifindex, NMIPConfigSource source, guint32 timestamp, guint32 lifetime, guint32 preferred, guint flags) { NMPlatformIP6Address *addr = nmtst_platform_ip6_address (address, peer_address, plen); @@ -615,7 +615,7 @@ nmtst_platform_ip6_route (const char *network, guint plen, const char *gateway) inline static NMPlatformIP6Route * nmtst_platform_ip6_route_full (const char *network, guint plen, const char *gateway, - int ifindex, NMPlatformSource source, + int ifindex, NMIPConfigSource source, guint metric, guint mss) { NMPlatformIP6Route *route = nmtst_platform_ip6_route (network, plen, gateway); diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 646c9e1a4d..d8d670d3ff 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -2359,14 +2359,14 @@ aipd_get_ip4_config (NMDevice *self, guint32 lla) memset (&address, 0, sizeof (address)); address.address = lla; address.plen = 16; - address.source = NM_PLATFORM_SOURCE_IP4LL; + address.source = NM_IP_CONFIG_SOURCE_IP4LL; nm_ip4_config_add_address (config, &address); /* Add a multicast route for link-local connections: destination= 224.0.0.0, netmask=240.0.0.0 */ memset (&route, 0, sizeof (route)); route.network = htonl (0xE0000000L); route.plen = 4; - route.source = NM_PLATFORM_SOURCE_IP4LL; + route.source = NM_IP_CONFIG_SOURCE_IP4LL; route.metric = nm_device_get_priority (self); nm_ip4_config_add_route (config, &route); @@ -2888,7 +2888,7 @@ shared4_new_config (NMDevice *self, NMConnection *connection, NMDeviceStateReaso } config = nm_ip4_config_new (); - address.source = NM_PLATFORM_SOURCE_SHARED; + address.source = NM_IP_CONFIG_SOURCE_SHARED; nm_ip4_config_add_address (config, &address); /* Remove the address lock when the object gets disposed */ @@ -3575,7 +3575,7 @@ rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, NMDevice *self) address.preferred = discovered_address->preferred; if (address.preferred > address.lifetime) address.preferred = address.lifetime; - address.source = NM_PLATFORM_SOURCE_RDISC; + address.source = NM_IP_CONFIG_SOURCE_RDISC; address.flags = ifa_flags; nm_ip6_config_add_address (priv->ac_ip6_config, &address); @@ -3599,7 +3599,7 @@ rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, NMDevice *self) route.network = discovered_route->network; route.plen = discovered_route->plen; route.gateway = discovered_route->gateway; - route.source = NM_PLATFORM_SOURCE_RDISC; + route.source = NM_IP_CONFIG_SOURCE_RDISC; route.metric = nm_device_get_priority (self); nm_ip6_config_add_route (priv->ac_ip6_config, &route); diff --git a/src/devices/wwan/nm-modem-broadband.c b/src/devices/wwan/nm-modem-broadband.c index 7cf75c28ec..ad2c8de4fa 100644 --- a/src/devices/wwan/nm-modem-broadband.c +++ b/src/devices/wwan/nm-modem-broadband.c @@ -691,7 +691,7 @@ static_stage3_ip4_done (NMModemBroadband *self) memset (&address, 0, sizeof (address)); address.address = address_network; address.plen = mm_bearer_ip_config_get_prefix (self->priv->ipv4_config); - address.source = NM_PLATFORM_SOURCE_WWAN; + address.source = NM_IP_CONFIG_SOURCE_WWAN; nm_ip4_config_add_address (config, &address); nm_log_info (LOGD_MB, " address %s/%d", address_string, address.plen); diff --git a/src/dhcp-manager/nm-dhcp-dhclient-utils.c b/src/dhcp-manager/nm-dhcp-dhclient-utils.c index 6c5be77cb8..d39da6b9f9 100644 --- a/src/dhcp-manager/nm-dhcp-dhclient-utils.c +++ b/src/dhcp-manager/nm-dhcp-dhclient-utils.c @@ -623,7 +623,7 @@ nm_dhcp_dhclient_read_lease_ip_configs (const char *iface, address.timestamp = now_monotonic_ts; address.lifetime = address.preferred = expiry; - address.source = NM_PLATFORM_SOURCE_DHCP; + address.source = NM_IP_CONFIG_SOURCE_DHCP; ip4 = nm_ip4_config_new (); nm_ip4_config_add_address (ip4, &address); diff --git a/src/dhcp-manager/nm-dhcp-utils.c b/src/dhcp-manager/nm-dhcp-utils.c index c017f6cfb3..379e73729f 100644 --- a/src/dhcp-manager/nm-dhcp-utils.c +++ b/src/dhcp-manager/nm-dhcp-utils.c @@ -84,7 +84,7 @@ ip4_process_dhcpcd_rfc3442_routes (const char *str, route.network = rt_addr; route.plen = rt_cidr; route.gateway = rt_route; - route.source = NM_PLATFORM_SOURCE_DHCP; + route.source = NM_IP_CONFIG_SOURCE_DHCP; route.metric = priority; nm_ip4_config_add_route (ip4_config, &route); } @@ -191,7 +191,7 @@ ip4_process_dhclient_rfc3442_routes (const char *str, char addr[INET_ADDRSTRLEN]; /* normal route */ - route.source = NM_PLATFORM_SOURCE_DHCP; + route.source = NM_IP_CONFIG_SOURCE_DHCP; route.metric = priority; nm_ip4_config_add_route (ip4_config, &route); @@ -313,7 +313,7 @@ process_classful_routes (GHashTable *options, guint priority, NMIP4Config *ip4_c route.plen = 32; } route.gateway = rt_route; - route.source = NM_PLATFORM_SOURCE_DHCP; + route.source = NM_IP_CONFIG_SOURCE_DHCP; route.metric = priority; nm_ip4_config_add_route (ip4_config, &route); @@ -462,7 +462,7 @@ nm_dhcp_utils_ip4_config_from_options (const char *iface, route.plen = 32; /* this will be a device route if gwaddr is 0 */ route.gateway = gwaddr; - route.source = NM_PLATFORM_SOURCE_DHCP; + route.source = NM_IP_CONFIG_SOURCE_DHCP; route.metric = priority; nm_ip4_config_add_route (ip4_config, &route); nm_log_dbg (LOGD_IP, "adding route for server identifier: %s", @@ -479,7 +479,7 @@ nm_dhcp_utils_ip4_config_from_options (const char *iface, nm_log_info (LOGD_DHCP4, " lease time %d", address.lifetime); } - address.source = NM_PLATFORM_SOURCE_DHCP; + address.source = NM_IP_CONFIG_SOURCE_DHCP; nm_ip4_config_add_address (ip4_config, &address); str = g_hash_table_lookup (options, "host_name"); @@ -629,7 +629,7 @@ nm_dhcp_utils_ip6_config_from_options (const char *iface, } address.address = tmp_addr; - address.source = NM_PLATFORM_SOURCE_DHCP; + address.source = NM_IP_CONFIG_SOURCE_DHCP; nm_ip6_config_add_address (ip6_config, &address); nm_log_info (LOGD_DHCP6, " address %s", str); } else if (info_only == FALSE) { diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c index aab50aeb8d..b30a4ee766 100644 --- a/src/nm-ip4-config.c +++ b/src/nm-ip4-config.c @@ -23,7 +23,6 @@ #include "nm-ip4-config.h" -#include "nm-platform.h" #include "nm-utils.h" #include "nm-dbus-manager.h" #include "nm-dbus-glib-types.h" @@ -336,7 +335,7 @@ nm_ip4_config_merge_setting (NMIP4Config *config, NMSettingIP4Config *setting, i address.plen = nm_ip4_address_get_prefix (s_addr); address.lifetime = NM_PLATFORM_LIFETIME_PERMANENT; address.preferred = NM_PLATFORM_LIFETIME_PERMANENT; - address.source = NM_PLATFORM_SOURCE_USER; + address.source = NM_IP_CONFIG_SOURCE_USER; g_strlcpy (address.label, label, sizeof (address.label)); nm_ip4_config_add_address (config, &address); @@ -356,7 +355,7 @@ nm_ip4_config_merge_setting (NMIP4Config *config, NMSettingIP4Config *setting, i route.metric = nm_ip4_route_get_metric (s_route); if (!route.metric) route.metric = default_route_metric; - route.source = NM_PLATFORM_SOURCE_USER; + route.source = NM_IP_CONFIG_SOURCE_USER; nm_ip4_config_add_route (config, &route); } @@ -447,7 +446,7 @@ nm_ip4_config_create_setting (const NMIP4Config *config) continue; /* Ignore routes provided by external sources */ - if (route->source != NM_PLATFORM_SOURCE_USER) + if (route->source != NM_IP_CONFIG_SOURCE_USER) continue; s_route = nm_ip4_route_new (); @@ -1052,7 +1051,7 @@ nm_ip4_config_add_address (NMIP4Config *config, const NMPlatformIP4Address *new) * with "what should be" and the kernel values are "what turned out after configuring it". * * For other sources, the longer lifetime wins. */ - if ( (new->source == NM_PLATFORM_SOURCE_KERNEL && new->source != item_old.source) + if ( (new->source == NM_IP_CONFIG_SOURCE_KERNEL && new->source != item_old.source) || nm_platform_ip_address_cmp_expiry ((const NMPlatformIPAddress *) &item_old, (const NMPlatformIPAddress *) new) > 0) { item->timestamp = item_old.timestamp; item->lifetime = item_old.lifetime; @@ -1139,7 +1138,7 @@ void nm_ip4_config_add_route (NMIP4Config *config, const NMPlatformIP4Route *new) { NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config); - NMPlatformSource old_source; + NMIPConfigSource old_source; int i; g_return_if_fail (new != NULL); diff --git a/src/nm-ip6-config.c b/src/nm-ip6-config.c index 9d2b61f2c5..92064f9791 100644 --- a/src/nm-ip6-config.c +++ b/src/nm-ip6-config.c @@ -24,7 +24,6 @@ #include "nm-ip6-config.h" #include "nm-glib-compat.h" -#include "nm-platform.h" #include "nm-utils.h" #include "nm-dbus-manager.h" #include "nm-dbus-glib-types.h" @@ -440,7 +439,7 @@ nm_ip6_config_merge_setting (NMIP6Config *config, NMSettingIP6Config *setting, i address.plen = nm_ip6_address_get_prefix (s_addr); address.lifetime = NM_PLATFORM_LIFETIME_PERMANENT; address.preferred = NM_PLATFORM_LIFETIME_PERMANENT; - address.source = NM_PLATFORM_SOURCE_USER; + address.source = NM_IP_CONFIG_SOURCE_USER; nm_ip6_config_add_address (config, &address); } @@ -459,7 +458,7 @@ nm_ip6_config_merge_setting (NMIP6Config *config, NMSettingIP6Config *setting, i route.metric = nm_ip6_route_get_metric (s_route); if (!route.metric) route.metric = default_route_metric; - route.source = NM_PLATFORM_SOURCE_USER; + route.source = NM_IP_CONFIG_SOURCE_USER; nm_ip6_config_add_route (config, &route); } @@ -558,7 +557,7 @@ nm_ip6_config_create_setting (const NMIP6Config *config) continue; /* Ignore routes provided by external sources */ - if (route->source != NM_PLATFORM_SOURCE_USER) + if (route->source != NM_IP_CONFIG_SOURCE_USER) continue; s_route = nm_ip6_route_new (); @@ -1058,7 +1057,7 @@ nm_ip6_config_add_address (NMIP6Config *config, const NMPlatformIP6Address *new) * with "what should be" and the kernel values are "what turned out after configuring it". * * For other sources, the longer lifetime wins. */ - if ( (new->source == NM_PLATFORM_SOURCE_KERNEL && new->source != item_old.source) + if ( (new->source == NM_IP_CONFIG_SOURCE_KERNEL && new->source != item_old.source) || nm_platform_ip_address_cmp_expiry ((const NMPlatformIPAddress *) &item_old, (const NMPlatformIPAddress *) new) > 0) { item->timestamp = item_old.timestamp; item->lifetime = item_old.lifetime; @@ -1146,7 +1145,7 @@ void nm_ip6_config_add_route (NMIP6Config *config, const NMPlatformIP6Route *new) { NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config); - NMPlatformSource old_source; + NMIPConfigSource old_source; int i; g_return_if_fail (new != NULL); diff --git a/src/nm-policy.c b/src/nm-policy.c index 120afd65c6..ff100d069d 100644 --- a/src/nm-policy.c +++ b/src/nm-policy.c @@ -670,13 +670,13 @@ update_ip4_routing (NMPolicy *policy, gboolean force_update) if (ip_ifindex <= 0) ip_ifindex = parent_ifindex; - if (!nm_platform_ip4_route_add (ip_ifindex, NM_PLATFORM_SOURCE_VPN, + if (!nm_platform_ip4_route_add (ip_ifindex, NM_IP_CONFIG_SOURCE_VPN, 0, 0, int_gw, NM_PLATFORM_ROUTE_METRIC_DEFAULT, mss)) { - (void) nm_platform_ip4_route_add (parent_ifindex, NM_PLATFORM_SOURCE_VPN, + (void) nm_platform_ip4_route_add (parent_ifindex, NM_IP_CONFIG_SOURCE_VPN, gw_addr, 32, 0, NM_PLATFORM_ROUTE_METRIC_DEFAULT, parent_mss); - if (!nm_platform_ip4_route_add (ip_ifindex, NM_PLATFORM_SOURCE_VPN, + if (!nm_platform_ip4_route_add (ip_ifindex, NM_IP_CONFIG_SOURCE_VPN, 0, 0, int_gw, NM_PLATFORM_ROUTE_METRIC_DEFAULT, mss)) nm_log_err (LOGD_IP4 | LOGD_VPN, "Failed to set default route."); @@ -687,13 +687,13 @@ update_ip4_routing (NMPolicy *policy, gboolean force_update) int mss = nm_ip4_config_get_mss (ip4_config); g_assert (ip_iface); - if (!nm_platform_ip4_route_add (ip_ifindex, NM_PLATFORM_SOURCE_USER, + if (!nm_platform_ip4_route_add (ip_ifindex, NM_IP_CONFIG_SOURCE_USER, 0, 0, gw_addr, NM_PLATFORM_ROUTE_METRIC_DEFAULT, mss)) { - (void) nm_platform_ip4_route_add (ip_ifindex, NM_PLATFORM_SOURCE_USER, + (void) nm_platform_ip4_route_add (ip_ifindex, NM_IP_CONFIG_SOURCE_USER, gw_addr, 32, 0, NM_PLATFORM_ROUTE_METRIC_DEFAULT, mss); - if (!nm_platform_ip4_route_add (ip_ifindex, NM_PLATFORM_SOURCE_USER, + if (!nm_platform_ip4_route_add (ip_ifindex, NM_IP_CONFIG_SOURCE_USER, 0, 0, gw_addr, NM_PLATFORM_ROUTE_METRIC_DEFAULT, mss)) { nm_log_err (LOGD_IP4, "Failed to set default route."); @@ -876,13 +876,13 @@ update_ip6_routing (NMPolicy *policy, gboolean force_update) if (ip_ifindex <= 0) ip_ifindex = parent_ifindex; - if (!nm_platform_ip6_route_add (ip_ifindex, NM_PLATFORM_SOURCE_VPN, + if (!nm_platform_ip6_route_add (ip_ifindex, NM_IP_CONFIG_SOURCE_VPN, in6addr_any, 0, *int_gw, NM_PLATFORM_ROUTE_METRIC_DEFAULT, mss)) { - (void) nm_platform_ip6_route_add (parent_ifindex, NM_PLATFORM_SOURCE_VPN, + (void) nm_platform_ip6_route_add (parent_ifindex, NM_IP_CONFIG_SOURCE_VPN, *gw_addr, 128, in6addr_any, NM_PLATFORM_ROUTE_METRIC_DEFAULT, parent_mss); - if (!nm_platform_ip6_route_add (ip_ifindex, NM_PLATFORM_SOURCE_VPN, + if (!nm_platform_ip6_route_add (ip_ifindex, NM_IP_CONFIG_SOURCE_VPN, in6addr_any, 0, *int_gw, NM_PLATFORM_ROUTE_METRIC_DEFAULT, mss)) { nm_log_err (LOGD_IP6 | LOGD_VPN, "Failed to set default route."); @@ -893,13 +893,13 @@ update_ip6_routing (NMPolicy *policy, gboolean force_update) } else { int mss = nm_ip6_config_get_mss (ip6_config); - if (!nm_platform_ip6_route_add (ip_ifindex, NM_PLATFORM_SOURCE_USER, + if (!nm_platform_ip6_route_add (ip_ifindex, NM_IP_CONFIG_SOURCE_USER, in6addr_any, 0, *gw_addr, NM_PLATFORM_ROUTE_METRIC_DEFAULT, mss)) { - (void) nm_platform_ip6_route_add (ip_ifindex, NM_PLATFORM_SOURCE_USER, + (void) nm_platform_ip6_route_add (ip_ifindex, NM_IP_CONFIG_SOURCE_USER, *gw_addr, 128, in6addr_any, NM_PLATFORM_ROUTE_METRIC_DEFAULT, mss); - if (!nm_platform_ip6_route_add (ip_ifindex, NM_PLATFORM_SOURCE_USER, + if (!nm_platform_ip6_route_add (ip_ifindex, NM_IP_CONFIG_SOURCE_USER, in6addr_any, 0, *gw_addr, NM_PLATFORM_ROUTE_METRIC_DEFAULT, mss)) nm_log_err (LOGD_IP6, "Failed to set default route."); diff --git a/src/nm-types.h b/src/nm-types.h index 2acc25c0bd..e67ae20527 100644 --- a/src/nm-types.h +++ b/src/nm-types.h @@ -39,6 +39,20 @@ typedef struct _NMRfkillManager NMRfkillManager; typedef struct _NMSessionMonitor NMSessionMonitor; typedef struct _NMSleepMonitor NMSleepMonitor; +typedef enum { + /* In priority order; higher number == higher priority */ + NM_IP_CONFIG_SOURCE_UNKNOWN, + NM_IP_CONFIG_SOURCE_KERNEL, + NM_IP_CONFIG_SOURCE_SHARED, + NM_IP_CONFIG_SOURCE_IP4LL, + NM_IP_CONFIG_SOURCE_PPP, + NM_IP_CONFIG_SOURCE_WWAN, + NM_IP_CONFIG_SOURCE_VPN, + NM_IP_CONFIG_SOURCE_DHCP, + NM_IP_CONFIG_SOURCE_RDISC, + NM_IP_CONFIG_SOURCE_USER, +} NMIPConfigSource; + /* platform */ typedef struct _NMPlatformIP4Address NMPlatformIP4Address; typedef struct _NMPlatformIP4Route NMPlatformIP4Route; diff --git a/src/platform/nm-fake-platform.c b/src/platform/nm-fake-platform.c index 4e5d424e33..9e376e5035 100644 --- a/src/platform/nm-fake-platform.c +++ b/src/platform/nm-fake-platform.c @@ -827,7 +827,7 @@ ip4_address_add (NMPlatform *platform, int ifindex, int i; memset (&address, 0, sizeof (address)); - address.source = NM_PLATFORM_SOURCE_KERNEL; + address.source = NM_IP_CONFIG_SOURCE_KERNEL; address.ifindex = ifindex; address.address = addr; address.peer_address = peer_addr; @@ -869,7 +869,7 @@ ip6_address_add (NMPlatform *platform, int ifindex, int i; memset (&address, 0, sizeof (address)); - address.source = NM_PLATFORM_SOURCE_KERNEL; + address.source = NM_IP_CONFIG_SOURCE_KERNEL; address.ifindex = ifindex; address.address = addr; address.peer_address = peer_addr; @@ -1040,7 +1040,7 @@ ip6_route_get_all (NMPlatform *platform, int ifindex, gboolean include_default) } static gboolean -ip4_route_add (NMPlatform *platform, int ifindex, NMPlatformSource source, +ip4_route_add (NMPlatform *platform, int ifindex, NMIPConfigSource source, in_addr_t network, int plen, in_addr_t gateway, int metric, int mss) { @@ -1049,7 +1049,7 @@ ip4_route_add (NMPlatform *platform, int ifindex, NMPlatformSource source, guint i; memset (&route, 0, sizeof (route)); - route.source = NM_PLATFORM_SOURCE_KERNEL; + route.source = NM_IP_CONFIG_SOURCE_KERNEL; route.ifindex = ifindex; route.source = source; route.network = network; @@ -1080,7 +1080,7 @@ ip4_route_add (NMPlatform *platform, int ifindex, NMPlatformSource source, } static gboolean -ip6_route_add (NMPlatform *platform, int ifindex, NMPlatformSource source, +ip6_route_add (NMPlatform *platform, int ifindex, NMIPConfigSource source, struct in6_addr network, int plen, struct in6_addr gateway, int metric, int mss) { @@ -1089,7 +1089,7 @@ ip6_route_add (NMPlatform *platform, int ifindex, NMPlatformSource source, guint i; memset (&route, 0, sizeof (route)); - route.source = NM_PLATFORM_SOURCE_KERNEL; + route.source = NM_IP_CONFIG_SOURCE_KERNEL; route.ifindex = ifindex; route.source = source; route.network = network; diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index 26fa5fe135..603701685d 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -1206,7 +1206,7 @@ init_ip4_address (NMPlatformIP4Address *address, struct rtnl_addr *rtnladdr) memset (address, 0, sizeof (*address)); - address->source = NM_PLATFORM_SOURCE_KERNEL; + address->source = NM_IP_CONFIG_SOURCE_KERNEL; address->ifindex = rtnl_addr_get_ifindex (rtnladdr); address->plen = rtnl_addr_get_prefixlen (rtnladdr); _init_ip_address_lifetime ((NMPlatformIPAddress *) address, rtnladdr); @@ -1238,7 +1238,7 @@ init_ip6_address (NMPlatformIP6Address *address, struct rtnl_addr *rtnladdr) memset (address, 0, sizeof (*address)); - address->source = NM_PLATFORM_SOURCE_KERNEL; + address->source = NM_IP_CONFIG_SOURCE_KERNEL; address->ifindex = rtnl_addr_get_ifindex (rtnladdr); address->plen = rtnl_addr_get_prefixlen (rtnladdr); _init_ip_address_lifetime ((NMPlatformIPAddress *) address, rtnladdr); @@ -1260,16 +1260,16 @@ init_ip6_address (NMPlatformIP6Address *address, struct rtnl_addr *rtnladdr) } static guint -source_to_rtprot (NMPlatformSource source) +source_to_rtprot (NMIPConfigSource source) { switch (source) { - case NM_PLATFORM_SOURCE_UNKNOWN: + case NM_IP_CONFIG_SOURCE_UNKNOWN: return RTPROT_UNSPEC; - case NM_PLATFORM_SOURCE_KERNEL: + case NM_IP_CONFIG_SOURCE_KERNEL: return RTPROT_KERNEL; - case NM_PLATFORM_SOURCE_DHCP: + case NM_IP_CONFIG_SOURCE_DHCP: return RTPROT_DHCP; - case NM_PLATFORM_SOURCE_RDISC: + case NM_IP_CONFIG_SOURCE_RDISC: return RTPROT_RA; default: @@ -1277,22 +1277,22 @@ source_to_rtprot (NMPlatformSource source) } } -static NMPlatformSource +static NMIPConfigSource rtprot_to_source (guint rtprot) { switch (rtprot) { case RTPROT_UNSPEC: - return NM_PLATFORM_SOURCE_UNKNOWN; + return NM_IP_CONFIG_SOURCE_UNKNOWN; case RTPROT_REDIRECT: case RTPROT_KERNEL: - return NM_PLATFORM_SOURCE_KERNEL; + return NM_IP_CONFIG_SOURCE_KERNEL; case RTPROT_RA: - return NM_PLATFORM_SOURCE_RDISC; + return NM_IP_CONFIG_SOURCE_RDISC; case RTPROT_DHCP: - return NM_PLATFORM_SOURCE_DHCP; + return NM_IP_CONFIG_SOURCE_DHCP; default: - return NM_PLATFORM_SOURCE_USER; + return NM_IP_CONFIG_SOURCE_USER; } } @@ -3708,7 +3708,7 @@ clear_host_address (int family, const void *network, int plen, void *dst) } static struct nl_object * -build_rtnl_route (int family, int ifindex, NMPlatformSource source, +build_rtnl_route (int family, int ifindex, NMIPConfigSource source, gconstpointer network, int plen, gconstpointer gateway, int metric, int mss) { @@ -3749,7 +3749,7 @@ build_rtnl_route (int family, int ifindex, NMPlatformSource source, } static gboolean -ip4_route_add (NMPlatform *platform, int ifindex, NMPlatformSource source, +ip4_route_add (NMPlatform *platform, int ifindex, NMIPConfigSource source, in_addr_t network, int plen, in_addr_t gateway, int metric, int mss) { @@ -3757,7 +3757,7 @@ ip4_route_add (NMPlatform *platform, int ifindex, NMPlatformSource source, } static gboolean -ip6_route_add (NMPlatform *platform, int ifindex, NMPlatformSource source, +ip6_route_add (NMPlatform *platform, int ifindex, NMIPConfigSource source, struct in6_addr network, int plen, struct in6_addr gateway, int metric, int mss) { @@ -3818,7 +3818,7 @@ ip4_route_delete (NMPlatform *platform, int ifindex, in_addr_t network, int plen { in_addr_t gateway = 0; struct rtnl_route *cached_object; - struct nl_object *route = build_rtnl_route (AF_INET, ifindex, NM_PLATFORM_SOURCE_UNKNOWN, &network, plen, &gateway, metric, 0); + struct nl_object *route = build_rtnl_route (AF_INET, ifindex, NM_IP_CONFIG_SOURCE_UNKNOWN, &network, plen, &gateway, metric, 0); uint8_t scope = RT_SCOPE_NOWHERE; struct nl_cache *cache; @@ -3878,7 +3878,7 @@ ip6_route_delete (NMPlatform *platform, int ifindex, struct in6_addr network, in { struct in6_addr gateway = IN6ADDR_ANY_INIT; - return delete_object (platform, build_rtnl_route (AF_INET6, ifindex, NM_PLATFORM_SOURCE_UNKNOWN ,&network, plen, &gateway, metric, 0), FALSE) && + return delete_object (platform, build_rtnl_route (AF_INET6, ifindex, NM_IP_CONFIG_SOURCE_UNKNOWN ,&network, plen, &gateway, metric, 0), FALSE) && refresh_route (platform, AF_INET6, ifindex, &network, plen, metric); } @@ -3886,7 +3886,7 @@ static gboolean ip_route_exists (NMPlatform *platform, int family, int ifindex, gpointer network, int plen, int metric) { auto_nl_object struct nl_object *object = build_rtnl_route (family, ifindex, - NM_PLATFORM_SOURCE_UNKNOWN, + NM_IP_CONFIG_SOURCE_UNKNOWN, network, plen, NULL, metric, 0); struct nl_cache *cache = choose_cache (platform, object); auto_nl_object struct nl_object *cached_object = nl_cache_search (cache, object); diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index fb2058faa7..75e6448d2b 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -1858,7 +1858,7 @@ nm_platform_ip6_route_get_all (int ifindex, gboolean include_default) } gboolean -nm_platform_ip4_route_add (int ifindex, NMPlatformSource source, +nm_platform_ip4_route_add (int ifindex, NMIPConfigSource source, in_addr_t network, int plen, in_addr_t gateway, int metric, int mss) { @@ -1887,7 +1887,7 @@ nm_platform_ip4_route_add (int ifindex, NMPlatformSource source, } gboolean -nm_platform_ip6_route_add (int ifindex, NMPlatformSource source, +nm_platform_ip6_route_add (int ifindex, NMIPConfigSource source, struct in6_addr network, int plen, struct in6_addr gateway, int metric, int mss) { @@ -2059,7 +2059,7 @@ nm_platform_ip4_route_sync (int ifindex, const GArray *known_routes) known_route->gateway, known_route->metric, known_route->mss); - if (!success && known_route->source < NM_PLATFORM_SOURCE_USER) { + if (!success && known_route->source < NM_IP_CONFIG_SOURCE_USER) { nm_log_dbg (LOGD_PLATFORM, "ignore error adding IPv4 route to kernel: %s", nm_platform_ip4_route_to_string (known_route)); success = TRUE; @@ -2127,7 +2127,7 @@ nm_platform_ip6_route_sync (int ifindex, const GArray *known_routes) known_route->gateway, known_route->metric, known_route->mss); - if (!success && known_route->source < NM_PLATFORM_SOURCE_USER) { + if (!success && known_route->source < NM_IP_CONFIG_SOURCE_USER) { nm_log_dbg (LOGD_PLATFORM, "ignore error adding IPv6 route to kernel: %s", nm_platform_ip6_route_to_string (known_route)); success = TRUE; @@ -2150,26 +2150,26 @@ nm_platform_route_flush (int ifindex) /******************************************************************/ static const char * -source_to_string (NMPlatformSource source) +source_to_string (NMIPConfigSource source) { switch (source) { - case NM_PLATFORM_SOURCE_KERNEL: + case NM_IP_CONFIG_SOURCE_KERNEL: return "kernel"; - case NM_PLATFORM_SOURCE_SHARED: + case NM_IP_CONFIG_SOURCE_SHARED: return "shared"; - case NM_PLATFORM_SOURCE_IP4LL: + case NM_IP_CONFIG_SOURCE_IP4LL: return "ipv4ll"; - case NM_PLATFORM_SOURCE_PPP: + case NM_IP_CONFIG_SOURCE_PPP: return "ppp"; - case NM_PLATFORM_SOURCE_WWAN: + case NM_IP_CONFIG_SOURCE_WWAN: return "wwan"; - case NM_PLATFORM_SOURCE_VPN: + case NM_IP_CONFIG_SOURCE_VPN: return "vpn"; - case NM_PLATFORM_SOURCE_DHCP: + case NM_IP_CONFIG_SOURCE_DHCP: return "dhcp"; - case NM_PLATFORM_SOURCE_RDISC: + case NM_IP_CONFIG_SOURCE_RDISC: return "rdisc"; - case NM_PLATFORM_SOURCE_USER: + case NM_IP_CONFIG_SOURCE_USER: return "user"; default: break; diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index 4cddd9c2b7..cd2729cddf 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -143,21 +143,6 @@ typedef enum { #define NM_PLATFORM_LIFETIME_PERMANENT G_MAXUINT32 -typedef enum { - /* In priority order; higher number == higher priority */ - NM_PLATFORM_SOURCE_UNKNOWN, - NM_PLATFORM_SOURCE_KERNEL, - NM_PLATFORM_SOURCE_SHARED, - NM_PLATFORM_SOURCE_IP4LL, - NM_PLATFORM_SOURCE_PPP, - NM_PLATFORM_SOURCE_WWAN, - NM_PLATFORM_SOURCE_VPN, - NM_PLATFORM_SOURCE_DHCP, - NM_PLATFORM_SOURCE_RDISC, - NM_PLATFORM_SOURCE_USER, -} NMPlatformSource; - - typedef struct { __NMPlatformObject_COMMON; } NMPlatformObject; @@ -165,7 +150,7 @@ typedef struct { #define __NMPlatformIPAddress_COMMON \ __NMPlatformObject_COMMON; \ - NMPlatformSource source; \ + NMIPConfigSource source; \ \ /* Timestamp in seconds in the reference system of nm_utils_get_monotonic_timestamp_*(). * @@ -235,7 +220,7 @@ G_STATIC_ASSERT (G_STRUCT_OFFSET (NMPlatformIPAddress, address_ptr) == G_STRUCT_ #define __NMPlatformIPRoute_COMMON \ __NMPlatformObject_COMMON; \ - NMPlatformSource source; \ + NMIPConfigSource source; \ int plen; \ guint metric; \ guint mss; \ @@ -454,10 +439,10 @@ typedef struct { GArray * (*ip4_route_get_all) (NMPlatform *, int ifindex, gboolean include_default); GArray * (*ip6_route_get_all) (NMPlatform *, int ifindex, gboolean include_default); - gboolean (*ip4_route_add) (NMPlatform *, int ifindex, NMPlatformSource source, + gboolean (*ip4_route_add) (NMPlatform *, int ifindex, NMIPConfigSource source, in_addr_t network, int plen, in_addr_t gateway, int prio, int mss); - gboolean (*ip6_route_add) (NMPlatform *, int ifindex, NMPlatformSource source, + gboolean (*ip6_route_add) (NMPlatform *, int ifindex, NMIPConfigSource source, struct in6_addr network, int plen, struct in6_addr gateway, int prio, int mss); gboolean (*ip4_route_delete) (NMPlatform *, int ifindex, in_addr_t network, int plen, int metric); @@ -602,10 +587,10 @@ gboolean nm_platform_address_flush (int ifindex); GArray *nm_platform_ip4_route_get_all (int ifindex, gboolean include_default); GArray *nm_platform_ip6_route_get_all (int ifindex, gboolean include_default); gboolean nm_platform_route_set_metric (int ifindex, int metric); -gboolean nm_platform_ip4_route_add (int ifindex, NMPlatformSource source, +gboolean nm_platform_ip4_route_add (int ifindex, NMIPConfigSource source, in_addr_t network, int plen, in_addr_t gateway, int metric, int mss); -gboolean nm_platform_ip6_route_add (int ifindex, NMPlatformSource source, +gboolean nm_platform_ip6_route_add (int ifindex, NMIPConfigSource source, struct in6_addr network, int plen, struct in6_addr gateway, int metric, int mss); gboolean nm_platform_ip4_route_delete (int ifindex, in_addr_t network, int plen, int metric); diff --git a/src/platform/tests/platform.c b/src/platform/tests/platform.c index 3bc2acbf9d..469652c55f 100644 --- a/src/platform/tests/platform.c +++ b/src/platform/tests/platform.c @@ -680,7 +680,7 @@ do_ip4_route_add (char **argv) metric = strtol (*argv++, NULL, 10); mss = strtol (*argv++, NULL, 10); - return nm_platform_ip4_route_add (ifindex, NM_PLATFORM_SOURCE_USER, + return nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, metric, mss); } @@ -696,7 +696,7 @@ do_ip6_route_add (char **argv) parse_ip6_address (*argv++, &gateway, NULL); metric = strtol (*argv++, NULL, 10); mss = strtol (*argv++, NULL, 10); - return nm_platform_ip6_route_add (ifindex, NM_PLATFORM_SOURCE_USER, + return nm_platform_ip6_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, metric, mss); } diff --git a/src/platform/tests/test-cleanup.c b/src/platform/tests/test-cleanup.c index e60d82f0ed..6006ca1f1b 100644 --- a/src/platform/tests/test-cleanup.c +++ b/src/platform/tests/test-cleanup.c @@ -43,12 +43,12 @@ test_cleanup_internal () /* Add routes and addresses */ g_assert (nm_platform_ip4_address_add (ifindex, addr4, 0, plen4, lifetime, preferred, NULL)); g_assert (nm_platform_ip6_address_add (ifindex, addr6, in6addr_any, plen6, lifetime, preferred, flags)); - g_assert (nm_platform_ip4_route_add (ifindex, NM_PLATFORM_SOURCE_USER, gateway4, 32, INADDR_ANY, metric, mss)); - g_assert (nm_platform_ip4_route_add (ifindex, NM_PLATFORM_SOURCE_USER, network4, plen4, gateway4, metric, mss)); - g_assert (nm_platform_ip4_route_add (ifindex, NM_PLATFORM_SOURCE_USER, 0, 0, gateway4, metric, mss)); - g_assert (nm_platform_ip6_route_add (ifindex, NM_PLATFORM_SOURCE_USER, gateway6, 128, in6addr_any, metric, mss)); - g_assert (nm_platform_ip6_route_add (ifindex, NM_PLATFORM_SOURCE_USER, network6, plen6, gateway6, metric, mss)); - g_assert (nm_platform_ip6_route_add (ifindex, NM_PLATFORM_SOURCE_USER, in6addr_any, 0, gateway6, metric, mss)); + g_assert (nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, gateway4, 32, INADDR_ANY, metric, mss)); + g_assert (nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, network4, plen4, gateway4, metric, mss)); + g_assert (nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, 0, 0, gateway4, metric, mss)); + g_assert (nm_platform_ip6_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, gateway6, 128, in6addr_any, metric, mss)); + g_assert (nm_platform_ip6_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, network6, plen6, gateway6, metric, mss)); + g_assert (nm_platform_ip6_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, in6addr_any, 0, gateway6, metric, mss)); addresses4 = nm_platform_ip4_address_get_all (ifindex); addresses6 = nm_platform_ip6_address_get_all (ifindex); diff --git a/src/platform/tests/test-route.c b/src/platform/tests/test-route.c index d45730ac57..4d6c5f09b0 100644 --- a/src/platform/tests/test-route.c +++ b/src/platform/tests/test-route.c @@ -66,56 +66,56 @@ test_ip4_route () inet_pton (AF_INET, "198.51.100.1", &gateway); /* Add route to gateway */ - g_assert (nm_platform_ip4_route_add (ifindex, NM_PLATFORM_SOURCE_USER, gateway, 32, INADDR_ANY, metric, mss)); + g_assert (nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, gateway, 32, INADDR_ANY, metric, mss)); no_error (); accept_signal (route_added); /* Add route */ g_assert (!nm_platform_ip4_route_exists (ifindex, network, plen, metric)); no_error (); - g_assert (nm_platform_ip4_route_add (ifindex, NM_PLATFORM_SOURCE_USER, network, plen, gateway, metric, mss)); + g_assert (nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, metric, mss)); no_error (); g_assert (nm_platform_ip4_route_exists (ifindex, network, plen, metric)); no_error (); accept_signal (route_added); /* Add route again */ - g_assert (nm_platform_ip4_route_add (ifindex, NM_PLATFORM_SOURCE_USER, network, plen, gateway, metric, mss)); + g_assert (nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, metric, mss)); no_error (); accept_signal (route_changed); /* Add default route */ g_assert (!nm_platform_ip4_route_exists (ifindex, 0, 0, metric)); no_error (); - g_assert (nm_platform_ip4_route_add (ifindex, NM_PLATFORM_SOURCE_USER, 0, 0, gateway, metric, mss)); + g_assert (nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, 0, 0, gateway, metric, mss)); no_error (); g_assert (nm_platform_ip4_route_exists (ifindex, 0, 0, metric)); no_error (); accept_signal (route_added); /* Add default route again */ - g_assert (nm_platform_ip4_route_add (ifindex, NM_PLATFORM_SOURCE_USER, 0, 0, gateway, metric, mss)); + g_assert (nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, 0, 0, gateway, metric, mss)); no_error (); accept_signal (route_changed); /* Test route listing */ routes = nm_platform_ip4_route_get_all (ifindex, TRUE); memset (rts, 0, sizeof (rts)); - rts[0].source = NM_PLATFORM_SOURCE_USER; + rts[0].source = NM_IP_CONFIG_SOURCE_USER; rts[0].network = gateway; rts[0].plen = 32; rts[0].ifindex = ifindex; rts[0].gateway = INADDR_ANY; rts[0].metric = metric; rts[0].mss = mss; - rts[1].source = NM_PLATFORM_SOURCE_USER; + rts[1].source = NM_IP_CONFIG_SOURCE_USER; rts[1].network = network; rts[1].plen = plen; rts[1].ifindex = ifindex; rts[1].gateway = gateway; rts[1].metric = metric; rts[1].mss = mss; - rts[2].source = NM_PLATFORM_SOURCE_USER; + rts[2].source = NM_IP_CONFIG_SOURCE_USER; rts[2].network = 0; rts[2].plen = 0; rts[2].ifindex = ifindex; @@ -161,56 +161,56 @@ test_ip6_route () inet_pton (AF_INET6, "2001:db8:c:d:1:2:3:4", &gateway); /* Add route to gateway */ - g_assert (nm_platform_ip6_route_add (ifindex, NM_PLATFORM_SOURCE_USER, gateway, 128, in6addr_any, metric, mss)); + g_assert (nm_platform_ip6_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, gateway, 128, in6addr_any, metric, mss)); no_error (); accept_signal (route_added); /* Add route */ g_assert (!nm_platform_ip6_route_exists (ifindex, network, plen, metric)); no_error (); - g_assert (nm_platform_ip6_route_add (ifindex, NM_PLATFORM_SOURCE_USER, network, plen, gateway, metric, mss)); + g_assert (nm_platform_ip6_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, metric, mss)); no_error (); g_assert (nm_platform_ip6_route_exists (ifindex, network, plen, metric)); no_error (); accept_signal (route_added); /* Add route again */ - g_assert (nm_platform_ip6_route_add (ifindex, NM_PLATFORM_SOURCE_USER, network, plen, gateway, metric, mss)); + g_assert (nm_platform_ip6_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, metric, mss)); no_error (); accept_signal (route_changed); /* Add default route */ g_assert (!nm_platform_ip6_route_exists (ifindex, in6addr_any, 0, metric)); no_error (); - g_assert (nm_platform_ip6_route_add (ifindex, NM_PLATFORM_SOURCE_USER, in6addr_any, 0, gateway, metric, mss)); + g_assert (nm_platform_ip6_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, in6addr_any, 0, gateway, metric, mss)); no_error (); g_assert (nm_platform_ip6_route_exists (ifindex, in6addr_any, 0, metric)); no_error (); accept_signal (route_added); /* Add default route again */ - g_assert (nm_platform_ip6_route_add (ifindex, NM_PLATFORM_SOURCE_USER, in6addr_any, 0, gateway, metric, mss)); + g_assert (nm_platform_ip6_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, in6addr_any, 0, gateway, metric, mss)); no_error (); accept_signal (route_changed); /* Test route listing */ routes = nm_platform_ip6_route_get_all (ifindex, TRUE); memset (rts, 0, sizeof (rts)); - rts[0].source = NM_PLATFORM_SOURCE_USER; + rts[0].source = NM_IP_CONFIG_SOURCE_USER; rts[0].network = gateway; rts[0].plen = 128; rts[0].ifindex = ifindex; rts[0].gateway = in6addr_any; rts[0].metric = metric; rts[0].mss = mss; - rts[1].source = NM_PLATFORM_SOURCE_USER; + rts[1].source = NM_IP_CONFIG_SOURCE_USER; rts[1].network = network; rts[1].plen = plen; rts[1].ifindex = ifindex; rts[1].gateway = gateway; rts[1].metric = metric; rts[1].mss = mss; - rts[2].source = NM_PLATFORM_SOURCE_USER; + rts[2].source = NM_IP_CONFIG_SOURCE_USER; rts[2].network = in6addr_any; rts[2].plen = 0; rts[2].ifindex = ifindex; diff --git a/src/ppp-manager/nm-ppp-manager.c b/src/ppp-manager/nm-ppp-manager.c index 0b8481d419..af588c51ec 100644 --- a/src/ppp-manager/nm-ppp-manager.c +++ b/src/ppp-manager/nm-ppp-manager.c @@ -583,7 +583,7 @@ impl_ppp_manager_set_ip4_config (NMPPPManager *manager, address.plen = g_value_get_uint (val); if (address.address && address.plen) { - address.source = NM_PLATFORM_SOURCE_PPP; + address.source = NM_IP_CONFIG_SOURCE_PPP; nm_ip4_config_add_address (config, &address); } else { nm_log_err (LOGD_PPP, "invalid IPv4 address received!"); diff --git a/src/tests/test-ip4-config.c b/src/tests/test-ip4-config.c index 0032b8f7a7..ca01d5f02e 100644 --- a/src/tests/test-ip4-config.c +++ b/src/tests/test-ip4-config.c @@ -194,18 +194,18 @@ test_compare_with_source (void) /* Address */ addr_init (&addr, "1.2.3.4", NULL, 24); - addr.source = NM_PLATFORM_SOURCE_USER; + addr.source = NM_IP_CONFIG_SOURCE_USER; nm_ip4_config_add_address (a, &addr); - addr.source = NM_PLATFORM_SOURCE_VPN; + addr.source = NM_IP_CONFIG_SOURCE_VPN; nm_ip4_config_add_address (b, &addr); /* Route */ route_new (&route, "10.0.0.0", 8, "192.168.1.1"); - route.source = NM_PLATFORM_SOURCE_USER; + route.source = NM_IP_CONFIG_SOURCE_USER; nm_ip4_config_add_route (a, &route); - route.source = NM_PLATFORM_SOURCE_VPN; + route.source = NM_IP_CONFIG_SOURCE_VPN; nm_ip4_config_add_route (b, &route); /* Assert that the configs are basically the same, eg that the source is ignored */ @@ -226,31 +226,31 @@ test_add_address_with_source (void) /* Test that a higher priority source is not overwritten */ addr_init (&addr, "1.2.3.4", NULL, 24); - addr.source = NM_PLATFORM_SOURCE_USER; + addr.source = NM_IP_CONFIG_SOURCE_USER; nm_ip4_config_add_address (a, &addr); test_addr = nm_ip4_config_get_address (a, 0); - g_assert_cmpint (test_addr->source, ==, NM_PLATFORM_SOURCE_USER); + g_assert_cmpint (test_addr->source, ==, NM_IP_CONFIG_SOURCE_USER); - addr.source = NM_PLATFORM_SOURCE_VPN; + addr.source = NM_IP_CONFIG_SOURCE_VPN; nm_ip4_config_add_address (a, &addr); test_addr = nm_ip4_config_get_address (a, 0); - g_assert_cmpint (test_addr->source, ==, NM_PLATFORM_SOURCE_USER); + g_assert_cmpint (test_addr->source, ==, NM_IP_CONFIG_SOURCE_USER); /* Test that a lower priority address source is overwritten */ nm_ip4_config_del_address (a, 0); - addr.source = NM_PLATFORM_SOURCE_KERNEL; + addr.source = NM_IP_CONFIG_SOURCE_KERNEL; nm_ip4_config_add_address (a, &addr); test_addr = nm_ip4_config_get_address (a, 0); - g_assert_cmpint (test_addr->source, ==, NM_PLATFORM_SOURCE_KERNEL); + g_assert_cmpint (test_addr->source, ==, NM_IP_CONFIG_SOURCE_KERNEL); - addr.source = NM_PLATFORM_SOURCE_USER; + addr.source = NM_IP_CONFIG_SOURCE_USER; nm_ip4_config_add_address (a, &addr); test_addr = nm_ip4_config_get_address (a, 0); - g_assert_cmpint (test_addr->source, ==, NM_PLATFORM_SOURCE_USER); + g_assert_cmpint (test_addr->source, ==, NM_IP_CONFIG_SOURCE_USER); g_object_unref (a); } @@ -266,31 +266,31 @@ test_add_route_with_source (void) /* Test that a higher priority source is not overwritten */ route_new (&route, "1.2.3.4", 24, "1.2.3.1"); - route.source = NM_PLATFORM_SOURCE_USER; + route.source = NM_IP_CONFIG_SOURCE_USER; nm_ip4_config_add_route (a, &route); test_route = nm_ip4_config_get_route (a, 0); - g_assert_cmpint (test_route->source, ==, NM_PLATFORM_SOURCE_USER); + g_assert_cmpint (test_route->source, ==, NM_IP_CONFIG_SOURCE_USER); - route.source = NM_PLATFORM_SOURCE_VPN; + route.source = NM_IP_CONFIG_SOURCE_VPN; nm_ip4_config_add_route (a, &route); test_route = nm_ip4_config_get_route (a, 0); - g_assert_cmpint (test_route->source, ==, NM_PLATFORM_SOURCE_USER); + g_assert_cmpint (test_route->source, ==, NM_IP_CONFIG_SOURCE_USER); /* Test that a lower priority address source is overwritten */ nm_ip4_config_del_route (a, 0); - route.source = NM_PLATFORM_SOURCE_KERNEL; + route.source = NM_IP_CONFIG_SOURCE_KERNEL; nm_ip4_config_add_route (a, &route); test_route = nm_ip4_config_get_route (a, 0); - g_assert_cmpint (test_route->source, ==, NM_PLATFORM_SOURCE_KERNEL); + g_assert_cmpint (test_route->source, ==, NM_IP_CONFIG_SOURCE_KERNEL); - route.source = NM_PLATFORM_SOURCE_USER; + route.source = NM_IP_CONFIG_SOURCE_USER; nm_ip4_config_add_route (a, &route); test_route = nm_ip4_config_get_route (a, 0); - g_assert_cmpint (test_route->source, ==, NM_PLATFORM_SOURCE_USER); + g_assert_cmpint (test_route->source, ==, NM_IP_CONFIG_SOURCE_USER); g_object_unref (a); } diff --git a/src/tests/test-ip6-config.c b/src/tests/test-ip6-config.c index 2177241de5..f8ecefc93b 100644 --- a/src/tests/test-ip6-config.c +++ b/src/tests/test-ip6-config.c @@ -132,18 +132,18 @@ test_compare_with_source (void) /* Address */ addr = *nmtst_platform_ip6_address ("1122:3344:5566::7788", NULL, 64); - addr.source = NM_PLATFORM_SOURCE_USER; + addr.source = NM_IP_CONFIG_SOURCE_USER; nm_ip6_config_add_address (a, &addr); - addr.source = NM_PLATFORM_SOURCE_VPN; + addr.source = NM_IP_CONFIG_SOURCE_VPN; nm_ip6_config_add_address (b, &addr); /* Route */ route = *nmtst_platform_ip6_route ("abcd:1234:4321::", 24, "abcd:1234:4321:cdde::2"); - route.source = NM_PLATFORM_SOURCE_USER; + route.source = NM_IP_CONFIG_SOURCE_USER; nm_ip6_config_add_route (a, &route); - route.source = NM_PLATFORM_SOURCE_VPN; + route.source = NM_IP_CONFIG_SOURCE_VPN; nm_ip6_config_add_route (b, &route); /* Assert that the configs are basically the same, eg that the source is ignored */ @@ -164,31 +164,31 @@ test_add_address_with_source (void) /* Test that a higher priority source is not overwritten */ addr = *nmtst_platform_ip6_address ("1122:3344:5566::7788", NULL, 64); - addr.source = NM_PLATFORM_SOURCE_USER; + addr.source = NM_IP_CONFIG_SOURCE_USER; nm_ip6_config_add_address (a, &addr); test_addr = nm_ip6_config_get_address (a, 0); - g_assert_cmpint (test_addr->source, ==, NM_PLATFORM_SOURCE_USER); + g_assert_cmpint (test_addr->source, ==, NM_IP_CONFIG_SOURCE_USER); - addr.source = NM_PLATFORM_SOURCE_VPN; + addr.source = NM_IP_CONFIG_SOURCE_VPN; nm_ip6_config_add_address (a, &addr); test_addr = nm_ip6_config_get_address (a, 0); - g_assert_cmpint (test_addr->source, ==, NM_PLATFORM_SOURCE_USER); + g_assert_cmpint (test_addr->source, ==, NM_IP_CONFIG_SOURCE_USER); /* Test that a lower priority address source is overwritten */ nm_ip6_config_del_address (a, 0); - addr.source = NM_PLATFORM_SOURCE_KERNEL; + addr.source = NM_IP_CONFIG_SOURCE_KERNEL; nm_ip6_config_add_address (a, &addr); test_addr = nm_ip6_config_get_address (a, 0); - g_assert_cmpint (test_addr->source, ==, NM_PLATFORM_SOURCE_KERNEL); + g_assert_cmpint (test_addr->source, ==, NM_IP_CONFIG_SOURCE_KERNEL); - addr.source = NM_PLATFORM_SOURCE_USER; + addr.source = NM_IP_CONFIG_SOURCE_USER; nm_ip6_config_add_address (a, &addr); test_addr = nm_ip6_config_get_address (a, 0); - g_assert_cmpint (test_addr->source, ==, NM_PLATFORM_SOURCE_USER); + g_assert_cmpint (test_addr->source, ==, NM_IP_CONFIG_SOURCE_USER); g_object_unref (a); } @@ -204,31 +204,31 @@ test_add_route_with_source (void) /* Test that a higher priority source is not overwritten */ route = *nmtst_platform_ip6_route ("abcd:1234:4321::", 24, "abcd:1234:4321:cdde::2"); - route.source = NM_PLATFORM_SOURCE_USER; + route.source = NM_IP_CONFIG_SOURCE_USER; nm_ip6_config_add_route (a, &route); test_route = nm_ip6_config_get_route (a, 0); - g_assert_cmpint (test_route->source, ==, NM_PLATFORM_SOURCE_USER); + g_assert_cmpint (test_route->source, ==, NM_IP_CONFIG_SOURCE_USER); - route.source = NM_PLATFORM_SOURCE_VPN; + route.source = NM_IP_CONFIG_SOURCE_VPN; nm_ip6_config_add_route (a, &route); test_route = nm_ip6_config_get_route (a, 0); - g_assert_cmpint (test_route->source, ==, NM_PLATFORM_SOURCE_USER); + g_assert_cmpint (test_route->source, ==, NM_IP_CONFIG_SOURCE_USER); /* Test that a lower priority address source is overwritten */ nm_ip6_config_del_route (a, 0); - route.source = NM_PLATFORM_SOURCE_KERNEL; + route.source = NM_IP_CONFIG_SOURCE_KERNEL; nm_ip6_config_add_route (a, &route); test_route = nm_ip6_config_get_route (a, 0); - g_assert_cmpint (test_route->source, ==, NM_PLATFORM_SOURCE_KERNEL); + g_assert_cmpint (test_route->source, ==, NM_IP_CONFIG_SOURCE_KERNEL); - route.source = NM_PLATFORM_SOURCE_USER; + route.source = NM_IP_CONFIG_SOURCE_USER; nm_ip6_config_add_route (a, &route); test_route = nm_ip6_config_get_route (a, 0); - g_assert_cmpint (test_route->source, ==, NM_PLATFORM_SOURCE_USER); + g_assert_cmpint (test_route->source, ==, NM_IP_CONFIG_SOURCE_USER); g_object_unref (a); } @@ -286,33 +286,33 @@ test_nm_ip6_config_addresses_sort (void) #define ADDR_ADD(...) nm_ip6_config_add_address (config, nmtst_platform_ip6_address_full (__VA_ARGS__)) nm_ip6_config_reset_addresses (config); - ADDR_ADD("2607:f0d0:1002:51::4", NULL, 64, 0, NM_PLATFORM_SOURCE_USER, 0, 0, 0, 0); - ADDR_ADD("2607:f0d0:1002:51::5", NULL, 64, 0, NM_PLATFORM_SOURCE_USER, 0, 0, 0, 0); - ADDR_ADD("2607:f0d0:1002:51::6", NULL, 64, 0, NM_PLATFORM_SOURCE_RDISC, 0, 0, 0, IFA_F_MANAGETEMPADDR); - ADDR_ADD("2607:f0d0:1002:51::3", NULL, 64, 0, NM_PLATFORM_SOURCE_USER, 0, 0, 0, IFA_F_SECONDARY); - ADDR_ADD("2607:f0d0:1002:51::8", NULL, 64, 0, NM_PLATFORM_SOURCE_USER, 0, 0, 0, IFA_F_SECONDARY); - ADDR_ADD("2607:f0d0:1002:51::0", NULL, 64, 0, NM_PLATFORM_SOURCE_KERNEL, 0, 0, 0, IFA_F_SECONDARY); - ADDR_ADD("fec0::1", NULL, 128, 0, NM_PLATFORM_SOURCE_KERNEL, 0, 0, 0, 0); - ADDR_ADD("fe80::208:74ff:feda:625c", NULL, 128, 0, NM_PLATFORM_SOURCE_KERNEL, 0, 0, 0, 0); - ADDR_ADD("fe80::208:74ff:feda:625d", NULL, 128, 0, NM_PLATFORM_SOURCE_KERNEL, 0, 0, 0, 0); - ADDR_ADD("::1", NULL, 128, 0, NM_PLATFORM_SOURCE_USER, 0, 0, 0, 0); - ADDR_ADD("2607:f0d0:1002:51::2", NULL, 64, 0, NM_PLATFORM_SOURCE_USER, 0, 0, 0, IFA_F_TENTATIVE); + ADDR_ADD("2607:f0d0:1002:51::4", NULL, 64, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, 0); + ADDR_ADD("2607:f0d0:1002:51::5", NULL, 64, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, 0); + ADDR_ADD("2607:f0d0:1002:51::6", NULL, 64, 0, NM_IP_CONFIG_SOURCE_RDISC, 0, 0, 0, IFA_F_MANAGETEMPADDR); + ADDR_ADD("2607:f0d0:1002:51::3", NULL, 64, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, IFA_F_SECONDARY); + ADDR_ADD("2607:f0d0:1002:51::8", NULL, 64, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, IFA_F_SECONDARY); + ADDR_ADD("2607:f0d0:1002:51::0", NULL, 64, 0, NM_IP_CONFIG_SOURCE_KERNEL, 0, 0, 0, IFA_F_SECONDARY); + ADDR_ADD("fec0::1", NULL, 128, 0, NM_IP_CONFIG_SOURCE_KERNEL, 0, 0, 0, 0); + ADDR_ADD("fe80::208:74ff:feda:625c", NULL, 128, 0, NM_IP_CONFIG_SOURCE_KERNEL, 0, 0, 0, 0); + ADDR_ADD("fe80::208:74ff:feda:625d", NULL, 128, 0, NM_IP_CONFIG_SOURCE_KERNEL, 0, 0, 0, 0); + ADDR_ADD("::1", NULL, 128, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, 0); + ADDR_ADD("2607:f0d0:1002:51::2", NULL, 64, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, IFA_F_TENTATIVE); test_nm_ip6_config_addresses_sort_check (config, NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN, 8); test_nm_ip6_config_addresses_sort_check (config, NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED, 8); test_nm_ip6_config_addresses_sort_check (config, NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR, 8); nm_ip6_config_reset_addresses (config); - ADDR_ADD("2607:f0d0:1002:51::3", NULL, 64, 0, NM_PLATFORM_SOURCE_USER, 0, 0, 0, IFA_F_SECONDARY); - ADDR_ADD("2607:f0d0:1002:51::4", NULL, 64, 0, NM_PLATFORM_SOURCE_USER, 0, 0, 0, 0); - ADDR_ADD("2607:f0d0:1002:51::5", NULL, 64, 0, NM_PLATFORM_SOURCE_USER, 0, 0, 0, 0); - ADDR_ADD("2607:f0d0:1002:51::8", NULL, 64, 0, NM_PLATFORM_SOURCE_USER, 0, 0, 0, IFA_F_SECONDARY); - ADDR_ADD("2607:f0d0:1002:51::0", NULL, 64, 0, NM_PLATFORM_SOURCE_KERNEL, 0, 0, 0, IFA_F_SECONDARY); - ADDR_ADD("2607:f0d0:1002:51::6", NULL, 64, 0, NM_PLATFORM_SOURCE_RDISC, 0, 0, 0, IFA_F_MANAGETEMPADDR); - ADDR_ADD("fec0::1", NULL, 128, 0, NM_PLATFORM_SOURCE_KERNEL, 0, 0, 0, 0); - ADDR_ADD("fe80::208:74ff:feda:625c", NULL, 128, 0, NM_PLATFORM_SOURCE_KERNEL, 0, 0, 0, 0); - ADDR_ADD("fe80::208:74ff:feda:625d", NULL, 128, 0, NM_PLATFORM_SOURCE_KERNEL, 0, 0, 0, 0); - ADDR_ADD("::1", NULL, 128, 0, NM_PLATFORM_SOURCE_USER, 0, 0, 0, 0); - ADDR_ADD("2607:f0d0:1002:51::2", NULL, 64, 0, NM_PLATFORM_SOURCE_USER, 0, 0, 0, IFA_F_TENTATIVE); + ADDR_ADD("2607:f0d0:1002:51::3", NULL, 64, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, IFA_F_SECONDARY); + ADDR_ADD("2607:f0d0:1002:51::4", NULL, 64, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, 0); + ADDR_ADD("2607:f0d0:1002:51::5", NULL, 64, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, 0); + ADDR_ADD("2607:f0d0:1002:51::8", NULL, 64, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, IFA_F_SECONDARY); + ADDR_ADD("2607:f0d0:1002:51::0", NULL, 64, 0, NM_IP_CONFIG_SOURCE_KERNEL, 0, 0, 0, IFA_F_SECONDARY); + ADDR_ADD("2607:f0d0:1002:51::6", NULL, 64, 0, NM_IP_CONFIG_SOURCE_RDISC, 0, 0, 0, IFA_F_MANAGETEMPADDR); + ADDR_ADD("fec0::1", NULL, 128, 0, NM_IP_CONFIG_SOURCE_KERNEL, 0, 0, 0, 0); + ADDR_ADD("fe80::208:74ff:feda:625c", NULL, 128, 0, NM_IP_CONFIG_SOURCE_KERNEL, 0, 0, 0, 0); + ADDR_ADD("fe80::208:74ff:feda:625d", NULL, 128, 0, NM_IP_CONFIG_SOURCE_KERNEL, 0, 0, 0, 0); + ADDR_ADD("::1", NULL, 128, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, 0); + ADDR_ADD("2607:f0d0:1002:51::2", NULL, 64, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, IFA_F_TENTATIVE); test_nm_ip6_config_addresses_sort_check (config, NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR, 8); #undef ADDR_ADD diff --git a/src/vpn-manager/nm-vpn-connection.c b/src/vpn-manager/nm-vpn-connection.c index cd22b61fd1..8106698ead 100644 --- a/src/vpn-manager/nm-vpn-connection.c +++ b/src/vpn-manager/nm-vpn-connection.c @@ -493,7 +493,7 @@ add_ip4_vpn_gateway_route (NMIP4Config *config, NMDevice *parent_device, guint32 if (nm_ip4_config_destination_is_direct (parent_config, vpn_gw, 32)) route.gateway = 0; - route.source = NM_PLATFORM_SOURCE_VPN; + route.source = NM_IP_CONFIG_SOURCE_VPN; route.metric = nm_device_get_priority (parent_device); nm_ip4_config_add_route (config, &route); @@ -505,7 +505,7 @@ add_ip4_vpn_gateway_route (NMIP4Config *config, NMDevice *parent_device, guint32 memset (&route, 0, sizeof (route)); route.network = parent_gw; route.plen = 32; - route.source = NM_PLATFORM_SOURCE_VPN; + route.source = NM_IP_CONFIG_SOURCE_VPN; route.metric = nm_device_get_priority (parent_device); nm_ip4_config_add_route (config, &route); @@ -542,7 +542,7 @@ add_ip6_vpn_gateway_route (NMIP6Config *config, if (nm_ip6_config_destination_is_direct (parent_config, vpn_gw, 128)) route.gateway = in6addr_any; - route.source = NM_PLATFORM_SOURCE_VPN; + route.source = NM_IP_CONFIG_SOURCE_VPN; route.metric = nm_device_get_priority (parent_device); nm_ip6_config_add_route (config, &route); @@ -554,7 +554,7 @@ add_ip6_vpn_gateway_route (NMIP6Config *config, memset (&route, 0, sizeof (route)); route.network = *parent_gw; route.plen = 128; - route.source = NM_PLATFORM_SOURCE_VPN; + route.source = NM_IP_CONFIG_SOURCE_VPN; route.metric = nm_device_get_priority (parent_device); nm_ip6_config_add_route (config, &route); @@ -1130,7 +1130,7 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy, address.plen = g_value_get_uint (val); if (address.address && address.plen) { - address.source = NM_PLATFORM_SOURCE_VPN; + address.source = NM_IP_CONFIG_SOURCE_VPN; nm_ip4_config_add_address (config, &address); } else { nm_log_err (LOGD_VPN, "invalid IP4 config received!"); @@ -1189,7 +1189,7 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy, route.network = nm_ip4_route_get_dest (item); route.plen = nm_ip4_route_get_prefix (item); route.gateway = nm_ip4_route_get_next_hop (item); - route.source = NM_PLATFORM_SOURCE_VPN; + route.source = NM_IP_CONFIG_SOURCE_VPN; route.metric = vpn_routing_metric (connection); /* Ignore host routes to the VPN gateway since NM adds one itself @@ -1284,7 +1284,7 @@ nm_vpn_connection_ip6_config_get (DBusGProxy *proxy, address.plen = g_value_get_uint (val); if (!IN6_IS_ADDR_UNSPECIFIED (&address.address) && address.plen) { - address.source = NM_PLATFORM_SOURCE_VPN; + address.source = NM_IP_CONFIG_SOURCE_VPN; nm_ip6_config_add_address (config, &address); } else { nm_log_err (LOGD_VPN, "invalid IP6 config received!"); @@ -1335,7 +1335,7 @@ nm_vpn_connection_ip6_config_get (DBusGProxy *proxy, route.network = *nm_ip6_route_get_dest (item); route.plen = nm_ip6_route_get_prefix (item); route.gateway = *nm_ip6_route_get_next_hop (item); - route.source = NM_PLATFORM_SOURCE_VPN; + route.source = NM_IP_CONFIG_SOURCE_VPN; route.metric = vpn_routing_metric (connection); /* Ignore host routes to the VPN gateway since NM adds one itself |