#include "gnunet-service-messenger_member_store.h"
#include "gnunet-service-messenger_subscription.h"
Go to the source code of this file.
Data Structures | |
struct | GNUNET_MESSENGER_Member |
Typedefs | |
typedef enum GNUNET_GenericReturnValue(* | GNUNET_MESSENGER_SubscriptionIteratorCallback) (void *cls, const struct GNUNET_ShortHashCode *discourse, struct GNUNET_MESSENGER_Subscription *subscribtion) |
Functions | |
struct GNUNET_MESSENGER_Member * | create_member (struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_ShortHashCode *id) |
Creates and allocates a new member of a room with an optionally defined or random id. More... | |
void | destroy_member (struct GNUNET_MESSENGER_Member *member) |
Destroys a member and frees its memory fully. More... | |
const struct GNUNET_ShortHashCode * | get_member_id (const struct GNUNET_MESSENGER_Member *member) |
Returns the current id of a given member. More... | |
void | load_member (struct GNUNET_MESSENGER_MemberStore *store, const char *directory) |
Loads data from a directory into a new allocated and created member of a store if the required information can be read from the content of the given directory. More... | |
void | load_member_next_sessions (const struct GNUNET_MESSENGER_Member *member, const char *directory) |
Loads data about next sessions from a directory into an empty loaded member which does not contain a fully built session graph yet. More... | |
void | save_member (struct GNUNET_MESSENGER_Member *member, const char *directory) |
Saves data from a member into a directory which can be load to restore the member completely. More... | |
void | sync_member_contacts (struct GNUNET_MESSENGER_Member *member) |
Synchronizes contacts between all sessions from a given member and other sessions which are linked to them. More... | |
struct GNUNET_MESSENGER_MemberSession * | get_member_session (const struct GNUNET_MESSENGER_Member *member, const struct GNUNET_CRYPTO_PublicKey *public_key) |
Returns the member session of a member identified by a given public key. More... | |
struct GNUNET_MESSENGER_MemberSession * | get_member_session_of (struct GNUNET_MESSENGER_Member *member, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) |
Returns the member session of a member using a public key which can verify the signature of a given message and its hash. More... | |
void | add_member_session (struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSENGER_MemberSession *session) |
Adds a given member session to its member. More... | |
void | remove_member_session (struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSENGER_MemberSession *session) |
Removes a given member session from its member. More... | |
int | iterate_member_sessions (struct GNUNET_MESSENGER_Member *member, GNUNET_MESSENGER_MemberIteratorCallback it, void *cls) |
Iterate through all member sessions currently connected to a given member and call the provided iterator callback with a selected closure. More... | |
void | add_member_subscription (struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSENGER_Subscription *subscription) |
Adds a given subscription to a member. More... | |
void | remove_member_subscription (struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSENGER_Subscription *subscription) |
Removes a given subscription from a member. More... | |
struct GNUNET_MESSENGER_Subscription * | get_member_subscription (struct GNUNET_MESSENGER_Member *member, const struct GNUNET_ShortHashCode *discourse) |
Returns the active subscription of a given member to a selected discourse. More... | |
int | iterate_member_subscriptions (struct GNUNET_MESSENGER_Member *member, GNUNET_MESSENGER_SubscriptionIteratorCallback it, void *cls) |
Iterate through all subscriptions of a given member and call the provided iterator callback with a selected closure. More... | |
typedef enum GNUNET_GenericReturnValue(* GNUNET_MESSENGER_SubscriptionIteratorCallback) (void *cls, const struct GNUNET_ShortHashCode *discourse, struct GNUNET_MESSENGER_Subscription *subscribtion) |
Definition at line 1 of file gnunet-service-messenger_member.h.
struct GNUNET_MESSENGER_Member * create_member | ( | struct GNUNET_MESSENGER_MemberStore * | store, |
const struct GNUNET_ShortHashCode * | id | ||
) |
Creates and allocates a new member of a room with an optionally defined or random id.
If the creation fails, NULL gets returned.
[in,out] | store | Member store |
[in] | id | Member id or NULL |
Definition at line 34 of file gnunet-service-messenger_member.c.
References generate_free_member_id(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multishortmap_create(), GNUNET_free, GNUNET_memcpy, GNUNET_new, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_Member::id, GNUNET_MESSENGER_MemberStore::members, GNUNET_MESSENGER_Member::sessions, GNUNET_MESSENGER_Member::store, and GNUNET_MESSENGER_Member::subscriptions.
Referenced by add_store_member().
void destroy_member | ( | struct GNUNET_MESSENGER_Member * | member | ) |
Destroys a member and frees its memory fully.
[in,out] | member | Member |
Definition at line 93 of file gnunet-service-messenger_member.c.
References GNUNET_assert, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multishortmap_destroy(), GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_free, iterate_destroy_session(), iterate_destroy_subscription(), GNUNET_MESSENGER_Subscription::member, GNUNET_MESSENGER_Member::sessions, and GNUNET_MESSENGER_Member::subscriptions.
Referenced by add_store_member(), and iterate_destroy_members().
const struct GNUNET_ShortHashCode * get_member_id | ( | const struct GNUNET_MESSENGER_Member * | member | ) |
Returns the current id of a given member.
[in] | member | Member |
Definition at line 110 of file gnunet-service-messenger_member.c.
References GNUNET_assert, and GNUNET_MESSENGER_Member::id.
Referenced by add_store_member(), get_member_session_id(), and join_room().
void load_member | ( | struct GNUNET_MESSENGER_MemberStore * | store, |
const char * | directory | ||
) |
Loads data from a directory into a new allocated and created member of a store if the required information can be read from the content of the given directory.
[out] | store | Member store |
[in] | directory | Path to a directory |
Definition at line 143 of file gnunet-service-messenger_member.c.
References add_store_member(), callback_scan_for_sessions(), cfg, config_file, DIR_SEPARATOR, GNUNET_asprintf(), GNUNET_assert, GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_get_data(), GNUNET_CONFIGURATION_parse(), GNUNET_DISK_directory_scan(), GNUNET_DISK_directory_test(), GNUNET_DISK_file_test(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_OK, GNUNET_OS_project_data_gnunet(), GNUNET_YES, id, find_typedefs::scan_dir(), and GNUNET_MESSENGER_Member::store.
Referenced by callback_scan_for_members().
void load_member_next_sessions | ( | const struct GNUNET_MESSENGER_Member * | member, |
const char * | directory | ||
) |
Loads data about next sessions from a directory into an empty loaded member which does not contain a fully built session graph yet.
[in,out] | member | Member |
[in] | directory | Path to a directory |
Definition at line 231 of file gnunet-service-messenger_member.c.
References DIR_SEPARATOR, GNUNET_asprintf(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_free, iterate_load_next_session(), GNUNET_MESSENGER_MemberSession::member, and GNUNET_MESSENGER_Member::sessions.
Referenced by iterate_load_next_member_sessions().
void save_member | ( | struct GNUNET_MESSENGER_Member * | member, |
const char * | directory | ||
) |
Saves data from a member into a directory which can be load to restore the member completely.
[in] | member | Member |
[in] | directory | Path to a directory |
Definition at line 280 of file gnunet-service-messenger_member.c.
References cfg, config_file, DIR_SEPARATOR, GNUNET_asprintf(), GNUNET_assert, GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_set_value_string(), GNUNET_CONFIGURATION_write(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_DISK_directory_create(), GNUNET_DISK_directory_test(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_OS_project_data_gnunet(), GNUNET_STRINGS_data_to_string_alloc(), GNUNET_YES, GNUNET_MESSENGER_Member::id, iterate_save_session(), and GNUNET_MESSENGER_Member::sessions.
Referenced by iterate_save_members().
void sync_member_contacts | ( | struct GNUNET_MESSENGER_Member * | member | ) |
Synchronizes contacts between all sessions from a given member and other sessions which are linked to them.
[in,out] | member | Member |
Definition at line 364 of file gnunet-service-messenger_member.c.
References GNUNET_assert, GNUNET_CONTAINER_multihashmap_iterate(), iterate_sync_session_contact(), GNUNET_MESSENGER_MemberSession::member, and GNUNET_MESSENGER_Member::sessions.
Referenced by iterate_sync_member_contacts().
struct GNUNET_MESSENGER_MemberSession * get_member_session | ( | const struct GNUNET_MESSENGER_Member * | member, |
const struct GNUNET_CRYPTO_PublicKey * | public_key | ||
) |
Returns the member session of a member identified by a given public key.
If the member does not provide a session with the given key, NULL gets returned.
[in] | member | Member |
[in] | public_key | Public key |
Definition at line 374 of file gnunet-service-messenger_member.c.
References GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CRYPTO_hash(), and GNUNET_MESSENGER_Member::sessions.
Referenced by get_handle_member_session(), handle_get_message(), load_member_session_next(), solve_srv_room_member_collisions(), and try_member_session().
struct GNUNET_MESSENGER_MemberSession * get_member_session_of | ( | struct GNUNET_MESSENGER_Member * | member, |
const struct GNUNET_MESSENGER_Message * | message, | ||
const struct GNUNET_HashCode * | hash | ||
) |
Returns the member session of a member using a public key which can verify the signature of a given message and its hash.
If the member does not provide a matching session, NULL gets returned.
[in] | member | Member |
[in] | message | Message |
[in] | hash | Hash of message |
Definition at line 440 of file gnunet-service-messenger_member.c.
References GNUNET_MESSENGER_Message::body, GNUNET_assert, GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_memcmp, GNUNET_MESSENGER_KIND_JOIN, GNUNET_MESSENGER_ClosureSearchSession::hash, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_Member::id, iterate_search_session(), GNUNET_MESSENGER_MessageBody::join, GNUNET_MESSENGER_MessageJoin::key, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_ClosureSearchSession::match, GNUNET_MESSENGER_MemberSession::member, GNUNET_MESSENGER_ClosureSearchSession::message, GNUNET_MESSENGER_MessageHeader::sender_id, GNUNET_MESSENGER_Member::sessions, and try_member_session().
Referenced by callback_found_message(), callback_room_handle_message(), handle_room_messages(), recv_message_request(), and send_message_join().
void add_member_session | ( | struct GNUNET_MESSENGER_Member * | member, |
struct GNUNET_MESSENGER_MemberSession * | session | ||
) |
Adds a given member session to its member.
[in,out] | member | Member |
[in,out] | session | Member session |
Definition at line 467 of file gnunet-service-messenger_member.c.
References get_member_session_public_key(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_OK, GNUNET_MESSENGER_MemberSession::member, and GNUNET_MESSENGER_Member::sessions.
Referenced by handle_member_session_switch(), load_member_session(), and try_member_session().
void remove_member_session | ( | struct GNUNET_MESSENGER_Member * | member, |
struct GNUNET_MESSENGER_MemberSession * | session | ||
) |
Removes a given member session from its member.
[in,out] | member | Member |
[in,out] | session | Member session |
Definition at line 491 of file gnunet-service-messenger_member.c.
References get_member_session_public_key(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_YES, GNUNET_MESSENGER_MemberSession::member, and GNUNET_MESSENGER_Member::sessions.
Referenced by remove_room_member_session().
int iterate_member_sessions | ( | struct GNUNET_MESSENGER_Member * | member, |
GNUNET_MESSENGER_MemberIteratorCallback | it, | ||
void * | cls | ||
) |
Iterate through all member sessions currently connected to a given member and call the provided iterator callback with a selected closure.
The function will return the amount of member sessions it iterated through.
[in,out] | member | Member |
[in] | it | Iterator callback |
[in,out] | cls | Closure |
Definition at line 535 of file gnunet-service-messenger_member.c.
References GNUNET_MESSENGER_ClosureIterateSessions::cls, GNUNET_assert, GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_MESSENGER_ClosureIterateSessions::it, iterate_member_sessions_it(), and GNUNET_MESSENGER_Member::sessions.
Referenced by iterate_store_members_it().
void add_member_subscription | ( | struct GNUNET_MESSENGER_Member * | member, |
struct GNUNET_MESSENGER_Subscription * | subscription | ||
) |
Adds a given subscription to a member.
[in,out] | member | Member |
[in,out] | subscription | Subscription |
Definition at line 553 of file gnunet-service-messenger_member.c.
References get_subscription_discourse(), GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_CONTAINER_multishortmap_put(), GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_OK, GNUNET_sh2s(), and GNUNET_MESSENGER_Member::subscriptions.
Referenced by handle_message_subscribe().
void remove_member_subscription | ( | struct GNUNET_MESSENGER_Member * | member, |
struct GNUNET_MESSENGER_Subscription * | subscription | ||
) |
Removes a given subscription from a member.
[in,out] | member | Member |
[in,out] | subscription | Subscription |
Definition at line 572 of file gnunet-service-messenger_member.c.
References get_subscription_discourse(), GNUNET_assert, GNUNET_CONTAINER_multishortmap_remove(), GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_sh2s(), GNUNET_YES, and GNUNET_MESSENGER_Member::subscriptions.
Referenced by task_subscription_exit().
struct GNUNET_MESSENGER_Subscription * get_member_subscription | ( | struct GNUNET_MESSENGER_Member * | member, |
const struct GNUNET_ShortHashCode * | discourse | ||
) |
Returns the active subscription of a given member to a selected discourse.
[in] | member | Member |
[in] | discourse | Discourse |
Definition at line 592 of file gnunet-service-messenger_member.c.
References GNUNET_MESSENGER_Subscription::discourse, GNUNET_assert, GNUNET_CONTAINER_multishortmap_get(), GNUNET_MESSENGER_Subscription::member, and GNUNET_MESSENGER_Member::subscriptions.
Referenced by handle_message_subscribe(), iterate_member_for_subscription(), and notify_srv_handle_message().
int iterate_member_subscriptions | ( | struct GNUNET_MESSENGER_Member * | member, |
GNUNET_MESSENGER_SubscriptionIteratorCallback | it, | ||
void * | cls | ||
) |
Iterate through all subscriptions of a given member and call the provided iterator callback with a selected closure.
The function will return the amount of subscriptions it iterated through.
[in,out] | member | Member |
[in] | it | Iterator callback |
[in,out] | cls | Closure |
Definition at line 602 of file gnunet-service-messenger_member.c.
References GNUNET_assert, GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_MESSENGER_Subscription::member, and GNUNET_MESSENGER_Member::subscriptions.