aboutsummaryrefslogtreecommitdiff
path: root/src/service/messenger/messenger_api_message_control.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/service/messenger/messenger_api_message_control.h')
-rw-r--r--src/service/messenger/messenger_api_message_control.h105
1 files changed, 105 insertions, 0 deletions
diff --git a/src/service/messenger/messenger_api_message_control.h b/src/service/messenger/messenger_api_message_control.h
new file mode 100644
index 000000000..a990210f0
--- /dev/null
+++ b/src/service/messenger/messenger_api_message_control.h
@@ -0,0 +1,105 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 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 */
20/**
21 * @author Tobias Frisch
22 * @file src/messenger/messenger_api_message_control.h
23 * @brief messenger api: client and service implementation of GNUnet MESSENGER service
24 */
25
26#ifndef GNUNET_MESSENGER_API_MESSAGE_CONTROL_H
27#define GNUNET_MESSENGER_API_MESSAGE_CONTROL_H
28
29#include "gnunet_common.h"
30#include "gnunet_messenger_service.h"
31#include "gnunet_util_lib.h"
32
33struct GNUNET_MESSENGER_Message;
34struct GNUNET_MESSENGER_MessageControl;
35
36struct GNUNET_MESSENGER_MessageControlQueue
37{
38 struct GNUNET_MESSENGER_MessageControl *control;
39
40 struct GNUNET_HashCode sender;
41 struct GNUNET_HashCode context;
42 struct GNUNET_HashCode hash;
43
44 struct GNUNET_MESSENGER_Message *message;
45 enum GNUNET_MESSENGER_MessageFlags flags;
46 struct GNUNET_SCHEDULER_Task *task;
47
48 struct GNUNET_MESSENGER_MessageControlQueue *prev;
49 struct GNUNET_MESSENGER_MessageControlQueue *next;
50};
51
52struct GNUNET_MESSENGER_Room;
53
54struct GNUNET_MESSENGER_MessageControl
55{
56 struct GNUNET_MESSENGER_Room *room;
57
58 struct GNUNET_CONTAINER_MultiShortmap *peer_messages;
59 struct GNUNET_CONTAINER_MultiShortmap *member_messages;
60
61 struct GNUNET_MESSENGER_MessageControlQueue *head;
62 struct GNUNET_MESSENGER_MessageControlQueue *tail;
63};
64
65/**
66 * Creates and allocates a new message control for a <i>room</i> of the client API.
67 *
68 * @param[in,out] room Room
69 * @return New message control
70 */
71struct GNUNET_MESSENGER_MessageControl*
72create_message_control (struct GNUNET_MESSENGER_Room *room);
73
74/**
75 * Destroys a message control and frees its memory fully from the client API.
76 *
77 * @param[in,out] control Message control
78 */
79void
80destroy_message_control (struct GNUNET_MESSENGER_MessageControl *control);
81
82/**
83 * Processes a new <i>message</i> with its <i>hash</i> and regarding information about
84 * <i>sender</i>, <i>context</i> and message <i>flags</i> using a selected message
85 * <i>control</i>.
86 *
87 * The message control will ensure order of messages so that senders of messages
88 * can be identified via previously processed messages.
89 *
90 * @param[in,out] control Message control
91 * @param[in] sender Sender hash
92 * @param[in] context Context hash
93 * @param[in] hash Message hash
94 * @param[in] message Message
95 * @param[in] flags Message flags
96 */
97void
98process_message_control (struct GNUNET_MESSENGER_MessageControl *control,
99 const struct GNUNET_HashCode *sender,
100 const struct GNUNET_HashCode *context,
101 const struct GNUNET_HashCode *hash,
102 const struct GNUNET_MESSENGER_Message *message,
103 enum GNUNET_MESSENGER_MessageFlags flags);
104
105#endif //GNUNET_MESSENGER_API_MESSAGE_CONTROL_H \ No newline at end of file