From 22e99f1a44c4400e73ff78f51b81a1e16b68d429 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sun, 28 Jun 2009 11:55:11 +0200 Subject: [PATCH] Add support for reading DEVTYPE attribute --- src/connman.h | 6 ++++++ src/inet.c | 2 ++ src/udev.c | 25 +++++++++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/src/connman.h b/src/connman.h index 497d0fe..724dbab 100644 --- a/src/connman.h +++ b/src/connman.h @@ -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 diff --git a/src/inet.c b/src/inet.c index 7789286..046d10b 100644 --- a/src/inet.c +++ b/src/inet.c @@ -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; diff --git a/src/udev.c b/src/udev.c index d38abe6..c198646 100644 --- a/src/udev.c +++ b/src/udev.c @@ -23,6 +23,7 @@ #include #endif +#include #include #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; -- 2.7.4