2 This file is part of GNUnet.
3 (C) 2010,2011 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_neighbours.c
23 * @brief neighbour management
24 * @author Christian Grothoff
27 #include "gnunet_ats_service.h"
28 #include "gnunet-service-transport_neighbours.h"
29 #include "gnunet-service-transport_plugins.h"
30 #include "gnunet-service-transport_validation.h"
31 #include "gnunet-service-transport.h"
32 #include "gnunet_peerinfo_service.h"
33 #include "gnunet_constants.h"
34 #include "transport.h"
38 * Size of the neighbour hash map.
40 #define NEIGHBOUR_TABLE_SIZE 256
43 * How often must a peer violate bandwidth quotas before we start
44 * to simply drop its messages?
46 #define QUOTA_VIOLATION_DROP_THRESHOLD 10
50 * Entry in neighbours.
52 struct NeighbourMapEntry;
56 * For each neighbour we keep a list of messages
57 * that we still want to transmit to the neighbour.
63 * This is a doubly linked list.
65 struct MessageQueue *next;
68 * This is a doubly linked list.
70 struct MessageQueue *prev;
73 * Once this message is actively being transmitted, which
74 * neighbour is it associated with?
76 struct NeighbourMapEntry *n;
79 * Function to call once we're done.
81 GST_NeighbourSendContinuation cont;
89 * The message(s) we want to transmit, GNUNET_MessageHeader(s)
90 * stuck together in memory. Allocated at the end of this struct.
92 const char *message_buf;
95 * Size of the message buf
97 size_t message_buf_size;
100 * At what time should we fail?
102 struct GNUNET_TIME_Absolute timeout;
108 * Entry in neighbours.
110 struct NeighbourMapEntry
114 * Head of list of messages we would like to send to this peer;
115 * must contain at most one message per client.
117 struct MessageQueue *messages_head;
120 * Tail of list of messages we would like to send to this peer; must
121 * contain at most one message per client.
123 struct MessageQueue *messages_tail;
126 * Context for address suggestion.
127 * NULL after we are connected.
129 struct GNUNET_ATS_SuggestionContext *asc;
132 * Performance data for the peer.
134 struct GNUNET_TRANSPORT_ATS_Information *ats;
137 * Are we currently trying to send a message? If so, which one?
139 struct MessageQueue *is_active;
142 * Active session for communicating with the peer.
144 struct Session *session;
147 * Name of the plugin we currently use.
152 * Address used for communicating with the peer, NULL for inbound connections.
157 * Number of bytes in 'addr'.
162 * Identity of this neighbour.
164 struct GNUNET_PeerIdentity id;
167 * ID of task scheduled to run when this peer is about to
168 * time out (will free resources associated with the peer).
170 GNUNET_SCHEDULER_TaskIdentifier timeout_task;
173 * ID of task scheduled to run when we should try transmitting
174 * the head of the message queue.
176 GNUNET_SCHEDULER_TaskIdentifier transmission_task;
179 * Tracker for inbound bandwidth.
181 struct GNUNET_BANDWIDTH_Tracker in_tracker;
184 * How often has the other peer (recently) violated the inbound
185 * traffic limit? Incremented by 10 per violation, decremented by 1
186 * per non-violation (for each time interval).
188 unsigned int quota_violation_count;
191 * Number of values in 'ats' array.
193 unsigned int ats_count;
196 * Are we already in the process of disconnecting this neighbour?
201 * Do we currently consider this neighbour connected? (as far as
202 * the connect/disconnect callbacks are concerned)?
210 * All known neighbours and their HELLOs.
212 static struct GNUNET_CONTAINER_MultiHashMap *neighbours;
215 * Closure for connect_notify_cb and disconnect_notify_cb
217 static void *callback_cls;
220 * Function to call when we connected to a neighbour.
222 static GNUNET_TRANSPORT_NotifyConnect connect_notify_cb;
225 * Function to call when we disconnected from a neighbour.
227 static GNUNET_TRANSPORT_NotifyDisconnect disconnect_notify_cb;
231 * Lookup a neighbour entry in the neighbours hash map.
233 * @param pid identity of the peer to look up
234 * @return the entry, NULL if there is no existing record
236 static struct NeighbourMapEntry *
237 lookup_neighbour (const struct GNUNET_PeerIdentity *pid)
239 return GNUNET_CONTAINER_multihashmap_get (neighbours, &pid->hashPubKey);
244 * Task invoked to start a transmission to another peer.
246 * @param cls the 'struct NeighbourMapEntry'
247 * @param tc scheduler context
250 transmission_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
254 * We're done with our transmission attempt, continue processing.
256 * @param cls the 'struct MessageQueue' of the message
257 * @param receiver intended receiver
258 * @param success whether it worked or not
261 transmit_send_continuation (void *cls,
262 const struct GNUNET_PeerIdentity *receiver,
265 struct MessageQueue *mq;
266 struct NeighbourMapEntry *n;
272 GNUNET_assert (n->is_active == mq);
274 GNUNET_assert (n->transmission_task == GNUNET_SCHEDULER_NO_TASK);
275 n->transmission_task = GNUNET_SCHEDULER_add_now (&transmission_task, n);
277 if (NULL != mq->cont)
278 mq->cont (mq->cont_cls, success);
284 * Check the ready list for the given neighbour and if a plugin is
285 * ready for transmission (and if we have a message), do so!
287 * @param neighbour target peer for which to transmit
290 try_transmission_to_peer (struct NeighbourMapEntry *n)
292 struct MessageQueue *mq;
293 struct GNUNET_TIME_Relative timeout;
295 struct GNUNET_TRANSPORT_PluginFunctions *papi;
297 if (n->is_active != NULL)
298 return; /* transmission already pending */
299 if (n->transmission_task != GNUNET_SCHEDULER_NO_TASK)
300 return; /* currently waiting for bandwidth */
301 mq = n->messages_head;
302 while (NULL != (mq = n->messages_head))
304 timeout = GNUNET_TIME_absolute_get_remaining (mq->timeout);
305 if (timeout.rel_value > 0)
307 transmit_send_continuation (mq, &n->id, GNUNET_SYSERR); /* timeout */
310 return; /* no more messages */
312 papi = GST_plugins_find (n->plugin_name);
318 GNUNET_CONTAINER_DLL_remove (n->messages_head, n->messages_tail, mq);
321 ret = papi->send (papi->cls,
324 mq->message_buf_size,
325 0 /* priority -- remove from plugin API? */ ,
329 n->addrlen, GNUNET_YES, &transmit_send_continuation, mq);
332 /* failure, but 'send' would not call continuation in this case,
333 * so we need to do it here! */
334 transmit_send_continuation (mq, &n->id, GNUNET_SYSERR);
335 n->transmission_task = GNUNET_SCHEDULER_add_now (&transmission_task, n);
341 * Task invoked to start a transmission to another peer.
343 * @param cls the 'struct NeighbourMapEntry'
344 * @param tc scheduler context
347 transmission_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
349 struct NeighbourMapEntry *n = cls;
351 n->transmission_task = GNUNET_SCHEDULER_NO_TASK;
352 try_transmission_to_peer (n);
357 * Initialize the neighbours subsystem.
359 * @param cls closure for callbacks
360 * @param connect_cb function to call if we connect to a peer
361 * @param disconnect_cb function to call if we disconnect from a peer
364 GST_neighbours_start (void *cls,
365 GNUNET_TRANSPORT_NotifyConnect connect_cb,
366 GNUNET_TRANSPORT_NotifyDisconnect disconnect_cb)
369 connect_notify_cb = connect_cb;
370 disconnect_notify_cb = disconnect_cb;
371 neighbours = GNUNET_CONTAINER_multihashmap_create (NEIGHBOUR_TABLE_SIZE);
376 * Disconnect from the given neighbour, clean up the record.
378 * @param n neighbour to disconnect from
381 disconnect_neighbour (struct NeighbourMapEntry *n)
383 struct MessageQueue *mq;
385 if (GNUNET_YES == n->in_disconnect)
387 n->in_disconnect = GNUNET_YES;
388 while (NULL != (mq = n->messages_head))
390 GNUNET_CONTAINER_DLL_remove (n->messages_head, n->messages_tail, mq);
391 mq->cont (mq->cont_cls, GNUNET_SYSERR);
394 if (NULL != n->is_active)
396 n->is_active->n = NULL;
399 if (GNUNET_YES == n->is_connected)
401 n->is_connected = GNUNET_NO;
402 disconnect_notify_cb (callback_cls, &n->id);
404 GNUNET_assert (GNUNET_YES ==
405 GNUNET_CONTAINER_multihashmap_remove (neighbours,
406 &n->id.hashPubKey, n));
407 if (GNUNET_SCHEDULER_NO_TASK != n->timeout_task)
409 GNUNET_SCHEDULER_cancel (n->timeout_task);
410 n->timeout_task = GNUNET_SCHEDULER_NO_TASK;
412 if (GNUNET_SCHEDULER_NO_TASK != n->transmission_task)
414 GNUNET_SCHEDULER_cancel (n->timeout_task);
415 n->transmission_task = GNUNET_SCHEDULER_NO_TASK;
419 GNUNET_ATS_suggest_address_cancel (n->asc);
422 GNUNET_array_grow (n->ats, n->ats_count, 0);
423 if (NULL != n->plugin_name)
425 GNUNET_free (n->plugin_name);
426 n->plugin_name = NULL;
430 GNUNET_free (n->addr);
440 * Peer has been idle for too long. Disconnect.
442 * @param cls the 'struct NeighbourMapEntry' of the neighbour that went idle
443 * @param tc scheduler context
446 neighbour_timeout_task (void *cls,
447 const struct GNUNET_SCHEDULER_TaskContext *tc)
449 struct NeighbourMapEntry *n = cls;
451 n->timeout_task = GNUNET_SCHEDULER_NO_TASK;
452 disconnect_neighbour (n);
457 * Disconnect from the given neighbour.
460 * @param key hash of neighbour's public key (not used)
461 * @param value the 'struct NeighbourMapEntry' of the neighbour
464 disconnect_all_neighbours (void *cls, const GNUNET_HashCode * key, void *value)
466 struct NeighbourMapEntry *n = value;
469 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
470 "Disconnecting peer `%4s', %s\n",
471 GNUNET_i2s (&n->id), "SHUTDOWN_TASK");
473 disconnect_neighbour (n);
479 * Cleanup the neighbours subsystem.
482 GST_neighbours_stop ()
484 GNUNET_CONTAINER_multihashmap_iterate (neighbours,
485 &disconnect_all_neighbours, NULL);
486 GNUNET_CONTAINER_multihashmap_destroy (neighbours);
489 connect_notify_cb = NULL;
490 disconnect_notify_cb = NULL;
495 * For an existing neighbour record, set the active connection to
498 * @param peer identity of the peer to switch the address for
499 * @param plugin_name name of transport that delivered the PONG
500 * @param address address of the other peer, NULL if other peer
502 * @param address_len number of bytes in address
503 * @param session session to use (or NULL)
504 * @param ats performance data
505 * @param ats_count number of entries in ats (excluding 0-termination)
508 GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer,
509 const char *plugin_name,
512 struct Session *session,
513 const struct GNUNET_TRANSPORT_ATS_Information
514 *ats, uint32_t ats_count)
516 struct NeighbourMapEntry *n;
517 struct GNUNET_MessageHeader connect_msg;
519 n = lookup_neighbour (peer);
525 GNUNET_free_non_null (n->addr);
526 n->addr = GNUNET_malloc (address_len);
527 memcpy (n->addr, address, address_len);
528 n->addrlen = address_len;
529 n->session = session;
530 GNUNET_array_grow (n->ats, n->ats_count, ats_count);
532 ats, ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information));
533 GNUNET_free_non_null (n->plugin_name);
534 n->plugin_name = GNUNET_strdup (plugin_name);
535 GNUNET_SCHEDULER_cancel (n->timeout_task);
537 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
538 &neighbour_timeout_task, n);
539 connect_msg.size = htons (sizeof (struct GNUNET_MessageHeader));
540 connect_msg.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
541 GST_neighbours_send (peer,
543 sizeof (connect_msg),
544 GNUNET_TIME_UNIT_FOREVER_REL, NULL, NULL);
549 * Try to connect to the target peer using the given address
551 * @param cls the 'struct NeighbourMapEntry' of the target
552 * @param target identity of the target peer
553 * @param plugin_name name of the plugin
554 * @param plugin_address binary address
555 * @param plugin_address_len length of address
556 * @param bandwidth available bandwidth
557 * @param ats performance data for the address (as far as known)
558 * @param ats_count number of performance records in 'ats'
561 try_connect_using_address (void *cls,
562 const struct GNUNET_PeerIdentity *target,
563 const char *plugin_name,
564 const void *plugin_address,
565 size_t plugin_address_len,
566 struct GNUNET_BANDWIDTH_Value32NBO bandwidth,
567 const struct GNUNET_TRANSPORT_ATS_Information *ats,
570 struct NeighbourMapEntry *n = cls;
573 GST_neighbours_switch_to_address (target,
576 plugin_address_len, NULL, ats, ats_count);
577 if (GNUNET_YES == n->is_connected)
579 n->is_connected = GNUNET_YES;
580 connect_notify_cb (callback_cls, target, n->ats, n->ats_count);
585 * Try to create a connection to the given target (eventually).
587 * @param target peer to try to connect to
590 GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target)
592 struct NeighbourMapEntry *n;
594 GNUNET_assert (0 != memcmp (target,
596 sizeof (struct GNUNET_PeerIdentity)));
597 n = lookup_neighbour (target);
598 if ((NULL != n) && (GNUNET_YES == n->is_connected))
599 return; /* already connected */
602 n = GNUNET_malloc (sizeof (struct NeighbourMapEntry));
604 GNUNET_BANDWIDTH_tracker_init (&n->in_tracker,
605 GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT,
606 MAX_BANDWIDTH_CARRY_S);
608 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
609 &neighbour_timeout_task, n);
610 GNUNET_assert (GNUNET_OK ==
611 GNUNET_CONTAINER_multihashmap_put (neighbours,
612 &n->id.hashPubKey, n,
613 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
616 return; /* already trying */
617 n->asc = GNUNET_ATS_suggest_address (GST_ats,
618 target, &try_connect_using_address, n);
623 * Test if we're connected to the given peer.
625 * @param target peer to test
626 * @return GNUNET_YES if we are connected, GNUNET_NO if not
629 GST_neighbours_test_connected (const struct GNUNET_PeerIdentity *target)
631 struct NeighbourMapEntry *n;
633 n = lookup_neighbour (target);
634 if ((NULL == n) || (n->is_connected == GNUNET_YES))
635 return GNUNET_NO; /* not connected */
641 * A session was terminated. Take note.
643 * @param peer identity of the peer where the session died
644 * @param session session that is gone
647 GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
648 struct Session *session)
650 struct NeighbourMapEntry *n;
652 n = lookup_neighbour (peer);
655 if (session != n->session)
656 return; /* doesn't affect us */
658 if (GNUNET_YES != n->is_connected)
659 return; /* not connected anymore anyway, shouldn't matter */
660 /* try QUICKLY to re-establish a connection, reduce timeout! */
663 /* how can this be!? */
667 GNUNET_SCHEDULER_cancel (n->timeout_task);
669 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
670 &neighbour_timeout_task, n);
672 GNUNET_ATS_suggest_address (GST_ats, peer, &try_connect_using_address, n);
677 * Transmit a message to the given target using the active connection.
679 * @param target destination
680 * @param msg message to send
681 * @param msg_size number of bytes in msg
682 * @param timeout when to fail with timeout
683 * @param cont function to call when done
684 * @param cont_cls closure for 'cont'
687 GST_neighbours_send (const struct GNUNET_PeerIdentity *target,
690 struct GNUNET_TIME_Relative timeout,
691 GST_NeighbourSendContinuation cont, void *cont_cls)
693 struct NeighbourMapEntry *n;
694 struct MessageQueue *mq;
696 n = lookup_neighbour (target);
697 if ((n == NULL) || (GNUNET_YES != n->is_connected))
699 GNUNET_STATISTICS_update (GST_stats,
701 ("# SET QUOTA messages ignored (no such peer)"),
704 cont (cont_cls, GNUNET_SYSERR);
707 GNUNET_assert (msg_size >= sizeof (struct GNUNET_MessageHeader));
708 GNUNET_STATISTICS_update (GST_stats,
710 ("# bytes in message queue for other peers"),
711 msg_size, GNUNET_NO);
712 mq = GNUNET_malloc (sizeof (struct MessageQueue) + msg_size);
714 mq->cont_cls = cont_cls;
715 /* FIXME: this memcpy can be up to 7% of our total runtime! */
716 memcpy (&mq[1], msg, msg_size);
717 mq->message_buf = (const char *) &mq[1];
718 mq->message_buf_size = msg_size;
719 mq->timeout = GNUNET_TIME_relative_to_absolute (timeout);
720 GNUNET_CONTAINER_DLL_insert_tail (n->messages_head, n->messages_tail, mq);
721 if ((GNUNET_SCHEDULER_NO_TASK == n->transmission_task) &&
722 (NULL == n->is_active))
723 n->transmission_task = GNUNET_SCHEDULER_add_now (&transmission_task, n);
728 * We have received a message from the given sender. How long should
729 * we delay before receiving more? (Also used to keep the peer marked
732 * @param sender sender of the message
733 * @param size size of the message
734 * @param do_forward set to GNUNET_YES if the message should be forwarded to clients
735 * GNUNET_NO if the neighbour is not connected or violates the quota
736 * @return how long to wait before reading more from this sender
738 struct GNUNET_TIME_Relative
739 GST_neighbours_calculate_receive_delay (const struct GNUNET_PeerIdentity
740 *sender, ssize_t size, int *do_forward)
742 struct NeighbourMapEntry *n;
743 struct GNUNET_TIME_Relative ret;
745 n = lookup_neighbour (sender);
748 *do_forward = GNUNET_NO;
749 return GNUNET_TIME_UNIT_ZERO;
751 if (GNUNET_YES == GNUNET_BANDWIDTH_tracker_consume (&n->in_tracker, size))
753 n->quota_violation_count++;
755 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
756 "Bandwidth quota (%u b/s) violation detected (total of %u).\n",
757 n->in_tracker.available_bytes_per_s__,
758 n->quota_violation_count);
760 /* Discount 32k per violation */
761 GNUNET_BANDWIDTH_tracker_consume (&n->in_tracker, -32 * 1024);
765 if (n->quota_violation_count > 0)
767 /* try to add 32k back */
768 GNUNET_BANDWIDTH_tracker_consume (&n->in_tracker, 32 * 1024);
769 n->quota_violation_count--;
772 if (n->quota_violation_count > QUOTA_VIOLATION_DROP_THRESHOLD)
774 GNUNET_STATISTICS_update (GST_stats,
776 ("# bandwidth quota violations by other peers"),
778 *do_forward = GNUNET_NO;
779 return GNUNET_CONSTANTS_QUOTA_VIOLATION_TIMEOUT;
781 *do_forward = GNUNET_YES;
782 ret = GNUNET_BANDWIDTH_tracker_get_delay (&n->in_tracker, 0);
783 if (ret.rel_value > 0)
786 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
787 "Throttling read (%llu bytes excess at %u b/s), waiting %llu ms before reading more.\n",
788 (unsigned long long) n->
789 in_tracker.consumption_since_last_update__,
790 (unsigned int) n->in_tracker.available_bytes_per_s__,
791 (unsigned long long) ret.rel_value);
793 GNUNET_STATISTICS_update (GST_stats,
794 gettext_noop ("# ms throttling suggested"),
795 (int64_t) ret.rel_value, GNUNET_NO);
802 * Keep the connection to the given neighbour alive longer,
803 * we received a KEEPALIVE (or equivalent).
805 * @param neighbour neighbour to keep alive
808 GST_neighbours_keepalive (const struct GNUNET_PeerIdentity *neighbour)
810 struct NeighbourMapEntry *n;
812 n = lookup_neighbour (neighbour);
815 GNUNET_STATISTICS_update (GST_stats,
817 ("# KEEPALIVE messages discarded (not connected)"),
821 GNUNET_SCHEDULER_cancel (n->timeout_task);
823 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
824 &neighbour_timeout_task, n);
829 * Change the incoming quota for the given peer.
831 * @param neighbour identity of peer to change qutoa for
832 * @param quota new quota
835 GST_neighbours_set_incoming_quota (const struct GNUNET_PeerIdentity *neighbour,
836 struct GNUNET_BANDWIDTH_Value32NBO quota)
838 struct NeighbourMapEntry *n;
840 n = lookup_neighbour (neighbour);
843 GNUNET_STATISTICS_update (GST_stats,
845 ("# SET QUOTA messages ignored (no such peer)"),
849 GNUNET_BANDWIDTH_tracker_update_quota (&n->in_tracker, quota);
850 if (0 != ntohl (quota.value__))
853 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
854 "Disconnecting peer `%4s' due to `%s'\n",
855 GNUNET_i2s (&n->id), "SET_QUOTA");
857 GNUNET_STATISTICS_update (GST_stats,
858 gettext_noop ("# disconnects due to quota of 0"),
860 disconnect_neighbour (n);
865 * Closure for the neighbours_iterate function.
867 struct IteratorContext
870 * Function to call on each connected neighbour.
872 GST_NeighbourIterator cb;
882 * Call the callback from the closure for each connected neighbour.
884 * @param cls the 'struct IteratorContext'
885 * @param key the hash of the public key of the neighbour
886 * @param value the 'struct NeighbourMapEntry'
887 * @return GNUNET_OK (continue to iterate)
890 neighbours_iterate (void *cls, const GNUNET_HashCode * key, void *value)
892 struct IteratorContext *ic = cls;
893 struct NeighbourMapEntry *n = value;
895 if (GNUNET_YES != n->is_connected)
897 GNUNET_assert (n->ats_count > 0);
898 ic->cb (ic->cb_cls, &n->id, n->ats, n->ats_count - 1);
904 * Iterate over all connected neighbours.
906 * @param cb function to call
907 * @param cb_cls closure for cb
910 GST_neighbours_iterate (GST_NeighbourIterator cb, void *cb_cls)
912 struct IteratorContext ic;
916 GNUNET_CONTAINER_multihashmap_iterate (neighbours, &neighbours_iterate, &ic);
921 * If we have an active connection to the given target, it must be shutdown.
923 * @param target peer to disconnect from
926 GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target)
928 struct NeighbourMapEntry *n;
929 struct GNUNET_TRANSPORT_PluginFunctions *papi;
930 struct GNUNET_MessageHeader disconnect_msg;
932 n = lookup_neighbour (target);
934 return; /* not active */
935 if (GNUNET_YES == n->is_connected)
937 /* we're actually connected, send DISCONNECT message */
938 disconnect_msg.size = htons (sizeof (struct GNUNET_MessageHeader));
939 disconnect_msg.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
940 papi = GST_plugins_find (n->plugin_name);
942 papi->send (papi->cls,
944 (const void *) &disconnect_msg,
945 sizeof (struct GNUNET_MessageHeader),
946 UINT32_MAX /* priority */ ,
947 GNUNET_TIME_UNIT_FOREVER_REL,
948 n->session, n->addr, n->addrlen, GNUNET_YES, NULL, NULL);
950 disconnect_neighbour (n);
954 /* end of file gnunet-service-transport_neighbours.c */