vpn: allow plugins to indicate 'can-persist' capability

The plugin can indicate that this connection can persist across link
changes and other connectivity dropouts by passing this option
back in the SetConfig() calls.
This commit is contained in:
Dan Williams 2014-10-23 13:07:20 -05:00
parent a966a5e8b5
commit 1f544d337c
3 changed files with 23 additions and 0 deletions

View file

@ -206,6 +206,11 @@ typedef enum {
/* boolean: Has IP6 configuration? */
#define NM_VPN_PLUGIN_CONFIG_HAS_IP6 "has-ip6"
/* boolean: If %TRUE the VPN plugin can persist/reconnect the connection over
* link changes and VPN server dropouts.
*/
#define NM_VPN_PLUGIN_CAN_PERSIST "can-persist"
/*** Ip4Config ***/

View file

@ -206,6 +206,11 @@ typedef enum {
/* boolean: Has IP6 configuration? */
#define NM_VPN_PLUGIN_CONFIG_HAS_IP6 "has-ip6"
/* boolean: If %TRUE the VPN plugin can persist/reconnect the connection over
* link changes and VPN server dropouts.
*/
#define NM_VPN_PLUGIN_CAN_PERSIST "can-persist"
/*** Ip4Config ***/

View file

@ -76,6 +76,8 @@ typedef enum {
typedef struct {
NMConnection *connection;
gboolean service_can_persist;
gboolean connection_can_persist;
guint32 secrets_id;
SecretsReq secrets_idx;
@ -945,6 +947,12 @@ process_generic_config (NMVpnConnection *connection,
NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (connection);
GValue *val;
val = (GValue *) g_hash_table_lookup (config_hash, NM_VPN_PLUGIN_CAN_PERSIST);
if (val && G_VALUE_HOLDS_BOOLEAN (val) && g_value_get_boolean (val)) {
/* Defaults to FALSE, so only let service indicate TRUE */
priv->service_can_persist = TRUE;
}
g_clear_pointer (&priv->ip_iface, g_free);
val = (GValue *) g_hash_table_lookup (config_hash, NM_VPN_PLUGIN_CONFIG_TUNDEV);
if (val) {
@ -1559,12 +1567,17 @@ void
nm_vpn_connection_activate (NMVpnConnection *connection)
{
NMVpnConnectionPrivate *priv;
NMSettingVpn *s_vpn;
DBusGConnection *bus;
g_return_if_fail (NM_IS_VPN_CONNECTION (connection));
priv = NM_VPN_CONNECTION_GET_PRIVATE (connection);
s_vpn = nm_connection_get_setting_vpn (priv->connection);
g_assert (s_vpn);
priv->connection_can_persist = nm_setting_vpn_get_persistent (s_vpn);
_set_vpn_state (connection, STATE_PREPARE, NM_VPN_CONNECTION_STATE_REASON_NONE, FALSE);
bus = nm_dbus_manager_get_connection (nm_dbus_manager_get ());