GNUnet  0.11.x
Macros | Typedefs | Functions
Identity service

Identity management. More...

Macros

#define GNUNET_IDENTITY_VERSION   0x00000100
 Version number of GNUnet Identity API. More...
 

Typedefs

typedef 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. More...
 
typedef void(* GNUNET_IDENTITY_Continuation) (void *cls, const char *emsg)
 Function called once the requested operation has been completed. More...
 
typedef void(* GNUNET_IDENTITY_CreateContinuation) (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk, const char *emsg)
 Function called once the requested operation has been completed. More...
 
typedef void(* GNUNET_IDENTITY_EgoCallback) (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
 Function called with the result. More...
 
typedef void(* GNUNET_IDENTITY_EgoSuffixCallback) (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, const char *ego_name)
 Function called with the result. More...
 

Functions

const struct GNUNET_CRYPTO_EcdsaPrivateKeyGNUNET_IDENTITY_ego_get_private_key (const struct GNUNET_IDENTITY_Ego *ego)
 Obtain the ECC key associated with a ego. More...
 
const struct GNUNET_IDENTITY_EgoGNUNET_IDENTITY_ego_get_anonymous (void)
 Obtain the ego representing 'anonymous' users. More...
 
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. More...
 
struct GNUNET_IDENTITY_HandleGNUNET_IDENTITY_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_IDENTITY_Callback cb, void *cb_cls)
 Connect to the identity service. More...
 
struct GNUNET_IDENTITY_OperationGNUNET_IDENTITY_get (struct GNUNET_IDENTITY_Handle *id, const char *service_name, GNUNET_IDENTITY_Callback cb, void *cb_cls)
 Obtain the ego that is currently preferred/default for a service. More...
 
struct GNUNET_IDENTITY_OperationGNUNET_IDENTITY_set (struct GNUNET_IDENTITY_Handle *id, const char *service_name, struct GNUNET_IDENTITY_Ego *ego, GNUNET_IDENTITY_Continuation cont, void *cont_cls)
 Set the preferred/default ego for a service. More...
 
void GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle *h)
 Disconnect from identity service. More...
 
struct GNUNET_IDENTITY_OperationGNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *id, const char *name, GNUNET_IDENTITY_CreateContinuation cont, void *cont_cls)
 Create a new ego with the given name. More...
 
struct GNUNET_IDENTITY_OperationGNUNET_IDENTITY_rename (struct GNUNET_IDENTITY_Handle *id, const char *old_name, const char *new_name, GNUNET_IDENTITY_Continuation cb, void *cb_cls)
 Renames an existing ego. More...
 
struct GNUNET_IDENTITY_OperationGNUNET_IDENTITY_delete (struct GNUNET_IDENTITY_Handle *id, const char *name, GNUNET_IDENTITY_Continuation cb, void *cb_cls)
 Delete an existing ego. More...
 
void GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op)
 Cancel an identity operation. More...
 
struct GNUNET_IDENTITY_EgoLookupGNUNET_IDENTITY_ego_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *name, GNUNET_IDENTITY_EgoCallback cb, void *cb_cls)
 Lookup an ego by name. More...
 
void GNUNET_IDENTITY_ego_lookup_cancel (struct GNUNET_IDENTITY_EgoLookup *el)
 Abort ego lookup attempt. More...
 
struct GNUNET_IDENTITY_EgoSuffixLookupGNUNET_IDENTITY_ego_lookup_by_suffix (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *suffix, GNUNET_IDENTITY_EgoSuffixCallback cb, void *cb_cls)
 Obtain the ego with the maximum suffix match between the ego's name and the given domain name suffix. More...
 
void GNUNET_IDENTITY_ego_lookup_by_suffix_cancel (struct GNUNET_IDENTITY_EgoSuffixLookup *el)
 Abort ego suffix lookup attempt. More...
 

Detailed Description

Identity management.

Egos in GNUnet are ECDSA keys. You assume an ego by using (signing with) a particular private key. As GNUnet users are expected to have many egos, we need an identity service to allow users to manage their egos. The identity service manages the egos (private keys) of the local user; it does NOT manage egos of other users (public keys). For giving names to other users and manage their public keys securely, we use GNS.

See also
Documentation

Macro Definition Documentation

◆ GNUNET_IDENTITY_VERSION

#define GNUNET_IDENTITY_VERSION   0x00000100

Version number of GNUnet Identity API.

Definition at line 58 of file gnunet_identity_service.h.

Typedef Documentation

◆ GNUNET_IDENTITY_Callback

typedef 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.

When used with GNUNET_IDENTITY_connect, this function is initially called for all egos and then again whenever a ego's name changes or if it is deleted. At the end of the initial pass over all egos, the function is once called with 'NULL' for ego. That does NOT mean that the callback won't be invoked in the future or that there was an error.

When used with GNUNET_IDENTITY_create or GNUNET_IDENTITY_get, this function is only called ONCE, and 'NULL' being passed in ego does indicate an error (i.e. name is taken or no default value is known). If ego is non-NULL and if '*ctx' is set in those callbacks, the value WILL be passed to a subsequent call to the identity callback of GNUNET_IDENTITY_connect (if that one was not NULL).

When an identity is renamed, this function is called with the (known) ego but the NEW name.

When an identity is deleted, this function is called with the (known) ego and "NULL" for the name. In this case, the ego is henceforth invalid (and the ctx should also be cleaned up).

Parameters
clsclosure
egoego handle
ctxcontext for application to store data for this ego (during the lifetime of this process, initially NULL)
namename assigned by the user for this ego, NULL if the user just deleted the ego and it must thus no longer be used

Definition at line 140 of file gnunet_identity_service.h.

◆ GNUNET_IDENTITY_Continuation

typedef void(* GNUNET_IDENTITY_Continuation) (void *cls, const char *emsg)

Function called once the requested operation has been completed.

Parameters
clsclosure
emsgNULL on success, otherwise an error message

Definition at line 183 of file gnunet_identity_service.h.

◆ GNUNET_IDENTITY_CreateContinuation

typedef void(* GNUNET_IDENTITY_CreateContinuation) (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk, const char *emsg)

Function called once the requested operation has been completed.

Parameters
clsclosure
pkprivate key, NULL on error
emsgerror message, NULL on success

Definition at line 221 of file gnunet_identity_service.h.

◆ GNUNET_IDENTITY_EgoCallback

typedef void(* GNUNET_IDENTITY_EgoCallback) (void *cls, const struct GNUNET_IDENTITY_Ego *ego)

Function called with the result.

Parameters
clsclosure
egoNULL on error / ego not found

Definition at line 297 of file gnunet_identity_service.h.

◆ GNUNET_IDENTITY_EgoSuffixCallback

typedef void(* GNUNET_IDENTITY_EgoSuffixCallback) (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, const char *ego_name)

Function called with the result.

Parameters
clsclosure
egoNULL on error / ego not found
ego_nameNULL on error, name of the ego otherwise

Definition at line 338 of file gnunet_identity_service.h.

Function Documentation

◆ GNUNET_IDENTITY_ego_get_private_key()

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.

Parameters
egothe ego
Returns
associated ECC key, valid as long as the ego is valid

Definition at line 555 of file identity_api.c.

References GNUNET_IDENTITY_Ego::pk.

Referenced by add_attribute_cont(), authorize_endpoint(), code_redirect(), consume_ticket_cont(), delete_attribute_cont(), directory_trim_complete(), ego_callback(), ego_cb(), get_ego(), GNUNET_CONVERSATION_phone_create(), handle_gns_response(), identity_cb(), list_attribute_cont(), list_tickets_cont(), namestore_add(), namestore_delete(), namestore_get(), print_ego(), revoke_ticket_cont(), sign_cb(), store_cb(), token_endpoint(), uri_ksk_continuation(), and userinfo_endpoint().

556 {
557  return ego->pk;
558 }
struct GNUNET_CRYPTO_EcdsaPrivateKey * pk
Private key associated with this ego.
Definition: identity.h:250
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_ego_get_anonymous()

const struct GNUNET_IDENTITY_Ego* GNUNET_IDENTITY_ego_get_anonymous ( void  )

Obtain the ego representing 'anonymous' users.

Returns
handle for the anonymous user, must not be freed

Definition at line 156 of file identity_api.c.

References GNUNET_IDENTITY_Operation::cls, GNUNET_CRYPTO_ecdsa_key_get_anonymous(), GNUNET_CRYPTO_ecdsa_key_get_public(), GNUNET_CRYPTO_hash(), GNUNET_IDENTITY_Ego::id, GNUNET_IDENTITY_Ego::pk, and reconnect().

157 {
158  static struct GNUNET_IDENTITY_Ego anon;
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 }
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
Private ECC key encoded for transmission.
Handle for an ego.
Definition: identity.h:245
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
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
static struct GNUNET_CRYPTO_EddsaPublicKey pub
Definition: gnunet-scrypt.c:39
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
Here is the call graph for this function:

◆ GNUNET_IDENTITY_ego_get_public_key()

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.

Parameters
egoidentity handle with the private key
pkset to ego's public key

Definition at line 568 of file identity_api.c.

References GNUNET_CRYPTO_ecdsa_key_get_public(), and GNUNET_IDENTITY_Ego::pk.

Referenced by code_redirect(), consume_ticket_cont(), ego_callback(), ego_get_for_subsystem(), find_ego(), get_ego(), id_connect_cb(), init_egos(), list_ego(), print_ego(), revoke_ticket_cont(), and store_cb().

570 {
572 }
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_CRYPTO_EcdsaPrivateKey * pk
Private key associated with this ego.
Definition: identity.h:250
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_connect()

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.

Parameters
cfgConfiguration to contact the identity service.
cbfunction to call on all identity events, can be NULL
cb_clsclosure for cb
Returns
handle to communicate with identity service
Parameters
cfgthe configuration to use
cbfunction to call on all identity events, can be NULL
cb_clsclosure for cb
Returns
handle to use

Definition at line 527 of file identity_api.c.

References GNUNET_IDENTITY_Operation::cb, GNUNET_IDENTITY_Handle::cb, GNUNET_IDENTITY_Handle::cb_cls, cfg, GNUNET_IDENTITY_Handle::cfg, GNUNET_IDENTITY_Handle::egos, GNUNET_CONTAINER_multihashmap_create(), GNUNET_free, GNUNET_new, GNUNET_YES, GNUNET_IDENTITY_Operation::h, GNUNET_IDENTITY_Handle::mq, and reconnect().

Referenced by rest_identity_process_request(), rest_process_request(), and run().

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 }
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 const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static void reconnect(void *cls)
Try again to connect to the identity service.
Definition: identity_api.c:483
Handle for the service.
Definition: identity_api.c:95
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: identity_api.c:100
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
#define GNUNET_YES
Definition: gnunet_common.h:77
void * cb_cls
Closure for cb.
Definition: identity_api.c:121
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:105
GNUNET_IDENTITY_Callback cb
Function to call when we receive updates.
Definition: identity_api.c:116
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_get()

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 ego that is currently preferred/default for a service.

Parameters
ididentity service to query
service_namefor which service is an identity wanted
cbfunction to call with the result (will only be called once)
cb_clsclosure for cb
Returns
handle to abort the operation

Obtain the ego that is currently preferred/default for a service.

Parameters
hidentity service to query
service_namefor which service is an identity wanted
cbfunction to call with the result (will only be called once)
cb_clsclosure for cb
Returns
handle to abort the operation

Definition at line 586 of file identity_api.c.

References GNUNET_IDENTITY_Operation::cb, GNUNET_IDENTITY_Handle::cb, GNUNET_IDENTITY_Operation::cls, env, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_IDENTITY_Operation::h, GNUNET_IDENTITY_Handle::mq, GetDefaultMessage::name_len, op, GNUNET_IDENTITY_Handle::op_head, GNUNET_IDENTITY_Handle::op_tail, and GetDefaultMessage::reserved.

Referenced by ego_get_subsystem(), and id_connect_cb().

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 }
uint16_t reserved
Always zero.
Definition: identity.h:123
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
uint16_t name_len
Number of bytes in service name string including 0-termination, in NBO.
Definition: identity.h:118
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct GNUNET_IDENTITY_Operation * op_tail
Tail of active operations.
Definition: identity_api.c:131
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#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
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
#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
static char * service_name
Option -s: service name (hash to get service descriptor)
Definition: gnunet-vpn.c:51
struct GNUNET_IDENTITY_Operation * op_head
Head of active operations.
Definition: identity_api.c:126
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_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
void * cls
Closure for cont or cb.
Definition: identity_api.c:88
#define GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT
Client requests to know default identity for a subsystem.
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
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 struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
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 'get' operations (cont and create_cont...
Definition: identity_api.c:83
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_set()

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 ego for a service.

Parameters
ididentity service to inform
service_namefor which service is an identity set
egonew default identity to be set for this service
contfunction to call once the operation finished
cont_clsclosure for cont
Returns
handle to abort the operation

Set the preferred/default ego for a service.

Parameters
hidentity service to inform
service_namefor which service is an identity set
egonew default identity to be set for this service
contfunction to call once the operation finished
cont_clsclosure for cont
Returns
handle to abort the operation

Definition at line 631 of file identity_api.c.

References GNUNET_IDENTITY_Handle::cb, GNUNET_IDENTITY_Operation::cls, GNUNET_IDENTITY_Operation::cont, env, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_IDENTITY_Operation::h, GNUNET_IDENTITY_Handle::mq, SetDefaultMessage::name_len, op, GNUNET_IDENTITY_Handle::op_head, GNUNET_IDENTITY_Handle::op_tail, GNUNET_IDENTITY_Ego::pk, SetDefaultMessage::private_key, and SetDefaultMessage::reserved.

Referenced by ego_edit_subsystem(), and print_ego().

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 }
struct GNUNET_CRYPTO_EcdsaPrivateKey private_key
The private key.
Definition: identity.h:154
#define GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT
Client sets default identity; or service informs about default identity.
Used from service to client as a result to the GET_DEFAULT message, used from client to service to SE...
Definition: identity.h:134
uint16_t name_len
Number of bytes in service name string including 0-termination, in NBO.
Definition: identity.h:144
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct GNUNET_IDENTITY_Operation * op_tail
Tail of active operations.
Definition: identity_api.c:131
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#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
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
uint16_t reserved
Always zero.
Definition: identity.h:149
#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
static char * service_name
Option -s: service name (hash to get service descriptor)
Definition: gnunet-vpn.c:51
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
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_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
void * cls
Closure for cont or cb.
Definition: identity_api.c:88
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
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:105
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
GNUNET_IDENTITY_Callback cb
Function to call when we receive updates.
Definition: identity_api.c:116
struct GNUNET_CRYPTO_EcdsaPrivateKey * pk
Private key associated with this ego.
Definition: identity.h:250
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_disconnect()

void GNUNET_IDENTITY_disconnect ( struct GNUNET_IDENTITY_Handle h)

Disconnect from identity service.

Parameters
hidentity service to disconnect
hhandle to destroy

Definition at line 837 of file identity_api.c.

References GNUNET_IDENTITY_Operation::cont, GNUNET_IDENTITY_Handle::egos, free_ego(), GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_free, GNUNET_free_non_null, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), GNUNET_IDENTITY_Handle::mq, op, GNUNET_IDENTITY_Handle::op_head, GNUNET_IDENTITY_Handle::op_tail, GNUNET_IDENTITY_Operation::pk, and GNUNET_IDENTITY_Handle::reconnect_task.

Referenced by cleanup_handle(), do_cleanup(), do_shutdown(), do_stop_task(), process_stdin(), and shutdown_task().

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 }
#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
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_IDENTITY_Operation * op_tail
Tail of active operations.
Definition: identity_api.c:131
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#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
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
struct GNUNET_CRYPTO_EcdsaPrivateKey * pk
Private key to return to create_cont, or NULL.
Definition: identity_api.c:77
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 int free_ego(void *cls, const struct GNUNET_HashCode *key, void *value)
Free ego from hash map.
Definition: identity_api.c:189
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:105
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.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_create()

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 ego with the given name.

Parameters
ididentity service to use
namedesired name
contfunction to call with the result (will only be called once)
cont_clsclosure for cont
Returns
handle to abort the operation

Create a new ego with the given name.

Parameters
hidentity service to use
namedesired name
contfunction to call with the result (will only be called once)
cont_clsclosure for cont
Returns
handle to abort the operation

Definition at line 677 of file identity_api.c.

References GNUNET_IDENTITY_Operation::cls, GNUNET_IDENTITY_Operation::cont, GNUNET_IDENTITY_Operation::create_cont, env, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CRYPTO_ecdsa_key_create(), GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_IDENTITY_CREATE, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_IDENTITY_Operation::h, GNUNET_IDENTITY_Handle::mq, CreateRequestMessage::name_len, op, GNUNET_IDENTITY_Handle::op_head, GNUNET_IDENTITY_Handle::op_tail, GNUNET_IDENTITY_Operation::pk, CreateRequestMessage::private_key, and CreateRequestMessage::reserved.

Referenced by ego_create(), and run().

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 }
uint16_t reserved
Always zero.
Definition: identity.h:179
static struct GNUNET_CRYPTO_EddsaPrivateKey * pk
Private key of this peer.
struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_CRYPTO_ecdsa_key_create(void)
Create a new private key.
Definition: crypto_ecc.c:688
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct GNUNET_IDENTITY_Operation * op_tail
Tail of active operations.
Definition: identity_api.c:131
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Private ECC key encoded for transmission.
uint16_t name_len
Number of bytes in identity name string including 0-termination, in NBO.
Definition: identity.h:174
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
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
#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
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
Client requests creation of an identity.
Definition: identity.h:164
struct GNUNET_CRYPTO_EcdsaPrivateKey * pk
Private key to return to create_cont, or NULL.
Definition: identity_api.c:77
struct GNUNET_IDENTITY_Operation * op_head
Head of active operations.
Definition: identity_api.c:126
#define GNUNET_MESSAGE_TYPE_IDENTITY_CREATE
Create new identity (client->service).
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_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
const char * name
void * cls
Closure for cont or cb.
Definition: identity_api.c:88
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
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:105
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_rename()

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 ego.

Parameters
ididentity service to use
old_nameold name
new_namedesired new name
cbfunction to call with the result (will only be called once)
cb_clsclosure for cb
Returns
handle to abort the operation

Renames an existing ego.

Parameters
hidentity service to use
old_nameold name
new_namedesired new name
cbfunction to call with the result (will only be called once)
cb_clsclosure for cb
Returns
handle to abort the operation

Definition at line 724 of file identity_api.c.

References GNUNET_IDENTITY_Operation::cb, GNUNET_IDENTITY_Operation::cls, GNUNET_IDENTITY_Operation::cont, env, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_IDENTITY_RENAME, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_IDENTITY_Operation::h, GNUNET_IDENTITY_Handle::mq, RenameMessage::new_name_len, RenameMessage::old_name_len, op, GNUNET_IDENTITY_Handle::op_head, and GNUNET_IDENTITY_Handle::op_tail.

Referenced by ego_edit().

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 }
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
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct GNUNET_IDENTITY_Operation * op_tail
Tail of active operations.
Definition: identity_api.c:131
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#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
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
#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
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
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_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
uint16_t new_name_len
Number of characters in the new name including 0-termination, in NBO.
Definition: identity.h:209
void * cls
Closure for cont or cb.
Definition: identity_api.c:88
#define GNUNET_MESSAGE_TYPE_IDENTITY_RENAME
Rename existing identity (client->service).
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
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:105
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_delete()

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 ego.

Parameters
ididentity service to use
namename of the identity to delete
cbfunction to call with the result (will only be called once)
cb_clsclosure for cb
Returns
handle to abort the operation

Delete an existing ego.

Parameters
hidentity service to use
namename of the identity to delete
cbfunction to call with the result (will only be called once)
cb_clsclosure for cb
Returns
handle to abort the operation

Definition at line 777 of file identity_api.c.

References GNUNET_IDENTITY_Operation::cb, GNUNET_IDENTITY_Operation::cls, GNUNET_IDENTITY_Operation::cont, env, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_IDENTITY_DELETE, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_IDENTITY_Operation::h, GNUNET_IDENTITY_Handle::mq, DeleteMessage::name_len, op, GNUNET_IDENTITY_Handle::op_head, GNUNET_IDENTITY_Handle::op_tail, and DeleteMessage::reserved.

Referenced by ego_delete_name(), ego_delete_pubkey(), and run().

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 }
#define GNUNET_MESSAGE_TYPE_IDENTITY_DELETE
Delete identity (client->service).
#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_new(type)
Allocate a struct or union of the given type.
#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
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
#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
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
Client requests deletion of an identity.
Definition: identity.h:220
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_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
const char * name
void * cls
Closure for cont or cb.
Definition: identity_api.c:88
uint16_t name_len
Number of characters in the name including 0-termination, in NBO.
Definition: identity.h:230
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
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:105
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_cancel()

void GNUNET_IDENTITY_cancel ( struct GNUNET_IDENTITY_Operation op)

Cancel an identity operation.

Note that the operation MAY still be executed; this merely cancels the continuation; if the request was already transmitted, the service may still choose to complete the operation.

Parameters
opoperation to cancel

Definition at line 818 of file identity_api.c.

References GNUNET_IDENTITY_Operation::cb, GNUNET_IDENTITY_Operation::cont, GNUNET_IDENTITY_Operation::create_cont, GNUNET_free, and GNUNET_IDENTITY_Operation::pk.

Referenced by do_shutdown(), and shutdown_task().

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 }
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
struct GNUNET_CRYPTO_EcdsaPrivateKey * pk
Private key to return to create_cont, or NULL.
Definition: identity_api.c:77
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
GNUNET_IDENTITY_Callback cb
Continuation to invoke with the result of the transmission for 'get' operations (cont and create_cont...
Definition: identity_api.c:83
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_ego_lookup()

struct GNUNET_IDENTITY_EgoLookup* GNUNET_IDENTITY_ego_lookup ( const struct GNUNET_CONFIGURATION_Handle cfg,
const char *  name,
GNUNET_IDENTITY_EgoCallback  cb,
void *  cb_cls 
)

Lookup an ego by name.

Parameters
cfgconfiguration to use
namename to look up
cbcallback to invoke with the result
cb_clsclosure for cb
Returns
NULL on error

Definition at line 172 of file identity_api_lookup.c.

References GNUNET_IDENTITY_EgoLookup::cb, GNUNET_IDENTITY_EgoLookup::cb_cls, el, env, GNUNET_assert, GNUNET_break, GNUNET_CLIENT_connect(), GNUNET_free, GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP, GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE, GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_strdup, GNUNET_IDENTITY_EgoLookup::mq, mq_error_handler(), and GNUNET_IDENTITY_EgoLookup::name.

Referenced by run().

176 {
178  struct GNUNET_MQ_Envelope *env;
179  struct GNUNET_MessageHeader *req;
180  size_t nlen;
181 
182  GNUNET_assert (NULL != cb);
184  el->cb = cb;
185  el->cb_cls = cb_cls;
186  {
188  { GNUNET_MQ_hd_var_size (identity_result_code,
190  struct ResultCodeMessage,
191  el),
192  GNUNET_MQ_hd_var_size (identity_update,
194  struct UpdateMessage,
195  el),
197 
198  el->mq =
199  GNUNET_CLIENT_connect (cfg, "identity", handlers, &mq_error_handler, el);
200  }
201  if (NULL == el->mq)
202  {
203  GNUNET_break (0);
204  GNUNET_free (el);
205  return NULL;
206  }
207  el->name = GNUNET_strdup (name);
208  nlen = strlen (name) + 1;
210  memcpy (&req[1], name, nlen);
211  GNUNET_MQ_send (el->mq, env);
212  return el;
213 }
Handle for ego lookup.
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
struct GNUNET_MQ_Handle * mq
Connection to service.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE
Update about identity status from service to clients.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#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
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP
First message send from identity client to service to lookup a single ego.
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...
Message handler for a specific message type.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
char * name
Name of the ego we are looking up.
const char * name
GNUNET_IDENTITY_EgoCallback cb
Function to call with the result.
Header for all communications.
#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
static struct GNUNET_IDENTITY_EgoLookup * el
EgoLookup.
Definition: gnunet-abd.c:51
void * cb_cls
Closure for cb.
#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.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_ego_lookup_cancel()

void GNUNET_IDENTITY_ego_lookup_cancel ( struct GNUNET_IDENTITY_EgoLookup el)

Abort ego lookup attempt.

Parameters
elhandle for lookup to abort

Definition at line 222 of file identity_api_lookup.c.

References GNUNET_free, GNUNET_MQ_destroy(), GNUNET_IDENTITY_EgoLookup::mq, and GNUNET_IDENTITY_EgoLookup::name.

Referenced by do_shutdown(), handle_identity_result_code(), and handle_identity_update().

223 {
224  GNUNET_MQ_destroy (el->mq);
225  GNUNET_free (el->name);
226  GNUNET_free (el);
227 }
struct GNUNET_MQ_Handle * mq
Connection to service.
char * name
Name of the ego we are looking up.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_ego_lookup_by_suffix()

struct GNUNET_IDENTITY_EgoSuffixLookup* GNUNET_IDENTITY_ego_lookup_by_suffix ( const struct GNUNET_CONFIGURATION_Handle cfg,
const char *  suffix,
GNUNET_IDENTITY_EgoSuffixCallback  cb,
void *  cb_cls 
)

Obtain the ego with the maximum suffix match between the ego's name and the given domain name suffix.

I.e., given a suffix "a.b.c" and egos with names "d.a.b.c", "b.c" and "c", we return the ego for "b.c".

Parameters
cfgconfiguration to use
suffixfor which domain name suffix is an identity wanted
cbfunction to call with the result (will only be called once)
cb_clsclosure for cb
Returns
handle to abort the operation

Obtain the ego with the maximum suffix match between the ego's name and the given domain name suffix.

Parameters
cfgconfiguration to use
namename to look up
cbcallback to invoke with the result
cb_clsclosure for cb
Returns
NULL on error

Definition at line 168 of file identity_api_suffix_lookup.c.

References GNUNET_IDENTITY_EgoSuffixLookup::cb, GNUNET_IDENTITY_EgoSuffixLookup::cb_cls, el, env, GNUNET_assert, GNUNET_break, GNUNET_CLIENT_connect(), GNUNET_free, GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP_BY_SUFFIX, GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE, GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_strdup, GNUNET_IDENTITY_EgoSuffixLookup::mq, mq_error_handler(), and GNUNET_IDENTITY_EgoSuffixLookup::suffix.

Referenced by GNUNET_GNS_lookup_with_tld().

173 {
175  struct GNUNET_MQ_Envelope *env;
176  struct GNUNET_MessageHeader *req;
177  size_t nlen;
178 
179  GNUNET_assert (NULL != cb);
181  el->cb = cb;
182  el->cb_cls = cb_cls;
183  {
185  { GNUNET_MQ_hd_var_size (identity_result_code,
187  struct ResultCodeMessage,
188  el),
189  GNUNET_MQ_hd_var_size (identity_update,
191  struct UpdateMessage,
192  el),
194 
195  el->mq =
196  GNUNET_CLIENT_connect (cfg, "identity", handlers, &mq_error_handler, el);
197  }
198  if (NULL == el->mq)
199  {
200  GNUNET_break (0);
201  GNUNET_free (el);
202  return NULL;
203  }
204  el->suffix = GNUNET_strdup (suffix);
205  nlen = strlen (suffix) + 1;
206  env = GNUNET_MQ_msg_extra (req, nlen,
208  memcpy (&req[1], suffix, nlen);
209  GNUNET_MQ_send (el->mq, env);
210  return el;
211 }
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
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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...
#define GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE
Update about identity status from service to clients.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_MQ_Handle * mq
Connection to service.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#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
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
Message handler for a specific message type.
#define GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP_BY_SUFFIX
First message send from identity client to service to lookup a single ego matching the given suffix (...
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
GNUNET_IDENTITY_EgoSuffixCallback cb
Function to call with the result.
Header for all communications.
#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
char * suffix
Suffix we are looking up.
static struct GNUNET_IDENTITY_EgoLookup * el
EgoLookup.
Definition: gnunet-abd.c:51
#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.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_ego_lookup_by_suffix_cancel()

void GNUNET_IDENTITY_ego_lookup_by_suffix_cancel ( struct GNUNET_IDENTITY_EgoSuffixLookup el)

Abort ego suffix lookup attempt.

Parameters
elhandle for lookup to abort

Abort ego suffix lookup attempt.

Parameters
elhandle for lookup to abort

Definition at line 220 of file identity_api_suffix_lookup.c.

References GNUNET_free, GNUNET_MQ_destroy(), GNUNET_IDENTITY_EgoSuffixLookup::mq, and GNUNET_IDENTITY_EgoSuffixLookup::suffix.

Referenced by GNUNET_GNS_lookup_with_tld_cancel(), handle_identity_result_code(), handle_identity_update(), and mq_error_handler().

222 {
223  GNUNET_MQ_destroy (el->mq);
224  GNUNET_free (el->suffix);
225  GNUNET_free (el);
226 }
struct GNUNET_MQ_Handle * mq
Connection to service.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
char * suffix
Suffix we are looking up.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function: