summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2013-10-11 14:59:26 -0400
committerDan Winship <danw@gnome.org>2013-11-06 10:26:16 -0500
commit47cc8b25f2efe015defde7e76e49e67086603bb3 (patch)
treecf50a6e14d227e234661f484bf5a8d0d5748f03c
parentb7300bbe5a9f298ede02225b6b7e73e05aa78bc8 (diff)
downloadNetworkManager-47cc8b25f2efe015defde7e76e49e67086603bb3.tar.gz
libnm-glib: add NMDevice:physical-port-id property
Add the physical-port-id property to NMDevice so that clients can recognize NPAR/SR-IOV devices.
-rw-r--r--libnm-glib/libnm-glib.ver1
-rw-r--r--libnm-glib/nm-device.c55
-rw-r--r--libnm-glib/nm-device.h2
3 files changed, 58 insertions, 0 deletions
diff --git a/libnm-glib/libnm-glib.ver b/libnm-glib/libnm-glib.ver
index 4727bc3b9a..416b782c0a 100644
--- a/libnm-glib/libnm-glib.ver
+++ b/libnm-glib/libnm-glib.ver
@@ -130,6 +130,7 @@ global:
nm_device_get_ip6_config;
nm_device_get_ip_iface;
nm_device_get_managed;
+ nm_device_get_physical_port_id;
nm_device_get_product;
nm_device_get_state;
nm_device_get_state_reason;
diff --git a/libnm-glib/nm-device.c b/libnm-glib/nm-device.c
index 05e59e504e..d4f95ac3f9 100644
--- a/libnm-glib/nm-device.c
+++ b/libnm-glib/nm-device.c
@@ -96,6 +96,8 @@ typedef struct {
GUdevClient *client;
char *product;
char *vendor;
+
+ char *physical_port_id;
} NMDevicePrivate;
enum {
@@ -121,6 +123,7 @@ enum {
PROP_DEVICE_TYPE,
PROP_ACTIVE_CONNECTION,
PROP_AVAILABLE_CONNECTIONS,
+ PROP_PHYSICAL_PORT_ID,
LAST_PROP
};
@@ -199,6 +202,7 @@ register_properties (NMDevice *device)
{ NM_DEVICE_STATE_REASON, &priv->state, demarshal_state_reason },
{ NM_DEVICE_ACTIVE_CONNECTION, &priv->active_connection, NULL, NM_TYPE_ACTIVE_CONNECTION },
{ NM_DEVICE_AVAILABLE_CONNECTIONS, &priv->available_connections, NULL, NM_TYPE_REMOTE_CONNECTION },
+ { NM_DEVICE_PHYSICAL_PORT_ID, &priv->physical_port_id },
/* Properties that exist in D-Bus but that we don't track */
{ "ip4-address", NULL },
@@ -389,6 +393,7 @@ finalize (GObject *object)
g_free (priv->product);
g_free (priv->vendor);
g_free (priv->type_description);
+ g_free (priv->physical_port_id);
G_OBJECT_CLASS (nm_device_parent_class)->finalize (object);
}
@@ -473,6 +478,9 @@ get_property (GObject *object,
case PROP_VENDOR:
g_value_set_string (value, nm_device_get_vendor (device));
break;
+ case PROP_PHYSICAL_PORT_ID:
+ g_value_set_string (value, nm_device_get_physical_port_id (device));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -804,6 +812,22 @@ nm_device_class_init (NMDeviceClass *device_class)
NULL,
G_PARAM_READABLE));
+ /**
+ * NMDevice:physical-port-id:
+ *
+ * The physical port ID of the device. (See
+ * nm_device_get_physical_port_id().)
+ *
+ * Since: 0.9.10
+ **/
+ g_object_class_install_property
+ (object_class, PROP_PHYSICAL_PORT_ID,
+ g_param_spec_string (NM_DEVICE_PHYSICAL_PORT_ID,
+ "Physical Port ID",
+ "Physical port ID",
+ NULL,
+ G_PARAM_READABLE));
+
/* signals */
/**
@@ -1517,6 +1541,37 @@ nm_device_get_vendor (NMDevice *device)
return priv->vendor;
}
+/**
+ * nm_device_get_physical_port_id:
+ * @device: a #NMDevice
+ *
+ * Gets the physical port ID of the #NMDevice. If non-%NULL, this is
+ * an opaque string that can be used to recognize when
+ * seemingly-unrelated #NMDevices are actually just different virtual
+ * ports on a single physical port. (Eg, NPAR / SR-IOV.)
+ *
+ * Returns: the physical port ID of the device, or %NULL if the port
+ * ID is unknown. This is the internal string used by the device and
+ * must not be modified.
+ *
+ * Since: 0.9.10
+ **/
+const char *
+nm_device_get_physical_port_id (NMDevice *device)
+{
+ NMDevicePrivate *priv;
+
+ g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
+
+ priv = NM_DEVICE_GET_PRIVATE (device);
+
+ _nm_object_ensure_inited (NM_OBJECT (device));
+ if (priv->physical_port_id && *priv->physical_port_id)
+ return priv->physical_port_id;
+ else
+ return NULL;
+}
+
typedef struct {
NMDevice *device;
NMDeviceDeactivateFn fn;
diff --git a/libnm-glib/nm-device.h b/libnm-glib/nm-device.h
index ed274caa11..bd746b3b74 100644
--- a/libnm-glib/nm-device.h
+++ b/libnm-glib/nm-device.h
@@ -80,6 +80,7 @@ GQuark nm_device_error_quark (void);
#define NM_DEVICE_AVAILABLE_CONNECTIONS "available-connections"
#define NM_DEVICE_VENDOR "vendor"
#define NM_DEVICE_PRODUCT "product"
+#define NM_DEVICE_PHYSICAL_PORT_ID "physical-port-id"
typedef struct {
NMObject parent;
@@ -135,6 +136,7 @@ NMActiveConnection * nm_device_get_active_connection(NMDevice *device);
const GPtrArray * nm_device_get_available_connections(NMDevice *device);
const char * nm_device_get_product (NMDevice *device);
const char * nm_device_get_vendor (NMDevice *device);
+const char * nm_device_get_physical_port_id (NMDevice *device);
typedef void (*NMDeviceDeactivateFn) (NMDevice *device, GError *error, gpointer user_data);