summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>2011-06-22 09:28:54 +0300
committerSamuel Ortiz <sameo@linux.intel.com>2011-06-27 16:15:08 +0200
commit4d6fdeeb29d9c78ce99f54c6f7d01e6177706cad (patch)
treea71e16cf3d18aa68f82175d13be3984c06f24572
parentb3eb89368c50be00119171f577e3b4c86c5464ab (diff)
downloadconnman-4d6fdeeb29d9c78ce99f54c6f7d01e6177706cad.tar.gz
connman-4d6fdeeb29d9c78ce99f54c6f7d01e6177706cad.tar.bz2
connman-4d6fdeeb29d9c78ce99f54c6f7d01e6177706cad.zip
gweb: added the capability to restrict the requests to a specific address family.
-rw-r--r--gweb/gweb.c19
-rw-r--r--gweb/gweb.h2
2 files changed, 21 insertions, 0 deletions
diff --git a/gweb/gweb.c b/gweb/gweb.c
index 1183cc6b..536de006 100644
--- a/gweb/gweb.c
+++ b/gweb/gweb.c
@@ -101,6 +101,8 @@ struct _GWeb {
guint next_query_id;
+ int family;
+
int index;
GList *session_list;
@@ -203,6 +205,8 @@ GWeb *g_web_new(int index)
web->next_query_id = 1;
+ web->family = AF_UNSPEC;
+
web->index = index;
web->session_list = NULL;
@@ -280,6 +284,19 @@ gboolean g_web_set_proxy(GWeb *web, const char *proxy)
return TRUE;
}
+gboolean g_web_set_address_family(GWeb *web, int family)
+{
+ if (web == NULL)
+ return FALSE;
+
+ if (family != AF_UNSPEC && family != AF_INET && family != AF_INET6)
+ return FALSE;
+
+ web->family = family;
+
+ return TRUE;
+}
+
gboolean g_web_add_nameserver(GWeb *web, const char *address)
{
if (web == NULL)
@@ -1059,6 +1076,7 @@ static void resolv_result(GResolvResultStatus status,
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_flags = AI_NUMERICHOST;
+ hints.ai_family = session->web->family;
if (session->addr != NULL) {
freeaddrinfo(session->addr);
@@ -1155,6 +1173,7 @@ static guint do_request(GWeb *web, const char *url,
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_flags = AI_NUMERICHOST;
+ hints.ai_family = session->web->family;
if (session->addr != NULL) {
freeaddrinfo(session->addr);
diff --git a/gweb/gweb.h b/gweb/gweb.h
index 3a76778d..cfeceb63 100644
--- a/gweb/gweb.h
+++ b/gweb/gweb.h
@@ -54,6 +54,8 @@ void g_web_set_debug(GWeb *web, GWebDebugFunc func, gpointer user_data);
gboolean g_web_set_proxy(GWeb *web, const char *proxy);
+gboolean g_web_set_address_family(GWeb *web, int family);
+
gboolean g_web_add_nameserver(GWeb *web, const char *address);
gboolean g_web_set_accept(GWeb *web, const char *format, ...)