diff options
| author | Michael Biebl <biebl@debian.org> | 2019-03-26 23:25:23 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2019-03-26 23:25:23 +0100 |
| commit | 9a6dcbf895f9da01768e64b73cec88c16157d91e (patch) | |
| tree | a359958930d731e9f1b59344642e10754419fe84 /src/vpn | |
| parent | 964ae8cc391520440cf5aa13e2b9cc34850ea6c2 (diff) | |
New upstream version 1.16.0 upstream/1.16.0
Diffstat (limited to 'src/vpn')
| -rw-r--r-- | src/vpn/nm-vpn-connection.c | 64 | ||||
| -rw-r--r-- | src/vpn/nm-vpn-connection.h | 3 | ||||
| -rw-r--r-- | src/vpn/nm-vpn-manager.c | 2 |
3 files changed, 33 insertions, 36 deletions
diff --git a/src/vpn/nm-vpn-connection.c b/src/vpn/nm-vpn-connection.c index 3b3a97f4..5acf491a 100644 --- a/src/vpn/nm-vpn-connection.c +++ b/src/vpn/nm-vpn-connection.c @@ -23,11 +23,9 @@ #include "nm-vpn-connection.h" -#include <string.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> -#include <errno.h> #include <stdlib.h> #include <unistd.h> #include <syslog.h> @@ -725,7 +723,7 @@ add_ip4_vpn_gateway_route (NMIP4Config *config, AF_INET, &vpn_gw, ifindex, - (NMPObject **) &route_resolved) == NM_PLATFORM_ERROR_SUCCESS) { + (NMPObject **) &route_resolved) >= 0) { const NMPlatformIP4Route *r = NMP_OBJECT_CAST_IP4_ROUTE (route_resolved); if (r->ifindex == ifindex) { @@ -807,7 +805,7 @@ add_ip6_vpn_gateway_route (NMIP6Config *config, AF_INET6, vpn_gw, ifindex, - (NMPObject **) &route_resolved) == NM_PLATFORM_ERROR_SUCCESS) { + (NMPObject **) &route_resolved) >= 0) { const NMPlatformIP6Route *r = NMP_OBJECT_CAST_IP6_ROUTE (route_resolved); if (r->ifindex == ifindex) { @@ -867,6 +865,7 @@ nm_vpn_connection_new (NMSettingsConnection *settings_connection, NMDevice *parent_device, const char *specific_object, NMActivationReason activation_reason, + NMActivationStateFlags initial_state_flags, NMAuthSubject *subject) { g_return_val_if_fail (!settings_connection || NM_IS_SETTINGS_CONNECTION (settings_connection), NULL); @@ -880,6 +879,7 @@ nm_vpn_connection_new (NMSettingsConnection *settings_connection, NM_ACTIVE_CONNECTION_INT_SUBJECT, subject, NM_ACTIVE_CONNECTION_INT_ACTIVATION_REASON, activation_reason, NM_ACTIVE_CONNECTION_VPN, TRUE, + NM_ACTIVE_CONNECTION_STATE_FLAGS, (guint) initial_state_flags, NULL); } @@ -898,14 +898,15 @@ NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_vpn_plugin_failure_to_string, NMVpnPluginFai NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED, "connect-failed"), NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_PLUGIN_FAILURE_BAD_IP_CONFIG, "bad-ip-config"), ); -#define vpn_plugin_failure_to_string(failure) NM_UTILS_LOOKUP_STR (_vpn_plugin_failure_to_string, failure) + +#define vpn_plugin_failure_to_string_a(failure) NM_UTILS_LOOKUP_STR_A (_vpn_plugin_failure_to_string, failure) static void plugin_failed (NMVpnConnection *self, guint reason) { NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); - _LOGW ("VPN plugin: failed: %s (%d)", vpn_plugin_failure_to_string (reason), reason); + _LOGW ("VPN plugin: failed: %s (%d)", vpn_plugin_failure_to_string_a (reason), reason); switch (reason) { case NM_VPN_PLUGIN_FAILURE_LOGIN_FAILED: @@ -930,7 +931,8 @@ NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_vpn_service_state_to_string, NMVpnServiceSta NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_SERVICE_STATE_STOPPING, "stopping"), NM_UTILS_LOOKUP_STR_ITEM (NM_VPN_SERVICE_STATE_STOPPED, "stopped"), ); -#define vpn_service_state_to_string(state) NM_UTILS_LOOKUP_STR (_vpn_service_state_to_string, state) + +#define vpn_service_state_to_string_a(state) NM_UTILS_LOOKUP_STR_A (_vpn_service_state_to_string, state) NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_vpn_state_to_string, VpnState, NM_UTILS_LOOKUP_DEFAULT (NULL), @@ -946,7 +948,8 @@ NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_vpn_state_to_string, VpnState, NM_UTILS_LOOKUP_STR_ITEM (STATE_DISCONNECTED, "disconnected"), NM_UTILS_LOOKUP_STR_ITEM (STATE_FAILED, "failed"), ); -#define vpn_state_to_string(state) NM_UTILS_LOOKUP_STR (_vpn_state_to_string, state) + +#define vpn_state_to_string_a(state) NM_UTILS_LOOKUP_STR_A (_vpn_state_to_string, state) static void plugin_state_changed (NMVpnConnection *self, NMVpnServiceState new_service_state) @@ -955,7 +958,7 @@ plugin_state_changed (NMVpnConnection *self, NMVpnServiceState new_service_state NMVpnServiceState old_service_state = priv->service_state; _LOGI ("VPN plugin: state changed: %s (%d)", - vpn_service_state_to_string (new_service_state), new_service_state); + vpn_service_state_to_string_a (new_service_state), new_service_state); priv->service_state = new_service_state; if (new_service_state == NM_VPN_SERVICE_STATE_STOPPED) { @@ -995,15 +998,16 @@ print_vpn_config (NMVpnConnection *self) const NMPlatformIP6Address *address6; char *dns_domain = NULL; guint32 num, i; - char buf[NM_UTILS_INET_ADDRSTRLEN]; + char b1[NM_UTILS_INET_ADDRSTRLEN]; + char b2[NM_UTILS_INET_ADDRSTRLEN]; NMDedupMultiIter ipconf_iter; if (priv->ip4_external_gw) { _LOGI ("Data: VPN Gateway: %s", - nm_utils_inet4_ntop (priv->ip4_external_gw, NULL)); + nm_utils_inet4_ntop (priv->ip4_external_gw, b1)); } else if (priv->ip6_external_gw) { _LOGI ("Data: VPN Gateway: %s", - nm_utils_inet6_ntop (priv->ip6_external_gw, NULL)); + nm_utils_inet6_ntop (priv->ip6_external_gw, b1)); } _LOGI ("Data: Tunnel Device: %s%s%s", NM_PRINT_FMT_QUOTE_STRING (priv->ip_iface)); @@ -1017,22 +1021,22 @@ print_vpn_config (NMVpnConnection *self) nm_assert (address4); if (priv->ip4_internal_gw) - _LOGI ("Data: Internal Gateway: %s", nm_utils_inet4_ntop (priv->ip4_internal_gw, NULL)); - _LOGI ("Data: Internal Address: %s", address4 ? nm_utils_inet4_ntop (address4->address, NULL) : "??"); + _LOGI ("Data: Internal Gateway: %s", nm_utils_inet4_ntop (priv->ip4_internal_gw, b1)); + _LOGI ("Data: Internal Address: %s", address4 ? nm_utils_inet4_ntop (address4->address, b1) : "??"); _LOGI ("Data: Internal Prefix: %d", address4 ? (int) address4->plen : -1); - _LOGI ("Data: Internal Point-to-Point Address: %s", nm_utils_inet4_ntop (address4->peer_address, NULL)); + _LOGI ("Data: Internal Point-to-Point Address: %s", nm_utils_inet4_ntop (address4->peer_address, b1)); nm_ip_config_iter_ip4_route_for_each (&ipconf_iter, priv->ip4_config, &route) { _LOGI ("Data: Static Route: %s/%d Next Hop: %s", - nm_utils_inet4_ntop (route->network, NULL), + nm_utils_inet4_ntop (route->network, b1), route->plen, - nm_utils_inet4_ntop (route->gateway, buf)); + nm_utils_inet4_ntop (route->gateway, b2)); } num = nm_ip4_config_get_num_nameservers (priv->ip4_config); for (i = 0; i < num; i++) { _LOGI ("Data: Internal DNS: %s", - nm_utils_inet4_ntop (nm_ip4_config_get_nameserver (priv->ip4_config, i), NULL)); + nm_utils_inet4_ntop (nm_ip4_config_get_nameserver (priv->ip4_config, i), b1)); } if (nm_ip4_config_get_num_domains (priv->ip4_config) > 0) @@ -1051,22 +1055,22 @@ print_vpn_config (NMVpnConnection *self) nm_assert (address6); if (priv->ip6_internal_gw) - _LOGI ("Data: Internal Gateway: %s", nm_utils_inet6_ntop (priv->ip6_internal_gw, NULL)); - _LOGI ("Data: Internal Address: %s", nm_utils_inet6_ntop (&address6->address, NULL)); + _LOGI ("Data: Internal Gateway: %s", nm_utils_inet6_ntop (priv->ip6_internal_gw, b1)); + _LOGI ("Data: Internal Address: %s", nm_utils_inet6_ntop (&address6->address, b1)); _LOGI ("Data: Internal Prefix: %d", address6->plen); - _LOGI ("Data: Internal Point-to-Point Address: %s", nm_utils_inet6_ntop (&address6->peer_address, NULL)); + _LOGI ("Data: Internal Point-to-Point Address: %s", nm_utils_inet6_ntop (&address6->peer_address, b1)); nm_ip_config_iter_ip6_route_for_each (&ipconf_iter, priv->ip6_config, &route) { _LOGI ("Data: Static Route: %s/%d Next Hop: %s", - nm_utils_inet6_ntop (&route->network, NULL), + nm_utils_inet6_ntop (&route->network, b1), route->plen, - nm_utils_inet6_ntop (&route->gateway, buf)); + nm_utils_inet6_ntop (&route->gateway, b2)); } num = nm_ip6_config_get_num_nameservers (priv->ip6_config); for (i = 0; i < num; i++) { _LOGI ("Data: Internal DNS: %s", - nm_utils_inet6_ntop (nm_ip6_config_get_nameserver (priv->ip6_config, i), NULL)); + nm_utils_inet6_ntop (nm_ip6_config_get_nameserver (priv->ip6_config, i), b1)); } if (nm_ip6_config_get_num_domains (priv->ip6_config) > 0) @@ -1452,11 +1456,7 @@ get_route_table (NMVpnConnection *self, connection = _get_applied_connection (self); if (connection) { - if (addr_family == AF_INET) - s_ip = nm_connection_get_setting_ip4_config (connection); - else - s_ip = nm_connection_get_setting_ip6_config (connection); - + s_ip = nm_connection_get_setting_ip_config (connection, addr_family); if (s_ip) route_table = nm_setting_ip_config_get_route_table (s_ip); } @@ -1894,7 +1894,7 @@ connect_success (NMVpnConnection *self) timeout = nm_setting_vpn_get_timeout (s_vpn); if (timeout == 0) { timeout = nm_config_data_get_connection_default_int64 (NM_CONFIG_GET_DATA, - "vpn.timeout", + NM_CON_DEFAULT ("vpn.timeout"), NULL, 1, G_MAXUINT32, 60); } @@ -2703,12 +2703,12 @@ plugin_interactive_secrets_required (NMVpnConnection *self, if (!NM_IN_SET (priv->vpn_state, STATE_CONNECT, STATE_NEED_AUTH)) { _LOGD ("VPN plugin: requested secrets; state %s (%d); ignore request in current state", - vpn_state_to_string (priv->vpn_state), priv->vpn_state); + vpn_state_to_string_a (priv->vpn_state), priv->vpn_state); return; } _LOGI ("VPN plugin: requested secrets; state %s (%d)", - vpn_state_to_string (priv->vpn_state), priv->vpn_state); + vpn_state_to_string_a (priv->vpn_state), priv->vpn_state); priv->secrets_idx = SECRETS_REQ_INTERACTIVE; _set_vpn_state (self, STATE_NEED_AUTH, NM_ACTIVE_CONNECTION_STATE_REASON_NONE, FALSE); diff --git a/src/vpn/nm-vpn-connection.h b/src/vpn/nm-vpn-connection.h index e409cc31..e70590b2 100644 --- a/src/vpn/nm-vpn-connection.h +++ b/src/vpn/nm-vpn-connection.h @@ -28,8 +28,6 @@ #include "nm-active-connection.h" #include "nm-vpn-plugin-info.h" -#define NM_VPN_ROUTE_METRIC_DEFAULT 50 - #define NM_TYPE_VPN_CONNECTION (nm_vpn_connection_get_type ()) #define NM_VPN_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VPN_CONNECTION, NMVpnConnection)) #define NM_VPN_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_VPN_CONNECTION, NMVpnConnectionClass)) @@ -53,6 +51,7 @@ NMVpnConnection * nm_vpn_connection_new (NMSettingsConnection *settings_connecti NMDevice *parent_device, const char *specific_object, NMActivationReason activation_reason, + NMActivationStateFlags initial_state_flags, NMAuthSubject *subject); void nm_vpn_connection_activate (NMVpnConnection *self, diff --git a/src/vpn/nm-vpn-manager.c b/src/vpn/nm-vpn-manager.c index d0639168..0b27b9de 100644 --- a/src/vpn/nm-vpn-manager.c +++ b/src/vpn/nm-vpn-manager.c @@ -23,8 +23,6 @@ #include "nm-vpn-manager.h" -#include <string.h> - #include "nm-vpn-plugin-info.h" #include "nm-vpn-connection.h" #include "nm-setting-vpn.h" |