From: Martin Xu <martin...@intel.com>

If udev_device_get_devtype returns the devtype, it will be used after 
tranfering to connman_device_type.
If udev_device_get_devtype returns NULL, __connman_inet_get_device_type is used 
to return connman_device_type.
---
 src/udev.c |   30 +++++++++++++++++++++++++++++-
 1 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/src/udev.c b/src/udev.c
index fe814b8..51d61f3 100644
--- a/src/udev.c
+++ b/src/udev.c
@@ -54,6 +54,28 @@ static struct connman_device *find_device(int index)
        return NULL;
 }
 
+static enum connman_device_type get_device_type(
+               struct udev_device *udev_device, int index)
+{
+       const char *devtype = NULL;
+
+       devtype = udev_device_get_devtype(udev_device);
+
+       if (g_strcmp0(devtype, "wwan") == 0)
+               return CONNMAN_DEVICE_TYPE_CELLULAR;
+
+       if (g_strcmp0(devtype, "wlan") == 0)
+               return CONNMAN_DEVICE_TYPE_WIFI;
+
+       if (g_strcmp0(devtype, "wimax") == 0)
+               return CONNMAN_DEVICE_TYPE_WIMAX;
+
+       if (devtype == NULL)
+               return __connman_inet_get_device_type(index);
+
+       return CONNMAN_DEVICE_TYPE_UNKNOWN;
+}
+
 static void add_net_device(struct udev_device *udev_device)
 {
        struct udev_list_entry *entry;
@@ -84,7 +106,10 @@ static void add_net_device(struct udev_device *udev_device)
        if (index < 0)
                return;
 
-       devtype = __connman_inet_get_device_type(index);
+
+       devtype = get_device_type(udev_device, index);
+
+       DBG("devtype %d", devtype);
 
        switch (devtype) {
        case CONNMAN_DEVICE_TYPE_UNKNOWN:
@@ -325,6 +350,9 @@ static void print_device(struct udev_device *device, const 
char *action)
        }
 
        devtype = udev_device_get_devtype(device);
+
+       DBG("devtype %s", devtype);
+
        sysname = udev_device_get_sysname(device);
 
        driver = udev_device_get_driver(parent);
-- 
1.6.1.3

_______________________________________________
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman

Reply via email to