From: Marcel Holtmann Date: Sun, 12 Jul 2009 07:32:13 +0000 (-0700) Subject: Store control interface for complex devices X-Git-Tag: accepted/2.0alpha-wayland/20121110.002834~3565 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f39a9a367e4ae5cd6ed02dcf89ed6b5e2811a9cc;p=profile%2Fivi%2Fconnman.git Store control interface for complex devices --- diff --git a/include/device.h b/include/device.h index e2f1686..2cd77f8 100644 --- a/include/device.h +++ b/include/device.h @@ -70,7 +70,7 @@ const char *connman_device_get_path(struct connman_device *device); void connman_device_set_index(struct connman_device *device, int index); int connman_device_get_index(struct connman_device *device); void connman_device_set_interface(struct connman_device *device, - const char *interface); + const char *interface, const char *control); void connman_device_set_ident(struct connman_device *device, const char *ident); diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c index fa2c3c6..fac96cf 100644 --- a/plugins/bluetooth.c +++ b/plugins/bluetooth.c @@ -650,7 +650,7 @@ static void adapter_properties(DBusConnection *connection, const char *path, connman_device_set_index(adapter, index); } - connman_device_set_interface(adapter, node); + connman_device_set_interface(adapter, node, NULL); connman_device_set_mode(adapter, CONNMAN_DEVICE_MODE_NETWORK_MULTIPLE); diff --git a/src/connman.h b/src/connman.h index bc1039c..84ebf60 100644 --- a/src/connman.h +++ b/src/connman.h @@ -189,7 +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); +char *__connman_udev_get_mbm_devnode(const char *ifname); #include diff --git a/src/device.c b/src/device.c index a7e4a2c..bcf40a8 100644 --- a/src/device.c +++ b/src/device.c @@ -46,6 +46,7 @@ struct connman_device { char *node; char *address; char *interface; + char *control; char *ident; unsigned int connections; guint scan_timeout; @@ -1000,6 +1001,7 @@ static void device_destruct(struct connman_element *element) g_free(device->node); g_free(device->name); g_free(device->address); + g_free(device->control); g_free(device->interface); connman_ipconfig_unref(device->ipconfig); @@ -1182,11 +1184,12 @@ int connman_device_get_index(struct connman_device *device) * connman_device_set_interface: * @device: device structure * @interface: interface name + * @control: control interface * * Set interface name of device */ void connman_device_set_interface(struct connman_device *device, - const char *interface) + const char *interface, const char *control) { g_free(device->element.devname); device->element.devname = g_strdup(interface); @@ -1194,6 +1197,9 @@ void connman_device_set_interface(struct connman_device *device, g_free(device->interface); device->interface = g_strdup(interface); + g_free(device->control); + device->control = g_strdup(control); + if (device->name == NULL) { const char *str = type2description(device->type); if (str != NULL && device->interface != NULL) diff --git a/src/inet.c b/src/inet.c index eeceec0..2546778 100644 --- a/src/inet.c +++ b/src/inet.c @@ -312,6 +312,7 @@ enum connman_device_type __connman_inet_get_device_type(int index) char bridge_path[PATH_MAX], wimax_path[PATH_MAX]; struct stat st; struct iwreq iwr; + char *devnode; snprintf(bridge_path, PATH_MAX, "/sys/class/net/%s/bridge", devname); @@ -321,9 +322,14 @@ 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 (__connman_udev_is_mbm(devname) == TRUE) + devnode = __connman_udev_get_mbm_devnode(devname); + if (devnode != NULL) { devtype = CONNMAN_DEVICE_TYPE_MBM; - else if (g_str_has_prefix(devname, "vmnet") == TRUE) + g_free(devnode); + goto done; + } + + 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; @@ -355,7 +361,7 @@ struct connman_device *connman_inet_create_device(int index) enum connman_device_mode mode = CONNMAN_DEVICE_MODE_UNKNOWN; enum connman_device_type type; struct connman_device *device; - char *addr, *name, *devname, *ident = NULL; + char *addr, *name, *node, *devname, *ident = NULL; if (index < 0) return NULL; @@ -378,10 +384,10 @@ struct connman_device *connman_inet_create_device(int index) case CONNMAN_DEVICE_TYPE_WIMAX: name = index2ident(index, ""); addr = index2addr(index); + node = NULL; break; case CONNMAN_DEVICE_TYPE_BLUETOOTH: case CONNMAN_DEVICE_TYPE_GPS: - case CONNMAN_DEVICE_TYPE_MBM: case CONNMAN_DEVICE_TYPE_HSO: case CONNMAN_DEVICE_TYPE_NOZOMI: case CONNMAN_DEVICE_TYPE_HUAWEI: @@ -389,16 +395,18 @@ struct connman_device *connman_inet_create_device(int index) case CONNMAN_DEVICE_TYPE_VENDOR: name = strdup(devname); addr = NULL; + node = NULL; + break; + case CONNMAN_DEVICE_TYPE_MBM: + name = strdup(devname); + addr = index2addr(index); + node = __connman_udev_get_mbm_devnode(devname); break; } device = connman_device_create(name, type); - if (device == NULL) { - g_free(devname); - g_free(name); - g_free(addr); - return NULL; - } + if (device == NULL) + goto done; switch (type) { case CONNMAN_DEVICE_TYPE_UNKNOWN: @@ -430,7 +438,7 @@ struct connman_device *connman_inet_create_device(int index) connman_device_set_mode(device, mode); connman_device_set_index(device, index); - connman_device_set_interface(device, devname); + connman_device_set_interface(device, devname, node); if (ident != NULL) { connman_device_set_ident(device, ident); @@ -439,7 +447,9 @@ struct connman_device *connman_inet_create_device(int index) connman_device_set_string(device, "Address", addr); +done: g_free(devname); + g_free(node); g_free(name); g_free(addr); diff --git a/src/udev-compat.c b/src/udev-compat.c index 89813a7..4230984 100644 --- a/src/udev-compat.c +++ b/src/udev-compat.c @@ -95,9 +95,9 @@ char *__connman_udev_get_devtype(const char *ifname) return NULL; } -connman_bool_t __connman_udev_is_mbm(const char *ifname) +char *__connman_udev_get_mbm_devnode(const char *ifname) { - return FALSE; + return NULL; } int __connman_udev_init(void) diff --git a/src/udev.c b/src/udev.c index f03f952..0900f39 100644 --- a/src/udev.c +++ b/src/udev.c @@ -304,16 +304,16 @@ done: return NULL; } -connman_bool_t __connman_udev_is_mbm(const char *ifname) +char *__connman_udev_get_mbm_devnode(const char *ifname) { - connman_bool_t result = FALSE; struct udev_device *device, *parent, *control; const char *driver, *devpath1, *devpath2; + char *devnode = NULL; device = udev_device_new_from_subsystem_sysname(udev_ctx, "net", ifname); if (device == NULL) - return FALSE; + return NULL; parent = udev_device_get_parent(device); if (parent == NULL) @@ -343,12 +343,12 @@ connman_bool_t __connman_udev_is_mbm(const char *ifname) devpath2 = udev_device_get_devpath(parent); if (g_strcmp0(devpath1, devpath2) == 0) - result = TRUE; + devnode = g_strdup(udev_device_get_devnode(control)); done: udev_device_unref(device); - return result; + return devnode; } int __connman_udev_init(void)