summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2010-06-10 10:16:39 -0700
committerDan Williams <dcbw@redhat.com>2010-06-10 10:16:39 -0700
commit763f2f1d01680093dea197fb4658eba6c1451483 (patch)
tree4240ab97a9a1058cc123289557dde4f29764f703
parent69f25ca5cb413e41b1fcab9acf16501f6e1bdfc1 (diff)
downloadNetworkManager-763f2f1d01680093dea197fb4658eba6c1451483.tar.gz
core: expose device's IP interface when activated
Lets apps find out what the actual kernel interface name is for the device so they can do fun stuff with it.
-rw-r--r--introspection/nm-device.xml10
-rw-r--r--src/nm-device-ethernet.c2
-rw-r--r--src/nm-device-interface.c10
-rw-r--r--src/nm-device-interface.h2
-rw-r--r--src/nm-device.c22
5 files changed, 41 insertions, 5 deletions
diff --git a/introspection/nm-device.xml b/introspection/nm-device.xml
index 02b7501344..016c121e72 100644
--- a/introspection/nm-device.xml
+++ b/introspection/nm-device.xml
@@ -9,7 +9,15 @@
</property>
<property name="Interface" type="s" access="read">
<tp:docstring>
- The network interface offered by the device.
+ The name of the device's control (and often data) interface.
+ </tp:docstring>
+ </property>
+ <property name="IpInterface" type="s" access="read">
+ <tp:docstring>
+ The name of the device's data interface when available. This property
+ may not refer to the actual data interface until the device has
+ successfully established a data connection, indicated by the device's
+ State becoming ACTIVATED.
</tp:docstring>
</property>
<property name="Driver" type="s" access="read">
diff --git a/src/nm-device-ethernet.c b/src/nm-device-ethernet.c
index be6d4e2f3c..4333d0f5d4 100644
--- a/src/nm-device-ethernet.c
+++ b/src/nm-device-ethernet.c
@@ -1448,8 +1448,6 @@ real_deactivate_quickly (NMDevice *device)
{
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (device);
- nm_device_set_ip_iface (device, NULL);
-
if (priv->pending_ip4_config) {
g_object_unref (priv->pending_ip4_config);
priv->pending_ip4_config = NULL;
diff --git a/src/nm-device-interface.c b/src/nm-device-interface.c
index a2eb746221..a0b9877bcc 100644
--- a/src/nm-device-interface.c
+++ b/src/nm-device-interface.c
@@ -90,7 +90,15 @@ nm_device_interface_init (gpointer g_iface)
"Interface",
"Interface",
NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_interface_install_property
+ (g_iface,
+ g_param_spec_string (NM_DEVICE_INTERFACE_IP_IFACE,
+ "IP Interface",
+ "IP Interface",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_interface_install_property
(g_iface,
diff --git a/src/nm-device-interface.h b/src/nm-device-interface.h
index 1fee131bd1..0d8772dfce 100644
--- a/src/nm-device-interface.h
+++ b/src/nm-device-interface.h
@@ -49,6 +49,7 @@ typedef enum
#define NM_DEVICE_INTERFACE_UDI "udi"
#define NM_DEVICE_INTERFACE_IFACE "interface"
+#define NM_DEVICE_INTERFACE_IP_IFACE "ip-interface"
#define NM_DEVICE_INTERFACE_DRIVER "driver"
#define NM_DEVICE_INTERFACE_CAPABILITIES "capabilities"
#define NM_DEVICE_INTERFACE_IP4_ADDRESS "ip4-address"
@@ -69,6 +70,7 @@ typedef enum {
NM_DEVICE_INTERFACE_PROP_UDI = NM_DEVICE_INTERFACE_PROP_FIRST,
NM_DEVICE_INTERFACE_PROP_IFACE,
+ NM_DEVICE_INTERFACE_PROP_IP_IFACE,
NM_DEVICE_INTERFACE_PROP_DRIVER,
NM_DEVICE_INTERFACE_PROP_CAPABILITIES,
NM_DEVICE_INTERFACE_PROP_IP4_ADDRESS,
diff --git a/src/nm-device.c b/src/nm-device.c
index ba26decaa3..01874c5fde 100644
--- a/src/nm-device.c
+++ b/src/nm-device.c
@@ -388,11 +388,12 @@ void
nm_device_set_ip_iface (NMDevice *self, const char *iface)
{
NMDevicePrivate *priv;
+ char *old_ip_iface;
g_return_if_fail (NM_IS_DEVICE (self));
priv = NM_DEVICE_GET_PRIVATE (self);
- g_free (priv->ip_iface);
+ old_ip_iface = priv->ip_iface;
priv->ip_ifindex = 0;
priv->ip_iface = g_strdup (iface);
@@ -402,6 +403,11 @@ nm_device_set_ip_iface (NMDevice *self, const char *iface)
nm_log_warn (LOGD_HW, "(%s): failed to look up interface index", iface);
}
}
+
+ /* Emit change notification */
+ if (g_strcmp0 (old_ip_iface, priv->ip_iface))
+ g_object_notify (G_OBJECT (self), NM_DEVICE_INTERFACE_IP_IFACE);
+ g_free (old_ip_iface);
}
@@ -2746,6 +2752,8 @@ nm_device_deactivate_quickly (NMDevice *self)
dnsmasq_cleanup (self);
aipd_cleanup (self);
+ nm_device_set_ip_iface (self, NULL);
+
/* Turn off router advertisements until they are needed */
if (priv->ip6_accept_ra_path)
nm_utils_do_sysctl (priv->ip6_accept_ra_path, "0\n");
@@ -3387,6 +3395,8 @@ set_property (GObject *object, guint prop_id,
}
}
break;
+ case NM_DEVICE_INTERFACE_PROP_IP_IFACE:
+ break;
case NM_DEVICE_INTERFACE_PROP_DRIVER:
priv->driver = g_strdup (g_value_get_string (value));
break;
@@ -3436,6 +3446,12 @@ get_property (GObject *object, guint prop_id,
case NM_DEVICE_INTERFACE_PROP_IFACE:
g_value_set_string (value, priv->iface);
break;
+ case NM_DEVICE_INTERFACE_PROP_IP_IFACE:
+ if ((state == NM_DEVICE_STATE_ACTIVATED) || (state == NM_DEVICE_STATE_IP_CONFIG))
+ g_value_set_string (value, nm_device_get_ip_iface (self));
+ else
+ g_value_set_string (value, NULL);
+ break;
case NM_DEVICE_INTERFACE_PROP_IFINDEX:
g_value_set_int (value, priv->ifindex);
break;
@@ -3541,6 +3557,10 @@ nm_device_class_init (NMDeviceClass *klass)
NM_DEVICE_INTERFACE_IFACE);
g_object_class_override_property (object_class,
+ NM_DEVICE_INTERFACE_PROP_IP_IFACE,
+ NM_DEVICE_INTERFACE_IP_IFACE);
+
+ g_object_class_override_property (object_class,
NM_DEVICE_INTERFACE_PROP_IFINDEX,
NM_DEVICE_INTERFACE_IFINDEX);