GNUnet  0.11.x
identity_api.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2013, 2016 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
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  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
26 #include "platform.h"
27 #include "gnunet_util_lib.h"
28 #include "gnunet_constants.h"
29 #include "gnunet_protocols.h"
31 #include "identity.h"
32 
33 #define LOG(kind, ...) GNUNET_log_from (kind, "identity-api", __VA_ARGS__)
34 
35 
40 {
45 
50 
55 
60  const struct GNUNET_MessageHeader *msg;
61 
67 
73 
78 
84 
88  void *cls;
89 };
90 
91 
96 {
101 
106 
112 
117 
121  void *cb_cls;
122 
127 
132 
137 
141  struct GNUNET_TIME_Relative reconnect_delay;
142 
147 };
148 
149 
155 const struct GNUNET_IDENTITY_Ego *
157 {
158  static struct GNUNET_IDENTITY_Ego anon;
159  struct GNUNET_CRYPTO_EcdsaPublicKey pub;
160 
161  if (NULL != anon.pk)
162  return &anon;
163  anon.pk = (struct GNUNET_CRYPTO_EcdsaPrivateKey *)
166  GNUNET_CRYPTO_hash (&pub, sizeof(pub), &anon.id);
167  return &anon;
168 }
169 
170 
176 static void
177 reconnect (void *cls);
178 
179 
188 static int
189 free_ego (void *cls, const struct GNUNET_HashCode *key, void *value)
190 {
191  struct GNUNET_IDENTITY_Handle *h = cls;
192  struct GNUNET_IDENTITY_Ego *ego = value;
193 
194  if (NULL != h->cb)
195  h->cb (h->cb_cls, ego, &ego->ctx, NULL);
196  GNUNET_free (ego->pk);
197  GNUNET_free (ego->name);
199  GNUNET_CONTAINER_multihashmap_remove (h->egos, key, value));
200  GNUNET_free (ego);
201  return GNUNET_OK;
202 }
203 
204 
210 static void
212 {
214 
215  GNUNET_assert (NULL == h->reconnect_task);
216 
217  if (NULL != h->mq)
218  {
219  GNUNET_MQ_destroy (h->mq);
220  h->mq = NULL;
221  }
222  while (NULL != (op = h->op_head))
223  {
225  if (NULL != op->cont)
226  op->cont (op->cls, "Error in communication with the identity service");
227  else if (NULL != op->cb)
228  op->cb (op->cls, NULL, NULL, NULL);
229  else if (NULL != op->create_cont)
230  op->create_cont (op->cls,
231  NULL,
232  "Failed to communicate with the identity service");
233  GNUNET_free_non_null (op->pk);
234  GNUNET_free (op);
235  }
238  "Scheduling task to reconnect to identity service in %s.\n",
240  h->reconnect_task =
243 }
244 
245 
254 static void
256 {
257  struct GNUNET_IDENTITY_Handle *h = cls;
258 
259  reschedule_connect (h);
260 }
261 
262 
271 static int
273 {
274  if (sizeof(*rcm) != htons (rcm->header.size))
276  return GNUNET_OK;
277 }
278 
279 
286 static void
288 {
289  struct GNUNET_IDENTITY_Handle *h = cls;
291  uint16_t size = ntohs (rcm->header.size) - sizeof(*rcm);
292  const char *str = (0 == size) ? NULL : (const char *) &rcm[1];
293 
294  op = h->op_head;
295  if (NULL == op)
296  {
297  GNUNET_break (0);
298  reschedule_connect (h);
299  return;
300  }
302  if (NULL != op->cont)
303  op->cont (op->cls, str);
304  else if (NULL != op->cb)
305  op->cb (op->cls, NULL, NULL, NULL);
306  else if (NULL != op->create_cont)
307  op->create_cont (op->cls, (NULL == str) ? op->pk : NULL, str);
308  GNUNET_free_non_null (op->pk);
309  GNUNET_free (op);
310 }
311 
312 
320 static int
321 check_identity_update (void *cls, const struct UpdateMessage *um)
322 {
323  uint16_t size = ntohs (um->header.size);
324  uint16_t name_len = ntohs (um->name_len);
325  const char *str = (const char *) &um[1];
326 
327  if ((size != name_len + sizeof(struct UpdateMessage)) ||
328  ((0 != name_len) && ('\0' != str[name_len - 1])))
329  {
330  GNUNET_break (0);
331  return GNUNET_SYSERR;
332  }
333  return GNUNET_OK;
334 }
335 
336 
343 static void
344 handle_identity_update (void *cls, const struct UpdateMessage *um)
345 {
346  struct GNUNET_IDENTITY_Handle *h = cls;
347  uint16_t name_len = ntohs (um->name_len);
348  const char *str = (0 == name_len) ? NULL : (const char *) &um[1];
349  struct GNUNET_CRYPTO_EcdsaPublicKey pub;
350  struct GNUNET_HashCode id;
351  struct GNUNET_IDENTITY_Ego *ego;
352 
353  if (GNUNET_YES == ntohs (um->end_of_list))
354  {
355  /* end of initial list of data */
356  if (NULL != h->cb)
357  h->cb (h->cb_cls, NULL, NULL, NULL);
358  return;
359  }
361  GNUNET_CRYPTO_hash (&pub, sizeof(pub), &id);
362  ego = GNUNET_CONTAINER_multihashmap_get (h->egos, &id);
363  if (NULL == ego)
364  {
365  /* ego was created */
366  if (NULL == str)
367  {
368  /* deletion of unknown ego? not allowed */
369  GNUNET_break (0);
370  reschedule_connect (h);
371  return;
372  }
373  ego = GNUNET_new (struct GNUNET_IDENTITY_Ego);
375  *ego->pk = um->private_key;
376  ego->name = GNUNET_strdup (str);
377  ego->id = id;
380  h->egos,
381  &ego->id,
382  ego,
384  }
385  if (NULL == str)
386  {
387  /* ego was deleted */
389  &ego->id,
390  ego));
391  }
392  else
393  {
394  /* ego changed name */
395  GNUNET_free (ego->name);
396  ego->name = GNUNET_strdup (str);
397  }
398  /* inform application about change */
399  if (NULL != h->cb)
400  h->cb (h->cb_cls, ego, &ego->ctx, str);
401  /* complete deletion */
402  if (NULL == str)
403  {
404  GNUNET_free (ego->pk);
405  GNUNET_free (ego->name);
406  GNUNET_free (ego);
407  }
408 }
409 
410 
419 static int
421 {
422  uint16_t size = ntohs (sdm->header.size) - sizeof(*sdm);
423  uint16_t name_len = ntohs (sdm->name_len);
424  const char *str = (const char *) &sdm[1];
425 
426  if ((size != name_len) || ((0 != name_len) && ('\0' != str[name_len - 1])))
427  {
428  GNUNET_break (0);
429  return GNUNET_SYSERR;
430  }
431  GNUNET_break (0 == ntohs (sdm->reserved));
432  return GNUNET_OK;
433 }
434 
435 
443 static void
445 {
446  struct GNUNET_IDENTITY_Handle *h = cls;
448  struct GNUNET_CRYPTO_EcdsaPublicKey pub;
449  struct GNUNET_HashCode id;
450  struct GNUNET_IDENTITY_Ego *ego;
451 
453  GNUNET_CRYPTO_hash (&pub, sizeof(pub), &id);
454  ego = GNUNET_CONTAINER_multihashmap_get (h->egos, &id);
455  if (NULL == ego)
456  {
457  GNUNET_break (0);
458  reschedule_connect (h);
459  return;
460  }
461  op = h->op_head;
462  if (NULL == op)
463  {
464  GNUNET_break (0);
465  reschedule_connect (h);
466  return;
467  }
469  "Received SET_DEFAULT message from identity service\n");
471  if (NULL != op->cb)
472  op->cb (op->cls, ego, &ego->ctx, ego->name);
473  GNUNET_free (op);
474 }
475 
476 
482 static void
483 reconnect (void *cls)
484 {
485  struct GNUNET_IDENTITY_Handle *h = cls;
486  struct GNUNET_MQ_MessageHandler handlers[] =
487  { GNUNET_MQ_hd_var_size (identity_result_code,
489  struct ResultCodeMessage,
490  h),
491  GNUNET_MQ_hd_var_size (identity_update,
493  struct UpdateMessage,
494  h),
495  GNUNET_MQ_hd_var_size (identity_set_default,
497  struct SetDefaultMessage,
498  h),
500  struct GNUNET_MQ_Envelope *env;
501  struct GNUNET_MessageHeader *msg;
502 
503  h->reconnect_task = NULL;
504  LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to identity service.\n");
505  GNUNET_assert (NULL == h->mq);
506  h->mq =
507  GNUNET_CLIENT_connect (h->cfg, "identity", handlers, &mq_error_handler, h);
508  if (NULL == h->mq)
509  return;
510  if (NULL != h->cb)
511  {
513  GNUNET_MQ_send (h->mq, env);
514  }
515 }
516 
517 
526 struct GNUNET_IDENTITY_Handle *
529  void *cb_cls)
530 {
531  struct GNUNET_IDENTITY_Handle *h;
532 
533  h = GNUNET_new (struct GNUNET_IDENTITY_Handle);
534  h->cfg = cfg;
535  h->cb = cb;
536  h->cb_cls = cb_cls;
538  reconnect (h);
539  if (NULL == h->mq)
540  {
541  GNUNET_free (h);
542  return NULL;
543  }
544  return h;
545 }
546 
547 
554 const struct GNUNET_CRYPTO_EcdsaPrivateKey *
556 {
557  return ego->pk;
558 }
559 
560 
567 void
570 {
572 }
573 
574 
587  const char *service_name,
589  void *cb_cls)
590 {
592  struct GNUNET_MQ_Envelope *env;
593  struct GetDefaultMessage *gdm;
594  size_t slen;
595 
596  if (NULL == h->mq)
597  return NULL;
598  GNUNET_assert (NULL != h->cb);
599  slen = strlen (service_name) + 1;
600  if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct GetDefaultMessage))
601  {
602  GNUNET_break (0);
603  return NULL;
604  }
606  op->h = h;
607  op->cb = cb;
608  op->cls = cb_cls;
610  env =
612  gdm->name_len = htons (slen);
613  gdm->reserved = htons (0);
614  GNUNET_memcpy (&gdm[1], service_name, slen);
615  GNUNET_MQ_send (h->mq, env);
616  return op;
617 }
618 
619 
632  const char *service_name,
633  struct GNUNET_IDENTITY_Ego *ego,
635  void *cont_cls)
636 {
638  struct GNUNET_MQ_Envelope *env;
639  struct SetDefaultMessage *sdm;
640  size_t slen;
641 
642  if (NULL == h->mq)
643  return NULL;
644  GNUNET_assert (NULL != h->cb);
645  slen = strlen (service_name) + 1;
646  if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct SetDefaultMessage))
647  {
648  GNUNET_break (0);
649  return NULL;
650  }
652  op->h = h;
653  op->cont = cont;
654  op->cls = cont_cls;
656  env =
658  sdm->name_len = htons (slen);
659  sdm->reserved = htons (0);
660  sdm->private_key = *ego->pk;
661  GNUNET_memcpy (&sdm[1], service_name, slen);
662  GNUNET_MQ_send (h->mq, env);
663  return op;
664 }
665 
666 
678  const char *name,
680  void *cont_cls)
681 {
683  struct GNUNET_MQ_Envelope *env;
684  struct CreateRequestMessage *crm;
686  size_t slen;
687 
688  if (NULL == h->mq)
689  return NULL;
690  slen = strlen (name) + 1;
691  if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct CreateRequestMessage))
692  {
693  GNUNET_break (0);
694  return NULL;
695  }
697  op->h = h;
698  op->create_cont = cont;
699  op->cls = cont_cls;
702  crm->name_len = htons (slen);
703  crm->reserved = htons (0);
705  crm->private_key = *pk;
706  op->pk = pk;
707  GNUNET_memcpy (&crm[1], name, slen);
708  GNUNET_MQ_send (h->mq, env);
709  return op;
710 }
711 
712 
725  const char *old_name,
726  const char *new_name,
728  void *cb_cls)
729 {
731  struct GNUNET_MQ_Envelope *env;
732  struct RenameMessage *grm;
733  size_t slen_old;
734  size_t slen_new;
735  char *dst;
736 
737  if (NULL == h->mq)
738  return NULL;
739  slen_old = strlen (old_name) + 1;
740  slen_new = strlen (new_name) + 1;
741  if ((slen_old >= GNUNET_MAX_MESSAGE_SIZE) ||
742  (slen_new >= GNUNET_MAX_MESSAGE_SIZE) ||
743  (slen_old + slen_new >=
744  GNUNET_MAX_MESSAGE_SIZE - sizeof(struct RenameMessage)))
745  {
746  GNUNET_break (0);
747  return NULL;
748  }
750  op->h = h;
751  op->cont = cb;
752  op->cls = cb_cls;
754  env = GNUNET_MQ_msg_extra (grm,
755  slen_old + slen_new,
757  grm->old_name_len = htons (slen_old);
758  grm->new_name_len = htons (slen_new);
759  dst = (char *) &grm[1];
760  GNUNET_memcpy (dst, old_name, slen_old);
761  GNUNET_memcpy (&dst[slen_old], new_name, slen_new);
762  GNUNET_MQ_send (h->mq, env);
763  return op;
764 }
765 
766 
778  const char *name,
780  void *cb_cls)
781 {
783  struct GNUNET_MQ_Envelope *env;
784  struct DeleteMessage *gdm;
785  size_t slen;
786 
787  if (NULL == h->mq)
788  return NULL;
789  slen = strlen (name) + 1;
790  if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct DeleteMessage))
791  {
792  GNUNET_break (0);
793  return NULL;
794  }
796  op->h = h;
797  op->cont = cb;
798  op->cls = cb_cls;
801  gdm->name_len = htons (slen);
802  gdm->reserved = htons (0);
803  GNUNET_memcpy (&gdm[1], name, slen);
804  GNUNET_MQ_send (h->mq, env);
805  return op;
806 }
807 
808 
817 void
819 {
820  op->cont = NULL;
821  op->cb = NULL;
822  op->create_cont = NULL;
823  if (NULL != op->pk)
824  {
825  GNUNET_free (op->pk);
826  op->pk = NULL;
827  }
828 }
829 
830 
836 void
838 {
840 
841  GNUNET_assert (NULL != h);
842  if (h->reconnect_task != NULL)
843  {
845  h->reconnect_task = NULL;
846  }
847  if (NULL != h->egos)
848  {
851  h->egos = NULL;
852  }
853  while (NULL != (op = h->op_head))
854  {
855  GNUNET_break (NULL == op->cont);
857  GNUNET_free_non_null (op->pk);
858  GNUNET_free (op);
859  }
860  if (NULL != h->mq)
861  {
862  GNUNET_MQ_destroy (h->mq);
863  h->mq = NULL;
864  }
865  GNUNET_free (h);
866 }
867 
868 
869 /* end of identity_api.c */
struct GNUNET_IDENTITY_Handle * GNUNET_IDENTITY_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_IDENTITY_Callback cb, void *cb_cls)
Connect to the identity service.
Definition: identity_api.c:527
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_CONTAINER_MultiHashMap * egos
Hash map from the hash of the public key to the respective GNUNET_IDENTITY_Ego handle.
Definition: identity_api.c:111
static void handle_identity_update(void *cls, const struct UpdateMessage *um)
Handle identity update message.
Definition: identity_api.c:344
uint16_t reserved
Always zero.
Definition: identity.h:179
struct GNUNET_CRYPTO_EcdsaPrivateKey private_key
The private key.
Definition: identity.h:154
#define GNUNET_MESSAGE_TYPE_IDENTITY_START
First message send from identity client to service (to subscribe to updates).
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_CRYPTO_ecdsa_key_get_anonymous(void)
Get the shared private key we use for anonymous users.
Definition: crypto_ecc.c:812
void GNUNET_IDENTITY_cancel(struct GNUNET_IDENTITY_Operation *op)
Cancel an identity operation.
Definition: identity_api.c:818
#define GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT
Client sets default identity; or service informs about default identity.
const struct GNUNET_MessageHeader * msg
Message to send to the identity service.
Definition: identity_api.c:60
Used from service to client as a result to the GET_DEFAULT message, used from client to service to SE...
Definition: identity.h:134
struct GNUNET_TIME_Relative reconnect_delay
Time for next connect retry.
Definition: identity_api.c:141
#define GNUNET_MESSAGE_TYPE_IDENTITY_DELETE
Delete identity (client->service).
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
void(* GNUNET_IDENTITY_Callback)(void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *name)
Method called to inform about the egos of this peer.
Common type definitions for the identity service and API.
static void handle_identity_result_code(void *cls, const struct ResultCodeMessage *rcm)
We received a result code from the service.
Definition: identity_api.c:287
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1057
void(* GNUNET_IDENTITY_CreateContinuation)(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk, const char *emsg)
Function called once the requested operation has been completed.
uint16_t reserved
Always zero.
Definition: identity.h:123
GNUNET_MQ_Error
Error codes for the queue.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE.
Definition: identity.h:82
struct GNUNET_IDENTITY_Operation * GNUNET_IDENTITY_delete(struct GNUNET_IDENTITY_Handle *h, const char *name, GNUNET_IDENTITY_Continuation cb, void *cb_cls)
Delete an existing identity.
Definition: identity_api.c:777
static void mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...
Definition: identity_api.c:255
struct GNUNET_IDENTITY_Operation * GNUNET_IDENTITY_create(struct GNUNET_IDENTITY_Handle *h, const char *name, GNUNET_IDENTITY_CreateContinuation cont, void *cont_cls)
Create a new identity with the given name.
Definition: identity_api.c:677
uint16_t name_len
Number of bytes in service name string including 0-termination, in NBO.
Definition: identity.h:144
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE.
Definition: identity.h:47
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_CRYPTO_ecdsa_key_create(void)
Create a new private key.
Definition: crypto_ecc.c:688
uint16_t name_len
Number of bytes in service name string including 0-termination, in NBO.
Definition: identity.h:118
struct GNUNET_IDENTITY_Operation * GNUNET_IDENTITY_set(struct GNUNET_IDENTITY_Handle *h, const char *service_name, struct GNUNET_IDENTITY_Ego *ego, GNUNET_IDENTITY_Continuation cont, void *cont_cls)
Set the preferred/default identity for a service.
Definition: identity_api.c:631
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:555
uint16_t old_name_len
Number of characters in the old name including 0-termination, in NBO.
Definition: identity.h:204
Client requests renaming of an identity.
Definition: identity.h:194
struct GNUNET_CRYPTO_EcdsaPrivateKey private_key
The private key.
Definition: identity.h:98
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t reserved
Always zero.
Definition: identity.h:235
struct GNUNET_IDENTITY_Operation * op_tail
Tail of active operations.
Definition: identity_api.c:131
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct GNUNET_IDENTITY_Operation * GNUNET_IDENTITY_get(struct GNUNET_IDENTITY_Handle *h, const char *service_name, GNUNET_IDENTITY_Callback cb, void *cb_cls)
Obtain the identity that is currently preferred/default for a service.
Definition: identity_api.c:586
#define GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE
Update about identity status from service to clients.
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Private ECC key encoded for transmission.
static int check_identity_result_code(void *cls, const struct ResultCodeMessage *rcm)
We received a result code from the service.
Definition: identity_api.c:272
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
uint16_t name_len
Number of bytes in identity name string including 0-termination, in NBO.
Definition: identity.h:174
Internal representation of the hash map.
struct GNUNET_CRYPTO_EcdsaPrivateKey private_key
The private key.
Definition: identity.h:184
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Handle for an operation with the identity service.
Definition: identity_api.c:39
char * name
Current name associated with this ego.
Definition: identity.h:255
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
static void reconnect(void *cls)
Try again to connect to the identity service.
Definition: identity_api.c:483
uint16_t reserved
Always zero.
Definition: identity.h:149
#define LOG(kind,...)
Definition: identity_api.c:33
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1253
Handle for an ego.
Definition: identity.h:245
#define GNUNET_MQ_check_zero_termination(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...
static char * value
Value of the record to add/remove.
GNUNET_IDENTITY_CreateContinuation create_cont
Continuation to invoke with the result of the transmission; cb and cb will be NULL in this case...
Definition: identity_api.c:72
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:48
Handle for the service.
Definition: identity_api.c:95
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
struct GNUNET_SCHEDULER_Task * reconnect_task
Task doing exponential back-off trying to reconnect.
Definition: identity_api.c:136
Client requests creation of an identity.
Definition: identity.h:164
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:687
struct GNUNET_CRYPTO_EcdsaPrivateKey * pk
Private key to return to create_cont, or NULL.
Definition: identity_api.c:77
static char * service_name
Option -s: service name (hash to get service descriptor)
Definition: gnunet-vpn.c:51
static int check_identity_update(void *cls, const struct UpdateMessage *um)
Check validity of identity update message.
Definition: identity_api.c:321
int GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: identity_api.c:100
void GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h)
Disconnect from identity service.
Definition: identity_api.c:837
GNUNET_IDENTITY_Continuation cont
Continuation to invoke with the result of the transmission; cb and create_cont will be NULL in this c...
Definition: identity_api.c:66
struct GNUNET_IDENTITY_Operation * op_head
Head of active operations.
Definition: identity_api.c:126
static void reschedule_connect(struct GNUNET_IDENTITY_Handle *h)
Reschedule a connect attempt to the service.
Definition: identity_api.c:211
A 512-bit hashcode.
Message handler for a specific message type.
struct GNUNET_HashCode id
Hash of the public key of this ego.
Definition: identity.h:265
Client requests deletion of an identity.
Definition: identity.h:220
There must only be one value per key; storing a value should fail if a value under the same key alrea...
void * ctx
Client context associated with this ego.
Definition: identity.h:260
#define GNUNET_MESSAGE_TYPE_IDENTITY_CREATE
Create new identity (client->service).
struct GNUNET_HashCode key
The key used in the DHT.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static unsigned int size
Size of the "table".
Definition: peer.c:67
void GNUNET_CRYPTO_ecdsa_key_get_public(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:239
struct GNUNET_IDENTITY_Operation * next
We keep operations in a DLL.
Definition: identity_api.c:49
struct GNUNET_IDENTITY_Handle * h
Main identity handle.
Definition: identity_api.c:44
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
void GNUNET_IDENTITY_ego_get_public_key(const struct GNUNET_IDENTITY_Ego *ego, struct GNUNET_CRYPTO_EcdsaPublicKey *pk)
Get the identifier (public key) of an ego.
Definition: identity_api.c:568
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT.
Definition: identity.h:139
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
uint16_t name_len
Number of bytes in ego name string including 0-termination, in NBO; 0 if the ego was deleted...
Definition: identity.h:88
Handle to a message queue.
Definition: mq.c:85
uint16_t new_name_len
Number of characters in the new name including 0-termination, in NBO.
Definition: identity.h:209
static void handle_identity_set_default(void *cls, const struct SetDefaultMessage *sdm)
Type of a function to call when we receive a message from the service.
Definition: identity_api.c:444
static int free_ego(void *cls, const struct GNUNET_HashCode *key, void *value)
Free ego from hash map.
Definition: identity_api.c:189
configuration data
Definition: configuration.c:85
const char * name
struct GNUNET_IDENTITY_Operation * prev
We keep operations in a DLL.
Definition: identity_api.c:54
uint16_t end_of_list
Usually GNUNET_NO, GNUNET_YES to signal end of list.
Definition: identity.h:93
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
void * cls
Closure for cont or cb.
Definition: identity_api.c:88
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
Definition: scheduler.c:134
#define GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT
Client requests to know default identity for a subsystem.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
#define GNUNET_MESSAGE_TYPE_IDENTITY_RENAME
Rename existing identity (client->service).
uint16_t name_len
Number of characters in the name including 0-termination, in NBO.
Definition: identity.h:230
const struct GNUNET_IDENTITY_Ego * GNUNET_IDENTITY_ego_get_anonymous()
Obtain the ego representing &#39;anonymous&#39; users.
Definition: identity_api.c:156
Header for all communications.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
struct GNUNET_IDENTITY_Operation * GNUNET_IDENTITY_rename(struct GNUNET_IDENTITY_Handle *h, const char *old_name, const char *new_name, GNUNET_IDENTITY_Continuation cb, void *cb_cls)
Renames an existing identity.
Definition: identity_api.c:724
#define GNUNET_YES
Definition: gnunet_common.h:77
#define GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE
Generic response from identity service with success and/or error message.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
void * cb_cls
Closure for cb.
Definition: identity_api.c:121
Client requests knowledge about default identity for a subsystem from identity service.
Definition: identity.h:108
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:105
static int check_identity_set_default(void *cls, const struct SetDefaultMessage *sdm)
Function called when we receive a set default message from the service.
Definition: identity_api.c:420
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
void(* GNUNET_IDENTITY_Continuation)(void *cls, const char *emsg)
Function called once the requested operation has been completed.
GNUNET_IDENTITY_Callback cb
Function to call when we receive updates.
Definition: identity_api.c:116
GNUNET_IDENTITY_Callback cb
Continuation to invoke with the result of the transmission for &#39;get&#39; operations (cont and create_cont...
Definition: identity_api.c:83
struct GNUNET_CRYPTO_EcdsaPrivateKey * pk
Private key associated with this ego.
Definition: identity.h:250
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
Answer from service to client about last operation; GET_DEFAULT maybe answered with this message on f...
Definition: identity.h:42
Service informs client about status of a pseudonym.
Definition: identity.h:77
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
int in_receive
Are we polling for incoming messages right now?
Definition: identity_api.c:146
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966