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_clients.c
23 * @brief plugin management API
24 * @author Christian Grothoff
27 #include "gnunet-service-transport_blacklist.h"
28 #include "gnunet-service-transport_clients.h"
29 #include "gnunet-service-transport_hello.h"
30 #include "gnunet-service-transport_neighbours.h"
31 #include "gnunet-service-transport_plugins.h"
32 #include "gnunet-service-transport_validation.h"
33 #include "gnunet-service-transport.h"
34 #include "transport.h"
37 * How many messages can we have pending for a given client process
38 * before we start to drop incoming messages? We typically should
39 * have only one client and so this would be the primary buffer for
40 * messages, so the number should be chosen rather generously.
42 * The expectation here is that most of the time the queue is large
43 * enough so that a drop is virtually never required. Note that
44 * this value must be about as large as 'TOTAL_MSGS' in the
45 * 'test_transport_api_reliability.c', otherwise that testcase may
48 #define MAX_PENDING (128 * 1024)
52 * Linked list of messages to be transmitted to the client. Each
53 * entry is followed by the actual message.
55 struct ClientMessageQueueEntry
58 * This is a doubly-linked list.
60 struct ClientMessageQueueEntry *next;
63 * This is a doubly-linked list.
65 struct ClientMessageQueueEntry *prev;
70 * Client connected to the transport service.
72 struct TransportClient
76 * This is a doubly-linked list.
78 struct TransportClient *next;
81 * This is a doubly-linked list.
83 struct TransportClient *prev;
86 * Handle to the client.
88 struct GNUNET_SERVER_Client *client;
91 * Linked list of messages yet to be transmitted to
94 struct ClientMessageQueueEntry *message_queue_head;
97 * Tail of linked list of messages yet to be transmitted to the
100 struct ClientMessageQueueEntry *message_queue_tail;
103 * Current transmit request handle.
105 struct GNUNET_CONNECTION_TransmitHandle *th;
108 * Length of the list of messages pending for this client.
110 unsigned int message_count;
113 * GNUNET_SERVER_Client's unique id
115 uint64_t server_client_id;
120 * Head of linked list of all clients to this service.
122 static struct TransportClient *clients_head;
125 * Tail of linked list of all clients to this service.
127 static struct TransportClient *clients_tail;
130 * Find the internal handle associated with the given client handle
132 * @param client server's client handle to look up
133 * @return internal client handle
135 static struct TransportClient *
136 lookup_client (struct GNUNET_SERVER_Client *client)
138 struct TransportClient *tc;
143 if (tc->server_client_id == GNUNET_SERVER_client_get_id (client))
152 * Create the internal handle for the given server client handle
154 * @param client server's client handle to create our internal handle for
155 * @return fresh internal client handle
157 static struct TransportClient *
158 setup_client (struct GNUNET_SERVER_Client *client)
160 struct TransportClient *tc;
162 GNUNET_assert (lookup_client (client) == NULL);
164 tc = GNUNET_malloc (sizeof (struct TransportClient));
166 tc->server_client_id = GNUNET_SERVER_client_get_id (client);
168 GNUNET_CONTAINER_DLL_insert (clients_head, clients_tail, tc);
174 * Function called to notify a client about the socket being ready to
175 * queue more data. "buf" will be NULL and "size" zero if the socket
176 * was closed for writing in the meantime.
179 * @param size number of bytes available in buf
180 * @param buf where the callee should write the message
181 * @return number of bytes written to buf
184 transmit_to_client_callback (void *cls, size_t size, void *buf)
186 struct TransportClient *tc = cls;
187 struct ClientMessageQueueEntry *q;
188 const struct GNUNET_MessageHeader *msg;
197 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
198 "Transmission to client failed, closing connection.\n");
204 while (NULL != (q = tc->message_queue_head))
206 msg = (const struct GNUNET_MessageHeader *) &q[1];
207 msize = ntohs (msg->size);
208 if (msize + tsize > size)
211 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
212 "Transmitting message of type %u to client %X.\n",
213 ntohs (msg->type), tc);
215 GNUNET_CONTAINER_DLL_remove (tc->message_queue_head, tc->message_queue_tail,
218 memcpy (&cbuf[tsize], msg, msize);
224 GNUNET_assert (msize >= sizeof (struct GNUNET_MessageHeader));
226 GNUNET_SERVER_notify_transmit_ready (tc->client, msize,
227 GNUNET_TIME_UNIT_FOREVER_REL,
228 &transmit_to_client_callback, tc);
229 GNUNET_assert (tc->th != NULL);
236 * Queue the given message for transmission to the given client
238 * @param client target of the message
239 * @param msg message to transmit
240 * @param may_drop GNUNET_YES if the message can be dropped
243 unicast (struct TransportClient *tc, const struct GNUNET_MessageHeader *msg,
246 struct ClientMessageQueueEntry *q;
249 if ((tc->message_count >= MAX_PENDING) && (GNUNET_YES == may_drop))
251 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
253 ("Dropping message of type %u and size %u, have %u/%u messages pending\n"),
254 ntohs (msg->type), ntohs (msg->size), tc->message_count,
256 GNUNET_STATISTICS_update (GST_stats,
258 ("# messages dropped due to slow client"), 1,
262 msize = ntohs (msg->size);
263 GNUNET_assert (msize >= sizeof (struct GNUNET_MessageHeader));
264 q = GNUNET_malloc (sizeof (struct ClientMessageQueueEntry) + msize);
265 memcpy (&q[1], msg, msize);
266 GNUNET_CONTAINER_DLL_insert_tail (tc->message_queue_head,
267 tc->message_queue_tail, q);
272 GNUNET_SERVER_notify_transmit_ready (tc->client, msize,
273 GNUNET_TIME_UNIT_FOREVER_REL,
274 &transmit_to_client_callback, tc);
275 GNUNET_assert (tc->th != NULL);
280 * Called whenever a client is disconnected. Frees our
281 * resources associated with that client.
284 * @param client identification of the client
287 client_disconnect_notification (void *cls, struct GNUNET_SERVER_Client *client)
289 struct TransportClient *tc;
290 struct ClientMessageQueueEntry *mqe;
294 tc = lookup_client (client);
298 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
299 "Client %X disconnected, cleaning up.\n", tc);
301 while (NULL != (mqe = tc->message_queue_head))
303 GNUNET_CONTAINER_DLL_remove (tc->message_queue_head, tc->message_queue_tail,
308 GNUNET_CONTAINER_DLL_remove (clients_head, clients_tail, tc);
311 GNUNET_CONNECTION_notify_transmit_ready_cancel (tc->th);
314 GNUNET_break (0 == tc->message_count);
320 * Function called for each of our connected neighbours. Notify the
321 * client about the existing neighbour.
323 * @param cls the 'struct TransportClient' to notify
324 * @param peer identity of the neighbour
325 * @param ats performance data
326 * @param ats_count number of entries in ats (excluding 0-termination)
329 notify_client_about_neighbour (void *cls,
330 const struct GNUNET_PeerIdentity *peer,
331 const struct GNUNET_TRANSPORT_ATS_Information
332 *ats, uint32_t ats_count)
334 struct TransportClient *tc = cls;
335 struct ConnectInfoMessage *cim;
339 sizeof (struct ConnectInfoMessage) +
340 ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information);
341 GNUNET_assert (size < GNUNET_SERVER_MAX_MESSAGE_SIZE);
342 cim = GNUNET_malloc (size);
343 cim->header.size = htons (size);
344 cim->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
345 cim->ats_count = htonl (ats_count);
347 memcpy (&cim->ats, ats,
348 ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information));
349 unicast (tc, &cim->header, GNUNET_NO);
355 * Initialize a normal client. We got a start message from this
356 * client, add him to the list of clients for broadcasting of inbound
360 * @param client the client
361 * @param message the start message that was sent
364 clients_handle_start (void *cls, struct GNUNET_SERVER_Client *client,
365 const struct GNUNET_MessageHeader *message)
367 const struct StartMessage *start;
368 struct TransportClient *tc;
370 tc = lookup_client (client);
374 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
375 "Client %X sent START\n", tc);
377 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
378 "Client %X sent START\n", tc);
382 /* got 'start' twice from the same client, not allowed */
384 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
385 "TransportClient %X ServerClient %X id %llu sent multiple START messages\n",
388 tc->server_client_id);
391 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
394 start = (const struct StartMessage *) message;
395 if ((GNUNET_NO != ntohl (start->do_check)) &&
397 memcmp (&start->self, &GST_my_identity,
398 sizeof (struct GNUNET_PeerIdentity))))
400 /* client thinks this is a different peer, reject */
401 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
403 ("Rejecting control connection from peer `%s', which is not me!\n"),
404 GNUNET_i2s (&start->self));
405 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
408 tc = setup_client (client);
410 unicast (tc, GST_hello_get (), GNUNET_NO);
411 GST_neighbours_iterate (¬ify_client_about_neighbour, tc);
412 GNUNET_SERVER_receive_done (client, GNUNET_OK);
417 * Client sent us a HELLO. Process the request.
420 * @param client the client
421 * @param message the HELLO message
424 clients_handle_hello (void *cls, struct GNUNET_SERVER_Client *client,
425 const struct GNUNET_MessageHeader *message)
427 GST_validation_handle_hello (message);
428 GNUNET_SERVER_receive_done (client, GNUNET_OK);
433 * Closure for 'handle_send_transmit_continuation'
435 struct SendTransmitContinuationContext
438 * Client that made the request.
440 struct GNUNET_SERVER_Client *client;
443 * Peer that was the target.
445 struct GNUNET_PeerIdentity target;
450 * Function called after the transmission is done. Notify the client that it is
451 * OK to send the next message.
454 * @param success GNUNET_OK on success, GNUNET_NO on failure, GNUNET_SYSERR if we're not connected
457 handle_send_transmit_continuation (void *cls, int success)
459 struct SendTransmitContinuationContext *stcc = cls;
460 struct SendOkMessage send_ok_msg;
462 send_ok_msg.header.size = htons (sizeof (send_ok_msg));
463 send_ok_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK);
464 send_ok_msg.success = htonl (success);
465 send_ok_msg.latency =
466 GNUNET_TIME_relative_hton (GNUNET_TIME_UNIT_FOREVER_REL);
467 send_ok_msg.peer = stcc->target;
468 GST_clients_unicast (stcc->client, &send_ok_msg.header, GNUNET_NO);
469 GNUNET_SERVER_client_drop (stcc->client);
475 * Client asked for transmission to a peer. Process the request.
478 * @param client the client
479 * @param message the send message that was sent
482 clients_handle_send (void *cls, struct GNUNET_SERVER_Client *client,
483 const struct GNUNET_MessageHeader *message)
485 const struct OutboundMessage *obm;
486 const struct GNUNET_MessageHeader *obmm;
487 struct SendTransmitContinuationContext *stcc;
491 size = ntohs (message->size);
493 sizeof (struct OutboundMessage) + sizeof (struct GNUNET_MessageHeader))
496 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
499 obm = (const struct OutboundMessage *) message;
500 obmm = (const struct GNUNET_MessageHeader *) &obm[1];
501 msize = size - sizeof (struct OutboundMessage);
502 if (msize < sizeof (struct GNUNET_MessageHeader))
505 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
508 GNUNET_STATISTICS_update (GST_stats,
510 ("# bytes payload received for other peers"), msize,
513 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
514 "Received `%s' request from client with target `%4s' and first message of type %u and total size %u\n",
515 "SEND", GNUNET_i2s (&obm->peer), ntohs (obmm->type), msize);
517 if (GNUNET_NO == GST_neighbours_test_connected (&obm->peer))
519 /* not connected, not allowed to send; can happen due to asynchronous operations */
521 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
522 "Could not send message to peer `%s': not connected\n",
523 GNUNET_i2s (&obm->peer));
525 GNUNET_STATISTICS_update (GST_stats,
527 ("# bytes payload dropped (other peer was not connected)"),
529 GNUNET_SERVER_receive_done (client, GNUNET_OK);
532 GNUNET_SERVER_receive_done (client, GNUNET_OK);
533 stcc = GNUNET_malloc (sizeof (struct SendTransmitContinuationContext));
534 stcc->target = obm->peer;
535 stcc->client = client;
536 GNUNET_SERVER_client_keep (client);
537 GST_neighbours_send (&obm->peer, obmm, msize,
538 GNUNET_TIME_relative_ntoh (obm->timeout),
539 &handle_send_transmit_continuation, stcc);
544 * Try to initiate a connection to the given peer if the blacklist
547 * @param cls closure (unused, NULL)
548 * @param peer identity of peer that was tested
549 * @param result GNUNET_OK if the connection is allowed,
553 try_connect_if_allowed (void *cls, const struct GNUNET_PeerIdentity *peer,
556 if (GNUNET_OK != result)
557 return; /* not allowed */
558 GST_neighbours_try_connect (peer);
563 * Handle request connect message
565 * @param cls closure (always NULL)
566 * @param client identification of the client
567 * @param message the actual message
570 clients_handle_request_connect (void *cls, struct GNUNET_SERVER_Client *client,
571 const struct GNUNET_MessageHeader *message)
573 const struct TransportRequestConnectMessage *trcm =
574 (const struct TransportRequestConnectMessage *) message;
576 GNUNET_STATISTICS_update (GST_stats,
578 ("# REQUEST CONNECT messages received"), 1,
581 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
582 "Received a request connect message for peer `%s'\n",
583 GNUNET_i2s (&trcm->peer));
585 (void) GST_blacklist_test_allowed (&trcm->peer, NULL, &try_connect_if_allowed,
587 GNUNET_SERVER_receive_done (client, GNUNET_OK);
592 * Client asked for a quota change for a particular peer. Process the request.
595 * @param client the client
596 * @param message the quota changing message
599 clients_handle_set_quota (void *cls, struct GNUNET_SERVER_Client *client,
600 const struct GNUNET_MessageHeader *message)
602 const struct QuotaSetMessage *qsm;
604 qsm = (const struct QuotaSetMessage *) message;
605 GNUNET_STATISTICS_update (GST_stats,
606 gettext_noop ("# SET QUOTA messages received"), 1,
609 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
610 "Received `%s' request (new quota %u) from client for peer `%4s'\n",
611 "SET_QUOTA", (unsigned int) ntohl (qsm->quota.value__),
612 GNUNET_i2s (&qsm->peer));
614 GST_neighbours_set_incoming_quota (&qsm->peer, qsm->quota);
615 GNUNET_SERVER_receive_done (client, GNUNET_OK);
620 * Take the given address and append it to the set of results sent back to
623 * @param cls the transmission context used ('struct GNUNET_SERVER_TransmitContext*')
624 * @param address the resolved name, NULL to indicate the last response
627 transmit_address_to_client (void *cls, const char *address)
629 struct GNUNET_SERVER_TransmitContext *tc = cls;
633 GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0,
634 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY);
635 GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL);
638 GNUNET_SERVER_transmit_context_append_data (tc, address, strlen (address) + 1,
639 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY);
644 * Client asked to resolve an address. Process the request.
647 * @param client the client
648 * @param message the resolution request
651 clients_handle_address_lookup (void *cls, struct GNUNET_SERVER_Client *client,
652 const struct GNUNET_MessageHeader *message)
654 const struct AddressLookupMessage *alum;
655 struct GNUNET_TRANSPORT_PluginFunctions *papi;
656 const char *plugin_name;
658 uint32_t address_len;
660 struct GNUNET_SERVER_TransmitContext *tc;
661 struct GNUNET_TIME_Relative rtimeout;
664 size = ntohs (message->size);
665 if (size < sizeof (struct AddressLookupMessage))
668 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
671 alum = (const struct AddressLookupMessage *) message;
672 address_len = ntohl (alum->addrlen);
673 if (size <= sizeof (struct AddressLookupMessage) + address_len)
676 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
679 address = (const char *) &alum[1];
680 plugin_name = (const char *) &address[address_len];
681 if (plugin_name[size - sizeof (struct AddressLookupMessage) - address_len - 1]
685 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
688 rtimeout = GNUNET_TIME_relative_ntoh (alum->timeout);
689 numeric = ntohl (alum->numeric_only);
690 tc = GNUNET_SERVER_transmit_context_create (client);
691 papi = GST_plugins_find (plugin_name);
694 GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0,
695 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY);
696 GNUNET_SERVER_transmit_context_run (tc, rtimeout);
699 GNUNET_SERVER_disable_receive_done_warning (client);
700 papi->address_pretty_printer (papi->cls, plugin_name, address, address_len,
701 numeric, rtimeout, &transmit_address_to_client,
707 * Send an address to the client.
709 * @param cls our 'struct GNUNET_SERVER_TransmitContext' (for sending)
710 * @param public_key public key for the peer, never NULL
711 * @param target peer this change is about, never NULL
712 * @param valid_until until what time do we consider the address valid?
713 * @param validation_block is FOREVER if the address is for an unsupported plugin (from PEERINFO)
714 * is ZERO if the address is considered valid (no validation needed)
715 * is a time in the future if we're currently denying re-validation
716 * @param plugin_name name of the plugin
717 * @param plugin_address binary address
718 * @param plugin_address_len length of address
721 send_address_to_client (void *cls,
722 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
723 *public_key, const struct GNUNET_PeerIdentity *target,
724 struct GNUNET_TIME_Absolute valid_until,
725 struct GNUNET_TIME_Absolute validation_block,
726 const char *plugin_name, const void *plugin_address,
727 size_t plugin_address_len)
729 struct GNUNET_SERVER_TransmitContext *tc = cls;
732 /* FIXME: move to a binary format!!! */
733 GNUNET_asprintf (&addr_buf, "%s --- %s, %s",
734 GST_plugins_a2s (plugin_name, plugin_address,
737 GST_neighbours_test_connected (target)) ? "CONNECTED" :
739 (GNUNET_TIME_absolute_get_remaining (valid_until).rel_value >
740 0) ? "VALIDATED" : "UNVALIDATED");
741 transmit_address_to_client (tc, addr_buf);
742 GNUNET_free (addr_buf);
747 * Client asked to obtain information about a peer's addresses.
748 * Process the request.
749 * FIXME: use better name!
752 * @param client the client
753 * @param message the peer address information request
756 clients_handle_peer_address_lookup (void *cls,
757 struct GNUNET_SERVER_Client *client,
758 const struct GNUNET_MessageHeader *message)
760 const struct PeerAddressLookupMessage *peer_address_lookup;
761 struct GNUNET_SERVER_TransmitContext *tc;
763 peer_address_lookup = (const struct PeerAddressLookupMessage *) message;
764 GNUNET_break (ntohl (peer_address_lookup->reserved) == 0);
765 tc = GNUNET_SERVER_transmit_context_create (client);
766 GST_validation_get_addresses (&peer_address_lookup->peer,
767 &send_address_to_client, tc);
768 GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0,
769 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY);
770 GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL);
775 * Output the active address of connected neighbours to the given client.
777 * @param cls the 'struct GNUNET_SERVER_TransmitContext' for transmission to the client
778 * @param neighbour identity of the neighbour
779 * @param ats performance data
780 * @param ats_count number of entries in ats (excluding 0-termination)
783 output_addresses (void *cls, const struct GNUNET_PeerIdentity *neighbour,
784 const struct GNUNET_TRANSPORT_ATS_Information *ats,
787 struct GNUNET_SERVER_TransmitContext *tc = cls;
790 /* FIXME: move to a binary format!!! */
791 GNUNET_asprintf (&addr_buf, "%s: %s", GNUNET_i2s (neighbour),
792 GST_plugins_a2s ("FIXME", NULL, 0));
793 transmit_address_to_client (tc, addr_buf);
794 GNUNET_free (addr_buf);
799 * Client asked to obtain information about all actively used addresses.
800 * Process the request. FIXME: use better name!
803 * @param client the client
804 * @param message the peer address information request
807 clients_handle_address_iterate (void *cls, struct GNUNET_SERVER_Client *client,
808 const struct GNUNET_MessageHeader *message)
810 struct GNUNET_SERVER_TransmitContext *tc;
812 GNUNET_SERVER_disable_receive_done_warning (client);
813 tc = GNUNET_SERVER_transmit_context_create (client);
814 GST_neighbours_iterate (&output_addresses, tc);
815 GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0,
816 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY);
817 GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL);
822 * Start handling requests from clients.
824 * @param server server used to accept clients from.
827 GST_clients_start (struct GNUNET_SERVER_Handle *server)
829 static const struct GNUNET_SERVER_MessageHandler handlers[] = {
830 {&clients_handle_start, NULL,
831 GNUNET_MESSAGE_TYPE_TRANSPORT_START, sizeof (struct StartMessage)},
832 {&clients_handle_hello, NULL,
833 GNUNET_MESSAGE_TYPE_HELLO, 0},
834 {&clients_handle_send, NULL,
835 GNUNET_MESSAGE_TYPE_TRANSPORT_SEND, 0},
836 {&clients_handle_request_connect, NULL,
837 GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT,
838 sizeof (struct TransportRequestConnectMessage)},
839 {&clients_handle_set_quota, NULL,
840 GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA, sizeof (struct QuotaSetMessage)},
841 {&clients_handle_address_lookup, NULL,
842 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP, 0},
843 {&clients_handle_peer_address_lookup, NULL,
844 GNUNET_MESSAGE_TYPE_TRANSPORT_PEER_ADDRESS_LOOKUP,
845 sizeof (struct PeerAddressLookupMessage)},
846 {&clients_handle_address_iterate, NULL,
847 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE,
848 sizeof (struct GNUNET_MessageHeader)},
849 {&GST_blacklist_handle_init, NULL,
850 GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_INIT,
851 sizeof (struct GNUNET_MessageHeader)},
852 {&GST_blacklist_handle_reply, NULL,
853 GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_REPLY,
854 sizeof (struct BlacklistMessage)},
857 GNUNET_SERVER_add_handlers (server, handlers);
858 GNUNET_SERVER_disconnect_notify (server, &client_disconnect_notification,
864 * Stop processing clients.
874 * Broadcast the given message to all of our clients.
876 * @param msg message to broadcast
877 * @param may_drop GNUNET_YES if the message can be dropped
880 GST_clients_broadcast (const struct GNUNET_MessageHeader *msg, int may_drop)
882 struct TransportClient *tc;
884 for (tc = clients_head; tc != NULL; tc = tc->next)
885 unicast (tc, msg, may_drop);
890 * Send the given message to a particular client
892 * @param client target of the message
893 * @param msg message to transmit
894 * @param may_drop GNUNET_YES if the message can be dropped
897 GST_clients_unicast (struct GNUNET_SERVER_Client *client,
898 const struct GNUNET_MessageHeader *msg, int may_drop)
900 struct TransportClient *tc;
902 tc = lookup_client (client);
904 tc = setup_client (client);
905 unicast (tc, msg, may_drop);
909 /* end of file gnunet-service-transport_clients.c */