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 553 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().

554 {
555  return ego->pk;
556 }
struct GNUNET_CRYPTO_EcdsaPrivateKey * pk
Private key associated with this ego.
Definition: identity.h:241
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 154 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().

155 {
156  static struct GNUNET_IDENTITY_Ego anon;
158 
159  if (NULL != anon.pk)
160  return &anon;
161  anon.pk = (struct GNUNET_CRYPTO_EcdsaPrivateKey *)
164  GNUNET_CRYPTO_hash(&pub, sizeof(pub), &anon.id);
165  return &anon;
166 }
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:237
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 566 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(), and revoke_ticket_cont().

568 {
570 }
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:241
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 525 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().

528 {
529  struct GNUNET_IDENTITY_Handle *h;
530 
532  h->cfg = cfg;
533  h->cb = cb;
534  h->cb_cls = cb_cls;
536  reconnect(h);
537  if (NULL == h->mq)
538  {
539  GNUNET_free(h);
540  return NULL;
541  }
542  return h;
543 }
struct GNUNET_CONTAINER_MultiHashMap * egos
Hash map from the hash of the public key to the respective GNUNET_IDENTITY_Ego handle.
Definition: identity_api.c:109
#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:481
Handle for the service.
Definition: identity_api.c:94
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: identity_api.c:98
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:77
void * cb_cls
Closure for cb.
Definition: identity_api.c:119
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:103
GNUNET_IDENTITY_Callback cb
Function to call when we receive updates.
Definition: identity_api.c:114
#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 584 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(), and issue_cred_cont().

588 {
590  struct GNUNET_MQ_Envelope *env;
591  struct GetDefaultMessage *gdm;
592  size_t slen;
593 
594  if (NULL == h->mq)
595  return NULL;
596  GNUNET_assert(NULL != h->cb);
597  slen = strlen(service_name) + 1;
598  if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct GetDefaultMessage))
599  {
600  GNUNET_break(0);
601  return NULL;
602  }
604  op->h = h;
605  op->cb = cb;
606  op->cls = cb_cls;
608  env =
610  gdm->name_len = htons(slen);
611  gdm->reserved = htons(0);
612  GNUNET_memcpy(&gdm[1], service_name, slen);
613  GNUNET_MQ_send(h->mq, env);
614  return op;
615 }
uint16_t reserved
Always zero.
Definition: identity.h:119
#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:114
#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:129
#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
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:124
struct GNUNET_IDENTITY_Handle * h
Main identity handle.
Definition: identity_api.c:43
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_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:87
#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:351
Client requests knowledge about default identity for a subsystem from identity service.
Definition: identity.h:105
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:103
static 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:114
GNUNET_IDENTITY_Callback cb
Continuation to invoke with the result of the transmission for 'get' operations (cont and create_cont...
Definition: identity_api.c:82
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 629 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().

634 {
636  struct GNUNET_MQ_Envelope *env;
637  struct SetDefaultMessage *sdm;
638  size_t slen;
639 
640  if (NULL == h->mq)
641  return NULL;
642  GNUNET_assert(NULL != h->cb);
643  slen = strlen(service_name) + 1;
644  if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct SetDefaultMessage))
645  {
646  GNUNET_break(0);
647  return NULL;
648  }
650  op->h = h;
651  op->cont = cont;
652  op->cls = cont_cls;
654  env =
656  sdm->name_len = htons(slen);
657  sdm->reserved = htons(0);
658  sdm->private_key = *ego->pk;
659  GNUNET_memcpy(&sdm[1], service_name, slen);
660  GNUNET_MQ_send(h->mq, env);
661  return op;
662 }
struct GNUNET_CRYPTO_EcdsaPrivateKey private_key
The private key.
Definition: identity.h:149
#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:130
uint16_t name_len
Number of bytes in service name string including 0-termination, in NBO.
Definition: identity.h:139
#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:129
#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:144
#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:65
struct GNUNET_IDENTITY_Operation * op_head
Head of active operations.
Definition: identity_api.c:124
struct GNUNET_IDENTITY_Handle * h
Main identity handle.
Definition: identity_api.c:43
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_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:87
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:351
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:103
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:114
struct GNUNET_CRYPTO_EcdsaPrivateKey * pk
Private key associated with this ego.
Definition: identity.h:241
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 835 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().

836 {
838 
839  GNUNET_assert(NULL != h);
840  if (h->reconnect_task != NULL)
841  {
843  h->reconnect_task = NULL;
844  }
845  if (NULL != h->egos)
846  {
849  h->egos = NULL;
850  }
851  while (NULL != (op = h->op_head))
852  {
853  GNUNET_break(NULL == op->cont);
856  GNUNET_free(op);
857  }
858  if (NULL != h->mq)
859  {
860  GNUNET_MQ_destroy(h->mq);
861  h->mq = NULL;
862  }
863  GNUNET_free(h);
864 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_CONTAINER_MultiHashMap * egos
Hash map from the hash of the public key to the respective GNUNET_IDENTITY_Ego handle.
Definition: identity_api.c:109
#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:129
#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:134
struct GNUNET_CRYPTO_EcdsaPrivateKey * pk
Private key to return to create_cont, or NULL.
Definition: identity_api.c:76
GNUNET_IDENTITY_Continuation cont
Continuation to invoke with the result of the transmission; cb and create_cont will be NULL in this c...
Definition: identity_api.c:65
struct GNUNET_IDENTITY_Operation * op_head
Head of active operations.
Definition: identity_api.c:124
static int free_ego(void *cls, const struct GNUNET_HashCode *key, void *value)
Free ego from hash map.
Definition: identity_api.c:187
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:821
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:103
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
#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:956
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 675 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().

679 {
681  struct GNUNET_MQ_Envelope *env;
682  struct CreateRequestMessage *crm;
684  size_t slen;
685 
686  if (NULL == h->mq)
687  return NULL;
688  slen = strlen(name) + 1;
689  if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct CreateRequestMessage))
690  {
691  GNUNET_break(0);
692  return NULL;
693  }
695  op->h = h;
696  op->create_cont = cont;
697  op->cls = cont_cls;
700  crm->name_len = htons(slen);
701  crm->reserved = htons(0);
703  crm->private_key = *pk;
704  op->pk = pk;
705  GNUNET_memcpy(&crm[1], name, slen);
706  GNUNET_MQ_send(h->mq, env);
707  return op;
708 }
uint16_t reserved
Always zero.
Definition: identity.h:173
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
#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:129
#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:168
struct GNUNET_CRYPTO_EcdsaPrivateKey private_key
The private key.
Definition: identity.h:178
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Handle for an operation with the identity service.
Definition: identity_api.c:39
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
GNUNET_IDENTITY_CreateContinuation create_cont
Continuation to invoke with the result of the transmission; cb and cb will be NULL in this case...
Definition: identity_api.c:71
Client requests creation of an identity.
Definition: identity.h:159
struct GNUNET_CRYPTO_EcdsaPrivateKey * pk
Private key to return to create_cont, or NULL.
Definition: identity_api.c:76
struct GNUNET_IDENTITY_Operation * op_head
Head of active operations.
Definition: identity_api.c:124
#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:43
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_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:87
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:351
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:103
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 722 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().

727 {
729  struct GNUNET_MQ_Envelope *env;
730  struct RenameMessage *grm;
731  size_t slen_old;
732  size_t slen_new;
733  char *dst;
734 
735  if (NULL == h->mq)
736  return NULL;
737  slen_old = strlen(old_name) + 1;
738  slen_new = strlen(new_name) + 1;
739  if ((slen_old >= GNUNET_MAX_MESSAGE_SIZE) ||
740  (slen_new >= GNUNET_MAX_MESSAGE_SIZE) ||
741  (slen_old + slen_new >=
742  GNUNET_MAX_MESSAGE_SIZE - sizeof(struct RenameMessage)))
743  {
744  GNUNET_break(0);
745  return NULL;
746  }
748  op->h = h;
749  op->cont = cb;
750  op->cls = cb_cls;
752  env = GNUNET_MQ_msg_extra(grm,
753  slen_old + slen_new,
755  grm->old_name_len = htons(slen_old);
756  grm->new_name_len = htons(slen_new);
757  dst = (char *)&grm[1];
758  GNUNET_memcpy(dst, old_name, slen_old);
759  GNUNET_memcpy(&dst[slen_old], new_name, slen_new);
760  GNUNET_MQ_send(h->mq, env);
761  return op;
762 }
uint16_t old_name_len
Number of characters in the old name including 0-termination, in NBO.
Definition: identity.h:197
Client requests renaming of an identity.
Definition: identity.h:188
#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:129
#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
GNUNET_IDENTITY_Continuation cont
Continuation to invoke with the result of the transmission; cb and create_cont will be NULL in this c...
Definition: identity_api.c:65
struct GNUNET_IDENTITY_Operation * op_head
Head of active operations.
Definition: identity_api.c:124
struct GNUNET_IDENTITY_Handle * h
Main identity handle.
Definition: identity_api.c:43
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_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:202
void * cls
Closure for cont or cb.
Definition: identity_api.c:87
#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:351
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:103
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 775 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().

779 {
781  struct GNUNET_MQ_Envelope *env;
782  struct DeleteMessage *gdm;
783  size_t slen;
784 
785  if (NULL == h->mq)
786  return NULL;
787  slen = strlen(name) + 1;
788  if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct DeleteMessage))
789  {
790  GNUNET_break(0);
791  return NULL;
792  }
794  op->h = h;
795  op->cont = cb;
796  op->cls = cb_cls;
799  gdm->name_len = htons(slen);
800  gdm->reserved = htons(0);
801  GNUNET_memcpy(&gdm[1], name, slen);
802  GNUNET_MQ_send(h->mq, env);
803  return op;
804 }
#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:227
struct GNUNET_IDENTITY_Operation * op_tail
Tail of active operations.
Definition: identity_api.c:129
#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
GNUNET_IDENTITY_Continuation cont
Continuation to invoke with the result of the transmission; cb and create_cont will be NULL in this c...
Definition: identity_api.c:65
struct GNUNET_IDENTITY_Operation * op_head
Head of active operations.
Definition: identity_api.c:124
Client requests deletion of an identity.
Definition: identity.h:213
const char * name
struct GNUNET_IDENTITY_Handle * h
Main identity handle.
Definition: identity_api.c:43
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_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:87
uint16_t name_len
Number of characters in the name including 0-termination, in NBO.
Definition: identity.h:222
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:351
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:103
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 816 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().

817 {
818  op->cont = NULL;
819  op->cb = NULL;
820  op->create_cont = NULL;
821  if (NULL != op->pk)
822  {
823  GNUNET_free(op->pk);
824  op->pk = NULL;
825  }
826 }
GNUNET_IDENTITY_CreateContinuation create_cont
Continuation to invoke with the result of the transmission; cb and cb will be NULL in this case...
Definition: identity_api.c:71
struct GNUNET_CRYPTO_EcdsaPrivateKey * pk
Private key to return to create_cont, or NULL.
Definition: identity_api.c:76
GNUNET_IDENTITY_Continuation cont
Continuation to invoke with the result of the transmission; cb and create_cont will be NULL in this c...
Definition: identity_api.c:65
GNUNET_IDENTITY_Callback cb
Continuation to invoke with the result of the transmission for 'get' operations (cont and create_cont...
Definition: identity_api.c:82
#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 171 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().

175 {
177  struct GNUNET_MQ_Envelope *env;
178  struct GNUNET_MessageHeader *req;
179  size_t nlen;
180 
181  GNUNET_assert(NULL != cb);
183  el->cb = cb;
184  el->cb_cls = cb_cls;
185  {
187  { GNUNET_MQ_hd_var_size(identity_result_code,
189  struct ResultCodeMessage,
190  el),
191  GNUNET_MQ_hd_var_size(identity_update,
193  struct UpdateMessage,
194  el),
196 
197  el->mq =
198  GNUNET_CLIENT_connect(cfg, "identity", handlers, &mq_error_handler, el);
199  }
200  if (NULL == el->mq)
201  {
202  GNUNET_break(0);
203  GNUNET_free(el);
204  return NULL;
205  }
206  el->name = GNUNET_strdup(name);
207  nlen = strlen(name) + 1;
209  memcpy(&req[1], name, nlen);
210  GNUNET_MQ_send(el->mq, env);
211  return el;
212 }
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:900
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:351
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:75
#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 221 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().

222 {
223  GNUNET_MQ_destroy(el->mq);
224  GNUNET_free(el->name);
225  GNUNET_free(el);
226 }
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:821
#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 167 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().

171 {
173  struct GNUNET_MQ_Envelope *env;
174  struct GNUNET_MessageHeader *req;
175  size_t nlen;
176 
177  GNUNET_assert(NULL != cb);
179  el->cb = cb;
180  el->cb_cls = cb_cls;
181  {
183  { GNUNET_MQ_hd_var_size(identity_result_code,
185  struct ResultCodeMessage,
186  el),
187  GNUNET_MQ_hd_var_size(identity_update,
189  struct UpdateMessage,
190  el),
192 
193  el->mq =
194  GNUNET_CLIENT_connect(cfg, "identity", handlers, &mq_error_handler, el);
195  }
196  if (NULL == el->mq)
197  {
198  GNUNET_break(0);
199  GNUNET_free(el);
200  return NULL;
201  }
202  el->suffix = GNUNET_strdup(suffix);
203  nlen = strlen(suffix) + 1;
205  memcpy(&req[1], suffix, nlen);
206  GNUNET_MQ_send(el->mq, env);
207  return el;
208 }
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:900
#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:351
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:75
#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 217 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().

218 {
219  GNUNET_MQ_destroy(el->mq);
220  GNUNET_free(el->suffix);
221  GNUNET_free(el);
222 }
struct GNUNET_MQ_Handle * mq
Connection to service.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:821
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: