5 * Copyright (C) 2007-2013 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 #include <gweb/gweb.h>
33 #define STATUS_URL_IPV4 "http://ipv4.connman.net/online/status.html"
34 #define STATUS_URL_IPV6 "http://ipv6.connman.net/online/status.html"
36 struct connman_wispr_message {
38 const char *current_element;
42 char *abort_login_url;
44 char *access_procedure;
45 char *access_location;
49 enum connman_wispr_result {
50 CONNMAN_WISPR_RESULT_UNKNOWN = 0,
51 CONNMAN_WISPR_RESULT_LOGIN = 1,
52 CONNMAN_WISPR_RESULT_ONLINE = 2,
53 CONNMAN_WISPR_RESULT_FAILED = 3,
61 struct connman_wispr_portal_context {
62 struct connman_service *service;
63 enum connman_ipconfig_type type;
64 struct connman_wispr_portal *wispr_portal;
66 /* Portal/WISPr common */
71 const char *status_url;
76 GWebParser *wispr_parser;
77 struct connman_wispr_message wispr_msg;
83 enum connman_wispr_result wispr_result;
90 struct connman_wispr_portal {
91 struct connman_wispr_portal_context *ipv4_context;
92 struct connman_wispr_portal_context *ipv6_context;
95 static bool wispr_portal_web_result(GWebResult *result, gpointer user_data);
97 static GHashTable *wispr_portal_list = NULL;
99 static void connman_wispr_message_init(struct connman_wispr_message *msg)
103 msg->has_error = false;
104 msg->current_element = NULL;
106 msg->message_type = -1;
107 msg->response_code = -1;
109 g_free(msg->login_url);
110 msg->login_url = NULL;
112 g_free(msg->abort_login_url);
113 msg->abort_login_url = NULL;
115 g_free(msg->logoff_url);
116 msg->logoff_url = NULL;
118 g_free(msg->access_procedure);
119 msg->access_procedure = NULL;
121 g_free(msg->access_location);
122 msg->access_location = NULL;
124 g_free(msg->location_name);
125 msg->location_name = NULL;
128 static void free_wispr_routes(struct connman_wispr_portal_context *wp_context)
130 while (wp_context->route_list) {
131 struct wispr_route *route = wp_context->route_list->data;
133 DBG("free route to %s if %d type %d", route->address,
134 route->if_index, wp_context->type);
136 switch (wp_context->type) {
137 case CONNMAN_IPCONFIG_TYPE_IPV4:
138 connman_inet_del_host_route(route->if_index,
141 case CONNMAN_IPCONFIG_TYPE_IPV6:
142 connman_inet_del_ipv6_host_route(route->if_index,
145 case CONNMAN_IPCONFIG_TYPE_UNKNOWN:
149 g_free(route->address);
152 wp_context->route_list =
153 g_slist_delete_link(wp_context->route_list,
154 wp_context->route_list);
158 static void free_connman_wispr_portal_context(
159 struct connman_wispr_portal_context *wp_context)
161 DBG("context %p", wp_context);
166 if (wp_context->wispr_portal) {
167 if (wp_context->wispr_portal->ipv4_context == wp_context)
168 wp_context->wispr_portal->ipv4_context = NULL;
170 if (wp_context->wispr_portal->ipv6_context == wp_context)
171 wp_context->wispr_portal->ipv6_context = NULL;
174 if (wp_context->token > 0)
175 connman_proxy_lookup_cancel(wp_context->token);
177 if (wp_context->request_id > 0)
178 g_web_cancel_request(wp_context->web, wp_context->request_id);
180 if (wp_context->timeout > 0)
181 g_source_remove(wp_context->timeout);
184 g_web_unref(wp_context->web);
186 g_free(wp_context->redirect_url);
188 if (wp_context->wispr_parser)
189 g_web_parser_unref(wp_context->wispr_parser);
191 connman_wispr_message_init(&wp_context->wispr_msg);
193 g_free(wp_context->wispr_username);
194 g_free(wp_context->wispr_password);
195 g_free(wp_context->wispr_formdata);
197 free_wispr_routes(wp_context);
202 static struct connman_wispr_portal_context *create_wispr_portal_context(void)
204 return g_try_new0(struct connman_wispr_portal_context, 1);
207 static void free_connman_wispr_portal(gpointer data)
209 struct connman_wispr_portal *wispr_portal = data;
216 free_connman_wispr_portal_context(wispr_portal->ipv4_context);
217 free_connman_wispr_portal_context(wispr_portal->ipv6_context);
219 g_free(wispr_portal);
222 static const char *message_type_to_string(int message_type)
224 switch (message_type) {
226 return "Initial redirect message";
228 return "Proxy notification";
230 return "Authentication notification";
232 return "Logoff notification";
234 return "Response to Authentication Poll";
236 return "Response to Abort Login";
242 static const char *response_code_to_string(int response_code)
244 switch (response_code) {
248 return "Login succeeded";
250 return "Login failed";
252 return "RADIUS server error/timeout";
254 return "RADIUS server not enabled";
256 return "Logoff succeeded";
258 return "Login aborted";
260 return "Proxy detection/repeat operation";
262 return "Authentication pending";
264 return "Access gateway internal error";
273 WISPR_ELEMENT_NONE = 0,
274 WISPR_ELEMENT_ACCESS_PROCEDURE = 1,
275 WISPR_ELEMENT_ACCESS_LOCATION = 2,
276 WISPR_ELEMENT_LOCATION_NAME = 3,
277 WISPR_ELEMENT_LOGIN_URL = 4,
278 WISPR_ELEMENT_ABORT_LOGIN_URL = 5,
279 WISPR_ELEMENT_MESSAGE_TYPE = 6,
280 WISPR_ELEMENT_RESPONSE_CODE = 7,
281 WISPR_ELEMENT_NEXT_URL = 8,
282 WISPR_ELEMENT_DELAY = 9,
283 WISPR_ELEMENT_REPLY_MESSAGE = 10,
284 WISPR_ELEMENT_LOGIN_RESULTS_URL = 11,
285 WISPR_ELEMENT_LOGOFF_URL = 12,
287 } wispr_element_map[] = {
288 { "AccessProcedure", WISPR_ELEMENT_ACCESS_PROCEDURE },
289 { "AccessLocation", WISPR_ELEMENT_ACCESS_LOCATION },
290 { "LocationName", WISPR_ELEMENT_LOCATION_NAME },
291 { "LoginURL", WISPR_ELEMENT_LOGIN_URL },
292 { "AbortLoginURL", WISPR_ELEMENT_ABORT_LOGIN_URL },
293 { "MessageType", WISPR_ELEMENT_MESSAGE_TYPE },
294 { "ResponseCode", WISPR_ELEMENT_RESPONSE_CODE },
295 { "NextURL", WISPR_ELEMENT_NEXT_URL },
296 { "Delay", WISPR_ELEMENT_DELAY },
297 { "ReplyMessage", WISPR_ELEMENT_REPLY_MESSAGE },
298 { "LoginResultsURL", WISPR_ELEMENT_LOGIN_RESULTS_URL },
299 { "LogoffURL", WISPR_ELEMENT_LOGOFF_URL },
300 { NULL, WISPR_ELEMENT_NONE },
303 static void xml_wispr_start_element_handler(GMarkupParseContext *context,
304 const gchar *element_name,
305 const gchar **attribute_names,
306 const gchar **attribute_values,
307 gpointer user_data, GError **error)
309 struct connman_wispr_message *msg = user_data;
311 msg->current_element = element_name;
314 static void xml_wispr_end_element_handler(GMarkupParseContext *context,
315 const gchar *element_name,
316 gpointer user_data, GError **error)
318 struct connman_wispr_message *msg = user_data;
320 msg->current_element = NULL;
323 static void xml_wispr_text_handler(GMarkupParseContext *context,
324 const gchar *text, gsize text_len,
325 gpointer user_data, GError **error)
327 struct connman_wispr_message *msg = user_data;
330 if (!msg->current_element)
333 for (i = 0; wispr_element_map[i].str; i++) {
334 if (!g_str_equal(wispr_element_map[i].str, msg->current_element))
337 switch (wispr_element_map[i].element) {
338 case WISPR_ELEMENT_NONE:
339 case WISPR_ELEMENT_ACCESS_PROCEDURE:
340 g_free(msg->access_procedure);
341 msg->access_procedure = g_strdup(text);
343 case WISPR_ELEMENT_ACCESS_LOCATION:
344 g_free(msg->access_location);
345 msg->access_location = g_strdup(text);
347 case WISPR_ELEMENT_LOCATION_NAME:
348 g_free(msg->location_name);
349 msg->location_name = g_strdup(text);
351 case WISPR_ELEMENT_LOGIN_URL:
352 g_free(msg->login_url);
353 msg->login_url = g_strdup(text);
355 case WISPR_ELEMENT_ABORT_LOGIN_URL:
356 g_free(msg->abort_login_url);
357 msg->abort_login_url = g_strdup(text);
359 case WISPR_ELEMENT_MESSAGE_TYPE:
360 msg->message_type = atoi(text);
362 case WISPR_ELEMENT_RESPONSE_CODE:
363 msg->response_code = atoi(text);
365 case WISPR_ELEMENT_NEXT_URL:
366 case WISPR_ELEMENT_DELAY:
367 case WISPR_ELEMENT_REPLY_MESSAGE:
368 case WISPR_ELEMENT_LOGIN_RESULTS_URL:
370 case WISPR_ELEMENT_LOGOFF_URL:
371 g_free(msg->logoff_url);
372 msg->logoff_url = g_strdup(text);
378 static void xml_wispr_error_handler(GMarkupParseContext *context,
379 GError *error, gpointer user_data)
381 struct connman_wispr_message *msg = user_data;
383 msg->has_error = true;
386 static const GMarkupParser xml_wispr_parser_handlers = {
387 xml_wispr_start_element_handler,
388 xml_wispr_end_element_handler,
389 xml_wispr_text_handler,
391 xml_wispr_error_handler,
394 static void xml_wispr_parser_callback(const char *str, gpointer user_data)
396 struct connman_wispr_portal_context *wp_context = user_data;
397 GMarkupParseContext *parser_context = NULL;
402 parser_context = g_markup_parse_context_new(&xml_wispr_parser_handlers,
403 G_MARKUP_TREAT_CDATA_AS_TEXT,
404 &(wp_context->wispr_msg), NULL);
406 result = g_markup_parse_context_parse(parser_context,
407 str, strlen(str), NULL);
409 g_markup_parse_context_end_parse(parser_context, NULL);
411 g_markup_parse_context_free(parser_context);
414 static void web_debug(const char *str, void *data)
416 connman_info("%s: %s\n", (const char *) data, str);
419 static void wispr_portal_error(struct connman_wispr_portal_context *wp_context)
421 DBG("Failed to proceed wispr/portal web request");
423 wp_context->wispr_result = CONNMAN_WISPR_RESULT_FAILED;
426 static void portal_manage_status(GWebResult *result,
427 struct connman_wispr_portal_context *wp_context)
429 struct connman_service *service = wp_context->service;
430 enum connman_ipconfig_type type = wp_context->type;
431 const char *str = NULL;
435 /* We currently don't do anything with this info */
436 if (g_web_result_get_header(result, "X-ConnMan-Client-IP",
438 connman_info("Client-IP: %s", str);
440 if (g_web_result_get_header(result, "X-ConnMan-Client-Country",
442 connman_info("Client-Country: %s", str);
444 if (g_web_result_get_header(result, "X-ConnMan-Client-Region",
446 connman_info("Client-Region: %s", str);
448 if (g_web_result_get_header(result, "X-ConnMan-Client-Timezone",
450 connman_info("Client-Timezone: %s", str);
452 free_connman_wispr_portal_context(wp_context);
454 __connman_service_ipconfig_indicate_state(service,
455 CONNMAN_SERVICE_STATE_ONLINE, type);
458 static bool wispr_route_request(const char *address, int ai_family,
459 int if_index, gpointer user_data)
462 struct connman_wispr_portal_context *wp_context = user_data;
464 struct wispr_route *route;
466 gateway = __connman_ipconfig_get_gateway_from_index(if_index,
469 DBG("address %s if %d gw %s", address, if_index, gateway);
474 route = g_try_new0(struct wispr_route, 1);
476 DBG("could not create struct");
480 switch (wp_context->type) {
481 case CONNMAN_IPCONFIG_TYPE_IPV4:
482 result = connman_inet_add_host_route(if_index, address,
485 case CONNMAN_IPCONFIG_TYPE_IPV6:
486 result = connman_inet_add_ipv6_host_route(if_index, address,
489 case CONNMAN_IPCONFIG_TYPE_UNKNOWN:
498 route->address = g_strdup(address);
499 route->if_index = if_index;
500 wp_context->route_list = g_slist_prepend(wp_context->route_list, route);
505 static void wispr_portal_request_portal(
506 struct connman_wispr_portal_context *wp_context)
510 wp_context->request_id = g_web_request_get(wp_context->web,
511 wp_context->status_url,
512 wispr_portal_web_result,
516 if (wp_context->request_id == 0)
517 wispr_portal_error(wp_context);
520 static bool wispr_input(const guint8 **data, gsize *length,
523 struct connman_wispr_portal_context *wp_context = user_data;
529 buf = g_string_sized_new(100);
531 g_string_append(buf, "button=Login&UserName=");
532 g_string_append_uri_escaped(buf, wp_context->wispr_username,
534 g_string_append(buf, "&Password=");
535 g_string_append_uri_escaped(buf, wp_context->wispr_password,
537 g_string_append(buf, "&FNAME=0&OriginatingServer=");
538 g_string_append_uri_escaped(buf, wp_context->status_url, NULL, FALSE);
542 g_free(wp_context->wispr_formdata);
543 wp_context->wispr_formdata = g_string_free(buf, FALSE);
545 *data = (guint8 *) wp_context->wispr_formdata;
551 static void wispr_portal_browser_reply_cb(struct connman_service *service,
552 bool authentication_done,
553 const char *error, void *user_data)
555 struct connman_wispr_portal_context *wp_context = user_data;
559 if (!service || !wp_context)
562 if (!authentication_done) {
563 wispr_portal_error(wp_context);
564 free_wispr_routes(wp_context);
568 /* Restarting the test */
569 __connman_wispr_start(service, wp_context->type);
572 static void wispr_portal_request_wispr_login(struct connman_service *service,
574 const char *ssid, int ssid_len,
575 const char *username, const char *password,
576 bool wps, const char *wpspin,
577 const char *error, void *user_data)
579 struct connman_wispr_portal_context *wp_context = user_data;
585 "net.connman.Agent.Error.LaunchBrowser") == 0) {
586 if (__connman_agent_request_browser(service,
587 wispr_portal_browser_reply_cb,
588 wp_context->redirect_url,
589 wp_context) == -EINPROGRESS)
593 free_connman_wispr_portal_context(wp_context);
597 g_free(wp_context->wispr_username);
598 wp_context->wispr_username = g_strdup(username);
600 g_free(wp_context->wispr_password);
601 wp_context->wispr_password = g_strdup(password);
603 wp_context->request_id = g_web_request_post(wp_context->web,
604 wp_context->wispr_msg.login_url,
605 "application/x-www-form-urlencoded",
606 wispr_input, wispr_portal_web_result,
609 connman_wispr_message_init(&wp_context->wispr_msg);
612 static bool wispr_manage_message(GWebResult *result,
613 struct connman_wispr_portal_context *wp_context)
615 DBG("Message type: %s (%d)",
616 message_type_to_string(wp_context->wispr_msg.message_type),
617 wp_context->wispr_msg.message_type);
618 DBG("Response code: %s (%d)",
619 response_code_to_string(wp_context->wispr_msg.response_code),
620 wp_context->wispr_msg.response_code);
622 if (wp_context->wispr_msg.access_procedure)
623 DBG("Access procedure: %s",
624 wp_context->wispr_msg.access_procedure);
625 if (wp_context->wispr_msg.access_location)
626 DBG("Access location: %s",
627 wp_context->wispr_msg.access_location);
628 if (wp_context->wispr_msg.location_name)
629 DBG("Location name: %s",
630 wp_context->wispr_msg.location_name);
631 if (wp_context->wispr_msg.login_url)
632 DBG("Login URL: %s", wp_context->wispr_msg.login_url);
633 if (wp_context->wispr_msg.abort_login_url)
634 DBG("Abort login URL: %s",
635 wp_context->wispr_msg.abort_login_url);
636 if (wp_context->wispr_msg.logoff_url)
637 DBG("Logoff URL: %s", wp_context->wispr_msg.logoff_url);
639 switch (wp_context->wispr_msg.message_type) {
641 DBG("Login required");
643 wp_context->wispr_result = CONNMAN_WISPR_RESULT_LOGIN;
645 if (__connman_agent_request_login_input(wp_context->service,
646 wispr_portal_request_wispr_login,
647 wp_context) != -EINPROGRESS)
648 wispr_portal_error(wp_context);
653 case 120: /* Falling down */
655 if (wp_context->wispr_msg.response_code == 50) {
656 wp_context->wispr_result = CONNMAN_WISPR_RESULT_ONLINE;
658 g_free(wp_context->wispr_username);
659 wp_context->wispr_username = NULL;
661 g_free(wp_context->wispr_password);
662 wp_context->wispr_password = NULL;
664 g_free(wp_context->wispr_formdata);
665 wp_context->wispr_formdata = NULL;
667 wispr_portal_request_portal(wp_context);
671 wispr_portal_error(wp_context);
681 static bool wispr_portal_web_result(GWebResult *result, gpointer user_data)
683 struct connman_wispr_portal_context *wp_context = user_data;
684 const char *redirect = NULL;
685 const guint8 *chunk = NULL;
686 const char *str = NULL;
692 if (wp_context->wispr_result != CONNMAN_WISPR_RESULT_ONLINE) {
693 g_web_result_get_chunk(result, &chunk, &length);
696 g_web_parser_feed_data(wp_context->wispr_parser,
701 g_web_parser_end_data(wp_context->wispr_parser);
703 if (wp_context->wispr_msg.message_type >= 0) {
704 if (wispr_manage_message(result, wp_context))
709 status = g_web_result_get_status(result);
711 DBG("status: %03u", status);
715 __connman_agent_request_browser(wp_context->service,
716 wispr_portal_browser_reply_cb,
717 wp_context->status_url, wp_context);
720 if (wp_context->wispr_msg.message_type >= 0)
723 if (g_web_result_get_header(result, "X-ConnMan-Status",
725 portal_manage_status(result, wp_context);
728 __connman_agent_request_browser(wp_context->service,
729 wispr_portal_browser_reply_cb,
730 wp_context->redirect_url, wp_context);
734 if (!g_web_supports_tls() ||
735 !g_web_result_get_header(result, "Location",
738 __connman_agent_request_browser(wp_context->service,
739 wispr_portal_browser_reply_cb,
740 wp_context->status_url, wp_context);
744 DBG("Redirect URL: %s", redirect);
746 wp_context->redirect_url = g_strdup(redirect);
748 wp_context->request_id = g_web_request_get(wp_context->web,
749 redirect, wispr_portal_web_result,
750 wispr_route_request, wp_context);
755 if (__connman_service_online_check_failed(wp_context->service,
756 wp_context->type) == 0) {
757 wispr_portal_error(wp_context);
758 free_connman_wispr_portal_context(wp_context);
764 __connman_agent_request_browser(wp_context->service,
765 wispr_portal_browser_reply_cb,
766 wp_context->status_url, wp_context);
772 free_wispr_routes(wp_context);
773 wp_context->request_id = 0;
775 wp_context->wispr_msg.message_type = -1;
779 static void proxy_callback(const char *proxy, void *user_data)
781 struct connman_wispr_portal_context *wp_context = user_data;
783 DBG("proxy %s", proxy);
788 wp_context->token = 0;
790 if (proxy && g_strcmp0(proxy, "DIRECT") != 0) {
791 if (g_str_has_prefix(proxy, "PROXY")) {
793 for (; *proxy == ' ' && *proxy != '\0'; proxy++);
795 g_web_set_proxy(wp_context->web, proxy);
798 g_web_set_accept(wp_context->web, NULL);
799 g_web_set_user_agent(wp_context->web, "ConnMan/%s wispr", VERSION);
800 g_web_set_close_connection(wp_context->web, TRUE);
802 connman_wispr_message_init(&wp_context->wispr_msg);
804 wp_context->wispr_parser = g_web_parser_new(
805 "<WISPAccessGatewayParam",
806 "WISPAccessGatewayParam>",
807 xml_wispr_parser_callback, wp_context);
809 wispr_portal_request_portal(wp_context);
812 static gboolean no_proxy_callback(gpointer user_data)
814 struct connman_wispr_portal_context *wp_context = user_data;
816 wp_context->timeout = 0;
818 proxy_callback("DIRECT", wp_context);
823 static int wispr_portal_detect(struct connman_wispr_portal_context *wp_context)
825 enum connman_service_proxy_method proxy_method;
826 enum connman_service_type service_type;
827 char *interface = NULL;
828 char **nameservers = NULL;
833 DBG("wispr/portal context %p", wp_context);
834 DBG("service %p", wp_context->service);
836 service_type = connman_service_get_type(wp_context->service);
838 switch (service_type) {
839 case CONNMAN_SERVICE_TYPE_ETHERNET:
840 case CONNMAN_SERVICE_TYPE_WIFI:
841 case CONNMAN_SERVICE_TYPE_BLUETOOTH:
842 case CONNMAN_SERVICE_TYPE_CELLULAR:
843 case CONNMAN_SERVICE_TYPE_GADGET:
845 case CONNMAN_SERVICE_TYPE_UNKNOWN:
846 case CONNMAN_SERVICE_TYPE_SYSTEM:
847 case CONNMAN_SERVICE_TYPE_GPS:
848 case CONNMAN_SERVICE_TYPE_VPN:
849 case CONNMAN_SERVICE_TYPE_P2P:
853 interface = connman_service_get_interface(wp_context->service);
857 DBG("interface %s", interface);
859 if_index = connman_inet_ifindex(interface);
861 DBG("Could not get ifindex");
866 nameservers = connman_service_get_nameservers(wp_context->service);
868 DBG("Could not get nameservers");
873 wp_context->web = g_web_new(if_index);
874 if (!wp_context->web) {
875 DBG("Could not set up GWeb");
880 if (getenv("CONNMAN_WEB_DEBUG"))
881 g_web_set_debug(wp_context->web, web_debug, "WEB");
883 if (wp_context->type == CONNMAN_IPCONFIG_TYPE_IPV4) {
884 g_web_set_address_family(wp_context->web, AF_INET);
885 wp_context->status_url = STATUS_URL_IPV4;
887 g_web_set_address_family(wp_context->web, AF_INET6);
888 wp_context->status_url = STATUS_URL_IPV6;
891 for (i = 0; nameservers[i]; i++)
892 g_web_add_nameserver(wp_context->web, nameservers[i]);
894 proxy_method = connman_service_get_proxy_method(wp_context->service);
896 if (proxy_method != CONNMAN_SERVICE_PROXY_METHOD_DIRECT) {
897 wp_context->token = connman_proxy_lookup(interface,
898 wp_context->status_url,
900 proxy_callback, wp_context);
902 if (wp_context->token == 0) {
904 free_connman_wispr_portal_context(wp_context);
906 } else if (wp_context->timeout == 0) {
907 wp_context->timeout =
908 g_timeout_add_seconds(0, no_proxy_callback, wp_context);
912 g_strfreev(nameservers);
918 int __connman_wispr_start(struct connman_service *service,
919 enum connman_ipconfig_type type)
921 struct connman_wispr_portal_context *wp_context = NULL;
922 struct connman_wispr_portal *wispr_portal = NULL;
925 DBG("service %p", service);
927 if (!wispr_portal_list)
930 index = __connman_service_get_index(service);
934 wispr_portal = g_hash_table_lookup(wispr_portal_list,
935 GINT_TO_POINTER(index));
937 wispr_portal = g_try_new0(struct connman_wispr_portal, 1);
941 g_hash_table_replace(wispr_portal_list,
942 GINT_TO_POINTER(index), wispr_portal);
945 if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
946 wp_context = wispr_portal->ipv4_context;
947 else if (type == CONNMAN_IPCONFIG_TYPE_IPV6)
948 wp_context = wispr_portal->ipv6_context;
952 /* If there is already an existing context, we wipe it */
954 free_connman_wispr_portal_context(wp_context);
956 wp_context = create_wispr_portal_context();
960 wp_context->service = service;
961 wp_context->type = type;
962 wp_context->wispr_portal = wispr_portal;
964 if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
965 wispr_portal->ipv4_context = wp_context;
967 wispr_portal->ipv6_context = wp_context;
969 return wispr_portal_detect(wp_context);
972 void __connman_wispr_stop(struct connman_service *service)
976 DBG("service %p", service);
978 if (!wispr_portal_list)
981 index = __connman_service_get_index(service);
985 g_hash_table_remove(wispr_portal_list, GINT_TO_POINTER(index));
988 int __connman_wispr_init(void)
992 wispr_portal_list = g_hash_table_new_full(g_direct_hash,
993 g_direct_equal, NULL,
994 free_connman_wispr_portal);
999 void __connman_wispr_cleanup(void)
1003 g_hash_table_destroy(wispr_portal_list);
1004 wispr_portal_list = NULL;