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
89 * Queues with pending messages (!) are kept in a DLL.
94 * Queues with pending messages (!) are kept in a DLL.
99 * To whom are we talking to.
101 struct GNUNET_PeerIdentity target;
104 * Address of the other peer.
106 struct sockaddr_un *address;
109 * Length of the address.
111 socklen_t address_len;
114 * Message currently scheduled for transmission, non-NULL if and only
115 * if this queue is in the #queue_head DLL.
117 const struct GNUNET_MessageHeader *msg;
120 * Message queue we are providing for the #ch.
122 struct GNUNET_MQ_Handle *mq;
125 * handle for this queue with the #ch.
127 struct GNUNET_TRANSPORT_QueueHandle *qh;
130 * Number of bytes we currently have in our write queue.
132 unsigned long long bytes_in_queue;
135 * Timeout for this queue.
137 struct GNUNET_TIME_Absolute timeout;
140 * Queue timeout task.
142 struct GNUNET_SCHEDULER_Task *timeout_task;
149 static struct GNUNET_SCHEDULER_Task *read_task;
154 static struct GNUNET_SCHEDULER_Task *write_task;
157 * Number of messages we currently have in our queues towards the transport service.
159 static unsigned long long delivering_messages;
162 * Maximum queue length before we stop reading towards the transport service.
164 static unsigned long long max_queue_length;
167 * For logging statistics.
169 static struct GNUNET_STATISTICS_Handle *stats;
174 static struct GNUNET_TRANSPORT_CommunicatorHandle *ch;
177 * Queues (map from peer identity to `struct Queue`)
179 static struct GNUNET_CONTAINER_MultiPeerMap *queue_map;
182 * Head of queue of messages to transmit.
184 static struct Queue *queue_head;
187 * Tail of queue of messages to transmit.
189 static struct Queue *queue_tail;
192 * socket that we transmit all data with
194 static struct GNUNET_NETWORK_Handle *unix_sock;
197 * Handle to the operation that publishes our address.
199 static struct GNUNET_TRANSPORT_AddressIdentifier *ai;
203 * Functions with this signature are called whenever we need
204 * to close a queue due to a disconnect or failure to
205 * establish a connection.
207 * @param queue queue to close down
210 queue_destroy (struct Queue *queue)
212 struct GNUNET_MQ_Handle *mq;
214 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
215 "Disconnecting queue for peer `%s'\n",
216 GNUNET_i2s (&queue->target));
217 if (0 != queue->bytes_in_queue)
219 GNUNET_CONTAINER_DLL_remove (queue_head, queue_tail, queue);
220 queue->bytes_in_queue = 0;
222 if (NULL != (mq = queue->mq))
225 GNUNET_MQ_destroy (mq);
229 GNUNET_CONTAINER_multipeermap_remove (queue_map, &queue->target, queue));
230 GNUNET_STATISTICS_set (stats,
232 GNUNET_CONTAINER_multipeermap_size (queue_map),
234 if (NULL != queue->timeout_task)
236 GNUNET_SCHEDULER_cancel (queue->timeout_task);
237 queue->timeout_task = NULL;
239 GNUNET_free (queue->address);
245 * Queue was idle for too long, so disconnect it
247 * @param cls the `struct Queue *` to disconnect
250 queue_timeout (void *cls)
252 struct Queue *queue = cls;
253 struct GNUNET_TIME_Relative left;
255 queue->timeout_task = NULL;
256 left = GNUNET_TIME_absolute_get_remaining (queue->timeout);
257 if (0 != left.rel_value_us)
259 /* not actually our turn yet, but let's at least update
260 the monitor, it may think we're about to die ... */
261 queue->timeout_task =
262 GNUNET_SCHEDULER_add_delayed (left, &queue_timeout, queue);
265 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
266 "Queue %p was idle for %s, disconnecting\n",
268 GNUNET_STRINGS_relative_time_to_string (
269 GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
271 queue_destroy (queue);
276 * Increment queue timeout due to activity. We do not immediately
277 * notify the monitor here as that might generate excessive
280 * @param queue queue for which the timeout should be rescheduled
283 reschedule_queue_timeout (struct Queue *queue)
285 GNUNET_assert (NULL != queue->timeout_task);
287 GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
292 * Convert unix path to a `struct sockaddr_un *`
294 * @param unixpath path to convert
295 * @param[out] sock_len set to the length of the address
296 * @param is_abstract is this an abstract @a unixpath
297 * @return converted unix path
299 static struct sockaddr_un *
300 unix_address_to_sockaddr (const char *unixpath, socklen_t *sock_len)
302 struct sockaddr_un *un;
305 GNUNET_assert (0 < strlen (unixpath)); /* sanity check */
306 un = GNUNET_new (struct sockaddr_un);
307 un->sun_family = AF_UNIX;
308 slen = strlen (unixpath);
309 if (slen >= sizeof(un->sun_path))
310 slen = sizeof(un->sun_path) - 1;
311 GNUNET_memcpy (un->sun_path, unixpath, slen);
312 un->sun_path[slen] = '\0';
313 slen = sizeof(struct sockaddr_un);
314 #if HAVE_SOCKADDR_UN_SUN_LEN
315 un->sun_len = (u_char) slen;
318 if ('@' == un->sun_path[0])
319 un->sun_path[0] = '\0';
325 * Closure to #lookup_queue_it().
330 * Location to store the queue, if found.
335 * Address we are looking for.
337 const struct sockaddr_un *un;
340 * Number of bytes in @a un
347 * Function called to find a queue by address.
349 * @param cls the `struct LookupCtx *`
350 * @param key peer we are looking for (unused)
351 * @param value a queue
352 * @return #GNUNET_YES if not found (continue looking), #GNUNET_NO on success
355 lookup_queue_it (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
357 struct LookupCtx *lctx = cls;
358 struct Queue *queue = value;
360 if ((queue->address_len = lctx->un_len) &&
361 (0 == memcmp (lctx->un, queue->address, queue->address_len)))
371 * Find an existing queue by address.
373 * @param plugin the plugin
374 * @param address the address to find
375 * @return NULL if queue was not found
377 static struct Queue *
378 lookup_queue (const struct GNUNET_PeerIdentity *peer,
379 const struct sockaddr_un *un,
382 struct LookupCtx lctx;
385 lctx.un_len = un_len;
386 GNUNET_CONTAINER_multipeermap_get_multiple (queue_map,
395 * We have been notified that our socket is ready to write.
396 * Then reschedule this function to be called again once more is available.
401 select_write_cb (void *cls)
403 struct Queue *queue = queue_tail;
404 const struct GNUNET_MessageHeader *msg = queue->msg;
405 size_t msg_size = ntohs (msg->size);
408 /* take queue of the ready list */
410 GNUNET_CONTAINER_DLL_remove (queue_head, queue_tail, queue);
411 if (NULL != queue_head)
412 write_task = GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL,
419 GNUNET_MQ_impl_send_continue (queue->mq);
422 sent = GNUNET_NETWORK_socket_sendto (unix_sock,
425 (const struct sockaddr *) queue->address,
427 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
428 "UNIX transmitted message to %s (%d/%u: %s)\n",
429 GNUNET_i2s (&queue->target),
431 (unsigned int) msg_size,
432 (sent < 0) ? strerror (errno) : "ok");
435 GNUNET_STATISTICS_update (stats,
439 reschedule_queue_timeout (queue);
440 return; /* all good */
442 GNUNET_STATISTICS_update (stats,
443 "# network transmission failures",
450 /* We should retry later... */
451 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");
497 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "send");
504 * Signature of functions implementing the sending functionality of a
507 * @param mq the message queue
508 * @param msg the message to send
509 * @param impl_state our `struct Queue`
512 mq_send (struct GNUNET_MQ_Handle *mq,
513 const struct GNUNET_MessageHeader *msg,
516 struct Queue *queue = impl_state;
518 GNUNET_assert (mq == queue->mq);
519 GNUNET_assert (NULL == queue->msg);
521 GNUNET_CONTAINER_DLL_insert (queue_head, queue_tail, queue);
522 GNUNET_assert (NULL != unix_sock);
523 if (NULL == write_task)
524 write_task = GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL,
532 * Signature of functions implementing the destruction of a message
533 * queue. Implementations must not free @a mq, but should take care
536 * @param mq the message queue to destroy
537 * @param impl_state our `struct Queue`
540 mq_destroy (struct GNUNET_MQ_Handle *mq, void *impl_state)
542 struct Queue *queue = impl_state;
547 queue_destroy (queue);
553 * Implementation function that cancels the currently sent message.
555 * @param mq message queue
556 * @param impl_state our `struct Queue`
559 mq_cancel (struct GNUNET_MQ_Handle *mq, void *impl_state)
561 struct Queue *queue = impl_state;
563 GNUNET_assert (NULL != queue->msg);
565 GNUNET_CONTAINER_DLL_remove (queue_head, queue_tail, queue);
566 GNUNET_assert (NULL != write_task);
567 if (NULL == queue_head)
569 GNUNET_SCHEDULER_cancel (write_task);
576 * Generic error handler, called with the appropriate
577 * error code and the same closure specified at the creation of
579 * Not every message queue implementation supports an error handler.
581 * @param cls our `struct Queue`
582 * @param error error code
585 mq_error (void *cls, enum GNUNET_MQ_Error error)
587 struct Queue *queue = cls;
589 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
590 "UNIX MQ error in queue to %s: %d\n",
591 GNUNET_i2s (&queue->target),
593 queue_destroy (queue);
598 * Creates a new outbound queue the transport service will use to send
599 * data to another peer.
601 * @param peer the target peer
602 * @param cs inbound or outbound queue
603 * @param un the address
604 * @param un_len number of bytes in @a un
605 * @return the queue or NULL of max connections exceeded
607 static struct Queue *
608 setup_queue (const struct GNUNET_PeerIdentity *target,
609 enum GNUNET_TRANSPORT_ConnectionStatus cs,
610 const struct sockaddr_un *un,
615 queue = GNUNET_new (struct Queue);
616 queue->target = *target;
617 queue->address = GNUNET_memdup (un, un_len);
618 queue->address_len = un_len;
619 (void) GNUNET_CONTAINER_multipeermap_put (
623 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
624 GNUNET_STATISTICS_set (stats,
626 GNUNET_CONTAINER_multipeermap_size (queue_map),
629 GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
630 queue->timeout_task =
631 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
634 queue->mq = GNUNET_MQ_queue_for_callbacks (&mq_send,
644 if ('\0' == un->sun_path[0])
645 GNUNET_asprintf (&foreign_addr,
647 COMMUNICATOR_ADDRESS_PREFIX,
650 GNUNET_asprintf (&foreign_addr,
652 COMMUNICATOR_ADDRESS_PREFIX,
654 queue->qh = GNUNET_TRANSPORT_communicator_mq_add (ch,
661 GNUNET_free (foreign_addr);
668 * We have been notified that our socket has something to read. Do the
669 * read and reschedule this function to be called again once more is
675 select_read_cb (void *cls);
679 * Function called when message was successfully passed to
680 * transport service. Continue read activity.
683 * @param success #GNUNET_OK on success
686 receive_complete_cb (void *cls, int success)
689 delivering_messages--;
690 if (GNUNET_OK != success)
691 GNUNET_STATISTICS_update (stats,
692 "# transport transmission failures",
695 GNUNET_assert (NULL != unix_sock);
696 if ((NULL == read_task) && (delivering_messages < max_queue_length))
697 read_task = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
705 * We have been notified that our socket has something to read. Do the
706 * read and reschedule this function to be called again once more is
712 select_read_cb (void *cls)
714 char buf[65536] GNUNET_ALIGN;
716 const struct UNIXMessage *msg;
717 struct sockaddr_un un;
722 GNUNET_assert (NULL != unix_sock);
723 read_task = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
727 addrlen = sizeof(un);
728 memset (&un, 0, sizeof(un));
729 ret = GNUNET_NETWORK_socket_recvfrom (unix_sock,
732 (struct sockaddr *) &un,
734 if ((-1 == ret) && ((EAGAIN == errno) || (ENOBUFS == errno)))
738 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "recvfrom");
741 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
742 "Read %d bytes from socket %s\n",
745 GNUNET_assert (AF_UNIX == (un.sun_family));
746 msg = (struct UNIXMessage *) buf;
747 msize = ntohs (msg->header.size);
748 if ((msize < sizeof(struct UNIXMessage)) || (msize > ret))
753 queue = lookup_queue (&msg->sender, &un, addrlen);
756 setup_queue (&msg->sender, GNUNET_TRANSPORT_CS_INBOUND, &un, addrlen);
758 reschedule_queue_timeout (queue);
762 GNUNET_ERROR_TYPE_ERROR,
764 "Maximum number of UNIX connections exceeded, dropping incoming message\n"));
770 uint16_t tsize = msize - sizeof(struct UNIXMessage);
771 const char *msgbuf = (const char *) &msg[1];
773 while (offset + sizeof(struct GNUNET_MessageHeader) <= tsize)
775 const struct GNUNET_MessageHeader *currhdr;
776 struct GNUNET_MessageHeader al_hdr;
779 currhdr = (const struct GNUNET_MessageHeader *) &msgbuf[offset];
780 /* ensure aligned access */
781 memcpy (&al_hdr, currhdr, sizeof(al_hdr));
782 csize = ntohs (al_hdr.size);
783 if ((csize < sizeof(struct GNUNET_MessageHeader)) ||
784 (csize > tsize - offset))
789 ret = GNUNET_TRANSPORT_communicator_receive (ch,
792 GNUNET_TIME_UNIT_FOREVER_REL,
793 &receive_complete_cb,
795 if (GNUNET_SYSERR == ret)
796 return; /* transport not up */
797 if (GNUNET_NO == ret)
799 delivering_messages++;
803 if (delivering_messages >= max_queue_length)
805 /* we should try to apply 'back pressure' */
806 GNUNET_SCHEDULER_cancel (read_task);
813 * Function called by the transport service to initialize a
814 * message queue given address information about another peer.
815 * If and when the communication channel is established, the
816 * communicator must call #GNUNET_TRANSPORT_communicator_mq_add()
817 * to notify the service that the channel is now up. It is
818 * the responsibility of the communicator to manage sane
819 * retries and timeouts for any @a peer/@a address combination
820 * provided by the transport service. Timeouts and retries
821 * do not need to be signalled to the transport service.
824 * @param peer identity of the other peer
825 * @param address where to send the message, human-readable
826 * communicator-specific format, 0-terminated, UTF-8
827 * @return #GNUNET_OK on success, #GNUNET_SYSERR if the provided address is invalid
830 mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address)
834 struct sockaddr_un *un;
838 if (0 != strncmp (address,
839 COMMUNICATOR_ADDRESS_PREFIX "-",
840 strlen (COMMUNICATOR_ADDRESS_PREFIX "-")))
843 return GNUNET_SYSERR;
845 path = &address[strlen (COMMUNICATOR_ADDRESS_PREFIX "-")];
846 un = unix_address_to_sockaddr (path, &un_len);
847 queue = lookup_queue (peer, un, un_len);
850 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
851 "Address `%s' for %s ignored, queue exists\n",
857 queue = setup_queue (peer, GNUNET_TRANSPORT_CS_OUTBOUND, un, un_len);
861 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
862 "Failed to setup queue to %s at `%s'\n",
872 * Iterator over all message queues to clean up.
875 * @param target unused
876 * @param value the queue to destroy
877 * @return #GNUNET_OK to continue to iterate
880 get_queue_delete_it (void *cls,
881 const struct GNUNET_PeerIdentity *target,
884 struct Queue *queue = value;
888 queue_destroy (queue);
894 * Shutdown the UNIX communicator.
896 * @param cls NULL (always)
899 do_shutdown (void *cls)
901 if (NULL != read_task)
903 GNUNET_SCHEDULER_cancel (read_task);
906 if (NULL != write_task)
908 GNUNET_SCHEDULER_cancel (write_task);
911 if (NULL != unix_sock)
913 GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (unix_sock));
916 GNUNET_CONTAINER_multipeermap_iterate (queue_map, &get_queue_delete_it, NULL);
917 GNUNET_CONTAINER_multipeermap_destroy (queue_map);
920 GNUNET_TRANSPORT_communicator_address_remove (ai);
925 GNUNET_TRANSPORT_communicator_disconnect (ch);
930 GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
937 * Function called when the transport service has received an
938 * acknowledgement for this communicator (!) via a different return
941 * Not applicable for UNIX.
944 * @param sender which peer sent the notification
948 enc_notify_cb (void *cls,
949 const struct GNUNET_PeerIdentity *sender,
950 const struct GNUNET_MessageHeader *msg)
960 * Setup communicator and launch network interactions.
962 * @param cls NULL (always)
963 * @param args remaining command-line arguments
964 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
965 * @param cfg configuration
971 const struct GNUNET_CONFIGURATION_Handle *cfg)
973 char *unix_socket_path;
974 struct sockaddr_un *un;
981 GNUNET_CONFIGURATION_get_value_filename (cfg,
982 COMMUNICATOR_CONFIG_SECTION,
986 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
987 COMMUNICATOR_CONFIG_SECTION,
992 GNUNET_CONFIGURATION_get_value_number (cfg,
993 COMMUNICATOR_CONFIG_SECTION,
996 max_queue_length = DEFAULT_MAX_QUEUE_LENGTH;
998 un = unix_address_to_sockaddr (unix_socket_path, &un_len);
1001 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1002 "Failed to setup UNIX domain socket address with path `%s'\n",
1004 GNUNET_free (unix_socket_path);
1007 unix_sock = GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_DGRAM, 0);
1008 if (NULL == unix_sock)
1010 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket");
1012 GNUNET_free (unix_socket_path);
1015 if (('\0' != un->sun_path[0]) &&
1016 (GNUNET_OK != GNUNET_DISK_directory_create_for_file (un->sun_path)))
1018 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1019 _ ("Cannot create path to `%s'\n"),
1021 GNUNET_NETWORK_socket_close (unix_sock);
1024 GNUNET_free (unix_socket_path);
1027 if (GNUNET_OK != GNUNET_NETWORK_socket_bind (unix_sock,
1028 (const struct sockaddr *) un,
1031 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "bind", un->sun_path);
1032 GNUNET_NETWORK_socket_close (unix_sock);
1035 GNUNET_free (unix_socket_path);
1039 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Bound to `%s'\n", unix_socket_path);
1040 stats = GNUNET_STATISTICS_create ("C-UNIX", cfg);
1041 GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
1042 read_task = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
1046 queue_map = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
1047 ch = GNUNET_TRANSPORT_communicator_connect (cfg,
1048 COMMUNICATOR_CONFIG_SECTION,
1049 COMMUNICATOR_ADDRESS_PREFIX,
1050 GNUNET_TRANSPORT_CC_RELIABLE,
1058 GNUNET_SCHEDULER_shutdown ();
1059 GNUNET_free (unix_socket_path);
1062 GNUNET_asprintf (&my_addr,
1064 COMMUNICATOR_ADDRESS_PREFIX,
1066 GNUNET_free (unix_socket_path);
1067 ai = GNUNET_TRANSPORT_communicator_address_add (ch,
1070 GNUNET_TIME_UNIT_FOREVER_REL);
1071 GNUNET_free (my_addr);
1076 * The main function for the UNIX communicator.
1078 * @param argc number of arguments from the command line
1079 * @param argv command line arguments
1080 * @return 0 ok, 1 on error
1083 main (int argc, char *const *argv)
1085 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
1086 GNUNET_GETOPT_OPTION_END
1090 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
1094 GNUNET_PROGRAM_run (argc,
1096 "gnunet-communicator-unix",
1097 _ ("GNUnet UNIX domain socket communicator"),
1103 GNUNET_free ((void *) argv);
1108 #if defined(__linux__) && defined(__GLIBC__)
1112 * MINIMIZE heap size (way below 128k) since this process doesn't need much.
1114 void __attribute__ ((constructor))
1115 GNUNET_ARM_memory_init ()
1117 mallopt (M_TRIM_THRESHOLD, 4 * 1024);
1118 mallopt (M_TOP_PAD, 1 * 1024);
1125 /* end of gnunet-communicator-unix.c */