aboutsummaryrefslogtreecommitdiff
path: root/src/messenger/messenger_api_list_tunnels.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/messenger/messenger_api_list_tunnels.h')
-rw-r--r--src/messenger/messenger_api_list_tunnels.h112
1 files changed, 112 insertions, 0 deletions
diff --git a/src/messenger/messenger_api_list_tunnels.h b/src/messenger/messenger_api_list_tunnels.h
new file mode 100644
index 000000000..0240fceb8
--- /dev/null
+++ b/src/messenger/messenger_api_list_tunnels.h
@@ -0,0 +1,112 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2020 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_list_tunnels.h
23 * @brief messenger api: client and service implementation of GNUnet MESSENGER service
24 */
25
26#ifndef GNUNET_MESSENGER_API_LIST_TUNNELS_H
27#define GNUNET_MESSENGER_API_LIST_TUNNELS_H
28
29#include "platform.h"
30#include "gnunet_peer_lib.h"
31#include "gnunet_container_lib.h"
32
33struct GNUNET_MESSENGER_ListTunnel
34{
35 struct GNUNET_MESSENGER_ListTunnel *prev;
36 struct GNUNET_MESSENGER_ListTunnel *next;
37
38 GNUNET_PEER_Id peer;
39};
40
41struct GNUNET_MESSENGER_ListTunnels
42{
43 struct GNUNET_MESSENGER_ListTunnel *head;
44 struct GNUNET_MESSENGER_ListTunnel *tail;
45};
46
47/**
48 * Initializes list of tunnels peer identities as empty list.
49 *
50 * @param tunnels List of peer identities
51 */
52void
53init_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels);
54
55/**
56 * Clears the list of tunnels peer identities.
57 *
58 * @param tunnels List of peer identities
59 */
60void
61clear_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels);
62
63/**
64 * Adds a specific <i>peer</i> from a tunnel to the end of the list.
65 *
66 * @param tunnels List of peer identities
67 * @param peer Peer identity of tunnel
68 */
69void
70add_to_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer);
71
72/**
73 * Searches linearly through the list of tunnels peer identities for matching a
74 * specific <i>peer</i> identity and returns the matching element of the list.
75 *
76 * If no matching element is found, NULL gets returned.
77 *
78 * If <i>index</i> is not NULL, <i>index</i> will be overriden with the numeric index of
79 * the found element in the list. If no matching element is found, <i>index</i> will
80 * contain the total amount of elements in the list.
81 *
82 * @param tunnels List of peer identities
83 * @param peer Peer identity of tunnel
84 * @param[out] index Index of found element (optional)
85 * @return Element in the list with matching peer identity
86 */
87struct GNUNET_MESSENGER_ListTunnel*
88find_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer, size_t *index);
89
90/**
91 * Tests linearly if the list of tunnels peer identities contains a specific
92 * <i>peer</i> identity and returns GNUNET_YES on success, otherwise GNUNET_NO.
93 *
94 * @param tunnels List of peer identities
95 * @param peer Peer identity of tunnel
96 * @return GNUNET_YES on success, otherwise GNUNET_NO
97 */
98int
99contains_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer);
100
101/**
102 * Removes a specific <i>element</i> from the list of tunnels peer identities and returns
103 * the next element in the list.
104 *
105 * @param tunnels List of peer identities
106 * @param element Element of the list
107 * @return Next element in the list
108 */
109struct GNUNET_MESSENGER_ListTunnel*
110remove_from_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, struct GNUNET_MESSENGER_ListTunnel *element);
111
112#endif //GNUNET_MESSENGER_API_LIST_TUNNELS_H