device: add nm_device_is_vpn() function

This commit is contained in:
Thomas Haller 2020-02-12 11:05:24 +01:00
parent bf4b53d453
commit 7d87d2b8da
2 changed files with 18 additions and 0 deletions

View file

@ -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)
{

View file

@ -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__ */