2 This file is part of GNUnet.
3 (C) 2009, 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 core/gnunet-service-core_clients.c
23 * @brief code for managing interactions with clients of core service
24 * @author Christian Grothoff
27 #include "gnunet_util_lib.h"
28 #include "gnunet_statistics_service.h"
29 #include "gnunet_transport_service.h"
30 #include "gnunet-service-core.h"
31 #include "gnunet-service-core_clients.h"
32 #include "gnunet-service-core_sessions.h"
33 #include "gnunet-service-core_typemap.h"
36 #define DEBUG_CONNECTS GNUNET_YES
39 * How many messages do we queue up at most for optional
40 * notifications to a client? (this can cause notifications
41 * about outgoing messages to be dropped).
43 #define MAX_NOTIFY_QUEUE 1024
47 * Data structure for each client connected to the core service.
52 * Clients are kept in a linked list.
54 struct GSC_Client *next;
57 * Clients are kept in a linked list.
59 struct GSC_Client *prev;
62 * Handle for the client with the server API.
64 struct GNUNET_SERVER_Client *client_handle;
67 * Array of the types of messages this peer cares
68 * about (with "tcnt" entries). Allocated as part
69 * of this client struct, do not free!
71 const uint16_t *types;
74 * Map of peer identities to active transmission requests of this
75 * client to the peer (of type 'struct GSC_ClientActiveRequest').
77 struct GNUNET_CONTAINER_MultiHashMap *requests;
81 * Map containing all peers that this client knows we're connected to.
83 struct GNUNET_CONTAINER_MultiHashMap *connectmap;
87 * Options for messages this client cares about,
88 * see GNUNET_CORE_OPTION_ values.
93 * Number of types of incoming messages this client
94 * specifically cares about. Size of the "types" array.
102 * Head of linked list of our clients.
104 static struct GSC_Client *client_head;
107 * Tail of linked list of our clients.
109 static struct GSC_Client *client_tail;
112 * Context for notifications we need to send to our clients.
114 static struct GNUNET_SERVER_NotificationContext *notifier;
117 * Tokenizer for messages received from clients.
119 static struct GNUNET_SERVER_MessageStreamTokenizer *client_mst;
123 * Lookup our client struct given the server's client handle.
125 * @param client server client handle to look up
126 * @return our client handle for the client
128 static struct GSC_Client *
129 find_client (struct GNUNET_SERVER_Client *client)
131 struct GSC_Client *c;
134 while ((c != NULL) && (c->client_handle != client))
141 * Send a message to one of our clients.
143 * @param client target for the message
144 * @param msg message to transmit
145 * @param can_drop could this message be dropped if the
146 * client's queue is getting too large?
149 send_to_client (struct GSC_Client *client,
150 const struct GNUNET_MessageHeader *msg,
154 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
155 "Preparing to send %u bytes of message of type %u to client.\n",
156 (unsigned int) ntohs (msg->size),
157 (unsigned int) ntohs (msg->type));
159 GNUNET_SERVER_notification_context_unicast (notifier, client->client_handle,
165 * Send a message to one of our clients.
167 * @param client target for the message
168 * @param msg message to transmit
169 * @param can_drop could this message be dropped if the
170 * client's queue is getting too large?
173 GSC_CLIENTS_send_to_client (struct GNUNET_SERVER_Client *client,
174 const struct GNUNET_MessageHeader *msg,
177 struct GSC_Client *c;
179 c = find_client (client);
185 send_to_client (c, msg, can_drop);
190 * Test if the client is interested in messages of the given type.
192 * @param type message type
193 * @param c client to test
194 * @return GNUNET_YES if 'c' is interested, GNUNET_NO if not.
197 type_match (uint16_t type,
198 struct GSC_Client *c)
203 return GNUNET_YES; /* peer without handlers matches ALL */
204 for (i=0;i<c->tcnt;i++)
205 if (type == c->types[i])
212 * Send a message to all of our current clients that have the right
215 * @param msg message to multicast
216 * @param can_drop can this message be discarded if the queue is too long
217 * @param options mask to use
218 * @param type type of the embedded message, 0 for none
221 send_to_all_clients (const struct GNUNET_PeerIdentity *sender,
222 const struct GNUNET_MessageHeader *msg,
227 struct GSC_Client *c;
229 for (c = client_head; c != NULL; c = c->next)
231 if ( (0 == (options & GNUNET_CORE_OPTION_SEND_FULL_INBOUND)) &&
232 (GNUNET_YES == type_match (type, c)) )
233 continue; /* not the full message, but we'd like the full one! */
234 if ( (0 == (c->options & options)) &&
235 (GNUNET_YES != type_match (type, c)) )
236 continue; /* neither options nor type match permit the message */
238 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
239 "Sending message to client interested in messages of type %u.\n",
240 (unsigned int) type);
243 GNUNET_assert (GNUNET_YES ==
244 GNUNET_CONTAINER_multihashmap_contains (c->connectmap,
245 &sender->hashPubKey));
247 send_to_client (c, msg, can_drop);
253 * Handle CORE_INIT request.
256 * @param client new client that sent INIT
257 * @param message the 'struct InitMessage' (presumably)
260 handle_client_init (void *cls, struct GNUNET_SERVER_Client *client,
261 const struct GNUNET_MessageHeader *message)
263 const struct InitMessage *im;
264 struct InitReplyMessage irm;
265 struct GSC_Client *c;
267 const uint16_t *types;
271 /* check that we don't have an entry already */
272 c = find_client (client);
276 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
279 msize = ntohs (message->size);
280 if (msize < sizeof (struct InitMessage))
283 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
286 GNUNET_SERVER_notification_context_add (notifier, client);
287 im = (const struct InitMessage *) message;
288 types = (const uint16_t *) &im[1];
289 msize -= sizeof (struct InitMessage);
290 c = GNUNET_malloc (sizeof (struct GSC_Client) + msize);
291 c->client_handle = client;
292 c->tcnt = msize / sizeof (uint16_t);
293 c->options = ntohl (im->options);
294 c->types = (const uint16_t *) &c[1];
296 c->connectmap = GNUNET_CONTAINER_multihashmap_create (16);
297 GNUNET_assert (GNUNET_YES ==
298 GNUNET_CONTAINER_multihashmap_put (c->connectmap,
299 &GSC_my_identity.hashPubKey,
301 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
304 wtypes = (uint16_t *) & c[1];
305 for (i = 0; i < c->tcnt; i++)
306 wtypes[i] = ntohs (types[i]);
307 GSC_TYPEMAP_add (wtypes, c->tcnt);
308 GNUNET_CONTAINER_DLL_insert (client_head,
312 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
313 "Client connecting to core service is interested in %u message types\n",
314 (unsigned int) c->tcnt);
316 /* send init reply message */
317 irm.header.size = htons (sizeof (struct InitReplyMessage));
318 irm.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_INIT_REPLY);
319 irm.reserved = htonl (0);
320 irm.my_identity = GSC_my_identity;
321 send_to_client (c, &irm.header, GNUNET_NO);
322 GSC_SESSIONS_notify_client_about_sessions (c);
323 GNUNET_SERVER_receive_done (client, GNUNET_OK);
328 * Handle CORE_SEND_REQUEST message.
331 * @param client new client that sent CORE_SEND_REQUEST
332 * @param message the 'struct SendMessageRequest' (presumably)
335 handle_client_send_request (void *cls, struct GNUNET_SERVER_Client *client,
336 const struct GNUNET_MessageHeader *message)
338 const struct SendMessageRequest *req;
339 struct GSC_Client *c;
340 struct GSC_ClientActiveRequest *car;
342 req = (const struct SendMessageRequest *) message;
343 c = find_client (client);
346 /* client did not send INIT first! */
348 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
351 if (c->requests == NULL)
352 c->requests = GNUNET_CONTAINER_multihashmap_create (16);
354 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
355 "Client asked for transmission to `%s'\n",
356 GNUNET_i2s (&req->peer));
358 car = GNUNET_CONTAINER_multihashmap_get (c->requests, &req->peer.hashPubKey);
361 /* create new entry */
362 car = GNUNET_malloc (sizeof (struct GSC_ClientActiveRequest));
363 GNUNET_assert (GNUNET_OK ==
364 GNUNET_CONTAINER_multihashmap_put (c->requests,
365 &req->peer.hashPubKey,
367 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST));
368 car->client_handle = c;
372 GSC_SESSIONS_dequeue_request (car);
374 car->target = req->peer;
375 car->deadline = GNUNET_TIME_absolute_ntoh (req->deadline);
376 car->priority = ntohl (req->priority);
377 car->msize = ntohs (req->size);
378 car->smr_id = req->smr_id;
379 car->was_solicited = GNUNET_NO;
381 memcmp (&req->peer, &GSC_my_identity, sizeof (struct GNUNET_PeerIdentity)))
382 GSC_CLIENTS_solicit_request (car);
384 GSC_SESSIONS_queue_request (car);
385 GNUNET_SERVER_receive_done (client, GNUNET_OK);
390 * Closure for the 'client_tokenizer_callback'.
392 struct TokenizerContext
396 * Active request handle for the message.
398 struct GSC_ClientActiveRequest *car;
401 * Is corking allowed (set only once we have the real message).
409 * Handle CORE_SEND request.
412 * @param client the client issuing the request
413 * @param message the "struct SendMessage"
416 handle_client_send (void *cls, struct GNUNET_SERVER_Client *client,
417 const struct GNUNET_MessageHeader *message)
419 const struct SendMessage *sm;
420 struct GSC_Client *c;
421 struct TokenizerContext tc;
424 msize = ntohs (message->size);
426 sizeof (struct SendMessage) + sizeof (struct GNUNET_MessageHeader))
429 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
432 sm = (const struct SendMessage *) message;
433 msize -= sizeof (struct SendMessage);
434 GNUNET_break (0 == ntohl (sm->reserved));
435 c = find_client (client);
438 /* client did not send INIT first! */
440 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
443 tc.car = GNUNET_CONTAINER_multihashmap_get (c->requests, &sm->peer.hashPubKey);
446 /* client did not request transmission first! */
448 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
451 GNUNET_assert (GNUNET_YES ==
452 GNUNET_CONTAINER_multihashmap_remove (c->requests,
453 &sm->peer.hashPubKey,
455 tc.cork = ntohl (sm->cork);
457 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
458 "Client asked for transmission of %u bytes to `%s' %s\n",
460 GNUNET_i2s (&sm->peer),
461 tc.cork ? "now" : "");
463 GNUNET_SERVER_mst_receive (client_mst,
465 (const char*) &sm[1], msize,
469 memcmp (&tc.car->target, &GSC_my_identity, sizeof (struct GNUNET_PeerIdentity)))
470 GSC_SESSIONS_dequeue_request (tc.car);
471 GNUNET_free (tc.car);
472 GNUNET_SERVER_receive_done (client, GNUNET_OK);
477 * Functions with this signature are called whenever a complete
478 * message is received by the tokenizer. Used by the 'client_mst' for
479 * dispatching messages from clients to either the SESSION subsystem
480 * or other CLIENT (for loopback).
483 * @param client reservation request ('struct GSC_ClientActiveRequest')
484 * @param message the actual message
487 client_tokenizer_callback (void *cls, void *client,
488 const struct GNUNET_MessageHeader *message)
490 struct TokenizerContext *tc = client;
491 struct GSC_ClientActiveRequest *car = tc->car;
494 memcmp (&car->target, &GSC_my_identity, sizeof (struct GNUNET_PeerIdentity)))
497 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
498 "Delivering message of type %u to myself\n",
499 ntohs (message->type));
501 GSC_CLIENTS_deliver_message (&GSC_my_identity,
504 ntohs (message->size),
505 GNUNET_CORE_OPTION_SEND_FULL_INBOUND | GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND);
506 GSC_CLIENTS_deliver_message (&GSC_my_identity,
509 sizeof (struct GNUNET_MessageHeader),
510 GNUNET_CORE_OPTION_SEND_HDR_INBOUND | GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND);
515 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
516 "Delivering message of type %u to %s\n",
517 ntohs (message->type),
518 GNUNET_i2s (&car->target));
520 GSC_SESSIONS_transmit (car, message, tc->cork);
526 * Free client request records.
529 * @param key identity of peer for which this is an active request
530 * @param value the 'struct GSC_ClientActiveRequest' to free
531 * @return GNUNET_YES (continue iteration)
534 destroy_active_client_request (void *cls, const GNUNET_HashCode * key,
537 struct GSC_ClientActiveRequest *car = value;
539 GNUNET_assert (GNUNET_YES ==
540 GNUNET_CONTAINER_multihashmap_remove (car->client_handle->requests,
541 &car->target.hashPubKey,
543 GSC_SESSIONS_dequeue_request (car);
550 * A client disconnected, clean up.
553 * @param client identification of the client
556 handle_client_disconnect (void *cls,
557 struct GNUNET_SERVER_Client *client)
559 struct GSC_Client *c;
564 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
565 "Client %p has disconnected from core service.\n", client);
567 c = find_client (client);
569 return; /* client never sent INIT */
570 GNUNET_CONTAINER_DLL_remove (client_head,
573 if (c->requests != NULL)
575 GNUNET_CONTAINER_multihashmap_iterate (c->requests,
576 &destroy_active_client_request,
578 GNUNET_CONTAINER_multihashmap_destroy (c->requests);
581 GNUNET_CONTAINER_multihashmap_destroy (c->connectmap);
583 GSC_TYPEMAP_remove (c->types, c->tcnt);
589 * Tell a client that we are ready to receive the message.
591 * @param car request that is now ready; the responsibility
592 * for the handle remains shared between CLIENTS
593 * and SESSIONS after this call.
596 GSC_CLIENTS_solicit_request (struct GSC_ClientActiveRequest *car)
598 struct GSC_Client *c;
599 struct SendMessageReady smr;
601 c = car->client_handle;
602 smr.header.size = htons (sizeof (struct SendMessageReady));
603 smr.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_SEND_READY);
604 smr.size = htons (car->msize);
605 smr.smr_id = car->smr_id;
606 smr.peer = car->target;
608 GNUNET_assert (GNUNET_YES ==
609 GNUNET_CONTAINER_multihashmap_contains (c->connectmap,
610 &car->target.hashPubKey));
612 send_to_client (c, &smr.header, GNUNET_NO);
617 * Tell a client that we will never be ready to receive the
618 * given message in time (disconnect or timeout).
620 * @param car request that now permanently failed; the
621 * responsibility for the handle is now returned
622 * to CLIENTS (SESSIONS is done with it).
625 GSC_CLIENTS_reject_request (struct GSC_ClientActiveRequest *car)
628 GNUNET_assert (GNUNET_YES ==
629 GNUNET_CONTAINER_multihashmap_contains (car->client_handle->connectmap,
630 &car->target.hashPubKey));
632 GNUNET_assert (GNUNET_YES ==
633 GNUNET_CONTAINER_multihashmap_remove (car->client_handle->requests,
634 &car->target.hashPubKey,
641 * Notify a particular client about a change to existing connection to
642 * one of our neighbours (check if the client is interested). Called
643 * from 'GSC_SESSIONS_notify_client_about_sessions'.
645 * @param client client to notify
646 * @param neighbour identity of the neighbour that changed status
647 * @param atsi performance information about neighbour
648 * @param atsi_count number of entries in 'ats' array
649 * @param tmap_old previous type map for the neighbour, NULL for disconnect
650 * @param tmap_new updated type map for the neighbour, NULL for disconnect
651 * @param is_new GNUNET_YES if this is a completely new neighbour
654 GSC_CLIENTS_notify_client_about_neighbour (struct GSC_Client *client,
655 const struct GNUNET_PeerIdentity *neighbour,
656 const struct GNUNET_ATS_Information *atsi,
657 unsigned int atsi_count,
658 const struct GSC_TypeMap *tmap_old,
659 const struct GSC_TypeMap *tmap_new)
661 struct ConnectNotifyMessage *cnm;
663 char buf[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1];
664 struct GNUNET_ATS_Information *a;
665 struct DisconnectNotifyMessage dcm;
669 old_match = GSC_TYPEMAP_test_match (tmap_old, client->types, client->tcnt);
670 new_match = GSC_TYPEMAP_test_match (tmap_new, client->types, client->tcnt);
671 if (old_match == new_match)
672 return; /* no change */
673 if (old_match == GNUNET_NO)
677 GNUNET_assert (GNUNET_NO ==
678 GNUNET_CONTAINER_multihashmap_contains (client->connectmap,
679 &neighbour->hashPubKey));
680 GNUNET_assert (GNUNET_YES ==
681 GNUNET_CONTAINER_multihashmap_put (client->connectmap,
682 &neighbour->hashPubKey,
684 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
687 sizeof (struct ConnectNotifyMessage) +
688 (atsi_count) * sizeof (struct GNUNET_ATS_Information);
689 if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
692 /* recovery strategy: throw away performance data */
694 size = sizeof (struct ConnectNotifyMessage);
696 cnm = (struct ConnectNotifyMessage *) buf;
697 cnm->header.size = htons (size);
698 cnm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT);
699 cnm->ats_count = htonl (atsi_count);
700 a = (struct GNUNET_ATS_Information* ) &cnm[1];
702 sizeof (struct GNUNET_ATS_Information) * atsi_count);
704 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
705 "Sending `%s' message to client.\n",
708 cnm->peer = *neighbour;
709 send_to_client (client, &cnm->header, GNUNET_NO);
713 /* send disconnect */
715 GNUNET_assert (GNUNET_YES ==
716 GNUNET_CONTAINER_multihashmap_contains (client->connectmap,
717 &neighbour->hashPubKey));
718 GNUNET_assert (GNUNET_YES ==
719 GNUNET_CONTAINER_multihashmap_remove (client->connectmap,
720 &neighbour->hashPubKey,
723 dcm.header.size = htons (sizeof (struct DisconnectNotifyMessage));
724 dcm.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT);
725 dcm.reserved = htonl (0);
726 dcm.peer = *neighbour;
727 send_to_client (client, &dcm.header, GNUNET_NO);
733 * Notify all clients about a change to existing session.
734 * Called from SESSIONS whenever there is a change in sessions
735 * or types processed by the respective peer.
737 * @param neighbour identity of the neighbour that changed status
738 * @param atsi performance information about neighbour
739 * @param atsi_count number of entries in 'ats' array
740 * @param tmap_old previous type map for the neighbour, NULL for disconnect
741 * @param tmap_new updated type map for the neighbour, NULL for disconnect
744 GSC_CLIENTS_notify_clients_about_neighbour (const struct GNUNET_PeerIdentity *neighbour,
745 const struct GNUNET_ATS_Information *atsi,
746 unsigned int atsi_count,
747 const struct GSC_TypeMap *tmap_old,
748 const struct GSC_TypeMap *tmap_new)
750 struct GSC_Client *c;
752 for (c = client_head; c != NULL; c = c->next)
753 GSC_CLIENTS_notify_client_about_neighbour (c, neighbour, atsi,
760 * Deliver P2P message to interested clients. Caller must have checked
761 * that the sending peer actually lists the given message type as one
764 * @param sender peer who sent us the message
765 * @param atsi performance information about neighbour
766 * @param atsi_count number of entries in 'ats' array
767 * @param msg the message
768 * @param msize number of bytes to transmit
769 * @param options options for checking which clients should
770 * receive the message
773 GSC_CLIENTS_deliver_message (const struct GNUNET_PeerIdentity *sender,
774 const struct GNUNET_ATS_Information *atsi,
775 unsigned int atsi_count,
776 const struct GNUNET_MessageHeader *msg,
780 size_t size = msize + sizeof (struct NotifyTrafficMessage) +
781 atsi_count * sizeof (struct GNUNET_ATS_Information);
783 struct NotifyTrafficMessage *ntm;
784 struct GNUNET_ATS_Information *a;
788 GNUNET_snprintf (buf, sizeof (buf),
789 gettext_noop ("# bytes of messages of type %u received"),
790 (unsigned int) ntohs (msg->type));
791 GNUNET_STATISTICS_update (GSC_stats, buf, msize, GNUNET_NO);
793 if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
796 /* recovery strategy: throw performance data away... */
798 size = msize + sizeof (struct NotifyTrafficMessage);
801 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
802 "Core service passes message from `%4s' of type %u to client.\n",
804 (unsigned int) ntohs (msg->type));
806 GSC_SESSIONS_add_to_typemap (sender, ntohs (msg->type));
807 ntm = (struct NotifyTrafficMessage *) buf;
808 ntm->header.size = htons (size);
809 ntm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND);
810 ntm->ats_count = htonl (atsi_count);
814 sizeof (struct GNUNET_ATS_Information) * atsi_count);
815 a[atsi_count].type = htonl (GNUNET_ATS_ARRAY_TERMINATOR);
816 a[atsi_count].value = htonl (0);
817 memcpy (&a[atsi_count + 1], msg, msize);
818 send_to_all_clients (sender,
819 &ntm->header, GNUNET_YES,
820 options, ntohs (msg->type));
825 * Initialize clients subsystem.
827 * @param server handle to server clients connect to
830 GSC_CLIENTS_init (struct GNUNET_SERVER_Handle *server)
832 static const struct GNUNET_SERVER_MessageHandler handlers[] = {
833 {&handle_client_init, NULL,
834 GNUNET_MESSAGE_TYPE_CORE_INIT, 0},
835 {&GSC_SESSIONS_handle_client_iterate_peers, NULL,
836 GNUNET_MESSAGE_TYPE_CORE_ITERATE_PEERS,
837 sizeof (struct GNUNET_MessageHeader)},
838 {&GSC_SESSIONS_handle_client_have_peer, NULL,
839 GNUNET_MESSAGE_TYPE_CORE_PEER_CONNECTED,
840 sizeof (struct GNUNET_MessageHeader) +
841 sizeof (struct GNUNET_PeerIdentity)},
842 {&handle_client_send_request, NULL,
843 GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST,
844 sizeof (struct SendMessageRequest)},
845 {&handle_client_send, NULL,
846 GNUNET_MESSAGE_TYPE_CORE_SEND, 0},
850 /* setup notification */
851 client_mst = GNUNET_SERVER_mst_create (&client_tokenizer_callback, NULL);
853 GNUNET_SERVER_notification_context_create (server, MAX_NOTIFY_QUEUE);
854 GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL);
855 GNUNET_SERVER_add_handlers (server, handlers);
860 * Shutdown clients subsystem.
865 struct GSC_Client *c;
867 while (NULL != (c = client_head))
868 handle_client_disconnect (NULL, c->client_handle);
869 if (NULL != notifier)
871 GNUNET_SERVER_notification_context_destroy (notifier);
874 GNUNET_SERVER_mst_destroy (client_mst);
878 /* end of gnunet-service-core_clients.c */