GNUnet  0.11.x
Macros | Typedefs | Functions
Identity service

Identity management. More...

Macros

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

Typedefs

typedef void(* GNUNET_IDENTITY_Callback) (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *name)
 Method called to inform about the egos of this peer. More...
 
typedef void(* GNUNET_IDENTITY_Continuation) (void *cls, const char *emsg)
 Function called once the requested operation has been completed. More...
 
typedef void(* GNUNET_IDENTITY_CreateContinuation) (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk, const char *emsg)
 Function called once the requested operation has been completed. More...
 
typedef void(* GNUNET_IDENTITY_EgoCallback) (void *cls, 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 (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, const struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey, 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 141 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 185 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 225 of file gnunet_identity_service.h.

◆ GNUNET_IDENTITY_EgoCallback

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

Function called with the result.

Parameters
clsclosure
egoNULL on error / ego not found

Definition at line 304 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 345 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 595 of file identity_api.c.

References GNUNET_IDENTITY_Ego::pk.

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

596 {
597  return &ego->pk;
598 }
struct GNUNET_CRYPTO_EcdsaPrivateKey pk
Private key associated with this ego.
Definition: identity.h:255
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_ego_get_anonymous()

const struct GNUNET_IDENTITY_Ego* GNUNET_IDENTITY_ego_get_anonymous ( void  )

Obtain the ego representing 'anonymous' users.

Returns
handle for the anonymous user, must not be freed

Definition at line 156 of file identity_api.c.

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

157 {
158  static struct GNUNET_IDENTITY_Ego anon;
159  static int setup;
161 
162  if (setup)
163  return &anon;
166  &pub);
167  GNUNET_CRYPTO_hash (&anon.pk,
168  sizeof(anon.pk),
169  &anon.id);
170  setup = 1;
171  return &anon;
172 }
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:569
Handle for an ego.
Definition: identity.h:245
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:48
void GNUNET_CRYPTO_ecdsa_key_get_public(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:176
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 ( 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 608 of file identity_api.c.

References GNUNET_CRYPTO_ecdsa_key_get_public(), GNUNET_NO, GNUNET_YES, GNUNET_IDENTITY_Ego::pk, GNUNET_IDENTITY_Ego::pub, and GNUNET_IDENTITY_Ego::pub_initialized.

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

610 {
611  if (GNUNET_NO == ego->pub_initialized)
612  {
614  &ego->pub);
616  }
617  *pk = ego->pub;
618 }
struct GNUNET_CRYPTO_EcdsaPrivateKey pk
Private key associated with this ego.
Definition: identity.h:255
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:176
bool pub_initialized
Set to true once pub was initialized.
Definition: identity.h:276
struct GNUNET_CRYPTO_EcdsaPublicKey pub
Public key associated with this ego.
Definition: identity.h:261
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 566 of file identity_api.c.

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

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

569 {
570  struct GNUNET_IDENTITY_Handle *h;
571 
572  h = GNUNET_new (struct GNUNET_IDENTITY_Handle);
573  h->cfg = cfg;
574  h->cb = cb;
575  h->cb_cls = cb_cls;
577  GNUNET_YES);
578  reconnect (h);
579  if (NULL == h->mq)
580  {
581  GNUNET_free (h);
582  return NULL;
583  }
584  return h;
585 }
struct GNUNET_CONTAINER_MultiHashMap * egos
Hash map from the hash of the private key to the respective GNUNET_IDENTITY_Ego handle.
Definition: identity_api.c:111
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static void reconnect(void *cls)
Try again to connect to the identity service.
Definition: identity_api.c:515
Handle for the service.
Definition: identity_api.c:95
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: identity_api.c:100
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
void * cb_cls
Closure for cb.
Definition: identity_api.c:121
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:105
GNUNET_IDENTITY_Callback cb
Function to call when we receive updates.
Definition: identity_api.c:116
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_get()

struct GNUNET_IDENTITY_Operation* GNUNET_IDENTITY_get ( struct GNUNET_IDENTITY_Handle h,
const char *  service_name,
GNUNET_IDENTITY_Callback  cb,
void *  cb_cls 
)

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

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

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

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

Definition at line 632 of file identity_api.c.

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

Referenced by ego_get_subsystem(), and id_connect_cb().

636 {
638  struct GNUNET_MQ_Envelope *env;
639  struct GetDefaultMessage *gdm;
640  size_t slen;
641 
642  if (NULL == h->mq)
643  return NULL;
644  GNUNET_assert (NULL != h->cb);
645  slen = strlen (service_name) + 1;
646  if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct GetDefaultMessage))
647  {
648  GNUNET_break (0);
649  return NULL;
650  }
652  op->h = h;
653  op->cb = cb;
654  op->cls = cb_cls;
656  env =
658  gdm->name_len = htons (slen);
659  gdm->reserved = htons (0);
660  GNUNET_memcpy (&gdm[1], service_name, slen);
661  GNUNET_MQ_send (h->mq, env);
662  return op;
663 }
uint16_t reserved
Always zero.
Definition: identity.h:123
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
uint16_t name_len
Number of bytes in service name string including 0-termination, in NBO.
Definition: identity.h:118
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct GNUNET_IDENTITY_Operation * op_tail
Tail of active operations.
Definition: identity_api.c:131
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Handle for an operation with the identity service.
Definition: identity_api.c:39
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
static char * service_name
Option -s: service name (hash to get service descriptor)
Definition: gnunet-vpn.c:51
struct GNUNET_IDENTITY_Operation * op_head
Head of active operations.
Definition: identity_api.c:126
struct GNUNET_IDENTITY_Handle * h
Main identity handle.
Definition: identity_api.c:44
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
void * cls
Closure for cont or cb.
Definition: identity_api.c:88
#define GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT
Client requests to know default identity for a subsystem.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:355
Client requests knowledge about default identity for a subsystem from identity service.
Definition: identity.h:108
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:105
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
GNUNET_IDENTITY_Callback cb
Function to call when we receive updates.
Definition: identity_api.c:116
GNUNET_IDENTITY_Callback cb
Continuation to invoke with the result of the transmission for 'get' operations (cont and create_cont...
Definition: identity_api.c:83
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_set()

struct GNUNET_IDENTITY_Operation* GNUNET_IDENTITY_set ( struct GNUNET_IDENTITY_Handle h,
const char *  service_name,
struct GNUNET_IDENTITY_Ego ego,
GNUNET_IDENTITY_Continuation  cont,
void *  cont_cls 
)

Set the preferred/default ego for a service.

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

Set the preferred/default ego for a service.

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

Definition at line 677 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().

682 {
684  struct GNUNET_MQ_Envelope *env;
685  struct SetDefaultMessage *sdm;
686  size_t slen;
687 
688  if (NULL == h->mq)
689  return NULL;
690  GNUNET_assert (NULL != h->cb);
691  slen = strlen (service_name) + 1;
692  if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct SetDefaultMessage))
693  {
694  GNUNET_break (0);
695  return NULL;
696  }
698  op->h = h;
699  op->cont = cont;
700  op->cls = cont_cls;
702  env =
704  sdm->name_len = htons (slen);
705  sdm->reserved = htons (0);
706  sdm->private_key = ego->pk;
707  GNUNET_memcpy (&sdm[1], service_name, slen);
708  GNUNET_MQ_send (h->mq, env);
709  return op;
710 }
struct GNUNET_CRYPTO_EcdsaPrivateKey private_key
The private key.
Definition: identity.h:154
struct GNUNET_CRYPTO_EcdsaPrivateKey pk
Private key associated with this ego.
Definition: identity.h:255
#define GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT
Client sets default identity; or service informs about default identity.
Used from service to client as a result to the GET_DEFAULT message, used from client to service to SE...
Definition: identity.h:134
uint16_t name_len
Number of bytes in service name string including 0-termination, in NBO.
Definition: identity.h:144
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct GNUNET_IDENTITY_Operation * op_tail
Tail of active operations.
Definition: identity_api.c:131
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Handle for an operation with the identity service.
Definition: identity_api.c:39
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
uint16_t reserved
Always zero.
Definition: identity.h:149
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
static char * service_name
Option -s: service name (hash to get service descriptor)
Definition: gnunet-vpn.c:51
GNUNET_IDENTITY_Continuation cont
Continuation to invoke with the result of the transmission; cb and create_cont will be NULL in this c...
Definition: identity_api.c:66
struct GNUNET_IDENTITY_Operation * op_head
Head of active operations.
Definition: identity_api.c:126
struct GNUNET_IDENTITY_Handle * h
Main identity handle.
Definition: identity_api.c:44
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
void * cls
Closure for cont or cb.
Definition: identity_api.c:88
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:355
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:105
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
GNUNET_IDENTITY_Callback cb
Function to call when we receive updates.
Definition: identity_api.c:116
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 884 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_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().

885 {
887 
888  GNUNET_assert (NULL != h);
889  if (h->reconnect_task != NULL)
890  {
892  h->reconnect_task = NULL;
893  }
894  if (NULL != h->egos)
895  {
897  &free_ego,
898  h);
900  h->egos = NULL;
901  }
902  while (NULL != (op = h->op_head))
903  {
904  GNUNET_break (NULL == op->cont);
906  memset (&op->pk,
907  0,
908  sizeof (op->pk));
909  GNUNET_free (op);
910  }
911  if (NULL != h->mq)
912  {
913  GNUNET_MQ_destroy (h->mq);
914  h->mq = NULL;
915  }
916  GNUNET_free (h);
917 }
#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 private key to the respective GNUNET_IDENTITY_Ego handle.
Definition: identity_api.c:111
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_IDENTITY_Operation * op_tail
Tail of active operations.
Definition: identity_api.c:131
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Handle for an operation with the identity service.
Definition: identity_api.c:39
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
struct GNUNET_SCHEDULER_Task * reconnect_task
Task doing exponential back-off trying to reconnect.
Definition: identity_api.c:136
GNUNET_IDENTITY_Continuation cont
Continuation to invoke with the result of the transmission; cb and create_cont will be NULL in this c...
Definition: identity_api.c:66
struct GNUNET_IDENTITY_Operation * op_head
Head of active operations.
Definition: identity_api.c:126
struct GNUNET_CRYPTO_EcdsaPrivateKey pk
Private key to return to create_cont, or NULL.
Definition: identity_api.c:77
static int free_ego(void *cls, const struct GNUNET_HashCode *key, void *value)
Free ego from hash map.
Definition: identity_api.c:193
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:833
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:105
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972
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,
const struct GNUNET_CRYPTO_EcdsaPrivateKey privkey,
GNUNET_IDENTITY_CreateContinuation  cont,
void *  cont_cls 
)

Create a new ego with the given name.

Parameters
ididentity service to use
namedesired name
privkeydesired private key or NULL to create one
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
privkeydesired private key or NULL to create one
contfunction to call with the result (will only be called once)
cont_clsclosure for cont
Returns
handle to abort the operation

Definition at line 724 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().

729 {
731  struct GNUNET_MQ_Envelope *env;
732  struct CreateRequestMessage *crm;
733  size_t slen;
734 
735  if (NULL == h->mq)
736  return NULL;
737  slen = strlen (name) + 1;
738  if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct CreateRequestMessage))
739  {
740  GNUNET_break (0);
741  return NULL;
742  }
744  op->h = h;
745  op->create_cont = cont;
746  op->cls = cont_cls;
749  crm->name_len = htons (slen);
750  crm->reserved = htons (0);
751  if (NULL == privkey)
753  else
754  crm->private_key = *privkey;
755  op->pk = crm->private_key;
756  GNUNET_memcpy (&crm[1], name, slen);
757  GNUNET_MQ_send (h->mq, env);
758  return op;
759 }
uint16_t reserved
Always zero.
Definition: identity.h:179
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct GNUNET_IDENTITY_Operation * op_tail
Tail of active operations.
Definition: identity_api.c:131
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint16_t name_len
Number of bytes in identity name string including 0-termination, in NBO.
Definition: identity.h:174
struct GNUNET_CRYPTO_EcdsaPrivateKey private_key
The private key.
Definition: identity.h:184
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Handle for an operation with the identity service.
Definition: identity_api.c:39
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
GNUNET_IDENTITY_CreateContinuation create_cont
Continuation to invoke with the result of the transmission; cb and cb will be NULL in this case...
Definition: identity_api.c:72
Client requests creation of an identity.
Definition: identity.h:164
struct GNUNET_IDENTITY_Operation * op_head
Head of active operations.
Definition: identity_api.c:126
#define GNUNET_MESSAGE_TYPE_IDENTITY_CREATE
Create new identity (client->service).
struct GNUNET_CRYPTO_EcdsaPrivateKey pk
Private key to return to create_cont, or NULL.
Definition: identity_api.c:77
struct GNUNET_IDENTITY_Handle * h
Main identity handle.
Definition: identity_api.c:44
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
const char * name
void GNUNET_CRYPTO_ecdsa_key_create(struct GNUNET_CRYPTO_EcdsaPrivateKey *pk)
Create a new private key.
Definition: crypto_ecc.c:524
void * cls
Closure for cont or cb.
Definition: identity_api.c:88
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:355
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:105
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_rename()

struct GNUNET_IDENTITY_Operation* GNUNET_IDENTITY_rename ( struct GNUNET_IDENTITY_Handle h,
const char *  old_name,
const char *  new_name,
GNUNET_IDENTITY_Continuation  cb,
void *  cb_cls 
)

Renames an existing ego.

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

Renames an existing ego.

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

Definition at line 773 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().

778 {
780  struct GNUNET_MQ_Envelope *env;
781  struct RenameMessage *grm;
782  size_t slen_old;
783  size_t slen_new;
784  char *dst;
785 
786  if (NULL == h->mq)
787  return NULL;
788  slen_old = strlen (old_name) + 1;
789  slen_new = strlen (new_name) + 1;
790  if ((slen_old >= GNUNET_MAX_MESSAGE_SIZE) ||
791  (slen_new >= GNUNET_MAX_MESSAGE_SIZE) ||
792  (slen_old + slen_new >=
793  GNUNET_MAX_MESSAGE_SIZE - sizeof(struct RenameMessage)))
794  {
795  GNUNET_break (0);
796  return NULL;
797  }
799  op->h = h;
800  op->cont = cb;
801  op->cls = cb_cls;
803  env = GNUNET_MQ_msg_extra (grm,
804  slen_old + slen_new,
806  grm->old_name_len = htons (slen_old);
807  grm->new_name_len = htons (slen_new);
808  dst = (char *) &grm[1];
809  GNUNET_memcpy (dst, old_name, slen_old);
810  GNUNET_memcpy (&dst[slen_old], new_name, slen_new);
811  GNUNET_MQ_send (h->mq, env);
812  return op;
813 }
uint16_t old_name_len
Number of characters in the old name including 0-termination, in NBO.
Definition: identity.h:204
Client requests renaming of an identity.
Definition: identity.h:194
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct GNUNET_IDENTITY_Operation * op_tail
Tail of active operations.
Definition: identity_api.c:131
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Handle for an operation with the identity service.
Definition: identity_api.c:39
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
GNUNET_IDENTITY_Continuation cont
Continuation to invoke with the result of the transmission; cb and create_cont will be NULL in this c...
Definition: identity_api.c:66
struct GNUNET_IDENTITY_Operation * op_head
Head of active operations.
Definition: identity_api.c:126
struct GNUNET_IDENTITY_Handle * h
Main identity handle.
Definition: identity_api.c:44
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
uint16_t new_name_len
Number of characters in the new name including 0-termination, in NBO.
Definition: identity.h:209
void * cls
Closure for cont or cb.
Definition: identity_api.c:88
#define GNUNET_MESSAGE_TYPE_IDENTITY_RENAME
Rename existing identity (client->service).
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:355
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:105
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_delete()

struct GNUNET_IDENTITY_Operation* GNUNET_IDENTITY_delete ( struct GNUNET_IDENTITY_Handle h,
const char *  name,
GNUNET_IDENTITY_Continuation  cb,
void *  cb_cls 
)

Delete an existing ego.

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

Delete an existing ego.

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

Definition at line 826 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().

830 {
832  struct GNUNET_MQ_Envelope *env;
833  struct DeleteMessage *gdm;
834  size_t slen;
835 
836  if (NULL == h->mq)
837  return NULL;
838  slen = strlen (name) + 1;
839  if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct DeleteMessage))
840  {
841  GNUNET_break (0);
842  return NULL;
843  }
845  op->h = h;
846  op->cont = cb;
847  op->cls = cb_cls;
850  gdm->name_len = htons (slen);
851  gdm->reserved = htons (0);
852  GNUNET_memcpy (&gdm[1], name, slen);
853  GNUNET_MQ_send (h->mq, env);
854  return op;
855 }
#define GNUNET_MESSAGE_TYPE_IDENTITY_DELETE
Delete identity (client->service).
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t reserved
Always zero.
Definition: identity.h:235
struct GNUNET_IDENTITY_Operation * op_tail
Tail of active operations.
Definition: identity_api.c:131
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Handle for an operation with the identity service.
Definition: identity_api.c:39
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
GNUNET_IDENTITY_Continuation cont
Continuation to invoke with the result of the transmission; cb and create_cont will be NULL in this c...
Definition: identity_api.c:66
struct GNUNET_IDENTITY_Operation * op_head
Head of active operations.
Definition: identity_api.c:126
Client requests deletion of an identity.
Definition: identity.h:220
struct GNUNET_IDENTITY_Handle * h
Main identity handle.
Definition: identity_api.c:44
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
const char * name
void * cls
Closure for cont or cb.
Definition: identity_api.c:88
uint16_t name_len
Number of characters in the name including 0-termination, in NBO.
Definition: identity.h:230
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:355
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:105
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_cancel()

void GNUNET_IDENTITY_cancel ( struct GNUNET_IDENTITY_Operation op)

Cancel an identity operation.

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

Parameters
opoperation to cancel

Definition at line 867 of file identity_api.c.

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

Referenced by do_shutdown(), and shutdown_task().

868 {
869  op->cont = NULL;
870  op->cb = NULL;
871  op->create_cont = NULL;
872  memset (&op->pk,
873  0,
874  sizeof (op->pk));
875 }
GNUNET_IDENTITY_CreateContinuation create_cont
Continuation to invoke with the result of the transmission; cb and cb will be NULL in this case...
Definition: identity_api.c:72
GNUNET_IDENTITY_Continuation cont
Continuation to invoke with the result of the transmission; cb and create_cont will be NULL in this c...
Definition: identity_api.c:66
struct GNUNET_CRYPTO_EcdsaPrivateKey pk
Private key to return to create_cont, or NULL.
Definition: identity_api.c:77
GNUNET_IDENTITY_Callback cb
Continuation to invoke with the result of the transmission for 'get' operations (cont and create_cont...
Definition: identity_api.c:83
Here is the 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 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.
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:1063
struct GNUNET_MQ_Handle * mq
Connection to service.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE
Update about identity status from service to clients.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP
First message send from identity client to service to lookup a single ego.
static void mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...
Message handler for a specific message type.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
char * name
Name of the ego we are looking up.
const char * name
GNUNET_IDENTITY_EgoCallback cb
Function to call with the result.
Header for all communications.
#define GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE
Generic response from identity service with success and/or error message.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:355
static struct GNUNET_IDENTITY_EgoLookup * el
EgoLookup.
Definition: gnunet-abd.c:51
void * cb_cls
Closure for cb.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
Answer from service to client about last operation; GET_DEFAULT maybe answered with this message on f...
Definition: identity.h:42
Service informs client about status of a pseudonym.
Definition: identity.h:77
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_ego_lookup_cancel()

void GNUNET_IDENTITY_ego_lookup_cancel ( struct GNUNET_IDENTITY_EgoLookup el)

Abort ego lookup attempt.

Parameters
elhandle for lookup to abort

Definition at line 223 of file identity_api_lookup.c.

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

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

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:833
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_ego_lookup_by_suffix()

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

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

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

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

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

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

Definition at line 168 of file identity_api_suffix_lookup.c.

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

Referenced by GNUNET_GNS_lookup_with_tld().

173 {
175  struct GNUNET_MQ_Envelope *env;
176  struct GNUNET_MessageHeader *req;
177  size_t nlen;
178 
179  GNUNET_assert (NULL != cb);
181  el->cb = cb;
182  el->cb_cls = cb_cls;
183  {
185  { GNUNET_MQ_hd_var_size (identity_result_code,
187  struct ResultCodeMessage,
188  el),
189  GNUNET_MQ_hd_var_size (identity_update,
191  struct UpdateMessage,
192  el),
194 
195  el->mq =
196  GNUNET_CLIENT_connect (cfg, "identity", handlers, &mq_error_handler, el);
197  }
198  if (NULL == el->mq)
199  {
200  GNUNET_break (0);
201  GNUNET_free (el);
202  return NULL;
203  }
204  el->suffix = GNUNET_strdup (suffix);
205  nlen = strlen (suffix) + 1;
206  env = GNUNET_MQ_msg_extra (req, nlen,
208  memcpy (&req[1], suffix, nlen);
209  GNUNET_MQ_send (el->mq, env);
210  return el;
211 }
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1063
#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:355
char * suffix
Suffix we are looking up.
static struct GNUNET_IDENTITY_EgoLookup * el
EgoLookup.
Definition: gnunet-abd.c:51
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
Answer from service to client about last operation; GET_DEFAULT maybe answered with this message on f...
Definition: identity.h:42
Service informs client about status of a pseudonym.
Definition: identity.h:77
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_ego_lookup_by_suffix_cancel()

void GNUNET_IDENTITY_ego_lookup_by_suffix_cancel ( struct GNUNET_IDENTITY_EgoSuffixLookup el)

Abort ego suffix lookup attempt.

Parameters
elhandle for lookup to abort

Abort ego suffix lookup attempt.

Parameters
elhandle for lookup to abort

Definition at line 220 of file identity_api_suffix_lookup.c.

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

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

222 {
223  GNUNET_MQ_destroy (el->mq);
224  GNUNET_free (el->suffix);
225  GNUNET_free (el);
226 }
struct GNUNET_MQ_Handle * mq
Connection to service.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:833
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: