#include "gnunet_util_lib.h"
Go to the source code of this file.
Data Structures | |
struct | GNUNET_MESSENGER_MessageEntry |
struct | GNUNET_MESSENGER_MessageLink |
struct | GNUNET_MESSENGER_MessageStore |
Functions | |
void | init_message_store (struct GNUNET_MESSENGER_MessageStore *store) |
Initializes a message store as fully empty. More... | |
void | clear_message_store (struct GNUNET_MESSENGER_MessageStore *store) |
Clears a message store, wipes its content and deallocates its memory. More... | |
void | load_message_store (struct GNUNET_MESSENGER_MessageStore *store, const char *directory) |
Loads messages from a directory into a message store. More... | |
void | save_message_store (struct GNUNET_MESSENGER_MessageStore *store, const char *directory) |
Saves messages from a message store into a directory. More... | |
enum GNUNET_GenericReturnValue | contains_store_message (const struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash) |
Checks if a message matching a given hash is stored in a message store. More... | |
const struct GNUNET_MESSENGER_Message * | get_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash) |
Returns the message from a message store matching a given hash. More... | |
const struct GNUNET_MESSENGER_MessageLink * | get_store_message_link (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash, enum GNUNET_GenericReturnValue deleted_only) |
Returns the message link from a message store matching a given hash. More... | |
enum GNUNET_GenericReturnValue | put_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_Message *message) |
Stores a message into the message store. More... | |
enum GNUNET_GenericReturnValue | delete_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash) |
Deletes a message in the message store. More... | |
void | cleanup_store_discourse_messages_before (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_ShortHashCode *discourse, const struct GNUNET_TIME_Absolute timestamp) |
Cleans up and deletes all discourse messages existing in the message store memory before a certain timestamp. More... | |
void init_message_store | ( | struct GNUNET_MESSENGER_MessageStore * | store | ) |
Initializes a message store as fully empty.
[out] | store | Message store |
Definition at line 33 of file gnunet-service-messenger_message_store.c.
References GNUNET_MESSENGER_MessageStore::discourses, GNUNET_MESSENGER_MessageStore::entries, GNUNET_assert, GNUNET_CONTAINER_multihashmap_create(), GNUNET_NO, GNUNET_MESSENGER_MessageStore::links, GNUNET_MESSENGER_MessageStore::messages, GNUNET_MESSENGER_MessageStore::rewrite_entries, GNUNET_MESSENGER_MessageStore::storage_messages, and GNUNET_MESSENGER_MessageStore::write_links.
Referenced by create_srv_room().
void clear_message_store | ( | struct GNUNET_MESSENGER_MessageStore * | store | ) |
Clears a message store, wipes its content and deallocates its memory.
[in,out] | store | Message store |
Definition at line 98 of file gnunet-service-messenger_message_store.c.
References GNUNET_MESSENGER_MessageStore::discourses, GNUNET_MESSENGER_MessageStore::entries, GNUNET_assert, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_DISK_file_close(), iterate_destroy_entries(), iterate_destroy_links(), iterate_destroy_messages(), GNUNET_MESSENGER_MessageStore::links, GNUNET_MESSENGER_MessageStore::messages, and GNUNET_MESSENGER_MessageStore::storage_messages.
Referenced by destroy_srv_room().
void load_message_store | ( | struct GNUNET_MESSENGER_MessageStore * | store, |
const char * | directory | ||
) |
Loads messages from a directory into a message store.
[out] | store | Message store |
[in] | directory | Path to a directory |
Definition at line 250 of file gnunet-service-messenger_message_store.c.
References filename, GNUNET_asprintf(), GNUNET_assert, GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_file_test(), GNUNET_DISK_OPEN_READWRITE, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_free, GNUNET_YES, load_message_store_entries(), load_message_store_links(), and GNUNET_MESSENGER_MessageStore::storage_messages.
Referenced by load_srv_room().
void save_message_store | ( | struct GNUNET_MESSENGER_MessageStore * | store, |
const char * | directory | ||
) |
Saves messages from a message store into a directory.
[in] | store | Message store |
[in] | directory | Path to a directory |
Definition at line 401 of file gnunet-service-messenger_message_store.c.
References GNUNET_MESSENGER_MessageStore::entries, filename, GNUNET_asprintf(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_file_seek(), GNUNET_DISK_file_sync(), GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_OPEN_READWRITE, GNUNET_DISK_OPEN_WRITE, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_DISK_SEEK_END, GNUNET_DISK_SEEK_SET, GNUNET_free, GNUNET_NO, GNUNET_SYSERR, GNUNET_YES, iterate_save_entries(), iterate_save_links(), iterate_save_messages(), GNUNET_MESSENGER_MessageStore::links, GNUNET_MESSENGER_MessageStore::messages, GNUNET_MESSENGER_MessageStore::rewrite_entries, save(), GNUNET_MESSENGER_MessageStore::storage_messages, GNUNET_MESSENGER_ClosureMessageSave::store, and GNUNET_MESSENGER_MessageStore::write_links.
Referenced by save_srv_room().
enum GNUNET_GenericReturnValue contains_store_message | ( | const struct GNUNET_MESSENGER_MessageStore * | store, |
const struct GNUNET_HashCode * | hash | ||
) |
Checks if a message matching a given hash is stored in a message store.
The function returns GNUNET_YES if a match is found, GNUNET_NO otherwise.
The message has not to be loaded from disk into memory for this check!
[in] | store | Message store |
[in] | hash | Hash of message |
Definition at line 490 of file gnunet-service-messenger_message_store.c.
References GNUNET_MESSENGER_MessageStore::discourses, GNUNET_MESSENGER_MessageStore::entries, GNUNET_assert, GNUNET_CONTAINER_multihashmap_contains(), GNUNET_YES, GNUNET_MESSENGER_MessageStore::messages, and GNUNET_MESSENGER_ClosureMessageSave::store.
Referenced by update_room_message().
const struct GNUNET_MESSENGER_Message * get_store_message | ( | struct GNUNET_MESSENGER_MessageStore * | store, |
const struct GNUNET_HashCode * | hash | ||
) |
Returns the message from a message store matching a given hash.
If no matching message is found, NULL gets returned.
This function requires the message to be loaded into memory!
[in,out] | store | Message store |
[in] | hash | Hash of message |
Definition at line 508 of file gnunet-service-messenger_message_store.c.
References create_message(), decode_message(), destroy_message(), GNUNET_MESSENGER_MessageStore::discourses, GNUNET_MESSENGER_MessageStore::entries, get_message_kind_size(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_CRYPTO_hash_cmp(), GNUNET_DISK_file_read(), GNUNET_DISK_file_seek(), GNUNET_DISK_SEEK_SET, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_malloc, GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_OK, GNUNET_YES, hash_message(), GNUNET_MESSENGER_MessageEntry::length, GNUNET_MESSENGER_MessageStore::messages, GNUNET_MESSENGER_MessageEntry::offset, GNUNET_MESSENGER_MessageStore::rewrite_entries, and GNUNET_MESSENGER_MessageStore::storage_messages.
Referenced by check_srv_room_peer_status(), delete_srv_room_message(), delete_store_message(), forward_about_members(), get_store_message_link(), handle_room_messages(), notify_about_members(), recv_message_info(), request_room_message_step(), update_tunnel_last_message(), and verify_tunnel_message().
const struct GNUNET_MESSENGER_MessageLink * get_store_message_link | ( | struct GNUNET_MESSENGER_MessageStore * | store, |
const struct GNUNET_HashCode * | hash, | ||
enum GNUNET_GenericReturnValue | deleted_only | ||
) |
Returns the message link from a message store matching a given hash.
If the flag is set to GNUNET_YES, only links from deleted messages will be returned or NULL.
Otherwise message links will also returned for messages found in the store under the given hash. The link which will be returned copies link information from the message for temporary usage.
[in,out] | store | Message store |
[in] | hash | Hash of message |
[in] | deleted_only | Flag |
Definition at line 589 of file gnunet-service-messenger_message_store.c.
References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_MessageLink::first, get_store_message(), GNUNET_CONTAINER_multihashmap_get(), GNUNET_memcpy, GNUNET_MESSENGER_KIND_MERGE, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_MessageStore::links, GNUNET_MESSENGER_MessageBody::merge, GNUNET_MESSENGER_MessageLink::multiple, GNUNET_MESSENGER_MessageHeader::previous, GNUNET_MESSENGER_MessageMerge::previous, and GNUNET_MESSENGER_MessageLink::second.
Referenced by check_member_session_completion(), and request_room_message_step().
enum GNUNET_GenericReturnValue put_store_message | ( | struct GNUNET_MESSENGER_MessageStore * | store, |
const struct GNUNET_HashCode * | hash, | ||
struct GNUNET_MESSENGER_Message * | message | ||
) |
Stores a message into the message store.
The result indicates if the operation was successful.
[in,out] | store | Message store |
[in] | hash | Hash of message |
[in,out] | message | Message |
Definition at line 659 of file gnunet-service-messenger_message_store.c.
References GNUNET_MESSENGER_MessageStore::discourses, get_message_discourse(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, map, and GNUNET_MESSENGER_MessageStore::messages.
Referenced by update_room_message().
enum GNUNET_GenericReturnValue delete_store_message | ( | struct GNUNET_MESSENGER_MessageStore * | store, |
const struct GNUNET_HashCode * | hash | ||
) |
Deletes a message in the message store.
It will be removed from disk space and memory. The result indicates if the operation was successful.
[in,out] | store | Message store |
[in] | hash | Hash of message |
Definition at line 678 of file gnunet-service-messenger_message_store.c.
References add_link(), GNUNET_MESSENGER_MessageStore::entries, get_store_message(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CONTAINER_multihashmap_remove_all(), GNUNET_CRYPTO_zero_keys(), GNUNET_DISK_file_seek(), GNUNET_DISK_file_sync(), GNUNET_DISK_file_write(), GNUNET_DISK_SEEK_SET, GNUNET_free, GNUNET_malloc, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, GNUNET_MESSENGER_MessageEntry::length, GNUNET_MESSENGER_MessageStore::messages, GNUNET_MESSENGER_MessageEntry::offset, GNUNET_MESSENGER_MessageStore::rewrite_entries, and GNUNET_MESSENGER_MessageStore::storage_messages.
Referenced by callback_operation().
void cleanup_store_discourse_messages_before | ( | struct GNUNET_MESSENGER_MessageStore * | store, |
const struct GNUNET_ShortHashCode * | discourse, | ||
const struct GNUNET_TIME_Absolute | timestamp | ||
) |
Cleans up and deletes all discourse messages existing in the message store memory before a certain timestamp.
[in,out] | store | Message store |
[in] | discourse | Hash of discourse |
[in] | timestamp | Timestamp |
Definition at line 781 of file gnunet-service-messenger_message_store.c.
References cleanup(), clear_list_messages(), GNUNET_MESSENGER_CleanupDiscourseMessages::discourse, GNUNET_MESSENGER_MessageStore::discourses, GNUNET_assert, GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multihashmap_remove_all(), GNUNET_memcpy, GNUNET_MESSENGER_ListMessage::hash, init_list_messages(), iterate_flag_for_cleanup_discourse_message(), list, GNUNET_MESSENGER_ListMessage::next, and timestamp().
Referenced by cleanup_srv_room_discourse_messages().