diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2019-10-10 10:04:06 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2019-11-12 13:48:49 +0100 |
commit | b4b2f2735f252ad250159a4d7d3cb0f95df309c8 (patch) | |
tree | 41e85eb41e74ce7c6d51c085742457540747c02b | |
parent | 2e96cd48a3e863edc2c7cae0be94232347a17ea0 (diff) | |
download | NetworkManager-b4b2f2735f252ad250159a4d7d3cb0f95df309c8.tar.gz |
libnm: export interface flags
Add libnm support for the new InterfaceFlags property of NMDevice.
-rwxr-xr-x | examples/python/gi/get-interface-flags.py | 19 | ||||
-rw-r--r-- | libnm/libnm.ver | 1 | ||||
-rw-r--r-- | libnm/nm-device.c | 37 | ||||
-rw-r--r-- | libnm/nm-device.h | 4 |
4 files changed, 61 insertions, 0 deletions
diff --git a/examples/python/gi/get-interface-flags.py b/examples/python/gi/get-interface-flags.py new file mode 100755 index 0000000000..756999169b --- /dev/null +++ b/examples/python/gi/get-interface-flags.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2019 Red Hat, Inc. +# + +import gi +gi.require_version('NM', '1.0') +from gi.repository import GLib, NM + +if __name__ == "__main__": + client = NM.Client.new(None) + devices = client.get_devices() + + for d in devices: + print("{:<16} {:<16} {}".format(d.get_iface(), + "(" + d.get_type_description() + ")", + NM.utils_enum_to_str(NM.DeviceInterfaceFlags, + d.get_interface_flags()))) diff --git a/libnm/libnm.ver b/libnm/libnm.ver index 3ce7a0dea8..743bb50a06 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -1640,6 +1640,7 @@ global: nm_client_get_dbus_name_owner; nm_client_reload; nm_client_reload_finish; + nm_device_get_interface_flags; nm_device_interface_flags_get_type; nm_manager_reload_flags_get_type; nm_setting_gsm_get_auto_config; diff --git a/libnm/nm-device.c b/libnm/nm-device.c index 8344f2a037..4c8ac04c11 100644 --- a/libnm/nm-device.c +++ b/libnm/nm-device.c @@ -61,6 +61,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( PROP_LLDP_NEIGHBORS, PROP_IP4_CONNECTIVITY, PROP_IP6_CONNECTIVITY, + PROP_INTERFACE_FLAGS, ); enum { @@ -110,6 +111,7 @@ typedef struct _NMDevicePrivate { char *physical_port_id; guint32 mtu; GPtrArray *lldp_neighbors; + guint32 interface_flags; } NMDevicePrivate; G_DEFINE_ABSTRACT_TYPE (NMDevice, nm_device, NM_TYPE_OBJECT); @@ -223,6 +225,7 @@ init_dbus (NMObject *object) { NM_DEVICE_MTU, &priv->mtu }, { NM_DEVICE_METERED, &priv->metered }, { NM_DEVICE_LLDP_NEIGHBORS, &priv->lldp_neighbors, demarshal_lldp_neighbors }, + { NM_DEVICE_INTERFACE_FLAGS, &priv->interface_flags }, /* Properties that exist in D-Bus but that we don't track */ { "ip4-address", NULL }, @@ -434,6 +437,9 @@ get_property (GObject *object, case PROP_IP6_CONNECTIVITY: g_value_set_enum (value, nm_device_get_connectivity (device, AF_INET6)); break; + case PROP_INTERFACE_FLAGS: + g_value_set_uint (value, nm_device_get_interface_flags (device)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -825,6 +831,19 @@ nm_device_class_init (NMDeviceClass *device_class) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + /** + * NMDevice:interface-flags: + * + * The interface flags. + * + * Since: 1.22 + **/ + obj_properties[PROP_INTERFACE_FLAGS] = + g_param_spec_uint (NM_DEVICE_INTERFACE_FLAGS, "", "", + 0, G_MAXUINT32, 0, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); /** @@ -1277,6 +1296,24 @@ nm_device_get_connectivity (NMDevice *device, int addr_family) } /** + * nm_device_get_interface_flags: + * @device: a #NMDevice + * + * Gets the interface flags of the device. + * + * Returns: the flags + * + * Since: 1.22 + **/ +NMDeviceInterfaceFlags +nm_device_get_interface_flags (NMDevice *device) +{ + g_return_val_if_fail (NM_IS_DEVICE (device), NM_DEVICE_INTERFACE_FLAG_NONE); + + return NM_DEVICE_GET_PRIVATE (device)->interface_flags; +} + +/** * nm_device_get_state: * @device: a #NMDevice * diff --git a/libnm/nm-device.h b/libnm/nm-device.h index bc8aad63df..78130c1bdf 100644 --- a/libnm/nm-device.h +++ b/libnm/nm-device.h @@ -54,6 +54,7 @@ _NM_DEPRECATED_SYNC_WRITABLE_PROPERTY #define NM_DEVICE_LLDP_NEIGHBORS "lldp-neighbors" #define NM_DEVICE_IP4_CONNECTIVITY "ip4-connectivity" #define NM_DEVICE_IP6_CONNECTIVITY "ip6-connectivity" +#define NM_DEVICE_INTERFACE_FLAGS "interface-flags" /** * NMDevice: @@ -113,6 +114,9 @@ NM_AVAILABLE_IN_1_2 NMMetered nm_device_get_metered (NMDevice *device); NM_AVAILABLE_IN_1_2 GPtrArray * nm_device_get_lldp_neighbors (NMDevice *device); +NM_AVAILABLE_IN_1_22 +NMDeviceInterfaceFlags nm_device_get_interface_flags (NMDevice *device); + char ** nm_device_disambiguate_names (NMDevice **devices, int num_devices); NM_AVAILABLE_IN_1_2 |