aboutsummaryrefslogtreecommitdiff
path: root/src/messenger/gnunet-service-messenger_message_kind.c
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2020-11-01 22:57:28 +0100
committerTheJackiMonster <thejackimonster@gmail.com>2021-03-06 01:30:37 +0100
commit2925310d67483aca6e055e1ce0593c6463cd6c72 (patch)
tree2cc8aacafc25563cdccde2eee9a90f9ca257d405 /src/messenger/gnunet-service-messenger_message_kind.c
parent82b864a64679b0a735201724907cdf2b7e4e16c3 (diff)
downloadgnunet-2925310d67483aca6e055e1ce0593c6463cd6c72.tar.gz
gnunet-2925310d67483aca6e055e1ce0593c6463cd6c72.zip
-added core functionality of the messenger service
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> formatting messenger code Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -completed core functionality of messenger service Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -code cleanup and reuse Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> +added structure to memberships of rooms Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -implemented member permission checks and deletion of messages Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -moved solving requests out of updating last messages (also forward before update) Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -reduced complexity of permisson check and changed load/save of rooms Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -added save/load for accessed keys and basement peers of a room Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -implemented save/load for members with their history and session Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -abstracted management of egos and contacts Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -fix warning Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -abstracted management of members Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -fixed and adjusted test case Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -separated handling of direct and anonymous contacts Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -messenger added member-sessions which fix multiple edge cases, also additional cleanup Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -updated docs and fixed memory leak Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -changed info messages and added protocol version exchange Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -adjusted client api to use contacts from sessions Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -added more logging and fixed wrong session usage Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -adjusted comm0 test case and removed adding members from checking messages Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -fixed test-case for peer exchange Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -getting multiple peers connected in test-case with cadet Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -fixed wrong assert and added tunnel version check -simplified handling and forwarding Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -fixed merging last messages and cycling info messages Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -automated adding sessions and members Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -corrected use of identity keys and signatures Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -adding local joining on entering external room Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -fixed test-case comm0 Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -added more test-cases with generic setup Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -fixed multiple simultaneous channels blocking each other Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -making test-cases more precise Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -added check of members in test-cases, reduced merge messages Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -unified delayed operations: requests, deletions and merges Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -finished handling of operations Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -fixed member session historystorage, added request permission check and padding for transmission Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -improved padding and removed automatic recursive requests Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -implemented filter for sending messages and added private messages to API level Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -wrong setups fixed with proper ego lookups Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -fixed problem with anonymous ego and changed to discrete-level padding Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -added links to replace deleted messages, added local deletion and fixed anonymous id changing Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -added session completion and removal through completion process Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
Diffstat (limited to 'src/messenger/gnunet-service-messenger_message_kind.c')
-rw-r--r--src/messenger/gnunet-service-messenger_message_kind.c69
1 files changed, 58 insertions, 11 deletions
diff --git a/src/messenger/gnunet-service-messenger_message_kind.c b/src/messenger/gnunet-service-messenger_message_kind.c
index 9c829fe09..ef9bbfd2e 100644
--- a/src/messenger/gnunet-service-messenger_message_kind.c
+++ b/src/messenger/gnunet-service-messenger_message_kind.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2020 GNUnet e.V. 3 Copyright (C) 2020--2021 GNUnet e.V.
4 4
5 GNUnet is free software: you can redistribute it and/or modify it 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 6 under the terms of the GNU Affero General Public License as published
@@ -24,11 +24,15 @@
24 */ 24 */
25 25
26#include "gnunet-service-messenger_message_kind.h" 26#include "gnunet-service-messenger_message_kind.h"
27#include "gnunet-service-messenger_util.h" 27
28#include "messenger_api_util.h"
28 29
29struct GNUNET_MESSENGER_Message* 30struct GNUNET_MESSENGER_Message*
30create_message_info (struct GNUNET_MESSENGER_Ego *ego, struct GNUNET_CONTAINER_MultiShortmap *members) 31create_message_info (const struct GNUNET_MESSENGER_Ego *ego)
31{ 32{
33 if (!ego)
34 return NULL;
35
32 struct GNUNET_MESSENGER_Message *message = create_message (GNUNET_MESSENGER_KIND_INFO); 36 struct GNUNET_MESSENGER_Message *message = create_message (GNUNET_MESSENGER_KIND_INFO);
33 37
34 if (!message) 38 if (!message)
@@ -36,18 +40,17 @@ create_message_info (struct GNUNET_MESSENGER_Ego *ego, struct GNUNET_CONTAINER_M
36 40
37 GNUNET_memcpy(&(message->body.info.host_key), &(ego->pub), sizeof(ego->pub)); 41 GNUNET_memcpy(&(message->body.info.host_key), &(ego->pub), sizeof(ego->pub));
38 42
39 if (GNUNET_YES == generate_free_member_id (&(message->body.info.unique_id), members)) 43 message->body.info.messenger_version = GNUNET_MESSENGER_VERSION;
40 return message; 44
41 else 45 return message;
42 {
43 destroy_message (message);
44 return NULL;
45 }
46} 46}
47 47
48struct GNUNET_MESSENGER_Message* 48struct GNUNET_MESSENGER_Message*
49create_message_join (struct GNUNET_MESSENGER_Ego *ego) 49create_message_join (const struct GNUNET_MESSENGER_Ego *ego)
50{ 50{
51 if (!ego)
52 return NULL;
53
51 struct GNUNET_MESSENGER_Message *message = create_message (GNUNET_MESSENGER_KIND_JOIN); 54 struct GNUNET_MESSENGER_Message *message = create_message (GNUNET_MESSENGER_KIND_JOIN);
52 55
53 if (!message) 56 if (!message)
@@ -67,6 +70,9 @@ create_message_leave ()
67struct GNUNET_MESSENGER_Message* 70struct GNUNET_MESSENGER_Message*
68create_message_name (const char *name) 71create_message_name (const char *name)
69{ 72{
73 if (!name)
74 return NULL;
75
70 struct GNUNET_MESSENGER_Message *message = create_message (GNUNET_MESSENGER_KIND_NAME); 76 struct GNUNET_MESSENGER_Message *message = create_message (GNUNET_MESSENGER_KIND_NAME);
71 77
72 if (!message) 78 if (!message)
@@ -79,6 +85,9 @@ create_message_name (const char *name)
79struct GNUNET_MESSENGER_Message* 85struct GNUNET_MESSENGER_Message*
80create_message_key (const struct GNUNET_IDENTITY_PrivateKey *key) 86create_message_key (const struct GNUNET_IDENTITY_PrivateKey *key)
81{ 87{
88 if (!key)
89 return NULL;
90
82 struct GNUNET_MESSENGER_Message *message = create_message (GNUNET_MESSENGER_KIND_KEY); 91 struct GNUNET_MESSENGER_Message *message = create_message (GNUNET_MESSENGER_KIND_KEY);
83 92
84 if (!message) 93 if (!message)
@@ -91,6 +100,9 @@ create_message_key (const struct GNUNET_IDENTITY_PrivateKey *key)
91struct GNUNET_MESSENGER_Message* 100struct GNUNET_MESSENGER_Message*
92create_message_peer (const struct GNUNET_MESSENGER_Service *service) 101create_message_peer (const struct GNUNET_MESSENGER_Service *service)
93{ 102{
103 if (!service)
104 return NULL;
105
94 struct GNUNET_MESSENGER_Message *message = create_message (GNUNET_MESSENGER_KIND_PEER); 106 struct GNUNET_MESSENGER_Message *message = create_message (GNUNET_MESSENGER_KIND_PEER);
95 107
96 if (!message) 108 if (!message)
@@ -108,6 +120,9 @@ create_message_peer (const struct GNUNET_MESSENGER_Service *service)
108struct GNUNET_MESSENGER_Message* 120struct GNUNET_MESSENGER_Message*
109create_message_id (const struct GNUNET_ShortHashCode *unique_id) 121create_message_id (const struct GNUNET_ShortHashCode *unique_id)
110{ 122{
123 if (!unique_id)
124 return NULL;
125
111 struct GNUNET_MESSENGER_Message *message = create_message (GNUNET_MESSENGER_KIND_ID); 126 struct GNUNET_MESSENGER_Message *message = create_message (GNUNET_MESSENGER_KIND_ID);
112 127
113 if (!message) 128 if (!message)
@@ -121,6 +136,9 @@ create_message_id (const struct GNUNET_ShortHashCode *unique_id)
121struct GNUNET_MESSENGER_Message* 136struct GNUNET_MESSENGER_Message*
122create_message_miss (const struct GNUNET_PeerIdentity *peer) 137create_message_miss (const struct GNUNET_PeerIdentity *peer)
123{ 138{
139 if (!peer)
140 return NULL;
141
124 struct GNUNET_MESSENGER_Message *message = create_message (GNUNET_MESSENGER_KIND_MISS); 142 struct GNUNET_MESSENGER_Message *message = create_message (GNUNET_MESSENGER_KIND_MISS);
125 143
126 if (!message) 144 if (!message)
@@ -136,6 +154,9 @@ create_message_miss (const struct GNUNET_PeerIdentity *peer)
136struct GNUNET_MESSENGER_Message* 154struct GNUNET_MESSENGER_Message*
137create_message_merge (const struct GNUNET_HashCode *previous) 155create_message_merge (const struct GNUNET_HashCode *previous)
138{ 156{
157 if (!previous)
158 return NULL;
159
139 struct GNUNET_MESSENGER_Message *message = create_message (GNUNET_MESSENGER_KIND_MERGE); 160 struct GNUNET_MESSENGER_Message *message = create_message (GNUNET_MESSENGER_KIND_MERGE);
140 161
141 if (!message) 162 if (!message)
@@ -149,6 +170,9 @@ create_message_merge (const struct GNUNET_HashCode *previous)
149struct GNUNET_MESSENGER_Message* 170struct GNUNET_MESSENGER_Message*
150create_message_request (const struct GNUNET_HashCode *hash) 171create_message_request (const struct GNUNET_HashCode *hash)
151{ 172{
173 if (!hash)
174 return NULL;
175
152 struct GNUNET_HashCode zero; 176 struct GNUNET_HashCode zero;
153 memset (&zero, 0, sizeof(zero)); 177 memset (&zero, 0, sizeof(zero));
154 178
@@ -168,6 +192,9 @@ create_message_request (const struct GNUNET_HashCode *hash)
168struct GNUNET_MESSENGER_Message* 192struct GNUNET_MESSENGER_Message*
169create_message_invite (const struct GNUNET_PeerIdentity *door, const struct GNUNET_HashCode *key) 193create_message_invite (const struct GNUNET_PeerIdentity *door, const struct GNUNET_HashCode *key)
170{ 194{
195 if ((!door) || (!key))
196 return NULL;
197
171 struct GNUNET_MESSENGER_Message *message = create_message (GNUNET_MESSENGER_KIND_INVITE); 198 struct GNUNET_MESSENGER_Message *message = create_message (GNUNET_MESSENGER_KIND_INVITE);
172 199
173 if (!message) 200 if (!message)
@@ -182,6 +209,9 @@ create_message_invite (const struct GNUNET_PeerIdentity *door, const struct GNUN
182struct GNUNET_MESSENGER_Message* 209struct GNUNET_MESSENGER_Message*
183create_message_text (const char *text) 210create_message_text (const char *text)
184{ 211{
212 if (!text)
213 return NULL;
214
185 struct GNUNET_MESSENGER_Message *message = create_message (GNUNET_MESSENGER_KIND_TEXT); 215 struct GNUNET_MESSENGER_Message *message = create_message (GNUNET_MESSENGER_KIND_TEXT);
186 216
187 if (!message) 217 if (!message)
@@ -190,3 +220,20 @@ create_message_text (const char *text)
190 message->body.text.text = GNUNET_strdup(text); 220 message->body.text.text = GNUNET_strdup(text);
191 return message; 221 return message;
192} 222}
223
224struct GNUNET_MESSENGER_Message*
225create_message_delete (const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)
226{
227 if (!hash)
228 return NULL;
229
230 struct GNUNET_MESSENGER_Message *message = create_message (GNUNET_MESSENGER_KIND_DELETE);
231
232 if (!message)
233 return NULL;
234
235 GNUNET_memcpy(&(message->body.delete.hash), hash, sizeof(struct GNUNET_HashCode));
236 message->body.delete.delay = GNUNET_TIME_relative_hton (delay);
237
238 return message;
239}