From: Samuel Ortiz Date: Mon, 26 Jul 2010 10:17:41 +0000 (+0200) Subject: Start ondemand connection when getting a DNS request while disconnected X-Git-Tag: 0.56~104 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=635d63a7693cc82feaf8b94f6f90ae1f3e17595c;p=platform%2Fupstream%2Fconnman.git Start ondemand connection when getting a DNS request while disconnected --- diff --git a/plugins/dnsproxy.c b/plugins/dnsproxy.c index 5368ceb..04cb2ac 100644 --- a/plugins/dnsproxy.c +++ b/plugins/dnsproxy.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -684,7 +685,8 @@ static gboolean listener_event(GIOChannel *channel, GIOCondition condition, DBG("Received %d bytes (id 0x%04x)", len, buf[0] | buf[1] << 8); err = parse_request(buf, len, query, sizeof(query)); - if (err < 0 || g_slist_length(server_list) == 0) { + if (err < 0 || (g_slist_length(server_list) == 0 && + connman_ondemand_connected())) { send_response(sk, buf, len, (struct sockaddr *) &sin, size); return TRUE; } @@ -708,6 +710,33 @@ static gboolean listener_event(GIOChannel *channel, GIOCondition condition, buf[0] = req->dstid & 0xff; buf[1] = req->dstid >> 8; + if (!connman_ondemand_connected()) { + DBG("Starting on demand connection"); + /* + * We're not connected, let's queue the request and start + * an on-demand connection. + */ + req->request = g_try_malloc0(req->request_len); + if (req->request == NULL) + return TRUE; + + memcpy(req->request, buf, req->request_len); + + req->name = g_try_malloc0(sizeof(query)); + if (req->name == NULL) { + g_free(req->request); + return TRUE; + } + memcpy(req->name, query, sizeof(query)); + + request_pending_list = g_slist_append(request_pending_list, + req); + + connman_ondemand_start("", 300); + + return TRUE; + } + return resolv(req, buf, query); }