GNUnet 0.22.2
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"
30
31#include "messenger_api.h"
37
38#include <string.h>
39
42 const struct GNUNET_HashCode *key)
43{
44 struct GNUNET_MESSENGER_Room *room;
45
46 GNUNET_assert ((handle) && (key));
47
48 room = GNUNET_new (struct GNUNET_MESSENGER_Room);
49 room->handle = handle;
50
51 GNUNET_memcpy (&(room->key), key, sizeof(*key));
52
53 memset (&(room->last_message), 0, sizeof(room->last_message));
54
55 room->opened = GNUNET_NO;
58
59 room->sender_id = NULL;
60
61 init_list_tunnels (&(room->entries));
62
66
68
69 init_queue_messages (&(room->queue));
70 room->queue_task = NULL;
71
72 room->control = create_message_control (room);
73
74 return room;
75}
76
77
80 const struct GNUNET_HashCode *key,
81 void *value)
82{
84
86
87 entry = value;
88
89 destroy_message (entry->message);
90 GNUNET_free (entry);
91 return GNUNET_YES;
92}
93
94
97 const struct GNUNET_HashCode *key,
98 void *value)
99{
100 struct GNUNET_HashCode *hash;
101
103
104 hash = value;
105
106 GNUNET_free (hash);
107 return GNUNET_YES;
108}
109
110
113 const struct GNUNET_ShortHashCode *key,
114 void *value)
115{
116 struct GNUNET_MESSENGER_RoomSubscription *subscription;
117
119
120 subscription = value;
121
122 if (subscription->task)
123 GNUNET_SCHEDULER_cancel (subscription->task);
124
125 if (subscription->message)
126 destroy_message (subscription->message);
127
128 GNUNET_free (subscription);
129 return GNUNET_YES;
130}
131
132
133void
135{
137
139
140 if (room->queue_task)
142
145
146 if (room->subscriptions)
147 {
150 NULL);
151
153 }
154
155 if (room->messages)
156 {
159
161 }
162
163 if (room->members)
165
166 if (room->links)
167 {
170
172 }
173
174 if (room->sender_id)
176
178}
179
180
183{
185
186 if (! get_room_sender_id (room))
187 return GNUNET_NO;
188
189 if ((GNUNET_YES == room->opened) || (room->entries.head))
190 return GNUNET_YES;
191 else
192 return GNUNET_NO;
193}
194
195
198{
199 GNUNET_assert (room);
200
201 return room->handle;
202}
203
204
205const struct GNUNET_ShortHashCode*
207{
208 GNUNET_assert (room);
209
210 return room->sender_id;
211}
212
213
214void
216 const struct GNUNET_ShortHashCode *id)
217{
218 GNUNET_assert (room);
219
220 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Set member id for room: %s\n",
221 GNUNET_h2s (&(room->key)));
222
223 if (! id)
224 {
225 if (room->sender_id)
226 GNUNET_free (room->sender_id);
227
228 room->sender_id = NULL;
229 return;
230 }
231
232 if (! room->sender_id)
234
235 GNUNET_memcpy (room->sender_id, id, sizeof(struct GNUNET_ShortHashCode));
236}
237
238
239const struct GNUNET_MESSENGER_Message*
241 const struct GNUNET_HashCode *hash)
242{
244
245 GNUNET_assert ((room) && (hash));
246
247 entry = GNUNET_CONTAINER_multihashmap_get (room->messages, hash);
248
249 if ((! entry) || (GNUNET_YES != entry->completed))
250 return NULL;
251
252 return entry->message;
253}
254
255
258 const struct GNUNET_HashCode *hash)
259{
261
262 GNUNET_assert ((room) && (hash));
263
264 entry = GNUNET_CONTAINER_multihashmap_get (room->messages, hash);
265
266 if ((! entry) || (GNUNET_YES != entry->completed))
267 return NULL;
268
269 return entry->sender;
270}
271
272
275 const struct GNUNET_HashCode *hash)
276{
278
279 GNUNET_assert ((room) && (hash));
280
281 entry = GNUNET_CONTAINER_multihashmap_get (room->messages, hash);
282
283 if ((! entry) || (GNUNET_YES != entry->completed))
284 return NULL;
285
286 return entry->recipient;
287}
288
289
290void
292 const struct GNUNET_HashCode *hash,
293 const struct GNUNET_TIME_Relative delay)
294{
295 struct GNUNET_MESSENGER_Message *message;
296
297 GNUNET_assert ((room) && (hash));
298
299 message = create_message_delete (hash, delay);
300
301 if (! message)
302 {
304 "Sending deletion aborted: Message creation failed!\n");
305 return;
306 }
307
308 enqueue_message_to_room (room, message, NULL);
309}
310
311
312void
314 const struct GNUNET_HashCode *hash)
315{
318
319 GNUNET_assert ((room) && (hash));
320
321 handle = room->handle;
322 if (! handle)
323 return;
324
325 entry = GNUNET_CONTAINER_multihashmap_get (room->messages, hash);
326 if (! entry)
327 return;
328
329 if (handle->msg_callback)
330 handle->msg_callback (handle->msg_cls, room,
331 entry->sender,
332 entry->recipient,
333 entry->message,
334 hash,
335 entry->flags);
336
339}
340
341
342static void
344 const struct GNUNET_HashCode *hash,
346
347
348static void
350 const struct GNUNET_HashCode *hash,
352{
353 GNUNET_assert ((room) && (hash) && (entry));
354
355 if (! entry->sender)
356 {
357 struct GNUNET_MESSENGER_ContactStore *store;
359
360 store = get_handle_contact_store (room->handle);
361
362 get_context_from_member (&(room->key), &(entry->message->header.sender_id),
363 &context);
364
365 entry->sender = get_store_contact (store, &context,
366 &(entry->message->body.join.key));
367 }
368
370 room->members, &(entry->message->header.sender_id), entry->sender)) &&
372 &(entry->message->header
373 .sender_id),
374 entry->sender,
377}
378
379
380static void
382 const struct GNUNET_HashCode *hash,
384{
385 GNUNET_assert ((room) && (hash) && (entry));
386
387 if ((! entry->sender) ||
389 &(entry->message->
390 header.sender_id),
391 entry->sender)))
392 return;
393
394 if (GNUNET_YES == decrease_contact_rc (entry->sender))
396 "A contact does not share any room with you anymore!\n");
397}
398
399
400static void
402 const struct GNUNET_HashCode *hash,
404{
405 GNUNET_assert ((room) && (hash) && (entry));
406
408 {
409 const char *handle_name;
410
412 "Set rule for using handle name in room: %s\n",
413 GNUNET_h2s (&(room->key)));
414
415 handle_name = get_handle_name (room->handle);
416
417 if ((handle_name) && (0 == strcmp (handle_name,
418 entry->message->body.name.name)))
420 }
421
422 if (! entry->sender)
423 return;
424
425 set_contact_name (entry->sender, entry->message->body.name.name);
426}
427
428
429static void
431 const struct GNUNET_HashCode *hash,
433{
435 struct GNUNET_MESSENGER_ContactStore *store;
436
437 GNUNET_assert ((room) && (hash) && (entry));
438
439 if (! entry->sender)
440 return;
441
442 get_context_from_member (&(room->key), &(entry->message->header.sender_id),
443 &context);
444
445 store = get_handle_contact_store (room->handle);
446
447 update_store_contact (store, entry->sender, &context, &context,
448 &(entry->message->body.key.key));
449}
450
451
452static void
454 const struct GNUNET_HashCode *hash,
456{
457 struct GNUNET_HashCode context, next_context;
458 struct GNUNET_MESSENGER_ContactStore *store;
459
460 GNUNET_assert ((room) && (hash) && (entry));
461
463 set_room_sender_id (room, &(entry->message->body.id.id));
464
465 if ((! entry->sender) ||
467 &(entry->message->
468 header.sender_id),
469 entry->sender)) ||
471 &(entry->message->body.
472 id.id),
473 entry->sender,
475
476 return;
477
478 get_context_from_member (&(room->key), &(entry->message->header.sender_id),
479 &context);
480 get_context_from_member (&(room->key), &(entry->message->body.id.id),
481 &next_context);
482
483 store = get_handle_contact_store (room->handle);
484
485 update_store_contact (store, entry->sender, &context, &next_context,
486 get_contact_key (entry->sender));
487}
488
489
490static void
492 const struct GNUNET_HashCode *hash,
494{
495 struct GNUNET_MESSENGER_ListTunnel *match;
496
497 GNUNET_assert ((room) && (hash) && (entry));
498
499 if (0 == (GNUNET_MESSENGER_FLAG_SENT & entry->flags))
500 return;
501
502 match = find_list_tunnels (&(room->entries), &(entry->message->body.miss.peer), NULL);
503
504 if (match)
505 remove_from_list_tunnels (&(room->entries), match);
506}
507
508
509static void
511 const struct GNUNET_HashCode *hash,
513{
514 struct GNUNET_MESSENGER_Message *private_message;
515
516 GNUNET_assert ((room) && (hash) && (entry));
517
518 private_message = copy_message (entry->message);
519
520 if (! private_message)
521 return;
522
523 if (GNUNET_YES != decrypt_message (private_message,
524 get_handle_key (room->handle)))
525 {
526 destroy_message (private_message);
527 private_message = NULL;
528 }
529
530 if (! private_message)
531 return;
532
533 destroy_message (entry->message);
534
535 entry->recipient = get_handle_contact (room->handle, &(room->key));
536
537 entry->message = private_message;
539
540 if ((entry->sender) && (entry->recipient))
541 handle_message (room, hash, entry);
542}
543
544
545static void
547 const struct GNUNET_HashCode *hash,
549{
550 const struct GNUNET_HashCode *target_hash;
552
553 GNUNET_assert ((room) && (hash) && (entry));
554
555 target_hash = &(entry->message->body.deletion.hash);
556
557 if (get_handle_contact (room->handle, &(room->key)) == entry->sender)
558 {
559 struct GNUNET_TIME_Relative delay;
561
563
566
568 action);
569
570 link_room_deletion (room, target_hash, delay, delete_room_message);
571 }
572
573 target = GNUNET_CONTAINER_multihashmap_get (room->messages, target_hash);
574 if (! target)
575 return;
576
577 if (((target->sender != entry->sender) &&
578 (get_handle_contact (room->handle, &(room->key)) != entry->sender)))
579 return;
580
582 callback_room_message (room, target_hash);
583
585 target_hash,
586 target))
587 {
588 destroy_message (target->message);
589 GNUNET_free (target);
590 }
591}
592
593
594static void
596 const struct GNUNET_HashCode *hash,
598{
599 const struct GNUNET_HashCode *original_hash;
600 struct GNUNET_MESSENGER_RoomMessageEntry *original;
601 struct GNUNET_MESSENGER_Message *original_message;
602
603 GNUNET_assert ((room) && (hash) && (entry));
604
605 if (get_handle_contact (room->handle, &(room->key)) != entry->sender)
606 return;
607
608 original_hash = &(entry->message->body.transcript.hash);
609
610 original = GNUNET_CONTAINER_multihashmap_get (room->messages, original_hash);
611
612 if (original)
613 goto read_transcript;
614
616
617 if (! original)
618 return;
619
620 original->sender = NULL;
621 original->recipient = NULL;
622
623 original->message = NULL;
625 original->completed = GNUNET_NO;
626
628 original_hash,
629 original,
631 {
632 GNUNET_free (original);
633 return;
634 }
635
636read_transcript:
637 original_message = copy_message (entry->message);
638
639 if (! original_message)
640 return;
641
642 if (GNUNET_YES != read_transcript_message (original_message))
643 {
644 destroy_message (original_message);
645 return;
646 }
647
648 {
649 struct GNUNET_MESSENGER_ContactStore *store;
650
651 store = get_handle_contact_store (room->handle);
652 original->recipient = get_store_contact (store,
653 NULL,
654 &(entry->message->body.transcript.key
655 ));
656 }
657
658 if (original->message)
659 {
662
663 copy_message_header (original_message, &(original->message->header));
664 destroy_message (original->message);
665 }
666
667 original->message = original_message;
668
669 link_room_message (room, hash, original_hash);
670 link_room_message (room, original_hash, hash);
671
672 if ((original->sender) && (original->recipient))
673 {
675 handle_message (room, original_hash, original);
676 }
677}
678
679
680static void
682 const struct GNUNET_HashCode *hash,
684{
685 GNUNET_assert ((room) && (hash) && (entry));
686
687 switch (entry->message->header.kind)
688 {
690 handle_join_message (room, hash, entry);
691 break;
693 handle_leave_message (room, hash, entry);
694 break;
696 handle_name_message (room, hash, entry);
697 break;
699 handle_key_message (room, hash, entry);
700 break;
702 handle_id_message (room, hash, entry);
703 break;
705 handle_miss_message (room, hash, entry);
706 break;
708 handle_private_message (room, hash, entry);
709 break;
711 handle_delete_message (room, hash, entry);
712 break;
714 handle_transcript_message (room, hash, entry);
715 break;
716 default:
717 break;
718 }
719
721 callback_room_message (room, hash);
722}
723
724
725void
727 struct GNUNET_MESSENGER_Contact *sender,
728 const struct GNUNET_MESSENGER_Message *message,
729 const struct GNUNET_HashCode *hash,
731{
733
734 GNUNET_assert ((room) && (message) && (hash));
735
736 entry = GNUNET_CONTAINER_multihashmap_get (room->messages, hash);
737
738 if (entry)
739 goto update_entry;
740
742
743 if (! entry)
744 return;
745
746 entry->sender = NULL;
747 entry->recipient = NULL;
748
749 entry->message = NULL;
751 entry->completed = GNUNET_NO;
752
754 entry,
756 {
757 GNUNET_free (entry);
758 return;
759 }
760
761update_entry:
762 entry->sender = sender;
763 entry->flags = flags;
764
765 if (entry->message)
766 {
769
771 }
772 else
773 entry->message = copy_message (message);
774
775 entry->completed = GNUNET_YES;
776
777 handle_message (room, hash, entry);
778}
779
780
781void
783 const struct GNUNET_HashCode *hash)
784{
785 GNUNET_assert ((room) && (hash));
786
787 GNUNET_memcpy (&(room->last_message), hash, sizeof(room->last_message));
788}
789
790
792{
795 void *cls;
796};
797
800 const struct GNUNET_ShortHashCode *key,
801 void *value)
802{
804 struct GNUNET_MESSENGER_Contact *contact;
805
806 GNUNET_assert ((cls) && (value));
807
808 call = cls;
809 contact = value;
810
811 return call->callback (call->cls, call->room, contact);
812}
813
814
815int
818 void *cls)
819{
821
823
824 if (! callback)
826
827 call.room = room;
828 call.callback = callback;
829 call.cls = cls;
830
832
835 &call);
836}
837
838
840{
843};
844
847 const struct GNUNET_ShortHashCode *key,
848 void *value)
849{
850 struct GNUNET_MESSENGER_MemberFind *find;
851 struct GNUNET_MESSENGER_Contact *contact;
852
853 GNUNET_assert ((cls) && (value));
854
855 find = cls;
856 contact = value;
857
858 if (contact == find->contact)
859 {
860 find->result = GNUNET_YES;
861 return GNUNET_NO;
862 }
863
864 return GNUNET_YES;
865}
866
867
870 const struct GNUNET_MESSENGER_Contact *contact)
871{
872 struct GNUNET_MESSENGER_MemberFind find;
873
874 GNUNET_assert (room);
875
876 find.contact = contact;
877 find.result = GNUNET_NO;
878
880 &find);
881
882 return find.result;
883}
884
885
888 const struct GNUNET_HashCode *key,
889 void *value)
890{
891 const struct GNUNET_HashCode **result;
892 struct GNUNET_HashCode *hash;
893
894 GNUNET_assert ((cls) && (value));
895
896 result = cls;
897 hash = value;
898
899 if (0 == GNUNET_CRYPTO_hash_cmp (hash, *result))
900 {
901 *result = NULL;
902 return GNUNET_NO;
903 }
904
905 return GNUNET_YES;
906}
907
908
909void
911 const struct GNUNET_HashCode *hash,
912 const struct GNUNET_HashCode *other)
913{
914 const struct GNUNET_HashCode **result;
915 struct GNUNET_HashCode *value;
916
917 GNUNET_assert ((room) && (hash) && (other));
918
919 result = &other;
922
923 if (! *result)
924 return;
925
926 value = GNUNET_memdup (other, sizeof(struct GNUNET_HashCode));
927 if (! value)
928 return;
929
932
934}
935
936
938{
942};
943
944
947 const struct GNUNET_HashCode *key,
948 void *value)
949{
950 struct GNUNET_HashCode **linked;
951 struct GNUNET_HashCode *hash;
952
953 GNUNET_assert ((cls) && (value));
954
955 linked = cls;
956 hash = value;
957
958 if (0 != GNUNET_CRYPTO_hash_cmp (*linked, hash))
959 return GNUNET_YES;
960
961 *linked = hash;
962 return GNUNET_NO;
963}
964
965
968 const struct GNUNET_HashCode *key,
969 void *value)
970{
972 struct GNUNET_HashCode *hash;
973 struct GNUNET_HashCode key_value;
974 struct GNUNET_HashCode *linked;
975
976 GNUNET_assert ((cls) && (key) && (value));
977
978 info = cls;
979 hash = value;
980
981 GNUNET_memcpy (&key_value, key, sizeof (key_value));
982
983 linked = &key_value;
985 clear_linked_hash, &linked);
986
987 if ((linked != &key_value) &&
989 hash, linked)))
990 GNUNET_free (linked);
991
992 if (info->deletion)
993 info->deletion (info->room, hash, info->delay);
994
995 GNUNET_free (hash);
996 return GNUNET_YES;
997}
998
999
1000void
1002 const struct GNUNET_HashCode *hash,
1003 const struct GNUNET_TIME_Relative delay,
1005{
1007
1008 GNUNET_assert ((room) && (hash));
1009
1010 info.room = room;
1011 info.delay = delay;
1012 info.deletion = deletion;
1013
1017}
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:218
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_WARNING
@ 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.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:980
struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh(struct GNUNET_TIME_RelativeNBO a)
Convert relative time from network byte order.
Definition: time.c:630
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:741
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:452
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:423
void enqueue_message_to_room(struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Message *message, struct GNUNET_MESSENGER_Message *transcript)
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...
struct GNUNET_MESSENGER_MessageControl * create_message_control(struct GNUNET_MESSENGER_Room *room)
Creates and allocates a new message control for a room of the client API.
void destroy_message_control(struct GNUNET_MESSENGER_MessageControl *control)
Destroys a message control and frees its memory fully from the client API.
struct GNUNET_MESSENGER_Message * create_message_delete(const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)
Creates and allocates a new delete message containing the hash of a message to delete after a specifi...
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.
static enum GNUNET_GenericReturnValue iterate_destroy_subscription(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
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)
void delete_room_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)
Deletes a message with a given hash inside a room under a specific delay.
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.
static void handle_join_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
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)
struct GNUNET_MESSENGER_Handle * get_room_handle(struct GNUNET_MESSENGER_Room *room)
Returns the messenger handle of the room.
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...
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_SCHEDULER_Task * task
struct GNUNET_MESSENGER_Message * message
struct GNUNET_MESSENGER_Room * room
struct GNUNET_CONTAINER_MultiHashMap * links
struct GNUNET_CONTAINER_MultiShortmap * subscriptions
struct GNUNET_MESSENGER_Handle * handle
enum GNUNET_GenericReturnValue opened
enum GNUNET_GenericReturnValue wait_for_sync
struct GNUNET_CONTAINER_MultiShortmap * members
struct GNUNET_MESSENGER_MessageControl * control
struct GNUNET_SCHEDULER_Task * queue_task
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.