GNUnet MESSENGER service. More...
#include "platform.h"
#include "gnunet_cadet_service.h"
#include "gnunet_util_lib.h"
#include "gnunet_identity_service.h"
#include "gnunet-service-messenger_service.h"
#include "gnunet-service-messenger_member_session.h"
#include "messenger_api_ego.h"
#include "messenger_api_message.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 | 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... | |
int | 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... | |
void | set_srv_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Ego *ego) |
Sets the EGO used by a given handle. More... | |
const struct GNUNET_MESSENGER_Ego * | get_srv_handle_ego (const struct GNUNET_MESSENGER_SrvHandle *handle) |
Returns the EGO used by a given handle. More... | |
void | setup_srv_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name) |
Tries to set the name and EGO key of a handle initially by looking up a specific name. More... | |
void | update_srv_handle (struct GNUNET_MESSENGER_SrvHandle *handle) |
Tries to change the key pair of an EGO of a handle under the same name and informs all rooms about the change automatically. More... | |
void | set_srv_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name) |
Tries to rename the handle which implies renaming the EGO its using and moving all related data into the directory fitting to the changed name. More... | |
int | 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... | |
int | 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... | |
int | 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... | |
int | 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_MemberSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) |
Notifies the handle that a new message was received or sent. More... | |
void | load_srv_handle_configuration (struct GNUNET_MESSENGER_SrvHandle *handle) |
Loads member ids and other potential configuration from a given handle which depends on the given name the handle uses. More... | |
void | save_srv_handle_configuration (struct GNUNET_MESSENGER_SrvHandle *handle) |
Saves member ids and other potential configuration from a given handle which depends on the given name the handle uses. More... | |
GNUnet MESSENGER service.
Definition in file gnunet-service-messenger_handle.h.
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 35 of file gnunet-service-messenger_handle.c.
References GNUNET_assert, GNUNET_CONTAINER_multihashmap_create(), GNUNET_new, GNUNET_NO, handle, mq, GNUNET_DNS_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 64 of file gnunet-service-messenger_handle.c.
References get_service_ego_store(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_free, handle, iterate_free_member_ids(), save_srv_handle_configuration(), and unbind_store_ego().
Referenced by clear_list_handles(), and remove_service_handle().
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 87 of file gnunet-service-messenger_handle.c.
References dir, DIR_SEPARATOR, GNUNET_asprintf(), GNUNET_assert, handle, and name.
Referenced by callback_set_handle_name(), iterate_save_rooms(), load_srv_handle_configuration(), and save_srv_handle_configuration().
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 128 of file gnunet-service-messenger_handle.c.
References GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), handle, and key.
Referenced by close_service_room(), 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(), pack_srv_room_message(), send_srv_handle_message(), send_srv_room_message(), and solve_srv_room_member_collisions().
int 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 137 of file gnunet-service-messenger_handle.c.
References env, GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_memcmp, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_MEMBER_ID, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, GNUNET_OK, GNUNET_sh2s(), GNUNET_SYSERR, handle, key, GNUNET_DNS_Handle::mq, and msg.
Referenced by callback_scan_for_rooms(), join_room(), and send_message_id().
void set_srv_handle_ego | ( | struct GNUNET_MESSENGER_SrvHandle * | handle, |
const struct GNUNET_MESSENGER_Ego * | ego | ||
) |
Sets the EGO used by a given handle.
[in,out] | handle | Handle |
[in] | ego | EGO key pair |
Definition at line 254 of file gnunet-service-messenger_handle.c.
References change_handle_ego(), create_message_key(), destroy_message(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_iterate(), handle, GNUNET_MESSENGER_MessageHandle::handle, iterate_send_message(), GNUNET_MESSENGER_MessageHandle::message, and GNUNET_MESSENGER_Ego::priv.
Referenced by iterate_create_ego().
const struct GNUNET_MESSENGER_Ego* get_srv_handle_ego | ( | const struct GNUNET_MESSENGER_SrvHandle * | handle | ) |
Returns the EGO used by a given handle.
[in] | handle | Handle |
Definition at line 272 of file gnunet-service-messenger_handle.c.
References GNUNET_assert, GNUNET_IDENTITY_ego_get_anonymous(), GNUNET_IDENTITY_ego_get_private_key(), GNUNET_IDENTITY_ego_get_public_key(), GNUNET_memcpy, handle, GNUNET_MESSENGER_Ego::priv, and GNUNET_MESSENGER_Ego::pub.
Referenced by change_handle_ego(), get_handle_member_session(), handle_get_message(), join_room(), join_room_locally(), notify_srv_handle_message(), pack_srv_room_message(), recv_message_info(), send_room_info(), and solve_srv_room_member_collisions().
void setup_srv_handle_name | ( | struct GNUNET_MESSENGER_SrvHandle * | handle, |
const char * | name | ||
) |
Tries to set the name and EGO key of a handle initially by looking up a specific name.
[in,out] | handle | Handle |
[in] | name | Name (optionally: valid EGO name) |
Definition at line 310 of file gnunet-service-messenger_handle.c.
References callback_setup_handle_name(), get_service_ego_store(), GNUNET_assert, handle, lookup_store_ego(), and name.
Referenced by handle_create().
void update_srv_handle | ( | struct GNUNET_MESSENGER_SrvHandle * | handle | ) |
Tries to change the key pair of an EGO of a handle under the same name and informs all rooms about the change automatically.
[in,out] | handle | Handle |
Definition at line 340 of file gnunet-service-messenger_handle.c.
References callback_update_handle(), get_service_ego_store(), GNUNET_assert, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, handle, and lookup_store_ego().
Referenced by handle_update().
void set_srv_handle_name | ( | struct GNUNET_MESSENGER_SrvHandle * | handle, |
const char * | name | ||
) |
Tries to rename the handle which implies renaming the EGO its using and moving all related data into the directory fitting to the changed name.
The client connected to the handle will be informed afterwards automatically.
[in,out] | handle | Handle |
[in] | name | New name |
Definition at line 407 of file gnunet-service-messenger_handle.c.
References callback_set_handle_name(), change_handle_name(), get_service_ego_store(), GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, handle, lookup_store_ego(), and name.
Referenced by handle_set_name().
int 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 428 of file gnunet-service-messenger_handle.c.
References create_handle_member_id(), get_srv_handle_member_id(), GNUNET_assert, GNUNET_NO, GNUNET_YES, handle, key, and open_service_room().
Referenced by handle_room_open().
int 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 440 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().
int 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 453 of file gnunet-service-messenger_handle.c.
References close_service_room(), get_srv_handle_member_id(), GNUNET_assert, GNUNET_NO, handle, and key.
Referenced by handle_room_close().
int 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 465 of file gnunet-service-messenger_handle.c.
References copy_message(), get_service_room(), get_srv_handle_member_id(), GNUNET_assert, GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_NO, handle, key, msg, and send_srv_room_message().
Referenced by handle_send_message(), and iterate_send_message().
void notify_srv_handle_message | ( | struct GNUNET_MESSENGER_SrvHandle * | handle, |
struct GNUNET_MESSENGER_SrvRoom * | room, | ||
const struct GNUNET_MESSENGER_MemberSession * | session, | ||
const struct GNUNET_MESSENGER_Message * | message, | ||
const struct GNUNET_HashCode * | hash | ||
) |
Notifies the handle that a new message was received or sent.
[in,out] | handle | Handle |
[in] | room | Room of the message |
[in] | session | Member session |
[in] | message | Message |
[in] | hash | Hash of message |
Definition at line 527 of file gnunet-service-messenger_handle.c.
References GNUNET_MESSENGER_MemberSession::contact, context, copy_message(), decrypt_message(), destroy_message(), encode_message(), env, get_contact_key(), get_handle_member_session(), get_message_size(), get_next_member_session_contect(), get_srv_handle_ego(), get_srv_handle_member_id(), get_srv_room_key(), 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_PRIVATE, GNUNET_MESSENGER_FLAG_SENT, GNUNET_MESSENGER_KIND_PRIVATE, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_YES, handle, GNUNET_MESSENGER_Message::header, key, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_DNS_Handle::mq, msg, and pubkey.
Referenced by callback_found_message(), handle_service_message(), and notify_about_members().
void load_srv_handle_configuration | ( | struct GNUNET_MESSENGER_SrvHandle * | handle | ) |
Loads member ids and other potential configuration from a given handle which depends on the given name the handle uses.
[out] | handle | Handle |
Definition at line 624 of file gnunet-service-messenger_handle.c.
References callback_scan_for_rooms(), DIR_SEPARATOR, get_srv_handle_data_subdir(), GNUNET_asprintf(), GNUNET_assert, GNUNET_DISK_directory_scan(), GNUNET_DISK_directory_test(), GNUNET_free, GNUNET_OK, GNUNET_YES, handle, and find_typedefs::scan_dir().
Referenced by callback_setup_handle_name().
void save_srv_handle_configuration | ( | struct GNUNET_MESSENGER_SrvHandle * | handle | ) |
Saves member ids and other potential configuration from a given handle which depends on the given name the handle uses.
[in] | handle | Handle |
Definition at line 691 of file gnunet-service-messenger_handle.c.
References DIR_SEPARATOR, get_srv_handle_data_subdir(), GNUNET_asprintf(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_DISK_directory_create(), GNUNET_DISK_directory_test(), GNUNET_free, GNUNET_NO, GNUNET_OK, GNUNET_YES, handle, and iterate_save_rooms().
Referenced by destroy_srv_handle().