summaryrefslogtreecommitdiff
path: root/src/6to4.c
diff options
context:
space:
mode:
authorJukka Rissanen <jukka.rissanen@nokia.com>2011-03-25 15:03:16 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2011-03-25 14:46:04 +0100
commitb1fa5b81d18a7384dc75cbfdb9875c42ad34e86d (patch)
treea1ee10abd97ccfb338bb4e9aed120611cb82a4bb /src/6to4.c
parent6d667c5219aac6c701dc900d4b0c77d94fbadabc (diff)
downloadconnman-b1fa5b81d18a7384dc75cbfdb9875c42ad34e86d.tar.gz
connman-b1fa5b81d18a7384dc75cbfdb9875c42ad34e86d.tar.bz2
connman-b1fa5b81d18a7384dc75cbfdb9875c42ad34e86d.zip
6to4: Check the connectivity via tunnel after creating it.
Diffstat (limited to 'src/6to4.c')
-rw-r--r--src/6to4.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/src/6to4.c b/src/6to4.c
index 767c8662..e6815a0e 100644
--- a/src/6to4.c
+++ b/src/6to4.c
@@ -40,10 +40,15 @@
#include "connman.h"
#include <connman/log.h>
#include <connman/ipconfig.h>
+#include "gweb/gweb.h"
static int tunnel_created;
static int tunnel_pending;
static char *tunnel_ip_address;
+static GWeb *web;
+static guint web_request_id;
+
+#define STATUS_URL "http://ipv6.google.com/"
#define NLMSG_TAIL(nmsg) \
((struct rtattr *) (((void *)(nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len)))
@@ -358,6 +363,35 @@ done:
return ret;
}
+static gboolean unref_web(gpointer user_data)
+{
+ g_web_unref(web);
+ return FALSE;
+}
+
+static gboolean web_result(GWebResult *result, gpointer user_data)
+{
+ guint16 status;
+
+ if (web_request_id == 0)
+ return FALSE;
+
+ status = g_web_result_get_status(result);
+
+ DBG("status %u", status);
+
+ if (status >= 400 && status < 500)
+ tunnel_destroy();
+ else
+ tunnel_pending = 0;
+
+ web_request_id = 0;
+
+ g_timeout_add_seconds(1, unref_web, NULL);
+
+ return FALSE;
+}
+
static int init_6to4(struct in_addr *ip4addr)
{
unsigned int a, b, c, d;
@@ -391,7 +425,18 @@ static int init_6to4(struct in_addr *ip4addr)
if (ret)
goto error;
- tunnel_pending = 0;
+ /* We try to verify that connectivity through tunnel works ok.
+ */
+ web = g_web_new(0);
+ if (web == NULL)
+ goto error;
+
+ g_web_set_accept(web, NULL);
+ g_web_set_user_agent(web, "ConnMan/%s", VERSION);
+ g_web_set_close_connection(web, TRUE);
+
+ web_request_id = g_web_request_get(web, STATUS_URL, web_result, NULL);
+
return 0;
error: