![]() |
GNUnet
0.11.x
|
GNUnet MESSENGER service. More...
#include "gnunet-service-messenger_handle.h"
#include "gnunet-service-messenger.h"
#include "gnunet-service-messenger_message_kind.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 (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... | |
void | 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. More... | |
static void | change_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name) |
static void | change_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_Ego *ego) |
struct GNUNET_MESSENGER_Ego * | get_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle) |
Returns the EGO used by a given handle. More... | |
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 int | iterate_send_message (void *cls, const struct GNUNET_HashCode *key, void *value) |
static void | callback_ego_create (void *cls, const struct GNUNET_IDENTITY_PrivateKey *key, const char *emsg) |
int | update_handle (struct GNUNET_MESSENGER_SrvHandle *handle) |
Tries to change the keypair of an EGO of a handle under the same name and informs all rooms about the change automatically. More... | |
int | 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, struct GNUNET_MESSENGER_Message *message) |
Sends a message from a given handle to the room using a specific key. 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).
service | MESSENGER Service |
mq | Message queue |
Definition at line 32 of file gnunet-service-messenger_handle.c.
References GNUNET_MESSENGER_SrvHandle::ego, GNUNET_CONTAINER_multihashmap_create(), GNUNET_new, GNUNET_NO, handle, GNUNET_MESSENGER_SrvHandle::member_ids, mq, GNUNET_MESSENGER_SrvHandle::mq, GNUNET_MESSENGER_SrvHandle::name, GNUNET_MESSENGER_SrvHandle::operation, GNUNET_MESSENGER_SrvHandle::service, 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 51 of file gnunet-service-messenger_handle.c.
References GNUNET_free, and GNUNET_YES.
Referenced by destroy_handle().
void destroy_handle | ( | struct GNUNET_MESSENGER_SrvHandle * | handle | ) |
Destroys a handle and frees its memory fully.
handle | Handle |
Definition at line 59 of file gnunet-service-messenger_handle.c.
References GNUNET_MESSENGER_Service::dir, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_free, GNUNET_IDENTITY_cancel(), iterate_free_member_ids(), GNUNET_MESSENGER_SrvHandle::member_ids, GNUNET_MESSENGER_SrvHandle::name, GNUNET_MESSENGER_SrvHandle::operation, save_handle_configuration(), and GNUNET_MESSENGER_SrvHandle::service.
Referenced by clear_list_handles(), GNUNET_MESSENGER_connect(), GNUNET_MESSENGER_disconnect(), and remove_service_handle().
void get_handle_data_subdir | ( | 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.
handle | Handle |
name | Potential name of the handle |
dir[out] | Path to store data |
Definition at line 77 of file gnunet-service-messenger_handle.c.
References GNUNET_MESSENGER_Service::dir, DIR_SEPARATOR, GNUNET_asprintf(), and GNUNET_MESSENGER_SrvHandle::service.
Referenced by iterate_save_rooms(), load_handle_configuration(), save_handle_configuration(), and set_handle_name().
|
static |
Definition at line 88 of file gnunet-service-messenger_handle.c.
References generate_service_new_member_id(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_sh2s(), GNUNET_YES, GNUNET_MESSENGER_SrvHandle::member_ids, and GNUNET_MESSENGER_SrvHandle::service.
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.
handle | Handle |
key | Key of a room |
Definition at line 109 of file gnunet-service-messenger_handle.c.
References GNUNET_CONTAINER_multihashmap_get(), and GNUNET_MESSENGER_SrvHandle::member_ids.
Referenced by close_handle_room(), close_service_room(), entry_handle_room(), find_list_handle_by_member(), get_room_host_id(), handle_room_close(), handle_room_entry(), handle_room_open(), handle_service_message(), join_room_locally(), open_handle_room(), open_room(), pack_room_message(), and send_handle_message().
void 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.
The client connected to the handle will be informed afterwards automatically.
handle | Handle |
key | Key of a room |
unique_id | Unique member id |
Definition at line 115 of file gnunet-service-messenger_handle.c.
References env, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_MEMBER_ID, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, GNUNET_OK, GNUNET_sh2s(), GNUNET_MESSENGER_MemberMessage::id, GNUNET_MESSENGER_MemberMessage::key, GNUNET_MESSENGER_SrvHandle::member_ids, GNUNET_MESSENGER_SrvHandle::mq, and msg.
Referenced by callback_scan_for_rooms(), change_room_host_id(), and join_room().
|
static |
Definition at line 151 of file gnunet-service-messenger_handle.c.
References env, GNUNET_free, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_GET_NAME, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_strdup, GNUNET_MESSENGER_SrvHandle::mq, msg, and GNUNET_MESSENGER_SrvHandle::name.
Referenced by set_handle_name(), and setup_handle_name().
|
static |
Definition at line 176 of file gnunet-service-messenger_handle.c.
References GNUNET_MESSENGER_SrvHandle::ego, env, get_handle_ego(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_GET_KEY, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_MESSENGER_SrvHandle::mq, msg, GNUNET_MESSENGER_Ego::pub, and GNUNET_MESSENGER_KeyMessage::pubkey.
Referenced by callback_ego_create(), setup_handle_name(), and update_handle().
struct GNUNET_MESSENGER_Ego* get_handle_ego | ( | struct GNUNET_MESSENGER_SrvHandle * | handle | ) |
Returns the EGO used by a given handle.
handle | Handle |
Definition at line 193 of file gnunet-service-messenger_handle.c.
References GNUNET_MESSENGER_SrvHandle::ego, GNUNET_IDENTITY_ego_get_anonymous(), GNUNET_IDENTITY_ego_get_private_key(), GNUNET_IDENTITY_ego_get_public_key(), GNUNET_memcpy, GNUNET_MESSENGER_Ego::priv, and GNUNET_MESSENGER_Ego::pub.
Referenced by change_handle_ego(), join_room(), pack_room_message(), and send_room_info().
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.
handle | Handle |
name | Name (optionally: valid EGO name) |
Definition at line 213 of file gnunet-service-messenger_handle.c.
References change_handle_ego(), change_handle_name(), GNUNET_MESSENGER_Service::dir, load_handle_configuration(), lookup_service_ego(), GNUNET_MESSENGER_SrvHandle::name, and GNUNET_MESSENGER_SrvHandle::service.
Referenced by handle_create().
|
static |
Definition at line 229 of file gnunet-service-messenger_handle.c.
References GNUNET_YES, GNUNET_MESSENGER_MessageHandle::handle, GNUNET_MESSENGER_MessageHandle::message, and send_handle_message().
Referenced by callback_ego_create(), and set_handle_name().
|
static |
Definition at line 239 of file gnunet-service-messenger_handle.c.
References change_handle_ego(), create_message_key(), destroy_message(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_MESSENGER_MessageHandle::handle, iterate_send_message(), lookup_service_ego(), GNUNET_MESSENGER_SrvHandle::member_ids, GNUNET_MESSENGER_MessageHandle::message, GNUNET_MESSENGER_SrvHandle::name, GNUNET_MESSENGER_SrvHandle::operation, GNUNET_MESSENGER_SrvHandle::service, and update_service_ego().
Referenced by update_handle().
int update_handle | ( | struct GNUNET_MESSENGER_SrvHandle * | handle | ) |
Tries to change the keypair of an EGO of a handle under the same name and informs all rooms about the change automatically.
handle | Handle |
Definition at line 266 of file gnunet-service-messenger_handle.c.
References callback_ego_create(), change_handle_ego(), GNUNET_assert, GNUNET_IDENTITY_create(), GNUNET_IDENTITY_TYPE_ECDSA, GNUNET_OK, GNUNET_SYSERR, GNUNET_MESSENGER_Service::identity, lookup_service_ego(), GNUNET_MESSENGER_SrvHandle::name, GNUNET_MESSENGER_SrvHandle::operation, and GNUNET_MESSENGER_SrvHandle::service.
Referenced by handle_update().
int 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.
handle | Handle |
name | New name |
Definition at line 285 of file gnunet-service-messenger_handle.c.
References change_handle_name(), create_message_name(), destroy_message(), get_handle_data_subdir(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_DISK_directory_create_for_file(), GNUNET_DISK_directory_test(), GNUNET_free, GNUNET_IDENTITY_cancel(), GNUNET_IDENTITY_rename(), GNUNET_NO, GNUNET_OK, GNUNET_YES, GNUNET_MESSENGER_MessageHandle::handle, GNUNET_MESSENGER_Service::identity, iterate_send_message(), lookup_service_ego(), GNUNET_MESSENGER_SrvHandle::member_ids, GNUNET_MESSENGER_MessageHandle::message, GNUNET_MESSENGER_SrvHandle::name, GNUNET_MESSENGER_SrvHandle::operation, result, and GNUNET_MESSENGER_SrvHandle::service.
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.
handle | Handle |
key | Key of a room |
Definition at line 347 of file gnunet-service-messenger_handle.c.
References create_handle_member_id(), get_handle_member_id(), GNUNET_NO, GNUNET_YES, open_service_room(), and GNUNET_MESSENGER_SrvHandle::service.
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).
handle | Handle |
door | Peer identity |
key | Key of a room |
Definition at line 356 of file gnunet-service-messenger_handle.c.
References create_handle_member_id(), entry_service_room(), get_handle_member_id(), GNUNET_NO, GNUNET_YES, and GNUNET_MESSENGER_SrvHandle::service.
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.
handle | Handle |
key | Key of a room |
Definition at line 366 of file gnunet-service-messenger_handle.c.
References close_service_room(), get_handle_member_id(), GNUNET_NO, and GNUNET_MESSENGER_SrvHandle::service.
Referenced by handle_room_close().
int send_handle_message | ( | struct GNUNET_MESSENGER_SrvHandle * | handle, |
const struct GNUNET_HashCode * | key, | ||
struct GNUNET_MESSENGER_Message * | message | ||
) |
Sends a message from a given handle to the room using a specific key.
handle | Handle |
key | Key of a room |
message | Message |
Definition at line 375 of file gnunet-service-messenger_handle.c.
References get_handle_member_id(), get_service_room(), GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_Message::header, send_room_message(), GNUNET_MESSENGER_MessageHeader::sender_id, and GNUNET_MESSENGER_SrvHandle::service.
Referenced by handle_send_message(), and iterate_send_message().
|
static |
Definition at line 402 of file gnunet-service-messenger_handle.c.
References cfg, change_handle_member_id(), GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_get_data(), GNUNET_CONFIGURATION_parse(), GNUNET_DISK_file_test(), GNUNET_OK, GNUNET_YES, and GNUNET_MESSENGER_MessageHandle::handle.
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.
handle | Handle |
Definition at line 422 of file gnunet-service-messenger_handle.c.
References callback_scan_for_rooms(), DIR_SEPARATOR, get_handle_data_subdir(), GNUNET_asprintf(), GNUNET_DISK_directory_scan(), GNUNET_DISK_directory_test(), GNUNET_free, GNUNET_OK, GNUNET_YES, GNUNET_MESSENGER_SrvHandle::name, and find_typedefs::scan_dir().
Referenced by setup_handle_name().
|
static |
Definition at line 441 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_free, GNUNET_h2s(), GNUNET_STRINGS_data_to_string_alloc(), GNUNET_YES, GNUNET_MESSENGER_MessageHandle::handle, GNUNET_MESSENGER_SrvHandle::name, 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.
handle | Handle |
Definition at line 484 of file gnunet-service-messenger_handle.c.
References DIR_SEPARATOR, get_handle_data_subdir(), GNUNET_asprintf(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_DISK_directory_create(), GNUNET_DISK_directory_test(), GNUNET_free, GNUNET_NO, GNUNET_OK, GNUNET_YES, iterate_save_rooms(), GNUNET_MESSENGER_SrvHandle::member_ids, and GNUNET_MESSENGER_SrvHandle::name.
Referenced by destroy_handle().