2 This file is part of GNUnet
3 Copyright (C) 2010-2014, 2018 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your 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 Affero General Public License for more details.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
22 * @file transport/gnunet-communicator-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_protocols.h"
32 #include "gnunet_constants.h"
33 #include "gnunet_nt_lib.h"
34 #include "gnunet_statistics_service.h"
35 #include "gnunet_transport_communication_service.h"
38 * How many messages do we keep at most in the queue to the
39 * transport service before we start to drop (default,
40 * can be changed via the configuration file).
41 * Should be _below_ the level of the communicator API, as
42 * otherwise we may read messages just to have them dropped
43 * by the communicator API.
45 #define DEFAULT_MAX_QUEUE_LENGTH 8
48 * Address prefix used by the communicator.
50 #define COMMUNICATOR_ADDRESS_PREFIX "unix"
53 * Configuration section used by the communicator.
55 #define COMMUNICATOR_CONFIG_SECTION "communicator-unix"
60 #define UNIX_MTU UINT16_MAX
62 GNUNET_NETWORK_STRUCT_BEGIN
65 * UNIX Message-Packet header.
72 struct GNUNET_MessageHeader header;
75 * What is the identity of the sender (GNUNET_hash of public key)
77 struct GNUNET_PeerIdentity sender;
80 GNUNET_NETWORK_STRUCT_END
90 * Queues with pending messages (!) are kept in a DLL.
95 * Queues with pending messages (!) are kept in a DLL.
100 * To whom are we talking to.
102 struct GNUNET_PeerIdentity target;
105 * Address of the other peer.
107 struct sockaddr_un *address;
110 * Length of the address.
112 socklen_t address_len;
115 * Message currently scheduled for transmission, non-NULL if and only
116 * if this queue is in the #queue_head DLL.
118 const struct GNUNET_MessageHeader *msg;
121 * Message queue we are providing for the #ch.
123 struct GNUNET_MQ_Handle *mq;
126 * handle for this queue with the #ch.
128 struct GNUNET_TRANSPORT_QueueHandle *qh;
131 * Number of bytes we currently have in our write queue.
133 unsigned long long bytes_in_queue;
136 * Timeout for this queue.
138 struct GNUNET_TIME_Absolute timeout;
141 * Queue timeout task.
143 struct GNUNET_SCHEDULER_Task *timeout_task;
150 static struct GNUNET_SCHEDULER_Task *read_task;
155 static struct GNUNET_SCHEDULER_Task *write_task;
158 * Number of messages we currently have in our queues towards the transport service.
160 static unsigned long long delivering_messages;
163 * Maximum queue length before we stop reading towards the transport service.
165 static unsigned long long max_queue_length;
168 * For logging statistics.
170 static struct GNUNET_STATISTICS_Handle *stats;
175 static struct GNUNET_TRANSPORT_CommunicatorHandle *ch;
178 * Queues (map from peer identity to `struct Queue`)
180 static struct GNUNET_CONTAINER_MultiPeerMap *queue_map;
183 * Head of queue of messages to transmit.
185 static struct Queue *queue_head;
188 * Tail of queue of messages to transmit.
190 static struct Queue *queue_tail;
193 * socket that we transmit all data with
195 static struct GNUNET_NETWORK_Handle *unix_sock;
198 * Handle to the operation that publishes our address.
200 static struct GNUNET_TRANSPORT_AddressIdentifier *ai;
204 * Functions with this signature are called whenever we need
205 * to close a queue due to a disconnect or failure to
206 * establish a connection.
208 * @param queue queue to close down
211 queue_destroy (struct Queue *queue)
213 struct GNUNET_MQ_Handle *mq;
215 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
216 "Disconnecting queue for peer `%s'\n",
217 GNUNET_i2s (&queue->target));
218 if (0 != queue->bytes_in_queue)
220 GNUNET_CONTAINER_DLL_remove (queue_head, queue_tail, queue);
221 queue->bytes_in_queue = 0;
223 if (NULL != (mq = queue->mq))
226 GNUNET_MQ_destroy (mq);
230 GNUNET_CONTAINER_multipeermap_remove (queue_map, &queue->target, queue));
231 GNUNET_STATISTICS_set (stats,
233 GNUNET_CONTAINER_multipeermap_size (queue_map),
235 if (NULL != queue->timeout_task)
237 GNUNET_SCHEDULER_cancel (queue->timeout_task);
238 queue->timeout_task = NULL;
240 GNUNET_free (queue->address);
246 * Queue was idle for too long, so disconnect it
248 * @param cls the `struct Queue *` to disconnect
251 queue_timeout (void *cls)
253 struct Queue *queue = cls;
254 struct GNUNET_TIME_Relative left;
256 queue->timeout_task = NULL;
257 left = GNUNET_TIME_absolute_get_remaining (queue->timeout);
258 if (0 != left.rel_value_us)
260 /* not actually our turn yet, but let's at least update
261 the monitor, it may think we're about to die ... */
262 queue->timeout_task =
263 GNUNET_SCHEDULER_add_delayed (left, &queue_timeout, queue);
266 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
267 "Queue %p was idle for %s, disconnecting\n",
269 GNUNET_STRINGS_relative_time_to_string (
270 GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
272 queue_destroy (queue);
277 * Increment queue timeout due to activity. We do not immediately
278 * notify the monitor here as that might generate excessive
281 * @param queue queue for which the timeout should be rescheduled
284 reschedule_queue_timeout (struct Queue *queue)
286 GNUNET_assert (NULL != queue->timeout_task);
288 GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
293 * Convert unix path to a `struct sockaddr_un *`
295 * @param unixpath path to convert
296 * @param[out] sock_len set to the length of the address
297 * @param is_abstract is this an abstract @a unixpath
298 * @return converted unix path
300 static struct sockaddr_un *
301 unix_address_to_sockaddr (const char *unixpath, socklen_t *sock_len)
303 struct sockaddr_un *un;
306 GNUNET_assert (0 < strlen (unixpath)); /* sanity check */
307 un = GNUNET_new (struct sockaddr_un);
308 un->sun_family = AF_UNIX;
309 slen = strlen (unixpath);
310 if (slen >= sizeof (un->sun_path))
311 slen = sizeof (un->sun_path) - 1;
312 GNUNET_memcpy (un->sun_path, unixpath, slen);
313 un->sun_path[slen] = '\0';
314 slen = sizeof (struct sockaddr_un);
315 #if HAVE_SOCKADDR_UN_SUN_LEN
316 un->sun_len = (u_char) slen;
319 if ('@' == un->sun_path[0])
320 un->sun_path[0] = '\0';
326 * Closure to #lookup_queue_it().
331 * Location to store the queue, if found.
336 * Address we are looking for.
338 const struct sockaddr_un *un;
341 * Number of bytes in @a un
348 * Function called to find a queue by address.
350 * @param cls the `struct LookupCtx *`
351 * @param key peer we are looking for (unused)
352 * @param value a queue
353 * @return #GNUNET_YES if not found (continue looking), #GNUNET_NO on success
356 lookup_queue_it (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
358 struct LookupCtx *lctx = cls;
359 struct Queue *queue = value;
361 if ((queue->address_len = lctx->un_len) &&
362 (0 == memcmp (lctx->un, queue->address, queue->address_len)))
372 * Find an existing queue by address.
374 * @param plugin the plugin
375 * @param address the address to find
376 * @return NULL if queue was not found
378 static struct Queue *
379 lookup_queue (const struct GNUNET_PeerIdentity *peer,
380 const struct sockaddr_un *un,
383 struct LookupCtx lctx;
386 lctx.un_len = un_len;
387 GNUNET_CONTAINER_multipeermap_get_multiple (queue_map,
396 * We have been notified that our socket is ready to write.
397 * Then reschedule this function to be called again once more is available.
402 select_write_cb (void *cls)
404 struct Queue *queue = queue_tail;
405 const struct GNUNET_MessageHeader *msg = queue->msg;
406 size_t msg_size = ntohs (msg->size);
409 /* take queue of the ready list */
411 GNUNET_CONTAINER_DLL_remove (queue_head, queue_tail, queue);
412 if (NULL != queue_head)
413 write_task = GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL,
420 GNUNET_MQ_impl_send_continue (queue->mq);
423 sent = GNUNET_NETWORK_socket_sendto (unix_sock,
426 (const struct sockaddr *) queue->address,
428 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
429 "UNIX transmitted message to %s (%d/%u: %s)\n",
430 GNUNET_i2s (&queue->target),
432 (unsigned int) msg_size,
433 (sent < 0) ? strerror (errno) : "ok");
436 GNUNET_STATISTICS_update (stats,
440 reschedule_queue_timeout (queue);
441 return; /* all good */
443 GNUNET_STATISTICS_update (stats,
444 "# network transmission failures",
451 /* We should retry later... */
452 GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, "send");
456 socklen_t len = sizeof (size);
458 GNUNET_NETWORK_socket_getsockopt (unix_sock,
463 if (size > ntohs (msg->size))
465 /* Buffer is bigger than message: error, no retry
466 * This should never happen!*/
471 GNUNET_ERROR_TYPE_DEBUG,
472 "Trying to increase socket buffer size from %u to %u for message size %u\n",
474 (unsigned int) ((msg_size / 1000) + 2) * 1000,
475 (unsigned int) msg_size);
476 size = ((msg_size / 1000) + 2) * 1000;
477 if (GNUNET_OK == GNUNET_NETWORK_socket_setsockopt (unix_sock,
482 goto resend; /* Increased buffer size, retry sending */
483 /* Ok, then just try very modest increase */
485 if (GNUNET_OK == GNUNET_NETWORK_socket_setsockopt (unix_sock,
490 goto resend; /* Increased buffer size, retry sending */
491 /* Could not increase buffer size: error, no retry */
492 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "setsockopt");
496 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "send");
503 * Signature of functions implementing the sending functionality of a
506 * @param mq the message queue
507 * @param msg the message to send
508 * @param impl_state our `struct Queue`
511 mq_send (struct GNUNET_MQ_Handle *mq,
512 const struct GNUNET_MessageHeader *msg,
515 struct Queue *queue = impl_state;
517 GNUNET_assert (mq == queue->mq);
518 GNUNET_assert (NULL == queue->msg);
520 GNUNET_CONTAINER_DLL_insert (queue_head, queue_tail, queue);
521 GNUNET_assert (NULL != unix_sock);
522 if (NULL == write_task)
523 write_task = GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL,
531 * Signature of functions implementing the destruction of a message
532 * queue. Implementations must not free @a mq, but should take care
535 * @param mq the message queue to destroy
536 * @param impl_state our `struct Queue`
539 mq_destroy (struct GNUNET_MQ_Handle *mq, void *impl_state)
541 struct Queue *queue = impl_state;
546 queue_destroy (queue);
552 * Implementation function that cancels the currently sent message.
554 * @param mq message queue
555 * @param impl_state our `struct Queue`
558 mq_cancel (struct GNUNET_MQ_Handle *mq, void *impl_state)
560 struct Queue *queue = impl_state;
562 GNUNET_assert (NULL != queue->msg);
564 GNUNET_CONTAINER_DLL_remove (queue_head, queue_tail, queue);
565 GNUNET_assert (NULL != write_task);
566 if (NULL == queue_head)
568 GNUNET_SCHEDULER_cancel (write_task);
575 * Generic error handler, called with the appropriate
576 * error code and the same closure specified at the creation of
578 * Not every message queue implementation supports an error handler.
580 * @param cls our `struct Queue`
581 * @param error error code
584 mq_error (void *cls, enum GNUNET_MQ_Error error)
586 struct Queue *queue = cls;
588 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
589 "UNIX MQ error in queue to %s: %d\n",
590 GNUNET_i2s (&queue->target),
592 queue_destroy (queue);
597 * Creates a new outbound queue the transport service will use to send
598 * data to another peer.
600 * @param peer the target peer
601 * @param cs inbound or outbound queue
602 * @param un the address
603 * @param un_len number of bytes in @a un
604 * @return the queue or NULL of max connections exceeded
606 static struct Queue *
607 setup_queue (const struct GNUNET_PeerIdentity *target,
608 enum GNUNET_TRANSPORT_ConnectionStatus cs,
609 const struct sockaddr_un *un,
614 queue = GNUNET_new (struct Queue);
615 queue->target = *target;
616 queue->address = GNUNET_memdup (un, un_len);
617 queue->address_len = un_len;
618 (void) GNUNET_CONTAINER_multipeermap_put (
622 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
623 GNUNET_STATISTICS_set (stats,
625 GNUNET_CONTAINER_multipeermap_size (queue_map),
628 GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
629 queue->timeout_task =
630 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
633 queue->mq = GNUNET_MQ_queue_for_callbacks (&mq_send,
643 if ('\0' == un->sun_path[0])
644 GNUNET_asprintf (&foreign_addr,
646 COMMUNICATOR_ADDRESS_PREFIX,
649 GNUNET_asprintf (&foreign_addr,
651 COMMUNICATOR_ADDRESS_PREFIX,
653 queue->qh = GNUNET_TRANSPORT_communicator_mq_add (ch,
660 GNUNET_free (foreign_addr);
667 * We have been notified that our socket has something to read. Do the
668 * read and reschedule this function to be called again once more is
674 select_read_cb (void *cls);
678 * Function called when message was successfully passed to
679 * transport service. Continue read activity.
682 * @param success #GNUNET_OK on success
685 receive_complete_cb (void *cls, int success)
688 delivering_messages--;
689 if (GNUNET_OK != success)
690 GNUNET_STATISTICS_update (stats,
691 "# transport transmission failures",
694 GNUNET_assert (NULL != unix_sock);
695 if ((NULL == read_task) && (delivering_messages < max_queue_length))
696 read_task = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
704 * We have been notified that our socket has something to read. Do the
705 * read and reschedule this function to be called again once more is
711 select_read_cb (void *cls)
713 char buf[65536] GNUNET_ALIGN;
715 const struct UNIXMessage *msg;
716 struct sockaddr_un un;
721 GNUNET_assert (NULL != unix_sock);
722 read_task = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
726 addrlen = sizeof (un);
727 memset (&un, 0, sizeof (un));
728 ret = GNUNET_NETWORK_socket_recvfrom (unix_sock,
731 (struct sockaddr *) &un,
733 if ((-1 == ret) && ((EAGAIN == errno) || (ENOBUFS == errno)))
737 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "recvfrom");
740 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
741 "Read %d bytes from socket %s\n",
744 GNUNET_assert (AF_UNIX == (un.sun_family));
745 msg = (struct UNIXMessage *) buf;
746 msize = ntohs (msg->header.size);
747 if ((msize < sizeof (struct UNIXMessage)) || (msize > ret))
752 queue = lookup_queue (&msg->sender, &un, addrlen);
755 setup_queue (&msg->sender, GNUNET_TRANSPORT_CS_INBOUND, &un, addrlen);
757 reschedule_queue_timeout (queue);
761 GNUNET_ERROR_TYPE_ERROR,
763 "Maximum number of UNIX connections exceeded, dropping incoming message\n"));
769 uint16_t tsize = msize - sizeof (struct UNIXMessage);
770 const char *msgbuf = (const char *) &msg[1];
772 while (offset + sizeof (struct GNUNET_MessageHeader) <= tsize)
774 const struct GNUNET_MessageHeader *currhdr;
775 struct GNUNET_MessageHeader al_hdr;
778 currhdr = (const struct GNUNET_MessageHeader *) &msgbuf[offset];
779 /* ensure aligned access */
780 memcpy (&al_hdr, currhdr, sizeof (al_hdr));
781 csize = ntohs (al_hdr.size);
782 if ((csize < sizeof (struct GNUNET_MessageHeader)) ||
783 (csize > tsize - offset))
788 ret = GNUNET_TRANSPORT_communicator_receive (ch,
791 GNUNET_TIME_UNIT_FOREVER_REL,
792 &receive_complete_cb,
794 if (GNUNET_SYSERR == ret)
795 return; /* transport not up */
796 if (GNUNET_NO == ret)
798 delivering_messages++;
802 if (delivering_messages >= max_queue_length)
804 /* we should try to apply 'back pressure' */
805 GNUNET_SCHEDULER_cancel (read_task);
812 * Function called by the transport service to initialize a
813 * message queue given address information about another peer.
814 * If and when the communication channel is established, the
815 * communicator must call #GNUNET_TRANSPORT_communicator_mq_add()
816 * to notify the service that the channel is now up. It is
817 * the responsibility of the communicator to manage sane
818 * retries and timeouts for any @a peer/@a address combination
819 * provided by the transport service. Timeouts and retries
820 * do not need to be signalled to the transport service.
823 * @param peer identity of the other peer
824 * @param address where to send the message, human-readable
825 * communicator-specific format, 0-terminated, UTF-8
826 * @return #GNUNET_OK on success, #GNUNET_SYSERR if the provided address is invalid
829 mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address)
833 struct sockaddr_un *un;
837 if (0 != strncmp (address,
838 COMMUNICATOR_ADDRESS_PREFIX "-",
839 strlen (COMMUNICATOR_ADDRESS_PREFIX "-")))
842 return GNUNET_SYSERR;
844 path = &address[strlen (COMMUNICATOR_ADDRESS_PREFIX "-")];
845 un = unix_address_to_sockaddr (path, &un_len);
846 queue = lookup_queue (peer, un, un_len);
849 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
850 "Address `%s' for %s ignored, queue exists\n",
856 queue = setup_queue (peer, GNUNET_TRANSPORT_CS_OUTBOUND, un, un_len);
860 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
861 "Failed to setup queue to %s at `%s'\n",
871 * Iterator over all message queues to clean up.
874 * @param target unused
875 * @param value the queue to destroy
876 * @return #GNUNET_OK to continue to iterate
879 get_queue_delete_it (void *cls,
880 const struct GNUNET_PeerIdentity *target,
883 struct Queue *queue = value;
887 queue_destroy (queue);
893 * Shutdown the UNIX communicator.
895 * @param cls NULL (always)
898 do_shutdown (void *cls)
900 if (NULL != read_task)
902 GNUNET_SCHEDULER_cancel (read_task);
905 if (NULL != write_task)
907 GNUNET_SCHEDULER_cancel (write_task);
910 if (NULL != unix_sock)
912 GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (unix_sock));
915 GNUNET_CONTAINER_multipeermap_iterate (queue_map, &get_queue_delete_it, NULL);
916 GNUNET_CONTAINER_multipeermap_destroy (queue_map);
919 GNUNET_TRANSPORT_communicator_address_remove (ai);
924 GNUNET_TRANSPORT_communicator_disconnect (ch);
929 GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
936 * Function called when the transport service has received an
937 * acknowledgement for this communicator (!) via a different return
940 * Not applicable for UNIX.
943 * @param sender which peer sent the notification
947 enc_notify_cb (void *cls,
948 const struct GNUNET_PeerIdentity *sender,
949 const struct GNUNET_MessageHeader *msg)
959 * Setup communicator and launch network interactions.
961 * @param cls NULL (always)
962 * @param args remaining command-line arguments
963 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
964 * @param cfg configuration
970 const struct GNUNET_CONFIGURATION_Handle *cfg)
972 char *unix_socket_path;
973 struct sockaddr_un *un;
979 GNUNET_CONFIGURATION_get_value_filename (cfg,
980 COMMUNICATOR_CONFIG_SECTION,
984 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
985 COMMUNICATOR_CONFIG_SECTION,
990 GNUNET_CONFIGURATION_get_value_number (cfg,
991 COMMUNICATOR_CONFIG_SECTION,
994 max_queue_length = DEFAULT_MAX_QUEUE_LENGTH;
996 un = unix_address_to_sockaddr (unix_socket_path, &un_len);
999 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1000 "Failed to setup UNIX domain socket address with path `%s'\n",
1002 GNUNET_free (unix_socket_path);
1005 unix_sock = GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_DGRAM, 0);
1006 if (NULL == unix_sock)
1008 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket");
1010 GNUNET_free (unix_socket_path);
1013 if (('\0' != un->sun_path[0]) &&
1014 (GNUNET_OK != GNUNET_DISK_directory_create_for_file (un->sun_path)))
1016 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1017 _ ("Cannot create path to `%s'\n"),
1019 GNUNET_NETWORK_socket_close (unix_sock);
1022 GNUNET_free (unix_socket_path);
1025 if (GNUNET_OK != GNUNET_NETWORK_socket_bind (unix_sock,
1026 (const struct sockaddr *) un,
1029 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "bind", un->sun_path);
1030 GNUNET_NETWORK_socket_close (unix_sock);
1033 GNUNET_free (unix_socket_path);
1037 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Bound to `%s'\n", unix_socket_path);
1038 stats = GNUNET_STATISTICS_create ("C-UNIX", cfg);
1039 GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
1040 read_task = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
1044 queue_map = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
1045 ch = GNUNET_TRANSPORT_communicator_connect (cfg,
1046 COMMUNICATOR_CONFIG_SECTION,
1047 COMMUNICATOR_ADDRESS_PREFIX,
1048 GNUNET_TRANSPORT_CC_RELIABLE,
1056 GNUNET_SCHEDULER_shutdown ();
1057 GNUNET_free (unix_socket_path);
1060 GNUNET_asprintf (&my_addr,
1062 COMMUNICATOR_ADDRESS_PREFIX,
1064 GNUNET_free (unix_socket_path);
1065 ai = GNUNET_TRANSPORT_communicator_address_add (ch,
1068 GNUNET_TIME_UNIT_FOREVER_REL);
1069 GNUNET_free (my_addr);
1074 * The main function for the UNIX communicator.
1076 * @param argc number of arguments from the command line
1077 * @param argv command line arguments
1078 * @return 0 ok, 1 on error
1081 main (int argc, char *const *argv)
1083 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
1084 GNUNET_GETOPT_OPTION_END};
1087 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
1091 GNUNET_PROGRAM_run (argc,
1093 "gnunet-communicator-unix",
1094 _ ("GNUnet UNIX domain socket communicator"),
1100 GNUNET_free ((void *) argv);
1105 #if defined(LINUX) && defined(__GLIBC__)
1109 * MINIMIZE heap size (way below 128k) since this process doesn't need much.
1111 void __attribute__ ((constructor)) GNUNET_ARM_memory_init ()
1113 mallopt (M_TRIM_THRESHOLD, 4 * 1024);
1114 mallopt (M_TOP_PAD, 1 * 1024);
1119 /* end of gnunet-communicator-unix.c */