From 0c07cbad2ee8450fbe8050bf6223a99e3f2e01a9 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sun, 8 May 2011 17:38:40 -0700 Subject: [PATCH] tools: Add support for WISPr authentication polling To log into a FON access point, the redirect site needs to be requested since it contains the 2nd stage authentication challenge. --- tools/wispr.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/tools/wispr.c b/tools/wispr.c index e43208d..7de9dbb 100644 --- a/tools/wispr.c +++ b/tools/wispr.c @@ -491,8 +491,24 @@ static gboolean wispr_result(GWebResult *result, gpointer user_data) g_print("elapse: %f seconds\n", elapsed); - if (wispr->msg.message_type < 0) - goto done; + if (wispr->msg.message_type < 0) { + const char *redirect; + + if (status != 302) + goto done; + + if (g_web_result_get_header(result, "Location", + &redirect) == FALSE) + goto done; + + printf("Redirect URL: %s\n", redirect); + printf("\n"); + + wispr->request = g_web_request_get(wispr->web, redirect, + wispr_result, wispr); + + return FALSE; + } printf("Message type: %s (%d)\n", message_type_to_string(wispr->msg.message_type), @@ -527,7 +543,8 @@ static gboolean wispr_result(GWebResult *result, gpointer user_data) g_idle_add(execute_login, wispr); return FALSE; - } else if (status == 200 && wispr->msg.message_type == 120) { + } else if (status == 200 && (wispr->msg.message_type == 120 || + wispr->msg.message_type == 140)) { int code = wispr->msg.response_code; printf("Login process: %s\n", code == 50 ? "SUCCESS" : "FAILURE"); -- 2.7.4