#include "gnunet_util_lib.h"
#include "gnunet_time_lib.h"
#include "gnunet-service-messenger_list_messages.h"
#include "gnunet-service-messenger_member.h"
#include "messenger_api_contact.h"
Go to the source code of this file.
Data Structures | |
struct | GNUNET_MESSENGER_MemberSession |
Functions | |
struct GNUNET_MESSENGER_MemberSession * | create_member_session (struct GNUNET_MESSENGER_Member *member, const struct GNUNET_CRYPTO_PublicKey *pubkey) |
Creates and allocates a new member session of a member with a given public key. More... | |
struct GNUNET_MESSENGER_MemberSession * | switch_member_session (struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) |
Creates and allocates a new member session closing and replacing a given other session of the same member. More... | |
void | destroy_member_session (struct GNUNET_MESSENGER_MemberSession *session) |
Destroys a member session and frees its memory fully. More... | |
enum GNUNET_GenericReturnValue | reset_member_session (struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_HashCode *hash) |
Resets a given member session which re-opens a member session for new usage. More... | |
void | close_member_session (struct GNUNET_MESSENGER_MemberSession *session) |
Closes a given member session which opens the request for completion of the given member session. More... | |
enum GNUNET_GenericReturnValue | is_member_session_closed (const struct GNUNET_MESSENGER_MemberSession *session) |
Returns if the given member session has been closed. More... | |
enum GNUNET_GenericReturnValue | is_member_session_completed (const struct GNUNET_MESSENGER_MemberSession *session) |
Returns if the given member session has been completed. More... | |
struct GNUNET_TIME_Absolute | get_member_session_start (const struct GNUNET_MESSENGER_MemberSession *session) |
Returns the timestamp of the member session's start. More... | |
const struct GNUNET_HashCode * | get_member_session_key (const struct GNUNET_MESSENGER_MemberSession *session) |
Returns the key of the room a given member session belongs to. More... | |
const struct GNUNET_ShortHashCode * | get_member_session_id (const struct GNUNET_MESSENGER_MemberSession *session) |
Returns the member id of a given member session. More... | |
const struct GNUNET_CRYPTO_PublicKey * | get_member_session_public_key (const struct GNUNET_MESSENGER_MemberSession *session) |
Returns the public key of a given member session. More... | |
const struct GNUNET_HashCode * | get_member_session_context (const struct GNUNET_MESSENGER_MemberSession *session) |
Returns the member context of a given member session. More... | |
struct GNUNET_MESSENGER_Contact * | get_member_session_contact (struct GNUNET_MESSENGER_MemberSession *session) |
Returns the contact which is connected to a given member session. More... | |
enum GNUNET_GenericReturnValue | verify_member_session_as_sender (const struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) |
Verifies a given member session as sender of a selected message and its hash. More... | |
enum GNUNET_GenericReturnValue | check_member_session_history (const struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_HashCode *hash, enum GNUNET_GenericReturnValue ownership) |
Checks the history of a session for a specific message which is identified by its hash and if the ownership flag is set, if the message is owned by the sessions contact. More... | |
void | update_member_session_history (struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) |
Adds a given message to the history of a session using the messages hash. More... | |
void | clear_member_session_history (struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_HashCode *hash) |
Removes a message from the history of a session using the messages hash. More... | |
void | load_member_session (struct GNUNET_MESSENGER_Member *member, const char *directory) |
Loads data from a directory into a new allocated and created member session of a member if the required information can be read from the content of the given directory. More... | |
void | load_member_session_next (struct GNUNET_MESSENGER_MemberSession *session, const char *directory) |
Loads the connection from one session to another through the next attribute. More... | |
void | save_member_session (struct GNUNET_MESSENGER_MemberSession *session, const char *directory) |
Saves data from a member session into a directory which can be load to restore the member session completely. More... | |
struct GNUNET_MESSENGER_MemberSession * create_member_session | ( | struct GNUNET_MESSENGER_Member * | member, |
const struct GNUNET_CRYPTO_PublicKey * | pubkey | ||
) |
Creates and allocates a new member session of a member with a given public key.
If the creation fails, NULL gets returned.
[in,out] | member | Member |
[in] | pubkey | Public key |
Definition at line 34 of file gnunet-service-messenger_member_session.c.
References GNUNET_MESSENGER_MemberSession::closed, GNUNET_MESSENGER_MemberSession::completed, GNUNET_MESSENGER_MemberSession::contact, GNUNET_MESSENGER_MemberSession::context, get_context_from_member(), get_member_contact_store(), get_member_session_context(), get_member_session_id(), get_member_session_key(), get_member_session_public_key(), get_store_contact(), GNUNET_CONTAINER_multihashmap_create(), GNUNET_free, GNUNET_memcpy, GNUNET_new, GNUNET_NO, GNUNET_TIME_absolute_get(), GNUNET_MESSENGER_MemberSession::history, increase_contact_rc(), init_list_messages(), GNUNET_MESSENGER_MemberSession::member, GNUNET_MESSENGER_MemberSession::messages, GNUNET_MESSENGER_MemberSession::next, GNUNET_MESSENGER_MemberSession::prev, pubkey, GNUNET_MESSENGER_MemberSession::public_key, GNUNET_MESSENGER_MemberSession::start, and GNUNET_MESSENGER_Member::store.
Referenced by load_member_session(), and try_member_session().
struct GNUNET_MESSENGER_MemberSession * switch_member_session | ( | struct GNUNET_MESSENGER_MemberSession * | session, |
const struct GNUNET_MESSENGER_Message * | message, | ||
const struct GNUNET_HashCode * | hash | ||
) |
Creates and allocates a new member session closing and replacing a given other session of the same member.
The new session could have significant changes to the members public key or its member id depending on the used message to switch session. The new session will be linked to the old one.
[in,out] | session | Old member session |
[in] | message | Message |
[in] | hash | Hash of message |
Definition at line 233 of file gnunet-service-messenger_member_session.c.
References add_store_member(), GNUNET_MESSENGER_Message::body, check_member_session_completion(), GNUNET_MESSENGER_MemberSession::closed, GNUNET_MESSENGER_MemberSession::completed, GNUNET_MESSENGER_MemberSession::contact, GNUNET_MESSENGER_MemberSession::context, copy_list_messages(), get_context_from_member(), get_member_contact_store(), get_member_session_contact(), get_member_session_context(), get_member_session_id(), get_member_session_key(), get_member_session_public_key(), get_session_member_store(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_memcpy, GNUNET_MESSENGER_KIND_ID, GNUNET_MESSENGER_KIND_KEY, GNUNET_new, GNUNET_NO, GNUNET_sh2s(), GNUNET_TIME_absolute_get(), GNUNET_YES, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MemberSession::history, GNUNET_MESSENGER_MessageId::id, GNUNET_MESSENGER_MessageBody::id, increase_contact_rc(), init_list_messages(), iterate_copy_history(), GNUNET_MESSENGER_MessageKey::key, GNUNET_MESSENGER_MessageBody::key, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_MemberSession::member, GNUNET_MESSENGER_MemberSession::messages, GNUNET_MESSENGER_MemberSession::next, GNUNET_MESSENGER_MemberSession::prev, GNUNET_MESSENGER_MemberSession::public_key, GNUNET_MESSENGER_MemberSession::start, and update_store_contact().
Referenced by handle_member_session_switch().
void destroy_member_session | ( | struct GNUNET_MESSENGER_MemberSession * | session | ) |
Destroys a member session and frees its memory fully.
[in,out] | session | Member session |
Definition at line 324 of file gnunet-service-messenger_member_session.c.
References clear_list_messages(), decrease_contact_rc(), get_member_contact_store(), get_member_session_contact(), get_member_session_context(), get_session_member_store(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_free, GNUNET_YES, GNUNET_MESSENGER_MemberSession::history, GNUNET_MESSENGER_MemberSession::messages, and remove_store_contact().
Referenced by iterate_destroy_session(), and remove_room_member_session().
enum GNUNET_GenericReturnValue reset_member_session | ( | struct GNUNET_MESSENGER_MemberSession * | session, |
const struct GNUNET_HashCode * | hash | ||
) |
Resets a given member session which re-opens a member session for new usage.
Every connection to other sessions will be be dropped. The member sessions messages will be cleared but old history from uncompleted sessions however can be reused!
[in,out] | session | Member session |
[in] | hash | Hash of initial message (JOIN message!) |
Definition at line 350 of file gnunet-service-messenger_member_session.c.
References add_to_list_messages(), clear_list_messages(), GNUNET_MESSENGER_MemberSession::closed, GNUNET_MESSENGER_MemberSession::completed, GNUNET_MESSENGER_MemberSession::contact, get_member_contact_store(), get_member_session_context(), get_member_session_public_key(), get_session_member_store(), get_store_contact(), GNUNET_assert, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, increase_contact_rc(), GNUNET_MESSENGER_MemberSession::messages, and GNUNET_MESSENGER_MemberSession::next.
Referenced by handle_message_join().
void close_member_session | ( | struct GNUNET_MESSENGER_MemberSession * | session | ) |
Closes a given member session which opens the request for completion of the given member session.
Closing a session may complete a session and can't be used without a reset! (
[in,out] | session | Member session |
Definition at line 392 of file gnunet-service-messenger_member_session.c.
References check_member_session_completion(), GNUNET_MESSENGER_MemberSession::closed, GNUNET_assert, and GNUNET_YES.
Referenced by handle_message_leave().
enum GNUNET_GenericReturnValue is_member_session_closed | ( | const struct GNUNET_MESSENGER_MemberSession * | session | ) |
Returns if the given member session has been closed.
[in] | session | Member session |
Definition at line 402 of file gnunet-service-messenger_member_session.c.
References GNUNET_MESSENGER_MemberSession::closed, and GNUNET_assert.
enum GNUNET_GenericReturnValue is_member_session_completed | ( | const struct GNUNET_MESSENGER_MemberSession * | session | ) |
Returns if the given member session has been completed.
A completed member session can't verify any message as its own and it won't add any message to its history.
[in] | session | Member session |
Definition at line 411 of file gnunet-service-messenger_member_session.c.
References GNUNET_MESSENGER_MemberSession::completed, and GNUNET_assert.
Referenced by check_member_session_completion(), iterate_forward_members(), iterate_notify_about_members(), iterate_update_member_sessions(), update_member_session_history(), and verify_member_session_as_sender().
struct GNUNET_TIME_Absolute get_member_session_start | ( | const struct GNUNET_MESSENGER_MemberSession * | session | ) |
Returns the timestamp of the member session's start.
[in] | session | Member session |
Definition at line 421 of file gnunet-service-messenger_member_session.c.
References get_member_session_start(), and GNUNET_assert.
Referenced by get_member_session_start(), and solve_srv_room_member_collisions().
const struct GNUNET_HashCode * get_member_session_key | ( | const struct GNUNET_MESSENGER_MemberSession * | session | ) |
Returns the key of the room a given member session belongs to.
[in] | session | Member session |
Definition at line 433 of file gnunet-service-messenger_member_session.c.
References get_member_store_key(), get_session_member_store(), GNUNET_assert, and GNUNET_MESSENGER_MemberSession::member.
Referenced by create_member_session(), and switch_member_session().
const struct GNUNET_ShortHashCode * get_member_session_id | ( | const struct GNUNET_MESSENGER_MemberSession * | session | ) |
Returns the member id of a given member session.
[in] | session | Member session |
Definition at line 446 of file gnunet-service-messenger_member_session.c.
References get_member_id(), GNUNET_assert, and GNUNET_MESSENGER_MemberSession::member.
Referenced by check_member_session_completion(), create_member_session(), delete_srv_room_message(), find_member_session_in_room(), iterate_notify_about_members(), notify_about_members(), remove_room_member_session(), request_room_message_step(), save_member_session(), send_message_join(), switch_member_session(), update_member_session_history(), and verify_member_session_as_sender().
const struct GNUNET_CRYPTO_PublicKey * get_member_session_public_key | ( | const struct GNUNET_MESSENGER_MemberSession * | session | ) |
Returns the public key of a given member session.
[in] | session | Member session |
Definition at line 455 of file gnunet-service-messenger_member_session.c.
References GNUNET_assert, and GNUNET_MESSENGER_MemberSession::public_key.
Referenced by add_member_session(), create_member_session(), handle_message_id(), iterate_member_sessions_it(), notify_srv_handle_message(), remove_member_session(), remove_room_member_session(), reset_member_session(), save_member_session(), switch_member_session(), and verify_member_session_as_sender().
const struct GNUNET_HashCode * get_member_session_context | ( | const struct GNUNET_MESSENGER_MemberSession * | session | ) |
Returns the member context of a given member session.
[in] | session | Member session |
Definition at line 465 of file gnunet-service-messenger_member_session.c.
References GNUNET_MESSENGER_MemberSession::context, and GNUNET_assert.
Referenced by check_member_session_completion(), create_member_session(), destroy_member_session(), get_next_member_session_context(), reset_member_session(), and switch_member_session().
struct GNUNET_MESSENGER_Contact * get_member_session_contact | ( | struct GNUNET_MESSENGER_MemberSession * | session | ) |
Returns the contact which is connected to a given member session.
[in] | session | Member session |
Definition at line 475 of file gnunet-service-messenger_member_session.c.
References GNUNET_MESSENGER_MemberSession::contact, and GNUNET_assert.
Referenced by destroy_member_session(), and switch_member_session().
enum GNUNET_GenericReturnValue verify_member_session_as_sender | ( | const struct GNUNET_MESSENGER_MemberSession * | session, |
const struct GNUNET_MESSENGER_Message * | message, | ||
const struct GNUNET_HashCode * | hash | ||
) |
Verifies a given member session as sender of a selected message and its hash.
The function returns GNUNET_OK if the message session is verified as sender, otherwise GNUNET_SYSERR.
[in] | session | Member session |
[in] | message | Message |
[in] | hash | Hash of message |
Definition at line 484 of file gnunet-service-messenger_member_session.c.
References check_member_session_history(), get_member_session_id(), get_member_session_public_key(), GNUNET_assert, GNUNET_CRYPTO_public_key_to_string(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_memcmp, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, GNUNET_MESSENGER_Message::header, is_member_session_completed(), GNUNET_MESSENGER_MessageHeader::sender_id, and verify_message().
Referenced by iterate_search_session(), and update_member_session_history().
enum GNUNET_GenericReturnValue check_member_session_history | ( | const struct GNUNET_MESSENGER_MemberSession * | session, |
const struct GNUNET_HashCode * | hash, | ||
enum GNUNET_GenericReturnValue | ownership | ||
) |
Checks the history of a session for a specific message which is identified by its hash and if the ownership flag is set, if the message is owned by the sessions contact.
[in] | session | Member session |
[in] | hash | Hash of message |
[in] | ownership | Ownership flag |
Definition at line 517 of file gnunet-service-messenger_member_session.c.
References GNUNET_assert, GNUNET_CONTAINER_multihashmap_contains(), GNUNET_CONTAINER_multihashmap_get(), GNUNET_NO, GNUNET_YES, and GNUNET_MESSENGER_MemberSession::history.
Referenced by check_member_session_completion(), delete_srv_room_message(), notify_about_members(), recv_message_request(), request_room_message_step(), and verify_member_session_as_sender().
void update_member_session_history | ( | struct GNUNET_MESSENGER_MemberSession * | session, |
const struct GNUNET_MESSENGER_Message * | message, | ||
const struct GNUNET_HashCode * | hash | ||
) |
Adds a given message to the history of a session using the messages hash.
The ownership will be set automatically.
[in,out] | session | Member session |
[in] | message | Message |
[in] | hash | Hash of message |
Definition at line 549 of file gnunet-service-messenger_member_session.c.
References add_to_list_messages(), check_member_session_completion(), GNUNET_MESSENGER_MemberSession::closed, get_member_session_id(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_sh2s(), GNUNET_YES, is_member_session_completed(), is_message_session_bound(), GNUNET_MESSENGER_MemberSession::messages, update_member_chain_history(), and verify_member_session_as_sender().
Referenced by iterate_update_member_sessions().
void clear_member_session_history | ( | struct GNUNET_MESSENGER_MemberSession * | session, |
const struct GNUNET_HashCode * | hash | ||
) |
Removes a message from the history of a session using the messages hash.
[in,out] | session | Member session |
[in] | hash | Hash of message |
Definition at line 590 of file gnunet-service-messenger_member_session.c.
References clear_member_chain_history(), and GNUNET_assert.
Referenced by clear_member_chain_history().
void load_member_session | ( | struct GNUNET_MESSENGER_Member * | member, |
const char * | directory | ||
) |
Loads data from a directory into a new allocated and created member session of a member if the required information can be read from the content of the given directory.
[out] | member | Member |
[in] | directory | Path to a directory |
Definition at line 655 of file gnunet-service-messenger_member_session.c.
References GNUNET_TIME_Absolute::abs_value_us, add_member_session(), cfg, GNUNET_MESSENGER_MemberSession::closed, GNUNET_MESSENGER_MemberSession::completed, config_file, create_member_session(), GNUNET_asprintf(), GNUNET_assert, GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_parse(), GNUNET_CRYPTO_public_key_from_string(), GNUNET_DISK_file_test(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_OS_project_data_gnunet(), GNUNET_YES, key, load_list_messages(), load_member_session_history(), GNUNET_MESSENGER_MemberSession::messages, and GNUNET_MESSENGER_MemberSession::start.
Referenced by callback_scan_for_sessions().
void load_member_session_next | ( | struct GNUNET_MESSENGER_MemberSession * | session, |
const char * | directory | ||
) |
Loads the connection from one session to another through the next attribute.
Necessary information will be loaded from a configuration file inside of a given directory.
[in,out] | session | Member session |
[in] | directory | Path to a directory |
Definition at line 767 of file gnunet-service-messenger_member_session.c.
References cfg, config_file, get_cycle_safe_next_session(), get_member_session(), get_session_member_store(), get_store_member(), GNUNET_asprintf(), GNUNET_assert, GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_get_data(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_parse(), GNUNET_CRYPTO_public_key_from_string(), GNUNET_DISK_file_test(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_OK, GNUNET_OS_project_data_gnunet(), GNUNET_YES, GNUNET_MESSENGER_MemberSession::next, next_id, GNUNET_MESSENGER_MemberSession::prev, and GNUNET_MESSENGER_Member::store.
Referenced by iterate_load_next_session().
void save_member_session | ( | struct GNUNET_MESSENGER_MemberSession * | session, |
const char * | directory | ||
) |
Saves data from a member session into a directory which can be load to restore the member session completely.
[in] | session | Member session |
[in] | directory | Path to a directory |
Definition at line 890 of file gnunet-service-messenger_member_session.c.
References GNUNET_TIME_Absolute::abs_value_us, cfg, GNUNET_MESSENGER_MemberSession::closed, GNUNET_MESSENGER_MemberSession::completed, config_file, get_member_session_id(), get_member_session_public_key(), GNUNET_asprintf(), GNUNET_assert, GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_set_value_number(), GNUNET_CONFIGURATION_set_value_string(), GNUNET_CONFIGURATION_write(), GNUNET_CRYPTO_public_key_to_string(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_OS_project_data_gnunet(), GNUNET_STRINGS_data_to_string_alloc(), GNUNET_MESSENGER_MemberSession::messages, GNUNET_MESSENGER_MemberSession::next, next_id, save_list_messages(), save_member_session_history(), and GNUNET_MESSENGER_MemberSession::start.
Referenced by iterate_save_session().