mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-09 04:48:10 +02:00
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.
This commit is contained in:
parent
b7300bbe5a
commit
47cc8b25f2
3 changed files with 58 additions and 0 deletions
|
|
@ -130,6 +130,7 @@ global:
|
||||||
nm_device_get_ip6_config;
|
nm_device_get_ip6_config;
|
||||||
nm_device_get_ip_iface;
|
nm_device_get_ip_iface;
|
||||||
nm_device_get_managed;
|
nm_device_get_managed;
|
||||||
|
nm_device_get_physical_port_id;
|
||||||
nm_device_get_product;
|
nm_device_get_product;
|
||||||
nm_device_get_state;
|
nm_device_get_state;
|
||||||
nm_device_get_state_reason;
|
nm_device_get_state_reason;
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,8 @@ typedef struct {
|
||||||
GUdevClient *client;
|
GUdevClient *client;
|
||||||
char *product;
|
char *product;
|
||||||
char *vendor;
|
char *vendor;
|
||||||
|
|
||||||
|
char *physical_port_id;
|
||||||
} NMDevicePrivate;
|
} NMDevicePrivate;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
|
@ -121,6 +123,7 @@ enum {
|
||||||
PROP_DEVICE_TYPE,
|
PROP_DEVICE_TYPE,
|
||||||
PROP_ACTIVE_CONNECTION,
|
PROP_ACTIVE_CONNECTION,
|
||||||
PROP_AVAILABLE_CONNECTIONS,
|
PROP_AVAILABLE_CONNECTIONS,
|
||||||
|
PROP_PHYSICAL_PORT_ID,
|
||||||
|
|
||||||
LAST_PROP
|
LAST_PROP
|
||||||
};
|
};
|
||||||
|
|
@ -199,6 +202,7 @@ register_properties (NMDevice *device)
|
||||||
{ NM_DEVICE_STATE_REASON, &priv->state, demarshal_state_reason },
|
{ NM_DEVICE_STATE_REASON, &priv->state, demarshal_state_reason },
|
||||||
{ NM_DEVICE_ACTIVE_CONNECTION, &priv->active_connection, NULL, NM_TYPE_ACTIVE_CONNECTION },
|
{ 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_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 */
|
/* Properties that exist in D-Bus but that we don't track */
|
||||||
{ "ip4-address", NULL },
|
{ "ip4-address", NULL },
|
||||||
|
|
@ -389,6 +393,7 @@ finalize (GObject *object)
|
||||||
g_free (priv->product);
|
g_free (priv->product);
|
||||||
g_free (priv->vendor);
|
g_free (priv->vendor);
|
||||||
g_free (priv->type_description);
|
g_free (priv->type_description);
|
||||||
|
g_free (priv->physical_port_id);
|
||||||
|
|
||||||
G_OBJECT_CLASS (nm_device_parent_class)->finalize (object);
|
G_OBJECT_CLASS (nm_device_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
@ -473,6 +478,9 @@ get_property (GObject *object,
|
||||||
case PROP_VENDOR:
|
case PROP_VENDOR:
|
||||||
g_value_set_string (value, nm_device_get_vendor (device));
|
g_value_set_string (value, nm_device_get_vendor (device));
|
||||||
break;
|
break;
|
||||||
|
case PROP_PHYSICAL_PORT_ID:
|
||||||
|
g_value_set_string (value, nm_device_get_physical_port_id (device));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
|
@ -804,6 +812,22 @@ nm_device_class_init (NMDeviceClass *device_class)
|
||||||
NULL,
|
NULL,
|
||||||
G_PARAM_READABLE));
|
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 */
|
/* signals */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1517,6 +1541,37 @@ nm_device_get_vendor (NMDevice *device)
|
||||||
return priv->vendor;
|
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 {
|
typedef struct {
|
||||||
NMDevice *device;
|
NMDevice *device;
|
||||||
NMDeviceDeactivateFn fn;
|
NMDeviceDeactivateFn fn;
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,7 @@ GQuark nm_device_error_quark (void);
|
||||||
#define NM_DEVICE_AVAILABLE_CONNECTIONS "available-connections"
|
#define NM_DEVICE_AVAILABLE_CONNECTIONS "available-connections"
|
||||||
#define NM_DEVICE_VENDOR "vendor"
|
#define NM_DEVICE_VENDOR "vendor"
|
||||||
#define NM_DEVICE_PRODUCT "product"
|
#define NM_DEVICE_PRODUCT "product"
|
||||||
|
#define NM_DEVICE_PHYSICAL_PORT_ID "physical-port-id"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
NMObject parent;
|
NMObject parent;
|
||||||
|
|
@ -135,6 +136,7 @@ NMActiveConnection * nm_device_get_active_connection(NMDevice *device);
|
||||||
const GPtrArray * nm_device_get_available_connections(NMDevice *device);
|
const GPtrArray * nm_device_get_available_connections(NMDevice *device);
|
||||||
const char * nm_device_get_product (NMDevice *device);
|
const char * nm_device_get_product (NMDevice *device);
|
||||||
const char * nm_device_get_vendor (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);
|
typedef void (*NMDeviceDeactivateFn) (NMDevice *device, GError *error, gpointer user_data);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue