GNUnet 0.29.1-6-gb66d952d5
 
Loading...
Searching...
No Matches
gnunet-service-messenger_room.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2020--2026 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 "gnunet_common.h"
28#include "gnunet_pils_service.h"
29#include "gnunet_util_lib.h"
31#include "platform.h"
33
44
45#include "messenger_api_util.h"
46#include <stdint.h>
47#include <string.h>
48
49static void
51
52static void
54 char **dir)
55{
56 GNUNET_assert ((room) && (dir));
57
58 if (room->service->dir)
59 GNUNET_asprintf (dir, "%s%s%c%s%c", room->service->dir, "rooms",
62 else
63 *dir = NULL;
64}
65
66
69 const struct GNUNET_HashCode *key)
70{
71 struct GNUNET_MESSENGER_SrvRoom *room;
72 char *room_dir;
73
74 GNUNET_assert ((handle) && (key));
75
76 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Create new room: %s\n",
77 GNUNET_h2s (key));
78
80
81 room->service = handle->service;
82 room->host = handle;
83 room->sync = NULL;
84 room->port = NULL;
85
86 GNUNET_memcpy (&(room->key), key, sizeof(struct GNUNET_HashCode));
87
89
90 get_room_data_subdir (room, &room_dir);
91
93
98
99 GNUNET_free (room_dir);
100
101 init_list_tunnels (&(room->basement));
102 init_message_state (&(room->state));
103
104 room->peer_message = NULL;
105
106 init_list_messages (&(room->handling));
107 room->idle_task = NULL;
108 room->save_task = NULL;
109
110 if (room->service->dir)
111 load_srv_room (room);
112
115
116 return room;
117}
118
119
123 void *value)
124{
125 struct GNUNET_MESSENGER_SrvTunnel *tunnel;
126
128
129 tunnel = value;
130
131 destroy_tunnel (tunnel);
132 return GNUNET_YES;
133}
134
135
138 GNUNET_UNUSED const struct GNUNET_HashCode *key,
139 void *value)
140{
141 struct GNUNET_MESSENGER_SrvRoomSignature *signature;
142
144
145 signature = value;
146
147 if (signature->operation)
148 GNUNET_PILS_cancel (signature->operation);
149
150 if (signature->message)
151 destroy_message (signature->message);
152
153 if (signature->envelope)
154 GNUNET_free (signature->envelope);
155
156 GNUNET_free (signature);
157 return GNUNET_YES;
158}
159
160
161static void
163
164static void
166
167void
222
223
226{
227 GNUNET_assert (room);
228
229 return &(room->peer_store);
230}
231
232
240
241
244{
245 GNUNET_assert (room);
246
247 return &(room->message_store);
248}
249
250
258
259
263 struct GNUNET_MESSENGER_SrvTunnel *tunnel)
264{
265 if ((! handle) || (! is_tunnel_connected (tunnel)))
266 return GNUNET_NO;
267
269 room->service));
270}
271
272
273static void*
275 struct GNUNET_CADET_Channel *channel,
276 const struct GNUNET_PeerIdentity *source)
277{
278 struct GNUNET_MESSENGER_SrvRoom *room;
279 struct GNUNET_MESSENGER_SrvTunnel *tunnel;
280
281 GNUNET_assert ((cls) && (channel) && (source));
282
283 room = cls;
284
286 "New incoming connection to room (%s) from peer: %s\n",
288
289 tunnel = create_tunnel (room, source);
290
291 if ((tunnel) &&
293 tunnel,
295 {
296 destroy_tunnel (tunnel);
297 tunnel = NULL;
298 }
299
300 if (! tunnel)
301 {
303 return NULL;
304 }
305
306 bind_tunnel (tunnel, channel);
307
309 "New tunnel in room (%s) established to peer: %s\n",
311
312 if (GNUNET_YES == send_room_info (room, room->host, tunnel))
313 return tunnel;
314
315 disconnect_tunnel (tunnel);
316
318 tunnel))
319 destroy_tunnel (tunnel);
320
321 return NULL;
322}
323
324
328 struct GNUNET_MESSENGER_Member *member,
329 const struct GNUNET_ShortHashCode *id)
330{
331 const struct GNUNET_ShortHashCode *member_id;
332
333 GNUNET_assert ((room) && (handle) && (member));
334
335 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Joining room: %s (%s)\n", GNUNET_h2s (
336 get_srv_room_key (room)),
337 GNUNET_sh2s (get_member_id (member)));
338
339 member_id = get_member_id (member);
340
342 member_id))
343 return GNUNET_NO;
344
345 {
347 if ((! id) || (0 != GNUNET_memcmp (id, member_id)))
349 else
351
352 notify_srv_handle_member_id (handle, room, member_id, reset);
353 }
354
355 return GNUNET_YES;
356}
357
358
362{
363 struct GNUNET_MESSENGER_MemberStore *member_store;
364 const struct GNUNET_ShortHashCode *member_id;
365 struct GNUNET_MESSENGER_Member *member;
366
367 member_store = get_srv_room_member_store (room);
369 member = add_store_member (member_store, member_id);
370
371 if (GNUNET_NO == join_room (room, handle, member, member_id))
372 return GNUNET_NO;
373
374 return GNUNET_YES;
375}
376
377
381{
382 GNUNET_assert (room);
383
384 if (handle)
385 room->host = handle;
386
387 if (room->port)
388 {
390 "Port of room (%s) was already open!\n",
392
393 if (! handle)
394 return GNUNET_YES;
395
396 return join_room_locally (room, handle);
397 }
398
399 {
402 struct GNUNET_HashCode port;
403
405 tunnel_message,
407 struct
409 ,
411
412 cadet = get_srv_room_cadet (room);
413
415 &(key.hash),
416 get_srv_room_key (room),
417 sizeof (key.hash));
418
419 if ((key.code.feed_bit) && (! key.code.group_bit))
420 {
422 "Opening port of personal room containing private feeds failed!");
423 return GNUNET_SYSERR;
424 }
425
427 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to open CADET port: %s\n",
428 GNUNET_h2s (&port));
429
431 room, NULL, callback_tunnel_disconnect,
432 handlers);
433 }
434
435 if (room->port)
436 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Port of room (%s) was opened!\n",
438 else
440 "Port of room (%s) could not be opened!\n",
442
443 if (! handle)
444 goto complete_opening;
445
446 {
447 struct GNUNET_MESSENGER_MemberStore *member_store;
448 const struct GNUNET_ShortHashCode *member_id;
449 struct GNUNET_MESSENGER_Member *member;
450
451 member_store = get_srv_room_member_store (room);
453 member = add_store_member (member_store, member_id);
454
455 if ((GNUNET_NO == join_room (room, handle, member, member_id)) &&
456 (room->port))
457 {
459 "You could not join the room, therefore it keeps closed!\n");
460
461 close_srv_room (room);
462 return GNUNET_NO;
463 }
464 }
465
466complete_opening:
467 if (! room->port)
468 return GNUNET_NO;
469
470 {
471 struct GNUNET_MESSENGER_Message *message;
472 message = create_message_peer (room->service);
473
474 if (! message)
475 {
477 "Peer message could not be sent!\n");
478 return GNUNET_NO;
479 }
480
481 return send_srv_room_message (room, handle, message);
482 }
483}
484
485
486static void
488{
489 struct GNUNET_PeerIdentity peer;
490
491 GNUNET_assert (room);
492
493 if (! room->port)
494 return;
495
496 if ((room->peer_message) &&
497 (GNUNET_OK == get_service_peer_identity (room->service, &peer)))
498 {
499 struct GNUNET_MESSENGER_Message *message;
500
501 message = create_message_miss (&peer);
502
503 if (! message)
505 "Sending miss message about peer failed: %s\n",
506 GNUNET_h2s (&(room->key)));
507 else
508 send_srv_room_message (room, room->host, message);
509 }
510
512 room->port = NULL;
513}
514
515
519 const struct GNUNET_PeerIdentity *door)
520{
521 struct GNUNET_PeerIdentity peer;
522 struct GNUNET_MESSENGER_SrvTunnel *tunnel;
524
525 GNUNET_assert ((room) && (handle) && (door));
526
527 if ((GNUNET_is_zero (door)) ||
529 (0 == GNUNET_memcmp (&peer, door))))
530 return join_room_locally (room, handle);
531
533
534 if (! tunnel)
535 {
536 tunnel = create_tunnel (room, door);
537
539 tunnel,
541 {
543 "You could not connect to that door!\n");
544 destroy_tunnel (tunnel);
545 return GNUNET_NO;
546 }
547 }
548
549 ret = connect_tunnel (tunnel);
550
551 if (GNUNET_YES != ret)
552 {
554 destroy_tunnel (tunnel);
555
556 if (GNUNET_SYSERR == ret)
557 {
559 "Connection failure during entrance!\n");
560 return GNUNET_NO;
561 }
562 }
563
564 return join_room_locally (room, handle);
565}
566
567
568static void
570 const struct GNUNET_PeerIdentity *identity,
571 const struct GNUNET_CRYPTO_EddsaSignature *
572 peer_signature)
573{
574 struct GNUNET_MESSENGER_SrvRoomSignature *signature;
575 struct GNUNET_MessageHeader *header;
576 uint16_t padded_length;
577 char *buffer;
578
579 GNUNET_assert ((cls) && (peer_signature));
580
581 signature = cls;
582
584 "Signature operation with peer identity (%s) completed: %s\n",
586 GNUNET_h2s (&(signature->hash)));
587
588 GNUNET_assert (signature->operation);
589 signature->operation = NULL;
590
591 GNUNET_assert ((signature->room) && (signature->message) && (signature->
592 envelope));
593
595 peer_signature, sizeof (*peer_signature));
596
597 header = (struct GNUNET_MessageHeader *) GNUNET_MQ_env_get_msg (signature->
598 envelope);
599 padded_length = header->size - sizeof (*header);
600 buffer = (char *) &(header[1]);
601
602 encode_message_signature (signature->message, padded_length, buffer);
603
604 GNUNET_assert (signature->callback);
605 signature->callback (signature->closure,
606 signature->room,
607 signature->message,
608 signature->envelope,
609 &(signature->hash));
610
612 signatures,
613 &(signature->hash),
614 signature))
615 {
616 GNUNET_free (signature);
617 return;
618 }
619
621 "Signature operation could not be removed: %s\n",
622 GNUNET_h2s (&(signature->hash)));
623
624 signature->message = NULL;
625 signature->envelope = NULL;
626}
627
628
631 struct GNUNET_MESSENGER_Message *message,
633 void *closure)
634{
635 struct GNUNET_MESSENGER_SrvRoomSignature *signature;
637
638 GNUNET_assert ((room) && (message) && (callback));
639
640 if (GNUNET_YES != is_peer_message (message))
641 {
642 struct GNUNET_MQ_Envelope *envelope;
643 struct GNUNET_HashCode hash;
644
645 envelope = pack_message (message, &hash,
647
648 if (! envelope)
649 {
651 "Packing message into envelope failed: %s\n",
653 return GNUNET_SYSERR;
654 }
655
656 callback (closure, room, message, envelope, &hash);
657 return GNUNET_YES;
658 }
659
660 if (GNUNET_YES == is_epoch_message (message))
663 else
666
668 {
669 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peer identity is missing!\n");
670 return GNUNET_SYSERR;
671 }
672
674 get_message_state_chain_hash (&(room->state), &(message->header.previous));
675
677 {
678 const struct GNUNET_MESSENGER_MessageStore *store;
679 const struct GNUNET_HashCode *epoch;
680
681 store = get_srv_room_message_store (room);
682 epoch = get_store_message_epoch (store, &(message->header.previous));
683
684 if (epoch)
685 GNUNET_memcpy (&(message->body.merge.epochs[0]), epoch,
686 sizeof (struct GNUNET_HashCode));
687
688 epoch = get_store_message_epoch (store, &(message->body.merge.previous));
689
690 if (epoch)
691 GNUNET_memcpy (&(message->body.merge.epochs[1]), epoch,
692 sizeof (struct GNUNET_HashCode));
693 }
694
696 GNUNET_assert (signature);
697
698 signature->room = room;
699 signature->message = message;
700
702 "Packing message with peer signature: %s\n",
703 GNUNET_sh2s (&(signature->message->header.sender_id)));
704
706 signature->envelope = pack_message (signature->message, &(signature->hash),
708
709 if (! signature->envelope)
710 {
712 "Packing message into envelope failed: %s\n",
714 ;
715 destroy_message (signature->message);
716 GNUNET_free (signature);
717 return GNUNET_SYSERR;
718 }
719
721 &(signature->hash)))
722 {
724 "Signature operation already queued: %s\n",
725 GNUNET_h2s (&(signature->hash)));
726
727 destroy_message (signature->message);
728 GNUNET_free (signature->envelope);
729 GNUNET_free (signature);
730 return GNUNET_SYSERR;
731 }
732
733 signature->callback = callback;
734 signature->closure = closure;
735
736 signature->operation = sign_message_by_peer (signature->message,
737 &(signature->hash),
738 room->service->pils,
740 signature);
741
742 if (! signature->operation)
743 {
745 "Signing message by peer identity (%s) failed: %s\n",
747 GNUNET_h2s (&(signature->hash)));
748
749 destroy_message (signature->message);
750 GNUNET_free (signature->envelope);
751 GNUNET_free (signature);
752 return GNUNET_SYSERR;
753 }
754
756 &(signature->hash),
757 signature,
759 {
761 "Signature operation could not be stored: %s\n",
762 GNUNET_h2s (&(signature->hash)));
763
764 iterate_cancel_signature (NULL, &(signature->hash),
765 signature);
766 return GNUNET_SYSERR;
767 }
768
769 return GNUNET_YES;
770}
771
772
775 struct GNUNET_MESSENGER_Message *message,
776 const struct GNUNET_HashCode *hash);
777
778void
780 const struct GNUNET_MESSENGER_Message *message,
781 const struct GNUNET_HashCode *hash);
782
783static void
785 struct GNUNET_MESSENGER_SrvRoom *room,
786 struct GNUNET_MESSENGER_Message *message,
787 struct GNUNET_MQ_Envelope *envelope,
788 const struct GNUNET_HashCode *hash)
789{
791 enum GNUNET_GenericReturnValue new_message;
792
793 GNUNET_assert ((cls) && (room) && (message) && (envelope) && (hash));
794
795 handle = cls;
796
797 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending room message: %s\n",
798 GNUNET_h2s (hash));
799
800 send_srv_room_envelope (room, NULL, envelope, hash);
801 new_message = update_room_message (room, message, hash);
802
803 if (GNUNET_YES != new_message)
804 {
806 "Sending duplicate message failed: %s\n",
807 GNUNET_h2s (hash));
808 return;
809 }
810
811 switch (message->header.kind)
812 {
814 send_message_join (room, handle, message, hash);
815 break;
817 send_message_key (room, handle, message, hash);
818 break;
820 send_message_peer (room, handle, message, hash);
821 break;
823 send_message_id (room, handle, message, hash);
824 break;
826 send_message_request (room, handle, message, hash);
827 break;
828 default:
829 break;
830 }
831
832 callback_room_handle_message (room, message, hash);
833
834 if ((GNUNET_MESSENGER_KIND_MERGE == message->header.kind) &&
835 (room->sync == handle) &&
837 room->key))))
839}
840
841
845 struct GNUNET_MESSENGER_Message *message)
846{
847 GNUNET_assert ((room) && (handle));
848
849 if (! message)
850 return GNUNET_NO;
851
853 "Sending message from handle in room: %s (%s)\n",
854 GNUNET_h2s (&(room->key)),
856
857 return sign_srv_room_message (room, message,
859 handle);
860}
861
862
872
876 void *value)
877{
878 struct GNUNET_MESSENGER_SrvTunnel *tunnel;
879 struct GNUNET_MESSENGER_ClosureSendRoom *closure;
880 struct GNUNET_MQ_Envelope *envelope;
881
882 GNUNET_assert ((cls) && (value));
883
884 closure = cls;
885 tunnel = value;
886
887 GNUNET_assert ((closure->envelope) && (closure->hash));
888
889 if ((! is_tunnel_connected (tunnel)) ||
891 return GNUNET_YES;
892
893 if (tunnel == closure->exclude)
894 return GNUNET_YES;
895
896 envelope = GNUNET_MQ_env_copy (closure->envelope);
897
898 if (envelope)
899 send_tunnel_envelope (tunnel, envelope, closure->hash);
900
901 return GNUNET_YES;
902}
903
904
905void
907 struct GNUNET_MESSENGER_SrvTunnel *tunnel,
908 struct GNUNET_MQ_Envelope *envelope,
909 const struct GNUNET_HashCode *hash)
910{
912
913 GNUNET_assert ((room) && (envelope));
914
915 closure.exclude = tunnel;
916 closure.envelope = envelope;
917 closure.hash = hash;
918
921 &closure);
922
924}
925
926
927void
929 struct GNUNET_MESSENGER_SrvTunnel *tunnel)
930{
931 struct GNUNET_MESSENGER_MessageStore *message_store;
932 const struct GNUNET_MESSENGER_Message *message;
933
934 if (! room->peer_message)
935 return;
936
937 message_store = get_srv_room_message_store (room);
938 message = get_store_message (message_store, room->peer_message);
939
940 if (! message)
941 {
943 room->peer_message = NULL;
944 return;
945 }
946
947 if (tunnel)
948 forward_tunnel_message (tunnel, message, room->peer_message);
949}
950
951
955{
956 const struct GNUNET_HashCode *hash;
957 struct GNUNET_MESSENGER_Message *message;
958
959 GNUNET_assert (room);
960
961 if (! handle)
962 return GNUNET_SYSERR;
963
965 "Merging messages by handle in room: %s\n",
966 GNUNET_h2s (&(room->key)));
967
968 hash = get_message_state_merge_hash (&(room->state));
969
970 if ((! hash) || (GNUNET_is_zero (hash)))
971 return GNUNET_NO;
972
973 message = create_message_merge (hash);
974
975 if (! message)
976 {
978 "Merging messages failed: %s\n",
979 GNUNET_h2s (&(room->key)));
980 return GNUNET_SYSERR;
981 }
982
983 return send_srv_room_message (room, handle, message);
984}
985
986
989 struct GNUNET_MESSENGER_SrvMemberSession *session,
990 const struct GNUNET_HashCode *hash,
991 const struct GNUNET_TIME_Relative delay)
992{
993 const struct GNUNET_MESSENGER_Message *message;
994 struct GNUNET_TIME_Relative forever;
995
996 GNUNET_assert ((room) && (session) && (hash));
997
999
1000 if (0 == GNUNET_memcmp (&forever, &delay))
1001 {
1003 "Deletion is delayed forever: operation is impossible!\n");
1004 return GNUNET_SYSERR;
1005 }
1006
1007 {
1008 struct GNUNET_MESSENGER_MessageStore *message_store;
1009
1010 message_store = get_srv_room_message_store (room);
1011 message = get_store_message (message_store, hash);
1012 }
1013
1014 if (! message)
1015 return GNUNET_YES;
1016
1017 if (GNUNET_YES != check_member_session_history (session, hash, GNUNET_YES))
1018 {
1020 "Unpermitted request for deletion by member (%s) of message (%s)!\n",
1022 hash));
1023
1024 return GNUNET_NO;
1025 }
1026
1027 {
1028 struct GNUNET_MESSENGER_OperationStore *operation_store;
1029
1030 operation_store = get_srv_room_operation_store (room);
1031
1032 if (GNUNET_OK != use_store_operation (operation_store, hash,
1034 {
1036 "Deletion has failed: operation denied!\n");
1037 return GNUNET_SYSERR;
1038 }
1039 }
1040
1041 return GNUNET_YES;
1042}
1043
1044
1045struct GNUNET_CADET_Handle*
1047{
1048 GNUNET_assert (room);
1049
1050 return room->service->cadet;
1051}
1052
1053
1054const struct GNUNET_HashCode*
1056{
1057 GNUNET_assert (room);
1058
1059 return &(room->key);
1060}
1061
1062
1063const struct GNUNET_MESSENGER_SrvTunnel*
1065 const struct GNUNET_PeerIdentity *peer)
1066{
1067 GNUNET_assert ((room) && (peer));
1068
1070}
1071
1072
1073static enum GNUNET_GenericReturnValue
1075 const struct GNUNET_HashCode *hash,
1077 session,
1079 void *cls)
1080{
1081 struct GNUNET_MESSENGER_MessageStore *message_store;
1082 const struct GNUNET_MESSENGER_MessageLink *link;
1083 const struct GNUNET_MESSENGER_Message *message;
1084
1085 GNUNET_assert ((room) && (hash) && (session));
1086
1087 message_store = get_srv_room_message_store (room);
1088 link = get_store_message_link (message_store, hash, GNUNET_YES);
1089
1090 if (! link)
1091 goto forward;
1092
1094 "Requesting link of message with hash: %s\n",
1095 GNUNET_h2s (hash));
1096
1097 {
1099 result = request_room_message_step (room, &(link->first), session,
1100 callback, cls);
1101
1102 if ((GNUNET_YES == link->multiple) &&
1103 (GNUNET_YES == request_room_message_step (room, &(link->second),
1104 session, callback, cls)))
1105 return GNUNET_YES;
1106 else
1107 return result;
1108 }
1109
1110forward:
1111 message = get_store_message (message_store, hash);
1112
1113 if (! message)
1114 {
1116 "Requested message is missing in local storage: %s\n",
1117 GNUNET_h2s (hash));
1118 return GNUNET_NO;
1119 }
1120
1121 if (GNUNET_YES == is_epoch_message (message))
1122 goto skip_member_session;
1123
1124 if (GNUNET_YES != check_member_session_history (session, hash, GNUNET_NO))
1125 {
1127 "Unpermitted request for access by member (%s) of message (%s)!\n",
1129 GNUNET_h2s (hash));
1130 return GNUNET_YES;
1131 }
1132
1133skip_member_session:
1134 if (callback)
1135 callback (cls, room, message, hash);
1136
1137 return GNUNET_YES;
1138}
1139
1140
1143 const struct GNUNET_HashCode *hash,
1145 session,
1147 void *cls)
1148{
1150
1151 GNUNET_assert ((room) && (hash));
1152
1153 result = request_room_message_step (room, hash, session, callback, cls);
1154
1155 if ((GNUNET_NO == result) && (callback))
1156 callback (cls, room, NULL, hash);
1157
1158 return result;
1159}
1160
1161
1162static void
1164{
1165 struct GNUNET_MESSENGER_SrvRoom *room;
1166 struct GNUNET_MESSENGER_OperationStore *operation_store;
1167 const struct GNUNET_HashCode *hash;
1168
1169 GNUNET_assert (cls);
1170
1171 room = cls;
1172 room->idle_task = NULL;
1173
1174 operation_store = get_srv_room_operation_store (room);
1175 hash = get_message_state_merge_hash (&(room->state));
1176
1177 if ((hash) && (! GNUNET_is_zero (hash)) &&
1179 hash)))
1181 operation_store,
1182 hash,
1185
1190 cls);
1191}
1192
1193
1194void
1196 const struct
1198 const struct GNUNET_ShortHashCode *member_id,
1200{
1201 struct GNUNET_MESSENGER_MemberStore *member_store;
1202 struct GNUNET_MESSENGER_Member *member;
1203 struct GNUNET_MESSENGER_ListHandles *handles;
1204 struct GNUNET_MESSENGER_ListHandle *element;
1205
1206 GNUNET_assert ((room) && (public_key) && (member_id));
1207
1208 member_store = get_srv_room_member_store (room);
1209 member = get_store_member (member_store, member_id);
1210
1211 if ((! member) || (1 >= GNUNET_CONTAINER_multihashmap_size (
1212 member->sessions)))
1213 return;
1214
1215 handles = &(room->service->handles);
1216
1217 for (element = handles->head; element; element = element->next)
1218 {
1221 struct GNUNET_MESSENGER_SrvMemberSession *session;
1222
1224 get_srv_room_key (room));
1225
1226 if ((! handle_member_id) ||
1227 (0 != GNUNET_memcmp (member_id, handle_member_id)))
1228 continue;
1229
1230 pubkey = get_srv_handle_key (element->handle);
1231
1232 if (0 == GNUNET_memcmp (public_key, pubkey))
1233 continue;
1234
1235 session = get_member_session (member, pubkey);
1236
1237 if (! session)
1238 continue;
1239
1240 {
1242 start = get_member_session_start (session);
1243
1244 if (GNUNET_TIME_relative_get_zero_ ().rel_value_us !=
1246 continue;
1247 }
1248
1249 {
1250 struct GNUNET_ShortHashCode random_id;
1251 generate_free_member_id (&random_id, member_store->members);
1252
1254 element->handle,
1255 room,
1256 &random_id,
1257 GNUNET_NO);
1258 }
1259 }
1260}
1261
1262
1263void
1265{
1266 struct GNUNET_MESSENGER_ListTunnel *element;
1267 struct GNUNET_PeerIdentity peer;
1268 size_t count;
1269 size_t src;
1270 size_t dst;
1271
1272 GNUNET_assert (room);
1273
1274 if (GNUNET_OK != get_service_peer_identity (room->service, &peer))
1275 return;
1276
1277 count = count_of_tunnels (&(room->basement));
1278
1279 if (! find_list_tunnels (&(room->basement), &peer, &src))
1280 return;
1281
1282 if ((count > room->service->min_routers) &&
1283 (GNUNET_NO == is_srv_handle_routing (room->host, &(room->key))) &&
1285 &peer,
1287 {
1288 close_srv_room (room);
1289 return;
1290 }
1291
1292 element = room->basement.head;
1293 dst = 0;
1294
1295 while (element)
1296 {
1297 struct GNUNET_MESSENGER_SrvTunnel *tunnel;
1298
1299 GNUNET_PEER_resolve (element->peer, &peer);
1300
1302
1303 if (! tunnel)
1304 {
1305 element = remove_from_list_tunnels (&(room->basement), element);
1306 continue;
1307 }
1308
1309 if (GNUNET_YES == required_connection_between (count, src, dst))
1310 {
1311 if (GNUNET_SYSERR == connect_tunnel (tunnel))
1312 {
1313 element = remove_from_list_tunnels (&(room->basement), element);
1314 continue;
1315 }
1316 }
1317 else
1318 disconnect_tunnel (tunnel);
1319
1320 element = element->next;
1321 dst++;
1322 }
1323}
1324
1325
1326uint32_t
1333
1334
1335uint32_t
1337{
1338 uint32_t flags;
1339
1341
1343
1346
1347 return flags;
1348}
1349
1350
1351static void
1353{
1354 struct GNUNET_MESSENGER_MessageStore *message_store;
1355 struct GNUNET_MESSENGER_MemberStore *member_store;
1356 struct GNUNET_MESSENGER_PeerStore *peer_store;
1357 const struct GNUNET_HashCode *key;
1358
1359 message_store = get_srv_room_message_store (room);
1360 member_store = get_srv_room_member_store (room);
1361 peer_store = get_srv_room_peer_store (room);
1362
1363 key = get_srv_room_key (room);
1364
1366 "Handling room messages: %s\n", GNUNET_h2s (key));
1367
1368 while (room->handling.head)
1369 {
1370 struct GNUNET_MESSENGER_ListMessage *element;
1371 struct GNUNET_MESSENGER_SenderSession session;
1372 const struct GNUNET_MESSENGER_Message *message;
1373 const struct GNUNET_HashCode *epoch;
1374
1375 element = room->handling.head;
1376 message = get_store_message (
1377 message_store, &(element->hash));
1378
1379 if (! message)
1380 goto finish_handling;
1381
1382 if (GNUNET_YES == is_peer_message (message))
1383 {
1384 session.peer = get_store_peer_of (peer_store, message, &(element->hash));
1385
1386 if (! session.peer)
1387 goto finish_handling;
1388 }
1389 else
1390 {
1391 struct GNUNET_MESSENGER_Member *member;
1392
1393 member = get_store_member_of (member_store, message);
1394
1395 if (! member)
1396 goto finish_handling;
1397
1398 session.member = get_member_session_of (member, message,
1399 &(element->hash));
1400
1401 if (! session.member)
1402 goto finish_handling;
1403 }
1404
1405 epoch = get_store_message_epoch (message_store, &(element->hash));
1406
1407 handle_service_message (room->service, room, &session, message,
1408 &(element->hash), epoch, GNUNET_YES);
1409
1410finish_handling:
1412 element);
1413 GNUNET_free (element);
1414 }
1415}
1416
1417
1418static void
1420{
1421 struct GNUNET_MESSENGER_SrvRoom *room;
1422
1423 GNUNET_assert (cls);
1424
1425 room = cls;
1426 room->save_task = NULL;
1427
1428 save_srv_room (room);
1429}
1430
1431
1434 struct GNUNET_MESSENGER_Message *message,
1435 const struct GNUNET_HashCode *hash)
1436{
1437 struct GNUNET_MESSENGER_OperationStore *operation_store;
1438 struct GNUNET_MESSENGER_MessageStore *message_store;
1439 enum GNUNET_GenericReturnValue requested;
1440
1441 GNUNET_assert ((room) && (message) && (hash));
1442
1443 operation_store = get_srv_room_operation_store (room);
1444
1445 if (! operation_store)
1446 {
1447 destroy_message (message);
1448
1449 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Operation store invalid!\n");
1450 return GNUNET_NO;
1451 }
1452
1453 requested = (GNUNET_MESSENGER_OP_REQUEST ==
1454 get_store_operation_type (operation_store, hash)?
1456
1457 if (GNUNET_YES == requested)
1458 cancel_store_operation (operation_store, hash);
1459
1460 message_store = get_srv_room_message_store (room);
1461
1462 if (! message_store)
1463 {
1464 destroy_message (message);
1465
1466 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Message store invalid!\n");
1467 return GNUNET_NO;
1468 }
1469
1470 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Handle a message in room (%s).\n",
1471 GNUNET_h2s (get_srv_room_key (room)));
1472
1473 if (GNUNET_YES == contains_store_message (message_store, hash))
1474 {
1475 destroy_message (message);
1476
1477 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Duplicate message got dropped!\n");
1478 return GNUNET_NO;
1479 }
1480
1481 if (GNUNET_OK != put_store_message (message_store, hash, message))
1482 {
1483 destroy_message (message);
1484
1485 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Storing message failed!\n");
1486 return GNUNET_NO;
1487 }
1488
1489 update_message_state (&(room->state), requested, message, hash);
1490
1491 if ((GNUNET_YES == requested) ||
1492 (GNUNET_MESSENGER_KIND_INFO == message->header.kind) ||
1494 return GNUNET_YES;
1495
1496 if ((GNUNET_MESSENGER_KIND_MERGE == message->header.kind) &&
1498 &(message->body.
1499 merge.previous))
1500 ))
1501 cancel_store_operation (operation_store, &(message->body.merge.previous));
1502
1504 &(message->header.
1505 previous)))
1506 cancel_store_operation (operation_store, &(message->header.previous));
1507
1508 if (! room->save_task)
1513
1514 return GNUNET_YES;
1515}
1516
1517
1523
1524static enum GNUNET_GenericReturnValue
1527 public_key,
1529 session)
1530{
1532 struct GNUNET_MESSENGER_Member *member;
1533 struct GNUNET_MESSENGER_Subscription *subscription;
1534
1535 GNUNET_assert ((cls) && (session));
1536
1537 it = cls;
1538 member = session->member;
1539
1540 subscription = get_member_subscription (member, it->discourse);
1541 if (! subscription)
1542 return GNUNET_YES;
1543
1544 if (GNUNET_TIME_absolute_cmp (subscription->start, <, it->start))
1545 it->start = subscription->start;
1546
1547 return GNUNET_YES;
1548}
1549
1550
1551void
1553 const struct GNUNET_ShortHashCode *
1554 discourse)
1555{
1557 struct GNUNET_MESSENGER_MemberStore *member_store;
1558 struct GNUNET_MESSENGER_MessageStore *message_store;
1559
1560 GNUNET_assert ((room) && (discourse));
1561
1562 it.discourse = discourse;
1564
1565 member_store = get_srv_room_member_store (room);
1566
1568
1569 message_store = get_srv_room_message_store (room);
1570
1572 discourse,
1573 it.start);
1574}
1575
1576
1584
1593
1594static enum GNUNET_GenericReturnValue
1596 const struct
1599 session)
1600{
1601 struct GNUNET_MESSENGER_MemberUpdate *update;
1602
1603 GNUNET_assert ((cls) && (session));
1604
1605 if (GNUNET_YES == is_member_session_completed (session))
1606 return GNUNET_YES;
1607
1608 update = cls;
1609
1610 update_member_session_history (session, update->message, update->hash);
1611
1612 if (GNUNET_YES == is_member_session_completed (session))
1613 {
1615
1617
1618 if (! element)
1619 {
1621 "Adding member session completion to queue failed!\n");
1622 return GNUNET_YES;
1623 }
1624
1626 "Add member session completion to queue!\n");
1627
1628 element->session = session;
1629
1630 GNUNET_CONTAINER_DLL_insert_tail (update->head, update->tail, element);
1631 }
1632
1633 return GNUNET_YES;
1634}
1635
1636
1637static void
1640
1641void
1643 const struct GNUNET_MESSENGER_Message *message,
1644 const struct GNUNET_HashCode *hash)
1645{
1646 struct GNUNET_MESSENGER_PeerStore *peer_store;
1647 struct GNUNET_MESSENGER_MemberStore *member_store;
1648 struct GNUNET_MESSENGER_SenderSession session;
1649 enum GNUNET_GenericReturnValue start_handle;
1650
1651 GNUNET_assert ((room) && (message) && (hash));
1652
1653 peer_store = get_srv_room_peer_store (room);
1654 member_store = get_srv_room_member_store (room);
1655
1656 if (GNUNET_YES == is_peer_message (message))
1657 {
1658 session.peer = get_store_peer_of (peer_store, message, hash);
1659
1660 if (! session.peer)
1661 {
1663 "Message handling dropped: Peer is missing!\n");
1664 return;
1665 }
1666 }
1667 else
1668 {
1669 struct GNUNET_MESSENGER_Member *member;
1670 member = get_store_member_of (member_store, message);
1671
1672 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for message (%s)\n",
1673 GNUNET_h2s (hash));
1674
1675 if (! member)
1676 {
1678 "Message handling dropped: Member is missing!\n");
1679 return;
1680 }
1681
1682 session.member = get_member_session_of (member, message, hash);
1683
1684 if (! session.member)
1685 {
1687 "Message handling dropped: Session is missing!\n");
1688 return;
1689 }
1690 }
1691
1692 {
1693 struct GNUNET_MESSENGER_MemberUpdate update;
1694 update.message = message;
1695 update.hash = hash;
1696
1697 update.head = NULL;
1698 update.tail = NULL;
1699
1701 member_store,
1703 &update);
1704
1705 while (update.head)
1706 {
1707 struct GNUNET_MESSENGER_SrvMemberSessionCompletion *element = update.head;
1708
1709 remove_room_member_session (room, element->session);
1710
1711 GNUNET_CONTAINER_DLL_remove (update.head, update.tail, element);
1713 "Remove member session completion from queue!\n");
1714
1715 GNUNET_free (element);
1716 }
1717 }
1718
1719 start_handle = room->handling.head ? GNUNET_NO : GNUNET_YES;
1720
1721 add_to_list_messages (&(room->handling), hash);
1722
1723 switch (message->header.kind)
1724 {
1726 handle_message_join (room, &session, message, hash);
1727 break;
1729 handle_message_leave (room, &session, message, hash);
1730 break;
1732 handle_message_key (room, &session, message, hash);
1733 break;
1735 handle_message_peer (room, &session, message, hash);
1736 break;
1738 handle_message_id (room, &session, message, hash);
1739 break;
1741 handle_message_miss (room, &session, message, hash);
1742 break;
1744 handle_message_delete (room, &session, message, hash);
1745 break;
1747 handle_message_connection (room, &session, message, hash);
1748 break;
1750 handle_message_subscribe (room, &session, message, hash);
1751 break;
1752 default:
1753 break;
1754 }
1755
1756 if (GNUNET_YES == start_handle)
1757 handle_room_messages (room);
1758}
1759
1760
1761void
1763{
1764 char *room_dir;
1765
1766 GNUNET_assert (room);
1767
1768 get_room_data_subdir (room, &room_dir);
1769
1770 if (! room_dir)
1771 return;
1772
1773 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Load room from directory: %s\n",
1774 room_dir);
1775
1777 {
1778 char *peers_file;
1779 GNUNET_asprintf (&peers_file, "%s%s", room_dir, "peers.list");
1780
1781 load_peer_store (get_srv_room_peer_store (room), peers_file);
1782 GNUNET_free (peers_file);
1783
1788
1789 {
1790 char *basement_file;
1791 GNUNET_asprintf (&basement_file, "%s%s", room_dir, "basement.list");
1792
1793 load_list_tunnels (&(room->basement), basement_file);
1794 GNUNET_free (basement_file);
1795 }
1796
1797 load_message_state (&(room->state), room_dir);
1798 }
1799
1800 GNUNET_free (room_dir);
1801}
1802
1803
1804void
1806{
1807 char *room_dir;
1808
1809 GNUNET_assert (room);
1810
1811 if (room->save_task)
1812 {
1814 room->save_task = NULL;
1815 }
1816
1817 get_room_data_subdir (room, &room_dir);
1818
1819 if (! room_dir)
1820 return;
1821
1822 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Save room to directory: %s\n",
1823 room_dir);
1824
1825 if ((GNUNET_YES == GNUNET_DISK_directory_test (room_dir, GNUNET_NO)) ||
1827 {
1828 char *peers_file;
1829 GNUNET_asprintf (&peers_file, "%s%s", room_dir, "peers.list");
1830
1831 save_peer_store (get_srv_room_peer_store (room), peers_file);
1832 GNUNET_free (peers_file);
1833
1838
1839 {
1840 char *basement_file;
1841 GNUNET_asprintf (&basement_file, "%s%s", room_dir, "basement.list");
1842
1843 save_list_tunnels (&(room->basement), basement_file);
1844 GNUNET_free (basement_file);
1845 }
1846
1847 save_message_state (&(room->state), room_dir);
1848 }
1849
1850 GNUNET_free (room_dir);
1851}
1852
1853
1854void
1856{
1857 char *room_dir;
1858
1859 GNUNET_assert (room);
1860
1861 get_room_data_subdir (room, &room_dir);
1862
1863 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Remove room from directory: %s\n",
1864 room_dir);
1865
1868
1869 GNUNET_free (room_dir);
1870}
1871
1872
1873static void
1876{
1877 struct GNUNET_HashCode hash;
1878 char *session_dir;
1879 char *room_dir;
1880
1881 GNUNET_assert ((room) && (session));
1882
1884 "Remove member session from room: %s (%s)\n",
1886 GNUNET_h2s (get_srv_room_key (room)));
1887
1888 remove_member_session (session->member, session);
1889
1890 {
1891 const struct GNUNET_CRYPTO_BlindablePublicKey *public_key;
1892 public_key = get_member_session_public_key (session);
1893
1894 GNUNET_CRYPTO_hash (public_key, sizeof(*public_key), &hash);
1895 }
1896
1897
1898 get_room_data_subdir (room, &room_dir);
1899
1901 &session_dir, "%s%s%c%s%c%s%c%s%c", room_dir,
1902 "members", DIR_SEPARATOR,
1904 "sessions", DIR_SEPARATOR,
1905 GNUNET_h2s (&hash), DIR_SEPARATOR);
1906
1907 GNUNET_free (room_dir);
1908
1909 GNUNET_DISK_directory_remove (session_dir);
1910 GNUNET_free (session_dir);
1911
1912 destroy_member_session (session);
1913}
struct GNUNET_MQ_MessageHandlers handlers[]
Definition 003.c:1
static int forward
Search direction: forward.
Definition gnunet-abd.c:163
static int start
Set if we are to start default services (including ARM).
Definition gnunet-arm.c:38
static int ret
Final status code.
Definition gnunet-arm.c:93
static char * dir
Set to the directory where runtime files are stored.
Definition gnunet-arm.c:88
static uint16_t port
Port number.
Definition gnunet-bcd.c:146
static uint64_t timestamp(void)
Get current timestamp.
struct GNUNET_HashCode key
The key used in the DHT.
static GstElement * source
Appsrc instance into which we write data for the pipeline.
static struct GNUNET_CRYPTO_BlindablePublicKey pubkey
Public key of the zone to look in.
static int reset
Reset argument.
static char * value
Value of the record to add/remove.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static int result
Global testing status.
static void destroy_tunnel(void *cls)
This tunnel is no longer used, destroy it.
static struct GNUNET_CADET_Handle * cadet
Handle for cadet.
enum GNUNET_GenericReturnValue required_connection_between(size_t count, size_t src, size_t dst)
Returns GNUNET_YES or GNUNET_NO to determine if the peers of index src and index dst should be connec...
size_t count_of_tunnels(const struct GNUNET_MESSENGER_ListTunnels *tunnels)
Returns the count of peers in a list (typically from the basement of a room).
enum GNUNET_GenericReturnValue change_srv_handle_member_id(struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, const struct GNUNET_ShortHashCode *unique_id)
Changes the member id of a given handle in a specific room to match a unique_id and returns GNUNET_OK...
void notify_srv_handle_member_id(struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_ShortHashCode *member_id, enum GNUNET_GenericReturnValue reset)
Notifies the handle that a new member id needs to be used.
const struct GNUNET_CRYPTO_BlindablePublicKey * get_srv_handle_key(const struct GNUNET_MESSENGER_SrvHandle *handle)
Returns the public key of a given handle.
void merge_srv_handle_room_to_sync(struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvRoom *room)
Merges the latest hash from a specific room by a given handle until the message graph of the room is ...
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 is_srv_handle_routing(const struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
Returns whether a given handle has enabled routing for a room using a specific key by opening that ro...
void init_list_messages(struct GNUNET_MESSENGER_ListMessages *messages)
Initializes list of message hashes as empty list.
void add_to_list_messages(struct GNUNET_MESSENGER_ListMessages *messages, const struct GNUNET_HashCode *hash)
Adds a specific hash from a message to the end of the list.
const struct GNUNET_ShortHashCode * get_member_id(const struct GNUNET_MESSENGER_Member *member)
Returns the current id of a given member.
struct GNUNET_MESSENGER_SrvMemberSession * get_member_session(const struct GNUNET_MESSENGER_Member *member, const struct GNUNET_CRYPTO_BlindablePublicKey *public_key)
Returns the member session of a member identified by a given public key.
struct GNUNET_MESSENGER_SrvMemberSession * 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_Subscription * get_member_subscription(struct GNUNET_MESSENGER_Member *member, const struct GNUNET_ShortHashCode *discourse)
Returns the active subscription of a given member to a selected discourse.
void remove_member_session(struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSENGER_SrvMemberSession *session)
Removes a given member session from its member.
void update_member_session_history(struct GNUNET_MESSENGER_SrvMemberSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Adds a given message to the history of a session using the messages hash.
void destroy_member_session(struct GNUNET_MESSENGER_SrvMemberSession *session)
Destroys a member session and frees its memory fully.
enum GNUNET_GenericReturnValue is_member_session_completed(const struct GNUNET_MESSENGER_SrvMemberSession *session)
Returns if the given member session has been completed.
const struct GNUNET_ShortHashCode * get_member_session_id(const struct GNUNET_MESSENGER_SrvMemberSession *session)
Returns the member id of a given member session.
const struct GNUNET_CRYPTO_BlindablePublicKey * get_member_session_public_key(const struct GNUNET_MESSENGER_SrvMemberSession *session)
Returns the public key of a given member session.
struct GNUNET_TIME_Absolute get_member_session_start(const struct GNUNET_MESSENGER_SrvMemberSession *session)
Returns the timestamp of the member session's start.
enum GNUNET_GenericReturnValue check_member_session_history(const struct GNUNET_MESSENGER_SrvMemberSession *session, const struct GNUNET_HashCode *hash, enum GNUNET_GenericReturnValue ownership)
Checks the history of a session for a specific message which is identified by its hash and if the own...
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.
int iterate_store_members(struct GNUNET_MESSENGER_MemberStore *store, GNUNET_MESSENGER_MemberIteratorCallback it, void *cls)
Iterate through all member sessions currently connected to the members of the given member store and ...
void save_member_store(struct GNUNET_MESSENGER_MemberStore *store, const char *directory)
Saves members from a member store into a directory.
void load_member_store(struct GNUNET_MESSENGER_MemberStore *store, const char *directory)
Loads members from a directory into a member store.
struct GNUNET_MESSENGER_Member * add_store_member(struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_ShortHashCode *id)
Adds a member to a store under a specific id and returns it on success.
void init_member_store(struct GNUNET_MESSENGER_MemberStore *store, struct GNUNET_MESSENGER_SrvRoom *room)
Initializes a member store as fully empty connected to a room.
void clear_member_store(struct GNUNET_MESSENGER_MemberStore *store)
Clears a member store, wipes its content and deallocates its memory.
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.
void handle_message_id(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SenderSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received or sent id message to change a members id.
void handle_message_delete(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SenderSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received or sent delete message to delete a specific message from the store.
void handle_message_peer(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SenderSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received or sent peer message to make changes of the basement in the room.
void handle_message_join(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SenderSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received or sent join message to make changes of current member information.
void handle_message_key(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SenderSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received or sent key message to change the key of a member and rearrange the contacts accor...
void handle_message_leave(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SenderSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received or sent leave message to make changes of current member information.
void handle_message_subscribe(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SenderSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received or sent subscribe message to subscribe a member to a discourse.
void handle_message_connection(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SenderSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received or sent connection message to update connection information about a peer.
void handle_message_miss(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SenderSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received or sent miss message to drop a peer from the basement in the room.
struct GNUNET_MESSENGER_Message * create_message_info(struct GNUNET_MESSENGER_Service *service)
Creates and allocates a new info message containing the hosts service peer identity and version.
struct GNUNET_MESSENGER_Message * create_message_miss(const struct GNUNET_PeerIdentity *peer)
Creates and allocates a new miss message containing the missing peer identity.
struct GNUNET_MESSENGER_Message * create_message_peer(struct GNUNET_MESSENGER_Service *service)
Creates and allocates a new peer message containing a services peer identity.
struct GNUNET_MESSENGER_Message * create_message_merge(const struct GNUNET_HashCode *previous)
Creates and allocates a new merge message containing the hash of a second previous message besides th...
void send_message_id(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a sent id message to update the handles member id in the room.
void send_message_request(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a sent request message to trigger the request operation for this service.
void send_message_join(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a sent join message to ensure growth of the decentralized room structure.
void send_message_key(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a sent key message to ensure changes to the public key of the sending handle.
void send_message_peer(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a sent peer message to update the rooms peer message of this service.
const struct GNUNET_HashCode * get_message_state_merge_hash(const struct GNUNET_MESSENGER_MessageState *state)
void save_message_state(const struct GNUNET_MESSENGER_MessageState *state, const char *path)
void clear_message_state(struct GNUNET_MESSENGER_MessageState *state)
void get_message_state_chain_hash(const struct GNUNET_MESSENGER_MessageState *state, struct GNUNET_HashCode *hash)
void init_message_state(struct GNUNET_MESSENGER_MessageState *state)
void update_message_state(struct GNUNET_MESSENGER_MessageState *state, enum GNUNET_GenericReturnValue requested, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
void load_message_state(struct GNUNET_MESSENGER_MessageState *state, const char *path)
void save_message_store(struct GNUNET_MESSENGER_MessageStore *store)
Saves messages from a message store into its directory.
enum GNUNET_GenericReturnValue contains_store_message(const struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash)
Checks if a message matching a given hash is stored in a message store.
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.
enum GNUNET_GenericReturnValue put_store_message(struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_Message *message)
Stores a message into the message store.
void clear_message_store(struct GNUNET_MESSENGER_MessageStore *store)
Clears a message store, wipes its content and deallocates its memory.
void cleanup_store_discourse_messages_before(struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_ShortHashCode *discourse, const struct GNUNET_TIME_Absolute timestamp)
Cleans up and deletes all discourse messages existing in the message store memory before a certain ti...
void load_message_store(struct GNUNET_MESSENGER_MessageStore *store)
Loads messages from its directory into a message store.
void init_message_store(struct GNUNET_MESSENGER_MessageStore *store, const char *directory)
Initializes a message store as fully empty using a specific directory.
const struct GNUNET_MESSENGER_MessageLink * get_store_message_link(struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash, enum GNUNET_GenericReturnValue deleted_only)
Returns the message link from a message store matching a given hash.
const struct GNUNET_MESSENGER_Message * get_store_message(struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash)
Returns the message from a message store matching a given hash.
void move_message_store(struct GNUNET_MESSENGER_MessageStore *store, const char *directory)
Moves all storage from a message store from its current directory to a given directory.
void cancel_store_operation(struct GNUNET_MESSENGER_OperationStore *store, const struct GNUNET_HashCode *hash)
Stops any active operation under a given hash in a specific operation store.
void save_operation_store(const struct GNUNET_MESSENGER_OperationStore *store, const char *directory)
Saves operations from an operation store into a directory.
void clear_operation_store(struct GNUNET_MESSENGER_OperationStore *store)
Clears an operation store, stops all operations and deallocates its memory.
void load_operation_store(struct GNUNET_MESSENGER_OperationStore *store, const char *directory)
Loads operations from a directory into an operation store.
enum GNUNET_MESSENGER_OperationType get_store_operation_type(const struct GNUNET_MESSENGER_OperationStore *store, const struct GNUNET_HashCode *hash)
Returns the type of the active operation under a given hash in a specific operation store.
void init_operation_store(struct GNUNET_MESSENGER_OperationStore *store, struct GNUNET_MESSENGER_SrvRoom *room)
Initializes an operation store as fully empty with a given room.
enum GNUNET_GenericReturnValue use_store_operation(struct GNUNET_MESSENGER_OperationStore *store, const struct GNUNET_HashCode *hash, enum GNUNET_MESSENGER_OperationType type, struct GNUNET_TIME_Relative delay)
Tries to use an operation under a given hash in a specific operation store.
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.
void load_peer_store(struct GNUNET_MESSENGER_PeerStore *store, const char *path)
Loads peer identities from a file into a peer store.
void clear_peer_store(struct GNUNET_MESSENGER_PeerStore *store)
Clears a peer store, wipes its content and deallocates its memory.
void save_peer_store(const struct GNUNET_MESSENGER_PeerStore *store, const char *path)
Saves peer identities from a peer store into a file.
void init_peer_store(struct GNUNET_MESSENGER_PeerStore *store, struct GNUNET_MESSENGER_Service *service)
Initializes a peer store as fully empty.
uint32_t get_srv_room_amount_of_tunnels(const struct GNUNET_MESSENGER_SrvRoom *room)
Returns the amount of active tunnels of a given room.
enum GNUNET_GenericReturnValue sign_srv_room_message(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_Message *message, GNUNET_MESSENGER_SignedCallback callback, void *closure)
Packs a message depending on its kind into a newly allocated envelope.
static enum GNUNET_GenericReturnValue iterate_destroy_tunnels(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
const struct GNUNET_MESSENGER_SrvTunnel * get_srv_room_tunnel(const struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_PeerIdentity *peer)
Returns a tunnel inside of a room leading towards a given peer if such a tunnel exists,...
static void get_room_data_subdir(struct GNUNET_MESSENGER_SrvRoom *room, char **dir)
static enum GNUNET_GenericReturnValue join_room(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_Member *member, const struct GNUNET_ShortHashCode *id)
enum GNUNET_GenericReturnValue update_room_message(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
static enum GNUNET_GenericReturnValue iterate_update_member_sessions(void *cls, const struct GNUNET_CRYPTO_BlindablePublicKey *public_key, struct GNUNET_MESSENGER_SrvMemberSession *session)
struct GNUNET_MESSENGER_SrvRoom * create_srv_room(struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
Creates and allocates a new room for a handle with a given key.
void save_srv_room(struct GNUNET_MESSENGER_SrvRoom *room)
Saves the configuration for a given room of a service which contains the last messages hash and the r...
void rebuild_srv_room_basement_structure(struct GNUNET_MESSENGER_SrvRoom *room)
Rebuilds the decentralized structure for a room by ensuring all required connections are made dependi...
struct GNUNET_MESSENGER_MessageStore * get_srv_room_message_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used message store of a given room.
static void * callback_room_connect(void *cls, struct GNUNET_CADET_Channel *channel, const struct GNUNET_PeerIdentity *source)
static enum GNUNET_GenericReturnValue send_room_info(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvTunnel *tunnel)
static enum GNUNET_GenericReturnValue join_room_locally(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle)
enum GNUNET_GenericReturnValue enter_srv_room_at(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_PeerIdentity *door)
Connects a tunnel to a hosting peer of a room through a so called door which is represented by a peer...
struct GNUNET_MESSENGER_PeerStore * get_srv_room_peer_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used peer store of a given room.
static enum GNUNET_GenericReturnValue iterate_cancel_signature(void *cls, const struct GNUNET_HashCode *key, void *value)
static void idle_request_room_messages(void *cls)
static void callback_srv_room_sign_result(void *cls, const struct GNUNET_PeerIdentity *identity, const struct GNUNET_CRYPTO_EddsaSignature *peer_signature)
void check_srv_room_peer_status(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel)
Checks the current state of opening a given room from this peer and re-publishes it if necessary to a...
enum GNUNET_GenericReturnValue delete_srv_room_message(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvMemberSession *session, const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)
Deletes a message from the room with a given hash in a specific delay if the provided member by its s...
void remove_srv_room(struct GNUNET_MESSENGER_SrvRoom *room)
Removes the configuration for a given room of a service.
enum GNUNET_GenericReturnValue open_srv_room(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle)
Tries to open a room for a given handle.
void destroy_srv_room(struct GNUNET_MESSENGER_SrvRoom *room, enum GNUNET_GenericReturnValue deletion)
Destroys a room and frees its memory fully.
void cleanup_srv_room_discourse_messages(struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_ShortHashCode *discourse)
Cleanup discourse messages outside of current subscriptions from a specific discourse of all the memb...
void send_srv_room_envelope(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_MQ_Envelope *envelope, const struct GNUNET_HashCode *hash)
Sends an envelope from a message with a given hash excluding a specific tunnel inside of a room.
uint32_t get_srv_room_connection_flags(const struct GNUNET_MESSENGER_SrvRoom *room)
Returns connection flags about connection information of a given room and the service managing it.
static void remove_room_member_session(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvMemberSession *session)
enum GNUNET_GenericReturnValue merge_srv_room_last_messages(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle)
Reduces all current forks inside of the message history of a room to one remaining last message by me...
enum GNUNET_GenericReturnValue request_srv_room_message(struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_SrvMemberSession *session, GNUNET_MESSENGER_MessageRequestCallback callback, void *cls)
Requests a message from a room identified by a given hash.
static void handle_room_messages(struct GNUNET_MESSENGER_SrvRoom *room)
void callback_room_handle_message(struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
enum GNUNET_GenericReturnValue send_srv_room_message(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_Message *message)
Sends a message from a given handle into a room.
void solve_srv_room_member_collisions(struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_CRYPTO_BlindablePublicKey *public_key, const struct GNUNET_ShortHashCode *member_id, struct GNUNET_TIME_Absolute timestamp)
Checks for potential collisions with member ids and solves them changing active handles ids if they u...
struct GNUNET_MESSENGER_OperationStore * get_srv_room_operation_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used operation store of a given room.
static void close_srv_room(struct GNUNET_MESSENGER_SrvRoom *room)
static enum GNUNET_GenericReturnValue iterate_member_for_subscription(void *cls, const struct GNUNET_CRYPTO_BlindablePublicKey *public_key, struct GNUNET_MESSENGER_SrvMemberSession *session)
static enum GNUNET_GenericReturnValue iterate_send_room_envelope(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
static void callback_srv_room_message_signed(void *cls, struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_Message *message, struct GNUNET_MQ_Envelope *envelope, const struct GNUNET_HashCode *hash)
struct GNUNET_CADET_Handle * get_srv_room_cadet(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the CADET handle from a rooms service.
static enum GNUNET_GenericReturnValue request_room_message_step(struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_SrvMemberSession *session, GNUNET_MESSENGER_MessageRequestCallback callback, void *cls)
const struct GNUNET_HashCode * get_srv_room_key(const struct GNUNET_MESSENGER_SrvRoom *room)
Returns the shared secret you need to access a room.
static void autosave_room_messages(void *cls)
struct GNUNET_MESSENGER_MemberStore * get_srv_room_member_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used member store of a given room.
void load_srv_room(struct GNUNET_MESSENGER_SrvRoom *room)
Loads the local configuration for a given room of a service which contains the last messages hash and...
#define GNUNET_MESSENGER_SAVE_DELAY
#define GNUNET_MESSENGER_MERGE_DELAY
#define GNUNET_MESSENGER_IDLE_DELAY
void() GNUNET_MESSENGER_MessageRequestCallback(void *cls, struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Method called whenever a message is found during a request in a room.
void(* GNUNET_MESSENGER_SignedCallback)(void *cls, struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_Message *message, struct GNUNET_MQ_Envelope *envelope, const struct GNUNET_HashCode *hash)
enum GNUNET_GenericReturnValue get_service_peer_identity(struct GNUNET_MESSENGER_Service *service, struct GNUNET_PeerIdentity *peer)
Tries to write the peer identity of the peer running a service on to the peer parameter.
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...
void forward_tunnel_message(struct GNUNET_MESSENGER_SrvTunnel *tunnel, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Forwards a given message with a known hash through a tunnel.
void send_tunnel_envelope(struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_MQ_Envelope *env, const struct GNUNET_HashCode *hash)
Sends an envelope containing a message with a given hash through a tunnel.
enum GNUNET_GenericReturnValue is_tunnel_connected(const struct GNUNET_MESSENGER_SrvTunnel *tunnel)
Returns the status of a currently bound channel of a tunnel.
void bind_tunnel(struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_CADET_Channel *channel)
Binds a CADET channel to a tunnel and replaces its channel the tunnel is currently bound to if necess...
uint32_t get_tunnel_messenger_version(const struct GNUNET_MESSENGER_SrvTunnel *tunnel)
Returns the current messenger version the peer connected via a given tunnel has reported to be using ...
void callback_tunnel_disconnect(void *cls, const struct GNUNET_CADET_Channel *channel)
Callback for a CADET channel disconnecting to manage this event as a proper tunnel provided as its cl...
struct GNUNET_MESSENGER_SrvTunnel * create_tunnel(struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_PeerIdentity *door)
Creates and allocates a tunnel of a room to a specific peer identity (called door).
void disconnect_tunnel(struct GNUNET_MESSENGER_SrvTunnel *tunnel)
Disconnects and unbinds a channel from a tunnel.
enum GNUNET_GenericReturnValue connect_tunnel(struct GNUNET_MESSENGER_SrvTunnel *tunnel)
Tries to connect a tunnel by creating a new CADET channel and binding it.
enum GNUNET_GenericReturnValue send_tunnel_message(struct GNUNET_MESSENGER_SrvTunnel *tunnel, void *handle, struct GNUNET_MESSENGER_Message *message)
Sends a message by packing it automatically into an envelope and passing it through the tunnel.
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...
void GNUNET_PILS_cancel(struct GNUNET_PILS_Operation *op)
Cancel request.
Definition pils_api.c:776
struct GNUNET_CADET_Port * GNUNET_CADET_open_port(struct GNUNET_CADET_Handle *h, const struct GNUNET_HashCode *port, GNUNET_CADET_ConnectEventHandler connects, void *connects_cls, GNUNET_CADET_WindowSizeEventHandler window_changes, GNUNET_CADET_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Open a port to receive incoming MQ-based channels.
Definition cadet_api.c:966
void GNUNET_CADET_close_port(struct GNUNET_CADET_Port *p)
Close a port opened with GNUNET_CADET_open_port.
Definition cadet_api.c:804
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_remove(const char *filename)
Remove all files in a directory (rm -rf).
Definition disk.c:1140
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_test(const char *fil, int is_readable)
Test if fil is a directory and listable.
Definition disk.c:466
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create(const char *dir)
Implementation of "mkdir -p".
Definition disk.c:573
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition crypto_hash.c:40
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_contains(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Check if the map contains any value under the given key (including values that are NULL).
void * GNUNET_CONTAINER_multipeermap_get(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Given a key find a value in the map matching the key.
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_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
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.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries 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.
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the map.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
unsigned int GNUNET_CONTAINER_multipeermap_size(const struct GNUNET_CONTAINER_MultiPeerMap *map)
Get the number of key-value pairs in the map.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *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_is_zero(a)
Check that memory in a is all zeros.
#define GNUNET_log(kind,...)
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
#define GNUNET_UNUSED
gcc-ism to document unused arguments
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
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_PUBLIC_KEY_TYPE_EDDSA
EDDSA identity.
@ GNUNET_SCHEDULER_PRIORITY_IDLE
Run when otherwise idle.
@ 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
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#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.
#define GNUNET_MESSENGER_VERSION
Version number of GNUnet Messenger API.
@ GNUNET_MESSENGER_KIND_INFO
The info kind.
@ GNUNET_MESSENGER_KIND_MISS
The miss kind.
@ GNUNET_MESSENGER_KIND_REQUEST
The request kind.
@ GNUNET_MESSENGER_KIND_LEAVE
The leave kind.
@ GNUNET_MESSENGER_KIND_PEER
The peer kind.
@ GNUNET_MESSENGER_KIND_KEY
The key kind.
@ GNUNET_MESSENGER_KIND_JOIN
The join kind.
@ GNUNET_MESSENGER_KIND_SUBSCRIBTION
The subscription kind.
@ GNUNET_MESSENGER_KIND_DELETION
The deletion kind.
@ GNUNET_MESSENGER_KIND_CONNECTION
The connection kind.
@ GNUNET_MESSENGER_KIND_MERGE
The merge kind.
@ GNUNET_MESSENGER_KIND_ID
The id kind.
@ GNUNET_MESSENGER_FLAG_CONNECTION_AUTO
The auto flag.
@ GNUNET_MESSENGER_FLAG_CONNECTION_NONE
The none flag.
struct GNUNET_MQ_Envelope * GNUNET_MQ_env_copy(struct GNUNET_MQ_Envelope *env)
Function to copy an envelope.
Definition mq.c:405
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
const struct GNUNET_MessageHeader * GNUNET_MQ_env_get_msg(const struct GNUNET_MQ_Envelope *env)
Obtain message contained in envelope.
Definition mq.c:928
void GNUNET_PEER_resolve(GNUNET_PEER_Id id, struct GNUNET_PeerIdentity *pid)
Convert an interned PID to a normal peer identity.
Definition peer.c:220
#define GNUNET_MESSAGE_TYPE_CADET_CLI
Traffic (net-cat style) used by the Command Line Interface.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition scheduler.c:986
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed_with_priority(struct GNUNET_TIME_Relative delay, enum GNUNET_SCHEDULER_Priority priority, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition scheduler.c:1213
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_with_priority(enum GNUNET_SCHEDULER_Priority prio, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified priority.
Definition scheduler.c:1237
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_zero_(void)
Return relative time of 0ms.
Definition time.c:133
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get_zero_(void)
Return absolute time of 0ms.
Definition time.c:142
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get_forever_(void)
Return "forever".
Definition time.c:205
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition time.c:111
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_forever_(void)
Return "forever".
Definition time.c:196
#define GNUNET_TIME_absolute_cmp(t1, op, t2)
Compare two absolute times.
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
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition time.c:636
static void handle_member_id(void *cls, const struct GNUNET_MESSENGER_MemberMessage *msg)
void load_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels, const char *path)
Loads the list of tunnels peer identities from a file under a given path.
void init_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels)
Initializes list of tunnels peer identities as empty list.
void save_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels, const char *path)
Saves the list of tunnels peer identities to a file under a given path.
enum GNUNET_GenericReturnValue verify_list_tunnels_flag_token(const struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer, enum GNUNET_MESSENGER_ConnectionFlags flag)
Verifies that a specific tunnel selected by its peer identity in a list of tunnels is the first in or...
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...
void encode_message_signature(const struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer)
Encodes the signature of a given message into a buffer of a maximum length in bytes.
struct GNUNET_MQ_Envelope * pack_message(struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash, enum GNUNET_MESSENGER_PackMode mode)
Encodes the message to pack it into a newly allocated envelope if mode is equal to GNUNET_MESSENGER_P...
struct GNUNET_PILS_Operation * sign_message_by_peer(struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, struct GNUNET_PILS_Handle *pils, const GNUNET_PILS_SignResultCallback sign_cb, void *cls)
Signs the hash of a message with the peer identity of a given pils service going into a callback with...
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...
enum GNUNET_GenericReturnValue is_epoch_message(const struct GNUNET_MESSENGER_Message *message)
Returns whether a certain kind of message from storage contains some specific details that might be r...
void destroy_message(struct GNUNET_MESSENGER_Message *message)
Destroys a message and frees its memory fully.
@ GNUNET_MESSENGER_PACK_MODE_ENVELOPE
enum GNUNET_GenericReturnValue generate_free_member_id(struct GNUNET_ShortHashCode *id, const struct GNUNET_CONTAINER_MultiShortmap *members)
Tries to generate an unused member id and store it into the id parameter.
void convert_messenger_key_to_port(const union GNUNET_MESSENGER_RoomKey *key, struct GNUNET_HashCode *port)
Converts a Messenger service key of a room to the specific port which gets used for the CADET channel...
void convert_peer_identity_to_id(const struct GNUNET_PeerIdentity *identity, struct GNUNET_ShortHashCode *id)
Converts a peers identity to a short hash code which can be used as id to refer to a peer via sender ...
void delayed_disconnect_channel(struct GNUNET_CADET_Channel *channel)
Starts an urgent task to close a CADET channel asynchronously.
#define DIR_SEPARATOR
Definition platform.h:166
Opaque handle to a channel.
Definition cadet.h:116
Opaque handle to the service.
Definition cadet_api.c:39
struct GNUNET_CRYPTO_EddsaSignature eddsa_signature
AN EdDSA signature.
An identity key as per LSD0001.
an ECC signature using EdDSA.
A 512-bit hashcode.
struct GNUNET_MESSENGER_SrvTunnel * exclude
struct GNUNET_MESSENGER_ListHandle * next
struct GNUNET_MESSENGER_SrvHandle * handle
struct GNUNET_MESSENGER_ListHandle * head
struct GNUNET_MESSENGER_ListMessage * head
struct GNUNET_MESSENGER_ListMessage * tail
struct GNUNET_MESSENGER_ListTunnel * next
struct GNUNET_MESSENGER_ListTunnel * head
struct GNUNET_CONTAINER_MultiShortmap * members
struct GNUNET_MESSENGER_SrvMemberSessionCompletion * tail
const struct GNUNET_MESSENGER_Message * message
struct GNUNET_MESSENGER_SrvMemberSessionCompletion * head
struct GNUNET_CONTAINER_MultiHashMap * sessions
struct GNUNET_MESSENGER_MessageMerge merge
struct GNUNET_HashCode previous
The hash of the previous message from the senders perspective.
struct GNUNET_CRYPTO_BlindableKeySignature signature
The signature of the senders private key.
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_HashCode previous
The hash of a second previous message.
struct GNUNET_HashCode epochs[2]
The previous epochs the message was sent from.
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_MESSENGER_MessageBody body
Body.
struct GNUNET_MESSENGER_SrvMemberSession * member
enum GNUNET_GenericReturnValue auto_routing
struct GNUNET_MESSENGER_ListHandles handles
struct GNUNET_MESSENGER_SrvMemberSessionCompletion * prev
struct GNUNET_MESSENGER_SrvMemberSessionCompletion * next
struct GNUNET_MESSENGER_SrvMemberSession * session
struct GNUNET_CRYPTO_BlindablePublicKey public_key
struct GNUNET_MESSENGER_SrvRoom * room
struct GNUNET_MESSENGER_Message * message
struct GNUNET_MESSENGER_PeerStore peer_store
struct GNUNET_CONTAINER_MultiPeerMap * tunnels
struct GNUNET_MESSENGER_MemberStore member_store
struct GNUNET_MESSENGER_Service * service
struct GNUNET_MESSENGER_SrvHandle * sync
struct GNUNET_MESSENGER_ListTunnels basement
struct GNUNET_MESSENGER_MessageStore message_store
struct GNUNET_SCHEDULER_Task * save_task
struct GNUNET_MESSENGER_MessageState state
struct GNUNET_SCHEDULER_Task * idle_task
struct GNUNET_MESSENGER_ListMessages handling
struct GNUNET_MESSENGER_OperationStore operation_store
struct GNUNET_MESSENGER_SrvHandle * host
struct GNUNET_CONTAINER_MultiHashMap * signatures
struct GNUNET_CADET_Channel * channel
struct GNUNET_MESSENGER_SrvRoom * room
Message handler for a specific message type.
Header for all communications.
The identity of the host (wraps the signing key of the peer).
A 256-bit hashcode.
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.
A room key unifies a room key code and its 512bit hash representation.