2 This file is part of GNUnet
3 (C) 2010-2014 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 3, 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_unix.c
23 * @brief Transport plugin using unix domain sockets (!)
24 * Clearly, can only be used locally on Unix/Linux hosts...
25 * ONLY INTENDED FOR TESTING!!!
26 * @author Christian Grothoff
27 * @author Nathan Evans
30 #include "gnunet_util_lib.h"
31 #include "gnunet_hello_lib.h"
32 #include "gnunet_protocols.h"
33 #include "gnunet_statistics_service.h"
34 #include "gnunet_transport_service.h"
35 #include "gnunet_transport_plugin.h"
36 #include "transport.h"
40 * Return code we give on 'send' if we failed to send right now
41 * but it makes sense to retry later. (Note: we might want to
42 * move this to the plugin API!?).
46 #define PLUGIN_NAME "unix"
48 enum UNIX_ADDRESS_OPTIONS
50 UNIX_OPTIONS_NONE = 0,
51 UNIX_OPTIONS_USE_ABSTRACT_SOCKETS = 1
56 * How long until we give up on transmitting the welcome message?
58 #define HOSTNAME_RESOLVE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
60 #define LOG(kind,...) GNUNET_log_from (kind, "transport-unix",__VA_ARGS__)
63 GNUNET_NETWORK_STRUCT_BEGIN
66 * Binary format for an UNIX Domain Socket address in GNUnet.
71 * Options to use for the address, in NBO
73 uint32_t options GNUNET_PACKED;
76 * Length of the address (path length), in NBO
78 uint32_t addrlen GNUNET_PACKED;
80 /* followed by actual path */
85 * UNIX Message-Packet header.
92 struct GNUNET_MessageHeader header;
95 * What is the identity of the sender (GNUNET_hash of public key)
97 struct GNUNET_PeerIdentity sender;
101 GNUNET_NETWORK_STRUCT_END
104 * Handle for a session.
109 * To whom are we talking to (set to our identity
110 * if we are still waiting for the welcome message).
112 * FIXME: information duplicated with 'peer' in address!
114 struct GNUNET_PeerIdentity target;
117 * Pointer to the global plugin struct.
119 struct Plugin *plugin;
122 * Address of the other peer.
124 struct GNUNET_HELLO_Address *address;
127 * Session timeout task
129 GNUNET_SCHEDULER_TaskIdentifier timeout_task;
136 struct UNIXMessageWrapper
139 * We keep messages in a doubly linked list.
141 struct UNIXMessageWrapper *next;
144 * We keep messages in a doubly linked list.
146 struct UNIXMessageWrapper *prev;
149 * The actual payload (allocated separately right now).
151 struct UNIXMessage *msg;
154 * Session this message belongs to.
156 struct Session *session;
159 * Function to call upon transmission.
161 GNUNET_TRANSPORT_TransmitContinuation cont;
164 * Closure for @e cont.
169 * Timeout for this message.
171 struct GNUNET_TIME_Absolute timeout;
174 * Number of bytes in @e msg.
179 * Number of bytes of payload encapsulated in @e msg.
184 * Priority of the message (ignored, just dragged along in UNIX).
186 unsigned int priority;
191 * Encapsulation of all of the state of the plugin.
197 * Information we keep for each of our listen sockets.
199 struct UNIX_Sock_Info
204 struct GNUNET_NETWORK_Handle *desc;
207 * The port we bound to (not an actual PORT, as UNIX domain sockets
208 * don't have ports, but rather a number in the path name to make this
216 * Encapsulation of all of the state of the plugin.
222 * ID of task used to update our addresses when one expires.
224 GNUNET_SCHEDULER_TaskIdentifier address_update_task;
229 GNUNET_SCHEDULER_TaskIdentifier select_task;
232 * Number of bytes we currently have in our write queue.
234 unsigned long long bytes_in_queue;
239 struct GNUNET_TRANSPORT_PluginEnvironment *env;
242 * Sessions (map from peer identity to `struct Session`)
244 struct GNUNET_CONTAINER_MultiPeerMap *session_map;
249 struct GNUNET_NETWORK_FDSet *rs;
254 struct GNUNET_NETWORK_FDSet *ws;
257 * Path of our unix domain socket (/tmp/unix-plugin-PORT)
259 char *unix_socket_path;
262 * Head of queue of messages to transmit.
264 struct UNIXMessageWrapper *msg_head;
267 * Tail of queue of messages to transmit.
269 struct UNIXMessageWrapper *msg_tail;
272 * Function to call about session status changes.
274 GNUNET_TRANSPORT_SessionInfoCallback sic;
277 * Closure for @e sic.
282 * socket that we transmit all data with
284 struct UNIX_Sock_Info unix_sock;
287 * Address options in HBO
294 struct GNUNET_ATS_Information ats_network;
297 * Is the write set in the current 'select' task? #GNUNET_NO if the
298 * write queue was empty when the main task was scheduled,
299 * #GNUNET_YES if we're already waiting for being allowed to write.
304 * Are we using an abstract UNIX domain socket?
312 * Increment session timeout due to activity
314 * @param s session for which the timeout should be moved
317 reschedule_session_timeout (struct Session *s);
321 * We have been notified that our writeset has something to read. We don't
322 * know which socket needs to be read, so we have to check each one
323 * Then reschedule this function to be called again once more is available.
325 * @param cls the plugin handle
326 * @param tc the scheduling context (for rescheduling this function again)
329 unix_plugin_select (void *cls,
330 const struct GNUNET_SCHEDULER_TaskContext *tc);
334 * Convert unix path to a `struct sockaddr_un`
336 * @param unixpath path to convert
337 * @param sock_len[out] set to the length of the address
338 * @return converted unix path
340 static struct sockaddr_un *
341 unix_address_to_sockaddr (const char *unixpath,
344 struct sockaddr_un *un;
347 GNUNET_assert (0 < strlen (unixpath)); /* sanity check */
348 un = GNUNET_new (struct sockaddr_un);
349 un->sun_family = AF_UNIX;
350 slen = strlen (unixpath);
351 if (slen >= sizeof (un->sun_path))
352 slen = sizeof (un->sun_path) - 1;
353 memcpy (un->sun_path, unixpath, slen);
354 un->sun_path[slen] = '\0';
355 slen = sizeof (struct sockaddr_un);
356 #if HAVE_SOCKADDR_IN_SIN_LEN
357 un->sun_len = (u_char) slen;
365 * Function called for a quick conversion of the binary address to
366 * a numeric address. Note that the caller must not free the
367 * address and that the next call to this function is allowed
368 * to override the address again.
371 * @param addr binary address
372 * @param addrlen length of the @a addr
373 * @return string representing the same address
376 unix_address_to_string (void *cls,
380 static char rbuf[1024];
381 struct UnixAddress *ua = (struct UnixAddress *) addr;
386 if ((NULL == addr) || (sizeof (struct UnixAddress) > addrlen))
391 addrstr = (char *) &ua[1];
392 addr_str_len = ntohl (ua->addrlen);
394 if (addr_str_len != addrlen - sizeof(struct UnixAddress))
399 if ('\0' != addrstr[addr_str_len - 1])
404 if (strlen (addrstr) + 1 != addr_str_len)
411 if ('\0' == addrstr[0])
413 memset (rbuf, 0, sizeof (rbuf));
414 GNUNET_snprintf (rbuf,
419 (off == 1) ? "@" : "",
420 (int) (addr_str_len - off),
427 * Re-schedule the main 'select' callback (#unix_plugin_select())
430 * @param plugin the plugin context
433 reschedule_select (struct Plugin *plugin)
435 if (plugin->select_task != GNUNET_SCHEDULER_NO_TASK)
437 GNUNET_SCHEDULER_cancel (plugin->select_task);
438 plugin->select_task = GNUNET_SCHEDULER_NO_TASK;
440 if (NULL != plugin->msg_head)
442 plugin->select_task =
443 GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
444 GNUNET_TIME_UNIT_FOREVER_REL,
447 &unix_plugin_select, plugin);
448 plugin->with_ws = GNUNET_YES;
452 plugin->select_task =
453 GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
454 GNUNET_TIME_UNIT_FOREVER_REL,
457 &unix_plugin_select, plugin);
458 plugin->with_ws = GNUNET_NO;
464 * Closure to #lookup_session_it().
469 * Location to store the session, if found.
474 * Address we are looking for.
476 const struct GNUNET_HELLO_Address *address;
481 * Function called to find a session by address.
483 * @param cls the `struct LookupCtx *`
484 * @param key peer we are looking for (unused)
485 * @param value a session
486 * @return #GNUNET_YES if not found (continue looking), #GNUNET_NO on success
489 lookup_session_it (void *cls,
490 const struct GNUNET_PeerIdentity * key,
493 struct LookupCtx *lctx = cls;
494 struct Session *s = value;
496 if (0 == GNUNET_HELLO_address_cmp (lctx->address, s->address))
506 * Find an existing session by address.
508 * @param plugin the plugin
509 * @param address the address to find
510 * @return NULL if session was not found
512 static struct Session *
513 lookup_session (struct Plugin *plugin,
514 const struct GNUNET_HELLO_Address *address)
516 struct LookupCtx lctx;
518 lctx.address = address;
520 GNUNET_CONTAINER_multipeermap_get_multiple (plugin->session_map,
522 &lookup_session_it, &lctx);
528 * Functions with this signature are called whenever we need
529 * to close a session due to a disconnect or failure to
530 * establish a connection.
532 * @param cls closure with the `struct Plugin`
533 * @param s session to close down
534 * @return #GNUNET_OK on success
537 unix_session_disconnect (void *cls,
540 struct Plugin *plugin = cls;
541 struct UNIXMessageWrapper *msgw;
542 struct UNIXMessageWrapper *next;
545 LOG (GNUNET_ERROR_TYPE_DEBUG,
546 "Disconnecting session for peer `%s' `%s'\n",
547 GNUNET_i2s (&s->target),
548 unix_address_to_string (NULL,
550 s->address->address_length));
551 plugin->env->session_end (plugin->env->cls, s->address, s);
553 next = plugin->msg_head;
558 if (msgw->session != s)
560 GNUNET_CONTAINER_DLL_remove (plugin->msg_head,
563 if (NULL != msgw->cont)
564 msgw->cont (msgw->cont_cls, &msgw->session->target, GNUNET_SYSERR,
566 GNUNET_free (msgw->msg);
568 removed = GNUNET_YES;
570 GNUNET_assert (GNUNET_YES ==
571 GNUNET_CONTAINER_multipeermap_remove (plugin->session_map,
574 GNUNET_STATISTICS_set (plugin->env->stats,
575 "# UNIX sessions active",
576 GNUNET_CONTAINER_multipeermap_size (plugin->session_map),
578 if ((GNUNET_YES == removed) && (NULL == plugin->msg_head))
579 reschedule_select (plugin);
580 if (GNUNET_SCHEDULER_NO_TASK != s->timeout_task)
582 GNUNET_SCHEDULER_cancel (s->timeout_task);
583 s->timeout_task = GNUNET_SCHEDULER_NO_TASK;
585 GNUNET_HELLO_address_free (s->address);
592 * Function that is called to get the keepalive factor.
593 * #GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to
594 * calculate the interval between keepalive packets.
596 * @param cls closure with the `struct Plugin`
597 * @return keepalive factor
600 unix_query_keepalive_factor (void *cls)
607 * Actually send out the message, assume we've got the address and
608 * send_handle squared away!
611 * @param send_handle which handle to send message on
612 * @param target who should receive this message (ignored by UNIX)
613 * @param msgbuf one or more GNUNET_MessageHeader(s) strung together
614 * @param msgbuf_size the size of the msgbuf to send
615 * @param priority how important is the message (ignored by UNIX)
616 * @param timeout when should we time out (give up) if we can not transmit?
617 * @param addr the addr to send the message to, needs to be a sockaddr for us
618 * @param addrlen the len of @a addr
619 * @param payload bytes payload to send
620 * @param cont continuation to call once the message has
621 * been transmitted (or if the transport is ready
622 * for the next transmission call; or if the
623 * peer disconnected...)
624 * @param cont_cls closure for @a cont
625 * @return on success the number of bytes written, RETRY for retry, -1 on errors
628 unix_real_send (void *cls,
629 struct GNUNET_NETWORK_Handle *send_handle,
630 const struct GNUNET_PeerIdentity *target,
633 unsigned int priority,
634 struct GNUNET_TIME_Absolute timeout,
635 const struct UnixAddress *addr,
638 GNUNET_TRANSPORT_TransmitContinuation cont,
641 struct Plugin *plugin = cls;
643 struct sockaddr_un *un;
645 const char *unixpath;
647 GNUNET_assert (NULL != plugin);
648 if (NULL == send_handle)
650 GNUNET_break (0); /* We do not have a send handle */
651 return GNUNET_SYSERR;
653 if ((NULL == addr) || (0 == addrlen))
655 GNUNET_break (0); /* Can never send if we don't have an address */
656 return GNUNET_SYSERR;
659 /* Prepare address */
660 unixpath = (const char *) &addr[1];
661 if (NULL == (un = unix_address_to_sockaddr (unixpath,
668 if ((GNUNET_YES == plugin->abstract) &&
669 (0 != (UNIX_OPTIONS_USE_ABSTRACT_SOCKETS & ntohl(addr->options) )) )
671 un->sun_path[0] = '\0';
675 sent = GNUNET_NETWORK_socket_sendto (send_handle, msgbuf, msgbuf_size,
676 (const struct sockaddr *) un, un_len);
677 if (GNUNET_SYSERR == sent)
679 if ( (EAGAIN == errno) ||
683 return RETRY; /* We have to retry later */
685 if (EMSGSIZE == errno)
688 socklen_t len = sizeof (size);
690 GNUNET_NETWORK_socket_getsockopt ((struct GNUNET_NETWORK_Handle *)
691 send_handle, SOL_SOCKET, SO_SNDBUF, &size,
693 if (size < msgbuf_size)
695 LOG (GNUNET_ERROR_TYPE_DEBUG,
696 "Trying to increase socket buffer size from %i to %i for message size %i\n",
697 size, ((msgbuf_size / 1000) + 2) * 1000, msgbuf_size);
698 size = ((msgbuf_size / 1000) + 2) * 1000;
699 if (GNUNET_OK == GNUNET_NETWORK_socket_setsockopt
700 ((struct GNUNET_NETWORK_Handle *) send_handle, SOL_SOCKET, SO_SNDBUF,
701 &size, sizeof (size)))
702 goto resend; /* Increased buffer size, retry sending */
705 /* Could not increase buffer size: error, no retry */
706 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "setsockopt");
708 return GNUNET_SYSERR;
713 /* Buffer is bigger than message: error, no retry
714 * This should never happen!*/
717 return GNUNET_SYSERR;
722 LOG (GNUNET_ERROR_TYPE_DEBUG,
723 "UNIX transmit %u-byte message to %s (%d: %s)\n",
724 (unsigned int) msgbuf_size,
725 GNUNET_a2s ((const struct sockaddr *)un, un_len),
727 (sent < 0) ? STRERROR (errno) : "ok");
734 * Session was idle for too long, so disconnect it
736 * @param cls the 'struct Session' to disconnect
737 * @param tc scheduler context
740 session_timeout (void *cls,
741 const struct GNUNET_SCHEDULER_TaskContext *tc)
743 struct Session *s = cls;
745 s->timeout_task = GNUNET_SCHEDULER_NO_TASK;
746 LOG (GNUNET_ERROR_TYPE_DEBUG,
747 "Session %p was idle for %s, disconnecting\n",
749 GNUNET_STRINGS_relative_time_to_string (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
751 unix_session_disconnect (s->plugin, s);
756 * Function obtain the network type for a session
758 * @param cls closure ('struct Plugin*')
759 * @param session the session
760 * @return the network type in HBO or #GNUNET_SYSERR
762 static enum GNUNET_ATS_Network_Type
763 unix_get_network (void *cls,
764 struct Session *session)
766 GNUNET_assert (NULL != session);
767 return GNUNET_ATS_NET_LOOPBACK;
772 * Creates a new outbound session the transport service will use to send data to the
775 * @param cls the plugin
776 * @param address the address
777 * @return the session or NULL of max connections exceeded
779 static struct Session *
780 unix_plugin_get_session (void *cls,
781 const struct GNUNET_HELLO_Address *address)
783 struct Plugin *plugin = cls;
785 struct UnixAddress *ua;
787 uint32_t addr_str_len;
788 uint32_t addr_option;
790 GNUNET_assert (NULL != plugin);
791 GNUNET_assert (NULL != address);
793 ua = (struct UnixAddress *) address->address;
794 if ((NULL == address->address) || (0 == address->address_length) ||
795 (sizeof (struct UnixAddress) > address->address_length))
800 addrstr = (char *) &ua[1];
801 addr_str_len = ntohl (ua->addrlen);
802 addr_option = ntohl (ua->options);
804 if ( (0 != (UNIX_OPTIONS_USE_ABSTRACT_SOCKETS & addr_option)) &&
805 (GNUNET_NO == plugin->abstract))
810 if (addr_str_len != address->address_length - sizeof (struct UnixAddress))
812 return NULL; /* This can be a legacy address */
815 if ('\0' != addrstr[addr_str_len - 1])
820 if (strlen (addrstr) + 1 != addr_str_len)
826 /* Check if a session for this address already exists */
827 if (NULL != (s = lookup_session (plugin,
830 LOG (GNUNET_ERROR_TYPE_DEBUG,
831 "Found existing session %p for address `%s'\n",
833 unix_address_to_string (NULL,
835 address->address_length));
839 /* create a new session */
840 s = GNUNET_new (struct Session);
841 s->target = address->peer;
842 s->address = GNUNET_HELLO_address_copy (address);
844 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == s->timeout_task);
845 s->timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
848 LOG (GNUNET_ERROR_TYPE_DEBUG,
849 "Creating a new session %p for address `%s'\n",
851 unix_address_to_string (NULL,
853 address->address_length));
854 (void) GNUNET_CONTAINER_multipeermap_put (plugin->session_map,
856 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
857 GNUNET_STATISTICS_set (plugin->env->stats,
858 "# UNIX sessions active",
859 GNUNET_CONTAINER_multipeermap_size (plugin->session_map),
866 * Function that will be called whenever the transport service wants
867 * to notify the plugin that a session is still active and in use and
868 * therefore the session timeout for this session has to be updated
870 * @param cls closure with the `struct Plugin *`
871 * @param peer which peer was the session for
872 * @param session which session is being updated
875 unix_plugin_update_session_timeout (void *cls,
876 const struct GNUNET_PeerIdentity *peer,
877 struct Session *session)
879 struct Plugin *plugin = cls;
882 GNUNET_CONTAINER_multipeermap_contains_value (plugin->session_map,
886 reschedule_session_timeout (session);
891 * Function that can be used by the transport service to transmit
892 * a message using the plugin. Note that in the case of a
893 * peer disconnecting, the continuation MUST be called
894 * prior to the disconnect notification itself. This function
895 * will be called with this peer's HELLO message to initiate
896 * a fresh connection to another peer.
899 * @param session which session must be used
900 * @param msgbuf the message to transmit
901 * @param msgbuf_size number of bytes in @a msgbuf
902 * @param priority how important is the message (most plugins will
903 * ignore message priority and just FIFO)
904 * @param to how long to wait at most for the transmission (does not
905 * require plugins to discard the message after the timeout,
906 * just advisory for the desired delay; most plugins will ignore
908 * @param cont continuation to call once the message has
909 * been transmitted (or if the transport is ready
910 * for the next transmission call; or if the
911 * peer disconnected...); can be NULL
912 * @param cont_cls closure for @a cont
913 * @return number of bytes used (on the physical network, with overheads);
914 * -1 on hard errors (i.e. address invalid); 0 is a legal value
915 * and does NOT mean that the message was not transmitted (DV)
918 unix_plugin_send (void *cls,
919 struct Session *session,
922 unsigned int priority,
923 struct GNUNET_TIME_Relative to,
924 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
926 struct Plugin *plugin = cls;
927 struct UNIXMessageWrapper *wrapper;
928 struct UNIXMessage *message;
932 GNUNET_CONTAINER_multipeermap_contains_value (plugin->session_map,
936 LOG (GNUNET_ERROR_TYPE_ERROR,
937 "Invalid session for peer `%s' `%s'\n",
938 GNUNET_i2s (&session->target),
939 unix_address_to_string(NULL,
940 session->address->address,
941 session->address->address_length));
943 return GNUNET_SYSERR;
945 LOG (GNUNET_ERROR_TYPE_DEBUG,
946 "Sending %u bytes with session for peer `%s' `%s'\n",
948 GNUNET_i2s (&session->target),
949 unix_address_to_string (NULL,
950 session->address->address,
951 session->address->address_length));
952 ssize = sizeof (struct UNIXMessage) + msgbuf_size;
953 message = GNUNET_malloc (sizeof (struct UNIXMessage) + msgbuf_size);
954 message->header.size = htons (ssize);
955 message->header.type = htons (0);
956 memcpy (&message->sender, plugin->env->my_identity,
957 sizeof (struct GNUNET_PeerIdentity));
958 memcpy (&message[1], msgbuf, msgbuf_size);
959 wrapper = GNUNET_new (struct UNIXMessageWrapper);
960 wrapper->msg = message;
961 wrapper->msgsize = ssize;
962 wrapper->payload = msgbuf_size;
963 wrapper->priority = priority;
964 wrapper->timeout = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (),
966 wrapper->cont = cont;
967 wrapper->cont_cls = cont_cls;
968 wrapper->session = session;
969 GNUNET_CONTAINER_DLL_insert (plugin->msg_head,
972 plugin->bytes_in_queue += ssize;
973 GNUNET_STATISTICS_set (plugin->env->stats,
974 "# bytes currently in UNIX buffers",
975 plugin->bytes_in_queue,
977 if (GNUNET_NO == plugin->with_ws)
978 reschedule_select (plugin);
984 * Demultiplexer for UNIX messages
986 * @param plugin the main plugin for this transport
987 * @param sender from which peer the message was received
988 * @param currhdr pointer to the header of the message
989 * @param ua address to look for
990 * @param ua_len length of the address @a ua
993 unix_demultiplexer (struct Plugin *plugin, struct GNUNET_PeerIdentity *sender,
994 const struct GNUNET_MessageHeader *currhdr,
995 const struct UnixAddress *ua, size_t ua_len)
997 struct Session *s = NULL;
998 struct GNUNET_HELLO_Address *address;
1000 GNUNET_break (ntohl(plugin->ats_network.value) != GNUNET_ATS_NET_UNSPECIFIED);
1001 GNUNET_assert (ua_len >= sizeof (struct UnixAddress));
1002 LOG (GNUNET_ERROR_TYPE_DEBUG,
1003 "Received message from %s\n",
1004 unix_address_to_string (NULL, ua, ua_len));
1005 GNUNET_STATISTICS_update (plugin->env->stats,
1006 "# bytes received via UNIX",
1007 ntohs (currhdr->size),
1010 /* Look for existing session */
1011 address = GNUNET_HELLO_address_allocate (sender, PLUGIN_NAME, ua, ua_len,
1012 GNUNET_HELLO_ADDRESS_INFO_NONE); /* UNIX does not have "inbound" sessions */
1013 s = lookup_session (plugin, address);
1017 s = unix_plugin_get_session (plugin, address);
1018 /* Notify transport and ATS about new inbound session */
1019 plugin->env->session_start (NULL, s->address, s, &plugin->ats_network, 1);
1021 GNUNET_HELLO_address_free (address);
1022 reschedule_session_timeout (s);
1024 plugin->env->receive (plugin->env->cls, s->address, s, currhdr);
1025 plugin->env->update_address_metrics (plugin->env->cls, s->address, s,
1026 &plugin->ats_network, 1);
1031 * Read from UNIX domain socket (it is ready).
1033 * @param plugin the plugin
1036 unix_plugin_select_read (struct Plugin *plugin)
1038 char buf[65536] GNUNET_ALIGN;
1039 struct UnixAddress *ua;
1040 struct UNIXMessage *msg;
1041 struct GNUNET_PeerIdentity sender;
1042 struct sockaddr_un un;
1049 const struct GNUNET_MessageHeader *currhdr;
1053 addrlen = sizeof (un);
1054 memset (&un, 0, sizeof (un));
1057 GNUNET_NETWORK_socket_recvfrom (plugin->unix_sock.desc, buf, sizeof (buf),
1058 (struct sockaddr *) &un, &addrlen);
1060 if ((GNUNET_SYSERR == ret) && ((errno == EAGAIN) || (errno == ENOBUFS)))
1063 if (ret == GNUNET_SYSERR)
1065 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "recvfrom");
1070 LOG (GNUNET_ERROR_TYPE_DEBUG,
1071 "Read %d bytes from socket %s\n",
1076 GNUNET_assert (AF_UNIX == (un.sun_family));
1077 is_abstract = GNUNET_NO;
1078 if ('\0' == un.sun_path[0])
1080 un.sun_path[0] = '@';
1081 is_abstract = GNUNET_YES;
1084 ua_len = sizeof (struct UnixAddress) + strlen (un.sun_path) + 1;
1085 ua = GNUNET_malloc (ua_len);
1086 ua->addrlen = htonl (strlen (&un.sun_path[0]) +1);
1087 memcpy (&ua[1], &un.sun_path[0], strlen (un.sun_path) + 1);
1089 ua->options = htonl(UNIX_OPTIONS_USE_ABSTRACT_SOCKETS);
1091 ua->options = htonl(UNIX_OPTIONS_NONE);
1093 msg = (struct UNIXMessage *) buf;
1094 csize = ntohs (msg->header.size);
1095 if ((csize < sizeof (struct UNIXMessage)) || (csize > ret))
1097 GNUNET_break_op (0);
1101 msgbuf = (char *) &msg[1];
1102 memcpy (&sender, &msg->sender, sizeof (struct GNUNET_PeerIdentity));
1104 tsize = csize - sizeof (struct UNIXMessage);
1105 while (offset + sizeof (struct GNUNET_MessageHeader) <= tsize)
1107 currhdr = (struct GNUNET_MessageHeader *) &msgbuf[offset];
1108 csize = ntohs (currhdr->size);
1109 if ((csize < sizeof (struct GNUNET_MessageHeader)) ||
1110 (csize > tsize - offset))
1112 GNUNET_break_op (0);
1115 unix_demultiplexer (plugin, &sender, currhdr, ua, ua_len);
1123 * Write to UNIX domain socket (it is ready).
1125 * @param plugin the plugin
1128 unix_plugin_select_write (struct Plugin *plugin)
1131 struct UNIXMessageWrapper * msgw;
1133 while (NULL != (msgw = plugin->msg_tail))
1135 if (GNUNET_TIME_absolute_get_remaining (msgw->timeout).rel_value_us > 0)
1136 break; /* Message is ready for sending */
1137 /* Message has a timeout */
1138 LOG (GNUNET_ERROR_TYPE_DEBUG,
1139 "Timeout for message with %u bytes \n",
1140 (unsigned int) msgw->msgsize);
1141 GNUNET_CONTAINER_DLL_remove (plugin->msg_head, plugin->msg_tail, msgw);
1142 plugin->bytes_in_queue -= msgw->msgsize;
1143 GNUNET_STATISTICS_set (plugin->env->stats,
1144 "# bytes currently in UNIX buffers",
1145 plugin->bytes_in_queue, GNUNET_NO);
1146 GNUNET_STATISTICS_update (plugin->env->stats,
1147 "# UNIX bytes discarded",
1150 if (NULL != msgw->cont)
1151 msgw->cont (msgw->cont_cls,
1152 &msgw->session->target,
1156 GNUNET_free (msgw->msg);
1160 return; /* Nothing to send at the moment */
1162 sent = unix_real_send (plugin,
1163 plugin->unix_sock.desc,
1164 &msgw->session->target,
1165 (const char *) msgw->msg,
1169 msgw->session->address->address,
1170 msgw->session->address->address_length,
1172 msgw->cont, msgw->cont_cls);
1176 GNUNET_STATISTICS_update (plugin->env->stats,
1177 "# UNIX retry attempts",
1181 if (GNUNET_SYSERR == sent)
1183 /* failed and no retry */
1184 if (NULL != msgw->cont)
1185 msgw->cont (msgw->cont_cls, &msgw->session->target, GNUNET_SYSERR, msgw->payload, 0);
1187 GNUNET_CONTAINER_DLL_remove(plugin->msg_head, plugin->msg_tail, msgw);
1189 GNUNET_assert (plugin->bytes_in_queue >= msgw->msgsize);
1190 plugin->bytes_in_queue -= msgw->msgsize;
1191 GNUNET_STATISTICS_set (plugin->env->stats,
1192 "# bytes currently in UNIX buffers",
1193 plugin->bytes_in_queue, GNUNET_NO);
1194 GNUNET_STATISTICS_update (plugin->env->stats,
1195 "# UNIX bytes discarded",
1199 GNUNET_free (msgw->msg);
1203 /* successfully sent bytes */
1204 GNUNET_break (sent > 0);
1205 GNUNET_CONTAINER_DLL_remove (plugin->msg_head,
1208 GNUNET_assert (plugin->bytes_in_queue >= msgw->msgsize);
1209 plugin->bytes_in_queue -= msgw->msgsize;
1210 GNUNET_STATISTICS_set (plugin->env->stats,
1211 "# bytes currently in UNIX buffers",
1212 plugin->bytes_in_queue,
1214 GNUNET_STATISTICS_update (plugin->env->stats,
1215 "# bytes transmitted via UNIX",
1218 if (NULL != msgw->cont)
1219 msgw->cont (msgw->cont_cls, &msgw->session->target,
1223 GNUNET_free (msgw->msg);
1229 * We have been notified that our writeset has something to read. We don't
1230 * know which socket needs to be read, so we have to check each one
1231 * Then reschedule this function to be called again once more is available.
1233 * @param cls the plugin handle
1234 * @param tc the scheduling context (for rescheduling this function again)
1237 unix_plugin_select (void *cls,
1238 const struct GNUNET_SCHEDULER_TaskContext *tc)
1240 struct Plugin *plugin = cls;
1242 plugin->select_task = GNUNET_SCHEDULER_NO_TASK;
1243 if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
1246 if ((tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY) != 0)
1248 /* Ready to send data */
1249 GNUNET_assert (GNUNET_NETWORK_fdset_isset
1250 (tc->write_ready, plugin->unix_sock.desc));
1251 if (NULL != plugin->msg_head)
1252 unix_plugin_select_write (plugin);
1255 if ((tc->reason & GNUNET_SCHEDULER_REASON_READ_READY) != 0)
1257 /* Ready to receive data */
1258 GNUNET_assert (GNUNET_NETWORK_fdset_isset
1259 (tc->read_ready, plugin->unix_sock.desc));
1260 unix_plugin_select_read (plugin);
1262 reschedule_select (plugin);
1267 * Create a slew of UNIX sockets. If possible, use IPv6 and IPv4.
1269 * @param cls closure for server start, should be a struct Plugin *
1270 * @return number of sockets created or #GNUNET_SYSERR on error
1273 unix_transport_server_start (void *cls)
1275 struct Plugin *plugin = cls;
1276 struct sockaddr_un *un;
1279 un = unix_address_to_sockaddr (plugin->unix_socket_path,
1281 if (GNUNET_YES == plugin->abstract)
1283 plugin->unix_socket_path[0] = '@';
1284 un->sun_path[0] = '\0';
1286 plugin->ats_network = plugin->env->get_address_type (plugin->env->cls, (const struct sockaddr *) un, un_len);
1287 plugin->unix_sock.desc =
1288 GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_DGRAM, 0);
1289 if (NULL == plugin->unix_sock.desc)
1291 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket");
1292 return GNUNET_SYSERR;
1294 if ('\0' != un->sun_path[0])
1296 if (GNUNET_OK != GNUNET_DISK_directory_create_for_file (un->sun_path))
1298 LOG (GNUNET_ERROR_TYPE_ERROR, _("Cannot create path to `%s'\n"),
1300 GNUNET_NETWORK_socket_close (plugin->unix_sock.desc);
1301 plugin->unix_sock.desc = NULL;
1303 return GNUNET_SYSERR;
1307 GNUNET_NETWORK_socket_bind (plugin->unix_sock.desc, (const struct sockaddr *) un, un_len))
1309 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "bind");
1310 GNUNET_NETWORK_socket_close (plugin->unix_sock.desc);
1311 plugin->unix_sock.desc = NULL;
1313 return GNUNET_SYSERR;
1315 LOG (GNUNET_ERROR_TYPE_DEBUG, "Bound to `%s'\n", plugin->unix_socket_path);
1316 plugin->rs = GNUNET_NETWORK_fdset_create ();
1317 plugin->ws = GNUNET_NETWORK_fdset_create ();
1318 GNUNET_NETWORK_fdset_zero (plugin->rs);
1319 GNUNET_NETWORK_fdset_zero (plugin->ws);
1320 GNUNET_NETWORK_fdset_set (plugin->rs, plugin->unix_sock.desc);
1321 GNUNET_NETWORK_fdset_set (plugin->ws, plugin->unix_sock.desc);
1323 reschedule_select (plugin);
1330 * Function that will be called to check if a binary address for this
1331 * plugin is well-formed and corresponds to an address for THIS peer
1332 * (as per our configuration). Naturally, if absolutely necessary,
1333 * plugins can be a bit conservative in their answer, but in general
1334 * plugins should make sure that the address does not redirect
1335 * traffic to a 3rd party that might try to man-in-the-middle our
1338 * @param cls closure, should be our handle to the Plugin
1339 * @param addr pointer to the address
1340 * @param addrlen length of @a addr
1341 * @return #GNUNET_OK if this is a plausible address for this peer
1342 * and transport, #GNUNET_SYSERR if not
1346 unix_check_address (void *cls,
1350 struct Plugin* plugin = cls;
1351 const struct UnixAddress *ua = addr;
1353 size_t addr_str_len;
1355 if ( (NULL == addr) ||
1357 (sizeof (struct UnixAddress) > addrlen) )
1360 return GNUNET_SYSERR;
1362 addrstr = (char *) &ua[1];
1363 addr_str_len = ntohl (ua->addrlen);
1364 if ('\0' != addrstr[addr_str_len - 1])
1367 return GNUNET_SYSERR;
1369 if (strlen (addrstr) + 1 != addr_str_len)
1372 return GNUNET_SYSERR;
1375 if (0 == strcmp (plugin->unix_socket_path, addrstr))
1377 return GNUNET_SYSERR;
1382 * Convert the transports address to a nice, human-readable
1385 * @param cls closure
1386 * @param type name of the transport that generated the address
1387 * @param addr one of the addresses of the host, NULL for the last address
1388 * the specific address format depends on the transport
1389 * @param addrlen length of the @a addr
1390 * @param numeric should (IP) addresses be displayed in numeric form?
1391 * @param timeout after how long should we give up?
1392 * @param asc function to call on each string
1393 * @param asc_cls closure for @a asc
1396 unix_plugin_address_pretty_printer (void *cls, const char *type,
1400 struct GNUNET_TIME_Relative timeout,
1401 GNUNET_TRANSPORT_AddressStringCallback asc,
1406 if ( (NULL != addr) && (addrlen > 0))
1407 ret = unix_address_to_string (NULL,
1414 (NULL == ret) ? GNUNET_SYSERR : GNUNET_OK);
1415 asc (asc_cls, NULL, GNUNET_OK);
1420 * Function called to convert a string address to
1423 * @param cls closure (`struct Plugin *`)
1424 * @param addr string address
1425 * @param addrlen length of the @a addr (strlen(addr) + '\0')
1426 * @param buf location to store the buffer
1427 * If the function returns #GNUNET_SYSERR, its contents are undefined.
1428 * @param added length of created address
1429 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
1432 unix_string_to_address (void *cls,
1433 const char *addr, uint16_t addrlen,
1434 void **buf, size_t *added)
1436 struct UnixAddress *ua;
1443 /* Format unix.options.address */
1448 if ((NULL == addr) || (addrlen == 0))
1451 return GNUNET_SYSERR;
1453 if ('\0' != addr[addrlen - 1])
1456 return GNUNET_SYSERR;
1458 if (strlen (addr) != addrlen - 1)
1461 return GNUNET_SYSERR;
1463 plugin = GNUNET_strdup (addr);
1464 optionstr = strchr (plugin, '.');
1465 if (NULL == optionstr)
1468 GNUNET_free (plugin);
1469 return GNUNET_SYSERR;
1471 optionstr[0] = '\0';
1473 options = atol (optionstr);
1474 address = strchr (optionstr, '.');
1475 if (NULL == address)
1478 GNUNET_free (plugin);
1479 return GNUNET_SYSERR;
1483 if (0 != strcmp(plugin, PLUGIN_NAME))
1486 GNUNET_free (plugin);
1487 return GNUNET_SYSERR;
1490 ua_size = sizeof (struct UnixAddress) + strlen (address) + 1;
1491 ua = GNUNET_malloc (ua_size);
1492 ua->options = htonl (options);
1493 ua->addrlen = htonl (strlen (address) + 1);
1494 memcpy (&ua[1], address, strlen (address) + 1);
1495 GNUNET_free (plugin);
1504 * Notify transport service about address
1506 * @param cls the plugin
1510 address_notification (void *cls,
1511 const struct GNUNET_SCHEDULER_TaskContext *tc)
1513 struct Plugin *plugin = cls;
1514 struct GNUNET_HELLO_Address *address;
1516 struct UnixAddress *ua;
1519 len = sizeof (struct UnixAddress) + strlen (plugin->unix_socket_path) + 1;
1520 ua = GNUNET_malloc (len);
1521 ua->options = htonl (plugin->myoptions);
1522 ua->addrlen = htonl(strlen (plugin->unix_socket_path) + 1);
1523 unix_path = (char *) &ua[1];
1524 memcpy (unix_path, plugin->unix_socket_path, strlen (plugin->unix_socket_path) + 1);
1526 plugin->address_update_task = GNUNET_SCHEDULER_NO_TASK;
1527 address = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
1531 GNUNET_HELLO_ADDRESS_INFO_NONE);
1532 plugin->env->notify_address (plugin->env->cls,
1536 GNUNET_free (address);
1541 * Increment session timeout due to activity
1543 * @param s session for which the timeout should be rescheduled
1546 reschedule_session_timeout (struct Session *s)
1548 GNUNET_assert (NULL != s);
1549 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != s->timeout_task);
1550 GNUNET_SCHEDULER_cancel (s->timeout_task);
1551 s->timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
1554 LOG (GNUNET_ERROR_TYPE_DEBUG,
1555 "Timeout rescheduled for session %p set to %s\n",
1557 GNUNET_STRINGS_relative_time_to_string (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
1563 * Function called on sessions to disconnect
1565 * @param cls the plugin
1566 * @param key peer identity (unused)
1567 * @param value the `struct Session *` to disconnect
1568 * @return #GNUNET_YES (always, continue to iterate)
1571 get_session_delete_it (void *cls,
1572 const struct GNUNET_PeerIdentity *key,
1575 struct Plugin *plugin = cls;
1576 struct Session *s = value;
1578 unix_session_disconnect (plugin, s);
1584 * Disconnect from a remote node. Clean up session if we have one for this peer
1586 * @param cls closure for this call (should be handle to Plugin)
1587 * @param target the peeridentity of the peer to disconnect
1588 * @return #GNUNET_OK on success, #GNUNET_SYSERR if the operation failed
1591 unix_peer_disconnect (void *cls,
1592 const struct GNUNET_PeerIdentity *target)
1594 struct Plugin *plugin = cls;
1596 GNUNET_assert (NULL != plugin);
1597 GNUNET_CONTAINER_multipeermap_get_multiple (plugin->session_map,
1599 &get_session_delete_it, plugin);
1604 * Return information about the given session to the
1607 * @param cls the `struct Plugin` with the monitor callback (`sic`)
1608 * @param peer peer we send information about
1609 * @param value our `struct Session` to send information about
1610 * @return #GNUNET_OK (continue to iterate)
1613 send_session_info_iter (void *cls,
1614 const struct GNUNET_PeerIdentity *peer,
1617 struct Plugin *plugin = cls;
1618 struct Session *session = value;
1619 struct GNUNET_TRANSPORT_SessionInfo info;
1621 memset (&info, 0, sizeof (info));
1622 info.state = GNUNET_TRANSPORT_SS_UP; /* ??? */
1623 // FIXME: info->is_inbound = ?
1624 // FIXME: info->num_msg_pending = ?
1625 // FIXME: info->num_bytes_pending = ?
1626 // FIXME: info->receive_delay = ?
1627 // FIXME: info->session_timeout = ?
1628 info.address = session->address;
1629 plugin->sic (plugin->sic_cls,
1637 * Begin monitoring sessions of a plugin. There can only
1638 * be one active monitor per plugin (i.e. if there are
1639 * multiple monitors, the transport service needs to
1640 * multiplex the generated events over all of them).
1642 * @param cls closure of the plugin
1643 * @param sic callback to invoke, NULL to disable monitor;
1644 * plugin will being by iterating over all active
1645 * sessions immediately and then enter monitor mode
1646 * @param sic_cls closure for @a sic
1649 unix_setup_monitor (void *cls,
1650 GNUNET_TRANSPORT_SessionInfoCallback sic,
1653 struct Plugin *plugin = cls;
1656 plugin->sic_cls = sic_cls;
1658 GNUNET_CONTAINER_multipeermap_iterate (plugin->session_map,
1659 &send_session_info_iter,
1665 * The exported method. Initializes the plugin and returns a
1666 * struct with the callbacks.
1668 * @param cls the plugin's execution environment
1669 * @return NULL on error, plugin functions otherwise
1672 libgnunet_plugin_transport_unix_init (void *cls)
1674 struct GNUNET_TRANSPORT_PluginEnvironment *env = cls;
1675 struct GNUNET_TRANSPORT_PluginFunctions *api;
1676 struct Plugin *plugin;
1677 int sockets_created;
1679 if (NULL == env->receive)
1681 /* run in 'stub' mode (i.e. as part of gnunet-peerinfo), don't fully
1682 initialze the plugin or the API */
1683 api = GNUNET_new (struct GNUNET_TRANSPORT_PluginFunctions);
1685 api->address_pretty_printer = &unix_plugin_address_pretty_printer;
1686 api->address_to_string = &unix_address_to_string;
1687 api->string_to_address = &unix_string_to_address;
1691 plugin = GNUNET_new (struct Plugin);
1693 GNUNET_CONFIGURATION_get_value_filename(env->cfg, "transport-unix", "UNIXPATH",
1694 &plugin->unix_socket_path))
1696 LOG (GNUNET_ERROR_TYPE_ERROR,
1697 _("No UNIXPATH given in configuration!\n"));
1698 GNUNET_free (plugin);
1704 /* Initialize my flags */
1706 plugin->abstract = GNUNET_CONFIGURATION_get_value_yesno (plugin->env->cfg,
1707 "testing", "USE_ABSTRACT_SOCKETS");
1709 plugin->myoptions = UNIX_OPTIONS_NONE;
1710 if (GNUNET_YES == plugin->abstract)
1712 plugin->myoptions = UNIX_OPTIONS_USE_ABSTRACT_SOCKETS;
1715 api = GNUNET_new (struct GNUNET_TRANSPORT_PluginFunctions);
1717 api->get_session = &unix_plugin_get_session;
1718 api->send = &unix_plugin_send;
1719 api->disconnect_peer = &unix_peer_disconnect;
1720 api->disconnect_session = &unix_session_disconnect;
1721 api->query_keepalive_factor = &unix_query_keepalive_factor;
1722 api->address_pretty_printer = &unix_plugin_address_pretty_printer;
1723 api->address_to_string = &unix_address_to_string;
1724 api->check_address = &unix_check_address;
1725 api->string_to_address = &unix_string_to_address;
1726 api->get_network = &unix_get_network;
1727 api->update_session_timeout = &unix_plugin_update_session_timeout;
1728 api->setup_monitor = &unix_setup_monitor;
1729 sockets_created = unix_transport_server_start (plugin);
1730 if ((0 == sockets_created) || (GNUNET_SYSERR == sockets_created))
1732 LOG (GNUNET_ERROR_TYPE_WARNING,
1733 _("Failed to open UNIX listen socket\n"));
1735 GNUNET_free (plugin->unix_socket_path);
1736 GNUNET_free (plugin);
1739 plugin->session_map = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
1740 plugin->address_update_task = GNUNET_SCHEDULER_add_now (&address_notification,
1747 * Shutdown the plugin.
1749 * @param cls the plugin API returned from the initialization function
1750 * @return NULL (always)
1753 libgnunet_plugin_transport_unix_done (void *cls)
1755 struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
1756 struct Plugin *plugin = api->cls;
1757 struct GNUNET_HELLO_Address *address;
1758 struct UNIXMessageWrapper * msgw;
1759 struct UnixAddress *ua;
1767 len = sizeof (struct UnixAddress) + strlen (plugin->unix_socket_path) + 1;
1768 ua = GNUNET_malloc (len);
1769 ua->options = htonl (plugin->myoptions);
1770 ua->addrlen = htonl(strlen (plugin->unix_socket_path) + 1);
1772 plugin->unix_socket_path,
1773 strlen (plugin->unix_socket_path) + 1);
1774 address = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
1777 GNUNET_HELLO_ADDRESS_INFO_NONE);
1778 plugin->env->notify_address (plugin->env->cls,
1782 GNUNET_free (address);
1785 while (NULL != (msgw = plugin->msg_head))
1787 GNUNET_CONTAINER_DLL_remove (plugin->msg_head,
1790 if (NULL != msgw->cont)
1791 msgw->cont (msgw->cont_cls,
1792 &msgw->session->target,
1795 GNUNET_free (msgw->msg);
1799 if (GNUNET_SCHEDULER_NO_TASK != plugin->select_task)
1801 GNUNET_SCHEDULER_cancel (plugin->select_task);
1802 plugin->select_task = GNUNET_SCHEDULER_NO_TASK;
1804 if (GNUNET_SCHEDULER_NO_TASK != plugin->address_update_task)
1806 GNUNET_SCHEDULER_cancel (plugin->address_update_task);
1807 plugin->address_update_task = GNUNET_SCHEDULER_NO_TASK;
1809 if (NULL != plugin->unix_sock.desc)
1811 GNUNET_break (GNUNET_OK ==
1812 GNUNET_NETWORK_socket_close (plugin->unix_sock.desc));
1813 plugin->unix_sock.desc = NULL;
1814 plugin->with_ws = GNUNET_NO;
1816 GNUNET_CONTAINER_multipeermap_iterate (plugin->session_map,
1817 &get_session_delete_it, plugin);
1818 GNUNET_CONTAINER_multipeermap_destroy (plugin->session_map);
1819 if (NULL != plugin->rs)
1820 GNUNET_NETWORK_fdset_destroy (plugin->rs);
1821 if (NULL != plugin->ws)
1822 GNUNET_NETWORK_fdset_destroy (plugin->ws);
1823 GNUNET_free (plugin->unix_socket_path);
1824 GNUNET_free (plugin);
1829 /* end of plugin_transport_unix.c */