mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-10 07:00:21 +01:00
Merge: add MTU property, change 'nmcli dev show' default format (rh #998003)
This commit is contained in:
commit
6b3c209d9a
18 changed files with 255 additions and 72 deletions
|
|
@ -92,18 +92,21 @@ static NmcOutputField nmc_fields_dev_show_general[] = {
|
|||
{"DRIVER-VERSION", N_("DRIVER-VERSION"), 18}, /* 6 */
|
||||
{"FIRMWARE-VERSION", N_("FIRMWARE-VERSION"), 18}, /* 7 */
|
||||
{"HWADDR", N_("HWADDR"), 19}, /* 8 */
|
||||
{"STATE", N_("STATE"), 14}, /* 9 */
|
||||
{"REASON", N_("REASON"), 25}, /* 10 */
|
||||
{"UDI", N_("UDI"), 64}, /* 11 */
|
||||
{"IP-IFACE", N_("IP-IFACE"), 10}, /* 12 */
|
||||
{"NM-MANAGED", N_("NM-MANAGED"), 15}, /* 13 */
|
||||
{"AUTOCONNECT", N_("AUTOCONNECT"), 15}, /* 14 */
|
||||
{"FIRMWARE-MISSING", N_("FIRMWARE-MISSING"), 18}, /* 15 */
|
||||
{"CONNECTION", N_("CONNECTION"), 51}, /* 16 */
|
||||
{"MTU", N_("MTU"), 10}, /* 9 */
|
||||
{"STATE", N_("STATE"), 14}, /* 10 */
|
||||
{"REASON", N_("REASON"), 25}, /* 11 */
|
||||
{"UDI", N_("UDI"), 64}, /* 12 */
|
||||
{"IP-IFACE", N_("IP-IFACE"), 10}, /* 13 */
|
||||
{"NM-MANAGED", N_("NM-MANAGED"), 15}, /* 14 */
|
||||
{"AUTOCONNECT", N_("AUTOCONNECT"), 15}, /* 15 */
|
||||
{"FIRMWARE-MISSING", N_("FIRMWARE-MISSING"), 18}, /* 16 */
|
||||
{"CONNECTION", N_("CONNECTION"), 20}, /* 17 */
|
||||
{"CON-UUID", N_("CON-UUID"), 38}, /* 18 */
|
||||
{"CON-PATH", N_("CON-PATH"), 51}, /* 19 */
|
||||
{NULL, NULL, 0}
|
||||
};
|
||||
#define NMC_FIELDS_DEV_SHOW_GENERAL_ALL "NAME,DEVICE,TYPE,VENDOR,PRODUCT,DRIVER,DRIVER-VERSION,FIRMWARE-VERSION,HWADDR,STATE,REASON,UDI,IP-IFACE,"\
|
||||
"NM-MANAGED,AUTOCONNECT,FIRMWARE-MISSING,CONNECTION"
|
||||
#define NMC_FIELDS_DEV_SHOW_GENERAL_ALL "NAME,DEVICE,TYPE,VENDOR,PRODUCT,DRIVER,DRIVER-VERSION,FIRMWARE-VERSION,HWADDR,MTU,STATE,REASON,"\
|
||||
"UDI,IP-IFACE,NM-MANAGED,AUTOCONNECT,FIRMWARE-MISSING,CONNECTION,CON-UUID,CON-PATH"
|
||||
#define NMC_FIELDS_DEV_SHOW_GENERAL_COMMON "NAME,DEVICE,TYPE,VENDOR,PRODUCT,DRIVER,HWADDR,STATE"
|
||||
|
||||
/* Available fields for 'device show' - CONNECTIONS part */
|
||||
|
|
@ -247,11 +250,15 @@ static NmcOutputField nmc_fields_dev_show_sections[] = {
|
|||
{NULL, NULL, 0, NULL }
|
||||
};
|
||||
#if WITH_WIMAX
|
||||
#define NMC_FIELDS_DEV_SHOW_SECTIONS_ALL "GENERAL,CAPABILITIES,BOND,VLAN,CONNECTIONS,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6"
|
||||
#define NMC_FIELDS_DEV_SHOW_SECTIONS_COMMON "GENERAL,CAPABILITIES,BOND,VLAN,CONNECTIONS,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6"
|
||||
#define NMC_FIELDS_DEV_SHOW_SECTIONS_ALL "GENERAL,CAPABILITIES,BOND,VLAN,CONNECTIONS,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,"\
|
||||
"WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6"
|
||||
#define NMC_FIELDS_DEV_SHOW_SECTIONS_COMMON "GENERAL.DEVICE,GENERAL.TYPE,GENERAL.HWADDR,GENERAL.MTU,GENERAL.STATE,"\
|
||||
"GENERAL.CONNECTION,GENERAL.CON-PATH,WIRED-PROPERTIES,IP4,IP6"
|
||||
#else
|
||||
#define NMC_FIELDS_DEV_SHOW_SECTIONS_ALL "GENERAL,CAPABILITIES,BOND,VLAN,CONNECTIONS,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,IP4,DHCP4,IP6,DHCP6"
|
||||
#define NMC_FIELDS_DEV_SHOW_SECTIONS_COMMON "GENERAL,CAPABILITIES,BOND,VLAN,CONNECTIONS,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,IP4,DHCP4,IP6,DHCP6"
|
||||
#define NMC_FIELDS_DEV_SHOW_SECTIONS_ALL "GENERAL,CAPABILITIES,BOND,VLAN,CONNECTIONS,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,"\
|
||||
"IP4,DHCP4,IP6,DHCP6"
|
||||
#define NMC_FIELDS_DEV_SHOW_SECTIONS_COMMON "GENERAL.DEVICE,GENERAL.TYPE,GENERAL.HWADDR,GENERAL.MTU,GENERAL.STATE,"\
|
||||
"GENERAL.CONNECTION,GENERAL.CON-PATH,WIRED-PROPERTIES,IP4,IP6"
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -564,6 +571,30 @@ construct_header_name (const char *base, const char *spec)
|
|||
return header_name;
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_active_connection_id (NMDevice *device)
|
||||
{
|
||||
const GPtrArray *avail_cons;
|
||||
NMActiveConnection *ac;
|
||||
const char *ac_uuid;
|
||||
int i;
|
||||
|
||||
ac = nm_device_get_active_connection (device);
|
||||
if (!ac)
|
||||
return NULL;
|
||||
ac_uuid = nm_active_connection_get_uuid (ac);
|
||||
|
||||
avail_cons = nm_device_get_available_connections (device);
|
||||
for (i = 0; avail_cons && (i < avail_cons->len); i++) {
|
||||
NMRemoteConnection *candidate = g_ptr_array_index (avail_cons, i);
|
||||
const char *test_uuid = nm_connection_get_uuid (NM_CONNECTION (candidate));
|
||||
|
||||
if (g_strcmp0 (ac_uuid, test_uuid) == 0)
|
||||
return nm_connection_get_id (NM_CONNECTION (candidate));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
show_device_info (NMDevice *device, NmCli *nmc)
|
||||
{
|
||||
|
|
@ -575,9 +606,7 @@ show_device_info (NMDevice *device, NmCli *nmc)
|
|||
NMDeviceCapabilities caps;
|
||||
NMActiveConnection *acon;
|
||||
guint32 speed;
|
||||
char *speed_str = NULL;
|
||||
char *state_str = NULL;
|
||||
char *reason_str = NULL;
|
||||
char *speed_str, *state_str, *reason_str, *mtu_str;
|
||||
GArray *sections_array;
|
||||
int k;
|
||||
char *fields_str;
|
||||
|
|
@ -640,25 +669,11 @@ show_device_info (NMDevice *device, NmCli *nmc)
|
|||
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
|
||||
g_ptr_array_add (nmc->output_data, arr);
|
||||
|
||||
if (NM_IS_DEVICE_ETHERNET (device))
|
||||
hwaddr = nm_device_ethernet_get_hw_address (NM_DEVICE_ETHERNET (device));
|
||||
else if (NM_IS_DEVICE_WIFI (device))
|
||||
hwaddr = nm_device_wifi_get_hw_address (NM_DEVICE_WIFI (device));
|
||||
#if WITH_WIMAX
|
||||
else if (NM_IS_DEVICE_WIMAX (device))
|
||||
hwaddr = nm_device_wimax_get_hw_address (NM_DEVICE_WIMAX (device));
|
||||
#endif
|
||||
else if (NM_IS_DEVICE_INFINIBAND (device))
|
||||
hwaddr = nm_device_infiniband_get_hw_address (NM_DEVICE_INFINIBAND (device));
|
||||
else if (NM_IS_DEVICE_BOND (device))
|
||||
hwaddr = nm_device_bond_get_hw_address (NM_DEVICE_BOND (device));
|
||||
else if (NM_IS_DEVICE_VLAN (device))
|
||||
hwaddr = nm_device_vlan_get_hw_address (NM_DEVICE_VLAN (device));
|
||||
else if (NM_IS_DEVICE_BRIDGE (device))
|
||||
hwaddr = nm_device_bridge_get_hw_address (NM_DEVICE_BRIDGE (device));
|
||||
|
||||
state_str = g_strdup_printf ("%d (%s)", state, nmc_device_state_to_string (state));
|
||||
reason_str = g_strdup_printf ("%d (%s)", reason, nmc_device_reason_to_string (reason));
|
||||
hwaddr = nm_device_get_hw_address (device);
|
||||
mtu_str = g_strdup_printf ("%u", nm_device_get_mtu (device));
|
||||
acon = nm_device_get_active_connection (device);
|
||||
|
||||
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
|
||||
set_val_strc (arr, 0, nmc_fields_dev_show_sections[0].name); /* "GENERAL"*/
|
||||
|
|
@ -670,15 +685,17 @@ show_device_info (NMDevice *device, NmCli *nmc)
|
|||
set_val_strc (arr, 6, nm_device_get_driver_version (device));
|
||||
set_val_strc (arr, 7, nm_device_get_firmware_version (device));
|
||||
set_val_strc (arr, 8, hwaddr ? hwaddr : _("(unknown)"));
|
||||
set_val_str (arr, 9, state_str);
|
||||
set_val_str (arr, 10, reason_str);
|
||||
set_val_strc (arr, 11, nm_device_get_udi (device));
|
||||
set_val_strc (arr, 12, nm_device_get_ip_iface (device));
|
||||
set_val_strc (arr, 13, nm_device_get_managed (device) ? _("yes") : _("no"));
|
||||
set_val_strc (arr, 14, nm_device_get_autoconnect (device) ? _("yes") : _("no"));
|
||||
set_val_strc (arr, 15, nm_device_get_firmware_missing (device) ? _("yes") : _("no"));
|
||||
set_val_strc (arr, 16, ((acon = nm_device_get_active_connection (device)) ?
|
||||
nm_object_get_path (NM_OBJECT (acon)) : _("not connected")));
|
||||
set_val_str (arr, 9, mtu_str);
|
||||
set_val_str (arr, 10, state_str);
|
||||
set_val_str (arr, 11, reason_str);
|
||||
set_val_strc (arr, 12, nm_device_get_udi (device));
|
||||
set_val_strc (arr, 13, nm_device_get_ip_iface (device));
|
||||
set_val_strc (arr, 14, nm_device_get_managed (device) ? _("yes") : _("no"));
|
||||
set_val_strc (arr, 15, nm_device_get_autoconnect (device) ? _("yes") : _("no"));
|
||||
set_val_strc (arr, 16, nm_device_get_firmware_missing (device) ? _("yes") : _("no"));
|
||||
set_val_strc (arr, 17, get_active_connection_id (device));
|
||||
set_val_strc (arr, 18, acon ? nm_active_connection_get_uuid (acon) : NULL);
|
||||
set_val_strc (arr, 19, acon ? nm_object_get_path (NM_OBJECT (acon)) : NULL);
|
||||
g_ptr_array_add (nmc->output_data, arr);
|
||||
|
||||
print_data (nmc); /* Print all data */
|
||||
|
|
@ -1012,30 +1029,6 @@ show_device_info (NMDevice *device, NmCli *nmc)
|
|||
g_ptr_array_free (fields_in_section, TRUE);
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_active_connection_id (NMDevice *device)
|
||||
{
|
||||
const GPtrArray *avail_cons;
|
||||
NMActiveConnection *ac;
|
||||
const char *ac_uuid;
|
||||
int i;
|
||||
|
||||
ac = nm_device_get_active_connection (device);
|
||||
if (!ac)
|
||||
return NULL;
|
||||
ac_uuid = nm_active_connection_get_uuid (ac);
|
||||
|
||||
avail_cons = nm_device_get_available_connections (device);
|
||||
for (i = 0; avail_cons && (i < avail_cons->len); i++) {
|
||||
NMRemoteConnection *candidate = g_ptr_array_index (avail_cons, i);
|
||||
const char *test_uuid = nm_connection_get_uuid (NM_CONNECTION (candidate));
|
||||
|
||||
if (g_strcmp0 (ac_uuid, test_uuid) == 0)
|
||||
return nm_connection_get_id (NM_CONNECTION (candidate));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
fill_output_device_status (NMDevice *device, NmCli *nmc)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -133,6 +133,11 @@
|
|||
different virtual interfaces to the same physical port.
|
||||
</tp:docstring>
|
||||
</property>
|
||||
<property name="Mtu" type="u" access="read">
|
||||
<tp:docstring>
|
||||
The device MTU (maximum transmission unit).
|
||||
</tp:docstring>
|
||||
</property>
|
||||
|
||||
<method name="Disconnect">
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_device_disconnect"/>
|
||||
|
|
|
|||
|
|
@ -129,11 +129,13 @@ global:
|
|||
nm_device_get_driver_version;
|
||||
nm_device_get_firmware_missing;
|
||||
nm_device_get_firmware_version;
|
||||
nm_device_get_hw_address;
|
||||
nm_device_get_iface;
|
||||
nm_device_get_ip4_config;
|
||||
nm_device_get_ip6_config;
|
||||
nm_device_get_ip_iface;
|
||||
nm_device_get_managed;
|
||||
nm_device_get_mtu;
|
||||
nm_device_get_physical_port_id;
|
||||
nm_device_get_product;
|
||||
nm_device_get_state;
|
||||
|
|
|
|||
|
|
@ -195,6 +195,12 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
|||
return NM_DEVICE_CLASS (nm_device_bond_parent_class)->connection_compatible (device, connection, error);
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_hw_address (NMDevice *device)
|
||||
{
|
||||
return nm_device_bond_get_hw_address (NM_DEVICE_BOND (device));
|
||||
}
|
||||
|
||||
/***********************************************************/
|
||||
|
||||
static void
|
||||
|
|
@ -296,6 +302,7 @@ nm_device_bond_class_init (NMDeviceBondClass *eth_class)
|
|||
object_class->finalize = finalize;
|
||||
object_class->get_property = get_property;
|
||||
device_class->connection_compatible = connection_compatible;
|
||||
device_class->get_hw_address = get_hw_address;
|
||||
|
||||
/* properties */
|
||||
|
||||
|
|
|
|||
|
|
@ -203,6 +203,12 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
|||
return NM_DEVICE_CLASS (nm_device_bridge_parent_class)->connection_compatible (device, connection, error);
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_hw_address (NMDevice *device)
|
||||
{
|
||||
return nm_device_bridge_get_hw_address (NM_DEVICE_BRIDGE (device));
|
||||
}
|
||||
|
||||
/***********************************************************/
|
||||
|
||||
static void
|
||||
|
|
@ -304,6 +310,7 @@ nm_device_bridge_class_init (NMDeviceBridgeClass *bridge_class)
|
|||
object_class->finalize = finalize;
|
||||
object_class->get_property = get_property;
|
||||
device_class->connection_compatible = connection_compatible;
|
||||
device_class->get_hw_address = get_hw_address;
|
||||
|
||||
/* properties */
|
||||
|
||||
|
|
|
|||
|
|
@ -227,6 +227,12 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
|||
return NM_DEVICE_CLASS (nm_device_bt_parent_class)->connection_compatible (device, connection, error);
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_hw_address (NMDevice *device)
|
||||
{
|
||||
return nm_device_bt_get_hw_address (NM_DEVICE_BT (device));
|
||||
}
|
||||
|
||||
/************************************************************/
|
||||
|
||||
static void
|
||||
|
|
@ -323,6 +329,7 @@ nm_device_bt_class_init (NMDeviceBtClass *bt_class)
|
|||
object_class->finalize = finalize;
|
||||
object_class->get_property = get_property;
|
||||
device_class->connection_compatible = connection_compatible;
|
||||
device_class->get_hw_address = get_hw_address;
|
||||
|
||||
/* properties */
|
||||
|
||||
|
|
|
|||
|
|
@ -231,6 +231,12 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
|||
return NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->connection_compatible (device, connection, error);
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_hw_address (NMDevice *device)
|
||||
{
|
||||
return nm_device_ethernet_get_hw_address (NM_DEVICE_ETHERNET (device));
|
||||
}
|
||||
|
||||
/***********************************************************/
|
||||
|
||||
static void
|
||||
|
|
@ -331,6 +337,7 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *eth_class)
|
|||
object_class->finalize = finalize;
|
||||
object_class->get_property = get_property;
|
||||
device_class->connection_compatible = connection_compatible;
|
||||
device_class->get_hw_address = get_hw_address;
|
||||
|
||||
/* properties */
|
||||
|
||||
|
|
|
|||
|
|
@ -128,6 +128,12 @@ get_type_description (NMDevice *device)
|
|||
return priv->type_description;
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_hw_address (NMDevice *device)
|
||||
{
|
||||
return nm_device_generic_get_hw_address (NM_DEVICE_GENERIC (device));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
|
||||
{
|
||||
|
|
@ -246,6 +252,7 @@ nm_device_generic_class_init (NMDeviceGenericClass *klass)
|
|||
object_class->get_property = get_property;
|
||||
|
||||
device_class->get_type_description = get_type_description;
|
||||
device_class->get_hw_address = get_hw_address;
|
||||
device_class->connection_compatible = connection_compatible;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -181,6 +181,12 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
|||
return NM_DEVICE_CLASS (nm_device_infiniband_parent_class)->connection_compatible (device, connection, error);
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_hw_address (NMDevice *device)
|
||||
{
|
||||
return nm_device_infiniband_get_hw_address (NM_DEVICE_INFINIBAND (device));
|
||||
}
|
||||
|
||||
/***********************************************************/
|
||||
|
||||
static void
|
||||
|
|
@ -272,6 +278,7 @@ nm_device_infiniband_class_init (NMDeviceInfinibandClass *eth_class)
|
|||
object_class->finalize = finalize;
|
||||
object_class->get_property = get_property;
|
||||
device_class->connection_compatible = connection_compatible;
|
||||
device_class->get_hw_address = get_hw_address;
|
||||
|
||||
/* properties */
|
||||
|
||||
|
|
|
|||
|
|
@ -154,6 +154,12 @@ nm_device_olpc_mesh_get_active_channel (NMDeviceOlpcMesh *device)
|
|||
return NM_DEVICE_OLPC_MESH_GET_PRIVATE (device)->active_channel;
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_hw_address (NMDevice *device)
|
||||
{
|
||||
return nm_device_olpc_mesh_get_hw_address (NM_DEVICE_OLPC_MESH (device));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
|
||||
{
|
||||
|
|
@ -277,6 +283,7 @@ nm_device_olpc_mesh_class_init (NMDeviceOlpcMeshClass *olpc_mesh_class)
|
|||
object_class->finalize = finalize;
|
||||
object_class->get_property = get_property;
|
||||
device_class->connection_compatible = connection_compatible;
|
||||
device_class->get_hw_address = get_hw_address;
|
||||
|
||||
/* properties */
|
||||
|
||||
|
|
|
|||
|
|
@ -154,6 +154,12 @@ nm_device_team_get_slaves (NMDeviceTeam *device)
|
|||
return handle_ptr_array_return (NM_DEVICE_TEAM_GET_PRIVATE (device)->slaves);
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_hw_address (NMDevice *device)
|
||||
{
|
||||
return nm_device_team_get_hw_address (NM_DEVICE_TEAM (device));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
|
||||
{
|
||||
|
|
@ -292,6 +298,7 @@ nm_device_team_class_init (NMDeviceTeamClass *eth_class)
|
|||
object_class->finalize = finalize;
|
||||
object_class->get_property = get_property;
|
||||
device_class->connection_compatible = connection_compatible;
|
||||
device_class->get_hw_address = get_hw_address;
|
||||
|
||||
/* properties */
|
||||
|
||||
|
|
|
|||
|
|
@ -210,6 +210,12 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
|||
return NM_DEVICE_CLASS (nm_device_vlan_parent_class)->connection_compatible (device, connection, error);
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_hw_address (NMDevice *device)
|
||||
{
|
||||
return nm_device_vlan_get_hw_address (NM_DEVICE_VLAN (device));
|
||||
}
|
||||
|
||||
/***********************************************************/
|
||||
|
||||
static void
|
||||
|
|
@ -305,6 +311,7 @@ nm_device_vlan_class_init (NMDeviceVlanClass *eth_class)
|
|||
object_class->finalize = finalize;
|
||||
object_class->get_property = get_property;
|
||||
device_class->connection_compatible = connection_compatible;
|
||||
device_class->get_hw_address = get_hw_address;
|
||||
|
||||
/* properties */
|
||||
|
||||
|
|
|
|||
|
|
@ -555,6 +555,12 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
|||
return NM_DEVICE_CLASS (nm_device_wifi_parent_class)->connection_compatible (device, connection, error);
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_hw_address (NMDevice *device)
|
||||
{
|
||||
return nm_device_wifi_get_hw_address (NM_DEVICE_WIFI (device));
|
||||
}
|
||||
|
||||
/**************************************************************/
|
||||
|
||||
static void
|
||||
|
|
@ -719,6 +725,7 @@ nm_device_wifi_class_init (NMDeviceWifiClass *wifi_class)
|
|||
object_class->dispose = dispose;
|
||||
object_class->finalize = finalize;
|
||||
device_class->connection_compatible = connection_compatible;
|
||||
device_class->get_hw_address = get_hw_address;
|
||||
|
||||
/* properties */
|
||||
|
||||
|
|
|
|||
|
|
@ -427,6 +427,12 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
|||
return NM_DEVICE_CLASS (nm_device_wimax_parent_class)->connection_compatible (device, connection, error);
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_hw_address (NMDevice *device)
|
||||
{
|
||||
return nm_device_wimax_get_hw_address (NM_DEVICE_WIMAX (device));
|
||||
}
|
||||
|
||||
/**************************************************************/
|
||||
|
||||
static void
|
||||
|
|
@ -615,6 +621,7 @@ nm_device_wimax_class_init (NMDeviceWimaxClass *wimax_class)
|
|||
object_class->get_property = get_property;
|
||||
object_class->dispose = dispose;
|
||||
device_class->connection_compatible = connection_compatible;
|
||||
device_class->get_hw_address = get_hw_address;
|
||||
|
||||
/* properties */
|
||||
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ typedef struct {
|
|||
char *vendor;
|
||||
|
||||
char *physical_port_id;
|
||||
guint32 mtu;
|
||||
} NMDevicePrivate;
|
||||
|
||||
enum {
|
||||
|
|
@ -124,6 +125,7 @@ enum {
|
|||
PROP_ACTIVE_CONNECTION,
|
||||
PROP_AVAILABLE_CONNECTIONS,
|
||||
PROP_PHYSICAL_PORT_ID,
|
||||
PROP_MTU,
|
||||
|
||||
LAST_PROP
|
||||
};
|
||||
|
|
@ -203,6 +205,7 @@ register_properties (NMDevice *device)
|
|||
{ 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 },
|
||||
{ NM_DEVICE_MTU, &priv->mtu },
|
||||
|
||||
/* Properties that exist in D-Bus but that we don't track */
|
||||
{ "ip4-address", NULL },
|
||||
|
|
@ -481,6 +484,9 @@ get_property (GObject *object,
|
|||
case PROP_PHYSICAL_PORT_ID:
|
||||
g_value_set_string (value, nm_device_get_physical_port_id (device));
|
||||
break;
|
||||
case PROP_MTU:
|
||||
g_value_set_uint (value, nm_device_get_mtu (device));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
@ -828,6 +834,21 @@ nm_device_class_init (NMDeviceClass *device_class)
|
|||
NULL,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
/**
|
||||
* NMDevice:mtu:
|
||||
*
|
||||
* The MTU of the device.
|
||||
*
|
||||
* Since: 0.9.10
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_MTU,
|
||||
g_param_spec_uint (NM_DEVICE_MTU,
|
||||
"MTU",
|
||||
"MTU",
|
||||
0, G_MAXUINT32, 1500,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
/* signals */
|
||||
|
||||
/**
|
||||
|
|
@ -1151,6 +1172,28 @@ nm_device_get_type_description (NMDevice *device)
|
|||
return priv->type_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_device_get_hw_address:
|
||||
* @device: a #NMDevice
|
||||
*
|
||||
* Gets the current a hardware address (MAC) for the @device.
|
||||
*
|
||||
* Returns: the current MAC of the device, or %NULL.
|
||||
* This is the internal string used by the device, and must not be modified.
|
||||
*
|
||||
* Since: 0.9.10
|
||||
**/
|
||||
const char *
|
||||
nm_device_get_hw_address (NMDevice *device)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
|
||||
|
||||
if (NM_DEVICE_GET_CLASS (device)->get_hw_address)
|
||||
return NM_DEVICE_GET_CLASS (device)->get_hw_address (device);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_device_get_capabilities:
|
||||
* @device: a #NMDevice
|
||||
|
|
@ -1588,6 +1631,25 @@ nm_device_get_physical_port_id (NMDevice *device)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_device_get_mtu:
|
||||
* @device: a #NMDevice
|
||||
*
|
||||
* Gets the MTU of the #NMDevice.
|
||||
*
|
||||
* Returns: the MTU of the device.
|
||||
*
|
||||
* Since: 0.9.10
|
||||
**/
|
||||
guint32
|
||||
nm_device_get_mtu (NMDevice *device)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_DEVICE (device), 0);
|
||||
|
||||
_nm_object_ensure_inited (NM_OBJECT (device));
|
||||
return NM_DEVICE_GET_PRIVATE (device)->mtu;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
NMDevice *device;
|
||||
NMDeviceDeactivateFn fn;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2007 - 2008 Novell, Inc.
|
||||
* Copyright (C) 2007 - 2012 Red Hat, Inc.
|
||||
* Copyright (C) 2007 - 2013 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef NM_DEVICE_H
|
||||
|
|
@ -81,6 +81,7 @@ GQuark nm_device_error_quark (void);
|
|||
#define NM_DEVICE_VENDOR "vendor"
|
||||
#define NM_DEVICE_PRODUCT "product"
|
||||
#define NM_DEVICE_PHYSICAL_PORT_ID "physical-port-id"
|
||||
#define NM_DEVICE_MTU "mtu"
|
||||
|
||||
typedef struct {
|
||||
NMObject parent;
|
||||
|
|
@ -100,13 +101,13 @@ typedef struct {
|
|||
GError **error);
|
||||
|
||||
const char * (*get_type_description) (NMDevice *device);
|
||||
const char * (*get_hw_address) (NMDevice *device);
|
||||
|
||||
/* Padding for future expansion */
|
||||
void (*_reserved1) (void);
|
||||
void (*_reserved2) (void);
|
||||
void (*_reserved3) (void);
|
||||
void (*_reserved4) (void);
|
||||
void (*_reserved5) (void);
|
||||
} NMDeviceClass;
|
||||
|
||||
GType nm_device_get_type (void);
|
||||
|
|
@ -121,6 +122,7 @@ const char * nm_device_get_driver (NMDevice *device);
|
|||
const char * nm_device_get_driver_version (NMDevice *device);
|
||||
const char * nm_device_get_firmware_version (NMDevice *device);
|
||||
const char * nm_device_get_type_description (NMDevice *device);
|
||||
const char * nm_device_get_hw_address (NMDevice *device);
|
||||
NMDeviceCapabilities nm_device_get_capabilities (NMDevice *device);
|
||||
gboolean nm_device_get_managed (NMDevice *device);
|
||||
gboolean nm_device_get_autoconnect (NMDevice *device);
|
||||
|
|
@ -137,6 +139,7 @@ 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);
|
||||
guint32 nm_device_get_mtu (NMDevice *device);
|
||||
|
||||
typedef void (*NMDeviceDeactivateFn) (NMDevice *device, GError *error, gpointer user_data);
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2005 - 2012 Red Hat, Inc.
|
||||
* Copyright (C) 2005 - 2013 Red Hat, Inc.
|
||||
* Copyright (C) 2006 - 2008 Novell, Inc.
|
||||
*/
|
||||
|
||||
|
|
@ -117,6 +117,7 @@ enum {
|
|||
PROP_FIRMWARE_VERSION,
|
||||
PROP_CAPABILITIES,
|
||||
PROP_CARRIER,
|
||||
PROP_MTU,
|
||||
PROP_IP4_ADDRESS,
|
||||
PROP_IP4_CONFIG,
|
||||
PROP_DHCP4_CONFIG,
|
||||
|
|
@ -230,6 +231,7 @@ typedef struct {
|
|||
gboolean carrier;
|
||||
guint carrier_wait_id;
|
||||
gboolean ignore_carrier;
|
||||
guint32 mtu;
|
||||
|
||||
/* Generic DHCP stuff */
|
||||
NMDHCPManager * dhcp_manager;
|
||||
|
|
@ -616,6 +618,9 @@ constructed (GObject *object)
|
|||
priv->physical_port_id = nm_platform_link_get_physical_port_id (priv->ifindex);
|
||||
}
|
||||
|
||||
if (priv->ifindex > 0)
|
||||
priv->mtu = nm_platform_link_get_mtu (priv->ifindex);
|
||||
|
||||
if (G_OBJECT_CLASS (nm_device_parent_class)->constructed)
|
||||
G_OBJECT_CLASS (nm_device_parent_class)->constructed (object);
|
||||
}
|
||||
|
|
@ -1199,6 +1204,12 @@ link_changed_cb (NMPlatform *platform, int ifindex, NMPlatformLink *info, NMPlat
|
|||
g_object_notify (G_OBJECT (device), NM_DEVICE_UDI);
|
||||
}
|
||||
|
||||
/* Update MTU if it has changed. */
|
||||
if (priv->mtu != info->mtu) {
|
||||
priv->mtu = info->mtu;
|
||||
g_object_notify (G_OBJECT (device), NM_DEVICE_MTU);
|
||||
}
|
||||
|
||||
if (klass->link_changed)
|
||||
klass->link_changed (device, info);
|
||||
}
|
||||
|
|
@ -5393,7 +5404,7 @@ finalize (GObject *object)
|
|||
|
||||
static void
|
||||
set_property (GObject *object, guint prop_id,
|
||||
const GValue *value, GParamSpec *pspec)
|
||||
const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (object);
|
||||
NMPlatformLink *platform_device;
|
||||
|
|
@ -5449,6 +5460,9 @@ set_property (GObject *object, guint prop_id,
|
|||
g_free (priv->firmware_version);
|
||||
priv->firmware_version = g_strdup (g_value_get_string (value));
|
||||
break;
|
||||
case PROP_MTU:
|
||||
priv->mtu = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_IP4_ADDRESS:
|
||||
priv->ip4_address = g_value_get_uint (value);
|
||||
break;
|
||||
|
|
@ -5547,6 +5561,9 @@ get_property (GObject *object, guint prop_id,
|
|||
case PROP_CARRIER:
|
||||
g_value_set_boolean (value, priv->carrier);
|
||||
break;
|
||||
case PROP_MTU:
|
||||
g_value_set_uint (value, priv->mtu);
|
||||
break;
|
||||
case PROP_IP4_CONFIG:
|
||||
if (ip_config_valid (priv->state) && priv->ip4_config)
|
||||
g_value_set_boxed (value, nm_ip4_config_get_dbus_path (priv->ip4_config));
|
||||
|
|
@ -5741,6 +5758,14 @@ nm_device_class_init (NMDeviceClass *klass)
|
|||
FALSE,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_MTU,
|
||||
g_param_spec_uint (NM_DEVICE_MTU,
|
||||
"MTU",
|
||||
"MTU",
|
||||
0, G_MAXUINT32, 1500,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_IP4_ADDRESS,
|
||||
g_param_spec_uint (NM_DEVICE_IP4_ADDRESS,
|
||||
|
|
@ -7244,3 +7269,16 @@ nm_device_get_physical_port_id (NMDevice *device)
|
|||
|
||||
return priv->physical_port_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_device_get_mtu:
|
||||
* @device: the #NMDevice
|
||||
*
|
||||
* Returns: MTU of the #NMDevice
|
||||
*/
|
||||
guint32
|
||||
nm_device_get_mtu (NMDevice *device)
|
||||
{
|
||||
return NM_DEVICE_GET_PRIVATE (device)->mtu;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2005 - 2012 Red Hat, Inc.
|
||||
* Copyright (C) 2005 - 2013 Red Hat, Inc.
|
||||
* Copyright (C) 2006 - 2008 Novell, Inc.
|
||||
*/
|
||||
|
||||
|
|
@ -61,6 +61,7 @@
|
|||
#define NM_DEVICE_FIRMWARE_MISSING "firmware-missing"
|
||||
#define NM_DEVICE_AVAILABLE_CONNECTIONS "available-connections"
|
||||
#define NM_DEVICE_PHYSICAL_PORT_ID "physical-port-id"
|
||||
#define NM_DEVICE_MTU "mtu"
|
||||
#define NM_DEVICE_TYPE_DESC "type-desc" /* Internal only */
|
||||
#define NM_DEVICE_RFKILL_TYPE "rfkill-type" /* Internal only */
|
||||
#define NM_DEVICE_IFINDEX "ifindex" /* Internal only */
|
||||
|
|
@ -324,6 +325,8 @@ GPtrArray *nm_device_get_available_connections (NMDevice *device,
|
|||
|
||||
const char *nm_device_get_physical_port_id (NMDevice *device);
|
||||
|
||||
guint32 nm_device_get_mtu (NMDevice *device);
|
||||
|
||||
gboolean nm_device_connection_is_available (NMDevice *device, NMConnection *connection);
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue