[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r25817 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r25817 - gnunet/src/transport |
Date: |
Thu, 17 Jan 2013 17:21:37 +0100 |
Author: wachs
Date: 2013-01-17 17:21:37 +0100 (Thu, 17 Jan 2013)
New Revision: 25817
Modified:
gnunet/src/transport/Makefile.am
gnunet/src/transport/gnunet-service-transport_clients.c
gnunet/src/transport/plugin_transport_http_common.c
gnunet/src/transport/plugin_transport_http_common.h
Log:
address parsing
Modified: gnunet/src/transport/Makefile.am
===================================================================
--- gnunet/src/transport/Makefile.am 2013-01-17 14:23:24 UTC (rev 25816)
+++ gnunet/src/transport/Makefile.am 2013-01-17 16:21:37 UTC (rev 25817)
@@ -316,6 +316,7 @@
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 @@
$(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 = \
Modified: gnunet/src/transport/gnunet-service-transport_clients.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_clients.c 2013-01-17
14:23:24 UTC (rev 25816)
+++ gnunet/src/transport/gnunet-service-transport_clients.c 2013-01-17
16:21:37 UTC (rev 25817)
@@ -756,7 +756,6 @@
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,
Modified: gnunet/src/transport/plugin_transport_http_common.c
===================================================================
--- gnunet/src/transport/plugin_transport_http_common.c 2013-01-17 14:23:24 UTC
(rev 25816)
+++ gnunet/src/transport/plugin_transport_http_common.c 2013-01-17 16:21:37 UTC
(rev 25817)
@@ -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 @@
asc (asc_cls, NULL);
return;
}
+ http_split_address (addr);
asc (asc_cls, saddr);
asc (asc_cls, NULL);
}
Modified: gnunet/src/transport/plugin_transport_http_common.h
===================================================================
--- gnunet/src/transport/plugin_transport_http_common.h 2013-01-17 14:23:24 UTC
(rev 25816)
+++ gnunet/src/transport/plugin_transport_http_common.h 2013-01-17 16:21:37 UTC
(rev 25817)
@@ -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.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r25817 - gnunet/src/transport,
gnunet <=