Пример #1
0
static void agent_free(void)
{
	if (agent_watch > 0)
		g_dbus_remove_watch(connection, agent_watch);

	agent_watch = 0;

	g_free(agent_sender);
	agent_sender = NULL;

	g_free(agent_path);
	agent_path = NULL;

	connman_agent_cancel(NULL);
}
Пример #2
0
void connman_peer_unregister(struct connman_peer *peer)
{
	DBG("peer %p", peer);

	if (!peer->path || !peer->registered)
		return;

	connman_agent_cancel(peer);
	reply_pending(peer, EIO);

	g_dbus_unregister_interface(connection, peer->path,
					CONNMAN_PEER_INTERFACE);
	peer->registered = false;
	peer_removed(peer);
}
Пример #3
0
static int peer_disconnect(struct connman_peer *peer)
{
	int err = -ENOTSUP;

	connman_agent_cancel(peer);
	reply_pending(peer, ECONNABORTED);

	connman_peer_set_state(peer, CONNMAN_PEER_STATE_DISCONNECT);

	if (peer->connection_master)
		stop_dhcp_server(peer);
	else
		__connman_dhcp_stop(peer->ipconfig);

	if (peer_driver->disconnect)
		err = peer_driver->disconnect(peer);

	connman_peer_set_state(peer, CONNMAN_PEER_STATE_IDLE);

	return err;
}
Пример #4
0
static bool wispr_portal_web_result(GWebResult *result, gpointer user_data)
{
	struct connman_wispr_portal_context *wp_context = user_data;
	const char *redirect = NULL;
	const guint8 *chunk = NULL;
	const char *str = NULL;
	guint16 status;
	gsize length;
	bool skip_failed = false;

	DBG("");

	if (wp_context->wispr_result != CONNMAN_WISPR_RESULT_ONLINE) {
		g_web_result_get_chunk(result, &chunk, &length);

		if (length > 0) {
			g_web_parser_feed_data(wp_context->wispr_parser,
								chunk, length);
			return true;
		}

		g_web_parser_end_data(wp_context->wispr_parser);

//		if (wp_context->wispr_msg.message_type >= 0) {
//			if (wispr_manage_message(result, wp_context))
//				goto done;
//		}
	}

	status = g_web_result_get_status(result);

	DBG("status: %03u", status);

	switch (status) {
	case 200:
//		if (wp_context->wispr_msg.message_type >= 0)
//			break;

		if (g_web_result_get_header(result, "X-ConnMan-Status",
						&str)) {
			// Cancel browser requests if useragent has not returned anything
			connman_agent_cancel(wp_context->service);
			portal_manage_status(result, wp_context);
			return false;
		} else
			__connman_agent_request_browser(wp_context->service,
					wispr_portal_browser_reply_cb,
					wp_context->redirect_url, wp_context);
		break;
	case 204:
		// Cancel browser requests if useragent has not returned anything
		connman_agent_cancel(wp_context->service);
		portal_manage_status(result, wp_context);
		return false;
	case 302:
	DBG("tls %d, Location header %d",(!g_web_supports_tls() ), (!g_web_result_get_header(result, "Location",
										&redirect)));
		if (!g_web_supports_tls() ||
			!g_web_result_get_header(result, "Location",
							&redirect)) {

			__connman_agent_request_browser(wp_context->service,
					wispr_portal_browser_reply_cb,
					wp_context->status_url, wp_context);
			break;
		}

		DBG("Redirect URL: %s", redirect);
		DBG("Status url URL: %s", wp_context->status_url);

		wp_context->redirect_url = g_strdup(redirect);
		wp_context->request_id = g_web_request_get(wp_context->web,
				redirect, wispr_portal_web_result,
				wispr_route_request, wp_context);
		skip_failed = true;

		break;
	case 000:
		DBG("Redirect URL: %s", redirect);
		DBG("Status url URL: %s", wp_context->status_url);

		__connman_agent_request_browser(wp_context->service,
										wispr_portal_browser_reply_cb,
										wp_context->status_url, wp_context);
		break;
	case 400:
	case 404:

		break;
	case 505:
		DBG("HTTP version not supported, handling over to the browser");
		DBG("Redirect URL: %s", redirect);
		DBG("Status url URL: %s", wp_context->status_url);

		__connman_agent_request_browser(wp_context->service,
					wispr_portal_browser_reply_cb,
					wp_context->status_url, wp_context);
		break;
	default:
		break;
	}
	if (!skip_failed && __connman_service_online_check_failed(wp_context->service,
		wp_context->type) == 0) {
		wispr_portal_error(wp_context);
		free_connman_wispr_portal_context(wp_context);
		return false;
	}

	free_wispr_routes(wp_context);
	wp_context->request_id = 0;
	wp_context->wispr_msg.message_type = -1;
	return false;
}