#include "gnunet-service-messenger_peer_store.h"
#include "gnunet-service-messenger_service.h"
#include "gnunet_common.h"
#include "messenger_api_message.h"
#include "messenger_api_util.h"
Go to the source code of this file.
Data Structures | |
struct | GNUNET_MESSENGER_PeerStoreEntry |
struct | GNUNET_MESSENGER_ClosureVerifyPeer |
struct | GNUNET_MESSENGER_ClosureFindPeer |
Functions | |
void | init_peer_store (struct GNUNET_MESSENGER_PeerStore *store, struct GNUNET_MESSENGER_Service *service) |
Initializes a peer store as fully empty. More... | |
static enum GNUNET_GenericReturnValue | iterate_destroy_peers (void *cls, const struct GNUNET_ShortHashCode *id, void *value) |
void | clear_peer_store (struct GNUNET_MESSENGER_PeerStore *store) |
Clears a peer store, wipes its content and deallocates its memory. More... | |
void | load_peer_store (struct GNUNET_MESSENGER_PeerStore *store, const char *path) |
Loads peer identities from a file into a peer store. More... | |
static enum GNUNET_GenericReturnValue | iterate_save_peers (void *cls, const struct GNUNET_ShortHashCode *id, void *value) |
void | save_peer_store (const struct GNUNET_MESSENGER_PeerStore *store, const char *path) |
Saves peer identities from a peer store into a file. More... | |
static enum GNUNET_GenericReturnValue | verify_store_peer (void *cls, const struct GNUNET_ShortHashCode *id, void *value) |
static struct GNUNET_MESSENGER_PeerStoreEntry * | add_peer_store_entry (struct GNUNET_MESSENGER_PeerStore *store, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_ShortHashCode *id, enum GNUNET_GenericReturnValue active) |
static const struct GNUNET_PeerIdentity * | get_store_service_peer_identity (struct GNUNET_MESSENGER_PeerStore *store) |
struct GNUNET_PeerIdentity * | get_store_peer_of (struct GNUNET_MESSENGER_PeerStore *store, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) |
Returns the peer identity inside the store which verifies the signature of a given message as valid. More... | |
static enum GNUNET_GenericReturnValue | find_store_peer (void *cls, const struct GNUNET_ShortHashCode *id, void *value) |
void | update_store_peer (struct GNUNET_MESSENGER_PeerStore *store, const struct GNUNET_PeerIdentity *peer, enum GNUNET_GenericReturnValue active) |
Adds a peer identity to the store if necessary. More... | |
void init_peer_store | ( | struct GNUNET_MESSENGER_PeerStore * | store, |
struct GNUNET_MESSENGER_Service * | service | ||
) |
Initializes a peer store as fully empty.
[out] | store | Peer store |
[in,out] | service | Messenger service |
Definition at line 40 of file gnunet-service-messenger_peer_store.c.
References GNUNET_assert, GNUNET_CONTAINER_multishortmap_create(), GNUNET_NO, GNUNET_MESSENGER_PeerStore::peers, service, and GNUNET_MESSENGER_PeerStore::service.
Referenced by create_srv_room().
|
static |
Definition at line 51 of file gnunet-service-messenger_peer_store.c.
References GNUNET_assert, GNUNET_free, GNUNET_YES, and value.
Referenced by clear_peer_store().
void clear_peer_store | ( | struct GNUNET_MESSENGER_PeerStore * | store | ) |
Clears a peer store, wipes its content and deallocates its memory.
[in,out] | store | Peer store |
Definition at line 66 of file gnunet-service-messenger_peer_store.c.
References GNUNET_assert, GNUNET_CONTAINER_multishortmap_destroy(), GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, iterate_destroy_peers(), and GNUNET_MESSENGER_PeerStore::peers.
Referenced by destroy_srv_room().
void load_peer_store | ( | struct GNUNET_MESSENGER_PeerStore * | store, |
const char * | path | ||
) |
Loads peer identities from a file into a peer store.
[out] | store | Peer store |
[in] | path | Path to a file |
Definition at line 81 of file gnunet-service-messenger_peer_store.c.
References GNUNET_MESSENGER_PeerStoreEntry::active, convert_peer_identity_to_id(), GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multishortmap_put(), GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_file_read(), GNUNET_DISK_file_seek(), GNUNET_DISK_file_test(), GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_DISK_SEEK_SET, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_memcpy, GNUNET_new, GNUNET_OK, GNUNET_YES, handle, GNUNET_MESSENGER_PeerStoreEntry::peer, peer_id, and GNUNET_MESSENGER_PeerStore::peers.
Referenced by load_srv_room().
|
static |
Definition at line 141 of file gnunet-service-messenger_peer_store.c.
References GNUNET_MESSENGER_PeerStoreEntry::active, GNUNET_assert, GNUNET_DISK_file_write(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_sh2s(), GNUNET_YES, handle, GNUNET_MESSENGER_PeerStoreEntry::peer, and value.
Referenced by save_peer_store().
void save_peer_store | ( | const struct GNUNET_MESSENGER_PeerStore * | store, |
const char * | path | ||
) |
Saves peer identities from a peer store into a file.
[in] | store | Peer store |
[in] | path | Path to a file |
Definition at line 164 of file gnunet-service-messenger_peer_store.c.
References GNUNET_assert, GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_file_seek(), GNUNET_DISK_file_sync(), GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_OPEN_WRITE, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_DISK_SEEK_SET, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, handle, iterate_save_peers(), and GNUNET_MESSENGER_PeerStore::peers.
Referenced by save_srv_room().
|
static |
Definition at line 203 of file gnunet-service-messenger_peer_store.c.
References GNUNET_assert, GNUNET_NO, GNUNET_OK, GNUNET_YES, GNUNET_MESSENGER_PeerStoreEntry::peer, value, verify, and verify_message_by_peer().
Referenced by get_store_peer_of().
|
static |
Definition at line 229 of file gnunet-service-messenger_peer_store.c.
References GNUNET_MESSENGER_PeerStoreEntry::active, GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multishortmap_put(), GNUNET_free, GNUNET_memcpy, GNUNET_new, GNUNET_OK, GNUNET_MESSENGER_PeerStoreEntry::peer, and GNUNET_MESSENGER_PeerStore::peers.
Referenced by get_store_peer_of(), and update_store_peer().
|
static |
Definition at line 259 of file gnunet-service-messenger_peer_store.c.
References get_service_peer_identity(), GNUNET_OK, and GNUNET_MESSENGER_PeerStore::service.
Referenced by get_store_peer_of().
struct GNUNET_PeerIdentity * get_store_peer_of | ( | struct GNUNET_MESSENGER_PeerStore * | store, |
const struct GNUNET_MESSENGER_Message * | message, | ||
const struct GNUNET_HashCode * | hash | ||
) |
Returns the peer identity inside the store which verifies the signature of a given message as valid.
The specific peer identity has to be added to the store previously. Otherwise the function returns NULL.
[in,out] | store | Peer store |
[in] | message | Message |
[in] | hash | Hash of message |
Definition at line 271 of file gnunet-service-messenger_peer_store.c.
References GNUNET_MESSENGER_PeerStoreEntry::active, add_peer_store_entry(), GNUNET_MESSENGER_Message::body, convert_peer_identity_to_id(), get_store_service_peer_identity(), GNUNET_assert, GNUNET_CONTAINER_multishortmap_get_multiple(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_memcmp, GNUNET_MESSENGER_KIND_MISS, GNUNET_MESSENGER_KIND_PEER, GNUNET_NO, GNUNET_OK, GNUNET_sh2s(), GNUNET_YES, GNUNET_MESSENGER_ClosureVerifyPeer::hash, GNUNET_MESSENGER_Message::header, is_peer_message(), GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_ClosureVerifyPeer::message, GNUNET_MESSENGER_MessageBody::miss, GNUNET_MESSENGER_MessagePeer::peer, GNUNET_MESSENGER_MessageMiss::peer, GNUNET_MESSENGER_MessageBody::peer, GNUNET_MESSENGER_PeerStoreEntry::peer, peer_id, GNUNET_MESSENGER_PeerStore::peers, GNUNET_MESSENGER_MessageHeader::sender_id, verify, verify_message_by_peer(), and verify_store_peer().
Referenced by callback_found_message(), callback_room_handle_message(), and handle_room_messages().
|
static |
Definition at line 360 of file gnunet-service-messenger_peer_store.c.
References GNUNET_assert, GNUNET_memcmp, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_ClosureFindPeer::match, GNUNET_MESSENGER_PeerStoreEntry::peer, GNUNET_MESSENGER_ClosureFindPeer::requested, and value.
Referenced by update_store_peer().
void update_store_peer | ( | struct GNUNET_MESSENGER_PeerStore * | store, |
const struct GNUNET_PeerIdentity * | peer, | ||
enum GNUNET_GenericReturnValue | active | ||
) |
Adds a peer identity to the store if necessary.
It ensures that the given peer can be verified as sender of a message afterwards by the store.
[in,out] | store | Peer store |
[in] | peer | Peer identity |
[in] | active | Whether the peer is active or not |
Definition at line 384 of file gnunet-service-messenger_peer_store.c.
References GNUNET_MESSENGER_PeerStoreEntry::active, add_peer_store_entry(), convert_peer_identity_to_id(), find_store_peer(), GNUNET_assert, GNUNET_CONTAINER_multishortmap_get_multiple(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_sh2s(), GNUNET_MESSENGER_ClosureFindPeer::match, peer_id, GNUNET_MESSENGER_PeerStore::peers, and GNUNET_MESSENGER_ClosureFindPeer::requested.
Referenced by handle_message_miss(), and handle_message_peer().