2 This file is part of GNUnet.
3 (C) 2010-2015 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/gnunet-service-transport.c
23 * @brief main for gnunet-service-transport
24 * @author Christian Grothoff
27 #include "gnunet_util_lib.h"
28 #include "gnunet_hello_lib.h"
29 #include "gnunet_statistics_service.h"
30 #include "gnunet_transport_service.h"
31 #include "gnunet_peerinfo_service.h"
32 #include "gnunet_ats_service.h"
33 #include "gnunet-service-transport.h"
34 #include "gnunet-service-transport_ats.h"
35 #include "gnunet-service-transport_blacklist.h"
36 #include "gnunet-service-transport_clients.h"
37 #include "gnunet-service-transport_hello.h"
38 #include "gnunet-service-transport_neighbours.h"
39 #include "gnunet-service-transport_plugins.h"
40 #include "gnunet-service-transport_validation.h"
41 #include "gnunet-service-transport_manipulation.h"
42 #include "transport.h"
45 * Information we need for an asynchronous session kill.
52 struct SessionKiller *next;
57 struct SessionKiller *prev;
62 struct Session *session;
65 * Plugin for the session.
67 struct GNUNET_TRANSPORT_PluginFunctions *plugin;
72 struct GNUNET_SCHEDULER_Task * task;
76 struct BlacklistCheckContext
78 struct BlacklistCheckContext *prev;
80 struct BlacklistCheckContext *next;
82 struct GST_BlacklistCheck *blc;
84 struct GNUNET_HELLO_Address *address;
86 struct Session *session;
88 struct GNUNET_MessageHeader *msg;
97 struct GNUNET_STATISTICS_Handle *GST_stats;
100 * Configuration handle.
102 const struct GNUNET_CONFIGURATION_Handle *GST_cfg;
105 * Configuration handle.
107 struct GNUNET_PeerIdentity GST_my_identity;
110 * Handle to peerinfo service.
112 struct GNUNET_PEERINFO_Handle *GST_peerinfo;
115 * Handle to our service's server.
117 static struct GNUNET_SERVER_Handle *GST_server;
122 struct GNUNET_CRYPTO_EddsaPrivateKey *GST_my_private_key;
127 struct GNUNET_ATS_SchedulingHandle *GST_ats;
130 * Hello address expiration
132 struct GNUNET_TIME_Relative hello_expiration;
135 * Head of DLL of asynchronous tasks to kill sessions.
137 static struct SessionKiller *sk_head;
140 * Tail of DLL of asynchronous tasks to kill sessions.
142 static struct SessionKiller *sk_tail;
147 struct BlacklistCheckContext *bc_head;
152 struct BlacklistCheckContext *bc_tail;
156 * Transmit our HELLO message to the given (connected) neighbour.
158 * @param cls the 'HELLO' message
159 * @param peer identity of the peer
160 * @param address the address
161 * @param state current state this peer is in
162 * @param state_timeout timeout for the current state of the peer
163 * @param bandwidth_in inbound quota in NBO
164 * @param bandwidth_out outbound quota in NBO
167 transmit_our_hello (void *cls,
168 const struct GNUNET_PeerIdentity *peer,
169 const struct GNUNET_HELLO_Address *address,
170 enum GNUNET_TRANSPORT_PeerState state,
171 struct GNUNET_TIME_Absolute state_timeout,
172 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
173 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
175 const struct GNUNET_MessageHeader *hello = cls;
177 if (GNUNET_NO == GST_neighbours_test_connected (peer))
180 GST_neighbours_send (peer,
189 * My HELLO has changed. Tell everyone who should know.
192 * @param hello new HELLO
195 process_hello_update (void *cls, const struct GNUNET_MessageHeader *hello)
197 GST_clients_broadcast (hello, GNUNET_NO);
198 GST_neighbours_iterate (&transmit_our_hello, (void *) hello);
203 * We received some payload. Prepare to pass it on to our clients.
205 * @param address address and (claimed) identity of the other peer
206 * @param session identifier used for this session (NULL for plugins
207 * that do not offer bi-directional communication to the sender
208 * using the same "connection")
209 * @param message the message to process
210 * @return how long the plugin should wait until receiving more data
212 static struct GNUNET_TIME_Relative
213 process_payload (const struct GNUNET_HELLO_Address *address,
214 struct Session *session,
215 const struct GNUNET_MessageHeader *message)
217 struct GNUNET_TIME_Relative ret;
219 struct InboundMessage *im;
220 size_t msg_size = ntohs (message->size);
221 size_t size = sizeof(struct InboundMessage) + msg_size;
222 char buf[size] GNUNET_ALIGN;
224 do_forward = GNUNET_SYSERR;
225 ret = GST_neighbours_calculate_receive_delay (&address->peer,
228 if (! GST_neighbours_test_connected (&address->peer))
230 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
231 "Discarded %u bytes type %u payload from peer `%s'\n",
233 ntohs (message->type),
234 GNUNET_i2s (&address->peer));
235 GNUNET_STATISTICS_update (GST_stats, gettext_noop
236 ("# bytes payload discarded due to not connected peer"),
242 if (GNUNET_YES != do_forward)
244 im = (struct InboundMessage *) buf;
245 im->header.size = htons (size);
246 im->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RECV);
247 im->peer = address->peer;
248 memcpy (&im[1], message, ntohs (message->size));
249 GST_clients_broadcast (&im->header, GNUNET_YES);
255 * Task to asynchronously terminate a session.
257 * @param cls the `struct SessionKiller` with the information for the kill
258 * @param tc scheduler context
261 kill_session_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
263 struct SessionKiller *sk = cls;
266 GNUNET_CONTAINER_DLL_remove(sk_head, sk_tail, sk);
267 sk->plugin->disconnect_session (sk->plugin->cls, sk->session);
273 * FIXME. Also, consider moving the "bc_*" logic into
277 cancel_pending_blacklist_checks (const struct GNUNET_HELLO_Address *address,
278 struct Session *session)
280 struct BlacklistCheckContext *blctx;
281 struct BlacklistCheckContext *next;
284 for (blctx = next; NULL != blctx; blctx = next)
287 if ( (NULL != blctx->address) &&
288 (0 == GNUNET_HELLO_address_cmp(blctx->address, address)) &&
289 (blctx->session == session))
291 GNUNET_CONTAINER_DLL_remove (bc_head, bc_tail, blctx);
292 if (NULL != blctx->blc)
294 GST_blacklist_test_cancel (blctx->blc);
297 GNUNET_HELLO_address_free (blctx->address);
298 GNUNET_free_non_null (blctx->msg);
306 * Force plugin to terminate session due to communication
309 * @param plugin_name name of the plugin
310 * @param session session to termiante
313 kill_session (const char *plugin_name,
314 struct Session *session)
316 struct GNUNET_TRANSPORT_PluginFunctions *plugin;
317 struct SessionKiller *sk;
319 for (sk = sk_head; NULL != sk; sk = sk->next)
320 if (sk->session == session)
322 plugin = GST_plugins_find (plugin_name);
328 /* need to issue disconnect asynchronously */
329 sk = GNUNET_new (struct SessionKiller);
330 sk->session = session;
332 sk->task = GNUNET_SCHEDULER_add_now (&kill_session_task, sk);
333 GNUNET_CONTAINER_DLL_insert (sk_head,
340 * Black list check result for try_connect call
341 * If connection to the peer is allowed request adddress and ???
343 * @param cls blc_ctx bl context
344 * @param peer the peer
345 * @param result the result
348 connect_bl_check_cont (void *cls,
349 const struct GNUNET_PeerIdentity *peer,
352 struct BlacklistCheckContext *blctx = cls;
354 GNUNET_CONTAINER_DLL_remove (bc_head, bc_tail, blctx);
357 if (GNUNET_OK == result)
359 /* Blacklist allows to speak to this peer, forward SYN to neighbours */
360 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
361 "Received SYN message from peer `%s' with `%s' %p\n",
363 GST_plugins_a2s (blctx->address),
367 GST_neighbours_handle_session_syn (blctx->msg,
368 &blctx->address->peer))
370 cancel_pending_blacklist_checks (blctx->address, blctx->session);
371 kill_session (blctx->address->transport_name, blctx->session);
376 /* Blacklist denies to speak to this peer */
378 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
379 "Discarding SYN message from `%s' due to denied blacklist check\n",
381 cancel_pending_blacklist_checks (blctx->address, blctx->session);
382 kill_session (blctx->address->transport_name, blctx->session);
385 if (NULL != blctx->address)
386 GNUNET_HELLO_address_free (blctx->address);
387 GNUNET_free (blctx->msg);
393 * Function called by the transport for each received message.
395 * @param cls closure, const char* with the name of the plugin we received the message from
396 * @param address address and (claimed) identity of the other peer
397 * @param message the message, NULL if we only care about
398 * learning about the delay until we should receive again
399 * @param session identifier used for this session (NULL for plugins
400 * that do not offer bi-directional communication to the sender
401 * using the same "connection")
402 * @return how long the plugin should wait until receiving more data
403 * (plugins that do not support this, can ignore the return value)
405 struct GNUNET_TIME_Relative
406 GST_receive_callback (void *cls,
407 const struct GNUNET_HELLO_Address *address,
408 struct Session *session,
409 const struct GNUNET_MessageHeader *message)
411 const char *plugin_name = cls;
412 struct GNUNET_TIME_Relative ret;
413 struct BlacklistCheckContext *blctx;
414 struct GST_BlacklistCheck *blc;
417 ret = GNUNET_TIME_UNIT_ZERO;
420 type = ntohs (message->type);
421 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
422 "Received Message with type %u from peer `%s'\n",
424 GNUNET_i2s (&address->peer));
426 GNUNET_STATISTICS_update (GST_stats,
427 gettext_noop ("# bytes total received"),
428 ntohs (message->size),
430 GST_neighbours_notify_data_recv (address,
434 case GNUNET_MESSAGE_TYPE_HELLO_LEGACY:
435 /* Legacy HELLO message, discard */
437 case GNUNET_MESSAGE_TYPE_HELLO:
438 if (GNUNET_OK != GST_validation_handle_hello (message))
441 cancel_pending_blacklist_checks (address,
445 case GNUNET_MESSAGE_TYPE_TRANSPORT_PING:
446 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
447 "Processing `%s' from `%s'\n", "PING",
448 GST_plugins_a2s (address));
450 GST_validation_handle_ping (&address->peer,
455 cancel_pending_blacklist_checks (address,
457 kill_session (plugin_name,
461 case GNUNET_MESSAGE_TYPE_TRANSPORT_PONG:
462 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
463 "Processing `%s' from `%s'\n", "PONG",
464 GST_plugins_a2s (address));
465 if (GNUNET_OK != GST_validation_handle_pong (&address->peer, message))
468 cancel_pending_blacklist_checks (address, session);
469 kill_session (plugin_name, session);
472 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN:
473 /* Do blacklist check if communication with this peer is allowed */
474 blctx = GNUNET_new (struct BlacklistCheckContext);
475 blctx->address = GNUNET_HELLO_address_copy (address);
476 blctx->session = session;
477 blctx->msg = GNUNET_malloc (ntohs(message->size));
478 memcpy (blctx->msg, message, ntohs(message->size));
479 GNUNET_CONTAINER_DLL_insert (bc_head, bc_tail, blctx);
480 if (NULL != (blc = GST_blacklist_test_allowed (&address->peer, NULL,
481 &connect_bl_check_cont,
487 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN_ACK:
489 GST_neighbours_handle_session_syn_ack (message,
493 cancel_pending_blacklist_checks (address, session);
494 kill_session (plugin_name, session);
497 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK:
499 GST_neighbours_handle_session_ack (message,
504 cancel_pending_blacklist_checks (address, session);
505 kill_session (plugin_name, session);
508 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT:
509 GST_neighbours_handle_disconnect_message (&address->peer, message);
511 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE:
512 GST_neighbours_keepalive (&address->peer, message);
514 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE_RESPONSE:
515 GST_neighbours_keepalive_response (&address->peer, message);
518 /* should be payload */
519 GNUNET_STATISTICS_update (GST_stats,
520 gettext_noop ("# bytes payload received"),
521 ntohs (message->size),
523 GST_neighbours_notify_payload_recv (address,
525 ret = process_payload (address,
531 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
532 "Allowing receive from peer %s to continue in %s\n",
533 GNUNET_i2s (&address->peer),
534 GNUNET_STRINGS_relative_time_to_string (ret,
541 * Function that will be called for each address the transport
542 * is aware that it might be reachable under. Update our HELLO.
544 * @param cls name of the plugin (const char*)
545 * @param add_remove should the address added (YES) or removed (NO) from the
546 * set of valid addresses?
547 * @param address the address to add or remove
550 plugin_env_address_change_notification (void *cls,
552 const struct GNUNET_HELLO_Address *address)
554 static int addresses = 0;
555 struct GNUNET_STATISTICS_Handle *cfg = GST_stats;
557 if (GNUNET_YES == add_remove)
560 GNUNET_STATISTICS_update (cfg, "# transport addresses", 1, GNUNET_NO);
562 else if (GNUNET_NO == add_remove)
569 GNUNET_STATISTICS_update (cfg, "# transport addresses", -1, GNUNET_NO);
573 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
574 "Transport now has %u addresses to communicate\n",
576 GST_hello_modify_addresses (add_remove, address);
581 * Function that will be called whenever the plugin internally
582 * cleans up a session pointer and hence the service needs to
583 * discard all of those sessions as well. Plugins that do not
584 * use sessions can simply omit calling this function and always
585 * use NULL wherever a session pointer is needed. This function
586 * should be called BEFORE a potential "TransmitContinuation"
587 * from the "TransmitFunction".
590 * @param address which address was the session for
591 * @param session which session is being destoyed
594 plugin_env_session_end (void *cls,
595 const struct GNUNET_HELLO_Address *address,
596 struct Session *session)
598 struct SessionKiller *sk;
610 GNUNET_assert (strlen (address->transport_name) > 0);
612 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
613 "Notification from plugin `%s' about terminated %s session %p from peer `%s' address `%s'\n",
614 address->transport_name,
615 GNUNET_HELLO_address_check_option (address,
616 GNUNET_HELLO_ADDRESS_INFO_INBOUND) ? "inbound" : "outbound",
618 GNUNET_i2s (&address->peer),
619 GST_plugins_a2s (address));
621 GST_neighbours_session_terminated (&address->peer, session);
622 GST_ats_del_session (address, session);
623 cancel_pending_blacklist_checks (address, session);
625 for (sk = sk_head; NULL != sk; sk = sk->next)
627 if (sk->session == session)
629 GNUNET_CONTAINER_DLL_remove (sk_head, sk_tail, sk);
630 GNUNET_SCHEDULER_cancel (sk->task);
639 * Function that will be called to figure if an address is an loopback,
640 * LAN, WAN etc. address
643 * @param addr binary address
644 * @param addrlen length of the @a addr
645 * @return type of the network @a addr belongs to
647 static enum GNUNET_ATS_Network_Type
648 plugin_env_address_to_type (void *cls,
649 const struct sockaddr *addr,
655 return GNUNET_ATS_NET_UNSPECIFIED;
657 return GNUNET_ATS_address_get_type (GST_ats,
664 * Function that will be called to update metrics for an address
667 * @param address address to update metrics for
668 * @param session the session
669 * @param ats the ats information to update
670 * @param ats_count the number of @a ats elements
673 plugin_env_update_metrics (void *cls,
674 const struct GNUNET_HELLO_Address *address,
675 struct Session *session,
676 const struct GNUNET_ATS_Information *ats,
679 GST_ats_update_metrics (address,
686 * Black list check result from blacklist check triggered when a
687 * plugin gave us a new session in #plugin_env_session_start(). If
688 * connection to the peer is disallowed, kill the session.
690 * @param cls blc_ctx bl context
691 * @param peer the peer
692 * @param result the result
695 plugin_env_session_start_bl_check_cont (void *cls,
696 const struct GNUNET_PeerIdentity *peer,
699 struct BlacklistCheckContext *blctx = cls;
701 GNUNET_CONTAINER_DLL_remove (bc_head,
705 if (GNUNET_OK != result)
707 cancel_pending_blacklist_checks (blctx->address,
709 kill_session (blctx->address->transport_name,
712 GNUNET_HELLO_address_free (blctx->address);
718 * Plugin tells transport service about a new inbound session
721 * @param address the address
722 * @param session the new session
723 * @param ats ats information
724 * @param ats_count number of @a ats information
727 plugin_env_session_start (void *cls,
728 const struct GNUNET_HELLO_Address *address,
729 struct Session *session,
730 const struct GNUNET_ATS_Information *ats,
733 struct BlacklistCheckContext *blctx;
734 struct GST_BlacklistCheck *blc;
746 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
747 "Notification from plugin `%s' about new %s session %p from peer `%s' address `%s'\n",
748 address->transport_name,
749 GNUNET_HELLO_address_check_option (address,
750 GNUNET_HELLO_ADDRESS_INFO_INBOUND) ? "inbound" : "outbound",
752 GNUNET_i2s (&address->peer),
753 GST_plugins_a2s (address));
755 GNUNET_HELLO_address_check_option (address,
756 GNUNET_HELLO_ADDRESS_INFO_INBOUND)) ||
758 GST_ats_is_known (address, NULL) ) )
760 /* inbound is always new, but outbound MAY already be known, but
761 for example for UNIX, we have symmetric connections and thus we
762 may not know the address yet; add if necessary! */
763 GST_ats_add_address (address,
770 GST_ats_new_session (address,
772 GST_ats_update_metrics (address,
777 /* Do blacklist check if communication with this peer is allowed */
778 blctx = GNUNET_new (struct BlacklistCheckContext);
779 blctx->address = GNUNET_HELLO_address_copy (address);
780 blctx->session = session;
781 GNUNET_CONTAINER_DLL_insert (bc_head,
785 (blc = GST_blacklist_test_allowed (&address->peer,
786 address->transport_name,
787 &plugin_env_session_start_bl_check_cont,
796 * Function called by ATS to notify the callee that the
797 * assigned bandwidth or address for a given peer was changed. If the
798 * callback is called with address/bandwidth assignments of zero, the
799 * ATS disconnect function will still be called once the disconnect
803 * @param peer the peer this address is intended for
804 * @param address address to use (for peer given in address)
805 * @param session session to use (if available)
806 * @param bandwidth_out assigned outbound bandwidth for the connection in NBO,
807 * 0 to disconnect from peer
808 * @param bandwidth_in assigned inbound bandwidth for the connection in NBO,
809 * 0 to disconnect from peer
810 * @param ats ATS information
811 * @param ats_count number of @a ats elements
814 ats_request_address_change (void *cls,
815 const struct GNUNET_PeerIdentity *peer,
816 const struct GNUNET_HELLO_Address *address,
817 struct Session *session,
818 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
819 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
821 uint32_t bw_in = ntohl (bandwidth_in.value__);
822 uint32_t bw_out = ntohl (bandwidth_out.value__);
824 /* ATS tells me to disconnect from peer */
825 if ((0 == bw_in) && (0 == bw_out))
827 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
828 "ATS tells me to disconnect from peer `%s'\n",
829 GNUNET_i2s (&address->peer));
830 GST_neighbours_force_disconnect (&address->peer);
833 GNUNET_STATISTICS_update (GST_stats,
834 "# ATS suggestions received",
837 GST_neighbours_switch_to_address (address,
839 bandwidth_in, bandwidth_out);
844 * Function called when the service shuts down. Unloads our plugins
845 * and cancels pending validations.
847 * @param cls closure, unused
848 * @param tc task context (unused)
851 shutdown_task (void *cls,
852 const struct GNUNET_SCHEDULER_TaskContext *tc)
854 GST_neighbours_stop ();
855 GST_plugins_unload ();
856 GST_validation_stop ();
858 GNUNET_ATS_scheduling_done (GST_ats);
861 GST_blacklist_stop ();
863 GST_manipulation_stop ();
865 if (NULL != GST_peerinfo)
867 GNUNET_PEERINFO_disconnect (GST_peerinfo);
870 if (NULL != GST_stats)
872 GNUNET_STATISTICS_destroy (GST_stats, GNUNET_NO);
875 if (NULL != GST_my_private_key)
877 GNUNET_free(GST_my_private_key);
878 GST_my_private_key = NULL;
885 * Initiate transport service.
888 * @param server the initialized server
889 * @param c configuration to use
893 struct GNUNET_SERVER_Handle *server,
894 const struct GNUNET_CONFIGURATION_Handle *c)
897 struct GNUNET_CRYPTO_EddsaPrivateKey *pk;
898 long long unsigned int max_fd_cfg;
906 GNUNET_CONFIGURATION_get_value_filename (c,
911 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
912 _("Transport service is lacking key configuration settings. Exiting.\n"));
913 GNUNET_SCHEDULER_shutdown ();
917 GNUNET_CONFIGURATION_get_value_time (c,
922 hello_expiration = GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION;
925 pk = GNUNET_CRYPTO_eddsa_key_create_from_file (keyfile);
926 GNUNET_free (keyfile);
927 GNUNET_assert (NULL != pk);
928 GST_my_private_key = pk;
930 GST_stats = GNUNET_STATISTICS_create ("transport", GST_cfg);
931 GST_peerinfo = GNUNET_PEERINFO_connect (GST_cfg);
932 GNUNET_CRYPTO_eddsa_key_get_public (GST_my_private_key,
933 &GST_my_identity.public_key);
934 GNUNET_assert(NULL != GST_my_private_key);
936 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
937 "My identity is `%4s'\n",
938 GNUNET_i2s_full (&GST_my_identity));
940 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
943 if (NULL == GST_peerinfo)
945 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
946 _("Could not access PEERINFO service. Exiting.\n"));
947 GNUNET_SCHEDULER_shutdown ();
954 struct rlimit r_file;
955 if (0 == getrlimit (RLIMIT_NOFILE, &r_file))
957 max_fd_rlimit = r_file.rlim_cur;
958 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
959 "Maximum number of open files was: %u/%u\n",
963 max_fd_rlimit = (9 * max_fd_rlimit) / 10; /* Keep 10% for rest of transport */
965 GNUNET_CONFIGURATION_get_value_number (GST_cfg,
970 if (max_fd_cfg > max_fd_rlimit)
973 max_fd = max_fd_rlimit;
974 if (max_fd < DEFAULT_MAX_FDS)
975 max_fd = DEFAULT_MAX_FDS;
977 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
978 "Limiting number of sockets to %u: validation %u, neighbors: %u\n",
979 max_fd, (max_fd / 3), (max_fd / 3) * 2);
981 friend_only = GNUNET_CONFIGURATION_get_value_yesno (GST_cfg, "topology",
983 if (GNUNET_SYSERR == friend_only)
984 friend_only = GNUNET_NO; /* According to topology defaults */
985 /* start subsystems */
986 GST_hello_start (friend_only, &process_hello_update, NULL );
987 GNUNET_assert(NULL != GST_hello_get());
988 GST_blacklist_start (GST_server, GST_cfg, &GST_my_identity);
989 GST_ats = GNUNET_ATS_scheduling_init (GST_cfg,
990 &ats_request_address_change,
993 GST_manipulation_init (GST_cfg);
994 GST_plugins_load (&GST_manipulation_recv,
995 &plugin_env_address_change_notification,
996 &plugin_env_session_start,
997 &plugin_env_session_end,
998 &plugin_env_address_to_type,
999 &plugin_env_update_metrics);
1000 GST_neighbours_start ((max_fd / 3) * 2);
1001 GST_clients_start (GST_server);
1002 GST_validation_start ((max_fd / 3));
1007 * The main function for the transport service.
1009 * @param argc number of arguments from the command line
1010 * @param argv command line arguments
1011 * @return 0 ok, 1 on error
1014 main (int argc, char * const *argv)
1018 == GNUNET_SERVICE_run (argc, argv, "transport",
1019 GNUNET_SERVICE_OPTION_NONE, &run, NULL )) ? 0 : 1;
1022 /* end of file gnunet-service-transport.c */