diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2009-07-12 00:32:13 -0700 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2009-07-12 00:32:13 -0700 |
commit | f39a9a367e4ae5cd6ed02dcf89ed6b5e2811a9cc (patch) | |
tree | 286550c36d5be75c0faad10d12f6f0555502507a /src | |
parent | aef901e56c30723062f524605e8e9827764e9237 (diff) | |
download | connman-f39a9a367e4ae5cd6ed02dcf89ed6b5e2811a9cc.tar.gz connman-f39a9a367e4ae5cd6ed02dcf89ed6b5e2811a9cc.tar.bz2 connman-f39a9a367e4ae5cd6ed02dcf89ed6b5e2811a9cc.zip |
Store control interface for complex devices
Diffstat (limited to 'src')
-rw-r--r-- | src/connman.h | 2 | ||||
-rw-r--r-- | src/device.c | 8 | ||||
-rw-r--r-- | src/inet.c | 32 | ||||
-rw-r--r-- | src/udev-compat.c | 4 | ||||
-rw-r--r-- | src/udev.c | 10 |
5 files changed, 36 insertions, 20 deletions
diff --git a/src/connman.h b/src/connman.h index bc1039cd..84ebf602 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 <connman/device.h> diff --git a/src/device.c b/src/device.c index a7e4a2c7..bcf40a81 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) @@ -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 89813a71..42309847 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) @@ -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) |