aboutsummaryrefslogtreecommitdiff
path: root/src/messenger/gnunet-service-messenger_handle.h
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2020-11-01 22:57:28 +0100
committerTheJackiMonster <thejackimonster@gmail.com>2021-03-06 01:30:37 +0100
commit2925310d67483aca6e055e1ce0593c6463cd6c72 (patch)
tree2cc8aacafc25563cdccde2eee9a90f9ca257d405 /src/messenger/gnunet-service-messenger_handle.h
parent82b864a64679b0a735201724907cdf2b7e4e16c3 (diff)
downloadgnunet-2925310d67483aca6e055e1ce0593c6463cd6c72.tar.gz
gnunet-2925310d67483aca6e055e1ce0593c6463cd6c72.zip
-added core functionality of the messenger service
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> formatting messenger code Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -completed core functionality of messenger service Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -code cleanup and reuse Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> +added structure to memberships of rooms Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -implemented member permission checks and deletion of messages Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -moved solving requests out of updating last messages (also forward before update) Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -reduced complexity of permisson check and changed load/save of rooms Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -added save/load for accessed keys and basement peers of a room Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -implemented save/load for members with their history and session Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -abstracted management of egos and contacts Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -fix warning Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -abstracted management of members Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -fixed and adjusted test case Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -separated handling of direct and anonymous contacts Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -messenger added member-sessions which fix multiple edge cases, also additional cleanup Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -updated docs and fixed memory leak Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -changed info messages and added protocol version exchange Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -adjusted client api to use contacts from sessions Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -added more logging and fixed wrong session usage Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -adjusted comm0 test case and removed adding members from checking messages Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -fixed test-case for peer exchange Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -getting multiple peers connected in test-case with cadet Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -fixed wrong assert and added tunnel version check -simplified handling and forwarding Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -fixed merging last messages and cycling info messages Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -automated adding sessions and members Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -corrected use of identity keys and signatures Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -adding local joining on entering external room Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -fixed test-case comm0 Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -added more test-cases with generic setup Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -fixed multiple simultaneous channels blocking each other Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -making test-cases more precise Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -added check of members in test-cases, reduced merge messages Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -unified delayed operations: requests, deletions and merges Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -finished handling of operations Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -fixed member session historystorage, added request permission check and padding for transmission Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -improved padding and removed automatic recursive requests Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -implemented filter for sending messages and added private messages to API level Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -wrong setups fixed with proper ego lookups Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -fixed problem with anonymous ego and changed to discrete-level padding Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -added links to replace deleted messages, added local deletion and fixed anonymous id changing Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -added session completion and removal through completion process Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
Diffstat (limited to 'src/messenger/gnunet-service-messenger_handle.h')
-rw-r--r--src/messenger/gnunet-service-messenger_handle.h120
1 files changed, 71 insertions, 49 deletions
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 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2020 GNUnet e.V. 3 Copyright (C) 2020--2021 GNUnet e.V.
4 4
5 GNUnet is free software: you can redistribute it and/or modify it 5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published 6 under the terms of the GNU Affero General Public License as published
@@ -35,6 +35,7 @@
35#include "gnunet_mq_lib.h" 35#include "gnunet_mq_lib.h"
36 36
37#include "gnunet-service-messenger_service.h" 37#include "gnunet-service-messenger_service.h"
38#include "gnunet-service-messenger_member_session.h"
38 39
39#include "messenger_api_ego.h" 40#include "messenger_api_ego.h"
40#include "messenger_api_message.h" 41#include "messenger_api_message.h"
@@ -46,9 +47,7 @@ struct GNUNET_MESSENGER_SrvHandle
46 47
47 char *name; 48 char *name;
48 49
49 struct GNUNET_IDENTITY_Operation *operation; 50 const struct GNUNET_MESSENGER_Ego *ego;
50
51 struct GNUNET_MESSENGER_Ego *ego;
52 51
53 struct GNUNET_CONTAINER_MultiHashMap *member_ids; 52 struct GNUNET_CONTAINER_MultiHashMap *member_ids;
54}; 53};
@@ -56,8 +55,8 @@ struct GNUNET_MESSENGER_SrvHandle
56/** 55/**
57 * Creates and allocates a new handle related to a <i>service</i> and using a given <i>mq</i> (message queue). 56 * Creates and allocates a new handle related to a <i>service</i> and using a given <i>mq</i> (message queue).
58 * 57 *
59 * @param service MESSENGER Service 58 * @param[in/out] service MESSENGER Service
60 * @param mq Message queue 59 * @param[in/out] mq Message queue
61 * @return New handle 60 * @return New handle
62 */ 61 */
63struct GNUNET_MESSENGER_SrvHandle* 62struct GNUNET_MESSENGER_SrvHandle*
@@ -66,7 +65,7 @@ create_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MQ_Handle
66/** 65/**
67 * Destroys a handle and frees its memory fully. 66 * Destroys a handle and frees its memory fully.
68 * 67 *
69 * @param handle Handle 68 * @param[in/out] handle Handle
70 */ 69 */
71void 70void
72destroy_handle (struct GNUNET_MESSENGER_SrvHandle *handle); 71destroy_handle (struct GNUNET_MESSENGER_SrvHandle *handle);
@@ -75,52 +74,63 @@ destroy_handle (struct GNUNET_MESSENGER_SrvHandle *handle);
75 * Writes the path of the directory for a given <i>handle</i> using a specific <i>name</i> to the parameter 74 * Writes the path of the directory for a given <i>handle</i> using a specific <i>name</i> to the parameter
76 * <i>dir</i>. This directory will be used to store data regarding the handle and its messages. 75 * <i>dir</i>. This directory will be used to store data regarding the handle and its messages.
77 * 76 *
78 * @param handle Handle 77 * @param[in] handle Handle
79 * @param name Potential name of the handle 78 * @param[in] name Potential name of the handle
80 * @param dir[out] Path to store data 79 * @param[out] dir Path to store data
81 */ 80 */
82void 81void
83get_handle_data_subdir (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name, char **dir); 82get_handle_data_subdir (const struct GNUNET_MESSENGER_SrvHandle *handle, const char *name, char **dir);
84 83
85/** 84/**
86 * Returns the member id of a given <i>handle</i> in a specific <i>room</i>. 85 * Returns the member id of a given <i>handle</i> in a specific <i>room</i>.
87 * 86 *
88 * If the handle is not a member of the specific <i>room</i>, NULL gets returned. 87 * If the handle is not a member of the specific <i>room</i>, NULL gets returned.
89 * 88 *
90 * @param handle Handle 89 * @param[in] handle Handle
91 * @param key Key of a room 90 * @param[in] key Key of a room
92 * @return Member id or NULL 91 * @return Member id or NULL
93 */ 92 */
94const struct GNUNET_ShortHashCode* 93const struct GNUNET_ShortHashCode*
95get_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key); 94get_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key);
96 95
97/** 96/**
98 * Changes the member id of a given <i>handle</i> in a specific <i>room</i> to match a <i>unique_id</i>. 97 * Changes the member id of a given <i>handle</i> in a specific <i>room</i> to match a <i>unique_id</i>
98 * and returns GNUNET_OK on success.
99 * 99 *
100 * The client connected to the <i>handle</i> will be informed afterwards automatically. 100 * The client connected to the <i>handle</i> will be informed afterwards automatically.
101 * 101 *
102 * @param handle Handle 102 * @param[in/out] handle Handle
103 * @param key Key of a room 103 * @param[in] key Key of a room
104 * @param unique_id Unique member id 104 * @param[in] unique_id Unique member id
105 * @return GNUNET_OK on success, otherwise GNUNET_SYSERR
105 */ 106 */
106void 107int
107change_handle_member_id (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, 108change_handle_member_id (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key,
108 const struct GNUNET_ShortHashCode *unique_id); 109 const struct GNUNET_ShortHashCode *unique_id);
109 110
110/** 111/**
112 * Sets the EGO used by a given <i>handle</i>.
113 *
114 * @param[in/out] handle Handle
115 * @param[in] ego EGO keypair
116 */
117void
118set_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Ego *ego);
119
120/**
111 * Returns the EGO used by a given <i>handle</i>. 121 * Returns the EGO used by a given <i>handle</i>.
112 * 122 *
113 * @param handle Handle 123 * @param[in] handle Handle
114 * @return EGO keypair 124 * @return EGO keypair
115 */ 125 */
116struct GNUNET_MESSENGER_Ego* 126const struct GNUNET_MESSENGER_Ego*
117get_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle); 127get_handle_ego (const struct GNUNET_MESSENGER_SrvHandle *handle);
118 128
119/** 129/**
120 * Tries to set the name and EGO key of a <i>handle</i> initially by looking up a specific <i>name</i>. 130 * Tries to set the name and EGO key of a <i>handle</i> initially by looking up a specific <i>name</i>.
121 * 131 *
122 * @param handle Handle 132 * @param[in/out] handle Handle
123 * @param name Name (optionally: valid EGO name) 133 * @param[in] name Name (optionally: valid EGO name)
124 */ 134 */
125void 135void
126setup_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name); 136setup_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);
129 * Tries to change the keypair of an EGO of a <i>handle</i> under the same name and informs all rooms 139 * Tries to change the keypair of an EGO of a <i>handle</i> under the same name and informs all rooms
130 * about the change automatically. 140 * about the change automatically.
131 * 141 *
132 * @param handle Handle 142 * @param[in/out] handle Handle
133 * @return GNUNET_OK on success, otherwise GNUNET_SYSERR
134 */ 143 */
135int 144void
136update_handle (struct GNUNET_MESSENGER_SrvHandle *handle); 145update_handle (struct GNUNET_MESSENGER_SrvHandle *handle);
137 146
138/** 147/**
@@ -141,20 +150,19 @@ update_handle (struct GNUNET_MESSENGER_SrvHandle *handle);
141 * 150 *
142 * The client connected to the <i>handle</i> will be informed afterwards automatically. 151 * The client connected to the <i>handle</i> will be informed afterwards automatically.
143 * 152 *
144 * @param handle Handle 153 * @param[in/out] handle Handle
145 * @param name New name 154 * @param[in] name New name
146 * @return GNUNET_OK on success, otherwise GNUNET_NO
147 */ 155 */
148int 156void
149set_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name); 157set_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name);
150 158
151/** 159/**
152 * Makes a given <i>handle</i> a member of the room using a specific <i>key</i> and opens the 160 * Makes a given <i>handle</i> a member of the room using a specific <i>key</i> and opens the
153 * room from the handles service. 161 * room from the handles service.
154 * 162 *
155 * @param handle Handle 163 * @param[in/out] handle Handle
156 * @param key Key of a room 164 * @param[in] key Key of a room
157 * @return GNUNET_YES on success, otherwise GNUNET_NO 165 * @return #GNUNET_YES on success, otherwise #GNUNET_NO
158 */ 166 */
159int 167int
160open_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key); 168open_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
163 * Makes a given <i>handle</i> a member of the room using a specific <i>key</i> and enters the room 171 * Makes a given <i>handle</i> a member of the room using a specific <i>key</i> and enters the room
164 * through a tunnel to a peer identified by a given <i>door</i> (peer identity). 172 * through a tunnel to a peer identified by a given <i>door</i> (peer identity).
165 * 173 *
166 * @param handle Handle 174 * @param[in/out] handle Handle
167 * @param door Peer identity 175 * @param[in] door Peer identity
168 * @param key Key of a room 176 * @param[in] key Key of a room
169 * @return GNUNET_YES on success, otherwise GNUNET_NO 177 * @return #GNUNET_YES on success, otherwise #GNUNET_NO
170 */ 178 */
171int 179int
172entry_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_PeerIdentity *door, 180entry_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
176 * Removes the membership of the room using a specific <i>key</i> and closes it if no other handle 184 * Removes the membership of the room using a specific <i>key</i> and closes it if no other handle
177 * from this service is still a member of it. 185 * from this service is still a member of it.
178 * 186 *
179 * @param handle Handle 187 * @param[in/out] handle Handle
180 * @param key Key of a room 188 * @param[in] key Key of a room
181 * @return GNUNET_YES on success, otherwise GNUNET_NO 189 * @return #GNUNET_YES on success, otherwise #GNUNET_NO
182 */ 190 */
183int 191int
184close_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key); 192close_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
186/** 194/**
187 * Sends a <i>message</i> from a given <i>handle</i> to the room using a specific <i>key</i>. 195 * Sends a <i>message</i> from a given <i>handle</i> to the room using a specific <i>key</i>.
188 * 196 *
189 * @param handle Handle 197 * @param[in/out] handle Handle
190 * @param key Key of a room 198 * @param[in] key Key of a room
191 * @param message Message 199 * @param[in] message Message
192 * @return GNUNET_YES on success, otherwise GNUNET_NO 200 * @return #GNUNET_YES on success, #GNUNET_NO or #GNUNET_SYSERR otherwise.
193 */ 201 */
194int 202int
195send_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, 203send_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key,
196 struct GNUNET_MESSENGER_Message *message); 204 const struct GNUNET_MESSENGER_Message *message);
205
206/**
207 * Notifies the handle that a new message was received or sent.
208 *
209 * @param[in/out] handle Handle
210 * @param[in] key Key of room
211 * @param[in] session Member session
212 * @param[in] message Message
213 * @param[in] hash Hash of message
214 */
215void
216notify_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key,
217 const struct GNUNET_MESSENGER_MemberSession *session,
218 const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash);
197 219
198/** 220/**
199 * Loads member ids and other potential configuration from a given <i>handle</i> which 221 * Loads member ids and other potential configuration from a given <i>handle</i> which
200 * depends on the given name the <i>handle</i> uses. 222 * depends on the given name the <i>handle</i> uses.
201 * 223 *
202 * @param handle Handle 224 * @param[out] handle Handle
203 */ 225 */
204void 226void
205load_handle_configuration(struct GNUNET_MESSENGER_SrvHandle *handle); 227load_handle_configuration (struct GNUNET_MESSENGER_SrvHandle *handle);
206 228
207/** 229/**
208 * Saves member ids and other potential configuration from a given <i>handle</i> which 230 * Saves member ids and other potential configuration from a given <i>handle</i> which
209 * depends on the given name the <i>handle</i> uses. 231 * depends on the given name the <i>handle</i> uses.
210 * 232 *
211 * @param handle Handle 233 * @param[in] handle Handle
212 */ 234 */
213void 235void
214save_handle_configuration(struct GNUNET_MESSENGER_SrvHandle *handle); 236save_handle_configuration (struct GNUNET_MESSENGER_SrvHandle *handle);
215 237
216#endif //GNUNET_SERVICE_MESSENGER_HANDLE_H 238#endif //GNUNET_SERVICE_MESSENGER_HANDLE_H