#include "gnunet-service-messenger_service.h"
#include "gnunet-service-messenger_message_kind.h"
#include "gnunet-service-messenger_room.h"
#include "gnunet_common.h"
#include "messenger_api_util.h"
Go to the source code of this file.
Data Structures | |
struct | HandleInitializationClosure |
Functions | |
static void | callback_shutdown_service (void *cls) |
struct GNUNET_MESSENGER_Service * | create_service (const struct GNUNET_CONFIGURATION_Handle *config, struct GNUNET_SERVICE_Handle *service_handle) |
Creates and allocates a new service using a given config and a GNUnet service handle. More... | |
static enum GNUNET_GenericReturnValue | iterate_destroy_rooms (void *cls, const struct GNUNET_HashCode *key, void *value) |
void | destroy_service (struct GNUNET_MESSENGER_Service *service) |
Destroys a service and frees its memory fully. More... | |
struct GNUNET_MESSENGER_ContactStore * | get_service_contact_store (struct GNUNET_MESSENGER_Service *service) |
Returns the used contact store of a given service. More... | |
struct GNUNET_MESSENGER_SrvHandle * | add_service_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MQ_Handle *mq) |
Creates and adds a new handle to a service using a given message queue. More... | |
void | remove_service_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle) |
Removes a handle from a service and destroys it. More... | |
enum GNUNET_GenericReturnValue | get_service_peer_identity (struct GNUNET_MESSENGER_Service *service, struct GNUNET_PeerIdentity *peer) |
Tries to write the peer identity of the peer running a service on to the peer parameter. More... | |
struct GNUNET_MESSENGER_SrvRoom * | get_service_room (const struct GNUNET_MESSENGER_Service *service, const struct GNUNET_HashCode *key) |
Returns the room identified by a given key for a service. More... | |
static enum GNUNET_GenericReturnValue | find_member_session_in_room (void *cls, const struct GNUNET_CRYPTO_PublicKey *public_key, struct GNUNET_MESSENGER_MemberSession *session) |
static void | initialize_service_handle (struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvRoom *room) |
enum GNUNET_GenericReturnValue | open_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key) |
Tries to open a room using a given key for a service by a specific handle. More... | |
enum GNUNET_GenericReturnValue | entry_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_PeerIdentity *door, const struct GNUNET_HashCode *key) |
Tries to enter a room using a given key for a service by a specific handle. More... | |
enum GNUNET_GenericReturnValue | close_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, enum GNUNET_GenericReturnValue deletion) |
Tries to close a room using a given key for a service by a specific handle. More... | |
void | handle_service_message (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_SenderSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) |
Sends a received or sent message with a given hash to each handle of a service which is currently member of a specific room for handling it in the client API. More... | |
|
static |
Definition at line 35 of file gnunet-service-messenger_service.c.
References destroy_service(), and service.
Referenced by create_service().
struct GNUNET_MESSENGER_Service * create_service | ( | const struct GNUNET_CONFIGURATION_Handle * | config, |
struct GNUNET_SERVICE_Handle * | service_handle | ||
) |
Creates and allocates a new service using a given config and a GNUnet service handle.
[in] | config | Configuration |
[in,out] | service_handle | GNUnet service handle |
Definition at line 51 of file gnunet-service-messenger_service.c.
References callback_shutdown_service(), config, get_service_contact_store(), GNUNET_assert, GNUNET_CADET_connect(), GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_CONTAINER_multihashmap_create(), GNUNET_DISK_directory_create(), GNUNET_DISK_directory_test(), GNUNET_free, GNUNET_MESSENGER_SERVICE_NAME, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_shutdown(), GNUNET_STATISTICS_create(), GNUNET_YES, init_contact_store(), init_list_handles(), and service.
Referenced by run().
|
static |
Definition at line 123 of file gnunet-service-messenger_service.c.
References destroy_srv_room(), GNUNET_assert, GNUNET_NO, GNUNET_YES, and value.
Referenced by destroy_service().
void destroy_service | ( | struct GNUNET_MESSENGER_Service * | service | ) |
Destroys a service and frees its memory fully.
[in,out] | service | Service |
Definition at line 139 of file gnunet-service-messenger_service.c.
References clear_contact_store(), clear_list_handles(), get_service_contact_store(), GNUNET_assert, GNUNET_CADET_disconnect(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_free, GNUNET_SCHEDULER_cancel(), GNUNET_SERVICE_shutdown(), GNUNET_STATISTICS_destroy(), GNUNET_YES, iterate_destroy_rooms(), and service.
Referenced by callback_shutdown_service().
struct GNUNET_MESSENGER_ContactStore * get_service_contact_store | ( | struct GNUNET_MESSENGER_Service * | service | ) |
Returns the used contact store of a given service.
[in,out] | service | Service |
Definition at line 188 of file gnunet-service-messenger_service.c.
References GNUNET_assert, and service.
Referenced by create_service(), destroy_service(), and get_member_contact_store().
struct GNUNET_MESSENGER_SrvHandle * add_service_handle | ( | struct GNUNET_MESSENGER_Service * | service, |
struct GNUNET_MQ_Handle * | mq | ||
) |
Creates and adds a new handle to a service using a given message queue.
[in,out] | service | Service |
[in,out] | mq | Message queue |
Definition at line 197 of file gnunet-service-messenger_service.c.
References add_list_handle(), create_srv_handle(), GNUNET_assert, GNUNET_NO, GNUNET_STATISTICS_update(), handle, mq, and service.
Referenced by callback_client_connect().
void remove_service_handle | ( | struct GNUNET_MESSENGER_Service * | service, |
struct GNUNET_MESSENGER_SrvHandle * | handle | ||
) |
Removes a handle from a service and destroys it.
[in,out] | service | Service |
[in,out] | handle | Handle |
Definition at line 220 of file gnunet-service-messenger_service.c.
References destroy_srv_handle(), GNUNET_assert, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_YES, handle, remove_list_handle(), and service.
Referenced by callback_client_disconnect().
enum GNUNET_GenericReturnValue get_service_peer_identity | ( | struct GNUNET_MESSENGER_Service * | service, |
struct GNUNET_PeerIdentity * | peer | ||
) |
Tries to write the peer identity of the peer running a service on to the peer parameter.
The functions returns GNUNET_OK on success, otherwise GNUNET_SYSERR.
[in,out] | service | Service |
[out] | peer | Peer identity |
Definition at line 240 of file gnunet-service-messenger_service.c.
References GNUNET_assert, GNUNET_CRYPTO_get_peer_identity(), GNUNET_memcpy, GNUNET_new, GNUNET_OK, result, and service.
Referenced by close_srv_room(), create_message_peer(), enter_srv_room_at(), get_store_service_peer_identity(), pack_srv_room_message(), and rebuild_srv_room_basement_structure().
struct GNUNET_MESSENGER_SrvRoom * get_service_room | ( | const struct GNUNET_MESSENGER_Service * | service, |
const struct GNUNET_HashCode * | key | ||
) |
Returns the room identified by a given key for a service.
If the service doesn't know any room using the given key, NULL gets returned.
[in] | service | Service |
[in] | key | Key of room |
Definition at line 267 of file gnunet-service-messenger_service.c.
References GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), key, and service.
Referenced by close_service_room(), entry_service_room(), handle_get_message(), open_service_room(), send_srv_handle_message(), and sync_srv_handle_messages().
|
static |
Definition at line 284 of file gnunet-service-messenger_service.c.
References change_srv_handle_member_id(), get_member_session_id(), get_srv_handle_key(), get_srv_room_key(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_memcmp, GNUNET_NO, GNUNET_sh2s(), GNUNET_YES, id, init, and pubkey.
Referenced by initialize_service_handle().
|
static |
Definition at line 324 of file gnunet-service-messenger_service.c.
References find_member_session_in_room(), get_anonymous_public_key(), get_srv_handle_key(), get_srv_room_member_store(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_memcmp, handle, init, iterate_store_members(), pubkey, and HandleInitializationClosure::room.
Referenced by entry_service_room(), and open_service_room().
enum GNUNET_GenericReturnValue open_service_room | ( | struct GNUNET_MESSENGER_Service * | service, |
struct GNUNET_MESSENGER_SrvHandle * | handle, | ||
const struct GNUNET_HashCode * | key | ||
) |
Tries to open a room using a given key for a service by a specific handle.
The room will be created if necessary. If the function is successful, it returns GNUNET_YES, otherwise GNUNET_NO.
[in,out] | service | Service |
[in,out] | handle | Handle |
[in] | key | Key of room |
Definition at line 355 of file gnunet-service-messenger_service.c.
References create_srv_room(), destroy_srv_room(), get_service_room(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_set(), GNUNET_STATISTICS_update(), GNUNET_YES, handle, initialize_service_handle(), key, open_srv_room(), result, and service.
Referenced by open_srv_handle_room().
enum GNUNET_GenericReturnValue entry_service_room | ( | struct GNUNET_MESSENGER_Service * | service, |
struct GNUNET_MESSENGER_SrvHandle * | handle, | ||
const struct GNUNET_PeerIdentity * | door, | ||
const struct GNUNET_HashCode * | key | ||
) |
Tries to enter a room using a given key for a service by a specific handle.
The room will be created if necessary. If the function is successful, it returns GNUNET_YES, otherwise GNUNET_NO.
The room will be entered through the peer identitied by the peer identity provided as door parameter and a new connection will be made.
[in,out] | service | Service |
[in,out] | handle | Handle |
[in] | door | Peer identity |
[in] | key | Key of room |
Definition at line 404 of file gnunet-service-messenger_service.c.
References create_srv_room(), destroy_srv_room(), enter_srv_room_at(), get_service_room(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_set(), GNUNET_STATISTICS_update(), GNUNET_YES, handle, initialize_service_handle(), key, and service.
Referenced by entry_srv_handle_room().
enum GNUNET_GenericReturnValue close_service_room | ( | struct GNUNET_MESSENGER_Service * | service, |
struct GNUNET_MESSENGER_SrvHandle * | handle, | ||
const struct GNUNET_HashCode * | key, | ||
enum GNUNET_GenericReturnValue | deletion | ||
) |
Tries to close a room using a given key for a service by a specific handle.
The room will be created if necessary. If the function is successful, it returns GNUNET_YES, otherwise GNUNET_NO.
If the specific handle is currently the host of the room for this service, a new handle which is a member will take its place. Otherwise the room will be destroyed for this service.
[in,out] | service | Service |
[in,out] | handle | Handle |
[in] | key | Key of room |
[in] | deletion | Flag to indicate context of closing |
Definition at line 459 of file gnunet-service-messenger_service.c.
References create_message_connection(), destroy_srv_room(), find_list_handle_by_member(), get_service_room(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_free, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_set(), GNUNET_STATISTICS_update(), GNUNET_YES, handle, GNUNET_MESSENGER_SrvRoom::host, id, key, GNUNET_MESSENGER_SrvRoom::peer_message, send_srv_room_message(), and service.
Referenced by close_srv_handle_room(), and iterate_close_rooms().
void handle_service_message | ( | struct GNUNET_MESSENGER_Service * | service, |
struct GNUNET_MESSENGER_SrvRoom * | room, | ||
const struct GNUNET_MESSENGER_SenderSession * | session, | ||
const struct GNUNET_MESSENGER_Message * | message, | ||
const struct GNUNET_HashCode * | hash | ||
) |
Sends a received or sent message with a given hash to each handle of a service which is currently member of a specific room for handling it in the client API.
[in,out] | service | Service |
[in,out] | room | Room |
[in] | session | Sender session |
[in] | message | Message |
[in] | hash | Hash of message |
Definition at line 531 of file gnunet-service-messenger_service.c.
References GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_MESSENGER_name_of_kind(), GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_YES, GNUNET_MESSENGER_ListHandle::handle, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_ListHandle::next, notify_srv_handle_message(), and service.
Referenced by handle_room_messages().