2 This file is part of GNUnet
3 (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file transport/plugin_transport_template.c
23 * @brief template for a new transport service
24 * @author Christian Grothoff
28 #include "gnunet_protocols.h"
29 #include "gnunet_connection_lib.h"
30 #include "gnunet_server_lib.h"
31 #include "gnunet_service_lib.h"
32 #include "gnunet_statistics_service.h"
33 #include "gnunet_transport_service.h"
34 #include "gnunet_resolver_service.h"
35 #include "plugin_transport.h"
36 #include "microhttpd.h"
37 #include <curl/curl.h>
39 #define DEBUG_HTTP GNUNET_NO
42 * Text of the response sent back after the last bytes of a PUT
43 * request have been received (just to formally obey the HTTP
46 #define HTTP_PUT_RESPONSE "Thank you!"
49 * After how long do we expire an address that we
50 * learned from another peer if it is not reconfirmed
53 #define LEARNED_ADDRESS_EXPIRATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 6)
56 * Page returned if request invalid
58 #define HTTP_ERROR_RESPONSE "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\"><HTML><HEAD><TITLE>404 Not Found</TITLE></HEAD><BODY><H1>Not Found</H1>The requested URL was not found on this server.<P><HR><ADDRESS></ADDRESS></BODY></HTML>"
62 * Encapsulation of all of the state of the plugin.
68 * Session handle for connections.
74 * Stored in a linked list.
79 * Pointer to the global plugin struct.
81 struct Plugin *plugin;
84 * Continuation function to call once the transmission buffer
85 * has again space available. NULL if there is no
86 * continuation to call.
88 GNUNET_TRANSPORT_TransmitContinuation transmit_cont;
91 * Closure for transmit_cont.
93 void *transmit_cont_cls;
96 * To whom are we talking to (set to our identity
97 * if we are still waiting for the welcome message)
99 struct GNUNET_PeerIdentity sender;
107 * Sender's ip address to distinguish between incoming connections
112 * Sender's ip address to distinguish between incoming connections
114 struct sockaddr_in * addr;
117 * Did we initiate the connection (GNUNET_YES) or the other peer (GNUNET_NO)?
119 unsigned int is_client;
122 * Is the connection active (GNUNET_YES) or terminated (GNUNET_NO)?
124 unsigned int is_active;
127 * At what time did we reset last_received last?
129 struct GNUNET_TIME_Absolute last_quota_update;
132 * How many bytes have we received since the "last_quota_update"
135 uint64_t last_received;
138 * Number of bytes per ms that this peer is allowed
146 * Encapsulation of all of the state of the plugin.
153 struct GNUNET_TRANSPORT_PluginEnvironment *env;
156 * List of open sessions.
158 struct Session *sessions;
161 * Number of active sessions
164 unsigned int session_count;
169 * Daemon for listening for new IPv4 connections.
171 static struct MHD_Daemon *http_daemon_v4;
174 * Daemon for listening for new IPv6connections.
176 static struct MHD_Daemon *http_daemon_v6;
179 * Our primary task for http daemon handling IPv4 connections
181 static GNUNET_SCHEDULER_TaskIdentifier http_task_v4;
184 * Our primary task for http daemon handling IPv6 connections
186 static GNUNET_SCHEDULER_TaskIdentifier http_task_v6;
190 * Information about this plugin
192 static struct Plugin *plugin;
197 static CURLM *multi_handle;
202 static char * hostname;
205 * Our ASCII encoded, hashed peer identity
206 * This string is used to distinguish between connections and is added to the urls
208 static struct GNUNET_CRYPTO_HashAsciiEncoded my_ascii_hash_ident;
212 * Finds a http session in our linked list using peer identity as a key
213 * @param peer peeridentity
214 * @return http session corresponding to peer identity
216 static struct Session * find_session_by_pi( const struct GNUNET_PeerIdentity *peer )
218 struct Session * cur;
219 GNUNET_HashCode hc_peer;
220 GNUNET_HashCode hc_current;
222 cur = plugin->sessions;
223 hc_peer = peer->hashPubKey;
226 hc_current = cur->sender.hashPubKey;
227 if ( 0 == GNUNET_CRYPTO_hash_cmp( &hc_peer, &hc_current))
229 cur = plugin->sessions->next;
236 * Finds a http session in our linked list using peer identity as a key
237 * @param peer peeridentity
238 * @return http session corresponding to peer identity
240 static struct Session * find_session_by_ip( char * ip )
243 struct Session * cur;
245 cur = plugin->sessions;
248 hc_current = cur->sender.hashPubKey;
249 if ( 0 == GNUNET_CRYPTO_hash_cmp( &hc_peer, &hc_current))
251 cur = plugin->sessions->next;
260 * Creates a http session in our linked list by ip address
261 * Only ip is set here, all other fields have to be set by calling method
262 * @param peer peeridentity
263 * @return created http session
265 static struct Session * create_session_by_ip ( struct sockaddr_in * addr )
267 struct Session * cur;
268 struct Session * last_in_list;
269 /* Create a new session object */
270 cur = GNUNET_malloc (sizeof (struct Session));
271 // FIXME: memcpy( &(cur->ip), , sizeof( struct GNUNET_PeerIdentity ) );
275 /* Insert into linked list */
276 last_in_list = plugin->sessions;
277 while (last_in_list->next != NULL)
279 last_in_list = last_in_list->next;
281 last_in_list->next = cur;
288 * Callback called by MHD when a connection is terminated
290 static void requestCompletedCallback (void *cls, struct MHD_Connection * connection, void **httpSessionCache)
294 cs = *httpSessionCache;
297 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection from peer `%s' was terminated\n",GNUNET_i2s(&cs->sender));
298 /* session set to inactive */
299 cs->is_active = GNUNET_NO;
305 * Check if we are allowed to connect to the given IP.
308 acceptPolicyCallback (void *cls,
309 const struct sockaddr *addr, socklen_t addr_len)
311 /* Every connection is accepted, nothing more to do here */
317 * Process GET or PUT request received via MHD. For
318 * GET, queue response that will send back our pending
319 * messages. For PUT, process incoming data and send
320 * to GNUnet core. In either case, check if a session
321 * already exists and create a new one if not.
324 accessHandlerCallback (void *cls,
325 struct MHD_Connection *session,
329 const char *upload_data,
330 size_t * upload_data_size, void **httpSessionCache)
332 struct MHD_Response *response;
334 struct Session * cs_temp;
335 const union MHD_ConnectionInfo * conn_info;
336 struct sockaddr_in *addrin;
337 struct sockaddr_in6 *addrin6;
338 char * address = NULL;
339 struct GNUNET_PeerIdentity pi_in;
342 if ( NULL == *httpSessionCache)
344 /* check url for peer identity */
345 res = GNUNET_CRYPTO_hash_from_string ( &url[1], &(pi_in.hashPubKey));
346 if ( GNUNET_SYSERR == res )
348 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Peer has no valid ident\n");
349 response = MHD_create_response_from_data (strlen (HTTP_ERROR_RESPONSE),HTTP_ERROR_RESPONSE, MHD_NO, MHD_NO);
350 res = MHD_queue_response (session, MHD_HTTP_NOT_FOUND, response);
351 MHD_destroy_response (response);
355 conn_info = MHD_get_connection_info(session, MHD_CONNECTION_INFO_CLIENT_ADDRESS );
356 /* Incoming IPv4 connection */
357 if ( AF_INET == conn_info->client_addr->sin_family)
359 address = GNUNET_malloc (INET_ADDRSTRLEN);
360 addrin = conn_info->client_addr;
361 inet_ntop(addrin->sin_family, &(addrin->sin_addr),address,INET_ADDRSTRLEN);
363 /* Incoming IPv6 connection */
364 if ( AF_INET6 == conn_info->client_addr->sin_family)
366 address = GNUNET_malloc (INET6_ADDRSTRLEN);
367 addrin6 = (struct sockaddr_in6 *) conn_info->client_addr;
368 inet_ntop(addrin6->sin6_family, &(addrin6->sin6_addr),address,INET6_ADDRSTRLEN);
371 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"HTTP Daemon has an incoming `%s' request from peer `%s' from `[%s]:%u'\n",method, GNUNET_h2s(&pi_in.hashPubKey),address,conn_info->client_addr->sin_port);
373 /* find session for address */
375 if (plugin->session_count > 0)
377 cs = plugin->sessions;
381 /* Comparison based on ip address */
382 // res = (0 == memcmp(&(conn_info->client_addr->sin_addr),&(cs->addr->sin_addr), sizeof (struct in_addr))) ? GNUNET_YES : GNUNET_NO;
384 /* Comparison based on ip address, port number and address family */
385 // res = (0 == memcmp((conn_info->client_addr),(cs->addr), sizeof (struct sockaddr_in))) ? GNUNET_YES : GNUNET_NO;
387 /* Comparison based on PeerIdentity */
388 res = (0 == memcmp(&pi_in,&(cs->sender), sizeof (struct GNUNET_PeerIdentity))) ? GNUNET_YES : GNUNET_NO;
390 if ( GNUNET_YES == res)
392 /* existing session for this address found */
393 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Session `%s' found\n",address);
402 /* create new session object */
403 cs = GNUNET_malloc ( sizeof( struct Session) );
404 cs->addr = GNUNET_malloc ( sizeof (struct sockaddr_in) );
407 memcpy(cs->addr, conn_info->client_addr, sizeof (struct sockaddr_in));
408 memcpy(&cs->sender, &pi_in, sizeof (struct GNUNET_PeerIdentity));
410 cs->is_active = GNUNET_YES;
412 /* Insert session into linked list */
413 if ( plugin->sessions == NULL)
415 plugin->sessions = cs;
416 plugin->session_count = 1;
418 cs_temp = plugin->sessions;
419 while ( cs_temp->next != NULL )
421 cs_temp = cs_temp->next;
426 plugin->session_count++;
428 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"New Session `%s' inserted, count %u \n", address, plugin->session_count);
431 if (*httpSessionCache == NULL)
432 *httpSessionCache = cs;
435 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Session already known \n");
437 /* Is it a PUT or a GET request */
438 if ( 0 == strcmp (MHD_HTTP_METHOD_PUT, method) )
440 /* PUT method here */
441 if (*upload_data_size == 0)
445 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Got PUT Request with size %lu \n",(*upload_data_size));
446 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"URL: `%s'\n",url);
447 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"PUT Request: `%s'\n",upload_data);
449 *upload_data_size = 0;
451 /* do something with the data */
453 response = MHD_create_response_from_data (strlen (HTTP_PUT_RESPONSE),HTTP_PUT_RESPONSE, MHD_NO, MHD_NO);
454 res = MHD_queue_response (session, MHD_HTTP_CONTINUE, response);
455 MHD_destroy_response (response);
458 if ( 0 == strcmp (MHD_HTTP_METHOD_GET, method) )
460 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Got GET Request\n");
461 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"URL: `%s'\n",url);
463 response = MHD_create_response_from_data (strlen (HTTP_PUT_RESPONSE),HTTP_PUT_RESPONSE, MHD_NO, MHD_NO);
464 res = MHD_queue_response (session, MHD_HTTP_OK, response);
465 MHD_destroy_response (response);
474 * Call MHD to process pending requests and then go back
475 * and schedule the next run.
477 static void http_daemon_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
480 * Function that queries MHD's select sets and
481 * starts the task waiting for them.
483 static GNUNET_SCHEDULER_TaskIdentifier
484 http_daemon_prepare (struct MHD_Daemon *daemon_handle)
486 GNUNET_SCHEDULER_TaskIdentifier ret;
490 struct GNUNET_NETWORK_FDSet *wrs;
491 struct GNUNET_NETWORK_FDSet *wws;
492 struct GNUNET_NETWORK_FDSet *wes;
494 unsigned long long timeout;
496 struct GNUNET_TIME_Relative tv;
501 wrs = GNUNET_NETWORK_fdset_create ();
502 wes = GNUNET_NETWORK_fdset_create ();
503 wws = GNUNET_NETWORK_fdset_create ();
505 GNUNET_assert (MHD_YES ==
506 MHD_get_fdset (daemon_handle,
511 haveto = MHD_get_timeout (daemon_handle, &timeout);
512 if (haveto == MHD_YES)
513 tv.value = (uint64_t) timeout;
515 tv = GNUNET_TIME_UNIT_FOREVER_REL;
516 GNUNET_NETWORK_fdset_copy_native (wrs, &rs, max);
517 GNUNET_NETWORK_fdset_copy_native (wws, &ws, max);
518 GNUNET_NETWORK_fdset_copy_native (wes, &es, max);
519 ret = GNUNET_SCHEDULER_add_select (plugin->env->sched,
520 GNUNET_SCHEDULER_PRIORITY_HIGH,
521 GNUNET_SCHEDULER_NO_TASK,
527 GNUNET_NETWORK_fdset_destroy (wrs);
528 GNUNET_NETWORK_fdset_destroy (wws);
529 GNUNET_NETWORK_fdset_destroy (wes);
534 * Call MHD to process pending requests and then go back
535 * and schedule the next run.
538 http_daemon_run (void *cls,
539 const struct GNUNET_SCHEDULER_TaskContext *tc)
541 struct MHD_Daemon *daemon_handle = cls;
543 if (daemon_handle == http_daemon_v4)
544 http_task_v4 = GNUNET_SCHEDULER_NO_TASK;
546 if (daemon_handle == http_daemon_v6)
547 http_task_v6 = GNUNET_SCHEDULER_NO_TASK;
549 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
554 GNUNET_assert (MHD_YES == MHD_run (daemon_handle));
555 if (daemon_handle == http_daemon_v4)
556 http_task_v4 = http_daemon_prepare (daemon_handle);
557 if (daemon_handle == http_daemon_v6)
558 http_task_v6 = http_daemon_prepare (daemon_handle);
562 static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream)
566 fprintf(stdout, "*** Read callback: size %u, size nmemb: %u \n", size, nmemb);
567 retcode = fread(ptr, size, nmemb, stream);
574 * Function that can be used by the transport service to transmit
575 * a message using the plugin.
578 * @param target who should receive this message
579 * @param priority how important is the message
580 * @param msgbuf the message to transmit
581 * @param msgbuf_size number of bytes in 'msgbuf'
582 * @param timeout when should we time out
583 * @param session which session must be used (or NULL for "any")
584 * @param addr the address to use (can be NULL if the plugin
585 * is "on its own" (i.e. re-use existing TCP connection))
586 * @param addrlen length of the address in bytes
587 * @param force_address GNUNET_YES if the plugin MUST use the given address,
588 * otherwise the plugin may use other addresses or
589 * existing connections (if available)
590 * @param cont continuation to call once the message has
591 * been transmitted (or if the transport is ready
592 * for the next transmission call; or if the
593 * peer disconnected...)
594 * @param cont_cls closure for cont
595 * @return number of bytes used (on the physical network, with overheads);
596 * -1 on hard errors (i.e. address invalid); 0 is a legal value
597 * and does NOT mean that the message was not transmitted (DV)
600 http_plugin_send (void *cls,
601 const struct GNUNET_PeerIdentity *
605 unsigned int priority,
606 struct GNUNET_TIME_Relative timeout,
607 struct Session *session,
611 GNUNET_TRANSPORT_TransmitContinuation
612 cont, void *cont_cls)
615 struct Session* ses_temp;
617 /* struct Plugin *plugin = cls; */
621 /* find session for peer */
622 ses = find_session_by_pi (target);
626 /* create new session object */
627 ses = GNUNET_malloc ( sizeof( struct Session) );
628 ses->addr = GNUNET_malloc ( sizeof (struct sockaddr_in) );
631 // memcpy(ses->addr, conn_info->client_addr, sizeof (struct sockaddr_in));
632 memcpy(&ses->sender, &target, sizeof (struct GNUNET_PeerIdentity));
634 ses->is_active = GNUNET_YES;
636 /* Insert session into linked list */
637 if ( plugin->sessions == NULL)
639 plugin->sessions = ses;
640 plugin->session_count = 1;
642 ses_temp = plugin->sessions;
643 while ( ses_temp->next != NULL )
645 ses_temp = ses_temp->next;
647 if (ses_temp != ses )
649 ses_temp->next = ses;
650 plugin->session_count++;
652 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"New Session `%s' inserted, count %u \n", GNUNET_i2s(target), plugin->session_count); }
657 curl_handle = curl_easy_init();
658 if( NULL == curl_handle)
660 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Getting cURL handle failed\n");
663 curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1L);
664 curl_easy_setopt(curl_handle, CURLOPT_READFUNCTION, read_callback);
665 curl_easy_setopt(curl_handle, CURLOPT_UPLOAD, 1L);
666 curl_easy_setopt(curl_handle, CURLOPT_PUT, 1L);
667 curl_easy_setopt(curl_handle, CURLOPT_URL, url);
668 curl_easy_setopt(curl_handle, CURLOPT_READDATA, msgbuf);
669 curl_easy_setopt(curl_handle, CURLOPT_INFILESIZE_LARGE,
670 (curl_off_t)msgbuf_size);
680 * Function that can be used to force the plugin to disconnect
681 * from the given peer and cancel all previous transmissions
682 * (and their continuationc).
685 * @param target peer from which to disconnect
688 http_plugin_disconnect (void *cls,
689 const struct GNUNET_PeerIdentity *target)
691 // struct Plugin *plugin = cls;
697 * Convert the transports address to a nice, human-readable
701 * @param type name of the transport that generated the address
702 * @param addr one of the addresses of the host, NULL for the last address
703 * the specific address format depends on the transport
704 * @param addrlen length of the address
705 * @param numeric should (IP) addresses be displayed in numeric form?
706 * @param timeout after how long should we give up?
707 * @param asc function to call on each string
708 * @param asc_cls closure for asc
711 http_plugin_address_pretty_printer (void *cls,
716 struct GNUNET_TIME_Relative timeout,
717 GNUNET_TRANSPORT_AddressStringCallback
726 * Another peer has suggested an address for this
727 * peer and transport plugin. Check that this could be a valid
728 * address. If so, consider adding it to the list
732 * @param addr pointer to the address
733 * @param addrlen length of addr
734 * @return GNUNET_OK if this is a plausible address for this peer
738 http_plugin_address_suggested (void *cls,
739 void *addr, size_t addrlen)
741 /* struct Plugin *plugin = cls; */
743 /* check if the address is plausible; if so,
744 add it to our list! */
750 * Function called for a quick conversion of the binary address to
751 * a numeric address. Note that the caller must not free the
752 * address and that the next call to this function is allowed
753 * to override the address again.
756 * @param addr binary address
757 * @param addrlen length of the address
758 * @return string representing the same address
761 http_plugin_address_to_string (void *cls,
770 * Exit point from the plugin.
773 libgnunet_plugin_transport_http_done (void *cls)
775 struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
776 struct Plugin *plugin = api->cls;
778 struct Session * cs_next;
780 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Unloading http plugin...\n");
782 if ( http_task_v4 != GNUNET_SCHEDULER_NO_TASK)
784 GNUNET_SCHEDULER_cancel(plugin->env->sched, http_task_v4);
785 http_task_v4 = GNUNET_SCHEDULER_NO_TASK;
788 if ( http_task_v6 != GNUNET_SCHEDULER_NO_TASK)
790 GNUNET_SCHEDULER_cancel(plugin->env->sched, http_task_v6);
791 http_task_v6 = GNUNET_SCHEDULER_NO_TASK;
794 if (http_daemon_v4 != NULL)
796 MHD_stop_daemon (http_daemon_v4);
797 http_daemon_v4 = NULL;
799 if (http_daemon_v6 != NULL)
801 MHD_stop_daemon (http_daemon_v6);
802 http_daemon_v6 = NULL;
805 curl_multi_cleanup(multi_handle);
807 /* free all sessions */
808 cs = plugin->sessions;
811 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Freeing session to `%s'\n",cs->ip);
813 GNUNET_free (cs->ip);
814 GNUNET_free (cs->addr);
816 plugin->session_count--;
820 GNUNET_free (plugin);
827 * Entry point for the plugin.
830 libgnunet_plugin_transport_http_init (void *cls)
832 struct GNUNET_TRANSPORT_PluginEnvironment *env = cls;
833 struct GNUNET_TRANSPORT_PluginFunctions *api;
835 long long unsigned int port;
837 plugin = GNUNET_malloc (sizeof (struct Plugin));
839 plugin->sessions = NULL;
840 api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
842 api->send = &http_plugin_send;
843 api->disconnect = &http_plugin_disconnect;
844 api->address_pretty_printer = &http_plugin_address_pretty_printer;
845 api->check_address = &http_plugin_address_suggested;
846 api->address_to_string = &http_plugin_address_to_string;
848 hostname = GNUNET_RESOLVER_local_fqdn_get ();
850 /* Hashing our identity to use it in URLs */
851 GNUNET_CRYPTO_hash_to_enc ( &(plugin->env->my_identity->hashPubKey), &my_ascii_hash_ident);
853 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Starting http plugin...\n");
854 /* Reading port number from config file */
856 GNUNET_CONFIGURATION_get_value_number (env->cfg,
862 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
865 ("Require valid port number for transport plugin `%s' in configuration!\n"),
867 libgnunet_plugin_transport_http_done (api);
871 if ((http_daemon_v4 == NULL) && (http_daemon_v6 == NULL) && (port != 0))
873 http_daemon_v6 = MHD_start_daemon (MHD_USE_IPv6,
875 &acceptPolicyCallback,
876 NULL , &accessHandlerCallback, NULL,
877 MHD_OPTION_CONNECTION_LIMIT, (unsigned int) 16,
878 MHD_OPTION_PER_IP_CONNECTION_LIMIT, (unsigned int) 1,
879 MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 16,
880 /* FIXME: set correct limit */
881 MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (16 * 1024),
882 MHD_OPTION_NOTIFY_COMPLETED, &requestCompletedCallback, NULL,
884 http_daemon_v4 = MHD_start_daemon (MHD_NO_FLAG,
886 &acceptPolicyCallback,
887 NULL , &accessHandlerCallback, NULL,
888 MHD_OPTION_CONNECTION_LIMIT, (unsigned int) 16,
889 MHD_OPTION_PER_IP_CONNECTION_LIMIT, (unsigned int) 1,
890 MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 16,
891 /* FIXME: set correct limit */
892 MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (16 * 1024),
893 MHD_OPTION_NOTIFY_COMPLETED, &requestCompletedCallback, NULL,
896 if (http_daemon_v4 != NULL)
897 http_task_v4 = http_daemon_prepare (http_daemon_v4);
898 if (http_daemon_v6 != NULL)
899 http_task_v6 = http_daemon_prepare (http_daemon_v6);
901 if (http_task_v4 != GNUNET_SCHEDULER_NO_TASK)
902 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Starting MHD with IPv4 on port %u\n",port);
903 if (http_task_v6 != GNUNET_SCHEDULER_NO_TASK)
904 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Starting MHD with IPv4 and IPv6 on port %u\n",port);
906 /* Initializing cURL */
907 multi_handle = curl_multi_init();
912 /* end of plugin_transport_template.c */