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_client_lib.h"
28 #include "gnunet_constants.h"
29 #include "gnunet_container_lib.h"
30 #include "gnunet_arm_service.h"
31 #include "gnunet_hello_lib.h"
32 #include "gnunet_protocols.h"
33 #include "gnunet_server_lib.h"
34 #include "gnunet_time_lib.h"
35 #include "gnunet_identity_service.h"
38 #define LOG(kind,...) GNUNET_log_from (kind, "identity-api",__VA_ARGS__)
43 struct GNUNET_IDENTITY_Ego
46 * Private key associated with this ego.
48 struct GNUNET_CRYPTO_EccPrivateKey *pk;
51 * Current name associated with this ego.
56 * Client context associated with this ego.
61 * Hash of the public key of this ego.
63 struct GNUNET_HashCode id;
68 * Handle for an operation with the identity service.
70 struct GNUNET_IDENTITY_Operation
74 * Main identity handle.
76 struct GNUNET_IDENTITY_Handle *h;
79 * We keep operations in a DLL.
81 struct GNUNET_IDENTITY_Operation *next;
84 * We keep operations in a DLL.
86 struct GNUNET_IDENTITY_Operation *prev;
89 * Message to send to the identity service.
90 * Allocated at the end of this struct.
92 const struct GNUNET_MessageHeader *msg;
95 * Continuation to invoke with the result of the transmission; 'cb'
96 * will be NULL in this case.
98 GNUNET_IDENTITY_Continuation cont;
101 * Continuation to invoke with the result of the transmission for
102 * 'get' operations ('cont' will be NULL in this case).
104 GNUNET_IDENTITY_Callback cb;
107 * Closure for 'cont' or 'cb'.
115 * Handle for the service.
117 struct GNUNET_IDENTITY_Handle
120 * Configuration to use.
122 const struct GNUNET_CONFIGURATION_Handle *cfg;
125 * Socket (if available).
127 struct GNUNET_CLIENT_Connection *client;
130 * Hash map from the hash of the public key to the
131 * respective 'GNUNET_IDENTITY_Ego' handle.
133 struct GNUNET_CONTAINER_MultiHashMap *egos;
136 * Function to call when we receive updates.
138 GNUNET_IDENTITY_Callback cb;
146 * Head of active operations.
148 struct GNUNET_IDENTITY_Operation *op_head;
151 * Tail of active operations.
153 struct GNUNET_IDENTITY_Operation *op_tail;
156 * Currently pending transmission request, or NULL for none.
158 struct GNUNET_CLIENT_TransmitHandle *th;
161 * Task doing exponential back-off trying to reconnect.
163 GNUNET_SCHEDULER_TaskIdentifier reconnect_task;
166 * Time for next connect retry.
168 struct GNUNET_TIME_Relative reconnect_delay;
171 * Are we polling for incoming messages right now?
179 * Obtain the ego representing 'anonymous' users.
181 const struct GNUNET_IDENTITY_Ego *
182 GNUNET_IDENTITY_ego_get_anonymous ()
184 static struct GNUNET_IDENTITY_Ego anon;
185 struct GNUNET_CRYPTO_EccPublicKey pub;
189 anon.pk = (struct GNUNET_CRYPTO_EccPrivateKey *) GNUNET_CRYPTO_ecc_key_get_anonymous ();
190 GNUNET_CRYPTO_ecc_key_get_public (anon.pk,
192 GNUNET_CRYPTO_hash (&pub, sizeof (pub), &anon.id);
198 * Try again to connect to network size estimation service.
200 * @param cls the handle to the transport service
201 * @param tc scheduler context
204 reconnect (void *cls,
205 const struct GNUNET_SCHEDULER_TaskContext *tc);
209 * Reschedule a connect attempt to the service.
211 * @param h transport service to reconnect
214 reschedule_connect (struct GNUNET_IDENTITY_Handle *h)
216 GNUNET_assert (h->reconnect_task == GNUNET_SCHEDULER_NO_TASK);
220 GNUNET_CLIENT_notify_transmit_ready_cancel (h->th);
223 if (NULL != h->client)
225 GNUNET_CLIENT_disconnect (h->client);
228 h->in_receive = GNUNET_NO;
229 LOG (GNUNET_ERROR_TYPE_DEBUG,
230 "Scheduling task to reconnect to identity service in %s.\n",
231 GNUNET_STRINGS_relative_time_to_string (h->reconnect_delay, GNUNET_YES));
233 GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h);
234 h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay);
239 * Type of a function to call when we receive a message
243 * @param msg message received, NULL on timeout or fatal error
246 message_handler (void *cls,
247 const struct GNUNET_MessageHeader *msg)
249 struct GNUNET_IDENTITY_Handle *h = cls;
250 struct GNUNET_IDENTITY_Operation *op;
251 struct GNUNET_IDENTITY_Ego *ego;
252 const struct GNUNET_IDENTITY_ResultCodeMessage *rcm;
253 const struct GNUNET_IDENTITY_UpdateMessage *um;
254 const struct GNUNET_IDENTITY_SetDefaultMessage *sdm;
255 struct GNUNET_CRYPTO_EccPublicKey pub;
256 struct GNUNET_HashCode id;
263 reschedule_connect (h);
266 LOG (GNUNET_ERROR_TYPE_DEBUG,
267 "Received message of type %d from identity service\n",
269 size = ntohs (msg->size);
270 switch (ntohs (msg->type))
272 case GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE:
273 if (size < sizeof (struct GNUNET_IDENTITY_ResultCodeMessage))
276 reschedule_connect (h);
279 rcm = (const struct GNUNET_IDENTITY_ResultCodeMessage *) msg;
280 str = (const char *) &rcm[1];
281 if ( (size > sizeof (struct GNUNET_IDENTITY_ResultCodeMessage)) &&
282 ('\0' != str[size - sizeof (struct GNUNET_IDENTITY_ResultCodeMessage) - 1]) )
285 reschedule_connect (h);
288 if (size == sizeof (struct GNUNET_IDENTITY_ResultCodeMessage))
292 GNUNET_CONTAINER_DLL_remove (h->op_head,
295 if (NULL != op->cont)
298 else if (NULL != op->cb)
299 op->cb (op->cls, NULL, NULL, NULL);
302 case GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE:
303 if (size < sizeof (struct GNUNET_IDENTITY_UpdateMessage))
306 reschedule_connect (h);
309 um = (const struct GNUNET_IDENTITY_UpdateMessage *) msg;
310 name_len = ntohs (um->name_len);
312 str = (const char *) &um[1];
313 if ( (size != name_len + sizeof (struct GNUNET_IDENTITY_UpdateMessage)) ||
315 ('\0' != str[name_len - 1])) )
318 reschedule_connect (h);
321 if (GNUNET_YES == ntohs (um->end_of_list))
323 /* end of initial list of data */
325 h->cb (h->cb_cls, NULL, NULL, NULL);
328 GNUNET_CRYPTO_ecc_key_get_public (&um->private_key,
330 GNUNET_CRYPTO_hash (&pub, sizeof (pub), &id);
334 str = (const char *) &um[1];
335 ego = GNUNET_CONTAINER_multihashmap_get (h->egos,
339 /* ego was created */
342 /* deletion of unknown ego? not allowed */
344 reschedule_connect (h);
347 ego = GNUNET_new (struct GNUNET_IDENTITY_Ego);
348 ego->pk = GNUNET_new (struct GNUNET_CRYPTO_EccPrivateKey);
349 *ego->pk = um->private_key;
350 ego->name = GNUNET_strdup (str);
352 GNUNET_assert (GNUNET_YES ==
353 GNUNET_CONTAINER_multihashmap_put (h->egos,
356 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
358 /* inform application about change */
366 /* ego was deleted */
367 GNUNET_assert (GNUNET_YES ==
368 GNUNET_CONTAINER_multihashmap_remove (h->egos,
371 GNUNET_CRYPTO_ecc_key_free (ego->pk);
372 GNUNET_free (ego->name);
377 /* ego changed name */
378 GNUNET_free (ego->name);
379 ego->name = GNUNET_strdup (str);
382 case GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT:
383 if (size < sizeof (struct GNUNET_IDENTITY_SetDefaultMessage))
386 reschedule_connect (h);
389 sdm = (const struct GNUNET_IDENTITY_SetDefaultMessage *) msg;
390 GNUNET_break (0 == ntohs (sdm->reserved));
391 name_len = ntohs (sdm->name_len);
392 str = (const char *) &sdm[1];
393 if ( (size != name_len + sizeof (struct GNUNET_IDENTITY_SetDefaultMessage)) ||
395 ('\0' != str[name_len - 1]) ) )
398 reschedule_connect (h);
401 GNUNET_CRYPTO_ecc_key_get_public (&sdm->private_key,
403 GNUNET_CRYPTO_hash (&pub, sizeof (pub), &id);
407 str = (const char *) &sdm[1];
408 ego = GNUNET_CONTAINER_multihashmap_get (h->egos,
413 reschedule_connect (h);
417 GNUNET_CONTAINER_DLL_remove (h->op_head,
429 reschedule_connect (h);
432 GNUNET_CLIENT_receive (h->client, &message_handler, h,
433 GNUNET_TIME_UNIT_FOREVER_REL);
438 * Schedule transmission of the next message from our queue.
440 * @param h identity handle
443 transmit_next (struct GNUNET_IDENTITY_Handle *h);
447 * Transmit next message to service.
449 * @param cls the 'struct GNUNET_IDENTITY_Handle'.
450 * @param size number of bytes available in buf
451 * @param buf where to copy the message
452 * @return number of bytes copied to buf
455 send_next_message (void *cls,
459 struct GNUNET_IDENTITY_Handle *h = cls;
460 struct GNUNET_IDENTITY_Operation *op = h->op_head;
466 ret = ntohs (op->msg->size);
469 reschedule_connect (h);
472 LOG (GNUNET_ERROR_TYPE_DEBUG,
473 "Sending message of type %d to identity service\n",
474 ntohs (op->msg->type));
475 memcpy (buf, op->msg, ret);
476 if ( (NULL == op->cont) &&
479 GNUNET_CONTAINER_DLL_remove (h->op_head,
485 if (GNUNET_NO == h->in_receive)
487 h->in_receive = GNUNET_YES;
488 GNUNET_CLIENT_receive (h->client,
490 GNUNET_TIME_UNIT_FOREVER_REL);
497 * Schedule transmission of the next message from our queue.
499 * @param h identity handle
502 transmit_next (struct GNUNET_IDENTITY_Handle *h)
504 struct GNUNET_IDENTITY_Operation *op = h->op_head;
506 GNUNET_assert (NULL == h->th);
509 if (NULL == h->client)
511 h->th = GNUNET_CLIENT_notify_transmit_ready (h->client,
512 ntohs (op->msg->size),
513 GNUNET_TIME_UNIT_FOREVER_REL,
521 * Try again to connect to network size estimation service.
523 * @param cls the handle to the transport service
524 * @param tc scheduler context
527 reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
529 struct GNUNET_IDENTITY_Handle *h = cls;
530 struct GNUNET_IDENTITY_Operation *op;
531 struct GNUNET_MessageHeader msg;
533 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
534 LOG (GNUNET_ERROR_TYPE_DEBUG,
535 "Connecting to identity service.\n");
536 GNUNET_assert (NULL == h->client);
537 h->client = GNUNET_CLIENT_connect ("identity", h->cfg);
538 GNUNET_assert (NULL != h->client);
539 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
540 sizeof (struct GNUNET_MessageHeader));
542 op->msg = (const struct GNUNET_MessageHeader *) &op[1];
543 msg.size = htons (sizeof (msg));
544 msg.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_START);
545 memcpy (&op[1], &msg, sizeof (msg));
546 GNUNET_CONTAINER_DLL_insert (h->op_head,
550 GNUNET_assert (NULL != h->th);
555 * Connect to the identity service.
557 * @param cfg the configuration to use
558 * @param cb function to call on all identity events, can be NULL
559 * @param cb_cls closure for 'cb'
560 * @return handle to use
562 struct GNUNET_IDENTITY_Handle *
563 GNUNET_IDENTITY_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
564 GNUNET_IDENTITY_Callback cb,
567 struct GNUNET_IDENTITY_Handle *h;
569 h = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Handle));
573 h->egos = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_YES);
574 h->reconnect_delay = GNUNET_TIME_UNIT_ZERO;
575 h->reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect, h);
581 * Obtain the ECC key associated with a ego.
584 * @return associated ECC key, valid as long as the ego is valid
586 const struct GNUNET_CRYPTO_EccPrivateKey *
587 GNUNET_IDENTITY_ego_get_private_key (const struct GNUNET_IDENTITY_Ego *ego)
594 * Get the identifier (public key) of an ego.
596 * @param ego identity handle with the private key
597 * @param pk set to ego's public key
600 GNUNET_IDENTITY_ego_get_public_key (const struct GNUNET_IDENTITY_Ego *ego,
601 struct GNUNET_CRYPTO_EccPublicKey *pk)
603 GNUNET_CRYPTO_ecc_key_get_public (ego->pk,
609 * Obtain the identity that is currently preferred/default
612 * @param id identity service to query
613 * @param service_name for which service is an identity wanted
614 * @param cb function to call with the result (will only be called once)
615 * @param cb_cls closure for cb
616 * @return handle to abort the operation
618 struct GNUNET_IDENTITY_Operation *
619 GNUNET_IDENTITY_get (struct GNUNET_IDENTITY_Handle *id,
620 const char *service_name,
621 GNUNET_IDENTITY_Callback cb,
624 struct GNUNET_IDENTITY_Operation *op;
625 struct GNUNET_IDENTITY_GetDefaultMessage *gdm;
628 slen = strlen (service_name) + 1;
629 if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_GetDefaultMessage))
634 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
635 sizeof (struct GNUNET_IDENTITY_GetDefaultMessage) +
640 gdm = (struct GNUNET_IDENTITY_GetDefaultMessage *) &op[1];
641 gdm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT);
642 gdm->header.size = htons (sizeof (struct GNUNET_IDENTITY_GetDefaultMessage) +
644 gdm->name_len = htons (slen);
645 gdm->reserved = htons (0);
646 memcpy (&gdm[1], service_name, slen);
647 op->msg = &gdm->header;
648 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
658 * Set the preferred/default identity for a service.
660 * @param id identity service to inform
661 * @param service_name for which service is an identity set
662 * @param ego new default identity to be set for this service
663 * @param cont function to call once the operation finished
664 * @param cont_cls closure for cont
665 * @return handle to abort the operation
667 struct GNUNET_IDENTITY_Operation *
668 GNUNET_IDENTITY_set (struct GNUNET_IDENTITY_Handle *id,
669 const char *service_name,
670 struct GNUNET_IDENTITY_Ego *ego,
671 GNUNET_IDENTITY_Continuation cont,
674 struct GNUNET_IDENTITY_Operation *op;
675 struct GNUNET_IDENTITY_SetDefaultMessage *sdm;
678 slen = strlen (service_name) + 1;
679 if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_SetDefaultMessage))
684 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
685 sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) +
690 sdm = (struct GNUNET_IDENTITY_SetDefaultMessage *) &op[1];
691 sdm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT);
692 sdm->header.size = htons (sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) +
694 sdm->name_len = htons (slen);
695 sdm->reserved = htons (0);
696 sdm->private_key = *ego->pk;
697 memcpy (&sdm[1], service_name, slen);
698 op->msg = &sdm->header;
699 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
709 * Create a new identity with the given name.
711 * @param id identity service to use
712 * @param name desired name
713 * @param cont function to call with the result (will only be called once)
714 * @param cont_cls closure for cont
715 * @return handle to abort the operation
717 struct GNUNET_IDENTITY_Operation *
718 GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *id,
720 GNUNET_IDENTITY_Continuation cont,
723 struct GNUNET_IDENTITY_Operation *op;
724 struct GNUNET_IDENTITY_CreateRequestMessage *crm;
725 struct GNUNET_CRYPTO_EccPrivateKey *pk;
728 slen = strlen (name) + 1;
729 pk = GNUNET_CRYPTO_ecc_key_create ();
731 if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_CreateRequestMessage))
734 GNUNET_CRYPTO_ecc_key_free (pk);
737 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
738 sizeof (struct GNUNET_IDENTITY_CreateRequestMessage) +
743 crm = (struct GNUNET_IDENTITY_CreateRequestMessage *) &op[1];
744 crm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_CREATE);
745 crm->header.size = htons (sizeof (struct GNUNET_IDENTITY_CreateRequestMessage) +
747 crm->name_len = htons (slen);
748 crm->reserved = htons (0);
749 crm->private_key = *pk;
750 memcpy (&crm[1], name, slen);
751 op->msg = &crm->header;
752 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
757 GNUNET_CRYPTO_ecc_key_free (pk);
763 * Renames an existing identity.
765 * @param id identity service to use
766 * @param old_name old name
767 * @param new_name desired new name
768 * @param cb function to call with the result (will only be called once)
769 * @param cb_cls closure for cb
770 * @return handle to abort the operation
772 struct GNUNET_IDENTITY_Operation *
773 GNUNET_IDENTITY_rename (struct GNUNET_IDENTITY_Handle *id,
774 const char *old_name,
775 const char *new_name,
776 GNUNET_IDENTITY_Continuation cb,
779 struct GNUNET_IDENTITY_Operation *op;
780 struct GNUNET_IDENTITY_RenameMessage *grm;
785 slen_old = strlen (old_name) + 1;
786 slen_new = strlen (new_name) + 1;
787 if ( (slen_old >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
788 (slen_new >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
789 (slen_old + slen_new >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_RenameMessage)) )
794 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
795 sizeof (struct GNUNET_IDENTITY_RenameMessage) +
796 slen_old + slen_new);
800 grm = (struct GNUNET_IDENTITY_RenameMessage *) &op[1];
801 grm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_RENAME);
802 grm->header.size = htons (sizeof (struct GNUNET_IDENTITY_RenameMessage) +
803 slen_old + slen_new);
804 grm->old_name_len = htons (slen_old);
805 grm->new_name_len = htons (slen_new);
806 dst = (char *) &grm[1];
807 memcpy (dst, old_name, slen_old);
808 memcpy (&dst[slen_old], new_name, slen_new);
809 op->msg = &grm->header;
810 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
820 * Delete an existing identity.
822 * @param id identity service to use
823 * @param name name of the identity to delete
824 * @param cb function to call with the result (will only be called once)
825 * @param cb_cls closure for cb
826 * @return handle to abort the operation
828 struct GNUNET_IDENTITY_Operation *
829 GNUNET_IDENTITY_delete (struct GNUNET_IDENTITY_Handle *id,
831 GNUNET_IDENTITY_Continuation cb,
834 struct GNUNET_IDENTITY_Operation *op;
835 struct GNUNET_IDENTITY_DeleteMessage *gdm;
838 slen = strlen (name) + 1;
839 if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_DeleteMessage))
844 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
845 sizeof (struct GNUNET_IDENTITY_DeleteMessage) +
850 gdm = (struct GNUNET_IDENTITY_DeleteMessage *) &op[1];
851 gdm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_DELETE);
852 gdm->header.size = htons (sizeof (struct GNUNET_IDENTITY_DeleteMessage) +
854 gdm->name_len = htons (slen);
855 gdm->reserved = htons (0);
856 memcpy (&gdm[1], name, slen);
857 op->msg = &gdm->header;
858 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
868 * Cancel an identity operation. Note that the operation MAY still
869 * be executed; this merely cancels the continuation; if the request
870 * was already transmitted, the service may still choose to complete
873 * @param op operation to cancel
876 GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op)
878 struct GNUNET_IDENTITY_Handle *h = op->h;
880 if ( (h->op_head != op) ||
881 (NULL == h->client) )
883 /* request not active, can simply remove */
884 GNUNET_CONTAINER_DLL_remove (h->op_head,
892 /* request active but not yet with service, can still abort */
893 GNUNET_CLIENT_notify_transmit_ready_cancel (h->th);
895 GNUNET_CONTAINER_DLL_remove (h->op_head,
902 /* request active with service, simply ensure continuations are not called */
909 * Free ego from hash map.
911 * @param cls identity service handle
913 * @param value ego to free
914 * @return GNUNET_OK (continue to iterate)
918 const struct GNUNET_HashCode *key,
921 struct GNUNET_IDENTITY_Handle *h = cls;
922 struct GNUNET_IDENTITY_Ego *ego = value;
928 GNUNET_CRYPTO_ecc_key_free (ego->pk);
929 GNUNET_free (ego->name);
936 * Disconnect from identity service
938 * @param h handle to destroy
941 GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle *h)
943 GNUNET_assert (NULL != h);
944 GNUNET_assert (h->op_head == h->op_tail);
945 if (h->reconnect_task != GNUNET_SCHEDULER_NO_TASK)
947 GNUNET_SCHEDULER_cancel (h->reconnect_task);
948 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
952 GNUNET_CLIENT_notify_transmit_ready_cancel (h->th);
957 GNUNET_CONTAINER_multihashmap_iterate (h->egos,
960 GNUNET_CONTAINER_multihashmap_destroy (h->egos);
963 if (NULL != h->client)
965 GNUNET_CLIENT_disconnect (h->client);
971 /* end of identity_api.c */