aboutsummaryrefslogtreecommitdiff
path: root/src/messenger/gnunet-service-messenger_service.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/messenger/gnunet-service-messenger_service.h')
-rw-r--r--src/messenger/gnunet-service-messenger_service.h162
1 files changed, 52 insertions, 110 deletions
diff --git a/src/messenger/gnunet-service-messenger_service.h b/src/messenger/gnunet-service-messenger_service.h
index 246c74771..aa43fa457 100644
--- a/src/messenger/gnunet-service-messenger_service.h
+++ b/src/messenger/gnunet-service-messenger_service.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
@@ -33,13 +33,14 @@
33#include "gnunet_disk_lib.h" 33#include "gnunet_disk_lib.h"
34#include "gnunet_identity_service.h" 34#include "gnunet_identity_service.h"
35 35
36#include "messenger_api_ego.h" 36#include "gnunet-service-messenger_ego_store.h"
37
38#include "gnunet-service-messenger_list_handles.h" 37#include "gnunet-service-messenger_list_handles.h"
39 38
40#include "gnunet-service-messenger_contact.h" 39#include "messenger_api_contact_store.h"
41#include "gnunet-service-messenger_room.h" 40#include "gnunet-service-messenger_room.h"
42 41
42#include "gnunet-service-messenger_member_session.h"
43
43struct GNUNET_MESSENGER_Service 44struct GNUNET_MESSENGER_Service
44{ 45{
45 const struct GNUNET_CONFIGURATION_Handle *config; 46 const struct GNUNET_CONFIGURATION_Handle *config;
@@ -50,21 +51,20 @@ struct GNUNET_MESSENGER_Service
50 char *dir; 51 char *dir;
51 52
52 struct GNUNET_CADET_Handle *cadet; 53 struct GNUNET_CADET_Handle *cadet;
53 struct GNUNET_IDENTITY_Handle *identity;
54 54
55 struct GNUNET_CONTAINER_MultiHashMap *egos; 55 struct GNUNET_MESSENGER_EgoStore ego_store;
56 struct GNUNET_MESSENGER_ContactStore contact_store;
56 57
57 struct GNUNET_MESSENGER_ListHandles handles; 58 struct GNUNET_MESSENGER_ListHandles handles;
58 59
59 struct GNUNET_CONTAINER_MultiHashMap *contacts;
60 struct GNUNET_CONTAINER_MultiHashMap *rooms; 60 struct GNUNET_CONTAINER_MultiHashMap *rooms;
61}; 61};
62 62
63/** 63/**
64 * Creates and allocates a new service using a given <i>config</i> and a GNUnet service handle. 64 * Creates and allocates a new service using a given <i>config</i> and a GNUnet service handle.
65 * 65 *
66 * @param config Configuration 66 * @param[in] config Configuration
67 * @param service_handle GNUnet service handle 67 * @param[in/out] service_handle GNUnet service handle
68 * @return New service 68 * @return New service
69 */ 69 */
70struct GNUNET_MESSENGER_Service* 70struct GNUNET_MESSENGER_Service*
@@ -73,39 +73,34 @@ create_service (const struct GNUNET_CONFIGURATION_Handle *config, struct GNUNET_
73/** 73/**
74 * Destroys a <i>service</i> and frees its memory fully. 74 * Destroys a <i>service</i> and frees its memory fully.
75 * 75 *
76 * @param service Service 76 * @param[in/out] service Service
77 */ 77 */
78void 78void
79destroy_service (struct GNUNET_MESSENGER_Service *service); 79destroy_service (struct GNUNET_MESSENGER_Service *service);
80 80
81/** 81/**
82 * Lookups an EGO which was registered to a <i>service</i> under 82 * Returns the used EGO-store of a given <i>service</i>.
83 * a specific <i>identifier</i>.
84 * 83 *
85 * @param service Service 84 * @param[in/out] service Service
86 * @param identifier Identifier string 85 * @return EGO-store
87 * @return EGO or NULL
88 */ 86 */
89struct GNUNET_MESSENGER_Ego* 87struct GNUNET_MESSENGER_EgoStore*
90lookup_service_ego (struct GNUNET_MESSENGER_Service *service, const char *identifier); 88get_service_ego_store (struct GNUNET_MESSENGER_Service *service);
91 89
92/** 90/**
93 * Updates the registration of an EGO to a <i>service</i> under 91 * Returns the used contact store of a given <i>service</i>.
94 * a specific <i>identifier</i> with a new <i>key</i>.
95 * 92 *
96 * @param service Service 93 * @param[in/out] service Service
97 * @param identifier Identifier string 94 * @return Contact store
98 * @param key Private EGO key
99 */ 95 */
100void 96struct GNUNET_MESSENGER_ContactStore*
101update_service_ego (struct GNUNET_MESSENGER_Service *service, const char *identifier, 97get_service_contact_store (struct GNUNET_MESSENGER_Service *service);
102 const struct GNUNET_IDENTITY_PrivateKey* key);
103 98
104/** 99/**
105 * Creates and adds a new handle to a <i>service</i> using a given message queue. 100 * Creates and adds a new handle to a <i>service</i> using a given message queue.
106 * 101 *
107 * @param service Service 102 * @param[in/out] service Service
108 * @param mq Message queue 103 * @param[in/out] mq Message queue
109 * @return New handle 104 * @return New handle
110 */ 105 */
111struct GNUNET_MESSENGER_SrvHandle* 106struct GNUNET_MESSENGER_SrvHandle*
@@ -114,77 +109,42 @@ add_service_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MQ_H
114/** 109/**
115 * Removes a <i>handle</i> from a <i>service</i> and destroys it. 110 * Removes a <i>handle</i> from a <i>service</i> and destroys it.
116 * 111 *
117 * @param service Service 112 * @param[in/out] service Service
118 * @param handle Handle 113 * @param[in/out] handle Handle
119 */ 114 */
120void 115void
121remove_service_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle); 116remove_service_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle);
122 117
123/** 118/**
124 * Tries to write the peer identity of the peer running a <i>service</i> on to the <i>peer</i> 119 * Tries to write the peer identity of the peer running a <i>service</i> on to the <i>peer</i>
125 * parameter. The functions returns GNUNET_OK on success, otherwise GNUNET_SYSERR. 120 * parameter. The functions returns #GNUNET_OK on success, otherwise #GNUNET_SYSERR.
126 * 121 *
127 * @param service Service 122 * @param[in] service Service
128 * @param[out] peer Peer identity 123 * @param[out] peer Peer identity
129 * @return GNUNET_OK on success, otherwise GNUNET_SYSERR 124 * @return #GNUNET_OK on success, otherwise #GNUNET_SYSERR
130 */ 125 */
131int 126int
132get_service_peer_identity (const struct GNUNET_MESSENGER_Service *service, struct GNUNET_PeerIdentity *peer); 127get_service_peer_identity (const struct GNUNET_MESSENGER_Service *service, struct GNUNET_PeerIdentity *peer);
133 128
134/** 129/**
135 * Returns a contact of a <i>service</i> identified by a given public key. If no matching contact exists,
136 * it will tried to create one with the specific public key. If the function still fails to do so,
137 * NULL gets returned.
138 *
139 * @param service Service
140 * @param pubkey Public key of EGO
141 * @return Contact
142 */
143struct GNUNET_MESSENGER_SrvContact*
144get_service_contact_by_pubkey (struct GNUNET_MESSENGER_Service *service, const struct GNUNET_IDENTITY_PublicKey *pubkey);
145
146/**
147 * Changes the public key for a <i>contact</i> known to a <i>service</i> to a specific public key and
148 * updates local map entries to access the contact by its updated key.
149 *
150 * @param service Service
151 * @param contact Contact
152 * @param pubkey Public key of EGO
153 */
154void
155swap_service_contact_by_pubkey (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvContact *contact,
156 const struct GNUNET_IDENTITY_PublicKey *pubkey);
157
158/**
159 * Tries to generate and allocate a new unique member id for a given room of a service identified by its <i>key</i>.
160 * If the generation fails caused by too many tries of duplicates, it returns NULL.
161 *
162 * @param service Service
163 * @param key Key of room
164 * @return Newly generated member id or NULL
165 */
166struct GNUNET_ShortHashCode*
167generate_service_new_member_id (struct GNUNET_MESSENGER_Service *service, const struct GNUNET_HashCode *key);
168
169/**
170 * Returns the room identified by a given <i>key</i> for a <i>service</i>. If the service doesn't know any room 130 * Returns the room identified by a given <i>key</i> for a <i>service</i>. If the service doesn't know any room
171 * using the given key, NULL gets returned. 131 * using the given key, NULL gets returned.
172 * 132 *
173 * @param service Service 133 * @param[in] service Service
174 * @param key Key of room 134 * @param[in] key Key of room
175 * @return Room or NULL 135 * @return Room or NULL
176 */ 136 */
177struct GNUNET_MESSENGER_SrvRoom* 137struct GNUNET_MESSENGER_SrvRoom*
178get_service_room (struct GNUNET_MESSENGER_Service *service, const struct GNUNET_HashCode *key); 138get_service_room (const struct GNUNET_MESSENGER_Service *service, const struct GNUNET_HashCode *key);
179 139
180/** 140/**
181 * Tries to open a room using a given <i>key</i> for a <i>service</i> by a specific <i>handle</i>. The room will be 141 * Tries to open a room using a given <i>key</i> for a <i>service</i> by a specific <i>handle</i>. The room will be
182 * created if necessary. If the function is successful, it returns GNUNET_YES, otherwise GNUNET_NO. 142 * created if necessary. If the function is successful, it returns #GNUNET_YES, otherwise #GNUNET_NO.
183 * 143 *
184 * @param service Service 144 * @param[in/out] service Service
185 * @param handle Handle 145 * @param[in/out] handle Handle
186 * @param key Key of room 146 * @param[in] key Key of room
187 * @return GNUNET_YES on success, otherwise GNUNET_NO 147 * @return #GNUNET_YES on success, otherwise #GNUNET_NO
188 */ 148 */
189int 149int
190open_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle, 150open_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle,
@@ -192,16 +152,16 @@ open_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSE
192 152
193/** 153/**
194 * Tries to enter a room using a given <i>key</i> for a <i>service</i> by a specific <i>handle</i>. The room will 154 * Tries to enter a room using a given <i>key</i> for a <i>service</i> by a specific <i>handle</i>. The room will
195 * be created if necessary. If the function is successful, it returns GNUNET_YES, otherwise GNUNET_NO. 155 * be created if necessary. If the function is successful, it returns #GNUNET_YES, otherwise #GNUNET_NO.
196 * 156 *
197 * The room will be entered through the peer identitied by the peer identity provided as <i>door</i> parameter and 157 * The room will be entered through the peer identitied by the peer identity provided as <i>door</i> parameter and
198 * a new connection will be made. 158 * a new connection will be made.
199 * 159 *
200 * @param service Service 160 * @param[in/out] service Service
201 * @param handle Handle 161 * @param[in/out] handle Handle
202 * @param door Peer identity 162 * @param[in] door Peer identity
203 * @param key Key of room 163 * @param[in] key Key of room
204 * @return GNUNET_YES on success, otherwise GNUNET_NO 164 * @return #GNUNET_YES on success, otherwise #GNUNET_NO
205 */ 165 */
206int 166int
207entry_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle, 167entry_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle,
@@ -209,51 +169,33 @@ entry_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESS
209 169
210/** 170/**
211 * Tries to close a room using a given <i>key</i> for a <i>service</i> by a specific <i>handle</i>. The room will 171 * Tries to close a room using a given <i>key</i> for a <i>service</i> by a specific <i>handle</i>. The room will
212 * be created if necessary. If the function is successful, it returns GNUNET_YES, otherwise GNUNET_NO. 172 * be created if necessary. If the function is successful, it returns #GNUNET_YES, otherwise #GNUNET_NO.
213 * 173 *
214 * If the specific handle is currently the host of the room for this service, a new handle which is a member will 174 * If the specific handle is currently the host of the room for this service, a new handle which is a member will
215 * take its place. Otherwise the room will be destroyed for this service. 175 * take its place. Otherwise the room will be destroyed for this service.
216 * 176 *
217 * @param service Service 177 * @param[in/out] service Service
218 * @param handle Handle 178 * @param[in/out] handle Handle
219 * @param key Key of room 179 * @param[in] key Key of room
220 * @return GNUNET_YES on success, otherwise GNUNET_NO 180 * @return #GNUNET_YES on success, otherwise #GNUNET_NO
221 */ 181 */
222int 182int
223close_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle, 183close_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle,
224 const struct GNUNET_HashCode *key); 184 const struct GNUNET_HashCode *key);
225 185
226/** 186/**
227 * Loads the local configuration for a given <i>room</i> of a <i>service</i> which contains the last messages hash
228 * and the ruleset for general access of new members.
229 *
230 * @param service Service
231 * @param room Room
232 */
233void
234load_service_room_and_messages (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvRoom *room);
235
236/**
237 * Saves the configuration for a given <i>room</i> of a <i>service</i> which contains the last messages hash
238 * and the ruleset for general access of new members locally.
239 *
240 * @param service Service
241 * @param room Room
242 */
243void
244save_service_room_and_messages (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvRoom *room);
245
246/**
247 * Sends a received or sent <i>message</i> with a given <i>hash</i> to each handle of a <i>service</i> which 187 * Sends a received or sent <i>message</i> with a given <i>hash</i> to each handle of a <i>service</i> which
248 * is currently member of a specific <i>room</i> for handling it in the client API. 188 * is currently member of a specific <i>room</i> for handling it in the client API.
249 * 189 *
250 * @param service Service 190 * @param[in/out] service Service
251 * @param room Room 191 * @param[in/out] room Room
252 * @param message Message 192 * @param[in] session Member session
253 * @param hash Hash of message 193 * @param[in] message Message
194 * @param[in] hash Hash of message
254 */ 195 */
255void 196void
256handle_service_message (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvRoom *room, 197handle_service_message (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvRoom *room,
198 const struct GNUNET_MESSENGER_MemberSession *session,
257 const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); 199 const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash);
258 200
259#endif //GNUNET_SERVICE_MESSENGER_SERVICE_H 201#endif //GNUNET_SERVICE_MESSENGER_SERVICE_H