aboutsummaryrefslogtreecommitdiff
path: root/src/cadet/gnunet-service-cadet.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/cadet/gnunet-service-cadet.h')
-rw-r--r--src/cadet/gnunet-service-cadet.h308
1 files changed, 308 insertions, 0 deletions
diff --git a/src/cadet/gnunet-service-cadet.h b/src/cadet/gnunet-service-cadet.h
new file mode 100644
index 000000000..2f2d7baf3
--- /dev/null
+++ b/src/cadet/gnunet-service-cadet.h
@@ -0,0 +1,308 @@
1
2/*
3 This file is part of GNUnet.
4 Copyright (C) 2001-2017 GNUnet e.V.
5
6 GNUnet is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published
8 by the Free Software Foundation; either version 3, or (at your
9 option) any later version.
10
11 GNUnet is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNUnet; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21
22/**
23 * @file cadet/gnunet-service-cadet.h
24 * @brief Information we track per peer.
25 * @author Bartlomiej Polot
26 * @author Christian Grothoff
27 */
28#ifndef GNUNET_SERVICE_CADET_H
29#define GNUNET_SERVICE_CADET_H
30
31#include "gnunet_util_lib.h"
32#define NEW_CADET 1
33#include "cadet_protocol.h"
34
35/**
36 * A client to the CADET service. Each client gets a unique handle.
37 */
38struct CadetClient;
39
40/**
41 * A peer in the GNUnet network. Each peer we care about must have one globally
42 * unique such handle within this process.
43 */
44struct CadetPeer;
45
46/**
47 * Tunnel from us to another peer. There can only be at most one
48 * tunnel per peer.
49 */
50struct CadetTunnel;
51
52/**
53 * Entry in the message queue of a `struct CadetTunnel`.
54 */
55struct CadetTunnelQueueEntry;
56
57/**
58 * A path of peer in the GNUnet network. There must only be at most
59 * once such path. Paths may share disjoint prefixes, but must all
60 * end at a unique suffix. Paths must also not be proper subsets of
61 * other existing paths.
62 */
63struct CadetPeerPath;
64
65/**
66 * Entry in a peer path.
67 */
68struct CadetPeerPathEntry
69{
70 /**
71 * DLL of paths where the same @e peer is at the same offset.
72 */
73 struct CadetPeerPathEntry *next;
74
75 /**
76 * DLL of paths where the same @e peer is at the same offset.
77 */
78 struct CadetPeerPathEntry *prev;
79
80 /**
81 * The peer at this offset of the path.
82 */
83 struct CadetPeer *peer;
84
85 /**
86 * Path this entry belongs to.
87 */
88 struct CadetPeerPath *path;
89
90 /**
91 * Connection using this path, or NULL for none.
92 */
93 struct CadetConnection *cc;
94
95 /**
96 * Path's historic score up to this point. Basically, how often did
97 * we succeed or fail to use the path up to this entry in a
98 * connection. Positive values indicate good experiences, negative
99 * values bad experiences. Code updating the score must guard
100 * against overflows.
101 */
102 int score;
103
104};
105
106/**
107 * Entry in list of connections used by tunnel, with metadata.
108 */
109struct CadetTConnection
110{
111 /**
112 * Next in DLL.
113 */
114 struct CadetTConnection *next;
115
116 /**
117 * Prev in DLL.
118 */
119 struct CadetTConnection *prev;
120
121 /**
122 * Connection handle.
123 */
124 struct CadetConnection *cc;
125
126 /**
127 * Tunnel this connection belongs to.
128 */
129 struct CadetTunnel *t;
130
131 /**
132 * Creation time, to keep oldest connection alive.
133 */
134 struct GNUNET_TIME_Absolute created;
135
136 /**
137 * Connection throughput, to keep fastest connection alive.
138 */
139 uint32_t throughput;
140
141 /**
142 * Is the connection currently ready for transmission?
143 */
144 int is_ready;
145};
146
147
148/**
149 * Active path through the network (used by a tunnel). There may
150 * be at most one connection per path.
151 */
152struct CadetConnection;
153
154/**
155 * Description of a segment of a `struct CadetConnection` at the
156 * intermediate peers. Routes are basically entries in a peer's
157 * routing table for forwarding traffic. At both endpoints, the
158 * routes are terminated by a `struct CadetConnection`, which knows
159 * the complete `struct CadetPath` that is formed by the individual
160 * routes.
161 */
162struct CadetRoute;
163
164/**
165 * Logical end-to-end conenction between clients. There can be
166 * any number of channels between clients.
167 */
168struct CadetChannel;
169
170/**
171 * Handle to our configuration.
172 */
173extern const struct GNUNET_CONFIGURATION_Handle *cfg;
174
175/**
176 * Handle to the statistics service.
177 */
178extern struct GNUNET_STATISTICS_Handle *stats;
179
180/**
181 * Handle to communicate with ATS.
182 */
183extern struct GNUNET_ATS_ConnectivityHandle *ats_ch;
184
185/**
186 * Local peer own ID.
187 */
188extern struct GNUNET_PeerIdentity my_full_id;
189
190/**
191 * Own private key.
192 */
193extern struct GNUNET_CRYPTO_EddsaPrivateKey *my_private_key;
194
195/**
196 * All ports clients of this peer have opened.
197 */
198extern struct GNUNET_CONTAINER_MultiHashMap *open_ports;
199
200/**
201 * Map from `struct GNUNET_CADET_ConnectionTunnelIdentifier`
202 * hash codes to `struct CadetConnection` objects.
203 */
204extern struct GNUNET_CONTAINER_MultiShortmap *connections;
205
206/**
207 * Map from ports to channels where the ports were closed at the
208 * time we got the inbound connection.
209 * Indexed by port, contains `struct CadetChannel`.
210 */
211extern struct GNUNET_CONTAINER_MultiHashMap *loose_channels;
212
213/**
214 * Map from PIDs to `struct CadetPeer` entries.
215 */
216extern struct GNUNET_CONTAINER_MultiPeerMap *peers;
217
218/**
219 * How many messages are needed to trigger an AXOLOTL ratchet advance.
220 */
221extern unsigned long long ratchet_messages;
222
223/**
224 * How long until we trigger a ratched advance due to time.
225 */
226extern struct GNUNET_TIME_Relative ratchet_time;
227
228/**
229 * How frequently do we send KEEPALIVE messages on idle connections?
230 */
231extern struct GNUNET_TIME_Relative keepalive_period;
232
233/**
234 * Signal that shutdown is happening: prevent recovery measures.
235 */
236extern int shutting_down;
237
238/**
239 * Set to non-zero values to create random drops to test retransmissions.
240 */
241extern unsigned long long drop_percent;
242
243
244/**
245 * Send a message to a client.
246 *
247 * @param c client to get the message
248 * @param env envelope with the message
249 */
250void
251GSC_send_to_client (struct CadetClient *c,
252 struct GNUNET_MQ_Envelope *env);
253
254
255/**
256 * A channel was destroyed by the other peer. Tell our client.
257 *
258 * @param c client that lost a channel
259 * @param ccn channel identification number for the client
260 * @param ch the channel object
261 */
262void
263GSC_handle_remote_channel_destroy (struct CadetClient *c,
264 struct GNUNET_CADET_ClientChannelNumber ccn,
265 struct CadetChannel *ch);
266
267/**
268 * A client that created a loose channel that was not bound to a port
269 * disconnected, drop it from the #loose_channels list.
270 *
271 * @param port the port the channel was trying to bind to
272 * @param ch the channel that was lost
273 */
274void
275GSC_drop_loose_channel (const struct GNUNET_HashCode *port,
276 struct CadetChannel *ch);
277
278
279/**
280 * Bind incoming channel to this client, and notify client
281 * about incoming connection.
282 *
283 * @param c client to bind to
284 * @param ch channel to be bound
285 * @param dest peer that establishes the connection
286 * @param port port number
287 * @param options options
288 * @return local channel number assigned to the new client
289 */
290struct GNUNET_CADET_ClientChannelNumber
291GSC_bind (struct CadetClient *c,
292 struct CadetChannel *ch,
293 struct CadetPeer *dest,
294 const struct GNUNET_HashCode *port,
295 uint32_t options);
296
297
298/**
299 * Return identifier for a client as a string.
300 *
301 * @param c client to identify
302 * @return string for debugging
303 */
304const char *
305GSC_2s (struct CadetClient *c);
306
307
308#endif