aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorwachs <wachs@140774ce-b5e7-0310-ab8b-a85725594a96>2013-01-17 16:21:37 +0000
committerwachs <wachs@140774ce-b5e7-0310-ab8b-a85725594a96>2013-01-17 16:21:37 +0000
commit9c7322f6568000d599769a9897ef08f18a439871 (patch)
treeb80fa2b600676749b8af173f0395e5fca6b0417e /src
parentf06312db792c3e3cf75e43cd8d966e672c246810 (diff)
address parsing
git-svn-id: https://gnunet.org/svn/gnunet@25817 140774ce-b5e7-0310-ab8b-a85725594a96
Diffstat (limited to 'src')
-rw-r--r--src/transport/Makefile.am11
-rw-r--r--src/transport/gnunet-service-transport_clients.c1
-rw-r--r--src/transport/plugin_transport_http_common.c75
-rw-r--r--src/transport/plugin_transport_http_common.h7
4 files changed, 92 insertions, 2 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am
index ef5517e013..3cf9f1c143 100644
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -316,6 +316,7 @@ check_PROGRAMS = \
test_plugin_udp \
$(UNIX_TEST) \
$(WLAN_PLUGIN_TEST) \
+ test_http_common \
$(HTTP_CLIENT_PLUGIN_TEST) \
$(HTTPS_CLIENT_PLUGIN_TEST) \
$(HTTP_SERVER_PLUGIN_TEST) \
@@ -493,6 +494,16 @@ test_plugin_wlan_LDADD = \
$(top_builddir)/src/util/libgnunetutil.la \
$(top_builddir)/src/transport/libgnunettransporttesting.la
+
+test_http_common_SOURCES = \
+ test_http_common.c plugin_transport_http_common.c
+test_http_common_LDADD = \
+ $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/statistics/libgnunetstatistics.la \
+ $(top_builddir)/src/hello/libgnunethello.la \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/transport/libgnunettransporttesting.la
+
test_plugin_http_server_SOURCES = \
test_plugin_transport.c
test_plugin_http_server_LDADD = \
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c
index f94814d41f..bdfcd1e89d 100644
--- a/src/transport/gnunet-service-transport_clients.c
+++ b/src/transport/gnunet-service-transport_clients.c
@@ -756,7 +756,6 @@ static void
transmit_address_to_client (void *cls, const char *buf)
{
struct AddressToStringContext *actx = cls;
-
if (NULL == buf)
{
GNUNET_SERVER_transmit_context_append_data (actx->tc, NULL, 0,
diff --git a/src/transport/plugin_transport_http_common.c b/src/transport/plugin_transport_http_common.c
index 5dd3413e1e..0c9bfffc8e 100644
--- a/src/transport/plugin_transport_http_common.c
+++ b/src/transport/plugin_transport_http_common.c
@@ -28,6 +28,80 @@
#include "gnunet_common.h"
#include "gnunet_transport_plugin.h"
+struct SplittedHTTPAddress
+{
+ char *protocoll;
+ char *host;
+ char *port;
+ char *path;
+};
+
+struct SplittedHTTPAddress *
+http_split_address (const char * addr)
+{
+ struct SplittedHTTPAddress *sp;
+ char *src = GNUNET_strdup (addr);
+ char *protocoll_start = NULL;
+ char *host_start = NULL;
+ char *port_start = NULL;
+ char *path_start = NULL;
+
+ protocoll_start = src;
+ sp = GNUNET_malloc (sizeof (struct SplittedHTTPAddress));
+
+ host_start = strstr (src, "://");
+ if (NULL == host_start)
+ {
+ GNUNET_free (src);
+ GNUNET_free (sp);
+ return NULL;
+ }
+
+ host_start[0] = '\0';
+ sp->protocoll = GNUNET_strdup (protocoll_start);
+
+ host_start += strlen ("://");
+ if (strlen (host_start) == 0)
+ if (NULL == host_start)
+ {
+ GNUNET_free (src);
+ GNUNET_free (sp);
+ return NULL;
+ }
+ port_start = strstr (host_start, ":");
+ if (NULL == port_start)
+ {
+ path_start = strstr (host_start, "/");
+ }
+ else
+ {
+ port_start[0] = '\0';
+ port_start ++;
+ sp->host = GNUNET_strdup (host_start);
+ path_start = strstr (port_start, "/");
+ }
+
+ if (NULL == path_start)
+ {
+ if (NULL != port_start)
+ sp->port = GNUNET_strdup (port_start);
+ sp->path = NULL;
+ }
+ else
+ {
+ if (NULL != port_start)
+ {
+ path_start[0] = '\0';
+ sp->port = GNUNET_strdup (port_start);
+ path_start[0] = '/';
+ }
+ sp->path = GNUNET_strdup(path_start);
+ }
+ GNUNET_free (src);
+ fprintf (stderr, "protocoll: `%s', host `%s' port `%s' path `%s'\n", sp->protocoll, sp->host, sp->port, sp->path);
+ return sp;
+}
+
/**
* Convert the transports address to a nice, human-readable
* format.
@@ -59,6 +133,7 @@ http_common_plugin_address_pretty_printer (void *cls, const char *type,
asc (asc_cls, NULL);
return;
}
+ http_split_address (addr);
asc (asc_cls, saddr);
asc (asc_cls, NULL);
}
diff --git a/src/transport/plugin_transport_http_common.h b/src/transport/plugin_transport_http_common.h
index 85793ce7fa..0cc6de5eec 100644
--- a/src/transport/plugin_transport_http_common.h
+++ b/src/transport/plugin_transport_http_common.h
@@ -26,7 +26,7 @@
#include "platform.h"
#include "gnunet_common.h"
-
+#include "gnunet_transport_plugin.h"
/**
* Timeout values for testing
*/
@@ -50,6 +50,11 @@
#endif
+struct SplittedHTTPAddress;
+
+struct SplittedHTTPAddress *
+http_split_address (const char * addr);
+
/**
* Convert the transports address to a nice, human-readable
* format.