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 the identity service.
195 * @param cls handle to the identity 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_CLIENT_receive (h->client, &message_handler, h,
423 GNUNET_TIME_UNIT_FOREVER_REL);
433 reschedule_connect (h);
440 * Schedule transmission of the next message from our queue.
442 * @param h identity handle
445 transmit_next (struct GNUNET_IDENTITY_Handle *h);
449 * Transmit next message to service.
451 * @param cls the 'struct GNUNET_IDENTITY_Handle'.
452 * @param size number of bytes available in buf
453 * @param buf where to copy the message
454 * @return number of bytes copied to buf
457 send_next_message (void *cls,
461 struct GNUNET_IDENTITY_Handle *h = cls;
462 struct GNUNET_IDENTITY_Operation *op = h->op_head;
468 ret = ntohs (op->msg->size);
471 reschedule_connect (h);
474 LOG (GNUNET_ERROR_TYPE_DEBUG,
475 "Sending message of type %d to identity service\n",
476 ntohs (op->msg->type));
477 memcpy (buf, op->msg, ret);
478 if ( (NULL == op->cont) &&
481 GNUNET_CONTAINER_DLL_remove (h->op_head,
487 if (GNUNET_NO == h->in_receive)
489 h->in_receive = GNUNET_YES;
490 GNUNET_CLIENT_receive (h->client,
492 GNUNET_TIME_UNIT_FOREVER_REL);
499 * Schedule transmission of the next message from our queue.
501 * @param h identity handle
504 transmit_next (struct GNUNET_IDENTITY_Handle *h)
506 struct GNUNET_IDENTITY_Operation *op = h->op_head;
508 GNUNET_assert (NULL == h->th);
511 if (NULL == h->client)
513 h->th = GNUNET_CLIENT_notify_transmit_ready (h->client,
514 ntohs (op->msg->size),
515 GNUNET_TIME_UNIT_FOREVER_REL,
523 * Try again to connect to the identity service.
525 * @param cls handle to the identity service.
526 * @param tc scheduler context
529 reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
531 struct GNUNET_IDENTITY_Handle *h = cls;
532 struct GNUNET_IDENTITY_Operation *op;
533 struct GNUNET_MessageHeader msg;
535 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
536 LOG (GNUNET_ERROR_TYPE_DEBUG,
537 "Connecting to identity service.\n");
538 GNUNET_assert (NULL == h->client);
539 h->client = GNUNET_CLIENT_connect ("identity", h->cfg);
540 GNUNET_assert (NULL != h->client);
541 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
542 sizeof (struct GNUNET_MessageHeader));
544 op->msg = (const struct GNUNET_MessageHeader *) &op[1];
545 msg.size = htons (sizeof (msg));
546 msg.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_START);
547 memcpy (&op[1], &msg, sizeof (msg));
548 GNUNET_CONTAINER_DLL_insert (h->op_head,
552 GNUNET_assert (NULL != h->th);
557 * Connect to the identity service.
559 * @param cfg the configuration to use
560 * @param cb function to call on all identity events, can be NULL
561 * @param cb_cls closure for 'cb'
562 * @return handle to use
564 struct GNUNET_IDENTITY_Handle *
565 GNUNET_IDENTITY_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
566 GNUNET_IDENTITY_Callback cb,
569 struct GNUNET_IDENTITY_Handle *h;
571 h = GNUNET_new (struct GNUNET_IDENTITY_Handle);
575 h->egos = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_YES);
576 h->reconnect_delay = GNUNET_TIME_UNIT_ZERO;
577 h->reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect, h);
583 * Obtain the ECC key associated with a ego.
586 * @return associated ECC key, valid as long as the ego is valid
588 const struct GNUNET_CRYPTO_EccPrivateKey *
589 GNUNET_IDENTITY_ego_get_private_key (const struct GNUNET_IDENTITY_Ego *ego)
596 * Get the identifier (public key) of an ego.
598 * @param ego identity handle with the private key
599 * @param pk set to ego's public key
602 GNUNET_IDENTITY_ego_get_public_key (const struct GNUNET_IDENTITY_Ego *ego,
603 struct GNUNET_CRYPTO_EccPublicKey *pk)
605 GNUNET_CRYPTO_ecc_key_get_public (ego->pk,
611 * Obtain the identity that is currently preferred/default
614 * @param id identity service to query
615 * @param service_name for which service is an identity wanted
616 * @param cb function to call with the result (will only be called once)
617 * @param cb_cls closure for cb
618 * @return handle to abort the operation
620 struct GNUNET_IDENTITY_Operation *
621 GNUNET_IDENTITY_get (struct GNUNET_IDENTITY_Handle *id,
622 const char *service_name,
623 GNUNET_IDENTITY_Callback cb,
626 struct GNUNET_IDENTITY_Operation *op;
627 struct GNUNET_IDENTITY_GetDefaultMessage *gdm;
630 slen = strlen (service_name) + 1;
631 if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_GetDefaultMessage))
636 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
637 sizeof (struct GNUNET_IDENTITY_GetDefaultMessage) +
642 gdm = (struct GNUNET_IDENTITY_GetDefaultMessage *) &op[1];
643 gdm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT);
644 gdm->header.size = htons (sizeof (struct GNUNET_IDENTITY_GetDefaultMessage) +
646 gdm->name_len = htons (slen);
647 gdm->reserved = htons (0);
648 memcpy (&gdm[1], service_name, slen);
649 op->msg = &gdm->header;
650 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
660 * Set the preferred/default identity for a service.
662 * @param id identity service to inform
663 * @param service_name for which service is an identity set
664 * @param ego new default identity to be set for this service
665 * @param cont function to call once the operation finished
666 * @param cont_cls closure for cont
667 * @return handle to abort the operation
669 struct GNUNET_IDENTITY_Operation *
670 GNUNET_IDENTITY_set (struct GNUNET_IDENTITY_Handle *id,
671 const char *service_name,
672 struct GNUNET_IDENTITY_Ego *ego,
673 GNUNET_IDENTITY_Continuation cont,
676 struct GNUNET_IDENTITY_Operation *op;
677 struct GNUNET_IDENTITY_SetDefaultMessage *sdm;
680 slen = strlen (service_name) + 1;
681 if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_SetDefaultMessage))
686 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
687 sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) +
692 sdm = (struct GNUNET_IDENTITY_SetDefaultMessage *) &op[1];
693 sdm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT);
694 sdm->header.size = htons (sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) +
696 sdm->name_len = htons (slen);
697 sdm->reserved = htons (0);
698 sdm->private_key = *ego->pk;
699 memcpy (&sdm[1], service_name, slen);
700 op->msg = &sdm->header;
701 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
711 * Create a new identity with the given name.
713 * @param id identity service to use
714 * @param name desired name
715 * @param cont function to call with the result (will only be called once)
716 * @param cont_cls closure for cont
717 * @return handle to abort the operation
719 struct GNUNET_IDENTITY_Operation *
720 GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *id,
722 GNUNET_IDENTITY_Continuation cont,
725 struct GNUNET_IDENTITY_Operation *op;
726 struct GNUNET_IDENTITY_CreateRequestMessage *crm;
727 struct GNUNET_CRYPTO_EccPrivateKey *pk;
730 slen = strlen (name) + 1;
731 pk = GNUNET_CRYPTO_ecc_key_create ();
733 if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_CreateRequestMessage))
739 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
740 sizeof (struct GNUNET_IDENTITY_CreateRequestMessage) +
745 crm = (struct GNUNET_IDENTITY_CreateRequestMessage *) &op[1];
746 crm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_CREATE);
747 crm->header.size = htons (sizeof (struct GNUNET_IDENTITY_CreateRequestMessage) +
749 crm->name_len = htons (slen);
750 crm->reserved = htons (0);
751 crm->private_key = *pk;
752 memcpy (&crm[1], name, slen);
753 op->msg = &crm->header;
754 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
765 * Renames an existing identity.
767 * @param id identity service to use
768 * @param old_name old name
769 * @param new_name desired new name
770 * @param cb function to call with the result (will only be called once)
771 * @param cb_cls closure for cb
772 * @return handle to abort the operation
774 struct GNUNET_IDENTITY_Operation *
775 GNUNET_IDENTITY_rename (struct GNUNET_IDENTITY_Handle *id,
776 const char *old_name,
777 const char *new_name,
778 GNUNET_IDENTITY_Continuation cb,
781 struct GNUNET_IDENTITY_Operation *op;
782 struct GNUNET_IDENTITY_RenameMessage *grm;
787 slen_old = strlen (old_name) + 1;
788 slen_new = strlen (new_name) + 1;
789 if ( (slen_old >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
790 (slen_new >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
791 (slen_old + slen_new >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_RenameMessage)) )
796 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
797 sizeof (struct GNUNET_IDENTITY_RenameMessage) +
798 slen_old + slen_new);
802 grm = (struct GNUNET_IDENTITY_RenameMessage *) &op[1];
803 grm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_RENAME);
804 grm->header.size = htons (sizeof (struct GNUNET_IDENTITY_RenameMessage) +
805 slen_old + slen_new);
806 grm->old_name_len = htons (slen_old);
807 grm->new_name_len = htons (slen_new);
808 dst = (char *) &grm[1];
809 memcpy (dst, old_name, slen_old);
810 memcpy (&dst[slen_old], new_name, slen_new);
811 op->msg = &grm->header;
812 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
822 * Delete an existing identity.
824 * @param id identity service to use
825 * @param name name of the identity to delete
826 * @param cb function to call with the result (will only be called once)
827 * @param cb_cls closure for @a cb
828 * @return handle to abort the operation
830 struct GNUNET_IDENTITY_Operation *
831 GNUNET_IDENTITY_delete (struct GNUNET_IDENTITY_Handle *id,
833 GNUNET_IDENTITY_Continuation cb,
836 struct GNUNET_IDENTITY_Operation *op;
837 struct GNUNET_IDENTITY_DeleteMessage *gdm;
840 slen = strlen (name) + 1;
841 if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_DeleteMessage))
846 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
847 sizeof (struct GNUNET_IDENTITY_DeleteMessage) +
852 gdm = (struct GNUNET_IDENTITY_DeleteMessage *) &op[1];
853 gdm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_DELETE);
854 gdm->header.size = htons (sizeof (struct GNUNET_IDENTITY_DeleteMessage) +
856 gdm->name_len = htons (slen);
857 gdm->reserved = htons (0);
858 memcpy (&gdm[1], name, slen);
859 op->msg = &gdm->header;
860 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
870 * Cancel an identity operation. Note that the operation MAY still
871 * be executed; this merely cancels the continuation; if the request
872 * was already transmitted, the service may still choose to complete
875 * @param op operation to cancel
878 GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op)
880 struct GNUNET_IDENTITY_Handle *h = op->h;
882 if ( (h->op_head != op) ||
883 (NULL == h->client) )
885 /* request not active, can simply remove */
886 GNUNET_CONTAINER_DLL_remove (h->op_head,
894 /* request active but not yet with service, can still abort */
895 GNUNET_CLIENT_notify_transmit_ready_cancel (h->th);
897 GNUNET_CONTAINER_DLL_remove (h->op_head,
904 /* request active with service, simply ensure continuations are not called */
911 * Free ego from hash map.
913 * @param cls identity service handle
915 * @param value ego to free
916 * @return #GNUNET_OK (continue to iterate)
920 const struct GNUNET_HashCode *key,
923 struct GNUNET_IDENTITY_Handle *h = cls;
924 struct GNUNET_IDENTITY_Ego *ego = value;
930 GNUNET_free (ego->pk);
931 GNUNET_free (ego->name);
938 * Disconnect from identity service
940 * @param h handle to destroy
943 GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle *h)
945 GNUNET_assert (NULL != h);
946 GNUNET_assert (h->op_head == h->op_tail);
947 if (h->reconnect_task != GNUNET_SCHEDULER_NO_TASK)
949 GNUNET_SCHEDULER_cancel (h->reconnect_task);
950 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
954 GNUNET_CLIENT_notify_transmit_ready_cancel (h->th);
959 GNUNET_CONTAINER_multihashmap_iterate (h->egos,
962 GNUNET_CONTAINER_multihashmap_destroy (h->egos);
965 if (NULL != h->client)
967 GNUNET_CLIENT_disconnect (h->client);
973 /* end of identity_api.c */