GNUnet debian-0.24.3-23-g589b01d60
gnunet-service-messenger.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2020--2025 GNUnet e.V.
4
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
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
25#include "gnunet_util_lib.h"
31
32
34{
37};
38
40
41static void
42handle_create (void *cls,
44{
45 struct GNUNET_MESSENGER_Client *msg_client;
46
47 GNUNET_assert (cls);
48
49 msg_client = cls;
50
51 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Handle created\n");
52
54}
55
56
57static void
58handle_destroy (void *cls,
60{
61 struct GNUNET_MESSENGER_Client *msg_client;
62
63 GNUNET_assert (cls);
64
65 msg_client = cls;
66
67 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Handle destroyed\n");
68
70}
71
72
75{
76 uint16_t full_length;
77 uint16_t msg_length;
78 const char *msg_buffer;
79
81
82 full_length = ntohs (msg->header.size);
83
84 if (full_length < sizeof(*msg))
85 return GNUNET_NO;
86
87 msg_length = full_length - sizeof(*msg);
88 msg_buffer = ((const char*) msg) + sizeof(*msg);
89
90 if (0 == msg_length)
91 return GNUNET_OK;
92
93 {
95 size_t key_len;
96
98 msg_length,
99 &key, &key_len))
100 return GNUNET_NO;
101
102 return key_len == msg_length ? GNUNET_OK : GNUNET_NO;
103 }
104}
105
106
107static void
109 const struct GNUNET_MESSENGER_RoomMessage *msg)
110{
111 uint16_t full_length;
112 uint16_t msg_length;
113 const char *msg_buffer;
114
115 GNUNET_assert ((handle) && (msg));
116
117 full_length = ntohs (msg->header.size);
118 msg_length = full_length - sizeof(*msg);
119 msg_buffer = ((const char*) msg) + sizeof(*msg);
120
121 if (msg_length > 0)
122 {
124 size_t key_len;
125
127 msg_length,
128 &key,
129 &key_len))
131 else
133 "Initialization failed while reading invalid key!\n");
134 }
135 else
136 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Initialization is missing key!\n");
137}
138
139
142 const struct GNUNET_MESSENGER_RoomMessage *msg)
143{
145}
146
147
148static void
150 const struct GNUNET_MESSENGER_RoomMessage *msg)
151{
152 struct GNUNET_MESSENGER_Client *msg_client;
153
154 GNUNET_assert ((cls) && (msg));
155
156 msg_client = cls;
157
158 initialize_handle_via_key (msg_client->handle, msg);
159
160 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Opening room: %s\n", GNUNET_h2s (
161 &(msg->key)));
162
163 if (GNUNET_YES == open_srv_handle_room (msg_client->handle, &(msg->key)))
164 {
165 struct GNUNET_HashCode prev, epoch;
166 const struct GNUNET_ShortHashCode *member_id;
168 struct GNUNET_MQ_Envelope *env;
169
170 sync_srv_handle_messages (msg_client->handle, &(msg->key), &(msg->previous),
171 &prev, &epoch);
172
173 member_id = get_srv_handle_member_id (msg_client->handle, &(msg->key));
174
175 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Opening room with member id: %s\n",
176 GNUNET_sh2s (member_id));
177
179 GNUNET_memcpy (&(response->key), &(msg->key), sizeof(response->key));
180 GNUNET_memcpy (&(response->previous), &prev, sizeof(response->previous));
181 GNUNET_memcpy (&(response->epoch), &epoch, sizeof(response->epoch));
182 GNUNET_MQ_send (msg_client->handle->mq, env);
183 }
184 else
185 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Opening room failed: %s\n",
186 GNUNET_h2s (&(msg->key)));
187
189}
190
191
194 const struct GNUNET_MESSENGER_RoomMessage *msg)
195{
197}
198
199
200static void
202 const struct GNUNET_MESSENGER_RoomMessage *msg)
203{
204 struct GNUNET_MESSENGER_Client *msg_client;
205
206 GNUNET_assert ((cls) && (msg));
207
208 msg_client = cls;
209
210 initialize_handle_via_key (msg_client->handle, msg);
211
212 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Entering room: %s, %s\n", GNUNET_h2s (
213 &(msg->key)), GNUNET_i2s (&(msg->door)));
214
215 if (GNUNET_YES == entry_srv_handle_room (msg_client->handle, &(msg->door),
216 &(msg->key)))
217 {
218 struct GNUNET_HashCode prev, epoch;
219 const struct GNUNET_ShortHashCode *member_id;
221 struct GNUNET_MQ_Envelope *env;
222
223 sync_srv_handle_messages (msg_client->handle, &(msg->key), &(msg->previous),
224 &prev, &epoch);
225
226 member_id = get_srv_handle_member_id (msg_client->handle, &(msg->key));
227
228 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Entering room with member id: %s\n",
229 GNUNET_sh2s (member_id));
230
232 GNUNET_memcpy (&(response->door), &(msg->door), sizeof(response->door));
233 GNUNET_memcpy (&(response->key), &(msg->key), sizeof(response->key));
234 GNUNET_memcpy (&(response->previous), &prev, sizeof(response->previous));
235 GNUNET_memcpy (&(response->epoch), &epoch, sizeof(response->epoch));
236 GNUNET_MQ_send (msg_client->handle->mq, env);
237 }
238 else
239 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Entrance into room failed: %s, %s\n",
240 GNUNET_h2s (&(msg->key)),
241 GNUNET_i2s (&(msg->door)));
242
244}
245
246
247static void
249 const struct GNUNET_MESSENGER_RoomMessage *msg)
250{
251 struct GNUNET_MESSENGER_Client *msg_client;
252
253 GNUNET_assert (cls);
254
255 msg_client = cls;
256
257 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Closing room: %s\n", GNUNET_h2s (
258 &(msg->key)));
259
260 if (GNUNET_YES == close_srv_handle_room (msg_client->handle, &(msg->key)))
261 {
263 struct GNUNET_MQ_Envelope *env;
264
265 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Closing room succeeded: %s\n",
266 GNUNET_h2s (&(msg->key)));
267
269 GNUNET_memcpy (&(response->key), &(msg->key), sizeof(response->key));
270 GNUNET_memcpy (&(response->previous), &(msg->previous),
271 sizeof(response->previous));
272 GNUNET_memcpy (&(response->epoch), &(msg->epoch), sizeof(response->epoch));
273 GNUNET_MQ_send (msg_client->handle->mq, env);
274 }
275 else
276 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Closing room failed: %s\n",
277 GNUNET_h2s (&(msg->key)));
278
280}
281
282
283static void
285 const struct GNUNET_MESSENGER_RoomMessage *msg)
286{
287 struct GNUNET_MESSENGER_Client *msg_client;
288
289 GNUNET_assert (cls);
290
291 msg_client = cls;
292
293 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Syncing room: %s\n", GNUNET_h2s (
294 &(msg->key)));
295
296 {
297 struct GNUNET_HashCode prev, epoch;
299 struct GNUNET_MQ_Envelope *env;
300
301 sync_srv_handle_messages (msg_client->handle, &(msg->key), &(msg->previous),
302 &prev, &epoch);
303
305 GNUNET_memcpy (&(response->key), &(msg->key), sizeof(response->key));
306 GNUNET_memcpy (&(response->previous), &prev, sizeof(response->previous));
307 GNUNET_memcpy (&(response->epoch), &epoch, sizeof(response->epoch));
308 GNUNET_MQ_send (msg_client->handle->mq, env);
309 }
310
312}
313
314
317 const struct GNUNET_MESSENGER_SendMessage *msg)
318{
319 uint16_t full_length;
320 uint16_t msg_length;
321 const char *msg_buffer;
322 struct GNUNET_MESSENGER_Message message;
323
325
326 full_length = ntohs (msg->header.size);
327
328 if (full_length < sizeof(*msg))
329 return GNUNET_NO;
330
331 msg_length = full_length - sizeof(*msg);
332 msg_buffer = ((const char*) msg) + sizeof(*msg);
333
335 GNUNET_YES))
336 {
337 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Too short message: %s\n", GNUNET_h2s (
338 &(msg->key)));
339 return GNUNET_NO;
340 }
341
342 if (GNUNET_YES != decode_message (&message, msg_length, msg_buffer,
344 NULL))
345 {
346 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Decoding message failed: %s\n",
347 GNUNET_h2s (
348 &(msg->key)));
349 return GNUNET_NO;
350 }
351
352 {
353 enum GNUNET_GenericReturnValue allowed;
354 allowed = filter_message_sending (&message);
355
356 if (GNUNET_SYSERR == allowed)
358 "Sending message not allowed: %s to %s\n",
360 GNUNET_h2s (&(msg->key)));
361
362 cleanup_message (&message);
363 return GNUNET_SYSERR != allowed? GNUNET_OK : GNUNET_NO;
364 }
365}
366
367
368static void
370 const struct GNUNET_MESSENGER_SendMessage *msg)
371{
372 struct GNUNET_MESSENGER_Client *msg_client;
373 const struct GNUNET_HashCode *key;
374 const char *msg_buffer;
375 uint16_t msg_length;
376
377 GNUNET_assert ((cls) && (msg));
378
379 msg_client = cls;
380
381 key = &(msg->key);
382 msg_buffer = ((const char*) msg) + sizeof(*msg);
383 msg_length = ntohs (msg->header.size) - sizeof(*msg);
384
385 {
386 struct GNUNET_MESSENGER_Message message;
387 decode_message (&message, msg_length, msg_buffer, GNUNET_YES, NULL);
388
389 if ((GNUNET_YES != msg_client->handle->service->group_keys) &&
391 goto skip_message;
392
393 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending message: %s to %s (by %s)\n",
395 GNUNET_h2s (key),
396 GNUNET_sh2s (&(message.header.sender_id)));
397
398 if (GNUNET_YES != send_srv_handle_message (msg_client->handle, key, &message
399 ))
400 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sending message failed: %s to %s\n",
402 GNUNET_h2s (key));
403
404skip_message:
405 cleanup_message (&message);
406 }
407
409}
410
411
412static void
414 struct GNUNET_MESSENGER_SrvRoom *room,
415 const struct GNUNET_MESSENGER_Message *message,
416 const struct GNUNET_HashCode *hash)
417{
418 struct GNUNET_MESSENGER_Client *msg_client;
419 struct GNUNET_MESSENGER_SenderSession session;
420
421 GNUNET_assert ((cls) && (room) && (hash));
422
423 msg_client = cls;
424
425 if (! message)
426 {
428 struct GNUNET_MQ_Envelope *env;
429
431 "Notifying client about missing message: %s\n",
432 GNUNET_h2s (hash));
433
436 GNUNET_memcpy (&(response->key), &(room->key), sizeof(room->key));
437 GNUNET_memcpy (&(response->hash), hash, sizeof(*hash));
438 GNUNET_MQ_send (msg_client->handle->mq, env);
439 return;
440 }
441
442 if (GNUNET_YES == is_peer_message (message))
443 {
444 struct GNUNET_MESSENGER_PeerStore *store;
445
446 store = get_srv_room_peer_store (room);
447 session.peer = get_store_peer_of (store, message, hash);
448
449 if (! session.peer)
450 {
452 "Peer session from sender of message (%s) unknown!\n",
453 GNUNET_h2s (hash));
454 return;
455 }
456 }
457 else
458 {
459 struct GNUNET_MESSENGER_MemberStore *store;
460 struct GNUNET_MESSENGER_Member *member;
461
463 member = get_store_member_of (store, message);
464
465 if (! member)
466 {
467 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sender of message (%s) unknown!\n",
468 GNUNET_h2s (hash));
469 return;
470 }
471
472 session.member = get_member_session_of (member, message, hash);
473
474 if (! session.member)
475 {
477 "Member session from sender of message (%s) unknown!\n",
478 GNUNET_h2s (hash));
479 return;
480 }
481 }
482
483 {
484 const struct GNUNET_MESSENGER_MessageStore *message_store;
485 const struct GNUNET_HashCode *epoch;
486
487 message_store = get_srv_room_message_store (room);
488 epoch = get_store_message_epoch (message_store, hash);
489
490 if (GNUNET_NO == msg_client->handle->service->local_request)
491 notify_srv_handle_message (msg_client->handle, room, &session, message,
492 hash, epoch, GNUNET_NO);
493 else
494 handle_service_message (msg_client->handle->service, room, &session,
495 message, hash, epoch, GNUNET_NO);
496 }
497}
498
499
500static void
502 const struct GNUNET_MESSENGER_GetMessage *msg)
503{
504 struct GNUNET_MESSENGER_Client *msg_client;
505 struct GNUNET_MESSENGER_SrvRoom *room;
506 const struct GNUNET_ShortHashCode *member_id;
507 struct GNUNET_MESSENGER_Member *member;
508 const struct GNUNET_CRYPTO_PublicKey *pubkey;
509 struct GNUNET_MESSENGER_MemberSession *session;
510
511 GNUNET_assert ((cls) && (msg));
512
513 msg_client = cls;
514
515 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Requesting message from room: %s\n",
516 GNUNET_h2s (&(msg->key)));
517 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Requested message: %s\n",
518 GNUNET_h2s (&(msg->hash)));
519
520 room = get_service_room (messenger, &(msg->key));
521
522 if (! room)
523 {
524 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Room not found: %s\n", GNUNET_h2s (
525 &(msg->key)));
526 goto end_handling;
527 }
528
529 {
530 struct GNUNET_MESSENGER_MemberStore *member_store;
531 member_store = get_srv_room_member_store (room);
532
533 member_id = get_srv_handle_member_id (msg_client->handle,
534 &(msg->key));
535
536 member = get_store_member (member_store, member_id);
537 }
538
539 if (! member)
540 {
542 "Member not valid to request a message! (%s)\n",
543 GNUNET_sh2s (member_id));
544 goto end_handling;
545 }
546
547 pubkey = get_srv_handle_key (msg_client->handle);
548
549 if (! pubkey)
550 {
552 "Handle needs to have a public key to request a message! (%s)\n",
553 GNUNET_sh2s (member_id));
554 goto end_handling;
555 }
556
557 session = get_member_session (member, pubkey);
558
559 if (! session)
560 {
562 "Session not valid to request a message! (%s)\n",
563 GNUNET_sh2s (member_id));
564 goto end_handling;
565 }
566
568 msg_client);
569
570end_handling:
572}
573
574
575static void*
577 struct GNUNET_SERVICE_Client *client,
578 struct GNUNET_MQ_Handle *mq)
579{
580 struct GNUNET_MESSENGER_Client *msg_client;
581
582 GNUNET_assert ((client) && (mq));
583
584 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New client connected to service!\n");
585
586 msg_client = GNUNET_new (struct GNUNET_MESSENGER_Client);
587
588 msg_client->client = client;
589 msg_client->handle = add_service_handle (messenger, mq);
590
591 return msg_client;
592}
593
594
595static void
598 void *internal_cls)
599{
600 struct GNUNET_MESSENGER_Client *msg_client;
601
602 GNUNET_assert (internal_cls);
603
604 msg_client = internal_cls;
605
607
608 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client disconnected from service!\n");
609
610 GNUNET_free (msg_client);
611}
612
613
621static void
622run (void *cls,
625{
627
629
630 if (! messenger)
632}
633
634
642 &run,
645 NULL,
648 struct
652 struct
655 struct GNUNET_MESSENGER_RoomMessage, NULL),
657 struct GNUNET_MESSENGER_RoomMessage, NULL),
659 struct GNUNET_MESSENGER_RoomMessage, NULL),
663 GNUNET_MQ_hd_fixed_size (get_message,
665 struct
668 struct GNUNET_MESSENGER_RoomMessage, NULL),
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct MHD_Response * response
Our canonical response.
struct GNUNET_HashCode key
The key used in the DHT.
static int create
Create DID Document Flag.
Definition: gnunet-did.c:68
const struct GNUNET_CONFIGURATION_Handle * config
static struct GNUNET_CRYPTO_PublicKey pubkey
Public key of the zone to look in.
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
static void handle_create(void *cls, const struct GNUNET_MESSENGER_CreateMessage *msg)
static void handle_destroy(void *cls, const struct GNUNET_MESSENGER_DestroyMessage *msg)
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *config, struct GNUNET_SERVICE_Handle *service)
Setup MESSENGER internals.
static void handle_room_close(void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
static void handle_send_message(void *cls, const struct GNUNET_MESSENGER_SendMessage *msg)
static void handle_room_open(void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
static void handle_room_entry(void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
static void callback_client_disconnect(void *cls, struct GNUNET_SERVICE_Client *client, void *internal_cls)
static void initialize_handle_via_key(struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_RoomMessage *msg)
static void handle_room_sync(void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
GNUNET_SERVICE_MAIN(GNUNET_OS_project_data_gnunet(), GNUNET_MESSENGER_SERVICE_NAME, GNUNET_SERVICE_OPTION_NONE, &run, &callback_client_connect, &callback_client_disconnect, NULL, GNUNET_MQ_hd_fixed_size(create, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_CREATE, struct GNUNET_MESSENGER_CreateMessage, NULL), GNUNET_MQ_hd_fixed_size(destroy, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_DESTROY, struct GNUNET_MESSENGER_DestroyMessage, NULL), GNUNET_MQ_hd_var_size(room_open, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN, struct GNUNET_MESSENGER_RoomMessage, NULL), GNUNET_MQ_hd_var_size(room_entry, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY, struct GNUNET_MESSENGER_RoomMessage, NULL), GNUNET_MQ_hd_fixed_size(room_close, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE, struct GNUNET_MESSENGER_RoomMessage, NULL), GNUNET_MQ_hd_var_size(send_message, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SEND_MESSAGE, struct GNUNET_MESSENGER_SendMessage, NULL), GNUNET_MQ_hd_fixed_size(get_message, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_GET_MESSAGE, struct GNUNET_MESSENGER_GetMessage, NULL), GNUNET_MQ_hd_fixed_size(room_sync, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SYNC, struct GNUNET_MESSENGER_RoomMessage, NULL), GNUNET_MQ_handler_end())
Define "main" method using service macro.
struct GNUNET_MESSENGER_Service * messenger
static void handle_get_message(void *cls, const struct GNUNET_MESSENGER_GetMessage *msg)
static void callback_found_message(void *cls, struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
static void * callback_client_connect(void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
static enum GNUNET_GenericReturnValue check_room_open(void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
static enum GNUNET_GenericReturnValue check_send_message(void *cls, const struct GNUNET_MESSENGER_SendMessage *msg)
static enum GNUNET_GenericReturnValue check_room_entry(void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
static enum GNUNET_GenericReturnValue check_room_initial_key(const struct GNUNET_MESSENGER_RoomMessage *msg)
void notify_srv_handle_message(struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_SenderSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, const struct GNUNET_HashCode *epoch, enum GNUNET_GenericReturnValue recent)
Notifies the handle that a new message was received or sent.
void set_srv_handle_key(struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_CRYPTO_PublicKey *key)
Sets the public key of a given handle.
void sync_srv_handle_messages(struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, const struct GNUNET_HashCode *prev, struct GNUNET_HashCode *hash, struct GNUNET_HashCode *epoch)
Returns the latest merged hash from a room of a given handle using a specific key and the handles own...
enum GNUNET_GenericReturnValue close_srv_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 se...
enum GNUNET_GenericReturnValue send_srv_handle_message(struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, const struct GNUNET_MESSENGER_Message *message)
Sends a message from a given handle to the room using a specific key.
enum GNUNET_GenericReturnValue entry_srv_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 t...
const struct GNUNET_CRYPTO_PublicKey * get_srv_handle_key(const struct GNUNET_MESSENGER_SrvHandle *handle)
Returns the public key of a given handle.
const struct GNUNET_ShortHashCode * get_srv_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.
enum GNUNET_GenericReturnValue open_srv_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 se...
struct GNUNET_MESSENGER_MemberSession * get_member_session_of(struct GNUNET_MESSENGER_Member *member, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Returns the member session of a member using a public key which can verify the signature of a given m...
struct GNUNET_MESSENGER_MemberSession * get_member_session(const struct GNUNET_MESSENGER_Member *member, const struct GNUNET_CRYPTO_PublicKey *public_key)
Returns the member session of a member identified by a given public key.
struct GNUNET_MESSENGER_Member * get_store_member_of(struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_MESSENGER_Message *message)
Returns the member of a store using a sender id of a given message.
struct GNUNET_MESSENGER_Member * get_store_member(const struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_ShortHashCode *id)
Returns the member in a store identified by a given id.
const struct GNUNET_HashCode * get_store_message_epoch(const struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash)
Returns the epoch hash of a message from a message store matching a given hash.
struct GNUNET_PeerIdentity * get_store_peer_of(struct GNUNET_MESSENGER_PeerStore *store, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Returns the peer identity inside the store which verifies the signature of a given message as valid.
struct GNUNET_MESSENGER_MessageStore * get_srv_room_message_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used message store of a given room.
struct GNUNET_MESSENGER_PeerStore * get_srv_room_peer_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used peer store of a given room.
enum GNUNET_GenericReturnValue request_srv_room_message(struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_MemberSession *session, GNUNET_MESSENGER_MessageRequestCallback callback, void *cls)
Requests a message from a room identified by a given hash.
struct GNUNET_MESSENGER_MemberStore * get_srv_room_member_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used member store of a given room.
void remove_service_handle(struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle)
Removes a handle from a service and destroys it.
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, const struct GNUNET_HashCode *epoch, enum GNUNET_GenericReturnValue recent)
Sends a received or sent message with a given hash to each handle of a service which is currently mem...
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.
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.
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.
static void send_message(struct PeerContext *peer_ctx, struct GNUNET_MQ_Envelope *ev, const char *type)
Send a message to another peer.
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition: gnunet-vpn.c:35
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_public_key_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_PublicKey *key, size_t *read)
Reads a GNUNET_CRYPTO_PublicKey from a compact buffer.
Definition: crypto_pkey.c:102
GNUNET_GenericReturnValue
Named constants for return values.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
const char * GNUNET_MESSENGER_name_of_kind(enum GNUNET_MESSENGER_MessageKind kind)
Get the name of a message kind.
Definition: messenger_api.c:46
#define GNUNET_MESSENGER_SERVICE_NAME
Identifier of GNUnet MESSENGER Service.
@ GNUNET_MESSENGER_KIND_UNKNOWN
The unknown kind.
@ GNUNET_MESSENGER_KIND_GROUP
The group kind.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:305
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:76
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SEND_MESSAGE
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_CREATE
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SYNC
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_GET_MESSAGE
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_DESTROY
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:567
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2462
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2433
@ GNUNET_SERVICE_OPTION_NONE
Use defaults.
enum GNUNET_GenericReturnValue filter_message_sending(const struct GNUNET_MESSENGER_Message *message)
Returns whether a specific kind of message should be sent by a client.
enum GNUNET_GenericReturnValue is_peer_message(const struct GNUNET_MESSENGER_Message *message)
Returns whether a specific kind of message can be sent by the service without usage of a clients priv...
uint16_t get_message_kind_size(enum GNUNET_MESSENGER_MessageKind kind, enum GNUNET_GenericReturnValue include_header)
Returns the minimal size in bytes to encode a message of a specific kind.
enum GNUNET_GenericReturnValue decode_message(struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer, enum GNUNET_GenericReturnValue include_header, uint16_t *padding)
Decodes a message from a given buffer of a maximal length in bytes.
void cleanup_message(struct GNUNET_MESSENGER_Message *message)
Frees the messages body memory.
static void destroy(void *cls)
Function to destroy a microphone.
Definition: microphone.c:155
An identity key as per LSD0001.
A 512-bit hashcode.
struct GNUNET_SERVICE_Client * client
struct GNUNET_MESSENGER_SrvHandle * handle
Message to create a handle for a client.
Message to destroy the handle for a client.
Message to request something from a room.
struct GNUNET_MESSENGER_MemberStore * store
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
struct GNUNET_ShortHashCode sender_id
The senders id inside of the room the message was sent in.
struct GNUNET_MESSENGER_MessageHeader header
Header.
General message to confirm interaction with a room.
Message to send something into a room.
struct GNUNET_MESSENGER_MemberSession * member
enum GNUNET_GenericReturnValue local_request
enum GNUNET_GenericReturnValue group_keys
struct GNUNET_MESSENGER_Service * service
struct GNUNET_MQ_Envelope * prev
Messages are stored in a linked list Each queue has its own list of envelopes.
Definition: mq.c:45
Handle to a message queue.
Definition: mq.c:87
Handle to a client that is connected to a service.
Definition: service.c:249
Handle to a service.
Definition: service.c:116
A 256-bit hashcode.