GNUnet 0.29.1-7-g14698f198
 
Loading...
Searching...
No Matches
gnunet-service-messenger_member_session.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2021--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 */
27
30
33
37{
39
40 if ((! member) || (! pubkey) || (! (member->store)))
41 return NULL;
42
43 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Create new member session!\n");
44
46 session->member = member;
47
48 GNUNET_memcpy (&(session->public_key), pubkey, sizeof(session->public_key));
49
51 get_member_session_key (session),
52 get_member_session_id (session),
53 &(session->context));
54
55 {
57
58 store = get_member_contact_store (member->store);
59
60 session->contact = get_store_contact (
61 store,
64 }
65
66 if (! (session->contact))
67 {
68 GNUNET_free (session);
69 return NULL;
70 }
71
73
75
76 init_list_messages (&(session->messages));
77
78 session->prev = NULL;
79 session->next = NULL;
80
81 session->start = GNUNET_TIME_absolute_get ();
82
83 session->closed = GNUNET_NO;
84 session->completed = GNUNET_NO;
85
86 return session;
87}
88
89
92 session)
93{
94 struct GNUNET_MESSENGER_Member *member;
95
96 GNUNET_assert (session);
97
98 member = session->member;
99
100 GNUNET_assert (member);
101
102 return member->store;
103}
104
105
106static struct GNUNET_MESSENGER_SrvRoom*
108{
109 struct GNUNET_MESSENGER_MemberStore *store;
110
111 GNUNET_assert (session);
112
113 store = get_session_member_store (session);
114
115 GNUNET_assert (store);
116
117 return store->room;
118}
119
120
121static void
123 session)
124{
125 const struct GNUNET_HashCode *start;
126 const struct GNUNET_HashCode *end;
127 struct GNUNET_MESSENGER_MessageStore *msg_store;
128 struct GNUNET_CONTAINER_MultiHashMap *completion;
131
132 GNUNET_assert (session);
133
135 "Check session history (%s) for completion.\n",
137
138 if (! session->messages.tail)
139 {
140 session->completed = GNUNET_YES;
141 goto completion;
142 }
143 else if (GNUNET_YES == session->completed)
144 goto completion;
145
146 start = &(session->messages.head->hash);
147 end = &(session->messages.tail->hash);
148
149 msg_store = get_srv_room_message_store (get_session_room (session));
151
152 if (! completion)
153 goto completion;
154
155 init_list_messages (&level);
156 add_to_list_messages (&level, end);
157
159
160 while (level.head)
161 {
162 struct GNUNET_MESSENGER_ListMessage *element;
163
164 for (element = level.head; element; element = element->next)
165 {
166 const struct GNUNET_MESSENGER_MessageLink *link;
167
169 msg_store, &(element->hash),
170 GNUNET_NO);
171
172 if (! link)
173 continue;
174
176 link->first)))
177 {
178 add_to_list_messages (&list, &(link->first));
179 GNUNET_CONTAINER_multihashmap_put (completion, &(link->first), NULL,
181 }
182
183 if ((GNUNET_YES == link->multiple) &&
185 link->second)
186 )))
187 {
188 add_to_list_messages (&list, &(link->second));
189 GNUNET_CONTAINER_multihashmap_put (completion, &(link->second), NULL,
191 }
192 }
193
194 clear_list_messages (&level);
195
196 for (element = list.head; element; element = element->next)
197 {
198 if (GNUNET_YES != check_member_session_history (session, &(element->hash),
199 GNUNET_YES))
200 continue;
201
202 if (0 == GNUNET_CRYPTO_hash_cmp (&(element->hash), start))
203 {
204 session->completed = GNUNET_YES;
205 break;
206 }
207 }
208
209 if (GNUNET_YES != session->completed)
210 copy_list_messages (&level, &list);
211
213 }
214
216
217completion:
219 {
220 struct GNUNET_MESSENGER_MemberStore *member_store;
221 struct GNUNET_MESSENGER_ContactStore *store;
222
223 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Completed session history (%s)\n",
225
226 member_store = get_session_member_store (session);
227 store = get_member_contact_store (member_store);
228
229 if ((session->contact) && (GNUNET_YES == decrease_contact_rc (
230 session->contact)))
232 store,
233 session->contact,
235
236 session->contact = NULL;
237 }
238}
239
240
243 const struct GNUNET_HashCode *key,
244 void *value)
245{
247
248 GNUNET_assert ((cls) && (key));
249
250 next = cls;
251
254
255 return GNUNET_YES;
256}
257
258
261 const struct GNUNET_MESSENGER_Message *message,
262 const struct GNUNET_HashCode *hash)
263{
264 struct GNUNET_MESSENGER_MemberStore *store;
266
267 if ((! session) || (! message) || (! hash))
268 return NULL;
269
272
273 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Switch member session!\n");
274
275 store = get_session_member_store (session);
277
278 if (GNUNET_MESSENGER_KIND_ID == message->header.kind)
279 {
280 next->member = add_store_member (store,
281 &(message->body.id.id));
282 if (! next->member)
283 {
285 "Failed to switch member session to ID: %s\n",
286 GNUNET_sh2s (&(message->body.id.id)));
287
289 return NULL;
290 }
291 }
292 else
293 {
294 if (! session->member)
295 {
297 "Failed to switch member session\n");
298
300 return NULL;
301 }
302
303 next->member = session->member;
304 }
305
306 if (GNUNET_MESSENGER_KIND_KEY == message->header.kind)
307 GNUNET_memcpy (&(next->public_key), &(message->body.key.key),
308 sizeof(next->public_key));
309 else
311 sizeof(next->public_key));
312
316 &(next->context));
317
324
326
327 if (! (next->contact))
328 {
330 return NULL;
331 }
332
334
337 GNUNET_NO);
338
340 next);
341
343 copy_list_messages (&(next->messages), &(session->messages));
344
345 session->next = next;
346 next->prev = session;
347 next->next = NULL;
348
350
351 session->closed = GNUNET_YES;
354
356
357 return next;
358}
359
360
361void
363{
364 struct GNUNET_MESSENGER_MemberStore *store;
365 struct GNUNET_MESSENGER_Contact *contact;
366
367 GNUNET_assert (session);
368
370
371 clear_list_messages (&(session->messages));
372
373 store = get_session_member_store (session);
374 contact = get_member_session_contact (session);
375
376 if ((contact) && (GNUNET_YES == decrease_contact_rc (contact)))
379 contact,
381
382 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Free member session!\n");
383 GNUNET_free (session);
384}
385
386
389 const struct GNUNET_HashCode *hash)
390{
391 struct GNUNET_MESSENGER_Contact *contact;
392
393 GNUNET_assert ((session) && (hash));
394
395 {
396 struct GNUNET_MESSENGER_MemberStore *member_store;
397 struct GNUNET_MESSENGER_ContactStore *store;
398
399 member_store = get_session_member_store (session);
400 store = get_member_contact_store (member_store);
401 contact = get_store_contact (
402 store,
405 }
406
407 if (! contact)
408 return GNUNET_SYSERR;
409
410 if (contact == session->contact)
411 goto clear_messages;
412
413 session->contact = contact;
414 increase_contact_rc (session->contact);
415
416clear_messages:
417 clear_list_messages (&(session->messages));
418 add_to_list_messages (&(session->messages), hash);
419
420 session->next = NULL;
421 session->closed = GNUNET_NO;
422 session->completed = GNUNET_NO;
423
424 return GNUNET_OK;
425}
426
427
428void
430{
431 GNUNET_assert (session);
432
433 session->closed = GNUNET_YES;
435}
436
437
440 session)
441{
442 GNUNET_assert (session);
443
444 return session->closed;
445}
446
447
451{
452 GNUNET_assert (session);
453
454 return session->completed;
455}
456
457
460 session)
461{
462 GNUNET_assert (session);
463
464 if (session->prev)
465 return get_member_session_start (session->prev);
466
467 return session->start;
468}
469
470
471const struct GNUNET_HashCode*
473{
474 const struct GNUNET_MESSENGER_MemberStore *store;
475
476 GNUNET_assert ((session) && (session->member));
477
478 store = get_session_member_store (session);
479
480 return get_member_store_key (store);
481}
482
483
484const struct GNUNET_ShortHashCode*
486{
487 GNUNET_assert (session);
488
489 return get_member_id (session->member);
490}
491
492
496{
497 GNUNET_assert (session);
498
499 return &(session->public_key);
500}
501
502
503const struct GNUNET_HashCode*
506{
507 GNUNET_assert (session);
508
509 return &(session->context);
510}
511
512
515{
516 GNUNET_assert (session);
517
518 return session->contact;
519}
520
521
525 const struct GNUNET_MESSENGER_Message *message,
526 const struct GNUNET_HashCode *hash)
527{
528 GNUNET_assert ((session) && (message) && (hash));
529
531 {
532 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Check message (%s) using history!\n",
533 GNUNET_h2s (hash));
534
535 if (GNUNET_YES == check_member_session_history (session, hash, GNUNET_YES))
536 return GNUNET_OK;
537 else
538 return GNUNET_SYSERR;
539 }
540
541 if (0 != GNUNET_memcmp (get_member_session_id (session),
542 &(message->header.sender_id)))
543 return GNUNET_SYSERR;
544
545 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Check message (%s) using key: %s\n",
546 GNUNET_h2s (hash),
549
550 return verify_message (message, hash, get_member_session_public_key (
551 session));
552}
553
554
558 const struct GNUNET_HashCode *hash,
559 enum GNUNET_GenericReturnValue ownership)
560{
561 GNUNET_assert ((session) && (hash));
562
563 if (GNUNET_YES == ownership)
564 return (NULL != GNUNET_CONTAINER_multihashmap_get (session->history, hash)?
566 else
567 return GNUNET_CONTAINER_multihashmap_contains (session->history, hash);
568}
569
570
571static void
573 const struct GNUNET_HashCode *hash,
574 enum GNUNET_GenericReturnValue ownership)
575{
576 GNUNET_assert ((session) && (hash));
577
579 (GNUNET_YES == ownership?
580 session : NULL),
582 && (session->next))
583 update_member_chain_history (session->next, hash, ownership);
584}
585
586
587void
589 ,
590 const struct GNUNET_MESSENGER_Message *message,
591 const struct GNUNET_HashCode *hash)
592{
593 GNUNET_assert ((session) && (message) && (hash));
594
596 {
598 "Updating session history (%s) failed: Session already completed!\n",
600 return;
601 }
602
604 "Updating sessions history (%s) += (%s)\n",
605 GNUNET_sh2s (get_member_session_id (session)), GNUNET_h2s (hash));
606
607 if (GNUNET_OK == verify_member_session_as_sender (session, message, hash))
608 {
609 if (GNUNET_YES == is_message_session_bound (message))
610 add_to_list_messages (&(session->messages), hash);
611
613 }
614 else
615 update_member_chain_history (session, hash, GNUNET_NO);
616
617 if (GNUNET_YES == session->closed)
619}
620
621
622static void
624 const struct GNUNET_HashCode *hash)
625{
626 GNUNET_assert ((session) && (hash));
627
628 if ((0 < GNUNET_CONTAINER_multihashmap_remove_all (session->history, hash)) &&
629 (session->next))
630 clear_member_session_history (session->next, hash);
631}
632
633
634void
636 const struct GNUNET_HashCode *hash)
637{
638 GNUNET_assert ((session) && (hash));
639
640 clear_member_chain_history (session, hash);
641}
642
643
649
650static void
652 const char *path)
653{
656
657 GNUNET_assert ((session) && (path));
658
659 if (GNUNET_YES != GNUNET_DISK_file_test (path))
660 return;
661
662 {
663 enum GNUNET_DISK_AccessPermissions permission;
664
667 }
668
669 if (! handle)
670 return;
671
673
674 do {
676 ssize_t len;
677
678 len = GNUNET_DISK_file_read (handle, &(entry.hash), sizeof(entry.hash));
679
680 if (len != sizeof(entry.hash))
681 break;
682
683 len = GNUNET_DISK_file_read (handle, &(entry.ownership),
684 sizeof(entry.ownership));
685
686 if (len != sizeof(entry.ownership))
687 break;
688
690 (entry.ownership? session :
691 NULL),
693 } while (status == GNUNET_OK);
694
696}
697
698
699void
701 const char *directory)
702{
703 char *config_file;
704 struct GNUNET_MESSENGER_SrvMemberSession *session;
706
707 GNUNET_assert ((member) && (directory));
708
709 GNUNET_asprintf (&config_file, "%s%s", directory, "session.cfg");
710
711 session = NULL;
712
714 goto free_config;
715
717 "Load session configuration of member: %s\n", config_file);
718
720
721 if (! cfg)
722 goto free_config;
723
725 {
727 enum GNUNET_GenericReturnValue key_result;
728 unsigned long long numeric_value;
729 char *key_data;
730
732 "key", &key_data))
733 goto destroy_config;
734
736 &key);
737 GNUNET_free (key_data);
738
739 if (GNUNET_OK != key_result)
740 goto destroy_config;
741
742 session = create_member_session (member, &key);
743
744 if (! session)
745 goto destroy_config;
746
748 "start",
749 &numeric_value))
750 session->start.abs_value_us = numeric_value;
751
753 "closed",
754 &numeric_value))
755 session->closed = (GNUNET_YES == numeric_value? GNUNET_YES : GNUNET_NO);
756
758 "completed",
759 &numeric_value))
760 session->completed = (GNUNET_YES == numeric_value? GNUNET_YES :
761 GNUNET_NO);
762 }
763
764destroy_config:
766
767free_config:
769
770 if (! session)
771 return;
772
773 {
774 char *history_file;
775 GNUNET_asprintf (&history_file, "%s%s", directory, "history.map");
776
777 load_member_session_history (session, history_file);
778 GNUNET_free (history_file);
779 }
780
781 {
782 char *messages_file;
783 GNUNET_asprintf (&messages_file, "%s%s", directory, "messages.list");
784
785 load_list_messages (&(session->messages), messages_file);
786 GNUNET_free (messages_file);
787 }
788
789 add_member_session (member, session);
790}
791
792
796{
798
799 if (! next)
800 return NULL;
801
802 for (check = next; check; check = check->next)
803 if (check == session)
804 return NULL;
805
806 return next;
807}
808
809
810void
812 const char *directory)
813{
815 char *config_file;
816
817
818 GNUNET_assert ((session) && (directory));
819
820 GNUNET_asprintf (&config_file, "%s%s", directory, "session.cfg");
821
823 goto free_config;
824
826 "Load next session configuration of member: %s\n", config_file);
827
829
830 if (! cfg)
831 goto free_config;
832
834 {
835 struct GNUNET_CRYPTO_BlindablePublicKey next_key;
836 enum GNUNET_GenericReturnValue key_result;
838 char *key_data;
839
841 "next_key",
842 &key_data))
843 goto destroy_config;
844
845 key_result = GNUNET_CRYPTO_blindable_public_key_from_string (key_data, &
846 next_key);
847 GNUNET_free (key_data);
848
849 if (GNUNET_OK != key_result)
850 goto destroy_config;
851
852 if (GNUNET_OK != GNUNET_CONFIGURATION_get_data (cfg, "session", "next_id",
853 &next_id, sizeof(next_id)))
854 goto destroy_config;
855
856 {
857 struct GNUNET_MESSENGER_MemberStore *store;
858 struct GNUNET_MESSENGER_Member *member;
859
861 member = get_store_member (store, &next_id);
862
864 session,
865 member? get_member_session (member, &next_key) : NULL);
866 }
867
868 if (session->next)
869 session->next->prev = session;
870 }
871
872destroy_config:
874
875free_config:
877}
878
879
882 const struct GNUNET_HashCode *key,
883 void *value)
884{
886 unsigned char ownership;
887
888 GNUNET_assert ((cls) && (key));
889
890 handle = cls;
891 ownership = value? GNUNET_YES : GNUNET_NO;
892
894 GNUNET_DISK_file_write (handle, &ownership, sizeof(ownership));
895
896 return GNUNET_YES;
897}
898
899
900static void
902 const char *path)
903{
905
906 GNUNET_assert ((session) && (path));
907
908 {
909 enum GNUNET_DISK_AccessPermissions permission;
910
912
914 path,
916 permission);
917 }
918
919 if (! handle)
920 return;
921
923
925 session->history,
927 handle);
928
931}
932
933
934void
936 const char *directory)
937{
939 char *config_file;
940 char *key_data;
941
942 GNUNET_assert ((session) && (directory));
943
944 GNUNET_asprintf (&config_file, "%s%s", directory, "session.cfg");
945
947 "Save session configuration of member: %s\n", config_file);
948
950
951 if (! cfg)
952 goto free_config;
953
956
957 if (key_data)
958 {
959 GNUNET_CONFIGURATION_set_value_string (cfg, "session", "key", key_data);
960 GNUNET_free (key_data);
961 }
962
963 if (session->next)
964 {
966 session->next);
967
968 char *next_id_data = GNUNET_STRINGS_data_to_string_alloc (next_id,
969 sizeof(*next_id));
970
971 if (next_id_data)
972 {
973 GNUNET_CONFIGURATION_set_value_string (cfg, "session", "next_id",
974 next_id_data);
975 GNUNET_free (next_id_data);
976 }
977
980
981 if (key_data)
982 {
983 GNUNET_CONFIGURATION_set_value_string (cfg, "session", "next_key",
984 key_data);
985 GNUNET_free (key_data);
986 }
987 }
988
989 GNUNET_CONFIGURATION_set_value_number (cfg, "session", "start",
990 session->start.abs_value_us);
991
992 GNUNET_CONFIGURATION_set_value_number (cfg, "session", "closed",
993 session->closed);
994 GNUNET_CONFIGURATION_set_value_number (cfg, "session", "completed",
995 session->completed);
996
999
1000free_config:
1002
1003 {
1004 char *history_file;
1005 GNUNET_asprintf (&history_file, "%s%s", directory, "history.map");
1006
1007 save_member_session_history (session, history_file);
1008 GNUNET_free (history_file);
1009 }
1010
1011 {
1012 char *messages_file;
1013 GNUNET_asprintf (&messages_file, "%s%s", directory, "messages.list");
1014
1015 save_list_messages (&(session->messages), messages_file);
1016 GNUNET_free (messages_file);
1017 }
1018}
static int start
Set if we are to start default services (including ARM).
Definition gnunet-arm.c:38
static int list
Set if we should print a list of currently running services.
Definition gnunet-arm.c:68
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition gnunet-arm.c:108
static int end
Set if we are to shutdown all services (including ARM).
Definition gnunet-arm.c:33
static char * config_file
Set to the name of the config file used.
Definition gnunet-arm.c:83
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_CRYPTO_BlindablePublicKey pubkey
Public key of the zone to look in.
static char * value
Value of the record to add/remove.
static int status
The program status; 0 for success.
Definition gnunet-nse.c:39
static char * next_id
Command-line option for namespace publishing: identifier for updates to this publication.
void clear_list_messages(struct GNUNET_MESSENGER_ListMessages *messages)
Clears the list of message hashes.
void load_list_messages(struct GNUNET_MESSENGER_ListMessages *messages, const char *path)
Loads the list of message hashes from a file under a given path.
void init_list_messages(struct GNUNET_MESSENGER_ListMessages *messages)
Initializes list of message hashes as empty list.
void copy_list_messages(struct GNUNET_MESSENGER_ListMessages *messages, const struct GNUNET_MESSENGER_ListMessages *origin)
Copies all message hashes from an origin to another list.
void save_list_messages(const struct GNUNET_MESSENGER_ListMessages *messages, const char *path)
Saves the list of message hashes to a file under a given path.
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.
void add_member_session(struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSENGER_SrvMemberSession *session)
Adds a given member session to its member.
static struct GNUNET_MESSENGER_SrvRoom * get_session_room(const struct GNUNET_MESSENGER_SrvMemberSession *session)
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.
struct GNUNET_MESSENGER_SrvMemberSession * create_member_session(struct GNUNET_MESSENGER_Member *member, const struct GNUNET_CRYPTO_BlindablePublicKey *pubkey)
Creates and allocates a new member session of a member with a given public key.
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.
static enum GNUNET_GenericReturnValue iterate_save_member_session_history_hentries(void *cls, const struct GNUNET_HashCode *key, void *value)
enum GNUNET_GenericReturnValue verify_member_session_as_sender(const struct GNUNET_MESSENGER_SrvMemberSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Verifies a given member session as sender of a selected message and its hash.
static void check_member_session_completion(struct GNUNET_MESSENGER_SrvMemberSession *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.
static enum GNUNET_GenericReturnValue iterate_copy_history(void *cls, const struct GNUNET_HashCode *key, void *value)
void clear_member_session_history(struct GNUNET_MESSENGER_SrvMemberSession *session, const struct GNUNET_HashCode *hash)
Removes a message from the history of a session using the messages hash.
struct GNUNET_MESSENGER_Contact * get_member_session_contact(struct GNUNET_MESSENGER_SrvMemberSession *session)
Returns the contact which is connected to a given member session.
static void save_member_session_history(struct GNUNET_MESSENGER_SrvMemberSession *session, const char *path)
struct GNUNET_MESSENGER_SrvMemberSession * switch_member_session(struct GNUNET_MESSENGER_SrvMemberSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Creates and allocates a new member session closing and replacing a given other session of the same me...
static struct GNUNET_MESSENGER_MemberStore * get_session_member_store(const struct GNUNET_MESSENGER_SrvMemberSession *session)
void load_member_session(struct GNUNET_MESSENGER_Member *member, const char *directory)
Loads data from a directory into a new allocated and created member session of a member if the requir...
struct GNUNET_TIME_Absolute get_member_session_start(const struct GNUNET_MESSENGER_SrvMemberSession *session)
Returns the timestamp of the member session's start.
void close_member_session(struct GNUNET_MESSENGER_SrvMemberSession *session)
Closes a given member session which opens the request for completion of the given member session.
static void clear_member_chain_history(struct GNUNET_MESSENGER_SrvMemberSession *session, const struct GNUNET_HashCode *hash)
const struct GNUNET_HashCode * get_member_session_context(const struct GNUNET_MESSENGER_SrvMemberSession *session)
Returns the member context of a given member session.
static void update_member_chain_history(struct GNUNET_MESSENGER_SrvMemberSession *session, const struct GNUNET_HashCode *hash, enum GNUNET_GenericReturnValue ownership)
static struct GNUNET_MESSENGER_SrvMemberSession * get_cycle_safe_next_session(struct GNUNET_MESSENGER_SrvMemberSession *session, struct GNUNET_MESSENGER_SrvMemberSession *next)
void load_member_session_next(struct GNUNET_MESSENGER_SrvMemberSession *session, const char *directory)
Loads the connection from one session to another through the next attribute.
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...
static void load_member_session_history(struct GNUNET_MESSENGER_SrvMemberSession *session, const char *path)
enum GNUNET_GenericReturnValue reset_member_session(struct GNUNET_MESSENGER_SrvMemberSession *session, const struct GNUNET_HashCode *hash)
Resets a given member session which re-opens a member session for new usage.
const struct GNUNET_HashCode * get_member_session_key(const struct GNUNET_MESSENGER_SrvMemberSession *session)
Returns the key of the room a given member session belongs to.
void save_member_session(struct GNUNET_MESSENGER_SrvMemberSession *session, const char *directory)
Saves data from a member session into a directory which can be load to restore the member session com...
enum GNUNET_GenericReturnValue is_member_session_closed(const struct GNUNET_MESSENGER_SrvMemberSession *session)
Returns if the given member session has been closed.
struct GNUNET_MESSENGER_ContactStore * get_member_contact_store(struct GNUNET_MESSENGER_MemberStore *store)
Returns the used contact store of a given member store.
const struct GNUNET_HashCode * get_member_store_key(const struct GNUNET_MESSENGER_MemberStore *store)
Returns the shared secret you need to access a room of the 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.
struct GNUNET_MESSENGER_Member * get_store_member(const struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_ShortHashCode *id)
Returns the member in a store identified by a given id.
const struct GNUNET_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.
struct GNUNET_MESSENGER_MessageStore * get_srv_room_message_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used message store of a given room.
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition gnunet-vpn.c:35
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_data(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, void *buf, size_t buf_size)
Get Crockford32-encoded fixed-size binary data from a configuration.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(const struct GNUNET_OS_ProjectData *pd)
Create a new configuration object.
void GNUNET_CONFIGURATION_set_value_string(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *value)
Set a configuration value that should be a string.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
void GNUNET_CONFIGURATION_set_value_number(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long number)
Set a configuration value that should be a number.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_parse(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Parse a configuration file, add all of the options in the file to the configuration environment.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_write(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Write configuration file.
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
Definition disk.c:1308
enum GNUNET_GenericReturnValue GNUNET_DISK_file_test(const char *fil)
Check that fil corresponds to a filename (of a file that exists and that is not a directory).
Definition disk.c:557
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition disk.c:745
off_t GNUNET_DISK_file_seek(const struct GNUNET_DISK_FileHandle *h, off_t offset, enum GNUNET_DISK_Seek whence)
Move the read/write pointer in a file.
Definition disk.c:219
GNUNET_DISK_AccessPermissions
File access permissions, UNIX-style.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_sync(const struct GNUNET_DISK_FileHandle *h)
Write file changes to disk.
Definition disk.c:1507
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition disk.c:1386
ssize_t GNUNET_DISK_file_read(const struct GNUNET_DISK_FileHandle *h, void *result, size_t len)
Read the contents of a binary file into a buffer.
Definition disk.c:704
@ GNUNET_DISK_OPEN_READ
Open the file for reading.
@ GNUNET_DISK_OPEN_WRITE
Open the file for writing.
@ GNUNET_DISK_OPEN_CREATE
Create file if it doesn't exist.
@ GNUNET_DISK_PERM_USER_READ
Owner can read.
@ GNUNET_DISK_PERM_USER_WRITE
Owner can write.
@ GNUNET_DISK_SEEK_SET
Seek an absolute position (from the start of the file).
int GNUNET_CRYPTO_hash_cmp(const struct GNUNET_HashCode *h1, const struct GNUNET_HashCode *h2)
Compare function for HashCodes, producing a total ordering of all hashcodes.
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).
int GNUNET_CONTAINER_multihashmap_remove_all(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Remove all entries for the given key from the map.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_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.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE...
#define GNUNET_log(kind,...)
char * GNUNET_CRYPTO_blindable_public_key_to_string(const struct GNUNET_CRYPTO_BlindablePublicKey *key)
Creates a (Base32) string representation of the public key.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blindable_public_key_from_string(const char *str, struct GNUNET_CRYPTO_BlindablePublicKey *key)
Parses a (Base32) string representation of the public key.
#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_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
#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.
@ GNUNET_MESSENGER_KIND_KEY
The key kind.
@ GNUNET_MESSENGER_KIND_ID
The id kind.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition strings.c:818
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition time.c:111
enum GNUNET_GenericReturnValue decrease_contact_rc(struct GNUNET_MESSENGER_Contact *contact)
Decreases the reference counter if possible (can not underflow!) of a given contact and returns GNUNE...
void increase_contact_rc(struct GNUNET_MESSENGER_Contact *contact)
Increases the reference counter of a given contact which is zero as default.
void get_context_from_member(const struct GNUNET_HashCode *key, const struct GNUNET_ShortHashCode *id, struct GNUNET_HashCode *context)
Calculates the context hash of a member in a room and returns it.
struct GNUNET_MESSENGER_Contact * get_store_contact(struct GNUNET_MESSENGER_ContactStore *store, const struct GNUNET_HashCode *context, const struct GNUNET_CRYPTO_BlindablePublicKey *pubkey)
Returns a contact using a specific public key.
void remove_store_contact(struct GNUNET_MESSENGER_ContactStore *store, struct GNUNET_MESSENGER_Contact *contact, const struct GNUNET_HashCode *context)
Removes a contact from the store which uses a given member context.
void update_store_contact(struct GNUNET_MESSENGER_ContactStore *store, struct GNUNET_MESSENGER_Contact *contact, const struct GNUNET_HashCode *context, const struct GNUNET_HashCode *next_context, const struct GNUNET_CRYPTO_BlindablePublicKey *pubkey)
Moves a contact from the store to another location matching a given public key and member context.
enum GNUNET_GenericReturnValue verify_message(const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, const struct GNUNET_CRYPTO_BlindablePublicKey *key)
Verifies the signature of a given message and its hash with a specific public key.
enum GNUNET_GenericReturnValue is_message_session_bound(const struct GNUNET_MESSENGER_Message *message)
Returns if the message should be bound to a member session.
Internal representation of the hash map.
An identity key as per LSD0001.
Handle used to access files (and pipes).
A 512-bit hashcode.
struct GNUNET_MESSENGER_ListMessage * next
struct GNUNET_MESSENGER_ListMessage * head
struct GNUNET_MESSENGER_ListMessage * tail
struct GNUNET_MESSENGER_MemberStore * store
struct GNUNET_MESSENGER_MessageId id
struct GNUNET_MESSENGER_MessageKey key
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
struct GNUNET_ShortHashCode sender_id
The senders id inside of the room the message was sent in.
struct GNUNET_ShortHashCode id
The new id which will replace the senders id in a room.
struct GNUNET_CRYPTO_BlindablePublicKey key
The new blindable public key which replaces the current senders public key.
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_MESSENGER_MessageBody body
Body.
struct GNUNET_MESSENGER_SrvMemberSession * next
struct GNUNET_MESSENGER_SrvMemberSession * prev
struct GNUNET_CRYPTO_BlindablePublicKey public_key
A 256-bit hashcode.
Time for absolute times used by GNUnet, in microseconds.
uint64_t abs_value_us
The actual value.