GNUnet  0.10.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 {
41 
46 
51 
56 
61  const struct GNUNET_MessageHeader *msg;
62 
68 
74 
79 
85 
89  void *cls;
90 };
91 
92 
97 {
102 
107 
113 
118 
122  void *cb_cls;
123 
128 
133 
138 
142  struct GNUNET_TIME_Relative reconnect_delay;
143 
148 };
149 
150 
156 const struct GNUNET_IDENTITY_Ego *
158 {
159  static struct GNUNET_IDENTITY_Ego anon;
160  struct GNUNET_CRYPTO_EcdsaPublicKey pub;
161 
162  if (NULL != anon.pk)
163  return &anon;
164  anon.pk = (struct GNUNET_CRYPTO_EcdsaPrivateKey *)
167  GNUNET_CRYPTO_hash (&pub, sizeof (pub), &anon.id);
168  return &anon;
169 }
170 
171 
177 static void
178 reconnect (void *cls);
179 
180 
189 static int
190 free_ego (void *cls, const struct GNUNET_HashCode *key, void *value)
191 {
192  struct GNUNET_IDENTITY_Handle *h = cls;
193  struct GNUNET_IDENTITY_Ego *ego = value;
194 
195  if (NULL != h->cb)
196  h->cb (h->cb_cls, ego, &ego->ctx, NULL);
197  GNUNET_free (ego->pk);
198  GNUNET_free (ego->name);
200  GNUNET_CONTAINER_multihashmap_remove (h->egos, key, value));
201  GNUNET_free (ego);
202  return GNUNET_OK;
203 }
204 
205 
211 static void
213 {
215 
216  GNUNET_assert (NULL == h->reconnect_task);
217 
218  if (NULL != h->mq)
219  {
220  GNUNET_MQ_destroy (h->mq);
221  h->mq = NULL;
222  }
223  while (NULL != (op = h->op_head))
224  {
226  if (NULL != op->cont)
227  op->cont (op->cls, "Error in communication with the identity service");
228  else if (NULL != op->cb)
229  op->cb (op->cls, NULL, NULL, NULL);
230  else if (NULL != op->create_cont)
231  op->create_cont (op->cls,
232  NULL,
233  "Failed to communicate with the identity service");
234  GNUNET_free_non_null (op->pk);
235  GNUNET_free (op);
236  }
239  "Scheduling task to reconnect to identity service in %s.\n",
241  h->reconnect_task =
244 }
245 
246 
255 static void
257 {
258  struct GNUNET_IDENTITY_Handle *h = cls;
259 
260  reschedule_connect (h);
261 }
262 
263 
272 static int
274 {
275  if (sizeof (*rcm) != htons (rcm->header.size))
277  return GNUNET_OK;
278 }
279 
280 
287 static void
289 {
290  struct GNUNET_IDENTITY_Handle *h = cls;
292  uint16_t size = ntohs (rcm->header.size) - sizeof (*rcm);
293  const char *str = (0 == size) ? NULL : (const char *) &rcm[1];
294 
295  op = h->op_head;
296  if (NULL == op)
297  {
298  GNUNET_break (0);
299  reschedule_connect (h);
300  return;
301  }
303  if (NULL != op->cont)
304  op->cont (op->cls, str);
305  else if (NULL != op->cb)
306  op->cb (op->cls, NULL, NULL, NULL);
307  else if (NULL != op->create_cont)
308  op->create_cont (op->cls, (NULL == str) ? op->pk : NULL, str);
309  GNUNET_free_non_null (op->pk);
310  GNUNET_free (op);
311 }
312 
313 
321 static int
322 check_identity_update (void *cls, const struct UpdateMessage *um)
323 {
324  uint16_t size = ntohs (um->header.size);
325  uint16_t name_len = ntohs (um->name_len);
326  const char *str = (const char *) &um[1];
327 
328  if ((size != name_len + sizeof (struct UpdateMessage)) ||
329  ((0 != name_len) && ('\0' != str[name_len - 1])))
330  {
331  GNUNET_break (0);
332  return GNUNET_SYSERR;
333  }
334  return GNUNET_OK;
335 }
336 
337 
344 static void
345 handle_identity_update (void *cls, const struct UpdateMessage *um)
346 {
347  struct GNUNET_IDENTITY_Handle *h = cls;
348  uint16_t name_len = ntohs (um->name_len);
349  const char *str = (0 == name_len) ? NULL : (const char *) &um[1];
350  struct GNUNET_CRYPTO_EcdsaPublicKey pub;
351  struct GNUNET_HashCode id;
352  struct GNUNET_IDENTITY_Ego *ego;
353 
354  if (GNUNET_YES == ntohs (um->end_of_list))
355  {
356  /* end of initial list of data */
357  if (NULL != h->cb)
358  h->cb (h->cb_cls, NULL, NULL, NULL);
359  return;
360  }
362  GNUNET_CRYPTO_hash (&pub, sizeof (pub), &id);
363  ego = GNUNET_CONTAINER_multihashmap_get (h->egos, &id);
364  if (NULL == ego)
365  {
366  /* ego was created */
367  if (NULL == str)
368  {
369  /* deletion of unknown ego? not allowed */
370  GNUNET_break (0);
371  reschedule_connect (h);
372  return;
373  }
374  ego = GNUNET_new (struct GNUNET_IDENTITY_Ego);
376  *ego->pk = um->private_key;
377  ego->name = GNUNET_strdup (str);
378  ego->id = id;
381  h->egos,
382  &ego->id,
383  ego,
385  }
386  if (NULL == str)
387  {
388  /* ego was deleted */
390  &ego->id,
391  ego));
392  }
393  else
394  {
395  /* ego changed name */
396  GNUNET_free (ego->name);
397  ego->name = GNUNET_strdup (str);
398  }
399  /* inform application about change */
400  if (NULL != h->cb)
401  h->cb (h->cb_cls, ego, &ego->ctx, str);
402  /* complete deletion */
403  if (NULL == str)
404  {
405  GNUNET_free (ego->pk);
406  GNUNET_free (ego->name);
407  GNUNET_free (ego);
408  }
409 }
410 
411 
420 static int
422 {
423  uint16_t size = ntohs (sdm->header.size) - sizeof (*sdm);
424  uint16_t name_len = ntohs (sdm->name_len);
425  const char *str = (const char *) &sdm[1];
426 
427  if ((size != name_len) || ((0 != name_len) && ('\0' != str[name_len - 1])))
428  {
429  GNUNET_break (0);
430  return GNUNET_SYSERR;
431  }
432  GNUNET_break (0 == ntohs (sdm->reserved));
433  return GNUNET_OK;
434 }
435 
436 
444 static void
446 {
447  struct GNUNET_IDENTITY_Handle *h = cls;
449  struct GNUNET_CRYPTO_EcdsaPublicKey pub;
450  struct GNUNET_HashCode id;
451  struct GNUNET_IDENTITY_Ego *ego;
452 
454  GNUNET_CRYPTO_hash (&pub, sizeof (pub), &id);
455  ego = GNUNET_CONTAINER_multihashmap_get (h->egos, &id);
456  if (NULL == ego)
457  {
458  GNUNET_break (0);
459  reschedule_connect (h);
460  return;
461  }
462  op = h->op_head;
463  if (NULL == op)
464  {
465  GNUNET_break (0);
466  reschedule_connect (h);
467  return;
468  }
470  "Received SET_DEFAULT message from identity service\n");
472  if (NULL != op->cb)
473  op->cb (op->cls, ego, &ego->ctx, ego->name);
474  GNUNET_free (op);
475 }
476 
477 
483 static void
484 reconnect (void *cls)
485 {
486  struct GNUNET_IDENTITY_Handle *h = cls;
487  struct GNUNET_MQ_MessageHandler handlers[] =
488  {GNUNET_MQ_hd_var_size (identity_result_code,
490  struct ResultCodeMessage,
491  h),
492  GNUNET_MQ_hd_var_size (identity_update,
494  struct UpdateMessage,
495  h),
496  GNUNET_MQ_hd_var_size (identity_set_default,
498  struct SetDefaultMessage,
499  h),
501  struct GNUNET_MQ_Envelope *env;
502  struct GNUNET_MessageHeader *msg;
503 
504  h->reconnect_task = NULL;
505  LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to identity service.\n");
506  GNUNET_assert (NULL == h->mq);
507  h->mq =
508  GNUNET_CLIENT_connect (h->cfg, "identity", handlers, &mq_error_handler, h);
509  if (NULL == h->mq)
510  return;
511  if (NULL != h->cb)
512  {
514  GNUNET_MQ_send (h->mq, env);
515  }
516 }
517 
518 
527 struct GNUNET_IDENTITY_Handle *
530  void *cb_cls)
531 {
532  struct GNUNET_IDENTITY_Handle *h;
533 
534  h = GNUNET_new (struct GNUNET_IDENTITY_Handle);
535  h->cfg = cfg;
536  h->cb = cb;
537  h->cb_cls = cb_cls;
539  reconnect (h);
540  if (NULL == h->mq)
541  {
542  GNUNET_free (h);
543  return NULL;
544  }
545  return h;
546 }
547 
548 
555 const struct GNUNET_CRYPTO_EcdsaPrivateKey *
557 {
558  return ego->pk;
559 }
560 
561 
568 void
571 {
573 }
574 
575 
588  const char *service_name,
590  void *cb_cls)
591 {
593  struct GNUNET_MQ_Envelope *env;
594  struct GetDefaultMessage *gdm;
595  size_t slen;
596 
597  if (NULL == h->mq)
598  return NULL;
599  GNUNET_assert (NULL != h->cb);
600  slen = strlen (service_name) + 1;
601  if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct GetDefaultMessage))
602  {
603  GNUNET_break (0);
604  return NULL;
605  }
607  op->h = h;
608  op->cb = cb;
609  op->cls = cb_cls;
611  env =
613  gdm->name_len = htons (slen);
614  gdm->reserved = htons (0);
615  GNUNET_memcpy (&gdm[1], service_name, slen);
616  GNUNET_MQ_send (h->mq, env);
617  return op;
618 }
619 
620 
633  const char *service_name,
634  struct GNUNET_IDENTITY_Ego *ego,
636  void *cont_cls)
637 {
639  struct GNUNET_MQ_Envelope *env;
640  struct SetDefaultMessage *sdm;
641  size_t slen;
642 
643  if (NULL == h->mq)
644  return NULL;
645  GNUNET_assert (NULL != h->cb);
646  slen = strlen (service_name) + 1;
647  if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct SetDefaultMessage))
648  {
649  GNUNET_break (0);
650  return NULL;
651  }
653  op->h = h;
654  op->cont = cont;
655  op->cls = cont_cls;
657  env =
659  sdm->name_len = htons (slen);
660  sdm->reserved = htons (0);
661  sdm->private_key = *ego->pk;
662  GNUNET_memcpy (&sdm[1], service_name, slen);
663  GNUNET_MQ_send (h->mq, env);
664  return op;
665 }
666 
667 
679  const char *name,
681  void *cont_cls)
682 {
684  struct GNUNET_MQ_Envelope *env;
685  struct CreateRequestMessage *crm;
687  size_t slen;
688 
689  if (NULL == h->mq)
690  return NULL;
691  slen = strlen (name) + 1;
692  if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct CreateRequestMessage))
693  {
694  GNUNET_break (0);
695  return NULL;
696  }
698  op->h = h;
699  op->create_cont = cont;
700  op->cls = cont_cls;
703  crm->name_len = htons (slen);
704  crm->reserved = htons (0);
706  crm->private_key = *pk;
707  op->pk = pk;
708  GNUNET_memcpy (&crm[1], name, slen);
709  GNUNET_MQ_send (h->mq, env);
710  return op;
711 }
712 
713 
726  const char *old_name,
727  const char *new_name,
729  void *cb_cls)
730 {
732  struct GNUNET_MQ_Envelope *env;
733  struct RenameMessage *grm;
734  size_t slen_old;
735  size_t slen_new;
736  char *dst;
737 
738  if (NULL == h->mq)
739  return NULL;
740  slen_old = strlen (old_name) + 1;
741  slen_new = strlen (new_name) + 1;
742  if ((slen_old >= GNUNET_MAX_MESSAGE_SIZE) ||
743  (slen_new >= GNUNET_MAX_MESSAGE_SIZE) ||
744  (slen_old + slen_new >=
745  GNUNET_MAX_MESSAGE_SIZE - sizeof (struct RenameMessage)))
746  {
747  GNUNET_break (0);
748  return NULL;
749  }
751  op->h = h;
752  op->cont = cb;
753  op->cls = cb_cls;
755  env = GNUNET_MQ_msg_extra (grm,
756  slen_old + slen_new,
758  grm->old_name_len = htons (slen_old);
759  grm->new_name_len = htons (slen_new);
760  dst = (char *) &grm[1];
761  GNUNET_memcpy (dst, old_name, slen_old);
762  GNUNET_memcpy (&dst[slen_old], new_name, slen_new);
763  GNUNET_MQ_send (h->mq, env);
764  return op;
765 }
766 
767 
779  const char *name,
781  void *cb_cls)
782 {
784  struct GNUNET_MQ_Envelope *env;
785  struct DeleteMessage *gdm;
786  size_t slen;
787 
788  if (NULL == h->mq)
789  return NULL;
790  slen = strlen (name) + 1;
791  if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct DeleteMessage))
792  {
793  GNUNET_break (0);
794  return NULL;
795  }
797  op->h = h;
798  op->cont = cb;
799  op->cls = cb_cls;
802  gdm->name_len = htons (slen);
803  gdm->reserved = htons (0);
804  GNUNET_memcpy (&gdm[1], name, slen);
805  GNUNET_MQ_send (h->mq, env);
806  return op;
807 }
808 
809 
818 void
820 {
821  op->cont = NULL;
822  op->cb = NULL;
823  op->create_cont = NULL;
824  if (NULL != op->pk)
825  {
826  GNUNET_free (op->pk);
827  op->pk = NULL;
828  }
829 }
830 
831 
837 void
839 {
841 
842  GNUNET_assert (NULL != h);
843  if (h->reconnect_task != NULL)
844  {
846  h->reconnect_task = NULL;
847  }
848  if (NULL != h->egos)
849  {
852  h->egos = NULL;
853  }
854  while (NULL != (op = h->op_head))
855  {
856  GNUNET_break (NULL == op->cont);
858  GNUNET_free_non_null (op->pk);
859  GNUNET_free (op);
860  }
861  if (NULL != h->mq)
862  {
863  GNUNET_MQ_destroy (h->mq);
864  h->mq = NULL;
865  }
866  GNUNET_free (h);
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:528
#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:112
static void handle_identity_update(void *cls, const struct UpdateMessage *um)
Handle identity update message.
Definition: identity_api.c:345
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:814
void GNUNET_IDENTITY_cancel(struct GNUNET_IDENTITY_Operation *op)
Cancel an identity operation.
Definition: identity_api.c:819
#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:61
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:142
#define GNUNET_MESSAGE_TYPE_IDENTITY_DELETE
Delete identity (client->service).
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:288
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:901
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:778
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:256
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:678
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:691
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:632
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:556
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
uint16_t reserved
Always zero.
Definition: identity.h:235
struct GNUNET_IDENTITY_Operation * op_tail
Tail of active operations.
Definition: identity_api.c:132
#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:587
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_HashMapIterator it, void *it_cls)
Iterate over all entries in the map.
#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:78
#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:273
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:484
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:1246
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 ...
#define GNUNET_memcpy(dst, src, n)
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:73
#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:44
Handle for the service.
Definition: identity_api.c:96
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:137
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:727
struct GNUNET_CRYPTO_EcdsaPrivateKey * pk
Private key to return to create_cont, or NULL.
Definition: identity_api.c:78
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:322
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:101
void GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h)
Disconnect from identity service.
Definition: identity_api.c:838
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:67
struct GNUNET_IDENTITY_Operation * op_head
Head of active operations.
Definition: identity_api.c:127
static void reschedule_connect(struct GNUNET_IDENTITY_Handle *h)
Reschedule a connect attempt to the service.
Definition: identity_api.c:212
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
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
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:79
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:241
struct GNUNET_IDENTITY_Operation * next
We keep operations in a DLL.
Definition: identity_api.c:50
const char * name
struct GNUNET_IDENTITY_Handle * h
Main identity handle.
Definition: identity_api.c:45
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:569
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:445
static int free_ego(void *cls, const struct GNUNET_HashCode *key, void *value)
Free ego from hash map.
Definition: identity_api.c:190
configuration data
Definition: configuration.c:85
struct GNUNET_IDENTITY_Operation * prev
We keep operations in a DLL.
Definition: identity_api.c:55
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:89
#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:157
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:725
#define GNUNET_YES
Definition: gnunet_common.h:80
#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:122
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:106
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:421
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
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:117
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:84
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:147
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965