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;
570 if (error != NULL && g_strcmp0(error,
571 "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);
582 g_free(wp_context->wispr_username);
583 wp_context->wispr_username = g_strdup(username);
585 g_free(wp_context->wispr_password);
586 wp_context->wispr_password = g_strdup(password);
588 wp_context->request_id = g_web_request_post(wp_context->web,
589 wp_context->wispr_msg.login_url,
590 "application/x-www-form-urlencoded",
591 wispr_input, wispr_portal_web_result,
594 connman_wispr_message_init(&wp_context->wispr_msg);
597 static gboolean wispr_manage_message(GWebResult *result,
598 struct connman_wispr_portal_context *wp_context)
600 DBG("Message type: %s (%d)",
601 message_type_to_string(wp_context->wispr_msg.message_type),
602 wp_context->wispr_msg.message_type);
603 DBG("Response code: %s (%d)",
604 response_code_to_string(wp_context->wispr_msg.response_code),
605 wp_context->wispr_msg.response_code);
607 if (wp_context->wispr_msg.access_procedure != NULL)
608 DBG("Access procedure: %s",
609 wp_context->wispr_msg.access_procedure);
610 if (wp_context->wispr_msg.access_location != NULL)
611 DBG("Access location: %s",
612 wp_context->wispr_msg.access_location);
613 if (wp_context->wispr_msg.location_name != NULL)
614 DBG("Location name: %s",
615 wp_context->wispr_msg.location_name);
616 if (wp_context->wispr_msg.login_url != NULL)
617 DBG("Login URL: %s", wp_context->wispr_msg.login_url);
618 if (wp_context->wispr_msg.abort_login_url != NULL)
619 DBG("Abort login URL: %s",
620 wp_context->wispr_msg.abort_login_url);
621 if (wp_context->wispr_msg.logoff_url != NULL)
622 DBG("Logoff URL: %s", wp_context->wispr_msg.logoff_url);
624 switch (wp_context->wispr_msg.message_type) {
626 DBG("Login required");
628 wp_context->wispr_result = CONNMAN_WISPR_RESULT_LOGIN;
630 if (__connman_agent_request_login_input(wp_context->service,
631 wispr_portal_request_wispr_login,
632 wp_context) != -EINPROGRESS) {
633 wispr_portal_error(wp_context);
634 free_connman_wispr_portal_context(wp_context);
638 case 120: /* Falling down */
640 if (wp_context->wispr_msg.response_code == 50) {
641 wp_context->wispr_result = CONNMAN_WISPR_RESULT_ONLINE;
643 g_free(wp_context->wispr_username);
644 wp_context->wispr_username = NULL;
646 g_free(wp_context->wispr_password);
647 wp_context->wispr_password = NULL;
649 g_free(wp_context->wispr_formdata);
650 wp_context->wispr_formdata = NULL;
652 wispr_portal_request_portal(wp_context);
656 wispr_portal_error(wp_context);
666 static gboolean wispr_portal_web_result(GWebResult *result, gpointer user_data)
668 struct connman_wispr_portal_context *wp_context = user_data;
669 const char *redirect = NULL;
670 const guint8 *chunk = NULL;
671 const char *str = NULL;
677 if (wp_context->wispr_result != CONNMAN_WISPR_RESULT_ONLINE) {
678 g_web_result_get_chunk(result, &chunk, &length);
681 g_web_parser_feed_data(wp_context->wispr_parser,
686 g_web_parser_end_data(wp_context->wispr_parser);
688 if (wp_context->wispr_msg.message_type >= 0) {
689 if (wispr_manage_message(result, wp_context) == TRUE)
694 status = g_web_result_get_status(result);
696 DBG("status: %03u", status);
700 if (wp_context->wispr_msg.message_type >= 0)
703 if (g_web_result_get_header(result, "X-ConnMan-Status",
705 portal_manage_status(result, wp_context);
706 free_connman_wispr_portal_context(wp_context);
710 __connman_agent_request_browser(wp_context->service,
711 wispr_portal_browser_reply_cb,
712 wp_context->redirect_url, wp_context);
716 if (g_web_supports_tls() == FALSE ||
717 g_web_result_get_header(result, "Location",
718 &redirect) == FALSE) {
720 __connman_agent_request_browser(wp_context->service,
721 wispr_portal_browser_reply_cb,
722 wp_context->status_url, wp_context);
726 DBG("Redirect URL: %s", redirect);
728 wp_context->redirect_url = g_strdup(redirect);
730 wp_context->request_id = g_web_request_get(wp_context->web,
731 redirect, wispr_portal_web_result,
732 wispr_route_request, wp_context);
737 if (__connman_service_online_check_failed(wp_context->service,
738 wp_context->type) == 0) {
739 wispr_portal_error(wp_context);
740 free_connman_wispr_portal_context(wp_context);
749 free_wispr_routes(wp_context);
750 wp_context->request_id = 0;
752 wp_context->wispr_msg.message_type = -1;
756 static void proxy_callback(const char *proxy, void *user_data)
758 struct connman_wispr_portal_context *wp_context = user_data;
760 DBG("proxy %s", proxy);
762 if (wp_context == NULL)
765 wp_context->token = 0;
767 if (proxy != NULL && g_strcmp0(proxy, "DIRECT") != 0)
768 g_web_set_proxy(wp_context->web, proxy);
770 g_web_set_accept(wp_context->web, NULL);
771 g_web_set_user_agent(wp_context->web, "ConnMan/%s wispr", VERSION);
772 g_web_set_close_connection(wp_context->web, TRUE);
774 connman_wispr_message_init(&wp_context->wispr_msg);
776 wp_context->wispr_parser = g_web_parser_new(
777 "<WISPAccessGatewayParam",
778 "WISPAccessGatewayParam>",
779 xml_wispr_parser_callback, wp_context);
781 wispr_portal_request_portal(wp_context);
784 static gboolean no_proxy_callback(gpointer user_data)
786 struct connman_wispr_portal_context *wp_context = user_data;
788 proxy_callback("DIRECT", wp_context);
793 static int wispr_portal_detect(struct connman_wispr_portal_context *wp_context)
795 enum connman_service_proxy_method proxy_method;
796 enum connman_service_type service_type;
797 char *interface = NULL;
798 char **nameservers = NULL;
803 DBG("wispr/portal context %p", wp_context);
804 DBG("service %p", wp_context->service);
806 service_type = connman_service_get_type(wp_context->service);
808 switch (service_type) {
809 case CONNMAN_SERVICE_TYPE_ETHERNET:
810 case CONNMAN_SERVICE_TYPE_WIFI:
811 case CONNMAN_SERVICE_TYPE_WIMAX:
812 case CONNMAN_SERVICE_TYPE_BLUETOOTH:
813 case CONNMAN_SERVICE_TYPE_CELLULAR:
815 case CONNMAN_SERVICE_TYPE_UNKNOWN:
816 case CONNMAN_SERVICE_TYPE_SYSTEM:
817 case CONNMAN_SERVICE_TYPE_GPS:
818 case CONNMAN_SERVICE_TYPE_VPN:
819 case CONNMAN_SERVICE_TYPE_GADGET:
823 interface = connman_service_get_interface(wp_context->service);
824 if (interface == NULL)
827 DBG("interface %s", interface);
829 if_index = connman_inet_ifindex(interface);
831 DBG("Could not get ifindex");
836 nameservers = connman_service_get_nameservers(wp_context->service);
837 if (nameservers == NULL) {
838 DBG("Could not get nameservers");
843 wp_context->web = g_web_new(if_index);
844 if (wp_context->web == NULL) {
845 DBG("Could not set up GWeb");
850 if (getenv("CONNMAN_WEB_DEBUG"))
851 g_web_set_debug(wp_context->web, web_debug, "WEB");
853 if (wp_context->type == CONNMAN_IPCONFIG_TYPE_IPV4) {
854 g_web_set_address_family(wp_context->web, AF_INET);
855 wp_context->status_url = STATUS_URL_IPV4;
857 g_web_set_address_family(wp_context->web, AF_INET6);
858 wp_context->status_url = STATUS_URL_IPV6;
861 for (i = 0; nameservers[i] != NULL; i++)
862 g_web_add_nameserver(wp_context->web, nameservers[i]);
864 proxy_method = connman_service_get_proxy_method(wp_context->service);
866 if (proxy_method != CONNMAN_SERVICE_PROXY_METHOD_DIRECT) {
867 wp_context->token = connman_proxy_lookup(interface,
868 wp_context->status_url,
870 proxy_callback, wp_context);
872 if (wp_context->token == 0) {
874 free_connman_wispr_portal_context(wp_context);
877 g_timeout_add_seconds(0, no_proxy_callback, wp_context);
881 g_strfreev(nameservers);
887 int __connman_wispr_start(struct connman_service *service,
888 enum connman_ipconfig_type type)
890 struct connman_wispr_portal_context *wp_context = NULL;
891 struct connman_wispr_portal *wispr_portal = NULL;
894 DBG("service %p", service);
896 if (wispr_portal_list == NULL)
899 index = __connman_service_get_index(service);
903 wispr_portal = g_hash_table_lookup(wispr_portal_list,
904 GINT_TO_POINTER(index));
905 if (wispr_portal == NULL) {
906 wispr_portal = g_try_new0(struct connman_wispr_portal, 1);
907 if (wispr_portal == NULL)
910 g_hash_table_replace(wispr_portal_list,
911 GINT_TO_POINTER(index), wispr_portal);
914 if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
915 wp_context = wispr_portal->ipv4_context;
916 else if (type == CONNMAN_IPCONFIG_TYPE_IPV6)
917 wp_context = wispr_portal->ipv6_context;
921 /* If there is already an existing context, we wipe it */
922 if (wp_context != NULL)
923 free_connman_wispr_portal_context(wp_context);
925 wp_context = create_wispr_portal_context();
926 if (wp_context == NULL)
929 wp_context->service = service;
930 wp_context->type = type;
931 wp_context->wispr_portal = wispr_portal;
933 if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
934 wispr_portal->ipv4_context = wp_context;
936 wispr_portal->ipv6_context = wp_context;
938 return wispr_portal_detect(wp_context);
941 void __connman_wispr_stop(struct connman_service *service)
945 DBG("service %p", service);
947 if (wispr_portal_list == NULL)
950 index = __connman_service_get_index(service);
954 g_hash_table_remove(wispr_portal_list, GINT_TO_POINTER(index));
957 int __connman_wispr_init(void)
961 wispr_portal_list = g_hash_table_new_full(g_direct_hash,
962 g_direct_equal, NULL,
963 free_connman_wispr_portal);
968 void __connman_wispr_cleanup(void)
972 g_hash_table_destroy(wispr_portal_list);
973 wispr_portal_list = NULL;