GNUnet  0.10.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 556 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_cred_issuer_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(), subject_ego_lookup(), token_endpoint(), uri_ksk_continuation(), and userinfo_endpoint().

557 {
558  return ego->pk;
559 }
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 157 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().

158 {
159  static struct GNUNET_IDENTITY_Ego anon;
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 }
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
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:44
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
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 569 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(), identity_master_cb(), init_egos(), list_ego(), print_ego(), and revoke_ticket_cont().

571 {
573 }
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_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 528 of file identity_api.c.

References GNUNET_IDENTITY_Operation::cb, GNUNET_IDENTITY_Handle::cb, GNUNET_IDENTITY_Handle::cb_cls, GNUNET_IDENTITY_Handle::cfg, 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 issue_cred_cont(), rest_identity_process_request(), rest_process_request(), and run().

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 }
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
#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:94
static void reconnect(void *cls)
Try again to connect to the identity service.
Definition: identity_api.c:484
Handle for the service.
Definition: identity_api.c:96
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: identity_api.c:101
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
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:80
void * cb_cls
Closure for cb.
Definition: identity_api.c:122
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:106
GNUNET_IDENTITY_Callback cb
Function to call when we receive updates.
Definition: identity_api.c:117
#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 587 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(), id_connect_cb(), issue_cred_cont(), and run().

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 }
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
struct GNUNET_IDENTITY_Operation * op_tail
Tail of active operations.
Definition: identity_api.c:132
#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:94
#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
#define GNUNET_memcpy(dst, src, n)
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:127
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_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:89
#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:106
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
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 'get' operations (cont and create_cont...
Definition: identity_api.c:84
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 632 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().

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 }
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.
struct GNUNET_IDENTITY_Operation * op_tail
Tail of active operations.
Definition: identity_api.c:132
#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:94
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
#define GNUNET_memcpy(dst, src, n)
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:67
struct GNUNET_IDENTITY_Operation * op_head
Head of active operations.
Definition: identity_api.c:127
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_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:89
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:106
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
GNUNET_IDENTITY_Callback cb
Function to call when we receive updates.
Definition: identity_api.c:117
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 838 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().

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 }
#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
#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:132
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_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:137
struct GNUNET_CRYPTO_EcdsaPrivateKey * pk
Private key to return to create_cont, or NULL.
Definition: identity_api.c:78
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 int free_ego(void *cls, const struct GNUNET_HashCode *key, void *value)
Free ego from hash map.
Definition: identity_api.c:190
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:106
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
#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:965
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 678 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().

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 }
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:691
struct GNUNET_IDENTITY_Operation * op_tail
Tail of active operations.
Definition: identity_api.c:132
#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:94
#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
#define GNUNET_memcpy(dst, src, n)
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
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:78
struct GNUNET_IDENTITY_Operation * op_head
Head of active operations.
Definition: identity_api.c:127
#define GNUNET_MESSAGE_TYPE_IDENTITY_CREATE
Create new identity (client->service).
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_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:89
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:106
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
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 725 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().

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 }
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_IDENTITY_Operation * op_tail
Tail of active operations.
Definition: identity_api.c:132
#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:94
#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
#define GNUNET_memcpy(dst, src, n)
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
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_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:89
#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:106
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
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 778 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().

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 }
#define GNUNET_MESSAGE_TYPE_IDENTITY_DELETE
Delete identity (client->service).
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_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:94
#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
#define GNUNET_memcpy(dst, src, n)
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
Client requests deletion of an identity.
Definition: identity.h:220
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_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:89
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:106
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
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 819 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 cleanup_handle(), do_shutdown(), and shutdown_task().

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 }
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
struct GNUNET_CRYPTO_EcdsaPrivateKey * pk
Private key to return to create_cont, or NULL.
Definition: identity_api.c:78
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
GNUNET_IDENTITY_Callback cb
Continuation to invoke with the result of the transmission for 'get' operations (cont and create_cont...
Definition: identity_api.c:84
#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 173 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 collect_cred_cont(), and run().

177 {
179  struct GNUNET_MQ_Envelope *env;
180  struct GNUNET_MessageHeader *req;
181  size_t nlen;
182 
183  GNUNET_assert (NULL != cb);
185  el->cb = cb;
186  el->cb_cls = cb_cls;
187  {
189  {GNUNET_MQ_hd_var_size (identity_result_code,
191  struct ResultCodeMessage,
192  el),
193  GNUNET_MQ_hd_var_size (identity_update,
195  struct UpdateMessage,
196  el),
198 
199  el->mq =
200  GNUNET_CLIENT_connect (cfg, "identity", handlers, &mq_error_handler, el);
201  }
202  if (NULL == el->mq)
203  {
204  GNUNET_break (0);
205  GNUNET_free (el);
206  return NULL;
207  }
208  el->name = GNUNET_strdup (name);
209  nlen = strlen (name) + 1;
211  memcpy (&req[1], name, nlen);
212  GNUNET_MQ_send (el->mq, env);
213  return el;
214 }
Handle for ego lookup.
static struct GNUNET_IDENTITY_EgoLookup * el
EgoLookup.
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
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.
const char * name
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
char * name
Name of the ego we are looking up.
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
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 223 of file identity_api_lookup.c.

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

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

224 {
225  GNUNET_MQ_destroy (el->mq);
226  GNUNET_free (el->name);
227  GNUNET_free (el);
228 }
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 169 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;
207  memcpy (&req[1], suffix, nlen);
208  GNUNET_MQ_send (el->mq, env);
209  return el;
210 }
static struct GNUNET_IDENTITY_EgoLookup * el
EgoLookup.
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
#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.
#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 219 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().

220 {
221  GNUNET_MQ_destroy (el->mq);
222  GNUNET_free (el->suffix);
223  GNUNET_free (el);
224 }
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: