GNUnet debian-0.24.3-24-gfea921bd2
gnunet-service-messenger_room.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2020--2025 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
26#include "gnunet_common.h"
28#include "platform.h"
30
41
42#include "messenger_api_util.h"
43
44static void
46
47static void
49 char **dir)
50{
51 GNUNET_assert ((room) && (dir));
52
53 if (room->service->dir)
54 GNUNET_asprintf (dir, "%s%s%c%s%c", room->service->dir, "rooms",
57 else
58 *dir = NULL;
59}
60
61
64 const struct GNUNET_HashCode *key)
65{
66 struct GNUNET_MESSENGER_SrvRoom *room;
67 char *room_dir;
68
69 GNUNET_assert ((handle) && (key));
70
71 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Create new room: %s\n",
72 GNUNET_h2s (key));
73
75
76 room->service = handle->service;
77 room->host = handle;
78 room->port = NULL;
79
80 GNUNET_memcpy (&(room->key), key, sizeof(struct GNUNET_HashCode));
81
83
84 get_room_data_subdir (room, &room_dir);
85
90
91 GNUNET_free (room_dir);
92
93 init_list_tunnels (&(room->basement));
94 init_message_state (&(room->state));
95
96 room->peer_message = NULL;
97
99 room->idle = NULL;
100
101 if (room->service->dir)
102 load_srv_room (room);
103
106
107 return room;
108}
109
110
113 const struct GNUNET_PeerIdentity *key,
114 void *value)
115{
116 struct GNUNET_MESSENGER_SrvTunnel *tunnel;
117
119
120 tunnel = value;
121
122 destroy_tunnel (tunnel);
123 return GNUNET_YES;
124}
125
126
127static void
129
130static void
132
133void
135 enum GNUNET_GenericReturnValue deletion)
136{
138
139 if (room->idle)
140 {
142 room->idle = NULL;
143 }
144
146
148 NULL);
150
151 if (! (room->service->dir))
152 goto skip_saving;
153
154 if (GNUNET_YES == deletion)
156 else
158
159skip_saving:
164
168
169 if (room->peer_message)
171
172 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Free room: %s\n",
173 GNUNET_h2s (&(room->key)));
174
176}
177
178
181{
182 GNUNET_assert (room);
183
184 return &(room->peer_store);
185}
186
187
190{
192
193 return &(room->member_store);
194}
195
196
199{
200 GNUNET_assert (room);
201
202 return &(room->message_store);
203}
204
205
208{
210
211 return &(room->operation_store);
212}
213
214
218 struct GNUNET_MESSENGER_SrvTunnel *tunnel)
219{
220 if ((! handle) || (! is_tunnel_connected (tunnel)))
221 return GNUNET_NO;
222
224 room->service));
225}
226
227
228static void*
230 struct GNUNET_CADET_Channel *channel,
231 const struct GNUNET_PeerIdentity *source)
232{
233 struct GNUNET_MESSENGER_SrvRoom *room;
234 struct GNUNET_MESSENGER_SrvTunnel *tunnel;
235
236 GNUNET_assert ((cls) && (channel) && (source));
237
238 room = cls;
239
241 "New incoming connection to room (%s) from peer: %s\n",
243
244 tunnel = create_tunnel (room, source);
245
246 if ((tunnel) &&
248 tunnel,
250 {
251 destroy_tunnel (tunnel);
252 tunnel = NULL;
253 }
254
255 if (! tunnel)
256 {
258 return NULL;
259 }
260
261 bind_tunnel (tunnel, channel);
262
264 "New tunnel in room (%s) established to peer: %s\n",
266
267 if (GNUNET_YES == send_room_info (room, room->host, tunnel))
268 return tunnel;
269
270 disconnect_tunnel (tunnel);
271
273 tunnel))
274 destroy_tunnel (tunnel);
275
276 return NULL;
277}
278
279
283 struct GNUNET_MESSENGER_Member *member,
284 const struct GNUNET_ShortHashCode *id)
285{
286 const struct GNUNET_ShortHashCode *member_id;
287
288 GNUNET_assert ((room) && (handle) && (member));
289
290 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Joining room: %s (%s)\n", GNUNET_h2s (
291 get_srv_room_key (room)),
292 GNUNET_sh2s (get_member_id (member)));
293
294 member_id = get_member_id (member);
295
297 member_id))
298 return GNUNET_NO;
299
300 {
302 if ((! id) || (0 != GNUNET_memcmp (id, member_id)))
304 else
306
307 notify_srv_handle_member_id (handle, room, member_id, reset);
308 }
309
310 return GNUNET_YES;
311}
312
313
317{
318 struct GNUNET_MESSENGER_MemberStore *member_store;
319 const struct GNUNET_ShortHashCode *member_id;
320 struct GNUNET_MESSENGER_Member *member;
321
322 member_store = get_srv_room_member_store (room);
324 member = add_store_member (member_store, member_id);
325
326 if (GNUNET_NO == join_room (room, handle, member, member_id))
327 return GNUNET_NO;
328
329 return GNUNET_YES;
330}
331
332
336{
337 GNUNET_assert (room);
338
339 if (handle)
340 room->host = handle;
341
342 if (room->port)
343 {
345 "Port of room (%s) was already open!\n",
347
348 if (! handle)
349 return GNUNET_YES;
350
351 return join_room_locally (room, handle);
352 }
353
354 {
357 struct GNUNET_HashCode port;
358
360 tunnel_message,
362 struct
364 ,
366
367 cadet = get_srv_room_cadet (room);
368
370 &(key.hash),
371 get_srv_room_key (room),
372 sizeof (key.hash));
373
374 if ((key.code.feed_bit) && (! key.code.group_bit))
375 {
377 "Opening port of personal room containing private feeds failed!");
378 return GNUNET_SYSERR;
379 }
380
382 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to open CADET port: %s\n",
383 GNUNET_h2s (&port));
384
386 room, NULL, callback_tunnel_disconnect,
387 handlers);
388 }
389
390 if (room->port)
391 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Port of room (%s) was opened!\n",
393 else
395 "Port of room (%s) could not be opened!\n",
397
398 if (! handle)
399 goto complete_opening;
400
401 {
402 struct GNUNET_MESSENGER_MemberStore *member_store;
403 const struct GNUNET_ShortHashCode *member_id;
404 struct GNUNET_MESSENGER_Member *member;
405
406 member_store = get_srv_room_member_store (room);
408 member = add_store_member (member_store, member_id);
409
410 if ((GNUNET_NO == join_room (room, handle, member, member_id)) &&
411 (room->port))
412 {
414 "You could not join the room, therefore it keeps closed!\n");
415
416 close_srv_room (room);
417 return GNUNET_NO;
418 }
419 }
420
421complete_opening:
422 if (! room->port)
423 return GNUNET_NO;
424
425 {
426 struct GNUNET_MESSENGER_Message *message;
427 message = create_message_peer (room->service);
428
429 if (! message)
430 {
432 "Peer message could not be sent!\n");
433 return GNUNET_NO;
434 }
435
436 return send_srv_room_message (room, handle, message);
437 }
438}
439
440
441static void
443{
444 struct GNUNET_PeerIdentity peer;
445
446 GNUNET_assert (room);
447
448 if (! room->port)
449 return;
450
451 if ((room->peer_message) &&
452 (GNUNET_OK == get_service_peer_identity (room->service, &peer)))
453 {
454 struct GNUNET_MESSENGER_Message *message;
455
456 message = create_message_miss (&peer);
457
458 if (! message)
460 "Sending miss message about peer failed: %s\n",
461 GNUNET_h2s (&(room->key)));
462 else
463 send_srv_room_message (room, room->host, message);
464 }
465
467 room->port = NULL;
468}
469
470
474 const struct GNUNET_PeerIdentity *door)
475{
476 struct GNUNET_PeerIdentity peer;
477 struct GNUNET_MESSENGER_SrvTunnel *tunnel;
478
479 GNUNET_assert ((room) && (handle) && (door));
480
482 (0 == GNUNET_memcmp (&peer, door)))
483 return join_room_locally (room, handle);
484
486
487 if (! tunnel)
488 {
489 tunnel = create_tunnel (room, door);
490
492 tunnel,
494 {
496 "You could not connect to that door!\n");
497 destroy_tunnel (tunnel);
498 return GNUNET_NO;
499 }
500 }
501
502 if (GNUNET_SYSERR == connect_tunnel (tunnel))
503 {
505 "Connection failure during entrance!\n");
507 destroy_tunnel (tunnel);
508 return GNUNET_NO;
509 }
510
511 return join_room_locally (room, handle);
512}
513
514
515static void
517 struct GNUNET_MESSENGER_Message *message,
518 uint16_t length,
519 char *buffer,
520 const struct GNUNET_HashCode *hash)
521{
522 const struct GNUNET_MESSENGER_Service *service;
523
524 GNUNET_assert ((cls) && (message) && (buffer) && (hash));
525
526 service = cls;
527
528 if (! service->config)
529 {
531 "Signing message by peer identity failed!\n");
532 return;
533 }
534
535 sign_message_by_peer (message, length, buffer, hash, service->config);
536}
537
538
539struct GNUNET_MQ_Envelope*
541 struct GNUNET_MESSENGER_Message *message,
542 struct GNUNET_HashCode *hash,
544{
545 struct GNUNET_PeerIdentity peer;
546
547 GNUNET_assert ((room) && (message) && (hash));
548
549 if (GNUNET_YES != is_peer_message (message))
550 return pack_message (message, hash, NULL, mode, NULL);
551
552 if (GNUNET_YES == is_epoch_message (message))
555 else
558
559 if (GNUNET_OK != get_service_peer_identity (room->service, &peer))
560 return NULL;
561
562 convert_peer_identity_to_id (&peer, &(message->header.sender_id));
563 get_message_state_chain_hash (&(room->state), &(message->header.previous));
564
566 {
567 const struct GNUNET_MESSENGER_MessageStore *store;
568 const struct GNUNET_HashCode *epoch;
569
570 store = get_srv_room_message_store (room);
571 epoch = get_store_message_epoch (store, &(message->header.previous));
572
573 if (epoch)
574 GNUNET_memcpy (&(message->body.merge.epochs[0]), epoch,
575 sizeof (struct GNUNET_HashCode));
576
577 epoch = get_store_message_epoch (store, &(message->body.merge.previous));
578
579 if (epoch)
580 GNUNET_memcpy (&(message->body.merge.epochs[1]), epoch,
581 sizeof (struct GNUNET_HashCode));
582 }
583
585 "Packing message with peer signature: %s\n",
586 GNUNET_sh2s (&(message->header.sender_id)));
587
589 return pack_message (message, hash, sign_srv_room_message_by_peer, mode,
590 room->service);
591}
592
593
595{
602};
603
606 const struct GNUNET_PeerIdentity *key,
607 void *value)
608{
609 struct GNUNET_MESSENGER_SrvTunnel *tunnel;
610 struct GNUNET_MESSENGER_ClosureSendRoom *closure;
611 struct GNUNET_MQ_Envelope *env;
612
613 GNUNET_assert ((cls) && (value));
614
615 tunnel = value;
616
617 if ((! is_tunnel_connected (tunnel)) ||
619 return GNUNET_YES;
620
621 closure = cls;
622
623 if (tunnel == closure->exclude)
624 return GNUNET_YES;
625
626 env = NULL;
627
628 if (closure->packed == GNUNET_NO)
629 {
630 env = pack_srv_room_message (closure->room,
631 closure->message,
632 closure->hash,
634
635 if (env)
636 closure->packed = GNUNET_YES;
637 }
638 else
639 env = pack_message (closure->message, NULL, NULL,
641
642 if (env)
643 send_tunnel_envelope (tunnel, env, closure->hash);
644
645 return GNUNET_YES;
646}
647
648
651 struct GNUNET_MESSENGER_Message *message,
652 const struct GNUNET_HashCode *hash);
653
654void
656 const struct GNUNET_MESSENGER_Message *message,
657 const struct GNUNET_HashCode *hash);
658
662 struct GNUNET_MESSENGER_Message *message)
663{
664 struct GNUNET_HashCode hash;
665
666 GNUNET_assert ((room) && (handle));
667
668 if (! message)
669 return GNUNET_NO;
670
672 "Sending message from handle in room: %s (%s)\n",
673 GNUNET_h2s (&(room->key)),
675
676 {
678
679 closure.room = room;
680 closure.handle = handle;
681 closure.exclude = NULL;
682 closure.message = message;
683 closure.hash = &hash;
684 closure.packed = GNUNET_NO;
685
687 iterate_send_room_message, &closure);
688
689 if (GNUNET_NO == closure.packed)
692 }
693
694 {
695 enum GNUNET_GenericReturnValue new_message;
696 new_message = update_room_message (room, message, &hash);
697
698 if (GNUNET_YES != new_message)
699 {
701 "Sending duplicate message failed!\n");
702 return GNUNET_SYSERR;
703 }
704 }
705
706 switch (message->header.kind)
707 {
710 break;
713 break;
716 break;
719 break;
722 break;
723 default:
724 break;
725 }
726
728 return GNUNET_YES;
729}
730
731
732void
734 struct GNUNET_MESSENGER_SrvTunnel *tunnel,
736 const struct GNUNET_HashCode *hash)
737{
739 struct GNUNET_HashCode message_hash;
740
741 GNUNET_assert ((room) && (tunnel));
742
743 if (! message)
744 return;
745
746 GNUNET_memcpy (&message_hash, hash, sizeof(struct GNUNET_HashCode));
747
748 closure.room = room;
749 closure.handle = NULL;
750 closure.exclude = tunnel;
751 closure.message = message;
752 closure.hash = &message_hash;
753 closure.packed = GNUNET_YES;
754
756 iterate_send_room_message, &closure);
757}
758
759
760void
762 struct GNUNET_MESSENGER_SrvTunnel *tunnel)
763{
764 struct GNUNET_MESSENGER_MessageStore *message_store;
765 const struct GNUNET_MESSENGER_Message *message;
766
767 if (! room->peer_message)
768 return;
769
770 message_store = get_srv_room_message_store (room);
771 message = get_store_message (message_store, room->peer_message);
772
773 if (! message)
774 {
776 room->peer_message = NULL;
777 return;
778 }
779
780 if (tunnel)
781 forward_tunnel_message (tunnel, message, room->peer_message);
782}
783
784
785void
788{
789 const struct GNUNET_HashCode *hash;
790
791 GNUNET_assert (room);
792
793 if (! handle)
794 return;
795
797 "Merging messages by handle in room: %s\n",
798 GNUNET_h2s (&(room->key)));
799
800 do
801 {
802 struct GNUNET_MESSENGER_Message *message;
803
804 hash = get_message_state_merge_hash (&(room->state));
805
806 if ((! hash) || (GNUNET_is_zero (hash)))
807 break;
808
809 message = create_message_merge (hash);
810
811 if (! message)
812 {
814 "Merging messages failed: %s\n",
815 GNUNET_h2s (&(room->key)));
816 }
817
818 send_srv_room_message (room, handle, message);
819 }
820 while (hash);
821}
822
823
826 struct GNUNET_MESSENGER_MemberSession *session,
827 const struct GNUNET_HashCode *hash,
828 const struct GNUNET_TIME_Relative delay)
829{
830 const struct GNUNET_MESSENGER_Message *message;
831 struct GNUNET_TIME_Relative forever;
832
833 GNUNET_assert ((room) && (session) && (hash));
834
836
837 if (0 == GNUNET_memcmp (&forever, &delay))
838 {
840 "Deletion is delayed forever: operation is impossible!\n");
841 return GNUNET_SYSERR;
842 }
843
844 {
845 struct GNUNET_MESSENGER_MessageStore *message_store;
846
847 message_store = get_srv_room_message_store (room);
848 message = get_store_message (message_store, hash);
849 }
850
851 if (! message)
852 return GNUNET_YES;
853
854 if (GNUNET_YES != check_member_session_history (session, hash, GNUNET_YES))
855 {
857 "Unpermitted request for deletion by member (%s) of message (%s)!\n",
859 hash));
860
861 return GNUNET_NO;
862 }
863
864 {
865 struct GNUNET_MESSENGER_OperationStore *operation_store;
866
867 operation_store = get_srv_room_operation_store (room);
868
869 if (GNUNET_OK != use_store_operation (operation_store, hash,
871 {
873 "Deletion has failed: operation denied!\n");
874 return GNUNET_SYSERR;
875 }
876 }
877
878 return GNUNET_YES;
879}
880
881
884{
885 GNUNET_assert (room);
886
887 return room->service->cadet;
888}
889
890
891const struct GNUNET_HashCode*
893{
894 GNUNET_assert (room);
895
896 return &(room->key);
897}
898
899
900const struct GNUNET_MESSENGER_SrvTunnel*
902 const struct GNUNET_PeerIdentity *peer)
903{
904 GNUNET_assert ((room) && (peer));
905
907}
908
909
912 const struct GNUNET_HashCode *hash,
913 const struct GNUNET_MESSENGER_MemberSession *session,
915 void *cls)
916{
917 struct GNUNET_MESSENGER_MessageStore *message_store;
918 const struct GNUNET_MESSENGER_MessageLink *link;
919 const struct GNUNET_MESSENGER_Message *message;
920
921 GNUNET_assert ((room) && (hash) && (session));
922
923 message_store = get_srv_room_message_store (room);
924 link = get_store_message_link (message_store, hash, GNUNET_YES);
925
926 if (! link)
927 goto forward;
928
930 "Requesting link of message with hash: %s\n",
931 GNUNET_h2s (hash));
932
933 {
935 result = request_room_message_step (room, &(link->first), session,
936 callback, cls);
937
938 if ((GNUNET_YES == link->multiple) &&
939 (GNUNET_YES == request_room_message_step (room, &(link->second),
940 session, callback, cls)))
941 return GNUNET_YES;
942 else
943 return result;
944 }
945
946forward:
947 message = get_store_message (message_store, hash);
948
949 if (! message)
950 {
952 "Requested message is missing in local storage: %s\n",
953 GNUNET_h2s (hash));
954 return GNUNET_NO;
955 }
956
957 if (GNUNET_YES == is_epoch_message (message))
958 goto skip_member_session;
959
960 if (GNUNET_YES != check_member_session_history (session, hash, GNUNET_NO))
961 {
963 "Unpermitted request for access by member (%s) of message (%s)!\n",
965 GNUNET_h2s (hash));
966 return GNUNET_YES;
967 }
968
969skip_member_session:
970 if (callback)
971 callback (cls, room, message, hash);
972
973 return GNUNET_YES;
974}
975
976
979 const struct GNUNET_HashCode *hash,
980 const struct GNUNET_MESSENGER_MemberSession *session,
982 void *cls)
983{
985
986 GNUNET_assert ((room) && (hash));
987
988 result = request_room_message_step (room, hash, session, callback, cls);
989
990 if ((GNUNET_NO == result) && (callback))
991 callback (cls, room, NULL, hash);
992
993 return result;
994}
995
996
997static void
999{
1000 struct GNUNET_MESSENGER_SrvRoom *room;
1001 struct GNUNET_MESSENGER_OperationStore *operation_store;
1002 const struct GNUNET_HashCode *hash;
1003
1004 GNUNET_assert (cls);
1005
1006 room = cls;
1007 room->idle = NULL;
1008
1009 operation_store = get_srv_room_operation_store (room);
1010 hash = get_message_state_merge_hash (&(room->state));
1011
1012 if ((hash) && (! GNUNET_is_zero (hash)) &&
1014 hash)))
1016 operation_store,
1017 hash,
1020
1025 cls);
1026}
1027
1028
1029void
1031 const struct
1032 GNUNET_CRYPTO_PublicKey *public_key,
1033 const struct GNUNET_ShortHashCode *member_id,
1035{
1036 struct GNUNET_MESSENGER_MemberStore *member_store;
1037 struct GNUNET_MESSENGER_Member *member;
1038 struct GNUNET_MESSENGER_ListHandles *handles;
1039 struct GNUNET_MESSENGER_ListHandle *element;
1040
1041 GNUNET_assert ((room) && (public_key) && (member_id));
1042
1043 member_store = get_srv_room_member_store (room);
1044 member = get_store_member (member_store, member_id);
1045
1046 if ((! member) || (1 >= GNUNET_CONTAINER_multihashmap_size (
1047 member->sessions)))
1048 return;
1049
1050 handles = &(room->service->handles);
1051
1052 for (element = handles->head; element; element = element->next)
1053 {
1054 const struct GNUNET_CRYPTO_PublicKey *pubkey;
1055 struct GNUNET_MESSENGER_MemberSession *session;
1056
1057 if (0 != GNUNET_memcmp (member_id, get_srv_handle_member_id (
1058 element->handle, get_srv_room_key (room))))
1059 continue;
1060
1061 pubkey = get_srv_handle_key (element->handle);
1062
1063 if (0 == GNUNET_memcmp (public_key, pubkey))
1064 continue;
1065
1066 session = get_member_session (member, pubkey);
1067
1068 if (! session)
1069 continue;
1070
1071 {
1073 start = get_member_session_start (session);
1074
1075 if (GNUNET_TIME_relative_get_zero_ ().rel_value_us !=
1077 continue;
1078 }
1079
1080 {
1081 struct GNUNET_ShortHashCode random_id;
1082 generate_free_member_id (&random_id, member_store->members);
1083
1085 element->handle,
1086 room,
1087 &random_id,
1088 GNUNET_NO);
1089 }
1090 }
1091}
1092
1093
1094void
1096{
1097 struct GNUNET_MESSENGER_ListTunnel *element;
1098 struct GNUNET_PeerIdentity peer;
1099 size_t count;
1100 size_t src;
1101 size_t dst;
1102
1103 GNUNET_assert (room);
1104
1105 if (GNUNET_OK != get_service_peer_identity (room->service, &peer))
1106 return;
1107
1108 count = count_of_tunnels (&(room->basement));
1109
1110 if (! find_list_tunnels (&(room->basement), &peer, &src))
1111 return;
1112
1113 if ((count > room->service->min_routers) &&
1114 (GNUNET_NO == is_srv_handle_routing (room->host, &(room->key))) &&
1116 &peer,
1118 {
1119 close_srv_room (room);
1120 return;
1121 }
1122
1123 element = room->basement.head;
1124 dst = 0;
1125
1126 while (element)
1127 {
1128 struct GNUNET_MESSENGER_SrvTunnel *tunnel;
1129
1130 GNUNET_PEER_resolve (element->peer, &peer);
1131
1133
1134 if (! tunnel)
1135 {
1136 element = remove_from_list_tunnels (&(room->basement), element);
1137 continue;
1138 }
1139
1140 if (GNUNET_YES == required_connection_between (count, src, dst))
1141 {
1142 if (GNUNET_SYSERR == connect_tunnel (tunnel))
1143 {
1144 element = remove_from_list_tunnels (&(room->basement), element);
1145 continue;
1146 }
1147 }
1148 else
1149 disconnect_tunnel (tunnel);
1150
1151 element = element->next;
1152 dst++;
1153 }
1154}
1155
1156
1157uint32_t
1159{
1161
1163}
1164
1165
1166uint32_t
1168{
1169 uint32_t flags;
1170
1172
1174
1177
1178 return flags;
1179}
1180
1181
1182static void
1184{
1185 struct GNUNET_MESSENGER_MessageStore *message_store;
1186 struct GNUNET_MESSENGER_MemberStore *member_store;
1187 struct GNUNET_MESSENGER_PeerStore *peer_store;
1188 const struct GNUNET_HashCode *key;
1189
1190 message_store = get_srv_room_message_store (room);
1191 member_store = get_srv_room_member_store (room);
1192 peer_store = get_srv_room_peer_store (room);
1193
1194 key = get_srv_room_key (room);
1195
1197 "Handling room messages: %s\n", GNUNET_h2s (key));
1198
1199 while (room->handling.head)
1200 {
1201 struct GNUNET_MESSENGER_ListMessage *element;
1202 struct GNUNET_MESSENGER_SenderSession session;
1203 const struct GNUNET_MESSENGER_Message *message;
1204 const struct GNUNET_HashCode *epoch;
1205
1206 element = room->handling.head;
1207 message = get_store_message (
1208 message_store, &(element->hash));
1209
1210 if (! message)
1211 goto finish_handling;
1212
1213 if (GNUNET_YES == is_peer_message (message))
1214 {
1215 session.peer = get_store_peer_of (peer_store, message, &(element->hash));
1216
1217 if (! session.peer)
1218 goto finish_handling;
1219 }
1220 else
1221 {
1222 struct GNUNET_MESSENGER_Member *member;
1223
1224 member = get_store_member_of (member_store, message);
1225
1226 if (! member)
1227 goto finish_handling;
1228
1229 session.member = get_member_session_of (member, message,
1230 &(element->hash));
1231
1232 if (! session.member)
1233 goto finish_handling;
1234 }
1235
1236 epoch = get_store_message_epoch (message_store, &(element->hash));
1237
1238 handle_service_message (room->service, room, &session, message,
1239 &(element->hash), epoch, GNUNET_YES);
1240
1241finish_handling:
1243 element);
1244 GNUNET_free (element);
1245 }
1246}
1247
1248
1251 struct GNUNET_MESSENGER_Message *message,
1252 const struct GNUNET_HashCode *hash)
1253{
1254 struct GNUNET_MESSENGER_OperationStore *operation_store;
1255 struct GNUNET_MESSENGER_MessageStore *message_store;
1256 enum GNUNET_GenericReturnValue requested;
1257
1258 GNUNET_assert ((room) && (message) && (hash));
1259
1260 operation_store = get_srv_room_operation_store (room);
1261
1262 requested = (GNUNET_MESSENGER_OP_REQUEST ==
1263 get_store_operation_type (operation_store, hash)?
1265
1266 if (GNUNET_YES == requested)
1267 cancel_store_operation (operation_store, hash);
1268
1269 message_store = get_srv_room_message_store (room);
1270
1271 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Handle a message in room (%s).\n",
1272 GNUNET_h2s (get_srv_room_key (room)));
1273
1274 if (GNUNET_YES == contains_store_message (message_store, hash))
1275 {
1276 destroy_message (message);
1277
1278 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Duplicate message got dropped!\n");
1279 return GNUNET_NO;
1280 }
1281
1282 if (GNUNET_OK != put_store_message (message_store, hash, message))
1283 {
1284 destroy_message (message);
1285
1286 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Storing message failed!\n");
1287 return GNUNET_NO;
1288 }
1289
1290 update_message_state (&(room->state), requested, message, hash);
1291
1292 if ((GNUNET_YES == requested) ||
1293 (GNUNET_MESSENGER_KIND_INFO == message->header.kind) ||
1295 return GNUNET_YES;
1296
1297 if ((GNUNET_MESSENGER_KIND_MERGE == message->header.kind) &&
1299 &(message->body.
1300 merge.previous))
1301 ))
1302 cancel_store_operation (operation_store, &(message->body.merge.previous));
1303
1305 &(message->header.
1306 previous)))
1307 cancel_store_operation (operation_store, &(message->header.previous));
1308
1309 return GNUNET_YES;
1310}
1311
1312
1314{
1317};
1318
1319static enum GNUNET_GenericReturnValue
1321 const struct GNUNET_CRYPTO_PublicKey *
1322 public_key,
1323 struct GNUNET_MESSENGER_MemberSession *session)
1324{
1326 struct GNUNET_MESSENGER_Member *member;
1327 struct GNUNET_MESSENGER_Subscription *subscription;
1328
1329 GNUNET_assert ((cls) && (session));
1330
1331 it = cls;
1332 member = session->member;
1333
1334 subscription = get_member_subscription (member, it->discourse);
1335 if (! subscription)
1336 return GNUNET_YES;
1337
1338 if (GNUNET_TIME_absolute_cmp (subscription->start, <, it->start))
1339 it->start = subscription->start;
1340
1341 return GNUNET_YES;
1342}
1343
1344
1345void
1347 const struct GNUNET_ShortHashCode *
1348 discourse)
1349{
1351 struct GNUNET_MESSENGER_MemberStore *member_store;
1352 struct GNUNET_MESSENGER_MessageStore *message_store;
1353
1354 GNUNET_assert ((room) && (discourse));
1355
1356 it.discourse = discourse;
1358
1359 member_store = get_srv_room_member_store (room);
1360
1362
1363 message_store = get_srv_room_message_store (room);
1364
1366 discourse,
1367 it.start);
1368}
1369
1370
1372{
1375
1377};
1378
1380{
1382 const struct GNUNET_HashCode *hash;
1383
1386};
1387
1388static enum GNUNET_GenericReturnValue
1390 const struct
1391 GNUNET_CRYPTO_PublicKey *public_key,
1393{
1394 struct GNUNET_MESSENGER_MemberUpdate *update;
1395
1396 GNUNET_assert ((cls) && (session));
1397
1398 update = cls;
1399
1400 update_member_session_history (session, update->message, update->hash);
1401
1402 if (GNUNET_YES == is_member_session_completed (session))
1403 {
1405
1407 "Add member session completion to queue!\n");
1408
1410 element->session = session;
1411
1412 GNUNET_CONTAINER_DLL_insert_tail (update->head, update->tail, element);
1413 }
1414
1415 return GNUNET_YES;
1416}
1417
1418
1419static void
1422
1423void
1425 const struct GNUNET_MESSENGER_Message *message,
1426 const struct GNUNET_HashCode *hash)
1427{
1428 struct GNUNET_MESSENGER_PeerStore *peer_store;
1429 struct GNUNET_MESSENGER_MemberStore *member_store;
1430 struct GNUNET_MESSENGER_SenderSession session;
1431 enum GNUNET_GenericReturnValue start_handle;
1432
1433 GNUNET_assert ((room) && (message) && (hash));
1434
1435 peer_store = get_srv_room_peer_store (room);
1436 member_store = get_srv_room_member_store (room);
1437
1438 if (GNUNET_YES == is_peer_message (message))
1439 {
1440 session.peer = get_store_peer_of (peer_store, message, hash);
1441
1442 if (! session.peer)
1443 {
1445 "Message handling dropped: Peer is missing!\n");
1446 return;
1447 }
1448 }
1449 else
1450 {
1451 struct GNUNET_MESSENGER_Member *member;
1452 member = get_store_member_of (member_store, message);
1453
1454 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for message (%s)\n",
1455 GNUNET_h2s (hash));
1456
1457 if (! member)
1458 {
1460 "Message handling dropped: Member is missing!\n");
1461 return;
1462 }
1463
1464 session.member = get_member_session_of (member, message, hash);
1465
1466 if (! session.member)
1467 {
1469 "Message handling dropped: Session is missing!\n");
1470 return;
1471 }
1472 }
1473
1474 {
1475 struct GNUNET_MESSENGER_MemberUpdate update;
1476 update.message = message;
1477 update.hash = hash;
1478
1479 update.head = NULL;
1480 update.tail = NULL;
1481
1483 member_store,
1485 &update);
1486
1487 while (update.head)
1488 {
1489 struct GNUNET_MESSENGER_MemberSessionCompletion *element = update.head;
1490
1491 remove_room_member_session (room, element->session);
1492
1493 GNUNET_CONTAINER_DLL_remove (update.head, update.tail, element);
1495 "Remove member session completion from queue!\n");
1496
1497 GNUNET_free (element);
1498 }
1499 }
1500
1501 start_handle = room->handling.head ? GNUNET_NO : GNUNET_YES;
1502
1503 add_to_list_messages (&(room->handling), hash);
1504
1505 switch (message->header.kind)
1506 {
1508 handle_message_join (room, &session, message, hash);
1509 break;
1511 handle_message_leave (room, &session, message, hash);
1512 break;
1514 handle_message_key (room, &session, message, hash);
1515 break;
1517 handle_message_peer (room, &session, message, hash);
1518 break;
1520 handle_message_id (room, &session, message, hash);
1521 break;
1523 handle_message_miss (room, &session, message, hash);
1524 break;
1526 handle_message_delete (room, &session, message, hash);
1527 break;
1529 handle_message_connection (room, &session, message, hash);
1530 break;
1532 handle_message_subscribe (room, &session, message, hash);
1533 break;
1534 default:
1535 break;
1536 }
1537
1538 if (GNUNET_YES == start_handle)
1539 handle_room_messages (room);
1540}
1541
1542
1543void
1545{
1546 char *room_dir;
1547
1548 GNUNET_assert (room);
1549
1550 get_room_data_subdir (room, &room_dir);
1551
1552 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Load room from directory: %s\n",
1553 room_dir);
1554
1556 {
1557 char *peers_file;
1558 GNUNET_asprintf (&peers_file, "%s%s", room_dir, "peers.list");
1559
1560 load_peer_store (get_srv_room_peer_store (room), peers_file);
1561 GNUNET_free (peers_file);
1562
1567
1568 {
1569 char *basement_file;
1570 GNUNET_asprintf (&basement_file, "%s%s", room_dir, "basement.list");
1571
1572 load_list_tunnels (&(room->basement), basement_file);
1573 GNUNET_free (basement_file);
1574 }
1575
1576 load_message_state (&(room->state), room_dir);
1577 }
1578
1579 GNUNET_free (room_dir);
1580}
1581
1582
1583void
1585{
1586 char *room_dir;
1587
1588 GNUNET_assert (room);
1589
1590 get_room_data_subdir (room, &room_dir);
1591
1592 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Save room to directory: %s\n",
1593 room_dir);
1594
1595 if ((GNUNET_YES == GNUNET_DISK_directory_test (room_dir, GNUNET_NO)) ||
1597 {
1598 char *peers_file;
1599 GNUNET_asprintf (&peers_file, "%s%s", room_dir, "peers.list");
1600
1601 save_peer_store (get_srv_room_peer_store (room), peers_file);
1602 GNUNET_free (peers_file);
1603
1608
1609 {
1610 char *basement_file;
1611 GNUNET_asprintf (&basement_file, "%s%s", room_dir, "basement.list");
1612
1613 save_list_tunnels (&(room->basement), basement_file);
1614 GNUNET_free (basement_file);
1615 }
1616
1617 save_message_state (&(room->state), room_dir);
1618 }
1619
1620 GNUNET_free (room_dir);
1621}
1622
1623
1624void
1626{
1627 char *room_dir;
1628
1629 GNUNET_assert (room);
1630
1631 get_room_data_subdir (room, &room_dir);
1632
1633 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Remove room from directory: %s\n",
1634 room_dir);
1635
1638
1639 GNUNET_free (room_dir);
1640}
1641
1642
1643static void
1646{
1647 struct GNUNET_HashCode hash;
1648 char *session_dir;
1649 char *room_dir;
1650
1651 GNUNET_assert ((room) && (session));
1652
1654 "Remove member session from room: %s (%s)\n",
1656 GNUNET_h2s (get_srv_room_key (room)));
1657
1658 remove_member_session (session->member, session);
1659
1660 {
1661 const struct GNUNET_CRYPTO_PublicKey *public_key;
1662 public_key = get_member_session_public_key (session);
1663
1664 GNUNET_CRYPTO_hash (public_key, sizeof(*public_key), &hash);
1665 }
1666
1667
1668 get_room_data_subdir (room, &room_dir);
1669
1671 &session_dir, "%s%s%c%s%c%s%c%s%c", room_dir,
1672 "members", DIR_SEPARATOR,
1674 "sessions", DIR_SEPARATOR,
1675 GNUNET_h2s (&hash), DIR_SEPARATOR);
1676
1677 GNUNET_free (room_dir);
1678
1679 GNUNET_DISK_directory_remove (session_dir);
1680 GNUNET_free (session_dir);
1681
1682 destroy_member_session (session);
1683}
struct GNUNET_MQ_MessageHandlers handlers[]
Definition: 003.c:1
struct GNUNET_MQ_Envelope * env
Definition: 005.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 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_PublicKey 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 int result
Global testing status.
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
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_PublicKey * get_srv_handle_key(const struct GNUNET_MESSENGER_SrvHandle *handle)
Returns the public key of a given handle.
const struct GNUNET_ShortHashCode * get_srv_handle_member_id(const struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
Returns the member id of a given handle in a specific room.
enum GNUNET_GenericReturnValue 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.
void remove_member_session(struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSENGER_MemberSession *session)
Removes a given member session from its member.
struct GNUNET_MESSENGER_MemberSession * get_member_session_of(struct GNUNET_MESSENGER_Member *member, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Returns the member session of a member using a public key which can verify the signature of a given m...
struct GNUNET_MESSENGER_MemberSession * get_member_session(const struct GNUNET_MESSENGER_Member *member, const struct GNUNET_CRYPTO_PublicKey *public_key)
Returns the member session of a member identified by a given public key.
struct GNUNET_MESSENGER_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 destroy_member_session(struct GNUNET_MESSENGER_MemberSession *session)
Destroys a member session and frees its memory fully.
const struct GNUNET_CRYPTO_PublicKey * get_member_session_public_key(const struct GNUNET_MESSENGER_MemberSession *session)
Returns the public key of a given member session.
struct GNUNET_TIME_Absolute get_member_session_start(const struct GNUNET_MESSENGER_MemberSession *session)
Returns the timestamp of the member session's start.
void update_member_session_history(struct GNUNET_MESSENGER_MemberSession *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.
const struct GNUNET_ShortHashCode * get_member_session_id(const struct GNUNET_MESSENGER_MemberSession *session)
Returns the member id of a given member session.
enum GNUNET_GenericReturnValue check_member_session_history(const struct GNUNET_MESSENGER_MemberSession *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...
enum GNUNET_GenericReturnValue is_member_session_completed(const struct GNUNET_MESSENGER_MemberSession *session)
Returns if the given member session has been completed.
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.
static enum GNUNET_GenericReturnValue request_room_message_step(struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_MemberSession *session, GNUNET_MESSENGER_MessageRequestCallback callback, void *cls)
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)
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 void remove_room_member_session(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session)
static enum GNUNET_GenericReturnValue iterate_member_for_subscription(void *cls, const struct GNUNET_CRYPTO_PublicKey *public_key, struct GNUNET_MESSENGER_MemberSession *session)
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 void idle_request_room_messages(void *cls)
void 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...
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...
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.
static void sign_srv_room_message_by_peer(const void *cls, struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer, const struct GNUNET_HashCode *hash)
void forward_srv_room_message(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Forwards a message with a given hash to a specific tunnel inside of a room.
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...
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.
enum GNUNET_GenericReturnValue request_srv_room_message(struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_MemberSession *session, GNUNET_MESSENGER_MessageRequestCallback callback, void *cls)
Requests a message from a room identified by a given hash.
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.
struct GNUNET_MESSENGER_OperationStore * get_srv_room_operation_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used operation store of a given room.
static enum GNUNET_GenericReturnValue iterate_send_room_message(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
static void close_srv_room(struct GNUNET_MESSENGER_SrvRoom *room)
void solve_srv_room_member_collisions(struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_CRYPTO_PublicKey *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_CADET_Handle * get_srv_room_cadet(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the CADET handle from a rooms service.
enum GNUNET_GenericReturnValue delete_srv_room_message(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *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...
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 enum GNUNET_GenericReturnValue iterate_update_member_sessions(void *cls, const struct GNUNET_CRYPTO_PublicKey *public_key, struct GNUNET_MESSENGER_MemberSession *session)
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...
struct GNUNET_MQ_Envelope * pack_srv_room_message(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash, enum GNUNET_MESSENGER_PackMode mode)
Packs a message depending on the selected mode into a newly allocated envelope.
#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.
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...
static enum @44 mode
Should we do a PUT (mode = 0) or GET (mode = 1);.
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:1098
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_test(const char *fil, int is_readable)
Test if fil is a directory and listable.
Definition: disk.c:454
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create(const char *dir)
Implementation of "mkdir -p".
Definition: disk.c:547
#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:41
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.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash 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.
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the 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_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_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
GNUNET_GenericReturnValue
Named constants for return values.
@ 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.
Definition: messenger_api.c:46
#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 subscribtion 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.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
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:980
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:1207
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:1231
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:640
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...
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...
struct GNUNET_MQ_Envelope * pack_message(struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash, const GNUNET_MESSENGER_SignFunction sign, enum GNUNET_MESSENGER_PackMode mode, const void *cls)
Encodes the message to pack it into a newly allocated envelope if mode is equal to GNUNET_MESSENGER_P...
void destroy_message(struct GNUNET_MESSENGER_Message *message)
Destroys a message and frees its memory fully.
void sign_message_by_peer(struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer, const struct GNUNET_HashCode *hash, const struct GNUNET_CONFIGURATION_Handle *cfg)
Signs the hash of a message with the peer identity of a given config and writes the signature into th...
GNUNET_MESSENGER_PackMode
@ GNUNET_MESSENGER_PACK_MODE_UNKNOWN
@ 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
An identity key as per LSD0001.
uint32_t type
Type of signature.
A 512-bit hashcode.
struct GNUNET_MESSENGER_SrvHandle * handle
struct GNUNET_MESSENGER_Message * message
struct GNUNET_MESSENGER_SrvTunnel * exclude
struct GNUNET_MESSENGER_SrvRoom * room
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_MESSENGER_MemberSessionCompletion * prev
struct GNUNET_MESSENGER_MemberSession * session
struct GNUNET_MESSENGER_MemberSessionCompletion * next
struct GNUNET_CONTAINER_MultiShortmap * members
struct GNUNET_MESSENGER_MemberSessionCompletion * head
const struct GNUNET_MESSENGER_Message * message
struct GNUNET_MESSENGER_MemberSessionCompletion * tail
struct GNUNET_CONTAINER_MultiHashMap * sessions
struct GNUNET_MESSENGER_MessageMerge merge
struct GNUNET_HashCode previous
The hash of the previous message from the senders perspective.
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
struct GNUNET_CRYPTO_Signature signature
The signature of the senders private key.
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_MemberSession * member
enum GNUNET_GenericReturnValue auto_routing
struct GNUNET_CADET_Handle * cadet
struct GNUNET_MESSENGER_ListHandles handles
struct GNUNET_HashCode * peer_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_CADET_Port * port
struct GNUNET_MESSENGER_ListTunnels basement
struct GNUNET_SCHEDULER_Task * idle
struct GNUNET_MESSENGER_MessageStore message_store
struct GNUNET_MESSENGER_MessageState state
struct GNUNET_MESSENGER_ListMessages handling
struct GNUNET_MESSENGER_OperationStore operation_store
struct GNUNET_MESSENGER_SrvHandle * host
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.