Add detection routine for Ericsson MBM devices
authorMarcel Holtmann <marcel@holtmann.org>
Sun, 12 Jul 2009 06:59:58 +0000 (23:59 -0700)
committerMarcel Holtmann <marcel@holtmann.org>
Sun, 12 Jul 2009 06:59:58 +0000 (23:59 -0700)
src/connman.h
src/inet.c
src/udev-compat.c
src/udev.c

index 03eb80f..bc1039c 100644 (file)
@@ -189,6 +189,7 @@ void __connman_connection_update_gateway(void);
 int __connman_udev_init(void);
 void __connman_udev_cleanup(void);
 char *__connman_udev_get_devtype(const char *ifname);
+connman_bool_t __connman_udev_is_mbm(const char *ifname);
 
 #include <connman/device.h>
 
index cfd0d77..eeceec0 100644 (file)
@@ -321,7 +321,9 @@ enum connman_device_type __connman_inet_get_device_type(int index)
                memset(&iwr, 0, sizeof(iwr));
                strncpy(iwr.ifr_ifrn.ifrn_name, devname, IFNAMSIZ);
 
-               if (g_str_has_prefix(devname, "vmnet") == TRUE)
+               if (__connman_udev_is_mbm(devname) == TRUE)
+                       devtype = CONNMAN_DEVICE_TYPE_MBM;
+               else if (g_str_has_prefix(devname, "vmnet") == TRUE)
                        devtype = CONNMAN_DEVICE_TYPE_UNKNOWN;
                else if (g_str_has_prefix(ifr.ifr_name, "vboxnet") == TRUE)
                        devtype = CONNMAN_DEVICE_TYPE_UNKNOWN;
index 333eb89..89813a7 100644 (file)
@@ -95,6 +95,11 @@ char *__connman_udev_get_devtype(const char *ifname)
        return NULL;
 }
 
+connman_bool_t __connman_udev_is_mbm(const char *ifname)
+{
+       return FALSE;
+}
+
 int __connman_udev_init(void)
 {
        int err;
index b96f275..276f64e 100644 (file)
@@ -304,6 +304,53 @@ done:
        return NULL;
 }
 
+connman_bool_t __connman_udev_is_mbm(const char *ifname)
+{
+       connman_bool_t result = FALSE;
+       struct udev_device *device, *parent, *control;
+       const char *driver, *devpath1, *devpath2;
+
+       device = udev_device_new_from_subsystem_sysname(udev_ctx,
+                                                       "net", ifname);
+       if (device == NULL)
+               return FALSE;
+
+       parent = udev_device_get_parent(device);
+       if (parent == NULL)
+               goto done;
+
+       driver = udev_device_get_driver(parent);
+       if (g_strcmp0(driver, "cdc_ether") != 0)
+               goto done;
+
+       parent = udev_device_get_parent_with_subsystem_devtype(device,
+                                                       "usb", "usb_device");
+       if (parent == NULL)
+               goto done;
+
+       devpath1 = udev_device_get_devpath(parent);
+
+       control = udev_device_new_from_subsystem_sysname(udev_ctx,
+                                                       "usb", "cdc-wdm0");
+       if (control == NULL)
+               goto done;
+
+       parent = udev_device_get_parent_with_subsystem_devtype(control,
+                                                       "usb", "usb_device");
+       if (parent == NULL)
+               goto done;
+
+       devpath2 = udev_device_get_devpath(parent);
+
+       if (g_strcmp0(devpath1, devpath2) == 0)
+               result = TRUE;
+
+done:
+       udev_device_unref(device);
+
+       return result;
+}
+
 int __connman_udev_init(void)
 {
        GIOChannel *channel;