GNUnet 0.22.0
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--2024 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
27
30
32
35 const struct GNUNET_CRYPTO_PublicKey *pubkey)
36{
37 struct GNUNET_MESSENGER_MemberSession *session;
38
39 if ((! member) || (! pubkey) || (! (member->store)))
40 return NULL;
41
43 session->member = member;
44
45 GNUNET_memcpy (&(session->public_key), pubkey, sizeof(session->public_key));
46
48 get_member_session_key (session),
49 get_member_session_id (session),
50 &(session->context)
51 );
52
53 {
55
56 store = get_member_contact_store (session->member->store);
57
58 session->contact = get_store_contact (
59 store,
62 );
63 }
64
65 if (! (session->contact))
66 {
67 GNUNET_free (session);
68 return NULL;
69 }
70
72
74
75 init_list_messages (&(session->messages));
76
77 session->prev = NULL;
78 session->next = NULL;
79
80 session->start = GNUNET_TIME_absolute_get ();
81
82 session->closed = GNUNET_NO;
83 session->completed = GNUNET_NO;
84
85 return session;
86}
87
88
89static void
91{
92 const struct GNUNET_HashCode *start;
93 const struct GNUNET_HashCode *end;
94 struct GNUNET_MESSENGER_MessageStore *msg_store;
97
98 GNUNET_assert (session);
99
101 "Check session history (%s) for completion.\n",
103
104 if (! session->messages.tail)
105 {
106 session->completed = GNUNET_YES;
107 goto completion;
108 }
109
110 start = &(session->messages.head->hash);
111 end = &(session->messages.tail->hash);
112
113 msg_store = get_srv_room_message_store (session->member->store->room);
114
115 init_list_messages (&level);
116 add_to_list_messages (&level, end);
117
119
120 while (level.head)
121 {
122 struct GNUNET_MESSENGER_ListMessage *element;
123
124 for (element = level.head; element; element = element->next)
125 {
126 const struct GNUNET_MESSENGER_MessageLink *link;
127
129 msg_store, &(element->hash), GNUNET_NO
130 );
131
132 if (! link)
133 continue;
134
135 add_to_list_messages (&list, &(link->first));
136
137 if (GNUNET_YES == link->multiple)
138 add_to_list_messages (&list, &(link->second));
139 }
140
141 clear_list_messages (&level);
142
143 for (element = list.head; element; element = element->next)
144 if (GNUNET_YES == check_member_session_history (session, &(element->hash),
145 GNUNET_YES))
146 break;
147
148 if (element)
149 if (0 != GNUNET_CRYPTO_hash_cmp (&(element->hash), start))
150 add_to_list_messages (&level, &(element->hash));
151 else
152 session->completed = GNUNET_YES;
153 else
154 copy_list_messages (&level, &list);
155
157 }
158
159completion:
161 {
162 struct GNUNET_MESSENGER_ContactStore *store;
163
164 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Completed session history (%s)\n",
166
167 store = get_member_contact_store (session->member->store);
168
169 if ((session->contact) && (GNUNET_YES == decrease_contact_rc (
170 session->contact)))
172 store,
173 session->contact,
175 );
176
177 session->contact = NULL;
178 }
179}
180
181
184 const struct GNUNET_HashCode *key,
185 void *value)
186{
188
189 GNUNET_assert ((cls) && (key));
190
191 next = cls;
192
195
196 return GNUNET_YES;
197}
198
199
202 const struct GNUNET_MESSENGER_Message *message,
203 const struct GNUNET_HashCode *hash)
204{
206
207 if ((! session) || (! message) || (! hash))
208 return NULL;
209
212
214
215 if (GNUNET_MESSENGER_KIND_ID == message->header.kind)
217 &(message->body.id.id));
218 else
219 next->member = session->member;
220
221 if (GNUNET_MESSENGER_KIND_KEY == message->header.kind)
222 GNUNET_memcpy (&(next->public_key), &(message->body.key.key),
223 sizeof(next->public_key));
224 else
226 sizeof(next->public_key));
227
231 &(next->context)
232 );
233
240 );
241
243
244 if (! (next->contact))
245 {
247 return NULL;
248 }
249
251
254 );
255
257 next);
258
260 copy_list_messages (&(next->messages), &(session->messages));
261
262 session->next = next;
263 next->prev = session;
264 next->next = NULL;
265
267
268 session->closed = GNUNET_YES;
271
273
274 return next;
275}
276
277
278void
280{
281 struct GNUNET_MESSENGER_Contact *contact;
282
283 GNUNET_assert (session);
284
286
287 clear_list_messages (&(session->messages));
288
289 contact = get_member_session_contact ( session);
290
291 if ((contact) && (GNUNET_YES == decrease_contact_rc (contact)))
294 contact,
296 );
297
298 GNUNET_free (session);
299}
300
301
304 const struct GNUNET_HashCode *hash)
305{
306 struct GNUNET_MESSENGER_Contact *contact;
307
308 GNUNET_assert ((session) && (hash));
309
310 {
311 struct GNUNET_MESSENGER_ContactStore *store;
312
313 store = get_member_contact_store (session->member->store);
314 contact = get_store_contact (
315 store,
318 );
319 }
320
321 if (! contact)
322 return GNUNET_SYSERR;
323
324 if (contact == session->contact)
325 goto clear_messages;
326
327 session->contact = contact;
328 increase_contact_rc (session->contact);
329
330clear_messages:
331 clear_list_messages (&(session->messages));
332 add_to_list_messages (&(session->messages), hash);
333
334 session->next = NULL;
335 session->closed = GNUNET_NO;
336 session->completed = GNUNET_NO;
337
338 return GNUNET_OK;
339}
340
341
342void
344{
345 GNUNET_assert (session);
346
347 session->closed = GNUNET_YES;
349}
350
351
354{
355 GNUNET_assert (session);
356
357 return session->closed;
358}
359
360
364{
365 GNUNET_assert (session);
366
367 return session->completed;
368}
369
370
373{
374 GNUNET_assert (session);
375
376 if (session->prev)
377 return get_member_session_start (session->prev);
378
379 return session->start;
380}
381
382
383const struct GNUNET_HashCode*
385{
386 GNUNET_assert ((session) && (session->member));
387
388 return get_member_store_key (session->member->store);
389}
390
391
392const struct GNUNET_ShortHashCode*
394{
395 GNUNET_assert (session);
396
397 return get_member_id (session->member);
398}
399
400
401const struct GNUNET_CRYPTO_PublicKey*
404{
405 GNUNET_assert (session);
406
407 return &(session->public_key);
408}
409
410
411const struct GNUNET_HashCode*
414{
415 GNUNET_assert (session);
416
417 return &(session->context);
418}
419
420
423{
424 GNUNET_assert (session);
425
426 return session->contact;
427}
428
429
433 const struct GNUNET_MESSENGER_Message *message,
434 const struct GNUNET_HashCode *hash)
435{
436 GNUNET_assert ((session) && (message) && (hash));
437
439 {
440 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Check message (%s) using history!\n",
441 GNUNET_h2s (hash));
442
443 if (GNUNET_YES == check_member_session_history (session, hash, GNUNET_YES))
444 return GNUNET_OK;
445 else
446 return GNUNET_SYSERR;
447 }
448
449 if (0 != GNUNET_memcmp (get_member_session_id (session),
450 &(message->header.sender_id)))
451 return GNUNET_SYSERR;
452
453 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Check message (%s) using key: %s\n",
454 GNUNET_h2s (hash),
457
458 return verify_message (message, hash, get_member_session_public_key (
459 session));
460}
461
462
466 const struct GNUNET_HashCode *hash,
467 enum GNUNET_GenericReturnValue ownership)
468{
469 GNUNET_assert ((session) && (hash));
470
471 if (GNUNET_YES == ownership)
472 return (NULL != GNUNET_CONTAINER_multihashmap_get (session->history, hash)?
474 else
475 return GNUNET_CONTAINER_multihashmap_contains (session->history, hash);
476}
477
478
479static void
481 const struct GNUNET_HashCode *hash,
482 enum GNUNET_GenericReturnValue ownership)
483{
484 GNUNET_assert ((session) && (hash));
485
487 (GNUNET_YES == ownership?
488 session : NULL),
490 && (session->next))
491 update_member_chain_history (session->next, hash, ownership);
492}
493
494
495void
497 const struct GNUNET_MESSENGER_Message *message,
498 const struct GNUNET_HashCode *hash)
499{
500 GNUNET_assert ((session) && (message) && (hash));
501
503 return;
504
506 "Updating sessions history (%s) += (%s)\n",
507 GNUNET_sh2s (get_member_session_id (session)), GNUNET_h2s (hash));
508
509 if (GNUNET_OK == verify_member_session_as_sender (session, message, hash))
510 {
511 if (GNUNET_YES == is_message_session_bound (message))
512 add_to_list_messages (&(session->messages), hash);
513
515 }
516 else
517 update_member_chain_history (session, hash, GNUNET_NO);
518
519 if (GNUNET_YES == session->closed)
521}
522
523
524static void
526 const struct GNUNET_HashCode *hash)
527{
528 GNUNET_assert ((session) && (hash));
529
530 if ((0 < GNUNET_CONTAINER_multihashmap_remove_all (session->history, hash)) &&
531 (session->next))
532 clear_member_session_history (session->next, hash);
533}
534
535
536void
538 const struct GNUNET_HashCode *hash)
539{
540 GNUNET_assert ((session) && (hash));
541
542 clear_member_chain_history (session, hash);
543}
544
545
547{
549 unsigned char ownership;
550};
551
552static void
554 const char *path)
555{
558
559 GNUNET_assert ((session) && (path));
560
561 if (GNUNET_YES != GNUNET_DISK_file_test (path))
562 return;
563
564 {
565 enum GNUNET_DISK_AccessPermissions permission;
566
569 }
570
571 if (! handle)
572 return;
573
575
576 do {
578 ssize_t len;
579
580 len = GNUNET_DISK_file_read (handle, &(entry.hash), sizeof(entry.hash));
581
582 if (len != sizeof(entry.hash))
583 break;
584
585 len = GNUNET_DISK_file_read (handle, &(entry.ownership),
586 sizeof(entry.ownership));
587
588 if (len != sizeof(entry.ownership))
589 break;
590
592 (entry.ownership? session :
593 NULL),
595 } while (status == GNUNET_OK);
596
598}
599
600
601void
603 const char *directory)
604{
605 char *config_file;
606 struct GNUNET_MESSENGER_MemberSession *session;
608
609 GNUNET_assert ((member) && (directory));
610
611 GNUNET_asprintf (&config_file, "%s%s", directory, "session.cfg");
612
613 session = NULL;
614
616 goto free_config;
617
619 "Load session configuration of member: %s\n", config_file);
620
622
623 if (! cfg)
624 goto free_config;
625
627 {
629 enum GNUNET_GenericReturnValue key_result;
630 unsigned long long numeric_value;
631 char *key_data;
632
634 "key", &key_data))
635 goto destroy_config;
636
637 key_result = GNUNET_CRYPTO_public_key_from_string (key_data, &key);
638 GNUNET_free (key_data);
639
640 if (GNUNET_OK != key_result)
641 goto destroy_config;
642
643 session = create_member_session (member, &key);
644
646 "start",
647 &numeric_value))
648 session->start.abs_value_us = numeric_value;
649
651 "closed",
652 &numeric_value))
653 session->closed = (GNUNET_YES == numeric_value? GNUNET_YES : GNUNET_NO);
654
656 "completed",
657 &numeric_value))
658 session->completed = (GNUNET_YES == numeric_value? GNUNET_YES :
659 GNUNET_NO);
660 }
661
662destroy_config:
664
665free_config:
667
668 if (! session)
669 return;
670
671 {
672 char *history_file;
673 GNUNET_asprintf (&history_file, "%s%s", directory, "history.map");
674
675 load_member_session_history (session, history_file);
676 GNUNET_free (history_file);
677 }
678
679 {
680 char *messages_file;
681 GNUNET_asprintf (&messages_file, "%s%s", directory, "messages.list");
682
683 load_list_messages (&(session->messages), messages_file);
684 GNUNET_free (messages_file);
685 }
686
687 add_member_session (member, session);
688}
689
690
694{
695 struct GNUNET_MESSENGER_MemberSession *check;
696
697 if (! next)
698 return NULL;
699
700 check = next;
701
702 do {
703 if (check == session)
704 return NULL;
705
706 check = check->next;
707 } while (check);
708
709 return next;
710}
711
712
713void
715 const char *directory)
716{
718 char *config_file;
719
720
721 GNUNET_assert ((session) && (directory));
722
723 GNUNET_asprintf (&config_file, "%s%s", directory, "session.cfg");
724
726 goto free_config;
727
729 "Load next session configuration of member: %s\n", config_file);
730
732
733 if (! cfg)
734 goto free_config;
735
737 {
738 struct GNUNET_CRYPTO_PublicKey next_key;
739 enum GNUNET_GenericReturnValue key_result;
741 char *key_data;
742
744 "next_key",
745 &key_data))
746 goto destroy_config;
747
748 key_result = GNUNET_CRYPTO_public_key_from_string (key_data, &next_key);
749 GNUNET_free (key_data);
750
751 if (GNUNET_OK != key_result)
752 goto destroy_config;
753
754 if (GNUNET_OK != GNUNET_CONFIGURATION_get_data (cfg, "session", "next_id",
755 &next_id, sizeof(next_id)))
756 goto destroy_config;
757
758 {
759 struct GNUNET_MESSENGER_Member *member;
760
761 member = get_store_member (session->member->store, &next_id);
762
764 session, member? get_member_session (member, &next_key) : NULL
765 );
766 }
767
768 if (session->next)
769 session->next->prev = session;
770 }
771
772destroy_config:
774
775free_config:
777}
778
779
782 const struct GNUNET_HashCode *key,
783 void *value)
784{
786 unsigned char ownership;
787
788 GNUNET_assert ((cls) && (key));
789
790 handle = cls;
791 ownership = value? GNUNET_YES : GNUNET_NO;
792
794 GNUNET_DISK_file_write (handle, &ownership, sizeof(ownership));
795
796 return GNUNET_YES;
797}
798
799
800static void
802 const char *path)
803{
805
806 GNUNET_assert ((session) && (path));
807
808 {
809 enum GNUNET_DISK_AccessPermissions permission;
810
812
815 );
816 }
817
818 if (! handle)
819 return;
820
822
824 session->history,
826 handle
827 );
828
831}
832
833
834void
836 const char *directory)
837{
839 char *config_file;
840 char *key_data;
841
842 GNUNET_assert ((session) && (directory));
843
844 GNUNET_asprintf (&config_file, "%s%s", directory, "session.cfg");
845
847 "Save session configuration of member: %s\n", config_file);
848
850
851 if (! cfg)
852 goto free_config;
853
856
857 if (key_data)
858 {
859 GNUNET_CONFIGURATION_set_value_string (cfg, "session", "key", key_data);
860 GNUNET_free (key_data);
861 }
862
863 if (session->next)
864 {
866 session->next);
867
868 char *next_id_data = GNUNET_STRINGS_data_to_string_alloc (next_id,
869 sizeof(*next_id));
870
871 if (next_id_data)
872 {
873 GNUNET_CONFIGURATION_set_value_string (cfg, "session", "next_id",
874 next_id_data);
875 GNUNET_free (next_id_data);
876 }
877
880
881 if (key_data)
882 {
883 GNUNET_CONFIGURATION_set_value_string (cfg, "session", "next_key",
884 key_data);
885 GNUNET_free (key_data);
886 }
887 }
888
889 GNUNET_CONFIGURATION_set_value_number (cfg, "session", "start",
890 session->start.abs_value_us);
891
892 GNUNET_CONFIGURATION_set_value_number (cfg, "session", "closed",
893 session->closed);
894 GNUNET_CONFIGURATION_set_value_number (cfg, "session", "completed",
895 session->completed);
896
899
900free_config:
902
903 {
904 char *history_file;
905 GNUNET_asprintf (&history_file, "%s%s", directory, "history.map");
906
907 save_member_session_history (session, history_file);
908 GNUNET_free (history_file);
909 }
910
911 {
912 char *messages_file;
913 GNUNET_asprintf (&messages_file, "%s%s", directory, "messages.list");
914
915 save_list_messages (&(session->messages), messages_file);
916 GNUNET_free (messages_file);
917 }
918}
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_PublicKey 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_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.
void add_member_session(struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSENGER_MemberSession *session)
Adds a given member session to its member.
void clear_member_session_history(struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_HashCode *hash)
Removes a message from the history of a session using the messages hash.
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.
static void clear_member_chain_history(struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_HashCode *hash)
void load_member_session_next(struct GNUNET_MESSENGER_MemberSession *session, const char *directory)
Loads the connection from one session to another through the next attribute.
void close_member_session(struct GNUNET_MESSENGER_MemberSession *session)
Closes a given member session which opens the request for completion of the 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.
static void update_member_chain_history(struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_HashCode *hash, enum GNUNET_GenericReturnValue ownership)
static void load_member_session_history(struct GNUNET_MESSENGER_MemberSession *session, const char *path)
static enum GNUNET_GenericReturnValue iterate_save_member_session_history_hentries(void *cls, const struct GNUNET_HashCode *key, void *value)
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 reset_member_session(struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_HashCode *hash)
Resets a given member session which re-opens a member session for new usage.
static void check_member_session_completion(struct GNUNET_MESSENGER_MemberSession *session)
const struct GNUNET_HashCode * get_member_session_key(const struct GNUNET_MESSENGER_MemberSession *session)
Returns the key of the room a given member session belongs to.
static enum GNUNET_GenericReturnValue iterate_copy_history(void *cls, const struct GNUNET_HashCode *key, void *value)
struct GNUNET_MESSENGER_Contact * get_member_session_contact(struct GNUNET_MESSENGER_MemberSession *session)
Returns the contact which is connected to a given member session.
struct GNUNET_MESSENGER_MemberSession * switch_member_session(struct GNUNET_MESSENGER_MemberSession *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...
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...
void save_member_session(struct GNUNET_MESSENGER_MemberSession *session, const char *directory)
Saves data from a member session into a directory which can be load to restore the member session com...
struct GNUNET_MESSENGER_MemberSession * create_member_session(struct GNUNET_MESSENGER_Member *member, const struct GNUNET_CRYPTO_PublicKey *pubkey)
Creates and allocates a new member session of a member with a given public key.
enum GNUNET_GenericReturnValue verify_member_session_as_sender(const struct GNUNET_MESSENGER_MemberSession *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 save_member_session_history(struct GNUNET_MESSENGER_MemberSession *session, const char *path)
enum GNUNET_GenericReturnValue is_member_session_completed(const struct GNUNET_MESSENGER_MemberSession *session)
Returns if the given member session has been completed.
enum GNUNET_GenericReturnValue is_member_session_closed(const struct GNUNET_MESSENGER_MemberSession *session)
Returns if the given member session has been closed.
static struct GNUNET_MESSENGER_MemberSession * get_cycle_safe_next_session(struct GNUNET_MESSENGER_MemberSession *session, struct GNUNET_MESSENGER_MemberSession *next)
const struct GNUNET_HashCode * get_member_session_context(const struct GNUNET_MESSENGER_MemberSession *session)
Returns the member context of a given member session.
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.
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.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
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:1238
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:483
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:687
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:206
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:1428
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1309
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:623
@ 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.
Definition: crypto_hash.c:221
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_public_key_to_string(const struct GNUNET_CRYPTO_PublicKey *key)
Creates a (Base32) string representation of the public key.
Definition: crypto_pkey.c:379
#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.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_public_key_from_string(const char *str, struct GNUNET_CRYPTO_PublicKey *key)
Parses a (Base32) string representation of the public key.
Definition: crypto_pkey.c:399
@ 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_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.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:764
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.
void update_store_contact(struct GNUNET_MESSENGER_ContactStore *store, struct GNUNET_MESSENGER_Contact *contact, const struct GNUNET_HashCode *context, const struct GNUNET_HashCode *next_context, const struct GNUNET_CRYPTO_PublicKey *pubkey)
Moves a contact from the store to another location matching a given public key and member context.
struct GNUNET_MESSENGER_Contact * get_store_contact(struct GNUNET_MESSENGER_ContactStore *store, const struct GNUNET_HashCode *context, const struct GNUNET_CRYPTO_PublicKey *pubkey)
Returns a contact using a specific public key.
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.
enum GNUNET_GenericReturnValue verify_message(const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, const struct GNUNET_CRYPTO_PublicKey *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.
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_CONTAINER_MultiHashMap * history
struct GNUNET_MESSENGER_MemberSession * prev
struct GNUNET_MESSENGER_MemberSession * next
struct GNUNET_MESSENGER_ListMessages messages
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_PublicKey key
The new public key which replaces the current senders public key.
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_MESSENGER_MessageBody body
Body.
A 256-bit hashcode.
Time for absolute times used by GNUnet, in microseconds.
uint64_t abs_value_us
The actual value.