diff options
author | Jacki <jacki@thejackimonster.de> | 2024-02-10 05:55:30 +0100 |
---|---|---|
committer | Jacki <jacki@thejackimonster.de> | 2024-02-10 05:55:30 +0100 |
commit | 9d04b7c3981d1e0d25655dcb047c876dd5b275f6 (patch) | |
tree | 7714a8aeda0e1255fedddfff92ac0a5b522b8916 /src | |
parent | ff5b51e8b00440dcf7ee252451947ce0622fd9c1 (diff) | |
download | libgnunetchat-9d04b7c3981d1e0d25655dcb047c876dd5b275f6.tar.gz libgnunetchat-9d04b7c3981d1e0d25655dcb047c876dd5b275f6.zip |
Fix rejections of invitations
Signed-off-by: Jacki <jacki@thejackimonster.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/gnunet_chat_context.c | 8 | ||||
-rw-r--r-- | src/gnunet_chat_context.h | 1 | ||||
-rw-r--r-- | src/gnunet_chat_context_intern.c | 13 | ||||
-rw-r--r-- | src/gnunet_chat_handle_intern.c | 16 | ||||
-rw-r--r-- | src/gnunet_chat_invitation.c | 1 | ||||
-rw-r--r-- | src/gnunet_chat_invitation.h | 1 | ||||
-rw-r--r-- | src/gnunet_chat_lib.c | 16 |
7 files changed, 36 insertions, 20 deletions
diff --git a/src/gnunet_chat_context.c b/src/gnunet_chat_context.c index 128fe8b..d7073ed 100644 --- a/src/gnunet_chat_context.c +++ b/src/gnunet_chat_context.c | |||
@@ -48,6 +48,8 @@ init_new_context (struct GNUNET_CHAT_Context *context, | |||
48 | initial_map_size, GNUNET_NO); | 48 | initial_map_size, GNUNET_NO); |
49 | context->messages = GNUNET_CONTAINER_multihashmap_create( | 49 | context->messages = GNUNET_CONTAINER_multihashmap_create( |
50 | initial_map_size, GNUNET_NO); | 50 | initial_map_size, GNUNET_NO); |
51 | context->rejections = GNUNET_CONTAINER_multihashmap_create( | ||
52 | initial_map_size, GNUNET_NO); | ||
51 | context->invites = GNUNET_CONTAINER_multihashmap_create( | 53 | context->invites = GNUNET_CONTAINER_multihashmap_create( |
52 | initial_map_size, GNUNET_NO); | 54 | initial_map_size, GNUNET_NO); |
53 | context->files = GNUNET_CONTAINER_multihashmap_create( | 55 | context->files = GNUNET_CONTAINER_multihashmap_create( |
@@ -107,6 +109,7 @@ context_destroy (struct GNUNET_CHAT_Context *context) | |||
107 | (context->timestamps) && | 109 | (context->timestamps) && |
108 | (context->dependencies) && | 110 | (context->dependencies) && |
109 | (context->messages) && | 111 | (context->messages) && |
112 | (context->rejections) && | ||
110 | (context->invites) && | 113 | (context->invites) && |
111 | (context->files) | 114 | (context->files) |
112 | ); | 115 | ); |
@@ -124,6 +127,10 @@ context_destroy (struct GNUNET_CHAT_Context *context) | |||
124 | ); | 127 | ); |
125 | 128 | ||
126 | GNUNET_CONTAINER_multihashmap_iterate( | 129 | GNUNET_CONTAINER_multihashmap_iterate( |
130 | context->rejections, it_destroy_context_rejections, NULL | ||
131 | ); | ||
132 | |||
133 | GNUNET_CONTAINER_multihashmap_iterate( | ||
127 | context->invites, it_destroy_context_invites, NULL | 134 | context->invites, it_destroy_context_invites, NULL |
128 | ); | 135 | ); |
129 | 136 | ||
@@ -132,6 +139,7 @@ context_destroy (struct GNUNET_CHAT_Context *context) | |||
132 | GNUNET_CONTAINER_multishortmap_destroy(context->timestamps); | 139 | GNUNET_CONTAINER_multishortmap_destroy(context->timestamps); |
133 | GNUNET_CONTAINER_multihashmap_destroy(context->dependencies); | 140 | GNUNET_CONTAINER_multihashmap_destroy(context->dependencies); |
134 | GNUNET_CONTAINER_multihashmap_destroy(context->messages); | 141 | GNUNET_CONTAINER_multihashmap_destroy(context->messages); |
142 | GNUNET_CONTAINER_multihashmap_destroy(context->rejections); | ||
135 | GNUNET_CONTAINER_multihashmap_destroy(context->invites); | 143 | GNUNET_CONTAINER_multihashmap_destroy(context->invites); |
136 | GNUNET_CONTAINER_multihashmap_destroy(context->files); | 144 | GNUNET_CONTAINER_multihashmap_destroy(context->files); |
137 | 145 | ||
diff --git a/src/gnunet_chat_context.h b/src/gnunet_chat_context.h index 8ba05d5..ffac61f 100644 --- a/src/gnunet_chat_context.h +++ b/src/gnunet_chat_context.h | |||
@@ -45,6 +45,7 @@ struct GNUNET_CHAT_Context | |||
45 | struct GNUNET_CONTAINER_MultiShortmap *timestamps; | 45 | struct GNUNET_CONTAINER_MultiShortmap *timestamps; |
46 | struct GNUNET_CONTAINER_MultiHashMap *dependencies; | 46 | struct GNUNET_CONTAINER_MultiHashMap *dependencies; |
47 | struct GNUNET_CONTAINER_MultiHashMap *messages; | 47 | struct GNUNET_CONTAINER_MultiHashMap *messages; |
48 | struct GNUNET_CONTAINER_MultiHashMap *rejections; | ||
48 | struct GNUNET_CONTAINER_MultiHashMap *invites; | 49 | struct GNUNET_CONTAINER_MultiHashMap *invites; |
49 | struct GNUNET_CONTAINER_MultiHashMap *files; | 50 | struct GNUNET_CONTAINER_MultiHashMap *files; |
50 | 51 | ||
diff --git a/src/gnunet_chat_context_intern.c b/src/gnunet_chat_context_intern.c index f50da29..17b4222 100644 --- a/src/gnunet_chat_context_intern.c +++ b/src/gnunet_chat_context_intern.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include "gnunet_chat_invitation.h" | 25 | #include "gnunet_chat_invitation.h" |
26 | #include "gnunet_chat_message.h" | 26 | #include "gnunet_chat_message.h" |
27 | 27 | ||
28 | #include <gnunet/gnunet_common.h> | ||
28 | #include <gnunet/gnunet_error_codes.h> | 29 | #include <gnunet/gnunet_error_codes.h> |
29 | 30 | ||
30 | #define GNUNET_UNUSED __attribute__ ((unused)) | 31 | #define GNUNET_UNUSED __attribute__ ((unused)) |
@@ -54,6 +55,18 @@ it_destroy_context_messages (GNUNET_UNUSED void *cls, | |||
54 | } | 55 | } |
55 | 56 | ||
56 | int | 57 | int |
58 | it_destroy_context_rejections (GNUNET_UNUSED void *cls, | ||
59 | GNUNET_UNUSED const struct GNUNET_HashCode *key, | ||
60 | void *value) | ||
61 | { | ||
62 | GNUNET_assert(value); | ||
63 | |||
64 | struct GNUNET_HashCode *hash = value; | ||
65 | GNUNET_free(hash); | ||
66 | return GNUNET_YES; | ||
67 | } | ||
68 | |||
69 | int | ||
57 | it_destroy_context_invites (GNUNET_UNUSED void *cls, | 70 | it_destroy_context_invites (GNUNET_UNUSED void *cls, |
58 | GNUNET_UNUSED const struct GNUNET_HashCode *key, | 71 | GNUNET_UNUSED const struct GNUNET_HashCode *key, |
59 | void *value) | 72 | void *value) |
diff --git a/src/gnunet_chat_handle_intern.c b/src/gnunet_chat_handle_intern.c index 91e5953..25847ed 100644 --- a/src/gnunet_chat_handle_intern.c +++ b/src/gnunet_chat_handle_intern.c | |||
@@ -1004,13 +1004,17 @@ on_handle_message (void *cls, | |||
1004 | if (msg->body.tag.tag) | 1004 | if (msg->body.tag.tag) |
1005 | break; | 1005 | break; |
1006 | 1006 | ||
1007 | struct GNUNET_CHAT_Invitation *invitation = GNUNET_CONTAINER_multihashmap_get( | 1007 | struct GNUNET_HashCode *rejection = GNUNET_new(struct GNUNET_HashCode); |
1008 | context->invites, &(msg->body.tag.hash) | 1008 | |
1009 | ); | 1009 | if (!rejection) |
1010 | break; | ||
1010 | 1011 | ||
1011 | if (invitation) | 1012 | GNUNET_memcpy(rejection, hash, sizeof(struct GNUNET_HashCode)); |
1012 | GNUNET_memcpy(&(invitation->rejection), hash, | 1013 | |
1013 | sizeof(invitation->rejection)); | 1014 | if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put( |
1015 | context->rejections, &(msg->body.tag.hash), rejection, | ||
1016 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)) | ||
1017 | GNUNET_free (rejection); | ||
1014 | 1018 | ||
1015 | break; | 1019 | break; |
1016 | } | 1020 | } |
diff --git a/src/gnunet_chat_invitation.c b/src/gnunet_chat_invitation.c index e06ad6a..7137156 100644 --- a/src/gnunet_chat_invitation.c +++ b/src/gnunet_chat_invitation.c | |||
@@ -37,7 +37,6 @@ invitation_create_from_message (struct GNUNET_CHAT_Context *context, | |||
37 | invitation->context = context; | 37 | invitation->context = context; |
38 | 38 | ||
39 | GNUNET_memcpy(&(invitation->hash), hash, sizeof(invitation->hash)); | 39 | GNUNET_memcpy(&(invitation->hash), hash, sizeof(invitation->hash)); |
40 | GNUNET_memcpy(&(invitation->rejection), hash, sizeof(invitation->rejection)); | ||
41 | 40 | ||
42 | GNUNET_memcpy(&(invitation->key), &(message->key), sizeof(invitation->key)); | 41 | GNUNET_memcpy(&(invitation->key), &(message->key), sizeof(invitation->key)); |
43 | invitation->door = GNUNET_PEER_intern(&(message->door)); | 42 | invitation->door = GNUNET_PEER_intern(&(message->door)); |
diff --git a/src/gnunet_chat_invitation.h b/src/gnunet_chat_invitation.h index 6336ed7..0f08d07 100644 --- a/src/gnunet_chat_invitation.h +++ b/src/gnunet_chat_invitation.h | |||
@@ -35,7 +35,6 @@ struct GNUNET_CHAT_Invitation | |||
35 | struct GNUNET_CHAT_Context *context; | 35 | struct GNUNET_CHAT_Context *context; |
36 | 36 | ||
37 | struct GNUNET_HashCode hash; | 37 | struct GNUNET_HashCode hash; |
38 | struct GNUNET_HashCode rejection; | ||
39 | 38 | ||
40 | struct GNUNET_HashCode key; | 39 | struct GNUNET_HashCode key; |
41 | GNUNET_PEER_Id door; | 40 | GNUNET_PEER_Id door; |
diff --git a/src/gnunet_chat_lib.c b/src/gnunet_chat_lib.c index b2eaaea..40e0482 100644 --- a/src/gnunet_chat_lib.c +++ b/src/gnunet_chat_lib.c | |||
@@ -2204,7 +2204,7 @@ GNUNET_CHAT_invitation_is_accepted (const struct GNUNET_CHAT_Invitation *invitat | |||
2204 | return GNUNET_NO; | 2204 | return GNUNET_NO; |
2205 | 2205 | ||
2206 | return GNUNET_CONTAINER_multihashmap_contains( | 2206 | return GNUNET_CONTAINER_multihashmap_contains( |
2207 | invitation->context->handle->contexts, | 2207 | invitation->context->handle->contexts, |
2208 | &(invitation->key) | 2208 | &(invitation->key) |
2209 | ); | 2209 | ); |
2210 | } | 2210 | } |
@@ -2218,18 +2218,10 @@ GNUNET_CHAT_invitation_is_rejected (const struct GNUNET_CHAT_Invitation *invitat | |||
2218 | if (!invitation) | 2218 | if (!invitation) |
2219 | return GNUNET_NO; | 2219 | return GNUNET_NO; |
2220 | 2220 | ||
2221 | if (0 == GNUNET_CRYPTO_hash_cmp(&(invitation->hash), &(invitation->rejection))) | 2221 | return GNUNET_CONTAINER_multihashmap_contains( |
2222 | return GNUNET_NO; | 2222 | invitation->context->rejections, |
2223 | 2223 | &(invitation->hash) | |
2224 | const struct GNUNET_CHAT_Message *message = GNUNET_CONTAINER_multihashmap_get( | ||
2225 | invitation->context->messages, &(invitation->rejection) | ||
2226 | ); | 2224 | ); |
2227 | |||
2228 | if ((!message) || (!message->msg) || (message->msg->header.kind != GNUNET_MESSENGER_KIND_TAG) || | ||
2229 | (message->msg->body.tag.tag)) | ||
2230 | return GNUNET_NO; | ||
2231 | else | ||
2232 | return GNUNET_YES; | ||
2233 | } | 2225 | } |
2234 | 2226 | ||
2235 | 2227 | ||