Пример #1
0
static void request_lookup_reply(DBusPendingCall *call, void *user_data)
{
	DBusMessage *reply = dbus_pending_call_steal_reply(call);
	struct proxy_data *data = user_data;
	const char *proxy;

	DBG("");

	if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) {
		connman_error("Failed to find URL:%s", data->url);
		proxy = NULL;
		goto done;
	}

	if (dbus_message_get_args(reply, NULL, DBUS_TYPE_STRING, &proxy,
						DBUS_TYPE_INVALID) == FALSE)
		proxy = NULL;

done:
	connman_proxy_driver_lookup_notify(data->service, data->url, proxy);

	connman_service_unref(data->service);

	g_free(data->url);
	g_free(data);

	dbus_message_unref(reply);
}
Пример #2
0
static void portal_manage_status(GWebResult *result,
			struct connman_wispr_portal_context *wp_context)
{
	enum connman_ipconfig_type type = wp_context->type;
	struct connman_service *service;
	const char *str = NULL;

	DBG("");

	/* We currently don't do anything with this info */
	if (g_web_result_get_header(result, "X-ConnMan-Client-IP",
				&str))
		DBG("Client-IP: %s", str);

	if (g_web_result_get_header(result, "X-ConnMan-Client-Country",
				&str))
		DBG("Client-Country: %s", str);

	if (g_web_result_get_header(result, "X-ConnMan-Client-Region",
				&str))
		DBG("Client-Region: %s", str);

	if (g_web_result_get_header(result, "X-ConnMan-Client-Timezone",
				&str))
		DBG("Client-Timezone: %s", str);

	/* __connman_service_ipconfig_indicate_state may end up calling
	 * __connman_wispr_start which would reinitialize the wispr context
	 * so we better free it beforehand to avoid deallocating it twice. */
	service = connman_service_ref(wp_context->service);
	free_connman_wispr_portal_context(wp_context);
	__connman_service_ipconfig_indicate_state(service,
					CONNMAN_SERVICE_STATE_ONLINE, type);
	connman_service_unref(service);
}
Пример #3
0
static void remove_lookup(struct proxy_lookup *lookup)
{
	if (lookup->watch > 0)
		g_source_remove(lookup->watch);

	lookup_list = g_slist_remove(lookup_list, lookup);

	connman_service_unref(lookup->service);
	g_free(lookup->url);
	g_free(lookup);
}
Пример #4
0
void __connman_wpad_stop(struct connman_service *service)
{
	int index;

	DBG("service %p", service);

	if (!wpad_list)
		return;

	index = __connman_service_get_index(service);
	if (index < 0)
		return;

	if (g_hash_table_remove(wpad_list, GINT_TO_POINTER(index)))
		connman_service_unref(service);
}
Пример #5
0
static void free_connman_wispr_portal_context(
		struct connman_wispr_portal_context *wp_context)
{
	DBG("context %p", wp_context);

	if (!wp_context)
		return;

	if (wp_context->wispr_portal) {
		if (wp_context->wispr_portal->ipv4_context == wp_context)
			wp_context->wispr_portal->ipv4_context = NULL;

		if (wp_context->wispr_portal->ipv6_context == wp_context)
			wp_context->wispr_portal->ipv6_context = NULL;
	}

	if (wp_context->token > 0)
		connman_proxy_lookup_cancel(wp_context->token);

	if (wp_context->request_id > 0)
		g_web_cancel_request(wp_context->web, wp_context->request_id);

	if (wp_context->timeout > 0)
		g_source_remove(wp_context->timeout);

	if (wp_context->web)
		g_web_unref(wp_context->web);

	g_free(wp_context->redirect_url);

	if (wp_context->wispr_parser)
		g_web_parser_unref(wp_context->wispr_parser);

	connman_wispr_message_init(&wp_context->wispr_msg);

	g_free(wp_context->wispr_username);
	g_free(wp_context->wispr_password);
	g_free(wp_context->wispr_formdata);

	free_wispr_routes(wp_context);

	connman_service_unref(wp_context->service);

	g_free(wp_context);
}
Пример #6
0
static void report_error_reply(DBusPendingCall *call, void *user_data)
{
	struct report_error_data *report_error = user_data;
	DBusMessage *reply = dbus_pending_call_steal_reply(call);
	gboolean retry = FALSE;
	const char *dbus_err;

	if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) {
		dbus_err = dbus_message_get_error_name(reply);
		if (dbus_err != NULL &&
			strcmp(dbus_err,
				CONNMAN_AGENT_INTERFACE ".Error.Retry") == 0)
			retry = TRUE;
	}

	report_error->callback(report_error->service, retry,
			report_error->user_data);
	connman_service_unref(report_error->service);
	g_free(report_error);
	dbus_message_unref(reply);
}
Пример #7
0
/**
* @brief Add the network associated to its qmi device
*/
static void add_network(struct qmi_data *qmi)
{
	struct connman_network *network = NULL;
	int index;
	struct connman_service *service = NULL;

	g_return_if_fail(qmi);

	DBG("data %p", qmi);

	if(qmi->network != NULL) {

		DBG("network %p already exists.", qmi->network);
		return;
	}

	/* Create an new qmi network */
	network = connman_network_create(qmi->devpath, CONNMAN_NETWORK_TYPE_QMI);
	if(network == NULL) {

		connman_error("Network could not be created.");
		return;
	}

	DBG("network %p", qmi->network);

	/* Set network properties */
	index = connman_device_get_index(qmi->device);
	connman_network_set_index(network, index);
	connman_network_set_data(network, qmi);
	connman_network_set_strength(network, qmi->strength);
	connman_network_set_group(network, qmi->group);

	if(qmi->provider)
		g_free(qmi->provider);
	qmi->provider = g_strdup("no-name");
	connman_network_set_name(network, qmi->provider);

	/* Add the created network */
	if (connman_device_add_network(qmi->device, network) < 0) {

		connman_error("Network not added to the device.");
		connman_network_unref(network);
		network = NULL;
		return;
	}

	qmi->network = network;

	/* Get configured values from the created *.config file */
	service = connman_service_lookup_from_network(network);
	DBG("service %p", service);
	if(service == NULL) {

		connman_error("No service available");
		return;
	}

	service = connman_service_ref(service);
	if(qmi->apn)
		g_free(qmi->apn);
	qmi->apn = g_strdup(connman_service_get_string(service, "APN"));

	if(qmi->passphrase)
		g_free(qmi->passphrase);
	qmi->passphrase = g_strdup(connman_service_get_string(service, "Passphrase"));

	if(qmi->username)
		g_free(qmi->username);
	qmi->username = g_strdup(connman_service_get_string(service, "Username"));

	if(qmi->provider)
		g_free(qmi->provider);
	qmi->provider = g_strdup(connman_service_get_string(service, "Provider"));
	if(qmi->provider == NULL)
		qmi->provider = g_strdup("no-name");

	connman_network_set_name(network, qmi->provider);
	connman_network_update(qmi->network);


    DBG("network %p IMSI %s APN %s PW %s Username %s", qmi->network, qmi->imsi, qmi->apn, qmi->passphrase, qmi->username);
	connman_service_unref(service);
	if((qmi->imsi == NULL) || (qmi->apn == NULL) || (qmi->passphrase == NULL)) {

		connman_error("There are not all required parameters available");
		return;
	}

}
Пример #8
0
static void request_input_passphrase_reply(DBusPendingCall *call, void *user_data)
{
	struct request_input_reply *passphrase_reply = user_data;
	connman_bool_t wps = FALSE;
	char *identity = NULL;
	char *passphrase = NULL;
	char *wpspin = NULL;
	char *key;
	DBusMessageIter iter, dict;
	DBusMessage *reply = dbus_pending_call_steal_reply(call);

	if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR)
		goto done;

	dbus_message_iter_init(reply, &iter);
	dbus_message_iter_recurse(&iter, &dict);
	while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
		DBusMessageIter entry, value;

		dbus_message_iter_recurse(&dict, &entry);
		if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_STRING)
			break;

		dbus_message_iter_get_basic(&entry, &key);

		if (g_str_equal(key, "Identity")) {
			dbus_message_iter_next(&entry);
			if (dbus_message_iter_get_arg_type(&entry)
							!= DBUS_TYPE_VARIANT)
				break;
			dbus_message_iter_recurse(&entry, &value);
			dbus_message_iter_get_basic(&value, &identity);

		} else if (g_str_equal(key, "Passphrase")) {
			dbus_message_iter_next(&entry);
			if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_VARIANT)
				break;
			dbus_message_iter_recurse(&entry, &value);
			dbus_message_iter_get_basic(&value, &passphrase);

		} else if (g_str_equal(key, "WPS")) {
			wps = TRUE;

			dbus_message_iter_next(&entry);
			if (dbus_message_iter_get_arg_type(&entry)
							!= DBUS_TYPE_VARIANT)
				break;
			dbus_message_iter_recurse(&entry, &value);
			dbus_message_iter_get_basic(&value, &wpspin);
			break;
		}
		dbus_message_iter_next(&dict);
	}

	if (wps == TRUE) {
		struct connman_network *network;

		network = __connman_service_get_network(
						passphrase_reply->service);
		if (network == NULL)
			goto done;

		connman_network_set_bool(network, "WiFi.UseWPS", wps);

		if (wpspin != NULL && strlen(wpspin) > 0)
			connman_network_set_string(network,
						"WiFi.PinWPS", wpspin);
		else
			connman_network_set_string(network,
						"WiFi.PinWPS", NULL);
	}

done:
	passphrase_reply->callback(passphrase_reply->service, identity,
				passphrase, passphrase_reply->user_data);
	connman_service_unref(passphrase_reply->service);
	dbus_message_unref(reply);
	g_free(passphrase_reply);
}
Пример #9
0
void __connman_connection_gateway_remove(struct connman_service *service,
					enum connman_ipconfig_type type)
{
	struct gateway_data *data = NULL;
	bool set_default4 = false, set_default6 = false;
        bool do_ipv4 = false, do_ipv6 = false;
	int err;

	DBG("service %p type %d", service, type);

	if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
		do_ipv4 = true;
	else if (type == CONNMAN_IPCONFIG_TYPE_IPV6)
		do_ipv6 = true;
	else
		do_ipv4 = do_ipv6 = true;

	__connman_service_nameserver_del_routes(service, type);

	data = g_hash_table_lookup(gateway_hash, service);
	if (!data)
		return;

	if (do_ipv4 && data->ipv4_gateway)
		set_default4 = data->ipv4_gateway->vpn;

	if (do_ipv6 && data->ipv6_gateway)
		set_default6 = data->ipv6_gateway->vpn;

	DBG("ipv4 gateway %s ipv6 gateway %s vpn %d/%d",
		data->ipv4_gateway ? data->ipv4_gateway->gateway : "<null>",
		data->ipv6_gateway ? data->ipv6_gateway->gateway : "<null>",
		set_default4, set_default6);

	if (do_ipv4 && data->ipv4_gateway &&
			data->ipv4_gateway->vpn && data->index >= 0)
		connman_inet_del_host_route(data->index,
						data->ipv4_gateway->gateway);

	if (do_ipv6 && data->ipv6_gateway &&
			data->ipv6_gateway->vpn && data->index >= 0)
		connman_inet_del_ipv6_host_route(data->index,
						data->ipv6_gateway->gateway);

	err = disable_gateway(data, type);

	/*
	 * We remove the service from the hash only if all the gateway
	 * settings are to be removed.
	 */
	if (do_ipv4 == do_ipv6 ||
		(data->ipv4_gateway && !data->ipv6_gateway
			&& do_ipv4) ||
		(data->ipv6_gateway && !data->ipv4_gateway
			&& do_ipv6)
		) {
		connman_service_unref(service);
		g_hash_table_remove(gateway_hash, service);
	} else
		DBG("Not yet removing gw ipv4 %p/%d ipv6 %p/%d",
			data->ipv4_gateway, do_ipv4,
			data->ipv6_gateway, do_ipv6);

	/* with vpn this will be called after the network was deleted,
	 * we need to call set_default here because we will not recieve any
	 * gateway delete notification.
	 * We hit the same issue if remove_gateway() fails.
	 */
	if (set_default4 || set_default6 || err < 0) {
		data = find_default_gateway();
		if (data)
			set_default_gateway(data, type);
	}
}