summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-02-12 11:05:24 +0100
committerThomas Haller <thaller@redhat.com>2020-02-12 11:55:30 +0100
commit7d87d2b8dae29c57fb25583b2105dec0bcdffe78 (patch)
treec8a73da59e6fcc48a497517e12e55f32e44367d8
parentbf4b53d453c23452514a996c83d170c5f3dc64f1 (diff)
device: add nm_device_is_vpn() function
-rw-r--r--src/devices/nm-device.c16
-rw-r--r--src/devices/nm-device.h2
2 files changed, 18 insertions, 0 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 763008048..ca2a51321 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -871,6 +871,22 @@ is_loopback (NMDevice *self)
&& NM_DEVICE_GET_PRIVATE (self)->ifindex == 1;
}
+gboolean
+nm_device_is_vpn (NMDevice *self)
+{
+ g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
+
+ /* NetworkManager currently treats VPN connections (loaded from NetworkManager VPN plugins)
+ * differently. Those are considered VPNs.
+ * However, some native device types may also be considered VPNs...
+ *
+ * We should avoid distinguishing between is-vpn and "regular" devices. Is an (unencrypted)
+ * IP tunnel a VPN? Is MACSec on top of an IP tunnel a VPN?
+ * Sometimes we differentiate, but avoid unless reasonable. */
+
+ return NM_IS_DEVICE_WIREGUARD (self);
+}
+
NMSettings *
nm_device_get_settings (NMDevice *self)
{
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index 66f9aa97b..0a0ea6250 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -881,4 +881,6 @@ struct _NMBtVTableNetworkServer {
const char *nm_device_state_to_str (NMDeviceState state);
const char *nm_device_state_reason_to_str (NMDeviceStateReason reason);
+gboolean nm_device_is_vpn (NMDevice *self);
+
#endif /* __NETWORKMANAGER_DEVICE_H__ */