Beispiel #1
0
int supplicant_connect(struct connman_network *network)
{
	struct supplicant_task *task;
	int index;

	_DBG_SUPPLICANT("network %p", network);

	index = connman_network_get_index(network);

	task = find_task_by_index(index);
	if (task == NULL)
		return -ENODEV;

	if (task->disconnecting == TRUE)
		task->pending_network = connman_network_ref(network);
	else {
		task->network = connman_network_ref(network);
		return task_connect(task);
	}

	return -EINPROGRESS;
}
Beispiel #2
0
int __connman_dhcp_start(struct connman_ipconfig *ipconfig,
			struct connman_network *network, dhcp_cb callback,
			gpointer user_data)
{
	const char *last_addr = NULL;
	struct connman_dhcp *dhcp;
	int err;

	DBG("");

	if (network) {
		struct connman_service *service;

		service = connman_service_lookup_from_network(network);
		if (!service)
			return -EINVAL;
	}

	last_addr = __connman_ipconfig_get_dhcp_address(ipconfig);

	dhcp = g_hash_table_lookup(ipconfig_table, ipconfig);
	if (!dhcp) {

		dhcp = g_try_new0(struct connman_dhcp, 1);
		if (!dhcp)
			return -ENOMEM;

		dhcp->ipconfig = ipconfig;
		__connman_ipconfig_ref(ipconfig);

		if (network) {
			dhcp->network = network;
			connman_network_ref(network);
		}

		err = dhcp_initialize(dhcp);

		if (err < 0) {
			if (network)
				connman_network_unref(network);
			g_free(dhcp);
			return err;
		}

		g_hash_table_insert(ipconfig_table, ipconfig, dhcp);
	}
static int pan_disconnect(struct connman_network *network)
{
	const char *path = connman_network_get_string(network, "Path");
	DBusMessage *message;
	DBusPendingCall *call;

	DBG("network %p", network);

	if (!path)
		return -EINVAL;

	message = dbus_message_new_method_call(BLUEZ_SERVICE, path,
					BLUEZ_NETWORK_INTERFACE, DISCONNECT);
	if (!message)
		return -ENOMEM;

	dbus_message_set_auto_start(message, FALSE);

	dbus_message_append_args(message, DBUS_TYPE_INVALID);

	if (!dbus_connection_send_with_reply(connection, message,
						&call, TIMEOUT)) {
		connman_error("Failed to disconnect service");
		dbus_message_unref(message);
		return -EINVAL;
	}

	if (!call) {
		connman_error("D-Bus connection not available");
		dbus_message_unref(message);
		return -EINVAL;
	}

	connman_network_ref(network);

	connman_network_set_associating(network, false);

	dbus_pending_call_set_notify(call, disconnect_reply, g_strdup(path),
			g_free);

	dbus_message_unref(message);

	return 0;
}
Beispiel #4
0
/**
 * connman_device_add_network:
 * @device: device structure
 * @network: network structure
 *
 * Add new network to the device
 */
int connman_device_add_network(struct connman_device *device,
					struct connman_network *network)
{
	const char *identifier = connman_network_get_identifier(network);

	DBG("device %p network %p", device, network);

	if (identifier == NULL)
		return -EINVAL;

	connman_network_ref(network);

	__connman_network_set_device(network, device);

	g_hash_table_replace(device->networks, g_strdup(identifier),
								network);

	return 0;
}
Beispiel #5
0
int __connman_dhcp_start(struct connman_network *network, dhcp_cb callback)
{
	struct connman_dhcp *dhcp;

	DBG("");

	dhcp = g_try_new0(struct connman_dhcp, 1);
	if (dhcp == NULL)
		return -ENOMEM;

	dhcp->network = network;
	dhcp->callback = callback;

	connman_network_ref(network);

	g_hash_table_replace(network_table, network, dhcp);

	return dhcp_request(dhcp);
}
Beispiel #6
0
int __connman_dhcpv6_start(struct connman_network *network,
                           GSList *prefixes, dhcp_cb callback)
{
    struct connman_dhcpv6 *dhcp;
    int delay;

    DBG("");

    if (network_table != NULL) {
        dhcp = g_hash_table_lookup(network_table, network);
        if (dhcp != NULL && dhcp->started == TRUE)
            return -EBUSY;
    }

    dhcp = g_try_new0(struct connman_dhcpv6, 1);
    if (dhcp == NULL)
        return -ENOMEM;

    dhcp->network = network;
    dhcp->callback = callback;
    dhcp->prefixes = prefixes;
    dhcp->started = TRUE;

    connman_network_ref(network);

    DBG("replace network %p dhcp %p", network, dhcp);

    g_hash_table_replace(network_table, network, dhcp);

    /* Initial timeout, RFC 3315, 17.1.2 */
    delay = rand() % 1000;

    dhcp->timeout = g_timeout_add(delay, start_solicitation, dhcp);

    return 0;
}