GNUnet 0.21.0
messenger_api_room.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2020--2024 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 */
26#include "messenger_api_room.h"
27
28#include "gnunet_common.h"
33#include <string.h>
34
37 const struct GNUNET_HashCode *key)
38{
39 GNUNET_assert ((handle) && (key));
40
41 struct GNUNET_MESSENGER_Room *room = GNUNET_new (struct
43
44 room->handle = handle;
45 GNUNET_memcpy (&(room->key), key, sizeof(*key));
46
47 memset (&(room->last_message), 0, sizeof(room->last_message));
48
49 room->opened = GNUNET_NO;
52
53 room->sender_id = NULL;
54
55 init_list_tunnels (&(room->entries));
56
60
61 init_queue_messages (&(room->queue));
62
63 return room;
64}
65
66
69 const struct GNUNET_HashCode *key,
70 void *value)
71{
73
74 destroy_message (entry->message);
75 GNUNET_free (entry);
76
77 return GNUNET_YES;
78}
79
80
83 const struct GNUNET_HashCode *key,
84 void *value)
85{
86 struct GNUNET_HashCode *hash = value;
87 GNUNET_free (hash);
88 return GNUNET_YES;
89}
90
91
92void
94{
95 GNUNET_assert (room);
96
97 clear_queue_messages (&(room->queue));
98 clear_list_tunnels (&(room->entries));
99
100 if (room->messages)
101 {
104
106 }
107
108 if (room->members)
110
111 if (room->links)
112 {
115
117 }
118
119 if (room->sender_id)
120 GNUNET_free (room->sender_id);
121
122 GNUNET_free (room);
123}
124
125
128{
129 GNUNET_assert (room);
130
131 if (! get_room_sender_id (room))
132 return GNUNET_NO;
133
134 if ((GNUNET_YES == room->opened) || (room->entries.head))
135 return GNUNET_YES;
136 else
137 return GNUNET_NO;
138}
139
140
141const struct GNUNET_ShortHashCode*
143{
144 GNUNET_assert (room);
145
146 return room->sender_id;
147}
148
149
150void
152 const struct GNUNET_ShortHashCode *id)
153{
154 GNUNET_assert (room);
155
156 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Set member id for room: %s\n",
157 GNUNET_h2s (&(room->key)));
158
159 if (! id)
160 {
161 if (room->sender_id)
162 GNUNET_free (room->sender_id);
163
164 room->sender_id = NULL;
165 return;
166 }
167
168 if (! room->sender_id)
170
171 GNUNET_memcpy (room->sender_id, id, sizeof(struct GNUNET_ShortHashCode));
172}
173
174
175const struct GNUNET_MESSENGER_Message*
177 const struct GNUNET_HashCode *hash)
178{
179 GNUNET_assert ((room) && (hash));
180
183 room->messages, hash);
184
185 if ((! entry) || (GNUNET_YES != entry->completed))
186 return NULL;
187
188 return entry->message;
189}
190
191
194 const struct GNUNET_HashCode *hash)
195{
196 GNUNET_assert ((room) && (hash));
197
200 room->messages, hash);
201
202 if ((! entry) || (GNUNET_YES != entry->completed))
203 return NULL;
204
205 return entry->sender;
206}
207
208
211 const struct GNUNET_HashCode *hash)
212{
213 GNUNET_assert ((room) && (hash));
214
217 room->messages, hash);
218
219 if ((! entry) || (GNUNET_YES != entry->completed))
220 return NULL;
221
222 return entry->recipient;
223}
224
225
226void
228 const struct GNUNET_HashCode *hash)
229{
230 GNUNET_assert ((room) && (hash));
231
232 struct GNUNET_MESSENGER_Handle *handle = room->handle;
233
234 if (! handle)
235 return;
236
238 entry = GNUNET_CONTAINER_multihashmap_get (room->messages, hash);
239
240 if (! entry)
241 return;
242
243 if (handle->msg_callback)
244 handle->msg_callback (handle->msg_cls, room,
245 entry->sender,
246 entry->recipient,
247 entry->message,
248 hash,
249 entry->flags);
250
253}
254
255
256static void
258 const struct GNUNET_HashCode *hash,
260
261
262void
264 const struct GNUNET_HashCode *hash,
266{
267 GNUNET_assert ((room) && (hash) && (entry));
268
269 if (! entry->sender)
270 {
272 room->handle);
274
275 get_context_from_member (&(room->key), &(entry->message->header.sender_id),
276 &context);
277
278 entry->sender = get_store_contact (store, &context,
279 &(entry->message->body.join.key));
280 }
281
283 room->members, &(entry->message->header.sender_id), entry->sender)) &&
285 &(entry->message->header
286 .sender_id),
287 entry->sender,
290}
291
292
293static void
295 const struct GNUNET_HashCode *hash,
297{
298 GNUNET_assert ((room) && (hash) && (entry));
299
300 if ((! entry->sender) ||
302 &(entry->message->
303 header.sender_id),
304 entry->sender)))
305 return;
306
307 if (GNUNET_YES == decrease_contact_rc (entry->sender))
309 "A contact does not share any room with you anymore!\n");
310}
311
312
313static void
315 const struct GNUNET_HashCode *hash,
317{
318 GNUNET_assert ((room) && (hash) && (entry));
319
321 {
323 "Set rule for using handle name in room: %s\n",
324 GNUNET_h2s (&(room->key)));
325
326 const char *handle_name = get_handle_name (room->handle);
327
328 if ((handle_name) && (0 == strcmp (handle_name,
329 entry->message->body.name.name)))
331 }
332
333 if (! entry->sender)
334 return;
335
336 set_contact_name (entry->sender, entry->message->body.name.name);
337}
338
339
340static void
342 const struct GNUNET_HashCode *hash,
344{
345 GNUNET_assert ((room) && (hash) && (entry));
346
347 if (! entry->sender)
348 return;
349
351 get_context_from_member (&(room->key), &(entry->message->header.sender_id),
352 &context);
353
355 room->handle);
356
357 update_store_contact (store, entry->sender, &context, &context,
358 &(entry->message->body.key.key));
359}
360
361
362static void
364 const struct GNUNET_HashCode *hash,
366{
367 GNUNET_assert ((room) && (hash) && (entry));
368
370 set_room_sender_id (room, &(entry->message->body.id.id));
371
372 if ((! entry->sender) ||
374 &(entry->message->
375 header.sender_id),
376 entry->sender)) ||
378 &(entry->message->body.
379 id.id),
380 entry->sender,
382 return;
383
384 struct GNUNET_HashCode context, next_context;
385 get_context_from_member (&(room->key), &(entry->message->header.sender_id),
386 &context);
387 get_context_from_member (&(room->key), &(entry->message->body.id.id),
388 &next_context);
389
391 room->handle);
392
393 update_store_contact (store, entry->sender, &context, &next_context,
394 get_contact_key (entry->sender));
395}
396
397
398static void
400 const struct GNUNET_HashCode *hash,
402{
403 GNUNET_assert ((room) && (hash) && (entry));
404
405 if (0 == (GNUNET_MESSENGER_FLAG_SENT & entry->flags))
406 return;
407
409 &(room->entries), &(entry->message->body.miss.peer), NULL);
410
411 if (match)
412 remove_from_list_tunnels (&(room->entries), match);
413}
414
415
416static void
418 const struct GNUNET_HashCode *hash,
420{
421 GNUNET_assert ((room) && (hash) && (entry));
422
423 struct GNUNET_MESSENGER_Message *private_message = copy_message (
424 entry->message);
425
426 if (! private_message)
427 return;
428
429 if (GNUNET_YES != decrypt_message (private_message,
430 get_handle_key (room->handle)))
431 {
432 destroy_message (private_message);
433 private_message = NULL;
434 }
435
436 if (! private_message)
437 return;
438
439 destroy_message (entry->message);
440
441 entry->recipient = get_handle_contact (room->handle, &(room->key));
442
443 entry->message = private_message;
445
446 if ((entry->sender) && (entry->recipient))
447 handle_message (room, hash, entry);
448}
449
450
451extern void
453 const struct GNUNET_HashCode *hash,
454 const struct GNUNET_TIME_Relative delay);
455
456
457static void
459 const struct GNUNET_HashCode *hash,
461{
462 GNUNET_assert ((room) && (hash) && (entry));
463
464 const struct GNUNET_HashCode *target_hash =
465 &(entry->message->body.deletion.hash);
466
467 if (get_handle_contact (room->handle, &(room->key)) == entry->sender)
468 {
469 struct GNUNET_TIME_Relative delay;
471
473
476
478 action);
479
480 link_room_deletion (room, target_hash, delay, delete_message_in_room);
481 }
482
483 struct GNUNET_MESSENGER_RoomMessageEntry *target =
484 GNUNET_CONTAINER_multihashmap_get (room->messages, target_hash);
485
486 if (! target)
487 return;
488
489 if (((target->sender != entry->sender) &&
490 (get_handle_contact (room->handle, &(room->key)) != entry->sender)))
491 return;
492
494 callback_room_message (room, target_hash);
495
497 target_hash,
498 target))
499 {
500 destroy_message (target->message);
501 GNUNET_free (target);
502 }
503}
504
505
506static void
508 const struct GNUNET_HashCode *hash,
510{
511 GNUNET_assert ((room) && (hash) && (entry));
512
513 if (get_handle_contact (room->handle, &(room->key)) != entry->sender)
514 return;
515
516 const struct GNUNET_HashCode *original_hash =
517 &(entry->message->body.transcript.hash);
519 room->handle);
520
521 struct GNUNET_MESSENGER_RoomMessageEntry *original =
522 GNUNET_CONTAINER_multihashmap_get (room->messages, original_hash);
523 struct GNUNET_MESSENGER_Message *original_message;
524
525 if (original)
526 goto read_transcript;
527
529
530 if (! original)
531 return;
532
533 original->sender = NULL;
534 original->recipient = NULL;
535
536 original->message = NULL;
538 original->completed = GNUNET_NO;
539
541 original_hash,
542 original,
544 {
545 GNUNET_free (original);
546 return;
547 }
548
549read_transcript:
550 original_message = copy_message (entry->message);
551
552 if (! original_message)
553 return;
554
555 if (GNUNET_YES != read_transcript_message (original_message))
556 {
557 destroy_message (original_message);
558 return;
559 }
560
561 original->recipient = get_store_contact (store,
562 NULL,
563 &(entry->message->body.transcript.key));
564
565 if (original->message)
566 {
569
570 copy_message_header (original_message, &(original->message->header));
571 destroy_message (original->message);
572 }
573
574 original->message = original_message;
575
576 link_room_message (room, hash, original_hash);
577 link_room_message (room, original_hash, hash);
578
579 if ((original->sender) && (original->recipient))
580 {
582 handle_message (room, original_hash, original);
583 }
584}
585
586
587static void
589 const struct GNUNET_HashCode *hash,
591{
592 GNUNET_assert ((room) && (hash) && (entry));
593
594 switch (entry->message->header.kind)
595 {
597 handle_join_message (room, hash, entry);
598 break;
600 handle_leave_message (room, hash, entry);
601 break;
603 handle_name_message (room, hash, entry);
604 break;
606 handle_key_message (room, hash, entry);
607 break;
609 handle_id_message (room, hash, entry);
610 break;
612 handle_miss_message (room, hash, entry);
613 break;
615 handle_private_message (room, hash, entry);
616 break;
618 handle_delete_message (room, hash, entry);
619 break;
621 handle_transcript_message (room, hash, entry);
622 break;
623 default:
624 break;
625 }
626
628 callback_room_message (room, hash);
629}
630
631
632void
634 struct GNUNET_MESSENGER_Contact *sender,
635 const struct GNUNET_MESSENGER_Message *message,
636 const struct GNUNET_HashCode *hash,
638{
639 GNUNET_assert ((room) && (message) && (hash));
640
642 entry = GNUNET_CONTAINER_multihashmap_get (room->messages, hash);
643
644 if (entry)
645 goto update_entry;
646
648
649 if (! entry)
650 return;
651
652 entry->sender = NULL;
653 entry->recipient = NULL;
654
655 entry->message = NULL;
657 entry->completed = GNUNET_NO;
658
660 entry,
662 {
663 GNUNET_free (entry);
664 return;
665 }
666
667update_entry:
668 entry->sender = sender;
669 entry->flags = flags;
670
671 if (entry->message)
672 {
675
677 }
678 else
679 entry->message = copy_message (message);
680
681 entry->completed = GNUNET_YES;
682
683 handle_message (room, hash, entry);
684}
685
686
687void
689 const struct GNUNET_HashCode *hash)
690{
691 GNUNET_assert ((room) && (hash));
692
693 GNUNET_memcpy (&(room->last_message), hash, sizeof(room->last_message));
694}
695
696
698{
701 void *cls;
702};
703
706 const struct GNUNET_ShortHashCode *key,
707 void *value)
708{
710 struct GNUNET_MESSENGER_Contact *contact = value;
711
712 return call->callback (call->cls, call->room, contact);
713}
714
715
716int
719 void *cls)
720{
721 GNUNET_assert (room);
722
723 if (! callback)
724 return GNUNET_CONTAINER_multishortmap_iterate (room->members, NULL, NULL);
725
727
728 call.room = room;
729 call.callback = callback;
730 call.cls = cls;
731
733
736 &call);
737}
738
739
741{
744};
745
748 const struct GNUNET_ShortHashCode *key,
749 void *value)
750{
751 struct GNUNET_MESSENGER_MemberFind *find = cls;
752 struct GNUNET_MESSENGER_Contact *contact = value;
753
754 if (contact == find->contact)
755 {
756 find->result = GNUNET_YES;
757 return GNUNET_NO;
758 }
759
760 return GNUNET_YES;
761}
762
763
766 const struct GNUNET_MESSENGER_Contact *contact)
767{
768 GNUNET_assert (room);
769
770 struct GNUNET_MESSENGER_MemberFind find;
771
772 find.contact = contact;
773 find.result = GNUNET_NO;
774
776 &find);
777
778 return find.result;
779}
780
781
784 const struct GNUNET_HashCode *key,
785 void *value)
786{
787 const struct GNUNET_HashCode **result = cls;
788 struct GNUNET_HashCode *hash = value;
789
790 if (0 == GNUNET_CRYPTO_hash_cmp (hash, *result))
791 {
792 *result = NULL;
793 return GNUNET_NO;
794 }
795
796 return GNUNET_YES;
797}
798
799
800void
802 const struct GNUNET_HashCode *hash,
803 const struct GNUNET_HashCode *other)
804{
805 GNUNET_assert ((room) && (hash) && (other));
806
807 const struct GNUNET_HashCode **result = &other;
810
811 if (! *result)
812 return;
813
814 struct GNUNET_HashCode *value = GNUNET_memdup (other, sizeof(struct
816 if (! value)
817 return;
818
822}
823
824
826{
830};
831
832
835 const struct GNUNET_HashCode *key,
836 void *value)
837{
838 struct GNUNET_HashCode **linked = cls;
839 struct GNUNET_HashCode *hash = value;
840
841 if (0 != GNUNET_CRYPTO_hash_cmp (*linked, hash))
842 return GNUNET_YES;
843
844 *linked = hash;
845 return GNUNET_NO;
846}
847
848
851 const struct GNUNET_HashCode *key,
852 void *value)
853{
855 struct GNUNET_HashCode *hash = value;
856
857 struct GNUNET_HashCode key_value;
858 GNUNET_memcpy (&key_value, key, sizeof (key_value));
859
860 struct GNUNET_HashCode *linked = &key_value;
861
863 clear_linked_hash, &linked);
864
865 if ((linked != &key_value) &&
867 hash, linked)))
868 GNUNET_free (linked);
869
870 if (info->deletion)
871 info->deletion (info->room, hash, info->delay);
872
873 GNUNET_free (hash);
874 return GNUNET_YES;
875}
876
877
878void
880 const struct GNUNET_HashCode *hash,
881 const struct GNUNET_TIME_Relative delay,
883{
884 GNUNET_assert ((room) && (hash));
885
887 info.room = room;
888 info.delay = delay;
889 info.deletion = deletion;
890
894}
static struct GNUNET_CONVERSATION_Call * call
Call handle (for active outgoing call).
struct GNUNET_HashCode key
The key used in the DHT.
static pa_context * context
Pulseaudio context.
static char * value
Value of the record to add/remove.
static int result
Global testing status.
#define info
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition: gnunet-vpn.c:35
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
int GNUNET_CRYPTO_hash_cmp(const struct GNUNET_HashCode *h1, const struct GNUNET_HashCode *h2)
Compare function for HashCodes, producing a total ordering of all hashcodes.
Definition: crypto_hash.c:221
int GNUNET_CONTAINER_multihashmap_remove_all(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Remove all entries for the given key from the map.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
struct GNUNET_CONTAINER_MultiShortmap * GNUNET_CONTAINER_multishortmap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multishortmap_put(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
int GNUNET_CONTAINER_multishortmap_iterate(struct GNUNET_CONTAINER_MultiShortmap *map, GNUNET_CONTAINER_ShortmapIterator it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
int GNUNET_CONTAINER_multishortmap_contains_value(const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, const void *value)
Check if the map contains the given value under the given key.
void GNUNET_CONTAINER_multishortmap_destroy(struct GNUNET_CONTAINER_MultiShortmap *map)
Destroy a hash map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
int GNUNET_CONTAINER_multishortmap_remove(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, const void *value)
Remove the given key-value pair from the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE...
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
GNUNET_GenericReturnValue
Named constants for return values.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_memdup(buf, size)
Allocate and initialize a block of memory.
GNUNET_MESSENGER_MessageFlags
Enum for the different supported flags used by message handling.
enum GNUNET_GenericReturnValue(* GNUNET_MESSENGER_MemberCallback)(void *cls, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *contact)
Method called for each member in a room during iteration.
@ GNUNET_MESSENGER_KIND_MISS
The miss kind.
@ GNUNET_MESSENGER_KIND_PRIVATE
The private kind.
@ GNUNET_MESSENGER_KIND_NAME
The name kind.
@ GNUNET_MESSENGER_KIND_LEAVE
The leave kind.
@ GNUNET_MESSENGER_KIND_TRANSCRIPT
The transcript kind.
@ GNUNET_MESSENGER_KIND_KEY
The key kind.
@ GNUNET_MESSENGER_KIND_JOIN
The join kind.
@ GNUNET_MESSENGER_KIND_DELETE
The delete kind.
@ GNUNET_MESSENGER_KIND_ID
The id kind.
@ GNUNET_MESSENGER_FLAG_PRIVATE
The private flag.
@ GNUNET_MESSENGER_FLAG_SENT
The sent flag.
@ GNUNET_MESSENGER_FLAG_UPDATE
The update flag.
@ GNUNET_MESSENGER_FLAG_NONE
The none flag.
@ GNUNET_MESSENGER_FLAG_DELETE
The delete flag.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh(struct GNUNET_TIME_RelativeNBO a)
Convert relative time from network byte order.
Definition: time.c:628
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:111
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:737
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_add(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration)
Add a given relative duration to the given start time.
Definition: time.c:450
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_difference(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Absolute end)
Compute the time difference between the given start and end times.
Definition: time.c:421
enum GNUNET_GenericReturnValue decrease_contact_rc(struct GNUNET_MESSENGER_Contact *contact)
Decreases the reference counter if possible (can not underflow!) of a given contact and returns GNUNE...
const struct GNUNET_CRYPTO_PublicKey * get_contact_key(const struct GNUNET_MESSENGER_Contact *contact)
Returns the public key of a given contact.
void set_contact_name(struct GNUNET_MESSENGER_Contact *contact, const char *name)
Changes the current name of a given contact by copying it from the parameter name.
void increase_contact_rc(struct GNUNET_MESSENGER_Contact *contact)
Increases the reference counter of a given contact which is zero as default.
void get_context_from_member(const struct GNUNET_HashCode *key, const struct GNUNET_ShortHashCode *id, struct GNUNET_HashCode *context)
Calculates the context hash of a member in a room and returns it.
void update_store_contact(struct GNUNET_MESSENGER_ContactStore *store, struct GNUNET_MESSENGER_Contact *contact, const struct GNUNET_HashCode *context, const struct GNUNET_HashCode *next_context, const struct GNUNET_CRYPTO_PublicKey *pubkey)
Moves a contact from the store to another location matching a given public key and member context.
struct GNUNET_MESSENGER_Contact * get_store_contact(struct GNUNET_MESSENGER_ContactStore *store, const struct GNUNET_HashCode *context, const struct GNUNET_CRYPTO_PublicKey *pubkey)
Returns a contact using a specific public key.
struct GNUNET_MESSENGER_ContactStore * get_handle_contact_store(struct GNUNET_MESSENGER_Handle *handle)
Returns the used contact store of a given handle.
struct GNUNET_MESSENGER_Contact * get_handle_contact(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key)
Returns the contact of a given handle in a room identified by a given key.
const char * get_handle_name(const struct GNUNET_MESSENGER_Handle *handle)
Returns the current name of a given handle or NULL if no valid name was assigned yet.
const struct GNUNET_CRYPTO_PrivateKey * get_handle_key(const struct GNUNET_MESSENGER_Handle *handle)
Returns the private key of a given handle.
void init_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels)
Initializes list of tunnels peer identities as empty list.
struct GNUNET_MESSENGER_ListTunnel * find_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer, size_t *index)
Searches linearly through the list of tunnels peer identities for matching a specific peer identity a...
void clear_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels)
Clears the list of tunnels peer identities.
struct GNUNET_MESSENGER_ListTunnel * remove_from_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels, struct GNUNET_MESSENGER_ListTunnel *element)
Removes a specific element from the list of tunnels peer identities and returns the next element in t...
struct GNUNET_MESSENGER_Message * copy_message(const struct GNUNET_MESSENGER_Message *message)
Creates and allocates a copy of a given message.
enum GNUNET_GenericReturnValue decrypt_message(struct GNUNET_MESSENGER_Message *message, const struct GNUNET_CRYPTO_PrivateKey *key)
Decrypts a private message using a given private key and replaces its body and kind with the inner en...
void copy_message_header(struct GNUNET_MESSENGER_Message *message, const struct GNUNET_MESSENGER_MessageHeader *header)
Copy message header details from another message to a given message.
void destroy_message(struct GNUNET_MESSENGER_Message *message)
Destroys a message and frees its memory fully.
enum GNUNET_GenericReturnValue read_transcript_message(struct GNUNET_MESSENGER_Message *message)
Read the original message from a transcript message and replaces its body and kind with the inner enc...
void init_queue_messages(struct GNUNET_MESSENGER_QueueMessages *messages)
Initializes queue of messages as empty queue.
void clear_queue_messages(struct GNUNET_MESSENGER_QueueMessages *messages)
Clears the queue of messages.
static void handle_name_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static void handle_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
enum GNUNET_GenericReturnValue find_room_member(const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *contact)
Checks through all members of a given room if a specific contact is found and returns a result depend...
static enum GNUNET_GenericReturnValue delete_linked_hash(void *cls, const struct GNUNET_HashCode *key, void *value)
static void handle_id_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
struct GNUNET_MESSENGER_Contact * get_room_sender(const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Returns a messages sender locally stored from a map for a given hash in a room.
void set_room_sender_id(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_ShortHashCode *id)
Sets the member id of the room's sender to a specific id or NULL.
void handle_room_message(struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, enum GNUNET_MESSENGER_MessageFlags flags)
Handles a message with a given hash in a room for the client API to update members and its informatio...
void link_room_deletion(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay, GNUNET_MESSENGER_RoomLinkDeletion deletion)
Delete all remaining links to a certain message identified by its hash inside a given room and cause ...
const struct GNUNET_MESSENGER_Message * get_room_message(const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Returns a message locally stored from a map for a given hash in a room.
void update_room_last_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Updates the last message hash of a room for the client API so that new messages can point to the late...
static void handle_private_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static enum GNUNET_GenericReturnValue iterate_find_member(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
enum GNUNET_GenericReturnValue is_room_available(const struct GNUNET_MESSENGER_Room *room)
Checks whether a room is available to send messages.
void callback_room_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Executes the message callback for a given hash in a room.
void delete_message_in_room(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)
static void handle_leave_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static void handle_miss_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static void handle_transcript_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static enum GNUNET_GenericReturnValue iterate_destroy_link(void *cls, const struct GNUNET_HashCode *key, void *value)
static void handle_key_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static void handle_delete_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static enum GNUNET_GenericReturnValue iterate_destroy_message(void *cls, const struct GNUNET_HashCode *key, void *value)
const struct GNUNET_ShortHashCode * get_room_sender_id(const struct GNUNET_MESSENGER_Room *room)
Returns the member id of the room's sender.
static enum GNUNET_GenericReturnValue clear_linked_hash(void *cls, const struct GNUNET_HashCode *key, void *value)
static enum GNUNET_GenericReturnValue iterate_local_members(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
void link_room_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_HashCode *other)
Links a message identified by its hash inside a given room with another message identified by its oth...
void handle_join_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
int iterate_room_members(struct GNUNET_MESSENGER_Room *room, GNUNET_MESSENGER_MemberCallback callback, void *cls)
Iterates through all members of a given room to forward each of them to a selected callback with a cu...
void destroy_room(struct GNUNET_MESSENGER_Room *room)
Destroys a room and frees its memory fully from the client API.
static enum GNUNET_GenericReturnValue find_linked_hash(void *cls, const struct GNUNET_HashCode *key, void *value)
struct GNUNET_MESSENGER_Contact * get_room_recipient(const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Returns a messages recipient locally stored from a map for a given hash in a room.
struct GNUNET_MESSENGER_Room * create_room(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key)
Creates and allocates a new room for a handle with a given key for the client API.
void(* GNUNET_MESSENGER_RoomLinkDeletion)(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)
A 512-bit hashcode.
struct GNUNET_MESSENGER_ListTunnel * head
GNUNET_MESSENGER_MemberCallback callback
struct GNUNET_MESSENGER_Room * room
const struct GNUNET_MESSENGER_Contact * contact
enum GNUNET_GenericReturnValue result
struct GNUNET_MESSENGER_MessageId id
struct GNUNET_MESSENGER_MessageName name
struct GNUNET_MESSENGER_MessageTranscript transcript
struct GNUNET_MESSENGER_MessageKey key
struct GNUNET_MESSENGER_MessageMiss miss
struct GNUNET_MESSENGER_MessageJoin join
struct GNUNET_MESSENGER_MessageDelete deletion
struct GNUNET_HashCode hash
The hash of the message to delete.
struct GNUNET_TIME_RelativeNBO delay
The delay of the delete operation to get processed.
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
struct GNUNET_TIME_AbsoluteNBO timestamp
The timestamp of the message.
struct GNUNET_ShortHashCode sender_id
The senders id inside of the room the message was sent in.
struct GNUNET_ShortHashCode id
The new id which will replace the senders id in a room.
struct GNUNET_CRYPTO_PublicKey key
The senders public key to verify its signatures.
struct GNUNET_CRYPTO_PublicKey key
The new public key which replaces the current senders public key.
struct GNUNET_PeerIdentity peer
The peer identity of a disconnected door to a room.
char * name
The new name which replaces the current senders name.
struct GNUNET_HashCode hash
The hash of the original message.
struct GNUNET_CRYPTO_PublicKey key
The key from the recipient of the original message.
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_MESSENGER_MessageBody body
Body.
struct GNUNET_MESSENGER_Room * room
GNUNET_MESSENGER_RoomLinkDeletion deletion
struct GNUNET_MESSENGER_Contact * recipient
enum GNUNET_MESSENGER_MessageFlags flags
struct GNUNET_MESSENGER_Message * message
struct GNUNET_MESSENGER_Contact * sender
enum GNUNET_GenericReturnValue completed
struct GNUNET_CONTAINER_MultiHashMap * links
struct GNUNET_MESSENGER_Handle * handle
enum GNUNET_GenericReturnValue opened
enum GNUNET_GenericReturnValue wait_for_sync
struct GNUNET_CONTAINER_MultiShortmap * members
struct GNUNET_CONTAINER_MultiHashMap * messages
enum GNUNET_GenericReturnValue use_handle_name
struct GNUNET_MESSENGER_QueueMessages queue
struct GNUNET_MESSENGER_ListTunnels entries
struct GNUNET_ShortHashCode * sender_id
struct GNUNET_HashCode key
struct GNUNET_HashCode last_message
A 256-bit hashcode.
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.