summaryrefslogtreecommitdiff
path: root/src/iface.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-01-04 02:37:34 +0100
committerMarcel Holtmann <marcel@holtmann.org>2008-01-04 02:37:34 +0100
commite0979df838ec942c23d8a5bad23a1e7f87d666ec (patch)
tree3aede848f2dcce90addc8f48599bad0c21dcf6de /src/iface.c
parent986cc2bccd53c801a9c15a0e1367dd1d63f2ca30 (diff)
downloadconnman-e0979df838ec942c23d8a5bad23a1e7f87d666ec.tar.gz
connman-e0979df838ec942c23d8a5bad23a1e7f87d666ec.tar.bz2
connman-e0979df838ec942c23d8a5bad23a1e7f87d666ec.zip
Add interface properties for device details
Diffstat (limited to 'src/iface.c')
-rw-r--r--src/iface.c111
1 files changed, 110 insertions, 1 deletions
diff --git a/src/iface.c b/src/iface.c
index 82fbdda9..b08fdb8f 100644
--- a/src/iface.c
+++ b/src/iface.c
@@ -417,8 +417,80 @@ static dbus_bool_t get_type(DBusConnection *conn,
return TRUE;
}
+static dbus_bool_t get_address(DBusConnection *conn,
+ DBusMessageIter *iter, void *data)
+{
+ struct connman_iface *iface = data;
+ const char *address;
+
+ DBG("iface %p", iface);
+
+ if (!iface->driver->get_address)
+ return FALSE;
+
+ address = iface->driver->get_address(iface);
+ if (address == NULL)
+ return FALSE;
+
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &address);
+
+ return TRUE;
+}
+
+static dbus_bool_t get_driver(DBusConnection *conn,
+ DBusMessageIter *iter, void *data)
+{
+ struct connman_iface *iface = data;
+
+ DBG("iface %p", iface);
+
+ if (iface->device.driver == NULL)
+ return FALSE;
+
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING,
+ &iface->device.driver);
+
+ return TRUE;
+}
+
+static dbus_bool_t get_vendor(DBusConnection *conn,
+ DBusMessageIter *iter, void *data)
+{
+ struct connman_iface *iface = data;
+
+ DBG("iface %p", iface);
+
+ if (iface->device.vendor == NULL)
+ return FALSE;
+
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING,
+ &iface->device.vendor);
+
+ return TRUE;
+}
+
+static dbus_bool_t get_product(DBusConnection *conn,
+ DBusMessageIter *iter, void *data)
+{
+ struct connman_iface *iface = data;
+
+ DBG("iface %p", iface);
+
+ if (iface->device.product == NULL)
+ return FALSE;
+
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING,
+ &iface->device.product);
+
+ return TRUE;
+}
+
static GDBusPropertyTable iface_properties[] = {
- { "Type", "s", get_type },
+ { "Type", "s", get_type },
+ { "Address", "s", get_address },
+ { "Driver", "s", get_driver },
+ { "Vendor", "s", get_vendor },
+ { "Product", "s", get_product },
{ },
};
@@ -436,9 +508,44 @@ static void device_free(void *data)
g_free(iface->path);
g_free(iface->udi);
g_free(iface->sysfs);
+ g_free(iface->device.driver);
+ g_free(iface->device.vendor);
+ g_free(iface->device.product);
g_free(iface);
}
+static void detect_device_info(LibHalContext *ctx, struct connman_iface *iface)
+{
+ char *parent, *subsys, *value;
+
+ parent = libhal_device_get_property_string(ctx, iface->udi,
+ "info.parent", NULL);
+
+ subsys = libhal_device_get_property_string(ctx, iface->udi,
+ "linux.subsystem", NULL);
+
+ value = libhal_device_get_property_string(ctx, iface->udi,
+ "info.linux.driver", NULL);
+ if (value == NULL) {
+ value = libhal_device_get_property_string(ctx, parent,
+ "info.linux.driver", NULL);
+ if (value != NULL)
+ iface->device.driver = g_strdup(value);
+ }
+
+ if (strcmp(subsys, "net") == 0) {
+ value = libhal_device_get_property_string(ctx, parent,
+ "info.vendor", NULL);
+ if (value != NULL)
+ iface->device.vendor = g_strdup(value);
+
+ value = libhal_device_get_property_string(ctx, parent,
+ "info.product", NULL);
+ if (value != NULL)
+ iface->device.product = g_strdup(value);
+ }
+}
+
static int probe_device(LibHalContext *ctx,
struct connman_iface_driver *driver, const char *udi)
{
@@ -469,6 +576,8 @@ static int probe_device(LibHalContext *ctx,
if (sysfs != NULL)
iface->sysfs = g_strdup(sysfs);
+ detect_device_info(ctx, iface);
+
iface->index = -1;
if (g_str_has_prefix(driver->capability, "net") == TRUE)