GNUnet  0.20.0
gnunet-service-messenger_ego_store.c File Reference

GNUnet MESSENGER service. More...

Include dependency graph for gnunet-service-messenger_ego_store.c:

Go to the source code of this file.

Functions

static void callback_update_ego (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *identifier)
 
void init_ego_store (struct GNUNET_MESSENGER_EgoStore *store, const struct GNUNET_CONFIGURATION_Handle *config)
 Initializes an EGO-store as fully empty. More...
 
static int iterate_destroy_egos (void *cls, const struct GNUNET_HashCode *key, void *value)
 
void clear_ego_store (struct GNUNET_MESSENGER_EgoStore *store)
 Clears an EGO-store, wipes its content and deallocates its memory. More...
 
static int iterate_create_ego (void *cls, const struct GNUNET_HashCode *key, void *value)
 
static void callback_ego_create (void *cls, const struct GNUNET_IDENTITY_PrivateKey *key, enum GNUNET_ErrorCode ec)
 
void create_store_ego (struct GNUNET_MESSENGER_EgoStore *store, const char *identifier)
 Creates a new EGO which will be registered to a store under a specific identifier. More...
 
void bind_store_ego (struct GNUNET_MESSENGER_EgoStore *store, const char *identifier, void *handle)
 Binds an EGO which was registered to a store under a specific identifier to a given handle More...
 
void unbind_store_ego (struct GNUNET_MESSENGER_EgoStore *store, const char *identifier, void *handle)
 Binds an EGO which was registered to a store under a specific identifier to a given handle More...
 
static void callback_ego_lookup (void *cls, struct GNUNET_IDENTITY_Ego *ego)
 
void lookup_store_ego (struct GNUNET_MESSENGER_EgoStore *store, const char *identifier, GNUNET_MESSENGER_EgoLookupCallback lookup, void *cls)
 Lookups an EGO which was registered to a store under a specific identifier. More...
 
struct GNUNET_MESSENGER_Egoupdate_store_ego (struct GNUNET_MESSENGER_EgoStore *store, const char *identifier, const struct GNUNET_IDENTITY_PrivateKey *key)
 Updates the registration of an EGO to a store under a specific identifier with a new key. More...
 
void delete_store_ego (struct GNUNET_MESSENGER_EgoStore *store, const char *identifier)
 Deletes the registration of an EGO in a store under a specific identifier. More...
 
static void callback_ego_rename (void *cls, enum GNUNET_ErrorCode ec)
 
void rename_store_ego (struct GNUNET_MESSENGER_EgoStore *store, const char *old_identifier, const char *new_identifier)
 Updates the location of a registered EGO in a store to a different one under a specific new_identifier replacing its old one. More...
 
static void callback_ego_delete (void *cls, enum GNUNET_ErrorCode ec)
 
void renew_store_ego (struct GNUNET_MESSENGER_EgoStore *store, const char *identifier)
 Replaces the registered EGO in a store under a specific identifier with a newly created one. More...
 

Detailed Description

GNUnet MESSENGER service.

Author
Tobias Frisch

Definition in file gnunet-service-messenger_ego_store.c.

Function Documentation

◆ callback_update_ego()

static void callback_update_ego ( void *  cls,
struct GNUNET_IDENTITY_Ego ego,
void **  ctx,
const char *  identifier 
)
static

Definition at line 32 of file gnunet-service-messenger_ego_store.c.

36 {
37  if ((!ctx) || (!identifier))
38  return;
39 
40  struct GNUNET_MESSENGER_EgoStore *store = cls;
41 
42  if (ego)
43  {
44  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New ego in use: '%s'\n", identifier);
45  update_store_ego (store, identifier, GNUNET_IDENTITY_ego_get_private_key (ego));
46  }
47  else
48  {
49  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego got deleted: '%s'\n", identifier);
50  delete_store_ego (store, identifier);
51  }
52 }
void delete_store_ego(struct GNUNET_MESSENGER_EgoStore *store, const char *identifier)
Deletes the registration of an EGO in a store under a specific identifier.
struct GNUNET_MESSENGER_Ego * update_store_ego(struct GNUNET_MESSENGER_EgoStore *store, const char *identifier, const struct GNUNET_IDENTITY_PrivateKey *key)
Updates the registration of an EGO to a store under a specific identifier with a new key.
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
const struct GNUNET_IDENTITY_PrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:560
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_DEBUG

References ctx, delete_store_ego(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_log, and update_store_ego().

Referenced by init_ego_store().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_ego_store()

void init_ego_store ( struct GNUNET_MESSENGER_EgoStore store,
const struct GNUNET_CONFIGURATION_Handle config 
)

Initializes an EGO-store as fully empty.

Parameters
[out]storeEGO-store
[in]configConfiguration handle

Definition at line 55 of file gnunet-service-messenger_ego_store.c.

57 {
58  GNUNET_assert ((store) && (config));
59 
60  store->cfg = config;
64 
65  store->lu_start = NULL;
66  store->lu_end = NULL;
67 
68  store->op_start = NULL;
69  store->op_end = NULL;
70 }
static void callback_update_ego(void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *identifier)
static const struct GNUNET_CONFIGURATION_Handle * config
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
struct GNUNET_IDENTITY_Handle * GNUNET_IDENTITY_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_IDENTITY_Callback cb, void *cb_cls)
Connect to the identity service.
Definition: identity_api.c:531
@ GNUNET_NO
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_CONTAINER_MultiHashMap * handles
struct GNUNET_MESSENGER_EgoLookup * lu_end
const struct GNUNET_CONFIGURATION_Handle * cfg
struct GNUNET_MESSENGER_EgoLookup * lu_start
struct GNUNET_IDENTITY_Handle * identity
struct GNUNET_CONTAINER_MultiHashMap * egos
struct GNUNET_MESSENGER_EgoOperation * op_end
struct GNUNET_MESSENGER_EgoOperation * op_start

References callback_update_ego(), GNUNET_MESSENGER_EgoStore::cfg, config, GNUNET_MESSENGER_EgoStore::egos, GNUNET_assert, GNUNET_CONTAINER_multihashmap_create(), GNUNET_IDENTITY_connect(), GNUNET_NO, GNUNET_MESSENGER_EgoStore::handles, GNUNET_MESSENGER_EgoStore::identity, GNUNET_MESSENGER_EgoStore::lu_end, GNUNET_MESSENGER_EgoStore::lu_start, GNUNET_MESSENGER_EgoStore::op_end, and GNUNET_MESSENGER_EgoStore::op_start.

Referenced by create_service().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iterate_destroy_egos()

static int iterate_destroy_egos ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Definition at line 73 of file gnunet-service-messenger_ego_store.c.

76 {
77  struct GNUNET_MESSENGER_Ego *ego = value;
78  GNUNET_free(ego);
79  return GNUNET_YES;
80 }
static char * value
Value of the record to add/remove.
@ GNUNET_YES
#define GNUNET_free(ptr)
Wrapper around free.

References GNUNET_free, GNUNET_YES, and value.

Referenced by clear_ego_store().

Here is the caller graph for this function:

◆ clear_ego_store()

void clear_ego_store ( struct GNUNET_MESSENGER_EgoStore store)

Clears an EGO-store, wipes its content and deallocates its memory.

Parameters
[in,out]storeEGO-store

Definition at line 83 of file gnunet-service-messenger_ego_store.c.

84 {
85  GNUNET_assert (store);
86 
88 
89  while (store->op_start)
90  {
91  op = store->op_start;
92 
93  GNUNET_IDENTITY_cancel (op->operation);
95 
96  if (op->identifier)
97  GNUNET_free (op->identifier);
98 
99  GNUNET_free (op);
100  }
101 
102  struct GNUNET_MESSENGER_EgoLookup *lu;
103 
104  while (store->lu_start)
105  {
106  lu = store->lu_start;
107 
110 
111  if (lu->identifier)
112  GNUNET_free(lu->identifier);
113 
114  GNUNET_free (lu);
115  }
116 
119 
121 
122  if (store->identity)
123  {
125 
126  store->identity = NULL;
127  }
128 }
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
static int iterate_destroy_egos(void *cls, const struct GNUNET_HashCode *key, void *value)
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
void GNUNET_IDENTITY_cancel(struct GNUNET_IDENTITY_Operation *op)
Cancel an identity operation.
Definition: identity_api.c:740
void GNUNET_IDENTITY_ego_lookup_cancel(struct GNUNET_IDENTITY_EgoLookup *el)
Abort ego lookup attempt.
void GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h)
Disconnect from identity service.
Definition: identity_api.c:757
struct GNUNET_IDENTITY_EgoLookup * lookup
struct GNUNET_MESSENGER_EgoStore * store
struct GNUNET_MESSENGER_EgoStore * store

References GNUNET_MESSENGER_EgoStore::egos, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_free, GNUNET_IDENTITY_cancel(), GNUNET_IDENTITY_disconnect(), GNUNET_IDENTITY_ego_lookup_cancel(), GNUNET_MESSENGER_EgoStore::handles, GNUNET_MESSENGER_EgoLookup::identifier, GNUNET_MESSENGER_EgoStore::identity, iterate_destroy_egos(), GNUNET_MESSENGER_EgoLookup::lookup, GNUNET_MESSENGER_EgoStore::lu_end, GNUNET_MESSENGER_EgoStore::lu_start, op, GNUNET_MESSENGER_EgoStore::op_end, GNUNET_MESSENGER_EgoStore::op_start, GNUNET_MESSENGER_EgoLookup::store, and GNUNET_MESSENGER_EgoOperation::store.

Referenced by destroy_service().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iterate_create_ego()

static int iterate_create_ego ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Definition at line 131 of file gnunet-service-messenger_ego_store.c.

134 {
137  return GNUNET_YES;
138 }
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
void set_srv_handle_ego(struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Ego *ego)
Sets the EGO used by a given handle.

References GNUNET_YES, handle, set_srv_handle_ego(), and value.

Referenced by callback_ego_create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ callback_ego_create()

static void callback_ego_create ( void *  cls,
const struct GNUNET_IDENTITY_PrivateKey key,
enum GNUNET_ErrorCode  ec 
)
static

FIXME: This is dangerous, please handle errors

Definition at line 141 of file gnunet-service-messenger_ego_store.c.

144 {
145  struct GNUNET_MESSENGER_EgoOperation *element = cls;
146  struct GNUNET_MESSENGER_EgoStore *store = element->store;
147 
148  GNUNET_assert (element->identifier);
149 
153  if (GNUNET_EC_NONE != ec)
156 
157  if (key)
158  {
159  struct GNUNET_MESSENGER_Ego *msg_ego = update_store_ego (store, element->identifier, key);
160 
161  struct GNUNET_HashCode hash;
162  GNUNET_CRYPTO_hash (element->identifier, strlen (element->identifier), &hash);
163 
165  }
166  else
167  GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Creating ego failed!\n");
168 
169  GNUNET_CONTAINER_DLL_remove (store->op_start, store->op_end, element);
170  GNUNET_free (element->identifier);
171  GNUNET_free (element);
172 }
const char * GNUNET_ErrorCode_get_hint(enum GNUNET_ErrorCode ec)
Returns a hint for a given error code.
@ GNUNET_EC_NONE
No error (success).
struct GNUNET_HashCode key
The key used in the DHT.
static int iterate_create_ego(void *cls, const struct GNUNET_HashCode *key, void *value)
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
@ GNUNET_ERROR_TYPE_WARNING
A 512-bit hashcode.

References GNUNET_MESSENGER_EgoOperation::cls, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CRYPTO_hash(), GNUNET_EC_NONE, GNUNET_ERROR_TYPE_WARNING, GNUNET_ErrorCode_get_hint(), GNUNET_free, GNUNET_log, GNUNET_MESSENGER_EgoStore::handles, GNUNET_MESSENGER_EgoOperation::identifier, iterate_create_ego(), key, GNUNET_MESSENGER_EgoStore::op_end, GNUNET_MESSENGER_EgoStore::op_start, GNUNET_MESSENGER_EgoOperation::store, and update_store_ego().

Referenced by create_store_ego().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_store_ego()

void create_store_ego ( struct GNUNET_MESSENGER_EgoStore store,
const char *  identifier 
)

Creates a new EGO which will be registered to a store under a specific identifier.

Parameters
[in,out]storeEGO-store
[in]identifierIdentifier string

Definition at line 175 of file gnunet-service-messenger_ego_store.c.

177 {
178  GNUNET_assert ((store) && (identifier));
179 
180  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Store create ego: %s\n", identifier);
181 
183 
184  element->store = store;
185  element->cls = NULL;
186 
187  element->identifier = GNUNET_strdup (identifier);
188 
189  element->operation = GNUNET_IDENTITY_create (
190  store->identity,
191  identifier,
192  NULL,
195  element
196  );
197 
199 }
static void callback_ego_create(void *cls, const struct GNUNET_IDENTITY_PrivateKey *key, enum GNUNET_ErrorCode ec)
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_IDENTITY_Operation * GNUNET_IDENTITY_create(struct GNUNET_IDENTITY_Handle *h, const char *name, const struct GNUNET_IDENTITY_PrivateKey *privkey, enum GNUNET_IDENTITY_KeyType ktype, GNUNET_IDENTITY_CreateContinuation cont, void *cont_cls)
Create a new ego with the given name.
Definition: identity_api.c:586
@ GNUNET_IDENTITY_TYPE_ECDSA
The identity type.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_IDENTITY_Operation * operation

References callback_ego_create(), GNUNET_MESSENGER_EgoOperation::cls, GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_IDENTITY_create(), GNUNET_IDENTITY_TYPE_ECDSA, GNUNET_log, GNUNET_new, GNUNET_strdup, GNUNET_MESSENGER_EgoOperation::identifier, GNUNET_MESSENGER_EgoStore::identity, GNUNET_MESSENGER_EgoStore::op_end, GNUNET_MESSENGER_EgoStore::op_start, GNUNET_MESSENGER_EgoOperation::operation, and GNUNET_MESSENGER_EgoOperation::store.

Referenced by callback_ego_delete(), and callback_update_handle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bind_store_ego()

void bind_store_ego ( struct GNUNET_MESSENGER_EgoStore store,
const char *  identifier,
void *  handle 
)

Binds an EGO which was registered to a store under a specific identifier to a given handle

Parameters
[in,out]storeEGO-store
[in]identifierIdentifier string
[in,out]handleHandle

Definition at line 202 of file gnunet-service-messenger_ego_store.c.

205 {
206  GNUNET_assert ((store) && (identifier) && (handle));
207 
208  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Store bind ego: %s\n", identifier);
209 
210  struct GNUNET_HashCode hash;
211  GNUNET_CRYPTO_hash (identifier, strlen (identifier), &hash);
212 
214  return;
215 
218  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Putting handle binding to ego store failed!\n");
219 }
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_contains_value(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Check if the map contains the given value under the given key.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
@ GNUNET_OK
@ GNUNET_ERROR_TYPE_ERROR

References GNUNET_assert, GNUNET_CONTAINER_multihashmap_contains_value(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_OK, GNUNET_YES, handle, GNUNET_MESSENGER_EgoStore::handles, GNUNET_MESSENGER_EgoOperation::identifier, and GNUNET_MESSENGER_EgoOperation::store.

Referenced by callback_update_handle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unbind_store_ego()

void unbind_store_ego ( struct GNUNET_MESSENGER_EgoStore store,
const char *  identifier,
void *  handle 
)

Binds an EGO which was registered to a store under a specific identifier to a given handle

Parameters
[in,out]storeEGO-store
[in]identifierIdentifier string
[in,out]handleHandle

Definition at line 222 of file gnunet-service-messenger_ego_store.c.

225 {
226  GNUNET_assert ((store) && (identifier) && (handle));
227 
228  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Store unbind ego: %s\n", identifier);
229 
230  struct GNUNET_HashCode hash;
231  GNUNET_CRYPTO_hash (identifier, strlen (identifier), &hash);
232 
234  return;
235 
237  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Removing handle binding from ego store failed!\n");
238 }
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.

References GNUNET_assert, GNUNET_CONTAINER_multihashmap_contains_value(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_YES, handle, and GNUNET_MESSENGER_EgoStore::handles.

Referenced by destroy_srv_handle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ callback_ego_lookup()

static void callback_ego_lookup ( void *  cls,
struct GNUNET_IDENTITY_Ego ego 
)
static

Definition at line 241 of file gnunet-service-messenger_ego_store.c.

243 {
244  struct GNUNET_MESSENGER_EgoLookup *element = cls;
245  struct GNUNET_MESSENGER_EgoStore *store = element->store;
246 
247  GNUNET_assert (element->identifier);
248 
249  struct GNUNET_MESSENGER_Ego *msg_ego = NULL;
250 
251  if (ego)
252  {
253  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New ego looked up: '%s'\n", element->identifier);
254  msg_ego = update_store_ego (
255  store,
256  element->identifier,
258  );
259  }
260  else
261  {
262  struct GNUNET_HashCode hash;
263  GNUNET_CRYPTO_hash (element->identifier, strlen (element->identifier), &hash);
264 
265  if (GNUNET_CONTAINER_multihashmap_get (store->egos, &hash))
266  {
267  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looked up ego got deleted: '%s'\n", element->identifier);
268  delete_store_ego(store, element->identifier);
269  }
270  }
271 
272  if (element->cb)
273  element->cb(element->cls, element->identifier, msg_ego);
274 
275  GNUNET_CONTAINER_DLL_remove (store->lu_start, store->lu_end, element);
276  GNUNET_free (element->identifier);
277  GNUNET_free (element);
278 }
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
GNUNET_MESSENGER_EgoLookupCallback cb

References GNUNET_MESSENGER_EgoLookup::cb, GNUNET_MESSENGER_EgoLookup::cls, delete_store_ego(), GNUNET_MESSENGER_EgoStore::egos, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_log, GNUNET_MESSENGER_EgoLookup::identifier, GNUNET_MESSENGER_EgoStore::lu_end, GNUNET_MESSENGER_EgoStore::lu_start, GNUNET_MESSENGER_EgoLookup::store, and update_store_ego().

Referenced by lookup_store_ego().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lookup_store_ego()

void lookup_store_ego ( struct GNUNET_MESSENGER_EgoStore store,
const char *  identifier,
GNUNET_MESSENGER_EgoLookupCallback  lookup,
void *  cls 
)

Lookups an EGO which was registered to a store under a specific identifier.

Parameters
[in,out]storeEGO-store
[in]identifierIdentifier string
[in]lookupLookup callback (non-NULL)
[in]clsClosure

Definition at line 281 of file gnunet-service-messenger_ego_store.c.

285 {
286  GNUNET_assert (store);
287 
288  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Store lookup ego: %s\n", identifier);
289 
290  if (!identifier)
291  {
292  lookup(cls, identifier, NULL);
293  return;
294  }
295 
297 
298  element->store = store;
299 
300  element->cb = lookup;
301  element->cls = cls;
302 
303  element->identifier = GNUNET_strdup (identifier);
304 
306 
308 }
static void callback_ego_lookup(void *cls, struct GNUNET_IDENTITY_Ego *ego)
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.

References callback_ego_lookup(), GNUNET_MESSENGER_EgoLookup::cb, GNUNET_MESSENGER_EgoStore::cfg, GNUNET_MESSENGER_EgoLookup::cls, GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_IDENTITY_ego_lookup(), GNUNET_log, GNUNET_new, GNUNET_strdup, GNUNET_MESSENGER_EgoLookup::identifier, GNUNET_MESSENGER_EgoLookup::lookup, GNUNET_MESSENGER_EgoStore::lu_end, GNUNET_MESSENGER_EgoStore::lu_start, and GNUNET_MESSENGER_EgoLookup::store.

Referenced by set_srv_handle_name(), setup_srv_handle_name(), and update_srv_handle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_store_ego()

struct GNUNET_MESSENGER_Ego* update_store_ego ( struct GNUNET_MESSENGER_EgoStore store,
const char *  identifier,
const struct GNUNET_IDENTITY_PrivateKey key 
)

Updates the registration of an EGO to a store under a specific identifier with a new key.

Parameters
[in,out]storeEGO-store
[in]identifierIdentifier string
[in]keyPrivate EGO key
Returns
Updated EGO

Definition at line 311 of file gnunet-service-messenger_ego_store.c.

314 {
315  GNUNET_assert ((store) && (identifier) && (key));
316 
317  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Store update ego: %s\n", identifier);
318 
319  struct GNUNET_HashCode hash;
320  GNUNET_CRYPTO_hash (identifier, strlen (identifier), &hash);
321 
322  struct GNUNET_MESSENGER_Ego *ego = GNUNET_CONTAINER_multihashmap_get (store->egos, &hash);
323 
324  if (!ego)
325  {
326  ego = GNUNET_new(struct GNUNET_MESSENGER_Ego);
328  }
329 
330  GNUNET_memcpy(&(ego->priv), key, sizeof(*key));
331 
333  GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Updating invalid ego key failed!\n");
334 
335  return ego;
336 }
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE...
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_key_get_public(const struct GNUNET_IDENTITY_PrivateKey *privkey, struct GNUNET_IDENTITY_PublicKey *key)
Retrieves the public key representation of a private key.
Definition: identity_api.c:179
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct GNUNET_IDENTITY_PublicKey pub
struct GNUNET_IDENTITY_PrivateKey priv

References GNUNET_MESSENGER_EgoStore::egos, GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_IDENTITY_key_get_public(), GNUNET_log, GNUNET_memcpy, GNUNET_new, GNUNET_OK, key, GNUNET_MESSENGER_Ego::priv, and GNUNET_MESSENGER_Ego::pub.

Referenced by callback_ego_create(), callback_ego_lookup(), and callback_update_ego().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ delete_store_ego()

void delete_store_ego ( struct GNUNET_MESSENGER_EgoStore store,
const char *  identifier 
)

Deletes the registration of an EGO in a store under a specific identifier.

Parameters
[in,out]storeEGO-store
[in]identifierIdentifier string

Definition at line 339 of file gnunet-service-messenger_ego_store.c.

341 {
342  GNUNET_assert ((store) && (identifier));
343 
344  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Store delete ego: %s\n", identifier);
345 
346  struct GNUNET_HashCode hash;
347  GNUNET_CRYPTO_hash (identifier, strlen (identifier), &hash);
348 
349  struct GNUNET_MESSENGER_Ego *ego = GNUNET_CONTAINER_multihashmap_get (store->egos, &hash);
350 
351  if (ego)
352  {
353  GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Ego is not stored!\n");
354  return;
355  }
356 
357  if (GNUNET_YES != GNUNET_CONTAINER_multihashmap_remove (store->egos, &hash, ego))
358  {
359  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Removing ego from store failed!\n");
360  return;
361  }
362 
363  GNUNET_free(ego);
364 }

References GNUNET_MESSENGER_EgoStore::egos, GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, and GNUNET_YES.

Referenced by callback_ego_lookup(), and callback_update_ego().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ callback_ego_rename()

static void callback_ego_rename ( void *  cls,
enum GNUNET_ErrorCode  ec 
)
static

FIXME: Dangerous, handle error

Definition at line 367 of file gnunet-service-messenger_ego_store.c.

369 {
370  struct GNUNET_MESSENGER_EgoOperation *element = cls;
371  struct GNUNET_MESSENGER_EgoStore *store = element->store;
372 
373  GNUNET_assert (element->identifier);
374 
378  if (GNUNET_EC_NONE != ec)
381 
382  struct GNUNET_HashCode hash;
383  GNUNET_CRYPTO_hash (element->identifier, strlen (element->identifier), &hash);
384 
385  struct GNUNET_MESSENGER_Ego *ego = GNUNET_CONTAINER_multihashmap_get (store->egos, &hash);
386 
387  if (!ego)
388  GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Ego is not stored!\n");
389 
390  char *identifier = (char*) element->cls;
391 
392  if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (store->egos, &hash, ego))
393  {
394  GNUNET_CRYPTO_hash (identifier, strlen (identifier), &hash);
395 
396  GNUNET_CONTAINER_multihashmap_put (store->egos, &hash, ego,
398  }
399  else
400  GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Renaming ego failed!\n");
401 
402  GNUNET_free (identifier);
403 
404  GNUNET_CONTAINER_DLL_remove (store->op_start, store->op_end, element);
405  GNUNET_free (element->identifier);
406  GNUNET_free (element);
407 }

References GNUNET_MESSENGER_EgoOperation::cls, GNUNET_MESSENGER_EgoStore::egos, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_CRYPTO_hash(), GNUNET_EC_NONE, GNUNET_ERROR_TYPE_WARNING, GNUNET_ErrorCode_get_hint(), GNUNET_free, GNUNET_log, GNUNET_YES, GNUNET_MESSENGER_EgoOperation::identifier, GNUNET_MESSENGER_EgoStore::op_end, GNUNET_MESSENGER_EgoStore::op_start, and GNUNET_MESSENGER_EgoOperation::store.

Referenced by rename_store_ego().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rename_store_ego()

void rename_store_ego ( struct GNUNET_MESSENGER_EgoStore store,
const char *  old_identifier,
const char *  new_identifier 
)

Updates the location of a registered EGO in a store to a different one under a specific new_identifier replacing its old one.

Parameters
[in,out]storeEGO-store
[in]old_identifierOld identifier string
[in]new_identifierNew identifier string

Definition at line 410 of file gnunet-service-messenger_ego_store.c.

413 {
414  GNUNET_assert ((store) && (old_identifier) && (new_identifier));
415 
416  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Store rename ego: %s -> %s\n", old_identifier, new_identifier);
417 
419 
420  element->store = store;
421  element->cls = GNUNET_strdup (new_identifier);
422 
423  element->identifier = GNUNET_strdup (old_identifier);
424 
425  element->operation = GNUNET_IDENTITY_rename (
426  store->identity,
427  old_identifier,
428  new_identifier,
430  element
431  );
432 
434 }
static void callback_ego_rename(void *cls, enum GNUNET_ErrorCode ec)
struct GNUNET_IDENTITY_Operation * GNUNET_IDENTITY_rename(struct GNUNET_IDENTITY_Handle *h, const char *old_name, const char *new_name, GNUNET_IDENTITY_Continuation cb, void *cb_cls)
Renames an existing identity.
Definition: identity_api.c:646

References callback_ego_rename(), GNUNET_MESSENGER_EgoOperation::cls, GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_IDENTITY_rename(), GNUNET_log, GNUNET_new, GNUNET_strdup, GNUNET_MESSENGER_EgoOperation::identifier, GNUNET_MESSENGER_EgoStore::identity, GNUNET_MESSENGER_EgoStore::op_end, GNUNET_MESSENGER_EgoStore::op_start, GNUNET_MESSENGER_EgoOperation::operation, and GNUNET_MESSENGER_EgoOperation::store.

Referenced by callback_set_handle_name().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ callback_ego_delete()

static void callback_ego_delete ( void *  cls,
enum GNUNET_ErrorCode  ec 
)
static

FIXME: Dangerous, handle error

Definition at line 437 of file gnunet-service-messenger_ego_store.c.

439 {
440  struct GNUNET_MESSENGER_EgoOperation *element = cls;
441  struct GNUNET_MESSENGER_EgoStore *store = element->store;
442 
443  GNUNET_assert (element->identifier);
444 
448  if (GNUNET_EC_NONE != ec)
451 
452  create_store_ego (store, element->identifier);
453 
454  GNUNET_CONTAINER_DLL_remove (store->op_start, store->op_end, element);
455  GNUNET_free (element->identifier);
456  GNUNET_free (element);
457 }
void create_store_ego(struct GNUNET_MESSENGER_EgoStore *store, const char *identifier)
Creates a new EGO which will be registered to a store under a specific identifier.

References GNUNET_MESSENGER_EgoOperation::cls, create_store_ego(), GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_EC_NONE, GNUNET_ERROR_TYPE_WARNING, GNUNET_ErrorCode_get_hint(), GNUNET_free, GNUNET_log, GNUNET_MESSENGER_EgoOperation::identifier, GNUNET_MESSENGER_EgoStore::op_end, GNUNET_MESSENGER_EgoStore::op_start, and GNUNET_MESSENGER_EgoOperation::store.

Referenced by renew_store_ego().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ renew_store_ego()

void renew_store_ego ( struct GNUNET_MESSENGER_EgoStore store,
const char *  identifier 
)

Replaces the registered EGO in a store under a specific identifier with a newly created one.

Parameters
[in,out]storeEGO-store
[in]identifierIdentifier string

Definition at line 460 of file gnunet-service-messenger_ego_store.c.

462 {
463  GNUNET_assert ((store) && (identifier));
464 
465  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Store renew ego: %s\n", identifier);
466 
468 
469  element->store = store;
470  element->cls = NULL;
471 
472  element->identifier = GNUNET_strdup (identifier);
473 
475  store->identity,
476  identifier,
478  element
479  );
480 
482 }
static void callback_ego_delete(void *cls, enum GNUNET_ErrorCode ec)
struct GNUNET_IDENTITY_Operation * GNUNET_IDENTITY_delete(struct GNUNET_IDENTITY_Handle *h, const char *name, GNUNET_IDENTITY_Continuation cb, void *cb_cls)
Delete an existing identity.
Definition: identity_api.c:699

References callback_ego_delete(), GNUNET_MESSENGER_EgoOperation::cls, GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_IDENTITY_delete(), GNUNET_log, GNUNET_new, GNUNET_strdup, GNUNET_MESSENGER_EgoOperation::identifier, GNUNET_MESSENGER_EgoStore::identity, GNUNET_MESSENGER_EgoStore::op_end, GNUNET_MESSENGER_EgoStore::op_start, GNUNET_MESSENGER_EgoOperation::operation, and GNUNET_MESSENGER_EgoOperation::store.

Referenced by callback_update_handle().

Here is the call graph for this function:
Here is the caller graph for this function: