Example #1
0
/**
 * connman_device_create:
 * @node: device node name (for example an address)
 * @type: device type
 *
 * Allocate a new device of given #type and assign the #node name to it.
 *
 * Returns: a newly-allocated #connman_device structure
 */
struct connman_device *connman_device_create(const char *node,
						enum connman_device_type type)
{
	struct connman_device *device;

	DBG("node %s type %d", node, type);

	device = g_try_new0(struct connman_device, 1);
	if (device == NULL)
		return NULL;

	DBG("device %p", device);

	device->refcount = 1;

	device->type = type;
	device->name = g_strdup(type2description(device->type));

	device->networks = g_hash_table_new_full(g_str_hash, g_str_equal,
						g_free, free_network);

	device_list = g_slist_prepend(device_list, device);

	return device;
}
Example #2
0
/**
 * connman_device_create:
 * @node: device node name (for example an address)
 * @type: device type
 *
 * Allocate a new device of given #type and assign the #node name to it.
 *
 * Returns: a newly-allocated #connman_device structure
 */
struct connman_device *connman_device_create(const char *node,
						enum connman_device_type type)
{
	struct connman_device *device;
	enum connman_service_type service_type;
	connman_bool_t bg_scan;

	DBG("node %s type %d", node, type);

	device = g_try_new0(struct connman_device, 1);
	if (device == NULL)
		return NULL;

	DBG("device %p", device);

	device->refcount = 1;

	bg_scan = connman_setting_get_bool("BackgroundScanning");

	device->type = type;
	device->name = g_strdup(type2description(device->type));

	device->powered_persistent = TRUE;

	device->phyindex = -1;

	service_type = __connman_device_get_service_type(device);
	device->blocked = __connman_technology_get_blocked(service_type);
	device->backoff_interval = SCAN_INITIAL_DELAY;

	switch (type) {
	case CONNMAN_DEVICE_TYPE_UNKNOWN:
	case CONNMAN_DEVICE_TYPE_ETHERNET:
	case CONNMAN_DEVICE_TYPE_WIMAX:
	case CONNMAN_DEVICE_TYPE_BLUETOOTH:
	case CONNMAN_DEVICE_TYPE_CELLULAR:
	case CONNMAN_DEVICE_TYPE_GPS:
	case CONNMAN_DEVICE_TYPE_GADGET:
	case CONNMAN_DEVICE_TYPE_VENDOR:
		device->scan_interval = 0;
		break;
	case CONNMAN_DEVICE_TYPE_WIFI:
		if (bg_scan == TRUE)
			device->scan_interval = 300;
		else
			device->scan_interval = 0;
		break;
	}

	device->networks = g_hash_table_new_full(g_str_hash, g_str_equal,
						g_free, free_network);

	device_list = g_slist_append(device_list, device);

	return device;
}
Example #3
0
/**
 * connman_device_set_interface:
 * @device: device structure
 * @interface: interface name
 *
 * Set interface name of device
 */
void connman_device_set_interface(struct connman_device *device,
						const char *interface)
{
	g_free(device->interface);
	device->interface = g_strdup(interface);

	if (!device->name) {
		const char *str = type2description(device->type);
		if (str && device->interface)
			device->name = g_strdup_printf("%s (%s)", str,
							device->interface);
	}
}