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 
44 
49 
54 
59  const struct GNUNET_MessageHeader *msg;
60 
66 
72 
77 
83 
87  void *cls;
88 };
89 
90 
99 
104 
110 
115 
119  void *cb_cls;
120 
125 
130 
135 
139  struct GNUNET_TIME_Relative reconnect_delay;
140 
145 };
146 
147 
153 const struct GNUNET_IDENTITY_Ego *
155 {
156  static struct GNUNET_IDENTITY_Ego anon;
157  struct GNUNET_CRYPTO_EcdsaPublicKey pub;
158 
159  if (NULL != anon.pk)
160  return &anon;
161  anon.pk = (struct GNUNET_CRYPTO_EcdsaPrivateKey *)
164  GNUNET_CRYPTO_hash(&pub, sizeof(pub), &anon.id);
165  return &anon;
166 }
167 
168 
174 static void
175 reconnect(void *cls);
176 
177 
186 static int
187 free_ego(void *cls, const struct GNUNET_HashCode *key, void *value)
188 {
189  struct GNUNET_IDENTITY_Handle *h = cls;
190  struct GNUNET_IDENTITY_Ego *ego = value;
191 
192  if (NULL != h->cb)
193  h->cb(h->cb_cls, ego, &ego->ctx, NULL);
194  GNUNET_free(ego->pk);
195  GNUNET_free(ego->name);
198  GNUNET_free(ego);
199  return GNUNET_OK;
200 }
201 
202 
208 static void
210 {
212 
213  GNUNET_assert(NULL == h->reconnect_task);
214 
215  if (NULL != h->mq)
216  {
217  GNUNET_MQ_destroy(h->mq);
218  h->mq = NULL;
219  }
220  while (NULL != (op = h->op_head))
221  {
223  if (NULL != op->cont)
224  op->cont(op->cls, "Error in communication with the identity service");
225  else if (NULL != op->cb)
226  op->cb(op->cls, NULL, NULL, NULL);
227  else if (NULL != op->create_cont)
228  op->create_cont(op->cls,
229  NULL,
230  "Failed to communicate with the identity service");
232  GNUNET_free(op);
233  }
236  "Scheduling task to reconnect to identity service in %s.\n",
238  h->reconnect_task =
241 }
242 
243 
252 static void
254 {
255  struct GNUNET_IDENTITY_Handle *h = cls;
256 
258 }
259 
260 
269 static int
271 {
272  if (sizeof(*rcm) != htons(rcm->header.size))
274  return GNUNET_OK;
275 }
276 
277 
284 static void
286 {
287  struct GNUNET_IDENTITY_Handle *h = cls;
289  uint16_t size = ntohs(rcm->header.size) - sizeof(*rcm);
290  const char *str = (0 == size) ? NULL : (const char *)&rcm[1];
291 
292  op = h->op_head;
293  if (NULL == op)
294  {
295  GNUNET_break(0);
297  return;
298  }
300  if (NULL != op->cont)
301  op->cont(op->cls, str);
302  else if (NULL != op->cb)
303  op->cb(op->cls, NULL, NULL, NULL);
304  else if (NULL != op->create_cont)
305  op->create_cont(op->cls, (NULL == str) ? op->pk : NULL, str);
307  GNUNET_free(op);
308 }
309 
310 
318 static int
319 check_identity_update(void *cls, const struct UpdateMessage *um)
320 {
321  uint16_t size = ntohs(um->header.size);
322  uint16_t name_len = ntohs(um->name_len);
323  const char *str = (const char *)&um[1];
324 
325  if ((size != name_len + sizeof(struct UpdateMessage)) ||
326  ((0 != name_len) && ('\0' != str[name_len - 1])))
327  {
328  GNUNET_break(0);
329  return GNUNET_SYSERR;
330  }
331  return GNUNET_OK;
332 }
333 
334 
341 static void
342 handle_identity_update(void *cls, const struct UpdateMessage *um)
343 {
344  struct GNUNET_IDENTITY_Handle *h = cls;
345  uint16_t name_len = ntohs(um->name_len);
346  const char *str = (0 == name_len) ? NULL : (const char *)&um[1];
347  struct GNUNET_CRYPTO_EcdsaPublicKey pub;
348  struct GNUNET_HashCode id;
349  struct GNUNET_IDENTITY_Ego *ego;
350 
351  if (GNUNET_YES == ntohs(um->end_of_list))
352  {
353  /* end of initial list of data */
354  if (NULL != h->cb)
355  h->cb(h->cb_cls, NULL, NULL, NULL);
356  return;
357  }
359  GNUNET_CRYPTO_hash(&pub, sizeof(pub), &id);
361  if (NULL == ego)
362  {
363  /* ego was created */
364  if (NULL == str)
365  {
366  /* deletion of unknown ego? not allowed */
367  GNUNET_break(0);
369  return;
370  }
371  ego = GNUNET_new(struct GNUNET_IDENTITY_Ego);
373  *ego->pk = um->private_key;
374  ego->name = GNUNET_strdup(str);
375  ego->id = id;
378  h->egos,
379  &ego->id,
380  ego,
382  }
383  if (NULL == str)
384  {
385  /* ego was deleted */
387  &ego->id,
388  ego));
389  }
390  else
391  {
392  /* ego changed name */
393  GNUNET_free(ego->name);
394  ego->name = GNUNET_strdup(str);
395  }
396  /* inform application about change */
397  if (NULL != h->cb)
398  h->cb(h->cb_cls, ego, &ego->ctx, str);
399  /* complete deletion */
400  if (NULL == str)
401  {
402  GNUNET_free(ego->pk);
403  GNUNET_free(ego->name);
404  GNUNET_free(ego);
405  }
406 }
407 
408 
417 static int
419 {
420  uint16_t size = ntohs(sdm->header.size) - sizeof(*sdm);
421  uint16_t name_len = ntohs(sdm->name_len);
422  const char *str = (const char *)&sdm[1];
423 
424  if ((size != name_len) || ((0 != name_len) && ('\0' != str[name_len - 1])))
425  {
426  GNUNET_break(0);
427  return GNUNET_SYSERR;
428  }
429  GNUNET_break(0 == ntohs(sdm->reserved));
430  return GNUNET_OK;
431 }
432 
433 
441 static void
443 {
444  struct GNUNET_IDENTITY_Handle *h = cls;
446  struct GNUNET_CRYPTO_EcdsaPublicKey pub;
447  struct GNUNET_HashCode id;
448  struct GNUNET_IDENTITY_Ego *ego;
449 
451  GNUNET_CRYPTO_hash(&pub, sizeof(pub), &id);
453  if (NULL == ego)
454  {
455  GNUNET_break(0);
457  return;
458  }
459  op = h->op_head;
460  if (NULL == op)
461  {
462  GNUNET_break(0);
464  return;
465  }
467  "Received SET_DEFAULT message from identity service\n");
469  if (NULL != op->cb)
470  op->cb(op->cls, ego, &ego->ctx, ego->name);
471  GNUNET_free(op);
472 }
473 
474 
480 static void
482 {
483  struct GNUNET_IDENTITY_Handle *h = cls;
484  struct GNUNET_MQ_MessageHandler handlers[] =
485  { GNUNET_MQ_hd_var_size(identity_result_code,
487  struct ResultCodeMessage,
488  h),
489  GNUNET_MQ_hd_var_size(identity_update,
491  struct UpdateMessage,
492  h),
493  GNUNET_MQ_hd_var_size(identity_set_default,
495  struct SetDefaultMessage,
496  h),
498  struct GNUNET_MQ_Envelope *env;
499  struct GNUNET_MessageHeader *msg;
500 
501  h->reconnect_task = NULL;
502  LOG(GNUNET_ERROR_TYPE_DEBUG, "Connecting to identity service.\n");
503  GNUNET_assert(NULL == h->mq);
504  h->mq =
505  GNUNET_CLIENT_connect(h->cfg, "identity", handlers, &mq_error_handler, h);
506  if (NULL == h->mq)
507  return;
508  if (NULL != h->cb)
509  {
511  GNUNET_MQ_send(h->mq, env);
512  }
513 }
514 
515 
524 struct GNUNET_IDENTITY_Handle *
527  void *cb_cls)
528 {
529  struct GNUNET_IDENTITY_Handle *h;
530 
532  h->cfg = cfg;
533  h->cb = cb;
534  h->cb_cls = cb_cls;
536  reconnect(h);
537  if (NULL == h->mq)
538  {
539  GNUNET_free(h);
540  return NULL;
541  }
542  return h;
543 }
544 
545 
552 const struct GNUNET_CRYPTO_EcdsaPrivateKey *
554 {
555  return ego->pk;
556 }
557 
558 
565 void
568 {
570 }
571 
572 
585  const char *service_name,
587  void *cb_cls)
588 {
590  struct GNUNET_MQ_Envelope *env;
591  struct GetDefaultMessage *gdm;
592  size_t slen;
593 
594  if (NULL == h->mq)
595  return NULL;
596  GNUNET_assert(NULL != h->cb);
597  slen = strlen(service_name) + 1;
598  if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct GetDefaultMessage))
599  {
600  GNUNET_break(0);
601  return NULL;
602  }
604  op->h = h;
605  op->cb = cb;
606  op->cls = cb_cls;
608  env =
610  gdm->name_len = htons(slen);
611  gdm->reserved = htons(0);
612  GNUNET_memcpy(&gdm[1], service_name, slen);
613  GNUNET_MQ_send(h->mq, env);
614  return op;
615 }
616 
617 
630  const char *service_name,
631  struct GNUNET_IDENTITY_Ego *ego,
633  void *cont_cls)
634 {
636  struct GNUNET_MQ_Envelope *env;
637  struct SetDefaultMessage *sdm;
638  size_t slen;
639 
640  if (NULL == h->mq)
641  return NULL;
642  GNUNET_assert(NULL != h->cb);
643  slen = strlen(service_name) + 1;
644  if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct SetDefaultMessage))
645  {
646  GNUNET_break(0);
647  return NULL;
648  }
650  op->h = h;
651  op->cont = cont;
652  op->cls = cont_cls;
654  env =
656  sdm->name_len = htons(slen);
657  sdm->reserved = htons(0);
658  sdm->private_key = *ego->pk;
659  GNUNET_memcpy(&sdm[1], service_name, slen);
660  GNUNET_MQ_send(h->mq, env);
661  return op;
662 }
663 
664 
676  const char *name,
678  void *cont_cls)
679 {
681  struct GNUNET_MQ_Envelope *env;
682  struct CreateRequestMessage *crm;
684  size_t slen;
685 
686  if (NULL == h->mq)
687  return NULL;
688  slen = strlen(name) + 1;
689  if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct CreateRequestMessage))
690  {
691  GNUNET_break(0);
692  return NULL;
693  }
695  op->h = h;
696  op->create_cont = cont;
697  op->cls = cont_cls;
700  crm->name_len = htons(slen);
701  crm->reserved = htons(0);
703  crm->private_key = *pk;
704  op->pk = pk;
705  GNUNET_memcpy(&crm[1], name, slen);
706  GNUNET_MQ_send(h->mq, env);
707  return op;
708 }
709 
710 
723  const char *old_name,
724  const char *new_name,
726  void *cb_cls)
727 {
729  struct GNUNET_MQ_Envelope *env;
730  struct RenameMessage *grm;
731  size_t slen_old;
732  size_t slen_new;
733  char *dst;
734 
735  if (NULL == h->mq)
736  return NULL;
737  slen_old = strlen(old_name) + 1;
738  slen_new = strlen(new_name) + 1;
739  if ((slen_old >= GNUNET_MAX_MESSAGE_SIZE) ||
740  (slen_new >= GNUNET_MAX_MESSAGE_SIZE) ||
741  (slen_old + slen_new >=
742  GNUNET_MAX_MESSAGE_SIZE - sizeof(struct RenameMessage)))
743  {
744  GNUNET_break(0);
745  return NULL;
746  }
748  op->h = h;
749  op->cont = cb;
750  op->cls = cb_cls;
752  env = GNUNET_MQ_msg_extra(grm,
753  slen_old + slen_new,
755  grm->old_name_len = htons(slen_old);
756  grm->new_name_len = htons(slen_new);
757  dst = (char *)&grm[1];
758  GNUNET_memcpy(dst, old_name, slen_old);
759  GNUNET_memcpy(&dst[slen_old], new_name, slen_new);
760  GNUNET_MQ_send(h->mq, env);
761  return op;
762 }
763 
764 
776  const char *name,
778  void *cb_cls)
779 {
781  struct GNUNET_MQ_Envelope *env;
782  struct DeleteMessage *gdm;
783  size_t slen;
784 
785  if (NULL == h->mq)
786  return NULL;
787  slen = strlen(name) + 1;
788  if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct DeleteMessage))
789  {
790  GNUNET_break(0);
791  return NULL;
792  }
794  op->h = h;
795  op->cont = cb;
796  op->cls = cb_cls;
799  gdm->name_len = htons(slen);
800  gdm->reserved = htons(0);
801  GNUNET_memcpy(&gdm[1], name, slen);
802  GNUNET_MQ_send(h->mq, env);
803  return op;
804 }
805 
806 
815 void
817 {
818  op->cont = NULL;
819  op->cb = NULL;
820  op->create_cont = NULL;
821  if (NULL != op->pk)
822  {
823  GNUNET_free(op->pk);
824  op->pk = NULL;
825  }
826 }
827 
828 
834 void
836 {
838 
839  GNUNET_assert(NULL != h);
840  if (h->reconnect_task != NULL)
841  {
843  h->reconnect_task = NULL;
844  }
845  if (NULL != h->egos)
846  {
849  h->egos = NULL;
850  }
851  while (NULL != (op = h->op_head))
852  {
853  GNUNET_break(NULL == op->cont);
856  GNUNET_free(op);
857  }
858  if (NULL != h->mq)
859  {
860  GNUNET_MQ_destroy(h->mq);
861  h->mq = NULL;
862  }
863  GNUNET_free(h);
864 }
865 
866 /* 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:525
#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:109
static void handle_identity_update(void *cls, const struct UpdateMessage *um)
Handle identity update message.
Definition: identity_api.c:342
uint16_t reserved
Always zero.
Definition: identity.h:173
struct GNUNET_CRYPTO_EcdsaPrivateKey private_key
The private key.
Definition: identity.h:149
#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:816
#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:59
Used from service to client as a result to the GET_DEFAULT message, used from client to service to SE...
Definition: identity.h:130
struct GNUNET_TIME_Relative reconnect_delay
Time for next connect retry.
Definition: identity_api.c:139
#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:285
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:900
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:119
GNUNET_MQ_Error
Error codes for the queue.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE.
Definition: identity.h:79
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:775
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:253
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:675
uint16_t name_len
Number of bytes in service name string including 0-termination, in NBO.
Definition: identity.h:139
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE.
Definition: identity.h:46
#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:114
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:629
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:553
uint16_t old_name_len
Number of characters in the old name including 0-termination, in NBO.
Definition: identity.h:197
Client requests renaming of an identity.
Definition: identity.h:188
struct GNUNET_CRYPTO_EcdsaPrivateKey private_key
The private key.
Definition: identity.h:95
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t reserved
Always zero.
Definition: identity.h:227
struct GNUNET_IDENTITY_Operation * op_tail
Tail of active operations.
Definition: identity_api.c:129
#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:584
#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:270
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:168
Internal representation of the hash map.
struct GNUNET_CRYPTO_EcdsaPrivateKey private_key
The private key.
Definition: identity.h:178
#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:246
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:481
uint16_t reserved
Always zero.
Definition: identity.h:144
#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:1237
Handle for an ego.
Definition: identity.h:237
#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:71
#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:94
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:134
Client requests creation of an identity.
Definition: identity.h:159
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:686
struct GNUNET_CRYPTO_EcdsaPrivateKey * pk
Private key to return to create_cont, or NULL.
Definition: identity_api.c:76
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:319
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:98
void GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h)
Disconnect from identity service.
Definition: identity_api.c:835
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:65
struct GNUNET_IDENTITY_Operation * op_head
Head of active operations.
Definition: identity_api.c:124
static void reschedule_connect(struct GNUNET_IDENTITY_Handle *h)
Reschedule a connect attempt to the service.
Definition: identity_api.c:209
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:256
Client requests deletion of an identity.
Definition: identity.h:213
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:251
#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:66
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:48
const char * name
struct GNUNET_IDENTITY_Handle * h
Main identity handle.
Definition: identity_api.c:43
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:566
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT.
Definition: identity.h:134
#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:85
Handle to a message queue.
Definition: mq.c:84
uint16_t new_name_len
Number of characters in the new name including 0-termination, in NBO.
Definition: identity.h:202
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:442
static int free_ego(void *cls, const struct GNUNET_HashCode *key, void *value)
Free ego from hash map.
Definition: identity_api.c:187
configuration data
Definition: configuration.c:83
struct GNUNET_IDENTITY_Operation * prev
We keep operations in a DLL.
Definition: identity_api.c:53
uint16_t end_of_list
Usually GNUNET_NO, GNUNET_YES to signal end of list.
Definition: identity.h:90
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:87
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
Definition: scheduler.c:131
#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:222
const struct GNUNET_IDENTITY_Ego * GNUNET_IDENTITY_ego_get_anonymous()
Obtain the ego representing &#39;anonymous&#39; users.
Definition: identity_api.c:154
Header for all communications.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:821
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:722
#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:351
void * cb_cls
Closure for cb.
Definition: identity_api.c:119
Client requests knowledge about default identity for a subsystem from identity service.
Definition: identity.h:105
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:103
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:418
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
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:114
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:82
struct GNUNET_CRYPTO_EcdsaPrivateKey * pk
Private key associated with this ego.
Definition: identity.h:241
#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:75
#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:144
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956