#include "messenger_api_contact_store.h"
#include "gnunet_common.h"
#include "messenger_api_contact.h"
#include "messenger_api_util.h"
Go to the source code of this file.
Functions | |
void | init_contact_store (struct GNUNET_MESSENGER_ContactStore *store) |
Initializes a contact store as fully empty. More... | |
static enum GNUNET_GenericReturnValue | iterate_destroy_contacts (void *cls, const struct GNUNET_HashCode *key, void *value) |
void | clear_contact_store (struct GNUNET_MESSENGER_ContactStore *store) |
Clears a contact store, wipes its content and deallocates its memory. More... | |
static struct GNUNET_CONTAINER_MultiHashMap * | select_store_contact_map (struct GNUNET_MESSENGER_ContactStore *store, const struct GNUNET_HashCode *context, struct GNUNET_HashCode *hash) |
struct GNUNET_MESSENGER_Contact * | get_store_contact_raw (struct GNUNET_MESSENGER_ContactStore *store, const struct GNUNET_HashCode *context, const struct GNUNET_HashCode *key_hash) |
Returns a contact using the hash of a specific public key. More... | |
struct GNUNET_MESSENGER_Contact * | get_store_contact (struct GNUNET_MESSENGER_ContactStore *store, const struct GNUNET_HashCode *context, const struct GNUNET_CRYPTO_PublicKey *pubkey) |
Returns a contact using a specific public key. More... | |
void | update_store_contact (struct GNUNET_MESSENGER_ContactStore *store, struct GNUNET_MESSENGER_Contact *contact, const struct GNUNET_HashCode *context, const struct GNUNET_HashCode *next_context, const struct GNUNET_CRYPTO_PublicKey *pubkey) |
Moves a contact from the store to another location matching a given public key and member context. More... | |
void | remove_store_contact (struct GNUNET_MESSENGER_ContactStore *store, struct GNUNET_MESSENGER_Contact *contact, const struct GNUNET_HashCode *context) |
Removes a contact from the store which uses a given member context. More... | |
void init_contact_store | ( | struct GNUNET_MESSENGER_ContactStore * | store | ) |
Initializes a contact store as fully empty.
[out] | store | Contact store |
Definition at line 33 of file messenger_api_contact_store.c.
References GNUNET_MESSENGER_ContactStore::anonymous, GNUNET_MESSENGER_ContactStore::contacts, GNUNET_MESSENGER_ContactStore::counter, GNUNET_assert, GNUNET_CONTAINER_multihashmap_create(), and GNUNET_NO.
Referenced by create_handle(), and create_service().
|
static |
Definition at line 45 of file messenger_api_contact_store.c.
References destroy_contact(), GNUNET_assert, GNUNET_YES, and value.
Referenced by clear_contact_store().
void clear_contact_store | ( | struct GNUNET_MESSENGER_ContactStore * | store | ) |
Clears a contact store, wipes its content and deallocates its memory.
[in,out] | store | Contact store |
Definition at line 61 of file messenger_api_contact_store.c.
References GNUNET_MESSENGER_ContactStore::anonymous, GNUNET_MESSENGER_ContactStore::contacts, GNUNET_assert, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, and iterate_destroy_contacts().
Referenced by destroy_handle(), and destroy_service().
|
static |
Definition at line 78 of file messenger_api_contact_store.c.
References GNUNET_MESSENGER_ContactStore::anonymous, GNUNET_MESSENGER_ContactStore::contacts, context, get_anonymous_public_key(), GNUNET_assert, GNUNET_CRYPTO_hash(), GNUNET_CRYPTO_hash_cmp(), and GNUNET_memcpy.
Referenced by get_store_contact(), get_store_contact_raw(), remove_store_contact(), and update_store_contact().
struct GNUNET_MESSENGER_Contact * get_store_contact_raw | ( | struct GNUNET_MESSENGER_ContactStore * | store, |
const struct GNUNET_HashCode * | context, | ||
const struct GNUNET_HashCode * | key_hash | ||
) |
Returns a contact using the hash of a specific public key.
In case the anonymous key gets used by the requested contact, it will use its provided member context to select the matching contact from the store.
In case there is no contact stored which uses the given key or context, NULL gets returned.
[in,out] | store | Contact store |
[in] | context | Member context |
[in] | key_hash | Hash of public key |
Definition at line 102 of file messenger_api_contact_store.c.
References GNUNET_MESSENGER_ContactStore::contacts, context, GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_memcpy, map, and select_store_contact_map().
Referenced by process_message_control(), and task_message_control().
struct GNUNET_MESSENGER_Contact * get_store_contact | ( | struct GNUNET_MESSENGER_ContactStore * | store, |
const struct GNUNET_HashCode * | context, | ||
const struct GNUNET_CRYPTO_PublicKey * | pubkey | ||
) |
Returns a contact using a specific public key.
In case the anonymous key gets used by the requested contact, it will use its provided member context to select the matching contact from the store.
In case there is no contact stored which uses the given key or context, a new contact will be created automatically.
The function returns NULL if an error occurs during allocation or validation of the contacts key.
[in,out] | store | Contact store |
[in] | context | Member context |
[in] | pubkey | Public key |
Definition at line 120 of file messenger_api_contact_store.c.
References GNUNET_MESSENGER_ContactStore::contacts, context, GNUNET_MESSENGER_ContactStore::counter, create_contact(), destroy_contact(), get_contact_key(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_CRYPTO_hash(), GNUNET_CRYPTO_public_key_to_string(), GNUNET_ERROR_TYPE_INVALID, GNUNET_free, GNUNET_log, GNUNET_memcmp, GNUNET_OK, map, pubkey, and select_store_contact_map().
Referenced by create_member_session(), get_handle_contact(), handle_join_message(), handle_transcript_message(), and reset_member_session().
void update_store_contact | ( | struct GNUNET_MESSENGER_ContactStore * | store, |
struct GNUNET_MESSENGER_Contact * | contact, | ||
const struct GNUNET_HashCode * | context, | ||
const struct GNUNET_HashCode * | next_context, | ||
const struct GNUNET_CRYPTO_PublicKey * | pubkey | ||
) |
Moves a contact from the store to another location matching a given public key and member context.
This function allows changes of keys or changes of member contexts!
[in,out] | store | Contact store |
[in,out] | contact | Contact |
[in] | context | Member context |
[in] | next_context | Member context |
[in] | pubkey | Public key |
Definition at line 164 of file messenger_api_contact_store.c.
References GNUNET_MESSENGER_ContactStore::contacts, context, get_contact_key(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_OK, GNUNET_YES, map, pubkey, GNUNET_MESSENGER_Contact::public_key, and select_store_contact_map().
Referenced by handle_id_message(), handle_key_message(), and switch_member_session().
void remove_store_contact | ( | struct GNUNET_MESSENGER_ContactStore * | store, |
struct GNUNET_MESSENGER_Contact * | contact, | ||
const struct GNUNET_HashCode * | context | ||
) |
Removes a contact from the store which uses a given member context.
[in,out] | store | Contact store |
[in,out] | contact | Contact |
[in] | context | Member context |
Definition at line 202 of file messenger_api_contact_store.c.
References GNUNET_MESSENGER_ContactStore::contacts, context, destroy_contact(), get_contact_key(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_YES, map, pubkey, and select_store_contact_map().
Referenced by check_member_session_completion(), and destroy_member_session().