summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiří Klimeš <jklimes@redhat.com>2013-12-16 15:16:43 +0100
committerJiří Klimeš <jklimes@redhat.com>2013-12-20 11:37:54 +0100
commit44bd2275e733fc0378648c36af0cb95a6c26f0a0 (patch)
tree8d59a6eb7b06fd0267eef4c866be5d1d502c8199
parente3bd57575819ff7db26541164746443f1fa203a6 (diff)
downloadNetworkManager-44bd2275e733fc0378648c36af0cb95a6c26f0a0.tar.gz
device: add 'mtu' property
-rw-r--r--introspection/nm-device.xml5
-rw-r--r--src/devices/nm-device.c42
-rw-r--r--src/devices/nm-device.h5
3 files changed, 49 insertions, 3 deletions
diff --git a/introspection/nm-device.xml b/introspection/nm-device.xml
index d6f2e8594a..06f5781c8b 100644
--- a/introspection/nm-device.xml
+++ b/introspection/nm-device.xml
@@ -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"/>
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 6f2383b753..f8caf5a8cb 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -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));
@@ -5742,6 +5759,14 @@ nm_device_class_init (NMDeviceClass *klass)
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,
"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;
+}
+
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index 69d81754ce..4573db000c 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -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