From 2925310d67483aca6e055e1ce0593c6463cd6c72 Mon Sep 17 00:00:00 2001 From: TheJackiMonster Date: Sun, 1 Nov 2020 22:57:28 +0100 Subject: -added core functionality of the messenger service Signed-off-by: TheJackiMonster formatting messenger code Signed-off-by: TheJackiMonster -completed core functionality of messenger service Signed-off-by: TheJackiMonster -code cleanup and reuse Signed-off-by: TheJackiMonster +added structure to memberships of rooms Signed-off-by: TheJackiMonster -implemented member permission checks and deletion of messages Signed-off-by: TheJackiMonster -moved solving requests out of updating last messages (also forward before update) Signed-off-by: TheJackiMonster -reduced complexity of permisson check and changed load/save of rooms Signed-off-by: TheJackiMonster -added save/load for accessed keys and basement peers of a room Signed-off-by: TheJackiMonster -implemented save/load for members with their history and session Signed-off-by: TheJackiMonster -abstracted management of egos and contacts Signed-off-by: TheJackiMonster -fix warning Signed-off-by: TheJackiMonster -abstracted management of members Signed-off-by: TheJackiMonster -fixed and adjusted test case Signed-off-by: TheJackiMonster -separated handling of direct and anonymous contacts Signed-off-by: TheJackiMonster -messenger added member-sessions which fix multiple edge cases, also additional cleanup Signed-off-by: TheJackiMonster -updated docs and fixed memory leak Signed-off-by: TheJackiMonster -changed info messages and added protocol version exchange Signed-off-by: TheJackiMonster -adjusted client api to use contacts from sessions Signed-off-by: TheJackiMonster -added more logging and fixed wrong session usage Signed-off-by: TheJackiMonster -adjusted comm0 test case and removed adding members from checking messages Signed-off-by: TheJackiMonster -fixed test-case for peer exchange Signed-off-by: TheJackiMonster -getting multiple peers connected in test-case with cadet Signed-off-by: TheJackiMonster -fixed wrong assert and added tunnel version check -simplified handling and forwarding Signed-off-by: TheJackiMonster -fixed merging last messages and cycling info messages Signed-off-by: TheJackiMonster -automated adding sessions and members Signed-off-by: TheJackiMonster -corrected use of identity keys and signatures Signed-off-by: TheJackiMonster -adding local joining on entering external room Signed-off-by: TheJackiMonster -fixed test-case comm0 Signed-off-by: TheJackiMonster -added more test-cases with generic setup Signed-off-by: TheJackiMonster -fixed multiple simultaneous channels blocking each other Signed-off-by: TheJackiMonster -making test-cases more precise Signed-off-by: TheJackiMonster -added check of members in test-cases, reduced merge messages Signed-off-by: TheJackiMonster -unified delayed operations: requests, deletions and merges Signed-off-by: TheJackiMonster -finished handling of operations Signed-off-by: TheJackiMonster -fixed member session historystorage, added request permission check and padding for transmission Signed-off-by: TheJackiMonster -improved padding and removed automatic recursive requests Signed-off-by: TheJackiMonster -implemented filter for sending messages and added private messages to API level Signed-off-by: TheJackiMonster -wrong setups fixed with proper ego lookups Signed-off-by: TheJackiMonster -fixed problem with anonymous ego and changed to discrete-level padding Signed-off-by: TheJackiMonster -added links to replace deleted messages, added local deletion and fixed anonymous id changing Signed-off-by: TheJackiMonster -added session completion and removal through completion process Signed-off-by: TheJackiMonster --- src/messenger/gnunet-service-messenger_handle.h | 120 ++++++++++++++---------- 1 file changed, 71 insertions(+), 49 deletions(-) (limited to 'src/messenger/gnunet-service-messenger_handle.h') diff --git a/src/messenger/gnunet-service-messenger_handle.h b/src/messenger/gnunet-service-messenger_handle.h index 81cf377a8..70b2cac6d 100644 --- a/src/messenger/gnunet-service-messenger_handle.h +++ b/src/messenger/gnunet-service-messenger_handle.h @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - Copyright (C) 2020 GNUnet e.V. + Copyright (C) 2020--2021 GNUnet e.V. GNUnet is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published @@ -35,6 +35,7 @@ #include "gnunet_mq_lib.h" #include "gnunet-service-messenger_service.h" +#include "gnunet-service-messenger_member_session.h" #include "messenger_api_ego.h" #include "messenger_api_message.h" @@ -46,9 +47,7 @@ struct GNUNET_MESSENGER_SrvHandle char *name; - struct GNUNET_IDENTITY_Operation *operation; - - struct GNUNET_MESSENGER_Ego *ego; + const struct GNUNET_MESSENGER_Ego *ego; struct GNUNET_CONTAINER_MultiHashMap *member_ids; }; @@ -56,8 +55,8 @@ struct GNUNET_MESSENGER_SrvHandle /** * Creates and allocates a new handle related to a service and using a given mq (message queue). * - * @param service MESSENGER Service - * @param mq Message queue + * @param[in/out] service MESSENGER Service + * @param[in/out] mq Message queue * @return New handle */ struct GNUNET_MESSENGER_SrvHandle* @@ -66,7 +65,7 @@ create_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MQ_Handle /** * Destroys a handle and frees its memory fully. * - * @param handle Handle + * @param[in/out] handle Handle */ void destroy_handle (struct GNUNET_MESSENGER_SrvHandle *handle); @@ -75,52 +74,63 @@ destroy_handle (struct GNUNET_MESSENGER_SrvHandle *handle); * 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. * - * @param handle Handle - * @param name Potential name of the handle - * @param dir[out] Path to store data + * @param[in] handle Handle + * @param[in] name Potential name of the handle + * @param[out] dir Path to store data */ void -get_handle_data_subdir (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name, char **dir); +get_handle_data_subdir (const struct GNUNET_MESSENGER_SrvHandle *handle, const char *name, char **dir); /** * 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. * - * @param handle Handle - * @param key Key of a room + * @param[in] handle Handle + * @param[in] key Key of a room * @return Member id or NULL */ const struct GNUNET_ShortHashCode* get_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key); /** - * Changes the member id of a given handle in a specific room to match a 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. * - * @param handle Handle - * @param key Key of a room - * @param unique_id Unique member id + * @param[in/out] handle Handle + * @param[in] key Key of a room + * @param[in] unique_id Unique member id + * @return GNUNET_OK on success, otherwise GNUNET_SYSERR */ -void +int change_handle_member_id (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, const struct GNUNET_ShortHashCode *unique_id); +/** + * Sets the EGO used by a given handle. + * + * @param[in/out] handle Handle + * @param[in] ego EGO keypair + */ +void +set_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Ego *ego); + /** * Returns the EGO used by a given handle. * - * @param handle Handle + * @param[in] handle Handle * @return EGO keypair */ -struct GNUNET_MESSENGER_Ego* -get_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle); +const struct GNUNET_MESSENGER_Ego* +get_handle_ego (const struct GNUNET_MESSENGER_SrvHandle *handle); /** * Tries to set the name and EGO key of a handle initially by looking up a specific name. * - * @param handle Handle - * @param name Name (optionally: valid EGO name) + * @param[in/out] handle Handle + * @param[in] name Name (optionally: valid EGO name) */ void setup_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name); @@ -129,10 +139,9 @@ setup_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name); * Tries to change the keypair of an EGO of a handle under the same name and informs all rooms * about the change automatically. * - * @param handle Handle - * @return GNUNET_OK on success, otherwise GNUNET_SYSERR + * @param[in/out] handle Handle */ -int +void update_handle (struct GNUNET_MESSENGER_SrvHandle *handle); /** @@ -141,20 +150,19 @@ update_handle (struct GNUNET_MESSENGER_SrvHandle *handle); * * The client connected to the handle will be informed afterwards automatically. * - * @param handle Handle - * @param name New name - * @return GNUNET_OK on success, otherwise GNUNET_NO + * @param[in/out] handle Handle + * @param[in] name New name */ -int +void set_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name); /** * Makes a given handle a member of the room using a specific key and opens the * room from the handles service. * - * @param handle Handle - * @param key Key of a room - * @return GNUNET_YES on success, otherwise GNUNET_NO + * @param[in/out] handle Handle + * @param[in] key Key of a room + * @return #GNUNET_YES on success, otherwise #GNUNET_NO */ int open_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key); @@ -163,10 +171,10 @@ open_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET * 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). * - * @param handle Handle - * @param door Peer identity - * @param key Key of a room - * @return GNUNET_YES on success, otherwise GNUNET_NO + * @param[in/out] handle Handle + * @param[in] door Peer identity + * @param[in] key Key of a room + * @return #GNUNET_YES on success, otherwise #GNUNET_NO */ int entry_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_PeerIdentity *door, @@ -176,9 +184,9 @@ entry_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNE * 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. * - * @param handle Handle - * @param key Key of a room - * @return GNUNET_YES on success, otherwise GNUNET_NO + * @param[in/out] handle Handle + * @param[in] key Key of a room + * @return #GNUNET_YES on success, otherwise #GNUNET_NO */ int close_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key); @@ -186,31 +194,45 @@ close_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNE /** * Sends a message from a given handle to the room using a specific key. * - * @param handle Handle - * @param key Key of a room - * @param message Message - * @return GNUNET_YES on success, otherwise GNUNET_NO + * @param[in/out] handle Handle + * @param[in] key Key of a room + * @param[in] message Message + * @return #GNUNET_YES on success, #GNUNET_NO or #GNUNET_SYSERR otherwise. */ int send_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, - struct GNUNET_MESSENGER_Message *message); + const struct GNUNET_MESSENGER_Message *message); + +/** + * Notifies the handle that a new message was received or sent. + * + * @param[in/out] handle Handle + * @param[in] key Key of room + * @param[in] session Member session + * @param[in] message Message + * @param[in] hash Hash of message + */ +void +notify_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, + const struct GNUNET_MESSENGER_MemberSession *session, + const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); /** * Loads member ids and other potential configuration from a given handle which * depends on the given name the handle uses. * - * @param handle Handle + * @param[out] handle Handle */ void -load_handle_configuration(struct GNUNET_MESSENGER_SrvHandle *handle); +load_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. * - * @param handle Handle + * @param[in] handle Handle */ void -save_handle_configuration(struct GNUNET_MESSENGER_SrvHandle *handle); +save_handle_configuration (struct GNUNET_MESSENGER_SrvHandle *handle); #endif //GNUNET_SERVICE_MESSENGER_HANDLE_H -- cgit v1.2.3