Add support for reading DEVTYPE attribute
authorMarcel Holtmann <marcel@holtmann.org>
Sun, 28 Jun 2009 09:55:11 +0000 (11:55 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Sun, 28 Jun 2009 09:55:11 +0000 (11:55 +0200)
src/connman.h
src/inet.c
src/udev.c

index 497d0fe..724dbab 100644 (file)
@@ -180,6 +180,7 @@ void __connman_connection_update_gateway(void);
 #ifdef HAVE_UDEV
 int __connman_udev_init(void);
 void __connman_udev_cleanup(void);
+char *__connman_udev_get_devtype(const char *ifname);
 #else
 static inline int __connman_udev_init(void)
 {
@@ -189,6 +190,11 @@ static inline int __connman_udev_init(void)
 static inline void __connman_udev_cleanup(void)
 {
 }
+
+static inline char *__connman_udev_get_devtype(const char *ifname)
+{
+       return NULL;
+}
 #endif
 
 #include <connman/device.h>
index 7789286..046d10b 100644 (file)
@@ -303,6 +303,8 @@ struct connman_device *connman_inet_create_device(int index)
        if (devname == NULL)
                return NULL;
 
+       __connman_udev_get_devtype(devname);
+
        if (type == ARPHRD_ETHER) {
                char bridge_path[PATH_MAX], wimax_path[PATH_MAX];
                struct stat st;
index d38abe6..c198646 100644 (file)
@@ -23,6 +23,7 @@
 #include <config.h>
 #endif
 
+#include <stdio.h>
 #include <sys/types.h>
 
 #define LIBUDEV_I_KNOW_THE_API_IS_SUBJECT_TO_CHANGE
@@ -271,6 +272,30 @@ static struct udev *udev_ctx;
 static struct udev_monitor *udev_mon;
 static guint udev_watch = 0;
 
+char *__connman_udev_get_devtype(const char *ifname)
+{
+       struct udev_device *device;
+       const char *devtype;
+       char syspath[128];
+
+       snprintf(syspath, sizeof(syspath) - 1, "/sys/class/net/%s", ifname);
+
+       device = udev_device_new_from_syspath(udev_ctx, syspath);
+       if (device == NULL)
+               return NULL;
+
+       devtype = udev_device_get_devtype(device);
+       if (devtype == NULL)
+               goto done;
+
+       connman_info("%s ==> %s", ifname, devtype);
+
+done:
+       udev_device_unref(device);
+
+       return NULL;
+}
+
 int __connman_udev_init(void)
 {
        GIOChannel *channel;