#include "gnunet_util_lib.h"
Go to the source code of this file.
Data Structures | |
struct | GNUNET_MESSENGER_PeerStore |
Functions | |
void | init_peer_store (struct GNUNET_MESSENGER_PeerStore *store, struct GNUNET_MESSENGER_Service *service) |
Initializes a peer store as fully empty. More... | |
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... | |
void | save_peer_store (const struct GNUNET_MESSENGER_PeerStore *store, const char *path) |
Saves peer identities from a peer store into a file. More... | |
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... | |
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().
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().
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().
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().
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().