struct interface_data {
int index;
- char *name;
char *ident;
enum connman_service_type service_type;
enum connman_device_type device_type;
interface->index, interface->ident);
g_free(interface->ident);
- g_free(interface->name);
g_free(interface);
}
static void read_uevent(struct interface_data *interface)
{
- char *filename, line[128];
+ char *filename, *name, line[128];
connman_bool_t found_devtype;
FILE *f;
- if (ether_blacklisted(interface->name) == TRUE) {
+ name = connman_inet_ifname(interface->index);
+
+ if (ether_blacklisted(name) == TRUE) {
interface->service_type = CONNMAN_SERVICE_TYPE_UNKNOWN;
interface->device_type = CONNMAN_DEVICE_TYPE_UNKNOWN;
} else {
interface->device_type = CONNMAN_DEVICE_TYPE_ETHERNET;
}
- filename = g_strdup_printf("/sys/class/net/%s/uevent",
- interface->name);
+ filename = g_strdup_printf("/sys/class/net/%s/uevent", name);
f = fopen(filename, "re");
if (!f) {
interface->service_type = CONNMAN_SERVICE_TYPE_UNKNOWN;
interface->device_type = CONNMAN_DEVICE_TYPE_UNKNOWN;
- return;
+ goto out;
}
found_devtype = FALSE;
fclose(f);
if (found_devtype)
- return;
+ goto out;
/* We haven't got a DEVTYPE, let's check if it's a wireless device */
- if (wext_interface(interface->name)) {
+ if (wext_interface(name)) {
interface->service_type = CONNMAN_SERVICE_TYPE_WIFI;
interface->device_type = CONNMAN_DEVICE_TYPE_WIFI;
- connman_error("%s runs an unsupported 802.11 driver",
- interface->name);
+ connman_error("%s runs an unsupported 802.11 driver", name);
}
+
+out:
+ g_free(name);
}
enum connman_device_type __connman_rtnl_get_device_type(int index)
if (interface == NULL) {
interface = g_new0(struct interface_data, 1);
interface->index = index;
- interface->name = g_strdup(ifname);
interface->ident = g_strdup(ident);
g_hash_table_insert(interface_list,