#include "gnunet_util_lib.h"
#include "gnunet-service-messenger_service.h"
#include "gnunet-service-messenger_sender_session.h"
Go to the source code of this file.
Data Structures | |
struct | GNUNET_MESSENGER_SrvHandle |
Functions | |
struct GNUNET_MESSENGER_SrvHandle * | create_srv_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MQ_Handle *mq) |
Creates and allocates a new handle related to a service and using a given mq (message queue). More... | |
void | destroy_srv_handle (struct GNUNET_MESSENGER_SrvHandle *handle) |
Destroys a handle and frees its memory fully. More... | |
void | set_srv_handle_key (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_CRYPTO_PublicKey *key) |
Sets the public key of a given handle. More... | |
const struct GNUNET_CRYPTO_PublicKey * | get_srv_handle_key (const struct GNUNET_MESSENGER_SrvHandle *handle) |
Returns the public key of a given handle. More... | |
void | get_srv_handle_data_subdir (const struct GNUNET_MESSENGER_SrvHandle *handle, const char *name, char **dir) |
Writes the path of the directory for a given handle using a specific name to the parameter dir. More... | |
const struct GNUNET_ShortHashCode * | get_srv_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key) |
Returns the member id of a given handle in a specific room. More... | |
enum GNUNET_GenericReturnValue | change_srv_handle_member_id (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, const struct GNUNET_ShortHashCode *unique_id) |
Changes the member id of a given handle in a specific room to match a unique_id and returns GNUNET_OK on success. More... | |
enum GNUNET_GenericReturnValue | open_srv_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key) |
Makes a given handle a member of the room using a specific key and opens the room from the handles service. More... | |
enum GNUNET_GenericReturnValue | entry_srv_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_PeerIdentity *door, const struct GNUNET_HashCode *key) |
Makes a given handle a member of the room using a specific key and enters the room through a tunnel to a peer identified by a given door (peer identity). More... | |
enum GNUNET_GenericReturnValue | close_srv_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key) |
Removes the membership of the room using a specific key and closes it if no other handle from this service is still a member of it. More... | |
enum GNUNET_GenericReturnValue | is_srv_handle_routing (const struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key) |
Returns whether a given handle has enabled routing for a room using a specific key by opening that room. More... | |
void | sync_srv_handle_messages (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, const struct GNUNET_HashCode *prev, struct GNUNET_HashCode *hash) |
Returns the latest merged hash from a room of a given handle using a specific key and the handles own latest known hash of a message. More... | |
enum GNUNET_GenericReturnValue | send_srv_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, const struct GNUNET_MESSENGER_Message *message) |
Sends a message from a given handle to the room using a specific key. More... | |
void | notify_srv_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_SenderSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, enum GNUNET_GenericReturnValue recent) |
Notifies the handle that a new message was received or sent. More... | |
void | notify_srv_handle_member_id (struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_ShortHashCode *member_id, enum GNUNET_GenericReturnValue reset) |
Notifies the handle that a new member id needs to be used. More... | |
struct GNUNET_MESSENGER_SrvHandle * create_srv_handle | ( | struct GNUNET_MESSENGER_Service * | service, |
struct GNUNET_MQ_Handle * | mq | ||
) |
Creates and allocates a new handle related to a service and using a given mq (message queue).
[in,out] | service | MESSENGER Service |
[in,out] | mq | Message queue |
Definition at line 42 of file gnunet-service-messenger_handle.c.
References GNUNET_assert, GNUNET_CONTAINER_multihashmap_create(), GNUNET_new, GNUNET_NO, handle, mq, GNUNET_VPN_Handle::mq, and service.
Referenced by add_service_handle().
void destroy_srv_handle | ( | struct GNUNET_MESSENGER_SrvHandle * | handle | ) |
Destroys a handle and frees its memory fully.
[in,out] | handle | Handle |
Definition at line 93 of file gnunet-service-messenger_handle.c.
References GNUNET_assert, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_free, GNUNET_SCHEDULER_cancel(), handle, iterate_close_rooms(), and iterate_free_values().
Referenced by clear_list_handles(), and remove_service_handle().
void set_srv_handle_key | ( | struct GNUNET_MESSENGER_SrvHandle * | handle, |
const struct GNUNET_CRYPTO_PublicKey * | key | ||
) |
Sets the public key of a given handle.
[out] | handle | Handle |
[in] | key | Public key |
Definition at line 117 of file gnunet-service-messenger_handle.c.
References GNUNET_assert, GNUNET_free, GNUNET_new, handle, and key.
Referenced by initialize_handle_via_key(), send_message_join(), and send_message_key().
const struct GNUNET_CRYPTO_PublicKey * get_srv_handle_key | ( | const struct GNUNET_MESSENGER_SrvHandle * | handle | ) |
Returns the public key of a given handle.
[in] | handle | Handle |
Definition at line 136 of file gnunet-service-messenger_handle.c.
References GNUNET_assert, and handle.
Referenced by find_member_session_in_room(), get_handle_member_session(), handle_get_message(), initialize_service_handle(), and solve_srv_room_member_collisions().
void get_srv_handle_data_subdir | ( | const struct GNUNET_MESSENGER_SrvHandle * | handle, |
const char * | name, | ||
char ** | dir | ||
) |
Writes the path of the directory for a given handle using a specific name to the parameter dir.
This directory will be used to store data regarding the handle and its messages.
[in] | handle | Handle |
[in] | name | Potential name of the handle |
[out] | dir | Path to store data |
Definition at line 145 of file gnunet-service-messenger_handle.c.
References dir, DIR_SEPARATOR, GNUNET_asprintf(), GNUNET_assert, handle, and name.
const struct GNUNET_ShortHashCode * get_srv_handle_member_id | ( | const struct GNUNET_MESSENGER_SrvHandle * | handle, |
const struct GNUNET_HashCode * | key | ||
) |
Returns the member id of a given handle in a specific room.
If the handle is not a member of the specific room, NULL gets returned.
[in] | handle | Handle |
[in] | key | Key of a room |
Definition at line 193 of file gnunet-service-messenger_handle.c.
References GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), handle, and key.
Referenced by close_srv_handle_room(), entry_srv_handle_room(), find_list_handle_by_member(), get_handle_member_session(), handle_get_message(), handle_room_entry(), handle_room_open(), join_room_locally(), notify_srv_handle_message(), open_srv_handle_room(), open_srv_room(), send_srv_handle_message(), solve_srv_room_member_collisions(), and sync_srv_handle_messages().
enum GNUNET_GenericReturnValue change_srv_handle_member_id | ( | struct GNUNET_MESSENGER_SrvHandle * | handle, |
const struct GNUNET_HashCode * | key, | ||
const struct GNUNET_ShortHashCode * | unique_id | ||
) |
Changes the member id of a given handle in a specific room to match a unique_id and returns GNUNET_OK on success.
The client connected to the handle will be informed afterwards automatically.
[in,out] | handle | Handle |
[in] | key | Key of a room |
[in] | unique_id | Unique member id |
Definition at line 203 of file gnunet-service-messenger_handle.c.
References GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_memcmp, GNUNET_memcpy, GNUNET_new, GNUNET_OK, GNUNET_sh2s(), GNUNET_SYSERR, handle, and key.
Referenced by find_member_session_in_room(), join_room(), and send_message_id().
enum GNUNET_GenericReturnValue open_srv_handle_room | ( | struct GNUNET_MESSENGER_SrvHandle * | handle, |
const struct GNUNET_HashCode * | key | ||
) |
Makes a given handle a member of the room using a specific key and opens the room from the handles service.
[in,out] | handle | Handle |
[in] | key | Key of a room |
Definition at line 244 of file gnunet-service-messenger_handle.c.
References create_handle_member_id(), get_srv_handle_member_id(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE, GNUNET_NO, GNUNET_OK, GNUNET_YES, handle, key, and open_service_room().
Referenced by handle_room_open().
enum GNUNET_GenericReturnValue entry_srv_handle_room | ( | struct GNUNET_MESSENGER_SrvHandle * | handle, |
const struct GNUNET_PeerIdentity * | door, | ||
const struct GNUNET_HashCode * | key | ||
) |
Makes a given handle a member of the room using a specific key and enters the room through a tunnel to a peer identified by a given door (peer identity).
[in,out] | handle | Handle |
[in] | door | Peer identity |
[in] | key | Key of a room |
Definition at line 266 of file gnunet-service-messenger_handle.c.
References create_handle_member_id(), entry_service_room(), get_srv_handle_member_id(), GNUNET_assert, GNUNET_NO, GNUNET_YES, handle, and key.
Referenced by handle_room_entry().
enum GNUNET_GenericReturnValue close_srv_handle_room | ( | struct GNUNET_MESSENGER_SrvHandle * | handle, |
const struct GNUNET_HashCode * | key | ||
) |
Removes the membership of the room using a specific key and closes it if no other handle from this service is still a member of it.
[in,out] | handle | Handle |
[in] | key | Key of a room |
Definition at line 282 of file gnunet-service-messenger_handle.c.
References close_service_room(), get_srv_handle_member_id(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CONTAINER_multihashmap_remove_all(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_YES, handle, iterate_free_values(), key, and result.
Referenced by handle_room_close().
enum GNUNET_GenericReturnValue is_srv_handle_routing | ( | const struct GNUNET_MESSENGER_SrvHandle * | handle, |
const struct GNUNET_HashCode * | key | ||
) |
Returns whether a given handle has enabled routing for a room using a specific key by opening that room.
[in] | handle | Handle |
[in] | key | Key of a room |
Definition at line 315 of file gnunet-service-messenger_handle.c.
References GNUNET_assert, GNUNET_CONTAINER_multihashmap_contains(), handle, and key.
Referenced by find_list_handle_by_member(), and rebuild_srv_room_basement_structure().
void sync_srv_handle_messages | ( | struct GNUNET_MESSENGER_SrvHandle * | handle, |
const struct GNUNET_HashCode * | key, | ||
const struct GNUNET_HashCode * | prev, | ||
struct GNUNET_HashCode * | hash | ||
) |
Returns the latest merged hash from a room of a given handle using a specific key and the handles own latest known hash of a message.
If the room does not contain other messages being accessible to the handle and older than the provided hash, the function returns the originally provided hash as fallback.
[in,out] | handle | Handle |
[in] | key | Key of a room |
[in] | prev | Known hash of a message |
[out] | hash | Hash of the latest merged message in a room available to the handle |
Definition at line 325 of file gnunet-service-messenger_handle.c.
References get_message_state_chain_hash(), get_service_room(), get_srv_handle_member_id(), GNUNET_assert, GNUNET_memcpy, handle, key, merge_srv_room_last_messages(), and GNUNET_MESSENGER_SrvRoom::state.
Referenced by handle_room_entry(), handle_room_open(), and handle_room_sync().
enum GNUNET_GenericReturnValue send_srv_handle_message | ( | struct GNUNET_MESSENGER_SrvHandle * | handle, |
const struct GNUNET_HashCode * | key, | ||
const struct GNUNET_MESSENGER_Message * | message | ||
) |
Sends a message from a given handle to the room using a specific key.
[in,out] | handle | Handle |
[in] | key | Key of a room |
[in] | message | Message |
Definition at line 348 of file gnunet-service-messenger_handle.c.
References copy_message(), get_service_room(), get_srv_handle_member_id(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_memcmp, GNUNET_NO, GNUNET_sh2s(), handle, GNUNET_MESSENGER_Message::header, id, key, msg, send_srv_room_message(), and GNUNET_MESSENGER_MessageHeader::sender_id.
Referenced by handle_send_message().
void notify_srv_handle_message | ( | struct GNUNET_MESSENGER_SrvHandle * | handle, |
struct GNUNET_MESSENGER_SrvRoom * | room, | ||
const struct GNUNET_MESSENGER_SenderSession * | session, | ||
const struct GNUNET_MESSENGER_Message * | message, | ||
const struct GNUNET_HashCode * | hash, | ||
enum GNUNET_GenericReturnValue | recent | ||
) |
Notifies the handle that a new message was received or sent.
[in,out] | handle | Handle |
[in] | room | Room of the message |
[in] | session | Sender session |
[in] | message | Message |
[in] | hash | Hash of message |
[in] | recent | Whether the message was recently handled |
Definition at line 456 of file gnunet-service-messenger_handle.c.
References GNUNET_MESSENGER_Message::body, context, GNUNET_MESSENGER_MessageTalk::discourse, encode_message(), env, get_handle_member_session(), get_member_session_public_key(), get_member_subscription(), get_message_size(), get_next_member_session_context(), get_srv_handle_member_id(), get_srv_room_key(), get_srv_room_member_store(), get_store_member(), GNUNET_assert, GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_RECV_MESSAGE, GNUNET_MESSENGER_FLAG_NONE, GNUNET_MESSENGER_FLAG_PEER, GNUNET_MESSENGER_FLAG_RECENT, GNUNET_MESSENGER_FLAG_SENT, GNUNET_MESSENGER_KIND_TALK, GNUNET_MESSENGER_name_of_kind(), GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_TIME_absolute_ntoh(), GNUNET_YES, handle, has_subscription_of_timestamp(), GNUNET_MESSENGER_Message::header, id, identity, is_peer_message(), key, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_SenderSession::member, GNUNET_VPN_Handle::mq, msg, GNUNET_MESSENGER_SenderSession::peer, pubkey, GNUNET_MESSENGER_MessageBody::talk, GNUNET_MESSENGER_MessageHeader::timestamp, and timestamp().
Referenced by callback_found_message(), handle_service_message(), and notify_about_members().
void notify_srv_handle_member_id | ( | struct GNUNET_MESSENGER_SrvHandle * | handle, |
struct GNUNET_MESSENGER_SrvRoom * | room, | ||
const struct GNUNET_ShortHashCode * | member_id, | ||
enum GNUNET_GenericReturnValue | reset | ||
) |
Notifies the handle that a new member id needs to be used.
[in,out] | handle | Handle |
[in] | room | Room of the member |
[in] | member_id | Member id |
[in] | reset | Reset member session with join message |
Definition at line 625 of file gnunet-service-messenger_handle.c.
References get_srv_room_key(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_new, GNUNET_SCHEDULER_add_now(), GNUNET_sh2s(), GNUNET_YES, handle, GNUNET_MESSENGER_NextMemberId::id, key, reset, GNUNET_MESSENGER_NextMemberId::reset, and task_notify_srv_handle_member_id().
Referenced by join_room(), and solve_srv_room_member_collisions().