diff options
author | TheJackiMonster <thejackimonster@gmail.com> | 2024-01-02 19:15:38 +0100 |
---|---|---|
committer | TheJackiMonster <thejackimonster@gmail.com> | 2024-01-02 19:15:38 +0100 |
commit | db937c59ca9c1d4679706851e4fefc06bbdbe640 (patch) | |
tree | 9ad41fadf83153238d0b64cdce57ed0c054e517c | |
parent | a118acdd652d35fc2445370ef7b7b86c510367d5 (diff) | |
download | gnunet-db937c59ca9c1d4679706851e4fefc06bbdbe640.tar.gz gnunet-db937c59ca9c1d4679706851e4fefc06bbdbe640.zip |
MESSENGER: Implement ticket message
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r-- | src/include/gnunet_messenger_service.h | 21 | ||||
-rw-r--r-- | src/service/messenger/messenger_api_message.c | 14 | ||||
-rw-r--r-- | src/service/messenger/messenger_api_message_kind.c | 18 | ||||
-rw-r--r-- | src/service/messenger/messenger_api_message_kind.h | 15 |
4 files changed, 67 insertions, 1 deletions
diff --git a/src/include/gnunet_messenger_service.h b/src/include/gnunet_messenger_service.h index c647272df..ad4151aed 100644 --- a/src/include/gnunet_messenger_service.h +++ b/src/include/gnunet_messenger_service.h | |||
@@ -42,6 +42,7 @@ extern "C" { | |||
42 | #include "gnunet_common.h" | 42 | #include "gnunet_common.h" |
43 | #include "gnunet_configuration_lib.h" | 43 | #include "gnunet_configuration_lib.h" |
44 | #include "gnunet_identity_service.h" | 44 | #include "gnunet_identity_service.h" |
45 | #include "gnunet_reclaim_lib.h" | ||
45 | #include "gnunet_scheduler_lib.h" | 46 | #include "gnunet_scheduler_lib.h" |
46 | #include "gnunet_time_lib.h" | 47 | #include "gnunet_time_lib.h" |
47 | #include "gnunet_util_lib.h" | 48 | #include "gnunet_util_lib.h" |
@@ -201,6 +202,11 @@ enum GNUNET_MESSENGER_MessageKind | |||
201 | GNUNET_MESSENGER_KIND_CONNECTION = 16, | 202 | GNUNET_MESSENGER_KIND_CONNECTION = 16, |
202 | 203 | ||
203 | /** | 204 | /** |
205 | * The ticket kind. The message contains a #GNUNET_MESSENGER_MessageTicket body. | ||
206 | */ | ||
207 | GNUNET_MESSENGER_KIND_TICKET = 17, | ||
208 | |||
209 | /** | ||
204 | * The unknown kind. The message contains an unknown body. | 210 | * The unknown kind. The message contains an unknown body. |
205 | */ | 211 | */ |
206 | GNUNET_MESSENGER_KIND_UNKNOWN = 0 | 212 | GNUNET_MESSENGER_KIND_UNKNOWN = 0 |
@@ -516,6 +522,20 @@ struct GNUNET_MESSENGER_MessageConnection | |||
516 | }; | 522 | }; |
517 | 523 | ||
518 | /** | 524 | /** |
525 | * A ticket message body | ||
526 | * This allows to exchange ticket identifiers with an audience. | ||
527 | * | ||
528 | * Message-body-size: 32 bytes | ||
529 | */ | ||
530 | struct GNUNET_MESSENGER_MessageTicket | ||
531 | { | ||
532 | /** | ||
533 | * The identifier of a RECLAIM ticket. | ||
534 | */ | ||
535 | struct GNUNET_RECLAIM_Identifier identifier; | ||
536 | }; | ||
537 | |||
538 | /** | ||
519 | * The unified body of a #GNUNET_MESSENGER_Message. | 539 | * The unified body of a #GNUNET_MESSENGER_Message. |
520 | */ | 540 | */ |
521 | struct GNUNET_MESSENGER_MessageBody | 541 | struct GNUNET_MESSENGER_MessageBody |
@@ -538,6 +558,7 @@ struct GNUNET_MESSENGER_MessageBody | |||
538 | struct GNUNET_MESSENGER_MessagePrivate privacy; | 558 | struct GNUNET_MESSENGER_MessagePrivate privacy; |
539 | struct GNUNET_MESSENGER_MessageDelete deletion; | 559 | struct GNUNET_MESSENGER_MessageDelete deletion; |
540 | struct GNUNET_MESSENGER_MessageConnection connection; | 560 | struct GNUNET_MESSENGER_MessageConnection connection; |
561 | struct GNUNET_MESSENGER_MessageTicket ticket; | ||
541 | }; | 562 | }; |
542 | }; | 563 | }; |
543 | 564 | ||
diff --git a/src/service/messenger/messenger_api_message.c b/src/service/messenger/messenger_api_message.c index 51213bce5..486a0e081 100644 --- a/src/service/messenger/messenger_api_message.c +++ b/src/service/messenger/messenger_api_message.c | |||
@@ -24,6 +24,7 @@ | |||
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include "messenger_api_message.h" | 26 | #include "messenger_api_message.h" |
27 | #include "gnunet_messenger_service.h" | ||
27 | 28 | ||
28 | struct GNUNET_MESSENGER_MessageSignature | 29 | struct GNUNET_MESSENGER_MessageSignature |
29 | { | 30 | { |
@@ -244,6 +245,9 @@ get_message_body_kind_size (enum GNUNET_MESSENGER_MessageKind kind) | |||
244 | length += member_size (struct GNUNET_MESSENGER_Message, body.connection.amount); | 245 | length += member_size (struct GNUNET_MESSENGER_Message, body.connection.amount); |
245 | length += member_size (struct GNUNET_MESSENGER_Message, body.connection.flags); | 246 | length += member_size (struct GNUNET_MESSENGER_Message, body.connection.flags); |
246 | break; | 247 | break; |
248 | case GNUNET_MESSENGER_KIND_TICKET: | ||
249 | length += member_size (struct GNUNET_MESSENGER_Message, body.ticket.identifier); | ||
250 | break; | ||
247 | default: | 251 | default: |
248 | break; | 252 | break; |
249 | } | 253 | } |
@@ -497,6 +501,9 @@ encode_message_body (enum GNUNET_MESSENGER_MessageKind kind, | |||
497 | encode_step (buffer, offset, &value0); | 501 | encode_step (buffer, offset, &value0); |
498 | encode_step (buffer, offset, &value1); | 502 | encode_step (buffer, offset, &value1); |
499 | break; | 503 | break; |
504 | case GNUNET_MESSENGER_KIND_TICKET: | ||
505 | encode_step (buffer, offset, &(body->ticket.identifier)); | ||
506 | break; | ||
500 | default: | 507 | default: |
501 | break; | 508 | break; |
502 | } | 509 | } |
@@ -686,6 +693,9 @@ decode_message_body (enum GNUNET_MESSENGER_MessageKind *kind, | |||
686 | body->connection.amount = GNUNET_be32toh (value0); | 693 | body->connection.amount = GNUNET_be32toh (value0); |
687 | body->connection.flags = GNUNET_be32toh (value1); | 694 | body->connection.flags = GNUNET_be32toh (value1); |
688 | break; | 695 | break; |
696 | case GNUNET_MESSENGER_KIND_TICKET: | ||
697 | decode_step (buffer, offset, &(body->ticket.identifier)); | ||
698 | break; | ||
689 | default: | 699 | default: |
690 | *kind = GNUNET_MESSENGER_KIND_UNKNOWN; | 700 | *kind = GNUNET_MESSENGER_KIND_UNKNOWN; |
691 | break; | 701 | break; |
@@ -1119,6 +1129,8 @@ is_service_message (const struct GNUNET_MESSENGER_Message *message) | |||
1119 | return GNUNET_YES; // Deletion should not apply individually! (inefficieny) | 1129 | return GNUNET_YES; // Deletion should not apply individually! (inefficieny) |
1120 | case GNUNET_MESSENGER_KIND_CONNECTION: | 1130 | case GNUNET_MESSENGER_KIND_CONNECTION: |
1121 | return GNUNET_YES; // Reserved for connection handling only! | 1131 | return GNUNET_YES; // Reserved for connection handling only! |
1132 | case GNUNET_MESSENGER_KIND_TICKET: | ||
1133 | return GNUNET_NO; | ||
1122 | default: | 1134 | default: |
1123 | return GNUNET_SYSERR; | 1135 | return GNUNET_SYSERR; |
1124 | } | 1136 | } |
@@ -1165,6 +1177,8 @@ filter_message_sending (const struct GNUNET_MESSENGER_Message *message) | |||
1165 | return GNUNET_YES; | 1177 | return GNUNET_YES; |
1166 | case GNUNET_MESSENGER_KIND_CONNECTION: | 1178 | case GNUNET_MESSENGER_KIND_CONNECTION: |
1167 | return GNUNET_SYSERR; // Reserved for connection handling only! | 1179 | return GNUNET_SYSERR; // Reserved for connection handling only! |
1180 | case GNUNET_MESSENGER_KIND_TICKET: | ||
1181 | return GNUNET_YES; | ||
1168 | default: | 1182 | default: |
1169 | return GNUNET_SYSERR; | 1183 | return GNUNET_SYSERR; |
1170 | } | 1184 | } |
diff --git a/src/service/messenger/messenger_api_message_kind.c b/src/service/messenger/messenger_api_message_kind.c index 7e8fd7a1d..c9cf227a2 100644 --- a/src/service/messenger/messenger_api_message_kind.c +++ b/src/service/messenger/messenger_api_message_kind.c | |||
@@ -187,3 +187,21 @@ create_message_delete (const struct GNUNET_HashCode *hash, | |||
187 | 187 | ||
188 | return message; | 188 | return message; |
189 | } | 189 | } |
190 | |||
191 | struct GNUNET_MESSENGER_Message* | ||
192 | create_message_ticket (const struct GNUNET_RECLAIM_Identifier *identifier) | ||
193 | { | ||
194 | if (! identifier) | ||
195 | return NULL; | ||
196 | |||
197 | struct GNUNET_MESSENGER_Message *message = create_message ( | ||
198 | GNUNET_MESSENGER_KIND_TICKET); | ||
199 | |||
200 | if (! message) | ||
201 | return NULL; | ||
202 | |||
203 | GNUNET_memcpy (&(message->body.ticket.identifier), identifier, | ||
204 | sizeof(struct GNUNET_RECLAIM_Identifier)); | ||
205 | |||
206 | return message; | ||
207 | } | ||
diff --git a/src/service/messenger/messenger_api_message_kind.h b/src/service/messenger/messenger_api_message_kind.h index 01bc9a232..20e3cba83 100644 --- a/src/service/messenger/messenger_api_message_kind.h +++ b/src/service/messenger/messenger_api_message_kind.h | |||
@@ -27,6 +27,7 @@ | |||
27 | #define GNUNET_SERVICE_MESSENGER_MESSAGE_KIND_H | 27 | #define GNUNET_SERVICE_MESSENGER_MESSAGE_KIND_H |
28 | 28 | ||
29 | #include "gnunet_messenger_service.h" | 29 | #include "gnunet_messenger_service.h" |
30 | #include "gnunet_reclaim_lib.h" | ||
30 | #include "gnunet_util_lib.h" | 31 | #include "gnunet_util_lib.h" |
31 | #include "gnunet_identity_service.h" | 32 | #include "gnunet_identity_service.h" |
32 | #include "gnunet_time_lib.h" | 33 | #include "gnunet_time_lib.h" |
@@ -116,7 +117,8 @@ struct GNUNET_MESSENGER_Message* | |||
116 | create_message_text (const char *text); | 117 | create_message_text (const char *text); |
117 | 118 | ||
118 | /** | 119 | /** |
119 | * Creates and allocates a new delete message containing the <i>hash</i> of a message to delete after a specific <i>delay</i>. | 120 | * Creates and allocates a new delete message containing the <i>hash</i> of a message to delete |
121 | * after a specific <i>delay</i>. | ||
120 | * (all values are stored as copy) | 122 | * (all values are stored as copy) |
121 | * | 123 | * |
122 | * @param[in] hash Hash of message | 124 | * @param[in] hash Hash of message |
@@ -127,4 +129,15 @@ struct GNUNET_MESSENGER_Message* | |||
127 | create_message_delete (const struct GNUNET_HashCode *hash, | 129 | create_message_delete (const struct GNUNET_HashCode *hash, |
128 | const struct GNUNET_TIME_Relative delay); | 130 | const struct GNUNET_TIME_Relative delay); |
129 | 131 | ||
132 | /** | ||
133 | * Creates and allocates a new ticket message containing the <i>identifier</i> of a ticket to | ||
134 | * exchange it with a given audience. | ||
135 | * (all values are stored as copy) | ||
136 | * | ||
137 | * @param[in] identifier Identifier of ticket | ||
138 | * @return New message | ||
139 | */ | ||
140 | struct GNUNET_MESSENGER_Message* | ||
141 | create_message_ticket (const struct GNUNET_RECLAIM_Identifier *identifier); | ||
142 | |||
130 | #endif //GNUNET_SERVICE_MESSENGER_MESSAGE_KIND_H | 143 | #endif //GNUNET_SERVICE_MESSENGER_MESSAGE_KIND_H |