5 * Copyright (C) 2007-2012 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;
88 struct connman_wispr_portal {
89 struct connman_wispr_portal_context *ipv4_context;
90 struct connman_wispr_portal_context *ipv6_context;
93 static gboolean wispr_portal_web_result(GWebResult *result, gpointer user_data);
95 static GHashTable *wispr_portal_list = NULL;
97 static void connman_wispr_message_init(struct connman_wispr_message *msg)
101 msg->has_error = FALSE;
102 msg->current_element = NULL;
104 msg->message_type = -1;
105 msg->response_code = -1;
107 g_free(msg->login_url);
108 msg->login_url = NULL;
110 g_free(msg->abort_login_url);
111 msg->abort_login_url = NULL;
113 g_free(msg->logoff_url);
114 msg->logoff_url = NULL;
116 g_free(msg->access_procedure);
117 msg->access_procedure = NULL;
119 g_free(msg->access_location);
120 msg->access_location = NULL;
122 g_free(msg->location_name);
123 msg->location_name = NULL;
126 static void free_wispr_routes(struct connman_wispr_portal_context *wp_context)
128 while (wp_context->route_list != NULL) {
129 struct wispr_route *route = wp_context->route_list->data;
131 DBG("free route to %s if %d type %d", route->address,
132 route->if_index, wp_context->type);
134 switch(wp_context->type) {
135 case CONNMAN_IPCONFIG_TYPE_IPV4:
136 connman_inet_del_host_route(route->if_index,
139 case CONNMAN_IPCONFIG_TYPE_IPV6:
140 connman_inet_del_ipv6_host_route(route->if_index,
143 case CONNMAN_IPCONFIG_TYPE_UNKNOWN:
147 g_free(route->address);
150 wp_context->route_list =
151 g_slist_delete_link(wp_context->route_list,
152 wp_context->route_list);
156 static void free_connman_wispr_portal_context(struct connman_wispr_portal_context *wp_context)
158 DBG("context %p", wp_context);
160 if (wp_context == NULL)
163 if (wp_context->wispr_portal != NULL) {
164 if (wp_context->wispr_portal->ipv4_context == wp_context)
165 wp_context->wispr_portal->ipv4_context = NULL;
167 if (wp_context->wispr_portal->ipv6_context == wp_context)
168 wp_context->wispr_portal->ipv6_context = NULL;
171 if (wp_context->token > 0)
172 connman_proxy_lookup_cancel(wp_context->token);
174 if (wp_context->request_id > 0)
175 g_web_cancel_request(wp_context->web, wp_context->request_id);
177 if (wp_context->web != NULL)
178 g_web_unref(wp_context->web);
180 g_free(wp_context->redirect_url);
182 if (wp_context->wispr_parser != NULL)
183 g_web_parser_unref(wp_context->wispr_parser);
185 connman_wispr_message_init(&wp_context->wispr_msg);
187 g_free(wp_context->wispr_username);
188 g_free(wp_context->wispr_password);
189 g_free(wp_context->wispr_formdata);
191 free_wispr_routes(wp_context);
196 static struct connman_wispr_portal_context *create_wispr_portal_context(void)
198 return g_try_new0(struct connman_wispr_portal_context, 1);
201 static void free_connman_wispr_portal(gpointer data)
203 struct connman_wispr_portal *wispr_portal = data;
207 if (wispr_portal == NULL)
210 free_connman_wispr_portal_context(wispr_portal->ipv4_context);
211 free_connman_wispr_portal_context(wispr_portal->ipv6_context);
213 g_free(wispr_portal);
216 static const char *message_type_to_string(int message_type)
218 switch (message_type) {
220 return "Initial redirect message";
222 return "Proxy notification";
224 return "Authentication notification";
226 return "Logoff notification";
228 return "Response to Authentication Poll";
230 return "Response to Abort Login";
236 static const char *response_code_to_string(int response_code)
238 switch (response_code) {
242 return "Login succeeded";
244 return "Login failed";
246 return "RADIUS server error/timeout";
248 return "RADIUS server not enabled";
250 return "Logoff succeeded";
252 return "Login aborted";
254 return "Proxy detection/repeat operation";
256 return "Authentication pending";
258 return "Access gateway internal error";
267 WISPR_ELEMENT_NONE = 0,
268 WISPR_ELEMENT_ACCESS_PROCEDURE = 1,
269 WISPR_ELEMENT_ACCESS_LOCATION = 2,
270 WISPR_ELEMENT_LOCATION_NAME = 3,
271 WISPR_ELEMENT_LOGIN_URL = 4,
272 WISPR_ELEMENT_ABORT_LOGIN_URL = 5,
273 WISPR_ELEMENT_MESSAGE_TYPE = 6,
274 WISPR_ELEMENT_RESPONSE_CODE = 7,
275 WISPR_ELEMENT_NEXT_URL = 8,
276 WISPR_ELEMENT_DELAY = 9,
277 WISPR_ELEMENT_REPLY_MESSAGE = 10,
278 WISPR_ELEMENT_LOGIN_RESULTS_URL = 11,
279 WISPR_ELEMENT_LOGOFF_URL = 12,
281 } wispr_element_map[] = {
282 { "AccessProcedure", WISPR_ELEMENT_ACCESS_PROCEDURE },
283 { "AccessLocation", WISPR_ELEMENT_ACCESS_LOCATION },
284 { "LocationName", WISPR_ELEMENT_LOCATION_NAME },
285 { "LoginURL", WISPR_ELEMENT_LOGIN_URL },
286 { "AbortLoginURL", WISPR_ELEMENT_ABORT_LOGIN_URL },
287 { "MessageType", WISPR_ELEMENT_MESSAGE_TYPE },
288 { "ResponseCode", WISPR_ELEMENT_RESPONSE_CODE },
289 { "NextURL", WISPR_ELEMENT_NEXT_URL },
290 { "Delay", WISPR_ELEMENT_DELAY },
291 { "ReplyMessage", WISPR_ELEMENT_REPLY_MESSAGE },
292 { "LoginResultsURL", WISPR_ELEMENT_LOGIN_RESULTS_URL },
293 { "LogoffURL", WISPR_ELEMENT_LOGOFF_URL },
294 { NULL, WISPR_ELEMENT_NONE },
297 static void xml_wispr_start_element_handler(GMarkupParseContext *context,
298 const gchar *element_name,
299 const gchar **attribute_names,
300 const gchar **attribute_values,
301 gpointer user_data, GError **error)
303 struct connman_wispr_message *msg = user_data;
305 msg->current_element = element_name;
308 static void xml_wispr_end_element_handler(GMarkupParseContext *context,
309 const gchar *element_name,
310 gpointer user_data, GError **error)
312 struct connman_wispr_message *msg = user_data;
314 msg->current_element = NULL;
317 static void xml_wispr_text_handler(GMarkupParseContext *context,
318 const gchar *text, gsize text_len,
319 gpointer user_data, GError **error)
321 struct connman_wispr_message *msg = user_data;
324 if (msg->current_element == NULL)
327 for (i = 0; wispr_element_map[i].str; i++) {
328 if (g_str_equal(wispr_element_map[i].str,
329 msg->current_element) == FALSE)
332 switch (wispr_element_map[i].element) {
333 case WISPR_ELEMENT_NONE:
334 case WISPR_ELEMENT_ACCESS_PROCEDURE:
335 g_free(msg->access_procedure);
336 msg->access_procedure = g_strdup(text);
338 case WISPR_ELEMENT_ACCESS_LOCATION:
339 g_free(msg->access_location);
340 msg->access_location = g_strdup(text);
342 case WISPR_ELEMENT_LOCATION_NAME:
343 g_free(msg->location_name);
344 msg->location_name = g_strdup(text);
346 case WISPR_ELEMENT_LOGIN_URL:
347 g_free(msg->login_url);
348 msg->login_url = g_strdup(text);
350 case WISPR_ELEMENT_ABORT_LOGIN_URL:
351 g_free(msg->abort_login_url);
352 msg->abort_login_url = g_strdup(text);
354 case WISPR_ELEMENT_MESSAGE_TYPE:
355 msg->message_type = atoi(text);
357 case WISPR_ELEMENT_RESPONSE_CODE:
358 msg->response_code = atoi(text);
360 case WISPR_ELEMENT_NEXT_URL:
361 case WISPR_ELEMENT_DELAY:
362 case WISPR_ELEMENT_REPLY_MESSAGE:
363 case WISPR_ELEMENT_LOGIN_RESULTS_URL:
365 case WISPR_ELEMENT_LOGOFF_URL:
366 g_free(msg->logoff_url);
367 msg->logoff_url = g_strdup(text);
373 static void xml_wispr_error_handler(GMarkupParseContext *context,
374 GError *error, gpointer user_data)
376 struct connman_wispr_message *msg = user_data;
378 msg->has_error = TRUE;
381 static const GMarkupParser xml_wispr_parser_handlers = {
382 xml_wispr_start_element_handler,
383 xml_wispr_end_element_handler,
384 xml_wispr_text_handler,
386 xml_wispr_error_handler,
389 static void xml_wispr_parser_callback(const char *str, gpointer user_data)
391 struct connman_wispr_portal_context *wp_context = user_data;
392 GMarkupParseContext *parser_context = NULL;
397 parser_context = g_markup_parse_context_new(&xml_wispr_parser_handlers,
398 G_MARKUP_TREAT_CDATA_AS_TEXT,
399 &(wp_context->wispr_msg), NULL);
401 result = g_markup_parse_context_parse(parser_context,
402 str, strlen(str), NULL);
404 g_markup_parse_context_end_parse(parser_context, NULL);
406 g_markup_parse_context_free(parser_context);
409 static void web_debug(const char *str, void *data)
411 connman_info("%s: %s\n", (const char *) data, str);
414 static void wispr_portal_error(struct connman_wispr_portal_context *wp_context)
416 DBG("Failed to proceed wispr/portal web request");
418 wp_context->wispr_result = CONNMAN_WISPR_RESULT_FAILED;
421 static void portal_manage_status(GWebResult *result,
422 struct connman_wispr_portal_context *wp_context)
424 const char *str = NULL;
428 /* We currently don't do anything with this info */
429 if (g_web_result_get_header(result, "X-ConnMan-Client-IP",
431 connman_info("Client-IP: %s", str);
433 if (g_web_result_get_header(result, "X-ConnMan-Client-Country",
435 connman_info("Client-Country: %s", str);
437 if (g_web_result_get_header(result, "X-ConnMan-Client-Region",
439 connman_info("Client-Region: %s", str);
441 __connman_service_ipconfig_indicate_state(wp_context->service,
442 CONNMAN_SERVICE_STATE_ONLINE,
446 static gboolean wispr_route_request(const char *address, int ai_family,
447 int if_index, gpointer user_data)
450 struct connman_wispr_portal_context *wp_context = user_data;
452 struct wispr_route *route;
454 gateway = __connman_ipconfig_get_gateway_from_index(if_index,
457 DBG("address %s if %d gw %s", address, if_index, gateway);
462 route = g_try_new0(struct wispr_route, 1);
464 DBG("could not create struct");
468 switch(wp_context->type) {
469 case CONNMAN_IPCONFIG_TYPE_IPV4:
470 result = connman_inet_add_host_route(if_index, address,
473 case CONNMAN_IPCONFIG_TYPE_IPV6:
474 result = connman_inet_add_ipv6_host_route(if_index, address,
477 case CONNMAN_IPCONFIG_TYPE_UNKNOWN:
486 route->address = g_strdup(address);
487 route->if_index = if_index;
488 wp_context->route_list = g_slist_prepend(wp_context->route_list, route);
493 static void wispr_portal_request_portal(struct connman_wispr_portal_context *wp_context)
497 wp_context->request_id = g_web_request_get(wp_context->web,
498 wp_context->status_url,
499 wispr_portal_web_result,
503 if (wp_context->request_id == 0)
504 wispr_portal_error(wp_context);
507 static gboolean wispr_input(const guint8 **data, gsize *length,
510 struct connman_wispr_portal_context *wp_context = user_data;
516 buf = g_string_sized_new(100);
518 g_string_append(buf, "button=Login&UserName=");
519 g_string_append_uri_escaped(buf, wp_context->wispr_username,
521 g_string_append(buf, "&Password=");
522 g_string_append_uri_escaped(buf, wp_context->wispr_password,
524 g_string_append(buf, "&FNAME=0&OriginatingServer=");
525 g_string_append_uri_escaped(buf, wp_context->status_url, NULL, FALSE);
529 g_free(wp_context->wispr_formdata);
530 wp_context->wispr_formdata = g_string_free(buf, FALSE);
532 *data = (guint8 *) wp_context->wispr_formdata;
538 static void wispr_portal_browser_reply_cb(struct connman_service *service,
539 connman_bool_t authentication_done,
540 const char *error, void *user_data)
542 struct connman_wispr_portal_context *wp_context = user_data;
546 if (service == NULL || wp_context == NULL)
549 if (authentication_done == FALSE) {
550 wispr_portal_error(wp_context);
551 free_wispr_routes(wp_context);
555 /* Restarting the test */
556 __connman_wispr_start(service, wp_context->type);
559 static void wispr_portal_request_wispr_login(struct connman_service *service,
560 connman_bool_t success,
561 const char *ssid, int ssid_len,
562 const char *username, const char *password,
563 gboolean wps, const char *wpspin,
564 const char *error, void *user_data)
566 struct connman_wispr_portal_context *wp_context = user_data;
572 "net.connman.Agent.Error.LaunchBrowser") == 0) {
573 if (__connman_agent_request_browser(service,
574 wispr_portal_browser_reply_cb,
575 wp_context->redirect_url,
576 wp_context) != -EINPROGRESS)
577 free_connman_wispr_portal_context(wp_context);
579 free_connman_wispr_portal_context(wp_context);
584 g_free(wp_context->wispr_username);
585 wp_context->wispr_username = g_strdup(username);
587 g_free(wp_context->wispr_password);
588 wp_context->wispr_password = g_strdup(password);
590 wp_context->request_id = g_web_request_post(wp_context->web,
591 wp_context->wispr_msg.login_url,
592 "application/x-www-form-urlencoded",
593 wispr_input, wispr_portal_web_result,
596 connman_wispr_message_init(&wp_context->wispr_msg);
599 static gboolean wispr_manage_message(GWebResult *result,
600 struct connman_wispr_portal_context *wp_context)
602 DBG("Message type: %s (%d)",
603 message_type_to_string(wp_context->wispr_msg.message_type),
604 wp_context->wispr_msg.message_type);
605 DBG("Response code: %s (%d)",
606 response_code_to_string(wp_context->wispr_msg.response_code),
607 wp_context->wispr_msg.response_code);
609 if (wp_context->wispr_msg.access_procedure != NULL)
610 DBG("Access procedure: %s",
611 wp_context->wispr_msg.access_procedure);
612 if (wp_context->wispr_msg.access_location != NULL)
613 DBG("Access location: %s",
614 wp_context->wispr_msg.access_location);
615 if (wp_context->wispr_msg.location_name != NULL)
616 DBG("Location name: %s",
617 wp_context->wispr_msg.location_name);
618 if (wp_context->wispr_msg.login_url != NULL)
619 DBG("Login URL: %s", wp_context->wispr_msg.login_url);
620 if (wp_context->wispr_msg.abort_login_url != NULL)
621 DBG("Abort login URL: %s",
622 wp_context->wispr_msg.abort_login_url);
623 if (wp_context->wispr_msg.logoff_url != NULL)
624 DBG("Logoff URL: %s", wp_context->wispr_msg.logoff_url);
626 switch (wp_context->wispr_msg.message_type) {
628 DBG("Login required");
630 wp_context->wispr_result = CONNMAN_WISPR_RESULT_LOGIN;
632 if (__connman_agent_request_login_input(wp_context->service,
633 wispr_portal_request_wispr_login,
634 wp_context) != -EINPROGRESS) {
635 wispr_portal_error(wp_context);
636 free_connman_wispr_portal_context(wp_context);
640 case 120: /* Falling down */
642 if (wp_context->wispr_msg.response_code == 50) {
643 wp_context->wispr_result = CONNMAN_WISPR_RESULT_ONLINE;
645 g_free(wp_context->wispr_username);
646 wp_context->wispr_username = NULL;
648 g_free(wp_context->wispr_password);
649 wp_context->wispr_password = NULL;
651 g_free(wp_context->wispr_formdata);
652 wp_context->wispr_formdata = NULL;
654 wispr_portal_request_portal(wp_context);
658 wispr_portal_error(wp_context);
668 static gboolean wispr_portal_web_result(GWebResult *result, gpointer user_data)
670 struct connman_wispr_portal_context *wp_context = user_data;
671 const char *redirect = NULL;
672 const guint8 *chunk = NULL;
673 const char *str = NULL;
679 if (wp_context->wispr_result != CONNMAN_WISPR_RESULT_ONLINE) {
680 g_web_result_get_chunk(result, &chunk, &length);
683 g_web_parser_feed_data(wp_context->wispr_parser,
688 g_web_parser_end_data(wp_context->wispr_parser);
690 if (wp_context->wispr_msg.message_type >= 0) {
691 if (wispr_manage_message(result, wp_context) == TRUE)
696 status = g_web_result_get_status(result);
698 DBG("status: %03u", status);
702 if (wp_context->wispr_msg.message_type >= 0)
705 if (g_web_result_get_header(result, "X-ConnMan-Status",
707 portal_manage_status(result, wp_context);
708 free_connman_wispr_portal_context(wp_context);
712 __connman_agent_request_browser(wp_context->service,
713 wispr_portal_browser_reply_cb,
714 wp_context->redirect_url, wp_context);
718 if (g_web_supports_tls() == FALSE ||
719 g_web_result_get_header(result, "Location",
720 &redirect) == FALSE) {
722 __connman_agent_request_browser(wp_context->service,
723 wispr_portal_browser_reply_cb,
724 wp_context->status_url, wp_context);
728 DBG("Redirect URL: %s", redirect);
730 wp_context->redirect_url = g_strdup(redirect);
732 wp_context->request_id = g_web_request_get(wp_context->web,
733 redirect, wispr_portal_web_result,
734 wispr_route_request, wp_context);
739 if (__connman_service_online_check_failed(wp_context->service,
740 wp_context->type) == 0) {
741 wispr_portal_error(wp_context);
742 free_connman_wispr_portal_context(wp_context);
751 free_wispr_routes(wp_context);
752 wp_context->request_id = 0;
754 wp_context->wispr_msg.message_type = -1;
758 static void proxy_callback(const char *proxy, void *user_data)
760 struct connman_wispr_portal_context *wp_context = user_data;
762 DBG("proxy %s", proxy);
764 if (wp_context == NULL)
767 wp_context->token = 0;
769 if (proxy != NULL && g_strcmp0(proxy, "DIRECT") != 0)
770 g_web_set_proxy(wp_context->web, proxy);
772 g_web_set_accept(wp_context->web, NULL);
773 g_web_set_user_agent(wp_context->web, "ConnMan/%s wispr", VERSION);
774 g_web_set_close_connection(wp_context->web, TRUE);
776 connman_wispr_message_init(&wp_context->wispr_msg);
778 wp_context->wispr_parser = g_web_parser_new(
779 "<WISPAccessGatewayParam",
780 "WISPAccessGatewayParam>",
781 xml_wispr_parser_callback, wp_context);
783 wispr_portal_request_portal(wp_context);
786 static gboolean no_proxy_callback(gpointer user_data)
788 struct connman_wispr_portal_context *wp_context = user_data;
790 proxy_callback("DIRECT", wp_context);
795 static int wispr_portal_detect(struct connman_wispr_portal_context *wp_context)
797 enum connman_service_proxy_method proxy_method;
798 enum connman_service_type service_type;
799 char *interface = NULL;
800 char **nameservers = NULL;
805 DBG("wispr/portal context %p", wp_context);
806 DBG("service %p", wp_context->service);
808 service_type = connman_service_get_type(wp_context->service);
810 switch (service_type) {
811 case CONNMAN_SERVICE_TYPE_ETHERNET:
812 case CONNMAN_SERVICE_TYPE_WIFI:
813 case CONNMAN_SERVICE_TYPE_WIMAX:
814 case CONNMAN_SERVICE_TYPE_BLUETOOTH:
815 case CONNMAN_SERVICE_TYPE_CELLULAR:
817 case CONNMAN_SERVICE_TYPE_UNKNOWN:
818 case CONNMAN_SERVICE_TYPE_SYSTEM:
819 case CONNMAN_SERVICE_TYPE_GPS:
820 case CONNMAN_SERVICE_TYPE_VPN:
821 case CONNMAN_SERVICE_TYPE_GADGET:
825 interface = connman_service_get_interface(wp_context->service);
826 if (interface == NULL)
829 DBG("interface %s", interface);
831 if_index = connman_inet_ifindex(interface);
833 DBG("Could not get ifindex");
838 nameservers = connman_service_get_nameservers(wp_context->service);
839 if (nameservers == NULL) {
840 DBG("Could not get nameservers");
845 wp_context->web = g_web_new(if_index);
846 if (wp_context->web == NULL) {
847 DBG("Could not set up GWeb");
852 if (getenv("CONNMAN_WEB_DEBUG"))
853 g_web_set_debug(wp_context->web, web_debug, "WEB");
855 if (wp_context->type == CONNMAN_IPCONFIG_TYPE_IPV4) {
856 g_web_set_address_family(wp_context->web, AF_INET);
857 wp_context->status_url = STATUS_URL_IPV4;
859 g_web_set_address_family(wp_context->web, AF_INET6);
860 wp_context->status_url = STATUS_URL_IPV6;
863 for (i = 0; nameservers[i] != NULL; i++)
864 g_web_add_nameserver(wp_context->web, nameservers[i]);
866 proxy_method = connman_service_get_proxy_method(wp_context->service);
868 if (proxy_method != CONNMAN_SERVICE_PROXY_METHOD_DIRECT) {
869 wp_context->token = connman_proxy_lookup(interface,
870 wp_context->status_url,
872 proxy_callback, wp_context);
874 if (wp_context->token == 0) {
876 free_connman_wispr_portal_context(wp_context);
879 g_timeout_add_seconds(0, no_proxy_callback, wp_context);
883 g_strfreev(nameservers);
889 int __connman_wispr_start(struct connman_service *service,
890 enum connman_ipconfig_type type)
892 struct connman_wispr_portal_context *wp_context = NULL;
893 struct connman_wispr_portal *wispr_portal = NULL;
896 DBG("service %p", service);
898 if (wispr_portal_list == NULL)
901 index = __connman_service_get_index(service);
905 wispr_portal = g_hash_table_lookup(wispr_portal_list,
906 GINT_TO_POINTER(index));
907 if (wispr_portal == NULL) {
908 wispr_portal = g_try_new0(struct connman_wispr_portal, 1);
909 if (wispr_portal == NULL)
912 g_hash_table_replace(wispr_portal_list,
913 GINT_TO_POINTER(index), wispr_portal);
916 if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
917 wp_context = wispr_portal->ipv4_context;
918 else if (type == CONNMAN_IPCONFIG_TYPE_IPV6)
919 wp_context = wispr_portal->ipv6_context;
923 /* If there is already an existing context, we wipe it */
924 if (wp_context != NULL)
925 free_connman_wispr_portal_context(wp_context);
927 wp_context = create_wispr_portal_context();
928 if (wp_context == NULL)
931 wp_context->service = service;
932 wp_context->type = type;
933 wp_context->wispr_portal = wispr_portal;
935 if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
936 wispr_portal->ipv4_context = wp_context;
938 wispr_portal->ipv6_context = wp_context;
940 return wispr_portal_detect(wp_context);
943 void __connman_wispr_stop(struct connman_service *service)
947 DBG("service %p", service);
949 if (wispr_portal_list == NULL)
952 index = __connman_service_get_index(service);
956 g_hash_table_remove(wispr_portal_list, GINT_TO_POINTER(index));
959 int __connman_wispr_init(void)
963 wispr_portal_list = g_hash_table_new_full(g_direct_hash,
964 g_direct_equal, NULL,
965 free_connman_wispr_portal);
970 void __connman_wispr_cleanup(void)
974 g_hash_table_destroy(wispr_portal_list);
975 wispr_portal_list = NULL;