![]() |
GNUnet
0.16.x
|
GNUnet MESSENGER service. More...
#include "gnunet-service-messenger_handle.h"
#include "gnunet-service-messenger.h"
#include "gnunet-service-messenger_message_kind.h"
#include "messenger_api_util.h"
Go to the source code of this file.
Data Structures | |
struct | GNUNET_MESSENGER_MessageHandle |
Functions | |
struct GNUNET_MESSENGER_SrvHandle * | create_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... | |
int | iterate_free_member_ids (void *cls, const struct GNUNET_HashCode *key, void *value) |
void | destroy_handle (struct GNUNET_MESSENGER_SrvHandle *handle) |
Destroys a handle and frees its memory fully. More... | |
void | get_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... | |
static int | create_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key) |
const struct GNUNET_ShortHashCode * | get_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_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... | |
static void | change_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name) |
static void | change_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Ego *ego) |
static int | iterate_send_message (void *cls, const struct GNUNET_HashCode *key, void *value) |
void | set_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_handle_ego (const struct GNUNET_MESSENGER_SrvHandle *handle) |
Returns the EGO used by a given handle. More... | |
static void | callback_setup_handle_name (void *cls, const char *name, const struct GNUNET_MESSENGER_Ego *ego) |
void | setup_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... | |
static void | callback_update_handle (void *cls, const char *name, const struct GNUNET_MESSENGER_Ego *ego) |
void | update_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... | |
static void | callback_set_handle_name (void *cls, const char *name, const struct GNUNET_MESSENGER_Ego *ego) |
void | set_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_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_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_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_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... | |
static const struct GNUNET_HashCode * | get_next_member_session_contect (const struct GNUNET_MESSENGER_MemberSession *session) |
static const struct GNUNET_MESSENGER_MemberSession * | get_handle_member_session (struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *key) |
void | notify_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... | |
static int | callback_scan_for_rooms (void *cls, const char *filename) |
void | load_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... | |
static int | iterate_save_rooms (void *cls, const struct GNUNET_HashCode *key, void *value) |
void | save_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.c.
struct GNUNET_MESSENGER_SrvHandle* create_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 34 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(), and GNUNET_MESSENGER_connect().
int iterate_free_member_ids | ( | void * | cls, |
const struct GNUNET_HashCode * | key, | ||
void * | value | ||
) |
Definition at line 53 of file gnunet-service-messenger_handle.c.
References GNUNET_free, GNUNET_YES, and value.
Referenced by destroy_handle().
void destroy_handle | ( | struct GNUNET_MESSENGER_SrvHandle * | handle | ) |
Destroys a handle and frees its memory fully.
[in/out] | handle Handle |
Definition at line 63 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_handle_configuration(), and unbind_store_ego().
Referenced by clear_list_handles(), GNUNET_MESSENGER_connect(), GNUNET_MESSENGER_disconnect(), and remove_service_handle().
void get_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 86 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_handle_configuration(), and save_handle_configuration().
|
static |
Definition at line 101 of file gnunet-service-messenger_handle.c.
References generate_free_member_id(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_sh2s(), GNUNET_YES, handle, and key.
Referenced by entry_handle_room(), and open_handle_room().
const struct GNUNET_ShortHashCode* get_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 127 of file gnunet-service-messenger_handle.c.
References GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), handle, and key.
Referenced by close_handle_room(), close_service_room(), entry_handle_room(), find_list_handle_by_member(), get_handle_member_session(), handle_get_message(), handle_room_entry(), handle_room_open(), join_room_locally(), notify_handle_message(), open_handle_room(), open_room(), pack_room_message(), send_handle_message(), send_room_message(), and solve_room_member_collisions().
int change_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 136 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().
|
static |
Definition at line 182 of file gnunet-service-messenger_handle.c.
References env, GNUNET_assert, GNUNET_free, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_GET_NAME, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_strdup, handle, GNUNET_DNS_Handle::mq, msg, and name.
Referenced by callback_set_handle_name(), callback_setup_handle_name(), and set_handle_name().
|
static |
Definition at line 210 of file gnunet-service-messenger_handle.c.
References env, get_handle_ego(), GNUNET_assert, GNUNET_ERROR_TYPE_WARNING, GNUNET_IDENTITY_key_get_length(), GNUNET_IDENTITY_write_key_to_buffer(), GNUNET_log, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_GET_KEY, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), handle, GNUNET_DNS_Handle::mq, msg, and GNUNET_MESSENGER_Ego::pub.
Referenced by callback_setup_handle_name(), and set_handle_ego().
|
static |
Definition at line 241 of file gnunet-service-messenger_handle.c.
References GNUNET_YES, GNUNET_MESSENGER_MessageHandle::handle, key, GNUNET_MESSENGER_MessageHandle::message, and send_handle_message().
Referenced by callback_set_handle_name(), and set_handle_ego().
void set_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 253 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_handle_ego | ( | const struct GNUNET_MESSENGER_SrvHandle * | handle | ) |
Returns the EGO used by a given handle.
[in] | handle | Handle |
Definition at line 271 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_handle_message(), pack_room_message(), recv_message_info(), send_room_info(), and solve_room_member_collisions().
|
static |
Definition at line 293 of file gnunet-service-messenger_handle.c.
References change_handle_ego(), change_handle_name(), GNUNET_MESSENGER_SrvHandle::ego, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, handle, load_handle_configuration(), and name.
Referenced by setup_handle_name().
void setup_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 309 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().
|
static |
Definition at line 320 of file gnunet-service-messenger_handle.c.
References bind_store_ego(), create_store_ego(), get_service_ego_store(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, handle, and renew_store_ego().
Referenced by update_handle().
void update_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 339 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().
|
static |
Definition at line 355 of file gnunet-service-messenger_handle.c.
References change_handle_name(), create_message_name(), destroy_message(), GNUNET_MESSENGER_SrvHandle::ego, get_handle_data_subdir(), get_service_ego_store(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_DISK_directory_create_for_file(), GNUNET_DISK_directory_remove(), GNUNET_DISK_directory_test(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_YES, handle, GNUNET_MESSENGER_MessageHandle::handle, iterate_send_message(), GNUNET_MESSENGER_MessageHandle::message, name, and rename_store_ego().
Referenced by set_handle_name().
void set_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 406 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_get_name(), and handle_set_name().
int open_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 427 of file gnunet-service-messenger_handle.c.
References create_handle_member_id(), get_handle_member_id(), GNUNET_assert, GNUNET_NO, GNUNET_YES, handle, key, and open_service_room().
Referenced by handle_room_open().
int entry_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 439 of file gnunet-service-messenger_handle.c.
References create_handle_member_id(), entry_service_room(), get_handle_member_id(), GNUNET_assert, GNUNET_NO, GNUNET_YES, handle, and key.
Referenced by handle_room_entry().
int close_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 452 of file gnunet-service-messenger_handle.c.
References close_service_room(), get_handle_member_id(), GNUNET_assert, GNUNET_NO, handle, and key.
Referenced by handle_room_close().
int send_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 464 of file gnunet-service-messenger_handle.c.
References copy_message(), get_handle_member_id(), get_service_room(), GNUNET_assert, GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_NO, handle, key, msg, and send_room_message().
Referenced by handle_send_message(), and iterate_send_message().
|
static |
Definition at line 494 of file gnunet-service-messenger_handle.c.
References get_member_session_context(), and GNUNET_MESSENGER_MemberSession::next.
Referenced by notify_handle_message().
|
static |
Definition at line 503 of file gnunet-service-messenger_handle.c.
References get_handle_ego(), get_handle_member_id(), get_member_session(), get_room_member_store(), get_store_member(), GNUNET_assert, handle, key, GNUNET_MESSENGER_Ego::pub, GNUNET_MESSENGER_MemberStore::room, and GNUNET_MESSENGER_Member::store.
Referenced by notify_handle_message().
void notify_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 526 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_ego(), get_handle_member_id(), get_handle_member_session(), get_message_size(), get_next_member_session_contect(), get_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().
|
static |
Definition at line 596 of file gnunet-service-messenger_handle.c.
References cfg, change_handle_member_id(), filename, GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_get_data(), GNUNET_CONFIGURATION_parse(), GNUNET_DISK_file_test(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_OK, GNUNET_YES, handle, and key.
Referenced by load_handle_configuration().
void load_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 623 of file gnunet-service-messenger_handle.c.
References callback_scan_for_rooms(), DIR_SEPARATOR, get_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().
|
static |
Definition at line 645 of file gnunet-service-messenger_handle.c.
References cfg, DIR_SEPARATOR, filename, get_handle_data_subdir(), GNUNET_asprintf(), GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_set_value_string(), GNUNET_CONFIGURATION_write(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_STRINGS_data_to_string_alloc(), GNUNET_YES, handle, key, and value.
Referenced by save_handle_configuration().
void save_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 690 of file gnunet-service-messenger_handle.c.
References DIR_SEPARATOR, get_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_handle().