-doxygen
[oweals/gnunet.git] / src / dv / plugin_transport_dv.c
1 /*
2      This file is part of GNUnet
3      (C) 2002--2013 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 3, 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 dv/plugin_transport_dv.c
23  * @brief DV transport service, takes incoming DV requests and deals with
24  * the DV service
25  * @author Nathan Evans
26  * @author Christian Grothoff
27  */
28
29 #include "platform.h"
30 #include "gnunet_util_lib.h"
31 #include "gnunet_protocols.h"
32 #include "gnunet_statistics_service.h"
33 #include "gnunet_dv_service.h"
34 #include "gnunet_transport_service.h"
35 #include "gnunet_transport_plugin.h"
36 #include "dv.h"
37
38
39 #define LOG(kind,...) GNUNET_log_from (kind, "transport-dv",__VA_ARGS__)
40
41 #define PLUGIN_NAME "dv"
42
43 /**
44  * Encapsulation of all of the state of the plugin.
45  */
46 struct Plugin;
47
48
49 /**
50  * An active request for transmission via DV.
51  */
52 struct PendingRequest
53 {
54
55   /**
56    * This is a DLL.
57    */
58   struct PendingRequest *next;
59
60   /**
61    * This is a DLL.
62    */
63   struct PendingRequest *prev;
64
65   /**
66    * Continuation function to call once the transmission buffer
67    * has again space available.  NULL if there is no
68    * continuation to call.
69    */
70   GNUNET_TRANSPORT_TransmitContinuation transmit_cont;
71
72   /**
73    * Closure for transmit_cont.
74    */
75   void *transmit_cont_cls;
76
77   /**
78    * Transmission handle from DV client library.
79    */
80   struct GNUNET_DV_TransmitHandle *th;
81
82   /**
83    * Session of this request.
84    */
85   struct Session *session;
86
87 };
88
89
90 /**
91  * Session handle for connections.
92  */
93 struct Session
94 {
95
96   /**
97    * Mandatory session header.
98    */
99   struct SessionHeader header;
100
101   /**
102    * Pointer to the global plugin struct.
103    */
104   struct Plugin *plugin;
105
106   /**
107    * Head of pending requests.
108    */
109   struct PendingRequest *pr_head;
110
111   /**
112    * Tail of pending requests.
113    */
114   struct PendingRequest *pr_tail;
115
116   /**
117    * To whom are we talking to.
118    */
119   struct GNUNET_PeerIdentity sender;
120
121   /**
122    * Current distance to the given peer.
123    */
124   uint32_t distance;
125
126   /**
127    * Current network the next hop peer is located in
128    */
129   uint32_t network;
130
131   /**
132    * Does the transport service know about this session (and we thus
133    * need to call `session_end` when it is released?)
134    */
135   int active;
136
137 };
138
139
140 /**
141  * Encapsulation of all of the state of the plugin.
142  */
143 struct Plugin
144 {
145   /**
146    * Our environment.
147    */
148   struct GNUNET_TRANSPORT_PluginEnvironment *env;
149
150   /**
151    * Hash map of sessions (active and inactive).
152    */
153   struct GNUNET_CONTAINER_MultiPeerMap *sessions;
154
155   /**
156    * Copy of the handler array where the closures are
157    * set to this struct's instance.
158    */
159   struct GNUNET_SERVER_MessageHandler *handlers;
160
161   /**
162    * Handle to the DV service
163    */
164   struct GNUNET_DV_ServiceHandle *dvh;
165
166   /**
167    * Tokenizer for boxed messages.
168    */
169   struct GNUNET_SERVER_MessageStreamTokenizer *mst;
170
171 };
172
173
174 /**
175  * Notify transport service about the change in distance.
176  *
177  * @param session session where the distance changed
178  */
179 static void
180 notify_distance_change (struct Session *session)
181 {
182   struct Plugin *plugin = session->plugin;
183   struct GNUNET_ATS_Information ats;
184
185   if (GNUNET_YES != session->active)
186     return;
187   ats.type = htonl ((uint32_t) GNUNET_ATS_QUALITY_NET_DISTANCE);
188   ats.value = htonl (session->distance);
189   plugin->env->update_address_metrics (plugin->env->cls,
190                                        &session->sender,
191                                        NULL, 0,
192                                        session,
193                                        &ats, 1);
194 }
195
196
197 /**
198  * Function called by MST on each message from the box.
199  *
200  * @param cls closure with the `struct Plugin *`
201  * @param client identification of the client (with the 'struct Session')
202  * @param message the actual message
203  * @return #GNUNET_OK on success
204  */
205 static int
206 unbox_cb (void *cls,
207           void *client,
208           const struct GNUNET_MessageHeader *message)
209 {
210   struct Plugin *plugin = cls;
211   struct Session *session = client;
212   struct GNUNET_ATS_Information ats;
213
214   ats.type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
215   ats.value = htonl (session->distance);
216   session->active = GNUNET_YES;
217   plugin->env->receive (plugin->env->cls,
218                         &session->sender,
219                         message,
220                         session, "", 0);
221   plugin->env->update_address_metrics (plugin->env->cls,
222                                        &session->sender, NULL,
223                                        0, session,
224                                        &ats, 1);
225   return GNUNET_OK;
226 }
227
228
229 /**
230  * Handler for messages received from the DV service.
231  *
232  * @param cls closure with the plugin
233  * @param sender sender of the message
234  * @param distance how far did the message travel
235  * @param msg actual message payload
236  */
237 static void
238 handle_dv_message_received (void *cls,
239                             const struct GNUNET_PeerIdentity *sender,
240                             uint32_t distance,
241                             const struct GNUNET_MessageHeader *msg)
242 {
243   struct Plugin *plugin = cls;
244   struct GNUNET_ATS_Information ats;
245   struct Session *session;
246
247   LOG (GNUNET_ERROR_TYPE_DEBUG,
248        "Received `%s' message for peer `%s': new distance %u\n",
249        "DV_MESSAGE_RECEIVED",
250        GNUNET_i2s (sender), distance);
251   session = GNUNET_CONTAINER_multipeermap_get (plugin->sessions,
252                                                sender);
253   if (NULL == session)
254   {
255     GNUNET_break (0);
256     return;
257   }
258   if (GNUNET_MESSAGE_TYPE_DV_BOX == ntohs (msg->type))
259   {
260     /* need to unbox using MST */
261     GNUNET_SERVER_mst_receive (plugin->mst,
262                                session,
263                                (const char *) &msg[1],
264                                ntohs (msg->size) - sizeof (struct GNUNET_MessageHeader),
265                                GNUNET_YES,
266                                GNUNET_NO);
267     return;
268   }
269   ats.type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
270   ats.value = htonl (distance);
271   session->active = GNUNET_YES;
272   plugin->env->receive (plugin->env->cls, sender,
273                         msg,
274                         session, "", 0);
275   plugin->env->update_address_metrics (plugin->env->cls,
276                                        sender, "",
277                                        0, session,
278                                        &ats, 1);
279 }
280
281
282 /**
283  * Function called if DV starts to be able to talk to a peer.
284  *
285  * @param cls closure with `struct Plugin *`
286  * @param peer newly connected peer
287  * @param distance distance to the peer
288  * @param network the network the next hop is located in
289  */
290 static void
291 handle_dv_connect (void *cls,
292                    const struct GNUNET_PeerIdentity *peer,
293                    uint32_t distance, uint32_t network)
294 {
295   struct Plugin *plugin = cls;
296   struct Session *session;
297   struct GNUNET_ATS_Information ats[2];
298
299   /**
300    * This requires transport plugin to be linked to libgnunetats.
301    * If you remove it, also remove libgnunetats linkage from Makefile.am
302    */
303   LOG (GNUNET_ERROR_TYPE_DEBUG,
304        "Received `%s' message for peer `%s' with next hop in network %s\n",
305        "DV_CONNECT",
306        GNUNET_i2s (peer),
307        GNUNET_ATS_print_network_type (network));
308
309   session = GNUNET_CONTAINER_multipeermap_get (plugin->sessions,
310                                                peer);
311   if (NULL != session)
312   {
313     GNUNET_break (0);
314     session->distance = distance;
315     notify_distance_change (session);
316     return; /* nothing to do */
317   }
318
319   session = GNUNET_new (struct Session);
320   session->sender = *peer;
321   session->plugin = plugin;
322   session->distance = distance;
323   session->network = network;
324   GNUNET_assert(GNUNET_YES ==
325                 GNUNET_CONTAINER_multipeermap_put (plugin->sessions,
326                                                    &session->sender, session,
327                                                    GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
328
329   LOG (GNUNET_ERROR_TYPE_DEBUG,
330        "Creating new session %p for peer `%s'\n",
331        session,
332        GNUNET_i2s (peer));
333
334   /* Notify transport and ats about new connection */
335   ats[0].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
336   ats[0].value = htonl (distance);
337   ats[1].type = htonl (GNUNET_ATS_NETWORK_TYPE);
338   ats[1].value = htonl (network);
339   session->active = GNUNET_YES;
340   plugin->env->session_start (plugin->env->cls, peer,
341                               PLUGIN_NAME,
342                               NULL, 0,
343                               session, ats, 2);
344 }
345
346
347 /**
348  * Function called if DV distance to a peer is changed.
349  *
350  * @param cls closure with `struct Plugin *`
351  * @param peer connected peer
352  * @param distance new distance to the peer
353  */
354 static void
355 handle_dv_distance_changed (void *cls,
356                             const struct GNUNET_PeerIdentity *peer,
357                             uint32_t distance)
358 {
359   struct Plugin *plugin = cls;
360   struct Session *session;
361
362   LOG (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message for peer `%s': new distance %u\n",
363       "DV_DISTANCE_CHANGED",
364       GNUNET_i2s (peer), distance);
365
366   session = GNUNET_CONTAINER_multipeermap_get (plugin->sessions,
367                                                peer);
368   if (NULL == session)
369   {
370     GNUNET_break (0);
371     /* FIXME */
372     handle_dv_connect (plugin, peer, distance, 0);
373     return;
374   }
375   session->distance = distance;
376   notify_distance_change (session);
377 }
378
379
380 /**
381  * Release session object and clean up associated resources.
382  *
383  * @param session session to clean up
384  */
385 static void
386 free_session (struct Session *session)
387 {
388   struct Plugin *plugin = session->plugin;
389   struct PendingRequest *pr;
390
391   GNUNET_assert (GNUNET_YES ==
392                  GNUNET_CONTAINER_multipeermap_remove (plugin->sessions,
393                                                        &session->sender,
394                                                        session));
395
396   LOG (GNUNET_ERROR_TYPE_DEBUG,
397        "Freeing session %p for peer `%s'\n",
398        session,
399        GNUNET_i2s (&session->sender));
400   if (GNUNET_YES == session->active)
401   {
402     plugin->env->session_end (plugin->env->cls,
403                               &session->sender,
404                               session);
405     session->active = GNUNET_NO;
406   }
407   while (NULL != (pr = session->pr_head))
408   {
409     GNUNET_CONTAINER_DLL_remove (session->pr_head,
410                                  session->pr_tail,
411                                  pr);
412     GNUNET_DV_send_cancel (pr->th);
413     pr->th = NULL;
414     if (NULL != pr->transmit_cont)
415       pr->transmit_cont (pr->transmit_cont_cls,
416                          &session->sender,
417                          GNUNET_SYSERR, 0, 0);
418     GNUNET_free (pr);
419   }
420   GNUNET_free (session);
421 }
422
423
424 /**
425  * Function called if DV is no longer able to talk to a peer.
426  *
427  * @param cls closure with `struct Plugin *`
428  * @param peer peer that disconnected
429  */
430 static void
431 handle_dv_disconnect (void *cls,
432                       const struct GNUNET_PeerIdentity *peer)
433 {
434   struct Plugin *plugin = cls;
435   struct Session *session;
436
437   LOG (GNUNET_ERROR_TYPE_DEBUG,
438        "Received `%s' message for peer `%s'\n",
439        "DV_DISCONNECT",
440        GNUNET_i2s (peer));
441   session = GNUNET_CONTAINER_multipeermap_get (plugin->sessions,
442                                                peer);
443   if (NULL == session)
444     return; /* nothing to do */
445   free_session (session);
446 }
447
448
449 /**
450  * Function called once the delivery of a message has been successful.
451  * Clean up the pending request, and call continuations.
452  *
453  * @param cls closure
454  * @param ok #GNUNET_OK on success, #GNUNET_SYSERR on error
455  */
456 static void
457 send_finished (void *cls,
458                int ok)
459 {
460   struct PendingRequest *pr = cls;
461   struct Session *session = pr->session;
462
463   pr->th = NULL;
464   GNUNET_CONTAINER_DLL_remove (session->pr_head,
465                                session->pr_tail,
466                                pr);
467   if (NULL != pr->transmit_cont)
468     pr->transmit_cont (pr->transmit_cont_cls,
469                        &session->sender,
470                        ok, 0, 0);
471   GNUNET_free (pr);
472 }
473
474
475 /**
476  * Function that can be used by the transport service to transmit
477  * a message using the plugin.
478  *
479  * @param cls closure
480  * @param session the session used
481  * @param priority how important is the message
482  * @param msgbuf the message to transmit
483  * @param msgbuf_size number of bytes in 'msgbuf'
484  * @param timeout when should we time out
485  * @param cont continuation to call once the message has
486  *        been transmitted (or if the transport is ready
487  *        for the next transmission call; or if the
488  *        peer disconnected...)
489  * @param cont_cls closure for @a cont
490  * @return number of bytes used (on the physical network, with overheads);
491  *         -1 on hard errors (i.e. address invalid); 0 is a legal value
492  *         and does NOT mean that the message was not transmitted (DV)
493  */
494 static ssize_t
495 dv_plugin_send (void *cls,
496                 struct Session *session,
497                 const char *msgbuf,
498                 size_t msgbuf_size,
499                 unsigned int priority,
500                 struct GNUNET_TIME_Relative timeout,
501                 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
502 {
503   struct Plugin *plugin = cls;
504   struct PendingRequest *pr;
505   const struct GNUNET_MessageHeader *msg;
506   struct GNUNET_MessageHeader *box;
507
508   box = NULL;
509   msg = (const struct GNUNET_MessageHeader *) msgbuf;
510   if (ntohs (msg->size) != msgbuf_size)
511   {
512     /* need to box */
513     box = GNUNET_malloc (sizeof (struct GNUNET_MessageHeader) + msgbuf_size);
514     box->type = htons (GNUNET_MESSAGE_TYPE_DV_BOX);
515     box->size = htons (sizeof (struct GNUNET_MessageHeader) + msgbuf_size);
516     memcpy (&box[1], msgbuf, msgbuf_size);
517     msg = box;
518   }
519   pr = GNUNET_new (struct PendingRequest);
520   pr->transmit_cont = cont;
521   pr->transmit_cont_cls = cont_cls;
522   pr->session = session;
523   GNUNET_CONTAINER_DLL_insert_tail (session->pr_head,
524                                     session->pr_tail,
525                                     pr);
526
527   pr->th = GNUNET_DV_send (plugin->dvh,
528                            &session->sender,
529                            msg ,
530                            &send_finished,
531                            pr);
532   GNUNET_free_non_null (box);
533   return 0; /* DV */
534 }
535
536
537 /**
538  * Function that can be used to force the plugin to disconnect
539  * from the given peer and cancel all previous transmissions
540  * (and their continuations).
541  *
542  * @param cls closure with the `struct Plugin *`
543  * @param target peer from which to disconnect
544  */
545 static void
546 dv_plugin_disconnect (void *cls,
547                       const struct GNUNET_PeerIdentity *target)
548 {
549   struct Plugin *plugin = cls;
550   struct Session *session;
551   struct PendingRequest *pr;
552
553   session = GNUNET_CONTAINER_multipeermap_get (plugin->sessions,
554                                                target);
555   if (NULL == session)
556     return; /* nothing to do */
557   while (NULL != (pr = session->pr_head))
558   {
559     GNUNET_CONTAINER_DLL_remove (session->pr_head,
560                                  session->pr_tail,
561                                  pr);
562     GNUNET_DV_send_cancel (pr->th);
563     pr->th = NULL;
564     if (NULL != pr->transmit_cont)
565       pr->transmit_cont (pr->transmit_cont_cls,
566                          &session->sender,
567                          GNUNET_SYSERR, 0, 0);
568     GNUNET_free (pr);
569   }
570   session->active = GNUNET_NO;
571 }
572
573
574 /**
575  * Convert the transports address to a nice, human-readable
576  * format.
577  *
578  * @param cls closure
579  * @param type name of the transport that generated the address
580  * @param addr one of the addresses of the host, NULL for the last address
581  *        the specific address format depends on the transport
582  * @param addrlen length of the address
583  * @param numeric should (IP) addresses be displayed in numeric form?
584  * @param timeout after how long should we give up?
585  * @param asc function to call on each string
586  * @param asc_cls closure for @a asc
587  */
588 static void
589 dv_plugin_address_pretty_printer (void *cls, const char *type,
590                                   const void *addr,
591                                   size_t addrlen, int numeric,
592                                   struct GNUNET_TIME_Relative timeout,
593                                   GNUNET_TRANSPORT_AddressStringCallback asc,
594                                   void *asc_cls)
595 {
596   if ( (0 == addrlen) &&
597        (0 == strcmp (type, "dv")) )
598     asc (asc_cls, "dv");
599   asc (asc_cls, NULL);
600 }
601
602
603 /**
604  * Convert the DV address to a pretty string.
605  *
606  * @param cls closure
607  * @param addr the (hopefully) DV address
608  * @param addrlen the length of the @a addr
609  * @return string representing the DV address
610  */
611 static const char *
612 dv_plugin_address_to_string (void *cls,
613                              const void *addr,
614                              size_t addrlen)
615 {
616   if (0 != addrlen)
617   {
618     GNUNET_break (0); /* malformed */
619     return NULL;
620   }
621   return "dv";
622 }
623
624
625 /**
626  * Another peer has suggested an address for this peer and transport
627  * plugin.  Check that this could be a valid address.  This function
628  * is not expected to 'validate' the address in the sense of trying to
629  * connect to it but simply to see if the binary format is technically
630  * legal for establishing a connection to this peer (and make sure that
631  * the address really corresponds to our network connection/settings
632  * and not some potential man-in-the-middle).
633  *
634  * @param cls closure
635  * @param addr pointer to the address
636  * @param addrlen length of addr
637  * @return #GNUNET_OK if this is a plausible address for this peer
638  *         and transport, #GNUNET_SYSERR if not
639  *
640  */
641 static int
642 dv_plugin_check_address (void *cls,
643                          const void *addr,
644                          size_t addrlen)
645 {
646   if (0 != addrlen)
647     return GNUNET_SYSERR;
648   return GNUNET_OK;
649 }
650
651
652 /**
653  * Create a new session to transmit data to the target
654  * This session will used to send data to this peer and the plugin will
655  * notify us by calling the env->session_end function
656  *
657  * @param cls the plugin
658  * @param address the address
659  * @return the session if the address is valid, NULL otherwise
660  */
661 static struct Session *
662 dv_get_session (void *cls,
663                 const struct GNUNET_HELLO_Address *address)
664 {
665   struct Plugin *plugin = cls;
666   struct Session *session;
667
668   if (0 != address->address_length)
669     return NULL;
670   session = GNUNET_CONTAINER_multipeermap_get (plugin->sessions,
671                                                &address->peer);
672   if (NULL == session)
673     return NULL; /* not valid right now */
674   session->active = GNUNET_YES;
675   return session;
676 }
677
678
679 /**
680  * Function called to convert a string address to
681  * a binary address.
682  *
683  * @param cls closure ('struct Plugin*')
684  * @param addr string address
685  * @param addrlen length of the @a addr including \0 termination
686  * @param buf location to store the buffer
687  *        If the function returns #GNUNET_SYSERR, its contents are undefined.
688  * @param added length of created address
689  * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
690  */
691 static int
692 dv_plugin_string_to_address (void *cls,
693                              const char *addr,
694                              uint16_t addrlen,
695                              void **buf,
696                              size_t *added)
697 {
698   if ( (addrlen == 3) &&
699        (0 == strcmp ("dv", addr)) )
700   {
701     *added = 0;
702     return GNUNET_OK;
703   }
704   return GNUNET_SYSERR;
705 }
706
707
708
709 /**
710  * Function to obtain the network type for a session
711  * FIXME: we should probably look at the network type
712  * used by the next hop here.  Or find some other way
713  * to properly allow ATS-DV resource allocation.
714  *
715  * @param cls closure (`struct Plugin *`)
716  * @param session the session
717  * @return the network type
718  */
719 static enum GNUNET_ATS_Network_Type
720 dv_get_network (void *cls,
721                 struct Session *session)
722 {
723   GNUNET_assert (NULL != session);
724   return session->network;
725 }
726
727
728 /**
729  * Entry point for the plugin.
730  *
731  * @param cls closure with the plugin environment
732  * @return plugin API
733  */
734 void *
735 libgnunet_plugin_transport_dv_init (void *cls)
736 {
737   struct GNUNET_TRANSPORT_PluginEnvironment *env = cls;
738   struct GNUNET_TRANSPORT_PluginFunctions *api;
739   struct Plugin *plugin;
740
741   plugin = GNUNET_new (struct Plugin);
742   plugin->env = env;
743   plugin->sessions = GNUNET_CONTAINER_multipeermap_create (1024 * 8, GNUNET_YES);
744   plugin->mst = GNUNET_SERVER_mst_create (&unbox_cb,
745                                           plugin);
746   plugin->dvh = GNUNET_DV_service_connect (env->cfg,
747                                            plugin,
748                                            &handle_dv_connect,
749                                            &handle_dv_distance_changed,
750                                            &handle_dv_disconnect,
751                                            &handle_dv_message_received);
752   if (NULL == plugin->dvh)
753   {
754     GNUNET_CONTAINER_multipeermap_destroy (plugin->sessions);
755     GNUNET_SERVER_mst_destroy (plugin->mst);
756     GNUNET_free (plugin);
757     return NULL;
758   }
759   api = GNUNET_new (struct GNUNET_TRANSPORT_PluginFunctions);
760   api->cls = plugin;
761   api->send = &dv_plugin_send;
762   api->disconnect = &dv_plugin_disconnect;
763   api->address_pretty_printer = &dv_plugin_address_pretty_printer;
764   api->check_address = &dv_plugin_check_address;
765   api->address_to_string = &dv_plugin_address_to_string;
766   api->string_to_address = &dv_plugin_string_to_address;
767   api->get_session = &dv_get_session;
768   api->get_network = &dv_get_network;
769   return api;
770 }
771
772
773 /**
774  * Function called to free a session.
775  *
776  * @param cls NULL
777  * @param key unused
778  * @param value session to free
779  * @return GNUNET_OK (continue to iterate)
780  */
781 static int
782 free_session_iterator (void *cls,
783                        const struct GNUNET_PeerIdentity *key,
784                        void *value)
785 {
786   struct Session *session = value;
787
788   free_session (session);
789   return GNUNET_OK;
790 }
791
792
793 /**
794  * Exit point from the plugin.
795  *
796  * @param cls plugin API
797  * @return NULL
798  */
799 void *
800 libgnunet_plugin_transport_dv_done (void *cls)
801 {
802   struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
803   struct Plugin *plugin = api->cls;
804
805   GNUNET_DV_service_disconnect (plugin->dvh);
806   GNUNET_CONTAINER_multipeermap_iterate (plugin->sessions,
807                                          &free_session_iterator,
808                                          NULL);
809   GNUNET_CONTAINER_multipeermap_destroy (plugin->sessions);
810   GNUNET_SERVER_mst_destroy (plugin->mst);
811   GNUNET_free (plugin);
812   GNUNET_free (api);
813   return NULL;
814 }
815
816 /* end of plugin_transport_dv.c */