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 /* Note: we know which service this should be for, so we're not
402 really using 'str' henceforth */
403 GNUNET_CRYPTO_ecc_key_get_public (&sdm->private_key,
405 GNUNET_CRYPTO_hash (&pub, sizeof (pub), &id);
406 ego = GNUNET_CONTAINER_multihashmap_get (h->egos,
411 reschedule_connect (h);
415 GNUNET_CONTAINER_DLL_remove (h->op_head,
418 GNUNET_free (ego->name);
428 reschedule_connect (h);
431 GNUNET_CLIENT_receive (h->client, &message_handler, h,
432 GNUNET_TIME_UNIT_FOREVER_REL);
437 * Schedule transmission of the next message from our queue.
439 * @param h identity handle
442 transmit_next (struct GNUNET_IDENTITY_Handle *h);
446 * Transmit next message to service.
448 * @param cls the 'struct GNUNET_IDENTITY_Handle'.
449 * @param size number of bytes available in buf
450 * @param buf where to copy the message
451 * @return number of bytes copied to buf
454 send_next_message (void *cls,
458 struct GNUNET_IDENTITY_Handle *h = cls;
459 struct GNUNET_IDENTITY_Operation *op = h->op_head;
465 ret = ntohs (op->msg->size);
468 reschedule_connect (h);
471 LOG (GNUNET_ERROR_TYPE_DEBUG,
472 "Sending message of type %d to identity service\n",
473 ntohs (op->msg->type));
474 memcpy (buf, op->msg, ret);
475 if ( (NULL == op->cont) &&
478 GNUNET_CONTAINER_DLL_remove (h->op_head,
484 if (GNUNET_NO == h->in_receive)
486 h->in_receive = GNUNET_YES;
487 GNUNET_CLIENT_receive (h->client,
489 GNUNET_TIME_UNIT_FOREVER_REL);
496 * Schedule transmission of the next message from our queue.
498 * @param h identity handle
501 transmit_next (struct GNUNET_IDENTITY_Handle *h)
503 struct GNUNET_IDENTITY_Operation *op = h->op_head;
505 GNUNET_assert (NULL == h->th);
508 if (NULL == h->client)
510 h->th = GNUNET_CLIENT_notify_transmit_ready (h->client,
511 ntohs (op->msg->size),
512 GNUNET_TIME_UNIT_FOREVER_REL,
520 * Try again to connect to network size estimation service.
522 * @param cls the handle to the transport service
523 * @param tc scheduler context
526 reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
528 struct GNUNET_IDENTITY_Handle *h = cls;
529 struct GNUNET_IDENTITY_Operation *op;
530 struct GNUNET_MessageHeader msg;
532 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
533 LOG (GNUNET_ERROR_TYPE_DEBUG,
534 "Connecting to identity service.\n");
535 GNUNET_assert (NULL == h->client);
536 h->client = GNUNET_CLIENT_connect ("identity", h->cfg);
537 GNUNET_assert (NULL != h->client);
538 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
539 sizeof (struct GNUNET_MessageHeader));
541 op->msg = (const struct GNUNET_MessageHeader *) &op[1];
542 msg.size = htons (sizeof (msg));
543 msg.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_START);
544 memcpy (&op[1], &msg, sizeof (msg));
545 GNUNET_CONTAINER_DLL_insert (h->op_head,
549 GNUNET_assert (NULL != h->th);
554 * Connect to the identity service.
556 * @param cfg the configuration to use
557 * @param cb function to call on all identity events, can be NULL
558 * @param cb_cls closure for 'cb'
559 * @return handle to use
561 struct GNUNET_IDENTITY_Handle *
562 GNUNET_IDENTITY_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
563 GNUNET_IDENTITY_Callback cb,
566 struct GNUNET_IDENTITY_Handle *h;
568 h = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Handle));
572 h->egos = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_YES);
573 h->reconnect_delay = GNUNET_TIME_UNIT_ZERO;
574 h->reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect, h);
580 * Obtain the ECC key associated with a ego.
583 * @return associated ECC key, valid as long as the ego is valid
585 const struct GNUNET_CRYPTO_EccPrivateKey *
586 GNUNET_IDENTITY_ego_get_private_key (const struct GNUNET_IDENTITY_Ego *ego)
593 * Get the identifier (public key) of an ego.
595 * @param ego identity handle with the private key
596 * @param pk set to ego's public key
599 GNUNET_IDENTITY_ego_get_public_key (const struct GNUNET_IDENTITY_Ego *ego,
600 struct GNUNET_CRYPTO_EccPublicKey *pk)
602 GNUNET_CRYPTO_ecc_key_get_public (ego->pk,
608 * Obtain the identity that is currently preferred/default
611 * @param id identity service to query
612 * @param service_name for which service is an identity wanted
613 * @param cb function to call with the result (will only be called once)
614 * @param cb_cls closure for cb
615 * @return handle to abort the operation
617 struct GNUNET_IDENTITY_Operation *
618 GNUNET_IDENTITY_get (struct GNUNET_IDENTITY_Handle *id,
619 const char *service_name,
620 GNUNET_IDENTITY_Callback cb,
623 struct GNUNET_IDENTITY_Operation *op;
624 struct GNUNET_IDENTITY_GetDefaultMessage *gdm;
627 slen = strlen (service_name) + 1;
628 if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_GetDefaultMessage))
633 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
634 sizeof (struct GNUNET_IDENTITY_GetDefaultMessage) +
639 gdm = (struct GNUNET_IDENTITY_GetDefaultMessage *) &op[1];
640 gdm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT);
641 gdm->header.size = htons (sizeof (struct GNUNET_IDENTITY_GetDefaultMessage) +
643 gdm->name_len = htons (slen);
644 gdm->reserved = htons (0);
645 memcpy (&gdm[1], service_name, slen);
646 op->msg = &gdm->header;
647 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
657 * Set the preferred/default identity for a service.
659 * @param id identity service to inform
660 * @param service_name for which service is an identity set
661 * @param ego new default identity to be set for this service
662 * @param cont function to call once the operation finished
663 * @param cont_cls closure for cont
664 * @return handle to abort the operation
666 struct GNUNET_IDENTITY_Operation *
667 GNUNET_IDENTITY_set (struct GNUNET_IDENTITY_Handle *id,
668 const char *service_name,
669 struct GNUNET_IDENTITY_Ego *ego,
670 GNUNET_IDENTITY_Continuation cont,
673 struct GNUNET_IDENTITY_Operation *op;
674 struct GNUNET_IDENTITY_SetDefaultMessage *sdm;
677 slen = strlen (service_name) + 1;
678 if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_SetDefaultMessage))
683 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
684 sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) +
689 sdm = (struct GNUNET_IDENTITY_SetDefaultMessage *) &op[1];
690 sdm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT);
691 sdm->header.size = htons (sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) +
693 sdm->name_len = htons (slen);
694 sdm->reserved = htons (0);
695 sdm->private_key = *ego->pk;
696 memcpy (&sdm[1], service_name, slen);
697 op->msg = &sdm->header;
698 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
708 * Create a new identity with the given name.
710 * @param id identity service to use
711 * @param name desired name
712 * @param cont function to call with the result (will only be called once)
713 * @param cont_cls closure for cont
714 * @return handle to abort the operation
716 struct GNUNET_IDENTITY_Operation *
717 GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *id,
719 GNUNET_IDENTITY_Continuation cont,
722 struct GNUNET_IDENTITY_Operation *op;
723 struct GNUNET_IDENTITY_CreateRequestMessage *crm;
724 struct GNUNET_CRYPTO_EccPrivateKey *pk;
727 slen = strlen (name) + 1;
728 pk = GNUNET_CRYPTO_ecc_key_create ();
730 if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_CreateRequestMessage))
733 GNUNET_CRYPTO_ecc_key_free (pk);
736 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
737 sizeof (struct GNUNET_IDENTITY_CreateRequestMessage) +
742 crm = (struct GNUNET_IDENTITY_CreateRequestMessage *) &op[1];
743 crm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_CREATE);
744 crm->header.size = htons (sizeof (struct GNUNET_IDENTITY_CreateRequestMessage) +
746 crm->name_len = htons (slen);
747 crm->reserved = htons (0);
748 crm->private_key = *pk;
749 memcpy (&crm[1], name, slen);
750 op->msg = &crm->header;
751 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
756 GNUNET_CRYPTO_ecc_key_free (pk);
762 * Renames an existing identity.
764 * @param id identity service to use
765 * @param old_name old name
766 * @param new_name desired new name
767 * @param cb function to call with the result (will only be called once)
768 * @param cb_cls closure for cb
769 * @return handle to abort the operation
771 struct GNUNET_IDENTITY_Operation *
772 GNUNET_IDENTITY_rename (struct GNUNET_IDENTITY_Handle *id,
773 const char *old_name,
774 const char *new_name,
775 GNUNET_IDENTITY_Continuation cb,
778 struct GNUNET_IDENTITY_Operation *op;
779 struct GNUNET_IDENTITY_RenameMessage *grm;
784 slen_old = strlen (old_name) + 1;
785 slen_new = strlen (new_name) + 1;
786 if ( (slen_old >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
787 (slen_new >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
788 (slen_old + slen_new >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_RenameMessage)) )
793 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
794 sizeof (struct GNUNET_IDENTITY_RenameMessage) +
795 slen_old + slen_new);
799 grm = (struct GNUNET_IDENTITY_RenameMessage *) &op[1];
800 grm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_RENAME);
801 grm->header.size = htons (sizeof (struct GNUNET_IDENTITY_RenameMessage) +
802 slen_old + slen_new);
803 grm->old_name_len = htons (slen_old);
804 grm->new_name_len = htons (slen_new);
805 dst = (char *) &grm[1];
806 memcpy (dst, old_name, slen_old);
807 memcpy (&dst[slen_old], new_name, slen_new);
808 op->msg = &grm->header;
809 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
819 * Delete an existing identity.
821 * @param id identity service to use
822 * @param name name of the identity to delete
823 * @param cb function to call with the result (will only be called once)
824 * @param cb_cls closure for cb
825 * @return handle to abort the operation
827 struct GNUNET_IDENTITY_Operation *
828 GNUNET_IDENTITY_delete (struct GNUNET_IDENTITY_Handle *id,
830 GNUNET_IDENTITY_Continuation cb,
833 struct GNUNET_IDENTITY_Operation *op;
834 struct GNUNET_IDENTITY_DeleteMessage *gdm;
837 slen = strlen (name) + 1;
838 if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_DeleteMessage))
843 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
844 sizeof (struct GNUNET_IDENTITY_DeleteMessage) +
849 gdm = (struct GNUNET_IDENTITY_DeleteMessage *) &op[1];
850 gdm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_DELETE);
851 gdm->header.size = htons (sizeof (struct GNUNET_IDENTITY_DeleteMessage) +
853 gdm->name_len = htons (slen);
854 gdm->reserved = htons (0);
855 memcpy (&gdm[1], name, slen);
856 op->msg = &gdm->header;
857 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
867 * Cancel an identity operation. Note that the operation MAY still
868 * be executed; this merely cancels the continuation; if the request
869 * was already transmitted, the service may still choose to complete
872 * @param op operation to cancel
875 GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op)
877 struct GNUNET_IDENTITY_Handle *h = op->h;
879 if ( (h->op_head != op) ||
880 (NULL == h->client) )
882 /* request not active, can simply remove */
883 GNUNET_CONTAINER_DLL_remove (h->op_head,
891 /* request active but not yet with service, can still abort */
892 GNUNET_CLIENT_notify_transmit_ready_cancel (h->th);
894 GNUNET_CONTAINER_DLL_remove (h->op_head,
901 /* request active with service, simply ensure continuations are not called */
908 * Free ego from hash map.
910 * @param cls identity service handle
912 * @param value ego to free
913 * @return GNUNET_OK (continue to iterate)
917 const struct GNUNET_HashCode *key,
920 struct GNUNET_IDENTITY_Handle *h = cls;
921 struct GNUNET_IDENTITY_Ego *ego = value;
927 GNUNET_CRYPTO_ecc_key_free (ego->pk);
928 GNUNET_free (ego->name);
935 * Disconnect from identity service
937 * @param h handle to destroy
940 GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle *h)
942 GNUNET_assert (NULL != h);
943 GNUNET_assert (h->op_head == h->op_tail);
944 if (h->reconnect_task != GNUNET_SCHEDULER_NO_TASK)
946 GNUNET_SCHEDULER_cancel (h->reconnect_task);
947 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
951 GNUNET_CLIENT_notify_transmit_ready_cancel (h->th);
956 GNUNET_CONTAINER_multihashmap_iterate (h->egos,
959 GNUNET_CONTAINER_multihashmap_destroy (h->egos);
962 if (NULL != h->client)
964 GNUNET_CLIENT_disconnect (h->client);
970 /* end of identity_api.c */