(no commit message)
[oweals/gnunet.git] / src / transport / plugin_transport_http.c
1 /*
2      This file is part of GNUnet
3      (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Christian Grothoff (and other contributing authors)
4
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.
9
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.
14
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.
19 */
20
21 /**
22  * @file transport/plugin_transport_template.c
23  * @brief template for a new transport service
24  * @author Christian Grothoff
25  */
26
27 #include "platform.h"
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 "plugin_transport.h"
35 #include "microhttpd.h"
36 #include <curl/curl.h>
37
38 #define DEBUG_HTTP GNUNET_NO
39
40 /**
41  * Text of the response sent back after the last bytes of a PUT
42  * request have been received (just to formally obey the HTTP
43  * protocol).
44  */
45 #define HTTP_PUT_RESPONSE "Thank you!"
46
47
48 /**
49  * After how long do we expire an address that we
50  * learned from another peer if it is not reconfirmed
51  * by anyone?
52  */
53 #define LEARNED_ADDRESS_EXPIRATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 6)
54
55
56 /**
57  * Encapsulation of all of the state of the plugin.
58  */
59 struct Plugin;
60
61
62 /**
63  * Session handle for connections.
64  */
65 struct Session
66 {
67
68   /**
69    * Stored in a linked list.
70    */
71   struct Session *next;
72
73   /**
74    * Pointer to the global plugin struct.
75    */
76   struct Plugin *plugin;
77
78   /**
79    * Continuation function to call once the transmission buffer
80    * has again space available.  NULL if there is no
81    * continuation to call.
82    */
83   GNUNET_TRANSPORT_TransmitContinuation transmit_cont;
84
85   /**
86    * Closure for transmit_cont.
87    */
88   void *transmit_cont_cls;
89
90   /**
91    * To whom are we talking to (set to our identity
92    * if we are still waiting for the welcome message)
93    */
94   struct GNUNET_PeerIdentity sender;
95
96   /**
97    * Sender's url
98    */
99   char * url;
100
101   /**
102    * Sender's ip address to distinguish between incoming connections
103    */
104   char * ip;
105
106   /**
107    * Did we initiate the connection (GNUNET_YES) or the other peer (GNUNET_NO)?
108    */
109   unsigned int is_client;
110
111   /**
112    * At what time did we reset last_received last?
113    */
114   struct GNUNET_TIME_Absolute last_quota_update;
115
116   /**
117    * How many bytes have we received since the "last_quota_update"
118    * timestamp?
119    */
120   uint64_t last_received;
121
122   /**
123    * Number of bytes per ms that this peer is allowed
124    * to send to us.
125    */
126   uint32_t quota;
127
128 };
129
130 /**
131  * Encapsulation of all of the state of the plugin.
132  */
133 struct Plugin
134 {
135   /**
136    * Our environment.
137    */
138   struct GNUNET_TRANSPORT_PluginEnvironment *env;
139
140   /**
141    * List of open sessions.
142    */
143   struct Session *sessions;
144
145 };
146
147 /**
148  * Daemon for listening for new IPv4 connections.
149  */
150 static struct MHD_Daemon *http_daemon_v4;
151
152 /**
153  * Daemon for listening for new IPv6connections.
154  */
155 static struct MHD_Daemon *http_daemon_v6;
156
157 /**
158  * Our primary task for http daemon handling IPv4 connections
159  */
160 static GNUNET_SCHEDULER_TaskIdentifier http_task_v4;
161
162 /**
163  * Our primary task for http daemon handling IPv6 connections
164  */
165 static GNUNET_SCHEDULER_TaskIdentifier http_task_v6;
166
167 struct Plugin *plugin;
168
169 static CURLM *multi_handle;
170
171
172 /**
173  * Finds a http session in our linked list using peer identity as a key
174  * @param peer peeridentity
175  * @return http session corresponding to peer identity
176  */
177 static struct Session * find_session_by_pi( const struct GNUNET_PeerIdentity *peer )
178 {
179   struct Session * cur;
180   GNUNET_HashCode hc_peer;
181   GNUNET_HashCode hc_current;
182
183   cur = plugin->sessions;
184   hc_peer = peer->hashPubKey;
185   while (cur != NULL)
186   {
187     hc_current = cur->sender.hashPubKey;
188     if ( 0 == GNUNET_CRYPTO_hash_cmp( &hc_peer, &hc_current))
189       return cur;
190     cur = plugin->sessions->next;
191   }
192   return NULL;
193 }
194
195 #if 0
196 /**
197  * Finds a http session in our linked list using peer identity as a key
198  * @param peer peeridentity
199  * @return http session corresponding to peer identity
200  */
201 static struct Session * find_session_by_ip( struct sockaddr_in * addr )
202 {
203   /*
204   struct Session * cur;
205
206   cur = plugin->sessions;
207   while (cur != NULL)
208   {
209     hc_current = cur->sender.hashPubKey;
210     if ( 0 == GNUNET_CRYPTO_hash_cmp( &hc_peer, &hc_current))
211       return cur;
212     cur = plugin->sessions->next;
213   }
214   */
215   return NULL;
216 }
217 #endif
218
219 /**
220  * Creates a http session in our linked list by peer identity
221  * Only peer is set here, all other  fields have to be set by calling method
222  * @param peer peeridentity
223  * @return created http session
224  */
225 static struct Session * create_session_by_pi( const struct GNUNET_PeerIdentity *peer )
226 {
227   struct Session * cur;
228   struct Session * last_in_list;
229   /* Create a new session object */
230   cur = GNUNET_malloc (sizeof (struct Session));
231   memcpy( &(cur->sender), peer, sizeof( struct GNUNET_PeerIdentity ) );
232
233   cur->next = NULL;
234
235   /* Insert into linked list */
236   last_in_list = plugin->sessions;
237   while (last_in_list->next != NULL)
238   {
239     last_in_list = last_in_list->next;
240   }
241   last_in_list->next = cur;
242
243   return cur;
244 }
245
246 /**
247  * Callback called by MHD when a connection is terminated
248  */
249 static void requestCompletedCallback (void *cls, struct MHD_Connection * connection, void **httpSessionCache)
250 {
251   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection was terminated\n");
252   return;
253 }
254
255 /**
256  * Check if we are allowed to connect to the given IP.
257  */
258 static int
259 acceptPolicyCallback (void *cls,
260                       const struct sockaddr *addr, socklen_t addr_len)
261 {
262   struct sockaddr_in * addrin =(struct sockaddr_in *) addr;
263   /* 40 == max IPv6 Address length as string: (4 * 8) + (7 * :) + \0 */
264   char * address = GNUNET_malloc(40);
265   inet_ntop(addrin->sin_family, &addrin->sin_addr.s_addr,address,40);
266   if (addrin->sin_family == AF_INET)
267     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Incoming IPv4 connection from `%s'\n", address);
268   if (addrin->sin_family == AF_INET6)
269     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Incoming IPv6 connection from `%s'\n",address);
270   GNUNET_free (address);
271
272   return MHD_YES;
273 }
274
275
276 /**
277  * Process GET or PUT request received via MHD.  For
278  * GET, queue response that will send back our pending
279  * messages.  For PUT, process incoming data and send
280  * to GNUnet core.  In either case, check if a session
281  * already exists and create a new one if not.
282  */
283 static int
284 accessHandlerCallback (void *cls,
285                        struct MHD_Connection *session,
286                        const char *url,
287                        const char *method,
288                        const char *version,
289                        const char *upload_data,
290                        size_t * upload_data_size, void **httpSessionCache)
291 {
292   //struct Session * http_session;
293
294   struct MHD_Response *response;
295   unsigned int have;
296
297   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"HTTP Daemon has an incoming `%s' request from \n",method);
298   if (*httpSessionCache==NULL)
299     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"New request \n",method);
300   else
301     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Already known request \n",method);
302
303   /*  Find out if session exists, otherwise create one */
304   //struct sockaddr_in * test = session->addr;
305   //http_session = find_session_by_ip ( test );
306
307
308   /* Is it a PUT or a GET request */
309   if ( 0 == strcmp (MHD_HTTP_METHOD_PUT, method) )
310   {
311     /* PUT method here */
312     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Got PUT Request with size %lu \n",(*upload_data_size));
313     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"URL: `%s'\n",url);
314     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"PUT Request: `%s'\n",upload_data);
315     /* FIXME: GNUNET_STATISTICS_update( plugin->env->stats , gettext_noop("# PUT requests"), 1, GNUNET_NO); */
316     have = *upload_data_size;
317     /* No data left */
318     *upload_data_size = 0;
319     response = MHD_create_response_from_data (strlen (HTTP_PUT_RESPONSE),HTTP_PUT_RESPONSE, MHD_NO, MHD_NO);
320     MHD_queue_response (session, MHD_HTTP_OK, response);
321     MHD_destroy_response (response);
322   }
323   if ( 0 == strcmp (MHD_HTTP_METHOD_GET, method) )
324   {
325     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Got GET Request\n");
326     //GNUNET_STATISTICS_update( plugin->env->stats , gettext_noop("# GET requests"), 1, GNUNET_NO);
327   }
328
329   return MHD_YES;
330 }
331
332
333 /**
334  * Call MHD to process pending requests and then go back
335  * and schedule the next run.
336  */
337 static void http_daemon_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
338
339 /**
340  * Function that queries MHD's select sets and
341  * starts the task waiting for them.
342  */
343 static GNUNET_SCHEDULER_TaskIdentifier
344 http_daemon_prepare (struct MHD_Daemon *daemon_handle)
345 {
346   GNUNET_SCHEDULER_TaskIdentifier ret;
347   fd_set rs;
348   fd_set ws;
349   fd_set es;
350   struct GNUNET_NETWORK_FDSet *wrs;
351   struct GNUNET_NETWORK_FDSet *wws;
352   struct GNUNET_NETWORK_FDSet *wes;
353   int max;
354   unsigned long long timeout;
355   int haveto;
356   struct GNUNET_TIME_Relative tv;
357
358   FD_ZERO(&rs);
359   FD_ZERO(&ws);
360   FD_ZERO(&es);
361   wrs = GNUNET_NETWORK_fdset_create ();
362   wes = GNUNET_NETWORK_fdset_create ();
363   wws = GNUNET_NETWORK_fdset_create ();
364   max = -1;
365   GNUNET_assert (MHD_YES ==
366                  MHD_get_fdset (daemon_handle,
367                                 &rs,
368                                 &ws,
369                                 &es,
370                                 &max));
371   haveto = MHD_get_timeout (daemon_handle, &timeout);
372   if (haveto == MHD_YES)
373     tv.value = (uint64_t) timeout;
374   else
375     tv = GNUNET_TIME_UNIT_FOREVER_REL;
376   GNUNET_NETWORK_fdset_copy_native (wrs, &rs, max);
377   GNUNET_NETWORK_fdset_copy_native (wws, &ws, max);
378   GNUNET_NETWORK_fdset_copy_native (wes, &es, max);
379   ret = GNUNET_SCHEDULER_add_select (plugin->env->sched,
380                                      GNUNET_SCHEDULER_PRIORITY_HIGH,
381                                      GNUNET_SCHEDULER_NO_TASK,
382                                      tv,
383                                      wrs,
384                                      wws,
385                                      &http_daemon_run,
386                                      daemon_handle);
387   GNUNET_NETWORK_fdset_destroy (wrs);
388   GNUNET_NETWORK_fdset_destroy (wws);
389   GNUNET_NETWORK_fdset_destroy (wes);
390   return ret;
391 }
392
393 /**
394  * Call MHD to process pending requests and then go back
395  * and schedule the next run.
396  */
397 static void
398 http_daemon_run (void *cls,
399             const struct GNUNET_SCHEDULER_TaskContext *tc)
400 {
401   struct MHD_Daemon *daemon_handle = cls;
402
403   if (daemon_handle == http_daemon_v4)
404     http_task_v4 = GNUNET_SCHEDULER_NO_TASK;
405
406   if (daemon_handle == http_daemon_v6)
407     http_task_v6 = GNUNET_SCHEDULER_NO_TASK;
408
409   if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
410     return;
411
412   GNUNET_assert (MHD_YES == MHD_run (daemon_handle));
413   if (daemon_handle == http_daemon_v4)
414     http_task_v4 = http_daemon_prepare (daemon_handle);
415   if (daemon_handle == http_daemon_v6)
416     http_task_v6 = http_daemon_prepare (daemon_handle);
417   return;
418 }
419
420 static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream)
421 {
422   size_t retcode;
423   /*
424   fprintf(stdout, "*** Read callback: size %u, size nmemb: %u \n", size, nmemb);
425   retcode = fread(ptr, size, nmemb, stream);
426    */
427   retcode = 0;
428   return retcode;
429 }
430
431 /**
432  * Function that can be used by the transport service to transmit
433  * a message using the plugin.
434  *
435  * @param cls closure
436  * @param target who should receive this message
437  * @param priority how important is the message
438  * @param msgbuf the message to transmit
439  * @param msgbuf_size number of bytes in 'msgbuf'
440  * @param timeout when should we time out
441  * @param session which session must be used (or NULL for "any")
442  * @param addr the address to use (can be NULL if the plugin
443  *                is "on its own" (i.e. re-use existing TCP connection))
444  * @param addrlen length of the address in bytes
445  * @param force_address GNUNET_YES if the plugin MUST use the given address,
446  *                otherwise the plugin may use other addresses or
447  *                existing connections (if available)
448  * @param cont continuation to call once the message has
449  *        been transmitted (or if the transport is ready
450  *        for the next transmission call; or if the
451  *        peer disconnected...)
452  * @param cont_cls closure for cont
453  * @return number of bytes used (on the physical network, with overheads);
454  *         -1 on hard errors (i.e. address invalid); 0 is a legal value
455  *         and does NOT mean that the message was not transmitted (DV)
456  */
457 static ssize_t
458 template_plugin_send (void *cls,
459                       const struct GNUNET_PeerIdentity *
460                       target,
461                       const char *msgbuf,
462                       size_t msgbuf_size,
463                       unsigned int priority,
464                       struct GNUNET_TIME_Relative timeout,
465                       struct Session *session,
466                       const void *addr,
467                       size_t addrlen,
468                       int force_address,
469                       GNUNET_TRANSPORT_TransmitContinuation
470                       cont, void *cont_cls)
471 {
472   struct Session* ses;
473   int bytes_sent = 0;
474   /*  struct Plugin *plugin = cls; */
475   CURL *curl_handle;
476   /* CURLcode res; */
477
478   /* find session for peer */
479   ses = find_session_by_pi (target);
480   if ( ses == NULL) create_session_by_pi (target);
481
482   char *url = "http://localhost:12389";
483
484   curl_handle = curl_easy_init();
485   if( NULL == curl_handle)
486   {
487     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Getting cURL handle failed\n");
488     return -1;
489   }
490   curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1L);
491   curl_easy_setopt(curl_handle, CURLOPT_READFUNCTION, read_callback);
492   curl_easy_setopt(curl_handle, CURLOPT_UPLOAD, 1L);
493   curl_easy_setopt(curl_handle, CURLOPT_PUT, 1L);
494   curl_easy_setopt(curl_handle, CURLOPT_URL, url);
495   curl_easy_setopt(curl_handle, CURLOPT_READDATA, msgbuf);
496   curl_easy_setopt(curl_handle, CURLOPT_INFILESIZE_LARGE,
497                   (curl_off_t)msgbuf_size);
498
499
500
501   return bytes_sent;
502 }
503
504
505
506 /**
507  * Function that can be used to force the plugin to disconnect
508  * from the given peer and cancel all previous transmissions
509  * (and their continuationc).
510  *
511  * @param cls closure
512  * @param target peer from which to disconnect
513  */
514 static void
515 template_plugin_disconnect (void *cls,
516                             const struct GNUNET_PeerIdentity *target)
517 {
518   // struct Plugin *plugin = cls;
519   // FIXME
520 }
521
522
523 /**
524  * Convert the transports address to a nice, human-readable
525  * format.
526  *
527  * @param cls closure
528  * @param type name of the transport that generated the address
529  * @param addr one of the addresses of the host, NULL for the last address
530  *        the specific address format depends on the transport
531  * @param addrlen length of the address
532  * @param numeric should (IP) addresses be displayed in numeric form?
533  * @param timeout after how long should we give up?
534  * @param asc function to call on each string
535  * @param asc_cls closure for asc
536  */
537 static void
538 template_plugin_address_pretty_printer (void *cls,
539                                         const char *type,
540                                         const void *addr,
541                                         size_t addrlen,
542                                         int numeric,
543                                         struct GNUNET_TIME_Relative timeout,
544                                         GNUNET_TRANSPORT_AddressStringCallback
545                                         asc, void *asc_cls)
546 {
547   asc (asc_cls, NULL);
548 }
549
550
551
552 /**
553  * Another peer has suggested an address for this
554  * peer and transport plugin.  Check that this could be a valid
555  * address.  If so, consider adding it to the list
556  * of addresses.
557  *
558  * @param cls closure
559  * @param addr pointer to the address
560  * @param addrlen length of addr
561  * @return GNUNET_OK if this is a plausible address for this peer
562  *         and transport
563  */
564 static int
565 template_plugin_address_suggested (void *cls,
566                                   void *addr, size_t addrlen)
567 {
568   /* struct Plugin *plugin = cls; */
569
570   /* check if the address is plausible; if so,
571      add it to our list! */
572   return GNUNET_OK;
573 }
574
575
576 /**
577  * Function called for a quick conversion of the binary address to
578  * a numeric address.  Note that the caller must not free the
579  * address and that the next call to this function is allowed
580  * to override the address again.
581  *
582  * @param cls closure
583  * @param addr binary address
584  * @param addrlen length of the address
585  * @return string representing the same address
586  */
587 static const char*
588 template_plugin_address_to_string (void *cls,
589                                    const void *addr,
590                                    size_t addrlen)
591 {
592   GNUNET_break (0);
593   return NULL;
594 }
595
596 /**
597  * Exit point from the plugin.
598  */
599 void *
600 libgnunet_plugin_transport_http_done (void *cls)
601 {
602   struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
603   struct Plugin *plugin = api->cls;
604
605   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Unloading http plugin...\n");
606
607   if ( http_task_v4 != GNUNET_SCHEDULER_NO_TASK)
608   {
609     GNUNET_SCHEDULER_cancel(plugin->env->sched, http_task_v4);
610     http_task_v4 = GNUNET_SCHEDULER_NO_TASK;
611   }
612
613   if ( http_task_v6 != GNUNET_SCHEDULER_NO_TASK)
614   {
615     GNUNET_SCHEDULER_cancel(plugin->env->sched, http_task_v6);
616     http_task_v6 = GNUNET_SCHEDULER_NO_TASK;
617   }
618
619   if (http_daemon_v4 != NULL)
620   {
621     MHD_stop_daemon (http_daemon_v4);
622     http_daemon_v4 = NULL;
623   }
624   if (http_daemon_v6 != NULL)
625   {
626     MHD_stop_daemon (http_daemon_v6);
627     http_daemon_v6 = NULL;
628   }
629
630   curl_multi_cleanup(multi_handle);
631
632   GNUNET_free (plugin);
633   GNUNET_free (api);
634   return NULL;
635 }
636
637
638 /**
639  * Entry point for the plugin.
640  */
641 void *
642 libgnunet_plugin_transport_http_init (void *cls)
643 {
644   struct GNUNET_TRANSPORT_PluginEnvironment *env = cls;
645   struct GNUNET_TRANSPORT_PluginFunctions *api;
646
647   long long unsigned int port;
648
649   plugin = GNUNET_malloc (sizeof (struct Plugin));
650   plugin->env = env;
651   plugin->sessions = NULL;
652   api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
653   api->cls = plugin;
654   api->send = &template_plugin_send;
655   api->disconnect = &template_plugin_disconnect;
656   api->address_pretty_printer = &template_plugin_address_pretty_printer;
657   api->check_address = &template_plugin_address_suggested;
658   api->address_to_string = &template_plugin_address_to_string;
659
660   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Starting http plugin...\n");
661   /* Reading port number from config file */
662   if ((GNUNET_OK !=
663        GNUNET_CONFIGURATION_get_value_number (env->cfg,
664                                               "transport-http",
665                                               "PORT",
666                                               &port)) ||
667       (port > 65535) )
668     {
669       GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
670                        "http",
671                        _
672                        ("Require valid port number for transport plugin `%s' in configuration!\n"),
673                        "transport-http");
674       libgnunet_plugin_transport_http_done (api);
675       return NULL;
676     }
677
678   if ((http_daemon_v4 == NULL) && (http_daemon_v6 == NULL) && (port != 0))
679     {
680     http_daemon_v6 = MHD_start_daemon (MHD_USE_IPv6,
681                                        port,
682                                        &acceptPolicyCallback,
683                                        NULL, &accessHandlerCallback, NULL,
684                                        MHD_OPTION_CONNECTION_LIMIT, (unsigned int) 16,
685                                        MHD_OPTION_PER_IP_CONNECTION_LIMIT, (unsigned int) 1,
686                                        MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 16,
687                                        MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (16 * 1024),
688                                        MHD_OPTION_NOTIFY_COMPLETED, &requestCompletedCallback, NULL,
689                                        MHD_OPTION_END);
690     http_daemon_v4 = MHD_start_daemon (MHD_NO_FLAG,
691                                        port,
692                                        &acceptPolicyCallback,
693                                        NULL, &accessHandlerCallback, NULL,
694                                        MHD_OPTION_CONNECTION_LIMIT, (unsigned int) 16,
695                                        MHD_OPTION_PER_IP_CONNECTION_LIMIT, (unsigned int) 1,
696                                        MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 16,
697                                        MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (16 * 1024),
698                                        MHD_OPTION_NOTIFY_COMPLETED, &requestCompletedCallback, NULL,
699                                        MHD_OPTION_END);
700     }
701
702   if (http_daemon_v4 != NULL)
703     http_task_v4 = http_daemon_prepare (http_daemon_v4);
704   if (http_daemon_v6 != NULL)
705     http_task_v6 = http_daemon_prepare (http_daemon_v6);
706
707   if (http_task_v4 != GNUNET_SCHEDULER_NO_TASK)
708     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Starting MHD with IPv4 on port %u\n",port);
709   if (http_task_v6 != GNUNET_SCHEDULER_NO_TASK)
710     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Starting MHD with IPv4 and IPv6 on port %u\n",port);
711
712   /* Initializing cURL */
713   multi_handle = curl_multi_init();
714
715   return api;
716 }
717
718 /* end of plugin_transport_template.c */