[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r23360 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r23360 - gnunet/src/transport |
Date: |
Wed, 22 Aug 2012 15:41:24 +0200 |
Author: wachs
Date: 2012-08-22 15:41:23 +0200 (Wed, 22 Aug 2012)
New Revision: 23360
Added:
gnunet/src/transport/plugin_transport_http_common.c
gnunet/src/transport/plugin_transport_http_common.h
Modified:
gnunet/src/transport/Makefile.am
gnunet/src/transport/plugin_transport_http_client.c
gnunet/src/transport/plugin_transport_http_server.c
gnunet/src/transport/test_transport_api_http_reverse_proxy.conf
Log:
changes
Modified: gnunet/src/transport/Makefile.am
===================================================================
--- gnunet/src/transport/Makefile.am 2012-08-22 12:49:00 UTC (rev 23359)
+++ gnunet/src/transport/Makefile.am 2012-08-22 13:41:23 UTC (rev 23360)
@@ -229,7 +229,7 @@
libgnunet_plugin_transport_http_client_la_SOURCES = \
- plugin_transport_http_client.c
+ plugin_transport_http_client.c plugin_transport_http_common.c
libgnunet_plugin_transport_http_client_la_LIBADD = \
$(top_builddir)/src/hello/libgnunethello.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
@@ -246,7 +246,7 @@
libgnunet_plugin_transport_http_server_la_SOURCES = \
- plugin_transport_http_server.c
+ plugin_transport_http_server.c plugin_transport_http_common.c
libgnunet_plugin_transport_http_server_la_LIBADD = \
$(top_builddir)/src/hello/libgnunethello.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
@@ -260,7 +260,7 @@
$(CFLAGS)
libgnunet_plugin_transport_https_client_la_SOURCES = \
- plugin_transport_http_client.c
+ plugin_transport_http_client.c plugin_transport_http_common.c
libgnunet_plugin_transport_https_client_la_LIBADD = \
$(top_builddir)/src/hello/libgnunethello.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
@@ -277,7 +277,7 @@
libgnunet_plugin_transport_https_server_la_SOURCES = \
- plugin_transport_http_server.c
+ plugin_transport_http_server.c plugin_transport_http_common.c
libgnunet_plugin_transport_https_server_la_LIBADD = \
$(top_builddir)/src/hello/libgnunethello.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
Modified: gnunet/src/transport/plugin_transport_http_client.c
===================================================================
--- gnunet/src/transport/plugin_transport_http_client.c 2012-08-22 12:49:00 UTC
(rev 23359)
+++ gnunet/src/transport/plugin_transport_http_client.c 2012-08-22 13:41:23 UTC
(rev 23360)
@@ -41,7 +41,10 @@
#include "gnunet_statistics_service.h"
#include "gnunet_transport_service.h"
#include "gnunet_transport_plugin.h"
+#include "plugin_transport_http_common.h"
+#include <curl/curl.h>
+
#define DEBUG_TEMPLATE GNUNET_EXTRA_LOGGING
/**
@@ -126,10 +129,39 @@
struct GNUNET_TRANSPORT_PluginEnvironment *env;
/**
- * List of open sessions.
+ * Linked list head of open sessions.
*/
- struct Session *sessions;
+ struct Session *head;
+ /**
+ * Linked list tail of open sessions.
+ */
+ struct Session *tail;
+
+ /**
+ * Plugin name
+ */
+ char *name;
+
+ /**
+ * Protocol
+ */
+ char *protocol;
+
+ /**
+ * use IPv6
+ */
+ uint16_t use_ipv6;
+
+ /**
+ * use IPv4
+ */
+ uint16_t use_ipv4;
+
+ /**
+ * cURL Multihandle
+ */
+ CURLM *curl_multi_handle;
};
@@ -195,33 +227,32 @@
// FIXME
}
-
-/**
- * Convert the transports address to a nice, human-readable
- * format.
- *
- * @param cls closure
- * @param type name of the transport that generated the address
- * @param addr one of the addresses of the host, NULL for the last address
- * the specific address format depends on the transport
- * @param addrlen length of the address
- * @param numeric should (IP) addresses be displayed in numeric form?
- * @param timeout after how long should we give up?
- * @param asc function to call on each string
- * @param asc_cls closure for asc
- */
static void
-http_client_plugin_address_pretty_printer (void *cls, const char *type,
- const void *addr, size_t addrlen,
- int numeric,
- struct GNUNET_TIME_Relative timeout,
- GNUNET_TRANSPORT_AddressStringCallback
- asc, void *asc_cls)
+client_stop (struct HTTP_Client_Plugin *plugin)
{
- asc (asc_cls, NULL);
+ if (NULL != plugin->curl_multi_handle)
+ {
+ curl_multi_cleanup (plugin->curl_multi_handle);
+ plugin->curl_multi_handle = NULL;
+ }
+ curl_global_cleanup ();
}
+static int
+client_start (struct HTTP_Client_Plugin *plugin)
+{
+ curl_global_init (CURL_GLOBAL_ALL);
+ plugin->curl_multi_handle = curl_multi_init ();
+ if (NULL == plugin->curl_multi_handle)
+ {
+ GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
+ _("Could not initialize curl multi handle, failed to
start %s plugin!\n"),
+ plugin->name);
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_OK;
+}
/**
* Another peer has suggested an address for this
@@ -240,33 +271,27 @@
{
/* struct Plugin *plugin = cls; */
- /* check if the address is plausible; if so,
- * add it to our list! */
- return GNUNET_OK;
+ /* A HTTP/S client does not have any valid address so:*/
+ return GNUNET_NO;
}
-
/**
- * Function called for a quick conversion of the binary address to
- * a numeric address. Note that the caller must not free the
- * address and that the next call to this function is allowed
- * to override the address again.
- *
- * @param cls closure
- * @param addr binary address
- * @param addrlen length of the address
- * @return string representing the same address
+ * Exit point from the plugin.
*/
-static const char *
-http_client_plugin_address_to_string (void *cls, const void *addr, size_t
addrlen)
+void *
+LIBGNUNET_PLUGIN_TRANSPORT_DONE (void *cls)
{
- GNUNET_break (0);
+ struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
+ struct HTTP_Client_Plugin *plugin = api->cls;
+
+ client_stop (plugin);
+
+ GNUNET_free (plugin);
+ GNUNET_free (api);
return NULL;
}
-
-
/**
* Entry point for the plugin.
*/
@@ -283,25 +308,27 @@
api->cls = plugin;
api->send = &http_client_plugin_send;
api->disconnect = &http_client_plugin_disconnect;
- api->address_pretty_printer = &http_client_plugin_address_pretty_printer;
api->check_address = &http_client_plugin_address_suggested;
- api->address_to_string = &http_client_plugin_address_to_string;
- return api;
-}
+ api->address_to_string = &http_common_plugin_address_to_string;
+ api->string_to_address = &http_common_plugin_string_to_address;
+ api->address_pretty_printer = &http_common_plugin_address_pretty_printer;
-/**
- * Exit point from the plugin.
- */
-void *
-LIBGNUNET_PLUGIN_TRANSPORT_DONE (void *cls)
-{
- struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
- struct HTTP_Client_Plugin *plugin = api->cls;
+#if BUILD_HTTPS
+ plugin->name = "transport-https_client";
+ plugin->protocol = "https";
+#else
+ plugin->name = "transport-http_client";
+ plugin->protocol = "http";
+#endif
- GNUNET_free (plugin);
- GNUNET_free (api);
- return NULL;
+ /* Start client */
+ if (GNUNET_SYSERR == client_start (plugin))
+ {
+ LIBGNUNET_PLUGIN_TRANSPORT_DONE (api);
+ return NULL;
+ }
+ return api;
}
/* end of plugin_transport_http_client.c */
Added: gnunet/src/transport/plugin_transport_http_common.c
===================================================================
--- gnunet/src/transport/plugin_transport_http_common.c
(rev 0)
+++ gnunet/src/transport/plugin_transport_http_common.c 2012-08-22 13:41:23 UTC
(rev 23360)
@@ -0,0 +1,99 @@
+/*
+ This file is part of GNUnet
+ (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Christian Grothoff
(and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file transport/plugin_transport_http_common.c
+ * @brief functionality shared by http client and server transport service
plugin
+ * @author Matthias Wachs
+ */
+
+#include "platform.h"
+#include "gnunet_common.h"
+#include "gnunet_transport_plugin.h"
+
+/**
+ * Convert the transports address to a nice, human-readable
+ * format.
+ *
+ * @param cls closure
+ * @param type name of the transport that generated the address
+ * @param addr one of the addresses of the host, NULL for the last address
+ * the specific address format depends on the transport
+ * @param addrlen length of the address
+ * @param numeric should (IP) addresses be displayed in numeric form?
+ * @param timeout after how long should we give up?
+ * @param asc function to call on each string
+ * @param asc_cls closure for asc
+ */
+void
+http_common_plugin_address_pretty_printer (void *cls, const char *type,
+ const void *addr, size_t addrlen,
+ int numeric,
+ struct GNUNET_TIME_Relative timeout,
+ GNUNET_TRANSPORT_AddressStringCallback
+ asc, void *asc_cls)
+{
+ GNUNET_break (0);
+ asc (asc_cls, NULL);
+}
+
+
+/**
+ * Function called for a quick conversion of the binary address to
+ * a numeric address. Note that the caller must not free the
+ * address and that the next call to this function is allowed
+ * to override the address again.
+ *
+ * @param cls closure
+ * @param addr binary address
+ * @param addrlen length of the address
+ * @return string representing the same address
+ */
+const char *
+http_common_plugin_address_to_string (void *cls, const void *addr, size_t
addrlen)
+{
+ GNUNET_break (0);
+ return NULL;
+}
+
+/**
+ * Function called to convert a string address to
+ * a binary address.
+ *
+ * @param cls closure ('struct Plugin*')
+ * @param addr string address
+ * @param addrlen length of the address
+ * @param buf location to store the buffer
+ * If the function returns GNUNET_SYSERR, its contents are undefined.
+ * @param added length of created address
+ * @return GNUNET_OK on success, GNUNET_SYSERR on failure
+ */
+int
+http_common_plugin_string_to_address (void *cls,
+ const char *addr,
+ uint16_t addrlen,
+ void **buf,
+ size_t *added)
+{
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+}
+
+/* end of plugin_transport_http_common.c */
Added: gnunet/src/transport/plugin_transport_http_common.h
===================================================================
--- gnunet/src/transport/plugin_transport_http_common.h
(rev 0)
+++ gnunet/src/transport/plugin_transport_http_common.h 2012-08-22 13:41:23 UTC
(rev 23360)
@@ -0,0 +1,85 @@
+/*
+ This file is part of GNUnet
+ (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Christian Grothoff
(and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file transport/plugin_transport_http_common.c
+ * @brief functionality shared by http client and server transport service
plugin
+ * @author Matthias Wachs
+ */
+
+#include "platform.h"
+#include "gnunet_common.h"
+
+/**
+ * Convert the transports address to a nice, human-readable
+ * format.
+ *
+ * @param cls closure
+ * @param type name of the transport that generated the address
+ * @param addr one of the addresses of the host, NULL for the last address
+ * the specific address format depends on the transport
+ * @param addrlen length of the address
+ * @param numeric should (IP) addresses be displayed in numeric form?
+ * @param timeout after how long should we give up?
+ * @param asc function to call on each string
+ * @param asc_cls closure for asc
+ */
+void
+http_common_plugin_address_pretty_printer (void *cls, const char *type,
+ const void *addr, size_t addrlen,
+ int numeric,
+ struct GNUNET_TIME_Relative timeout,
+ GNUNET_TRANSPORT_AddressStringCallback
+ asc, void *asc_cls);
+
+/**
+ * Function called for a quick conversion of the binary address to
+ * a numeric address. Note that the caller must not free the
+ * address and that the next call to this function is allowed
+ * to override the address again.
+ *
+ * @param cls closure
+ * @param addr binary address
+ * @param addrlen length of the address
+ * @return string representing the same address
+ */
+const char *
+http_common_plugin_address_to_string (void *cls, const void *addr, size_t
addrlen);
+
+/**
+ * Function called to convert a string address to
+ * a binary address.
+ *
+ * @param cls closure ('struct Plugin*')
+ * @param addr string address
+ * @param addrlen length of the address
+ * @param buf location to store the buffer
+ * If the function returns GNUNET_SYSERR, its contents are undefined.
+ * @param added length of created address
+ * @return GNUNET_OK on success, GNUNET_SYSERR on failure
+ */
+int
+http_common_plugin_string_to_address (void *cls,
+ const char *addr,
+ uint16_t addrlen,
+ void **buf,
+ size_t *added);
+
+/* end of plugin_transport_http_common.c */
Modified: gnunet/src/transport/plugin_transport_http_server.c
===================================================================
--- gnunet/src/transport/plugin_transport_http_server.c 2012-08-22 12:49:00 UTC
(rev 23359)
+++ gnunet/src/transport/plugin_transport_http_server.c 2012-08-22 13:41:23 UTC
(rev 23360)
@@ -35,6 +35,7 @@
#include "gnunet_container_lib.h"
#include "gnunet_nat_lib.h"
+#include "plugin_transport_http_common.h"
#include "microhttpd.h"
#if BUILD_HTTPS
@@ -59,12 +60,6 @@
struct Session
{
/**
- * To whom are we talking to (set to our identity
- * if we are still waiting for the welcome message)
- */
- struct GNUNET_PeerIdentity target;
-
- /**
* Stored in a linked list.
*/
struct Session *next;
@@ -75,45 +70,17 @@
struct Session *prev;
/**
- * Pointer to the global plugin struct.
+ * To whom are we talking to (set to our identity
+ * if we are still waiting for the welcome message)
*/
- struct HTTP_Server_Plugin *plugin;
+ struct GNUNET_PeerIdentity target;
/**
- * The client (used to identify this connection)
+ * Pointer to the global plugin struct.
*/
- /* void *client; */
+ struct HTTP_Server_Plugin *plugin;
/**
- * Continuation function to call once the transmission buffer
- * has again space available. NULL if there is no
- * continuation to call.
- */
- GNUNET_TRANSPORT_TransmitContinuation transmit_cont;
-
- /**
- * Closure for transmit_cont.
- */
- void *transmit_cont_cls;
-
- /**
- * At what time did we reset last_received last?
- */
- struct GNUNET_TIME_Absolute last_quota_update;
-
- /**
- * How many bytes have we received since the "last_quota_update"
- * timestamp?
- */
- uint64_t last_received;
-
- /**
- * Number of bytes per ms that this peer is allowed
- * to send to us.
- */
- uint32_t quota;
-
- /**
* next pointer for double linked list
*/
struct HTTP_Message *msg_head;
@@ -129,10 +96,6 @@
struct GNUNET_SERVER_MessageStreamTokenizer *msg_tk;
/**
- * Server handles
- */
-
- /**
* Client send handle
*/
struct ServerConnection *server_recv;
@@ -146,12 +109,6 @@
* Address
*/
void *addr;
-
- /**
- * Address length
- */
- size_t addrlen;
-
};
/**
@@ -165,40 +122,31 @@
struct GNUNET_TRANSPORT_PluginEnvironment *env;
/**
- * Linked list of open sessions.
+ * Linked list head of open sessions.
*/
struct Session *head;
+ /**
+ * Linked list tail of open sessions.
+ */
struct Session *tail;
-
- char *name;
- char *protocol;
- char *external_hostname;
-
/**
- * libCurl TLS crypto init string, can be set to enhance performance
- *
- * Example:
- *
- * Use RC4-128 instead of AES:
- * NONE:+VERS-TLS1.0:+ARCFOUR-128:+SHA1:+RSA:+COMP-NULL
- *
+ * Plugin name
*/
- char *crypto_init;
+ char *name;
/**
- * TLS key
+ * Protocol
*/
- char *key;
+ char *protocol;
/**
- * TLS certificate
+ * External address
*/
- char *cert;
+ char *external_hostname;
-
/**
* Maximum number of sockets the plugin can use
* Each http inbound /outbound connections are two connections
@@ -248,6 +196,15 @@
struct GNUNET_NAT_Handle *nat;
/**
+ * Server semi connections
+ * A full session consists of 2 semi-connections: send and receive
+ * If not both directions are established the server keeps this sessions here
+ */
+ struct Session *server_semi_head;
+
+ struct Session *server_semi_tail;
+
+ /**
* List of own addresses
*/
@@ -291,26 +248,39 @@
*/
int server_v6_immediately;
+ /**
+ * MHD IPv4 daemon
+ */
+ struct MHD_Daemon *server_v4;
/**
- * Server semi connections
- * A full session consists of 2 semi-connections: send and receive
- * If not both directions are established the server keeps this sessions here
+ * MHD IPv4 daemon
*/
- struct Session *server_semi_head;
+ struct MHD_Daemon *server_v6;
- struct Session *server_semi_tail;
+#if BUILD_HTTPS
+ /**
+ * Crypto related
+ *
+ * Example:
+ *
+ * Use RC4-128 instead of AES:
+ * NONE:+VERS-TLS1.0:+ARCFOUR-128:+SHA1:+RSA:+COMP-NULL
+ *
+ */
+ char *crypto_init;
-
/**
- * MHD IPv4 daemon
+ * TLS key
*/
- struct MHD_Daemon *server_v4;
+ char *key;
/**
- * MHD IPv4 daemon
+ * TLS certificate
*/
- struct MHD_Daemon *server_v6;
+ char *cert;
+#endif
+
};
GNUNET_NETWORK_STRUCT_BEGIN
@@ -461,33 +431,6 @@
/**
- * Convert the transports address to a nice, human-readable
- * format.
- *
- * @param cls closure
- * @param type name of the transport that generated the address
- * @param addr one of the addresses of the host, NULL for the last address
- * the specific address format depends on the transport
- * @param addrlen length of the address
- * @param numeric should (IP) addresses be displayed in numeric form?
- * @param timeout after how long should we give up?
- * @param asc function to call on each string
- * @param asc_cls closure for asc
- */
-static void
-http_server_plugin_address_pretty_printer (void *cls, const char *type,
- const void *addr, size_t addrlen,
- int numeric,
- struct GNUNET_TIME_Relative timeout,
- GNUNET_TRANSPORT_AddressStringCallback
- asc, void *asc_cls)
-{
- asc (asc_cls, NULL);
-}
-
-
-
-/**
* Another peer has suggested an address for this
* peer and transport plugin. Check that this could be a valid
* address. If so, consider adding it to the list
@@ -511,25 +454,6 @@
/**
- * Function called for a quick conversion of the binary address to
- * a numeric address. Note that the caller must not free the
- * address and that the next call to this function is allowed
- * to override the address again.
- *
- * @param cls closure
- * @param addr binary address
- * @param addrlen length of the address
- * @return string representing the same address
- */
-static const char *
-http_server_plugin_address_to_string (void *cls, const void *addr, size_t
addrlen)
-{
- GNUNET_break (0);
- return NULL;
-}
-
-
-/**
* Deleting the session
* Must not be used afterwards
*/
@@ -594,7 +518,7 @@
const char *upload_data, size_t * upload_data_size,
void **httpSessionCache)
{
- GNUNET_break (0);
+ /* FIXME SPLIT */
return MHD_NO;
}
@@ -602,6 +526,7 @@
server_disconnect_cb (void *cls, struct MHD_Connection *connection,
void **httpSessionCache)
{
+ /* FIXME SPLIT */
GNUNET_break (0);
}
@@ -1787,9 +1712,10 @@
api->cls = plugin;
api->send = &http_server_plugin_send;
api->disconnect = &http_server_plugin_disconnect;
- api->address_pretty_printer = &http_server_plugin_address_pretty_printer;
api->check_address = &http_server_plugin_address_suggested;
- api->address_to_string = &http_server_plugin_address_to_string;
+ api->address_to_string = &http_common_plugin_address_to_string;
+ api->string_to_address = &http_common_plugin_string_to_address;
+ api->address_pretty_printer = &http_common_plugin_address_pretty_printer;
#if BUILD_HTTPS
plugin->name = "transport-https_server";
Modified: gnunet/src/transport/test_transport_api_http_reverse_proxy.conf
===================================================================
--- gnunet/src/transport/test_transport_api_http_reverse_proxy.conf
2012-08-22 12:49:00 UTC (rev 23359)
+++ gnunet/src/transport/test_transport_api_http_reverse_proxy.conf
2012-08-22 13:41:23 UTC (rev 23360)
@@ -9,11 +9,14 @@
[transport-http_server]
PORT = 12080
EXTERNAL_HOSTNAME = fulcrum.net.in.tum.de:12080/peer
-#USE_IPV4 = YES
+USE_IPV4 = NO
#USE_IPV6 = YES
#BINDTO = 127.0.0.1
-#BINDTO6 = ::1
+BINDTO6 = ::1
+[transport-https_server]
+PORT = 12090
+
[arm]
PORT = 12085
DEFAULTSERVICES = transport
@@ -34,7 +37,7 @@
[transport]
#DEBUG = YES
PORT = 12081
-PLUGINS = http_server
+PLUGINS = https_client
# http_client
#BINARY = .libs/gnunet-service-transport
UNIXPATH = /tmp/gnunet-p1-service-transport.sock
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r23360 - gnunet/src/transport,
gnunet <=