summaryrefslogtreecommitdiff
path: root/gweb
diff options
context:
space:
mode:
authorPatrik Flykt <patrik.flykt@linux.intel.com>2012-04-27 17:33:13 +0300
committerMarcel Holtmann <marcel@holtmann.org>2012-04-27 16:45:01 +0200
commit747a5c4132ffdfd4cdf859c43c615feb0b787c7d (patch)
treebb1c9497f6b9a0532f00806e38f1fd3de5e14a95 /gweb
parent7faf6c0ccbd9ff8f4bccacb6b23c43e3f37c17e1 (diff)
downloadconnman-747a5c4132ffdfd4cdf859c43c615feb0b787c7d.tar.gz
connman-747a5c4132ffdfd4cdf859c43c615feb0b787c7d.tar.bz2
connman-747a5c4132ffdfd4cdf859c43c615feb0b787c7d.zip
gweb: Define GWebRouteFunc
Define GWebRouteFunc that will be called when a route to the intended destination may need to be set up.
Diffstat (limited to 'gweb')
-rw-r--r--gweb/gweb.c23
-rw-r--r--gweb/gweb.h6
2 files changed, 22 insertions, 7 deletions
diff --git a/gweb/gweb.c b/gweb/gweb.c
index 3db5dc55..fe28f798 100644
--- a/gweb/gweb.c
+++ b/gweb/gweb.c
@@ -98,6 +98,7 @@ struct web_session {
GWebResult result;
GWebResultFunc result_func;
+ GWebRouteFunc route_func;
GWebInputFunc input_func;
int fd;
gsize length;
@@ -442,6 +443,13 @@ static inline void call_result_func(struct web_session *session, guint16 status)
result == TRUE ? "continue" : "stop");
}
+static inline void call_route_func(struct web_session *session)
+{
+ if (session->route_func != NULL)
+ session->route_func(session->address, session->addr->ai_family,
+ session->web->index, session->user_data);
+}
+
static gboolean process_send_buffer(struct web_session *session)
{
GString *buf;
@@ -1212,6 +1220,7 @@ static void resolv_result(GResolvResultStatus status,
}
session->address = g_strdup(results[0]);
+ call_route_func(session);
if (create_transport(session) < 0) {
call_result_func(session, 409);
@@ -1222,7 +1231,7 @@ static void resolv_result(GResolvResultStatus status,
static guint do_request(GWeb *web, const char *url,
const char *type, GWebInputFunc input,
int fd, gsize length, GWebResultFunc func,
- gpointer user_data)
+ GWebRouteFunc route, gpointer user_data)
{
struct web_session *session;
@@ -1255,6 +1264,7 @@ static guint do_request(GWeb *web, const char *url,
session->web = web;
session->result_func = func;
+ session->route_func = route;
session->input_func = input;
session->fd = fd;
session->length = length;
@@ -1324,17 +1334,17 @@ static guint do_request(GWeb *web, const char *url,
return web->next_query_id++;
}
-guint g_web_request_get(GWeb *web, const char *url,
- GWebResultFunc func, gpointer user_data)
+guint g_web_request_get(GWeb *web, const char *url, GWebResultFunc func,
+ GWebRouteFunc route, gpointer user_data)
{
- return do_request(web, url, NULL, NULL, -1, 0, func, user_data);
+ return do_request(web, url, NULL, NULL, -1, 0, func, route, user_data);
}
guint g_web_request_post(GWeb *web, const char *url,
const char *type, GWebInputFunc input,
GWebResultFunc func, gpointer user_data)
{
- return do_request(web, url, type, input, -1, 0, func, user_data);
+ return do_request(web, url, type, input, -1, 0, func, NULL, user_data);
}
guint g_web_request_post_file(GWeb *web, const char *url,
@@ -1352,7 +1362,8 @@ guint g_web_request_post_file(GWeb *web, const char *url,
if (fd < 0)
return 0;
- ret = do_request(web, url, type, NULL, fd, st.st_size, func, user_data);
+ ret = do_request(web, url, type, NULL, fd, st.st_size, func, NULL,
+ user_data);
if (ret == 0)
close(fd);
diff --git a/gweb/gweb.h b/gweb/gweb.h
index 56405d2a..d6ed942c 100644
--- a/gweb/gweb.h
+++ b/gweb/gweb.h
@@ -40,6 +40,9 @@ typedef struct _GWebParser GWebParser;
typedef gboolean (*GWebResultFunc)(GWebResult *result, gpointer user_data);
+typedef gboolean (*GWebRouteFunc)(const char *addr, int ai_family,
+ int if_index, gpointer user_data);
+
typedef gboolean (*GWebInputFunc)(const guint8 **data, gsize *length,
gpointer user_data);
@@ -70,7 +73,8 @@ void g_web_set_close_connection(GWeb *web, gboolean enabled);
gboolean g_web_get_close_connection(GWeb *web);
guint g_web_request_get(GWeb *web, const char *url,
- GWebResultFunc func, gpointer user_data);
+ GWebResultFunc func, GWebRouteFunc route,
+ gpointer user_data);
guint g_web_request_post(GWeb *web, const char *url,
const char *type, GWebInputFunc input,
GWebResultFunc func, gpointer user_data);