2 This file is part of GNUnet.
3 (C) 2013 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 Liceidentity 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 Liceidentity for more details.
15 You should have received a copy of the GNU General Public Liceidentity
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 identity/identity_api.c
23 * @brief api to interact with the identity service
24 * @author Christian Grothoff
27 #include "gnunet_util_lib.h"
28 #include "gnunet_constants.h"
29 #include "gnunet_protocols.h"
30 #include "gnunet_identity_service.h"
33 #define LOG(kind,...) GNUNET_log_from (kind, "identity-api",__VA_ARGS__)
38 struct GNUNET_IDENTITY_Ego
41 * Private key associated with this ego.
43 struct GNUNET_CRYPTO_EccPrivateKey *pk;
46 * Current name associated with this ego.
51 * Client context associated with this ego.
56 * Hash of the public key of this ego.
58 struct GNUNET_HashCode id;
63 * Handle for an operation with the identity service.
65 struct GNUNET_IDENTITY_Operation
69 * Main identity handle.
71 struct GNUNET_IDENTITY_Handle *h;
74 * We keep operations in a DLL.
76 struct GNUNET_IDENTITY_Operation *next;
79 * We keep operations in a DLL.
81 struct GNUNET_IDENTITY_Operation *prev;
84 * Message to send to the identity service.
85 * Allocated at the end of this struct.
87 const struct GNUNET_MessageHeader *msg;
90 * Continuation to invoke with the result of the transmission; 'cb'
91 * will be NULL in this case.
93 GNUNET_IDENTITY_Continuation cont;
96 * Continuation to invoke with the result of the transmission for
97 * 'get' operations ('cont' will be NULL in this case).
99 GNUNET_IDENTITY_Callback cb;
102 * Closure for 'cont' or 'cb'.
110 * Handle for the service.
112 struct GNUNET_IDENTITY_Handle
115 * Configuration to use.
117 const struct GNUNET_CONFIGURATION_Handle *cfg;
120 * Socket (if available).
122 struct GNUNET_CLIENT_Connection *client;
125 * Hash map from the hash of the public key to the
126 * respective 'GNUNET_IDENTITY_Ego' handle.
128 struct GNUNET_CONTAINER_MultiHashMap *egos;
131 * Function to call when we receive updates.
133 GNUNET_IDENTITY_Callback cb;
141 * Head of active operations.
143 struct GNUNET_IDENTITY_Operation *op_head;
146 * Tail of active operations.
148 struct GNUNET_IDENTITY_Operation *op_tail;
151 * Currently pending transmission request, or NULL for none.
153 struct GNUNET_CLIENT_TransmitHandle *th;
156 * Task doing exponential back-off trying to reconnect.
158 GNUNET_SCHEDULER_TaskIdentifier reconnect_task;
161 * Time for next connect retry.
163 struct GNUNET_TIME_Relative reconnect_delay;
166 * Are we polling for incoming messages right now?
174 * Obtain the ego representing 'anonymous' users.
176 const struct GNUNET_IDENTITY_Ego *
177 GNUNET_IDENTITY_ego_get_anonymous ()
179 static struct GNUNET_IDENTITY_Ego anon;
180 struct GNUNET_CRYPTO_EccPublicKey pub;
184 anon.pk = (struct GNUNET_CRYPTO_EccPrivateKey *) GNUNET_CRYPTO_ecc_key_get_anonymous ();
185 GNUNET_CRYPTO_ecc_key_get_public (anon.pk,
187 GNUNET_CRYPTO_hash (&pub, sizeof (pub), &anon.id);
193 * Try again to connect to network size estimation service.
195 * @param cls the handle to the transport service
196 * @param tc scheduler context
199 reconnect (void *cls,
200 const struct GNUNET_SCHEDULER_TaskContext *tc);
204 * Reschedule a connect attempt to the service.
206 * @param h transport service to reconnect
209 reschedule_connect (struct GNUNET_IDENTITY_Handle *h)
211 GNUNET_assert (h->reconnect_task == GNUNET_SCHEDULER_NO_TASK);
215 GNUNET_CLIENT_notify_transmit_ready_cancel (h->th);
218 if (NULL != h->client)
220 GNUNET_CLIENT_disconnect (h->client);
223 h->in_receive = GNUNET_NO;
224 LOG (GNUNET_ERROR_TYPE_DEBUG,
225 "Scheduling task to reconnect to identity service in %s.\n",
226 GNUNET_STRINGS_relative_time_to_string (h->reconnect_delay, GNUNET_YES));
228 GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h);
229 h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay);
234 * Type of a function to call when we receive a message
238 * @param msg message received, NULL on timeout or fatal error
241 message_handler (void *cls,
242 const struct GNUNET_MessageHeader *msg)
244 struct GNUNET_IDENTITY_Handle *h = cls;
245 struct GNUNET_IDENTITY_Operation *op;
246 struct GNUNET_IDENTITY_Ego *ego;
247 const struct GNUNET_IDENTITY_ResultCodeMessage *rcm;
248 const struct GNUNET_IDENTITY_UpdateMessage *um;
249 const struct GNUNET_IDENTITY_SetDefaultMessage *sdm;
250 struct GNUNET_CRYPTO_EccPublicKey pub;
251 struct GNUNET_HashCode id;
258 reschedule_connect (h);
261 LOG (GNUNET_ERROR_TYPE_DEBUG,
262 "Received message of type %d from identity service\n",
264 size = ntohs (msg->size);
265 switch (ntohs (msg->type))
267 case GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE:
268 if (size < sizeof (struct GNUNET_IDENTITY_ResultCodeMessage))
271 reschedule_connect (h);
274 rcm = (const struct GNUNET_IDENTITY_ResultCodeMessage *) msg;
275 str = (const char *) &rcm[1];
276 if ( (size > sizeof (struct GNUNET_IDENTITY_ResultCodeMessage)) &&
277 ('\0' != str[size - sizeof (struct GNUNET_IDENTITY_ResultCodeMessage) - 1]) )
280 reschedule_connect (h);
283 if (size == sizeof (struct GNUNET_IDENTITY_ResultCodeMessage))
287 GNUNET_CONTAINER_DLL_remove (h->op_head,
290 GNUNET_CLIENT_receive (h->client, &message_handler, h,
291 GNUNET_TIME_UNIT_FOREVER_REL);
292 if (NULL != op->cont)
295 else if (NULL != op->cb)
296 op->cb (op->cls, NULL, NULL, NULL);
299 case GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE:
300 if (size < sizeof (struct GNUNET_IDENTITY_UpdateMessage))
303 reschedule_connect (h);
306 um = (const struct GNUNET_IDENTITY_UpdateMessage *) msg;
307 name_len = ntohs (um->name_len);
309 str = (const char *) &um[1];
310 if ( (size != name_len + sizeof (struct GNUNET_IDENTITY_UpdateMessage)) ||
312 ('\0' != str[name_len - 1])) )
315 reschedule_connect (h);
318 if (GNUNET_YES == ntohs (um->end_of_list))
320 /* end of initial list of data */
321 GNUNET_CLIENT_receive (h->client, &message_handler, h,
322 GNUNET_TIME_UNIT_FOREVER_REL);
324 h->cb (h->cb_cls, NULL, NULL, NULL);
327 GNUNET_CRYPTO_ecc_key_get_public (&um->private_key,
329 GNUNET_CRYPTO_hash (&pub, sizeof (pub), &id);
333 str = (const char *) &um[1];
334 ego = GNUNET_CONTAINER_multihashmap_get (h->egos,
338 /* ego was created */
341 /* deletion of unknown ego? not allowed */
343 reschedule_connect (h);
346 ego = GNUNET_new (struct GNUNET_IDENTITY_Ego);
347 ego->pk = GNUNET_new (struct GNUNET_CRYPTO_EccPrivateKey);
348 *ego->pk = um->private_key;
349 ego->name = GNUNET_strdup (str);
351 GNUNET_assert (GNUNET_YES ==
352 GNUNET_CONTAINER_multihashmap_put (h->egos,
355 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
359 /* ego was deleted */
360 GNUNET_assert (GNUNET_YES ==
361 GNUNET_CONTAINER_multihashmap_remove (h->egos,
367 /* ego changed name */
368 GNUNET_free (ego->name);
369 ego->name = GNUNET_strdup (str);
371 GNUNET_CLIENT_receive (h->client, &message_handler, h,
372 GNUNET_TIME_UNIT_FOREVER_REL);
373 /* inform application about change */
381 GNUNET_free (ego->pk);
382 GNUNET_free (ego->name);
386 case GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT:
387 if (size < sizeof (struct GNUNET_IDENTITY_SetDefaultMessage))
390 reschedule_connect (h);
393 sdm = (const struct GNUNET_IDENTITY_SetDefaultMessage *) msg;
394 GNUNET_break (0 == ntohs (sdm->reserved));
395 name_len = ntohs (sdm->name_len);
396 str = (const char *) &sdm[1];
397 if ( (size != name_len + sizeof (struct GNUNET_IDENTITY_SetDefaultMessage)) ||
399 ('\0' != str[name_len - 1]) ) )
402 reschedule_connect (h);
405 /* Note: we know which service this should be for, so we're not
406 really using 'str' henceforth */
407 GNUNET_CRYPTO_ecc_key_get_public (&sdm->private_key,
409 GNUNET_CRYPTO_hash (&pub, sizeof (pub), &id);
410 ego = GNUNET_CONTAINER_multihashmap_get (h->egos,
415 reschedule_connect (h);
419 GNUNET_CONTAINER_DLL_remove (h->op_head,
422 GNUNET_free (ego->name);
423 GNUNET_CLIENT_receive (h->client, &message_handler, h,
424 GNUNET_TIME_UNIT_FOREVER_REL);
434 reschedule_connect (h);
441 * Schedule transmission of the next message from our queue.
443 * @param h identity handle
446 transmit_next (struct GNUNET_IDENTITY_Handle *h);
450 * Transmit next message to service.
452 * @param cls the 'struct GNUNET_IDENTITY_Handle'.
453 * @param size number of bytes available in buf
454 * @param buf where to copy the message
455 * @return number of bytes copied to buf
458 send_next_message (void *cls,
462 struct GNUNET_IDENTITY_Handle *h = cls;
463 struct GNUNET_IDENTITY_Operation *op = h->op_head;
469 ret = ntohs (op->msg->size);
472 reschedule_connect (h);
475 LOG (GNUNET_ERROR_TYPE_DEBUG,
476 "Sending message of type %d to identity service\n",
477 ntohs (op->msg->type));
478 memcpy (buf, op->msg, ret);
479 if ( (NULL == op->cont) &&
482 GNUNET_CONTAINER_DLL_remove (h->op_head,
488 if (GNUNET_NO == h->in_receive)
490 h->in_receive = GNUNET_YES;
491 GNUNET_CLIENT_receive (h->client,
493 GNUNET_TIME_UNIT_FOREVER_REL);
500 * Schedule transmission of the next message from our queue.
502 * @param h identity handle
505 transmit_next (struct GNUNET_IDENTITY_Handle *h)
507 struct GNUNET_IDENTITY_Operation *op = h->op_head;
509 GNUNET_assert (NULL == h->th);
512 if (NULL == h->client)
514 h->th = GNUNET_CLIENT_notify_transmit_ready (h->client,
515 ntohs (op->msg->size),
516 GNUNET_TIME_UNIT_FOREVER_REL,
524 * Try again to connect to network size estimation service.
526 * @param cls the handle to the transport service
527 * @param tc scheduler context
530 reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
532 struct GNUNET_IDENTITY_Handle *h = cls;
533 struct GNUNET_IDENTITY_Operation *op;
534 struct GNUNET_MessageHeader msg;
536 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
537 LOG (GNUNET_ERROR_TYPE_DEBUG,
538 "Connecting to identity service.\n");
539 GNUNET_assert (NULL == h->client);
540 h->client = GNUNET_CLIENT_connect ("identity", h->cfg);
541 GNUNET_assert (NULL != h->client);
542 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
543 sizeof (struct GNUNET_MessageHeader));
545 op->msg = (const struct GNUNET_MessageHeader *) &op[1];
546 msg.size = htons (sizeof (msg));
547 msg.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_START);
548 memcpy (&op[1], &msg, sizeof (msg));
549 GNUNET_CONTAINER_DLL_insert (h->op_head,
553 GNUNET_assert (NULL != h->th);
558 * Connect to the identity service.
560 * @param cfg the configuration to use
561 * @param cb function to call on all identity events, can be NULL
562 * @param cb_cls closure for 'cb'
563 * @return handle to use
565 struct GNUNET_IDENTITY_Handle *
566 GNUNET_IDENTITY_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
567 GNUNET_IDENTITY_Callback cb,
570 struct GNUNET_IDENTITY_Handle *h;
572 h = GNUNET_new (struct GNUNET_IDENTITY_Handle);
576 h->egos = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_YES);
577 h->reconnect_delay = GNUNET_TIME_UNIT_ZERO;
578 h->reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect, h);
584 * Obtain the ECC key associated with a ego.
587 * @return associated ECC key, valid as long as the ego is valid
589 const struct GNUNET_CRYPTO_EccPrivateKey *
590 GNUNET_IDENTITY_ego_get_private_key (const struct GNUNET_IDENTITY_Ego *ego)
597 * Get the identifier (public key) of an ego.
599 * @param ego identity handle with the private key
600 * @param pk set to ego's public key
603 GNUNET_IDENTITY_ego_get_public_key (const struct GNUNET_IDENTITY_Ego *ego,
604 struct GNUNET_CRYPTO_EccPublicKey *pk)
606 GNUNET_CRYPTO_ecc_key_get_public (ego->pk,
612 * Obtain the identity that is currently preferred/default
615 * @param id identity service to query
616 * @param service_name for which service is an identity wanted
617 * @param cb function to call with the result (will only be called once)
618 * @param cb_cls closure for cb
619 * @return handle to abort the operation
621 struct GNUNET_IDENTITY_Operation *
622 GNUNET_IDENTITY_get (struct GNUNET_IDENTITY_Handle *id,
623 const char *service_name,
624 GNUNET_IDENTITY_Callback cb,
627 struct GNUNET_IDENTITY_Operation *op;
628 struct GNUNET_IDENTITY_GetDefaultMessage *gdm;
631 slen = strlen (service_name) + 1;
632 if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_GetDefaultMessage))
637 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
638 sizeof (struct GNUNET_IDENTITY_GetDefaultMessage) +
643 gdm = (struct GNUNET_IDENTITY_GetDefaultMessage *) &op[1];
644 gdm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT);
645 gdm->header.size = htons (sizeof (struct GNUNET_IDENTITY_GetDefaultMessage) +
647 gdm->name_len = htons (slen);
648 gdm->reserved = htons (0);
649 memcpy (&gdm[1], service_name, slen);
650 op->msg = &gdm->header;
651 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
661 * Set the preferred/default identity for a service.
663 * @param id identity service to inform
664 * @param service_name for which service is an identity set
665 * @param ego new default identity to be set for this service
666 * @param cont function to call once the operation finished
667 * @param cont_cls closure for cont
668 * @return handle to abort the operation
670 struct GNUNET_IDENTITY_Operation *
671 GNUNET_IDENTITY_set (struct GNUNET_IDENTITY_Handle *id,
672 const char *service_name,
673 struct GNUNET_IDENTITY_Ego *ego,
674 GNUNET_IDENTITY_Continuation cont,
677 struct GNUNET_IDENTITY_Operation *op;
678 struct GNUNET_IDENTITY_SetDefaultMessage *sdm;
681 slen = strlen (service_name) + 1;
682 if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_SetDefaultMessage))
687 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
688 sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) +
693 sdm = (struct GNUNET_IDENTITY_SetDefaultMessage *) &op[1];
694 sdm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT);
695 sdm->header.size = htons (sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) +
697 sdm->name_len = htons (slen);
698 sdm->reserved = htons (0);
699 sdm->private_key = *ego->pk;
700 memcpy (&sdm[1], service_name, slen);
701 op->msg = &sdm->header;
702 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
712 * Create a new identity with the given name.
714 * @param id identity service to use
715 * @param name desired name
716 * @param cont function to call with the result (will only be called once)
717 * @param cont_cls closure for cont
718 * @return handle to abort the operation
720 struct GNUNET_IDENTITY_Operation *
721 GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *id,
723 GNUNET_IDENTITY_Continuation cont,
726 struct GNUNET_IDENTITY_Operation *op;
727 struct GNUNET_IDENTITY_CreateRequestMessage *crm;
728 struct GNUNET_CRYPTO_EccPrivateKey *pk;
731 slen = strlen (name) + 1;
732 pk = GNUNET_CRYPTO_ecc_key_create ();
734 if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_CreateRequestMessage))
740 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
741 sizeof (struct GNUNET_IDENTITY_CreateRequestMessage) +
746 crm = (struct GNUNET_IDENTITY_CreateRequestMessage *) &op[1];
747 crm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_CREATE);
748 crm->header.size = htons (sizeof (struct GNUNET_IDENTITY_CreateRequestMessage) +
750 crm->name_len = htons (slen);
751 crm->reserved = htons (0);
752 crm->private_key = *pk;
753 memcpy (&crm[1], name, slen);
754 op->msg = &crm->header;
755 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
766 * Renames an existing identity.
768 * @param id identity service to use
769 * @param old_name old name
770 * @param new_name desired new name
771 * @param cb function to call with the result (will only be called once)
772 * @param cb_cls closure for cb
773 * @return handle to abort the operation
775 struct GNUNET_IDENTITY_Operation *
776 GNUNET_IDENTITY_rename (struct GNUNET_IDENTITY_Handle *id,
777 const char *old_name,
778 const char *new_name,
779 GNUNET_IDENTITY_Continuation cb,
782 struct GNUNET_IDENTITY_Operation *op;
783 struct GNUNET_IDENTITY_RenameMessage *grm;
788 slen_old = strlen (old_name) + 1;
789 slen_new = strlen (new_name) + 1;
790 if ( (slen_old >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
791 (slen_new >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
792 (slen_old + slen_new >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_RenameMessage)) )
797 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
798 sizeof (struct GNUNET_IDENTITY_RenameMessage) +
799 slen_old + slen_new);
803 grm = (struct GNUNET_IDENTITY_RenameMessage *) &op[1];
804 grm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_RENAME);
805 grm->header.size = htons (sizeof (struct GNUNET_IDENTITY_RenameMessage) +
806 slen_old + slen_new);
807 grm->old_name_len = htons (slen_old);
808 grm->new_name_len = htons (slen_new);
809 dst = (char *) &grm[1];
810 memcpy (dst, old_name, slen_old);
811 memcpy (&dst[slen_old], new_name, slen_new);
812 op->msg = &grm->header;
813 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
823 * Delete an existing identity.
825 * @param id identity service to use
826 * @param name name of the identity to delete
827 * @param cb function to call with the result (will only be called once)
828 * @param cb_cls closure for @a cb
829 * @return handle to abort the operation
831 struct GNUNET_IDENTITY_Operation *
832 GNUNET_IDENTITY_delete (struct GNUNET_IDENTITY_Handle *id,
834 GNUNET_IDENTITY_Continuation cb,
837 struct GNUNET_IDENTITY_Operation *op;
838 struct GNUNET_IDENTITY_DeleteMessage *gdm;
841 slen = strlen (name) + 1;
842 if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_DeleteMessage))
847 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
848 sizeof (struct GNUNET_IDENTITY_DeleteMessage) +
853 gdm = (struct GNUNET_IDENTITY_DeleteMessage *) &op[1];
854 gdm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_DELETE);
855 gdm->header.size = htons (sizeof (struct GNUNET_IDENTITY_DeleteMessage) +
857 gdm->name_len = htons (slen);
858 gdm->reserved = htons (0);
859 memcpy (&gdm[1], name, slen);
860 op->msg = &gdm->header;
861 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
871 * Cancel an identity operation. Note that the operation MAY still
872 * be executed; this merely cancels the continuation; if the request
873 * was already transmitted, the service may still choose to complete
876 * @param op operation to cancel
879 GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op)
881 struct GNUNET_IDENTITY_Handle *h = op->h;
883 if ( (h->op_head != op) ||
884 (NULL == h->client) )
886 /* request not active, can simply remove */
887 GNUNET_CONTAINER_DLL_remove (h->op_head,
895 /* request active but not yet with service, can still abort */
896 GNUNET_CLIENT_notify_transmit_ready_cancel (h->th);
898 GNUNET_CONTAINER_DLL_remove (h->op_head,
905 /* request active with service, simply ensure continuations are not called */
912 * Free ego from hash map.
914 * @param cls identity service handle
916 * @param value ego to free
917 * @return #GNUNET_OK (continue to iterate)
921 const struct GNUNET_HashCode *key,
924 struct GNUNET_IDENTITY_Handle *h = cls;
925 struct GNUNET_IDENTITY_Ego *ego = value;
931 GNUNET_free (ego->pk);
932 GNUNET_free (ego->name);
939 * Disconnect from identity service
941 * @param h handle to destroy
944 GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle *h)
946 GNUNET_assert (NULL != h);
947 GNUNET_assert (h->op_head == h->op_tail);
948 if (h->reconnect_task != GNUNET_SCHEDULER_NO_TASK)
950 GNUNET_SCHEDULER_cancel (h->reconnect_task);
951 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
955 GNUNET_CLIENT_notify_transmit_ready_cancel (h->th);
960 GNUNET_CONTAINER_multihashmap_iterate (h->egos,
963 GNUNET_CONTAINER_multihashmap_destroy (h->egos);
966 if (NULL != h->client)
968 GNUNET_CLIENT_disconnect (h->client);
974 /* end of identity_api.c */