aboutsummaryrefslogtreecommitdiff
path: root/src/cadet/gnunet-service-cadet_connection.h
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2023-10-18 20:02:10 +0200
committerMartin Schanzenbach <schanzen@gnunet.org>2023-10-18 20:02:10 +0200
commit11949e419fd7230431646703ac0cf8e34f615673 (patch)
tree94892053dd1734a41effa1fd2a5b7e9f650b0f31 /src/cadet/gnunet-service-cadet_connection.h
parent2d76608872f25220ef85c56af403392f6842dc19 (diff)
downloadgnunet-11949e419fd7230431646703ac0cf8e34f615673.tar.gz
gnunet-11949e419fd7230431646703ac0cf8e34f615673.zip
BUILD: Move cadet to service/cli
Diffstat (limited to 'src/cadet/gnunet-service-cadet_connection.h')
-rw-r--r--src/cadet/gnunet-service-cadet_connection.h363
1 files changed, 0 insertions, 363 deletions
diff --git a/src/cadet/gnunet-service-cadet_connection.h b/src/cadet/gnunet-service-cadet_connection.h
deleted file mode 100644
index 54c845b13..000000000
--- a/src/cadet/gnunet-service-cadet_connection.h
+++ /dev/null
@@ -1,363 +0,0 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2001-2017 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/**
22 * @file cadet/gnunet-service-cadet_connection.h
23 * @brief A connection is a live end-to-end messaging mechanism
24 * where the peers are identified by a path and know how
25 * to forward along the route using a connection identifier
26 * for routing the data.
27 * @author Bartlomiej Polot
28 * @author Christian Grothoff
29 */
30#ifndef GNUNET_SERVICE_CADET_CONNECTION_H
31#define GNUNET_SERVICE_CADET_CONNECTION_H
32
33#include "gnunet_util_lib.h"
34#include "gnunet-service-cadet.h"
35#include "gnunet-service-cadet_peer.h"
36#include "cadet_protocol.h"
37
38
39/**
40 * Function called to notify tunnel about change in our readiness.
41 *
42 * @param cls closure
43 * @param is_ready #GNUNET_YES if the connection is now ready for transmission,
44 * #GNUNET_NO if the connection is no longer ready for transmission
45 */
46typedef void
47(*GCC_ReadyCallback)(void *cls,
48 int is_ready);
49
50
51/**
52 * Destroy a connection, called when the CORE layer is already done
53 * (i.e. has received a BROKEN message), but if we still have to
54 * communicate the destruction of the connection to the tunnel (if one
55 * exists).
56 *
57 * @param cc connection to destroy
58 */
59void
60GCC_destroy_without_core (struct CadetConnection *cc);
61
62
63/**
64 * Destroy a connection, called if the tunnel association with the
65 * connection was already broken, but we still need to notify the CORE
66 * layer about the breakage.
67 *
68 * @param cc connection to destroy
69 */
70void
71GCC_destroy_without_tunnel (struct CadetConnection *cc);
72
73
74/**
75 * Lookup a connection by its identifier.
76 *
77 * @param cid identifier to resolve
78 * @return NULL if connection was not found
79 */
80struct CadetConnection *
81GCC_lookup (const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid);
82
83
84/**
85 * Create a connection to @a destination via @a path and
86 * notify @a cb whenever we are ready for more data.
87 *
88 * @param destination where to go
89 * @param path which path to take (may not be the full path)
90 * @param off offset of @a destination on @a path
91 * @param ct which tunnel uses this connection
92 * @param ready_cb function to call when ready to transmit
93 * @param ready_cb_cls closure for @a cb
94 * @return handle to the connection
95 */
96struct CadetConnection *
97GCC_create (struct CadetPeer *destination,
98 struct CadetPeerPath *path,
99 unsigned int off,
100 struct CadetTConnection *ct,
101 GCC_ReadyCallback ready_cb,
102 void *ready_cb_cls);
103
104
105/**
106 * Create a connection to @a destination via @a path and
107 * notify @a cb whenever we are ready for more data. This
108 * is an inbound tunnel, so we must use the existing @a cid
109 *
110 * @param destination where to go
111 * @param path which path to take (may not be the full path)
112 * @param ct which tunnel uses this connection
113 * @param ready_cb function to call when ready to transmit
114 * @param ready_cb_cls closure for @a cb
115 * @return handle to the connection, NULL if we already have
116 * a connection that takes precedence on @a path
117 */
118struct CadetConnection *
119GCC_create_inbound (struct CadetPeer *destination,
120 struct CadetPeerPath *path,
121 struct CadetTConnection *ct,
122 const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid,
123 GCC_ReadyCallback ready_cb,
124 void *ready_cb_cls);
125
126
127/**
128 * Transmit message @a msg via connection @a cc. Must only be called
129 * (once) after the connection has signalled that it is ready via the
130 * `ready_cb`. Clients can also use #GCC_is_ready() to check if the
131 * connection is right now ready for transmission.
132 *
133 * @param cc connection identification
134 * @param env envelope with message to transmit;
135 * the #GNUNET_MQ_notify_send() must not have yet been used
136 * for the envelope. Also, the message better match the
137 * connection identifier of this connection...
138 */
139void
140GCC_transmit (struct CadetConnection *cc,
141 struct GNUNET_MQ_Envelope *env);
142
143
144/**
145 * A #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK was received for
146 * this connection, implying that the end-to-end connection is up.
147 * Process it.
148 *
149 * @param cc the connection that got the ACK.
150 */
151void
152GCC_handle_connection_create_ack (struct CadetConnection *cc);
153
154
155/**
156 * We got a #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE for a
157 * connection that we already have. Either our ACK got lost
158 * or something is fishy. Consider retransmitting the ACK.
159 *
160 * @param cc connection that got the duplicate CREATE
161 */
162void
163GCC_handle_duplicate_create (struct CadetConnection *cc);
164
165
166/**
167 * Handle KX message.
168 *
169 * @param cc connection that received encrypted message
170 * @param msg the key exchange message
171 */
172void
173GCC_handle_kx (struct CadetConnection *cc,
174 const struct GNUNET_CADET_TunnelKeyExchangeMessage *msg);
175
176
177/**
178 * Handle KX_AUTH message.
179 *
180 * @param cc connection that received encrypted message
181 * @param msg the key exchange message
182 */
183void
184GCC_handle_kx_auth (struct CadetConnection *cc,
185 const struct
186 GNUNET_CADET_TunnelKeyExchangeAuthMessage *msg);
187
188/**
189 * Purpose for the signature of a monotime.
190 */
191struct CadetConnectionCreatePS
192{
193
194 /**
195 * Purpose is #GNUNET_SIGNATURE_PURPOSE_CADET_CONNECTION_INITIATOR
196 */
197 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
198
199 /**
200 * Time at the initiator when generating the signature.
201 *
202 * Note that the receiver MUST IGNORE the absolute time, and only interpret
203 * the value as a mononic time and reject "older" values than the last one
204 * observed. This is necessary as we do not want to require synchronized
205 * clocks and may not have a bidirectional communication channel.
206 *
207 * Even with this, there is no real guarantee against replay achieved here,
208 * unless the latest timestamp is persisted. Persistence should be
209 * provided via PEERSTORE if possible.
210 */
211 struct GNUNET_TIME_AbsoluteNBO monotonic_time;
212
213};
214
215/**
216 * Performance metrics for a connection.
217 */
218struct CadetConnectionMetrics
219{
220 /**
221 * Our current best estimate of the latency, based on a weighted
222 * average of at least @a latency_datapoints values.
223 */
224 struct GNUNET_TIME_Relative aged_latency;
225
226 /**
227 * When was this connection first established? (by us sending or
228 * receiving the CREATE_ACK for the first time)
229 */
230 struct GNUNET_TIME_Absolute age;
231
232 /**
233 * When was this connection last used? (by us sending or
234 * receiving a PAYLOAD message on it)
235 */
236 struct GNUNET_TIME_Absolute last_use;
237
238 /**
239 * How many packets that ought to generate an ACK did we send via
240 * this connection?
241 */
242 unsigned long long num_acked_transmissions;
243
244 /**
245 * Number of packets that were sent via this connection did actually
246 * receive an ACK? (Note: ACKs may be transmitted and lost via
247 * other connections, so this value should only be interpreted
248 * relative to @e num_acked_transmissions and in relation to other
249 * connections.)
250 */
251 unsigned long long num_successes;
252};
253
254
255/**
256 * Obtain performance @a metrics from @a cc.
257 *
258 * @param cc connection to query
259 * @return the metrics
260 */
261const struct CadetConnectionMetrics *
262GCC_get_metrics (struct CadetConnection *cc);
263
264
265/**
266 * Handle encrypted message.
267 *
268 * @param cc connection that received encrypted message
269 * @param msg the encrypted message to decrypt
270 */
271void
272GCC_handle_encrypted (struct CadetConnection *cc,
273 const struct GNUNET_CADET_TunnelEncryptedMessage *msg);
274
275
276/**
277 * We sent a message for which we expect to receive an ACK via
278 * the connection identified by @a cti.
279 *
280 * @param cid connection identifier where we expect an ACK
281 */
282void
283GCC_ack_expected (const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid);
284
285
286/**
287 * We observed an ACK for a message that was originally sent via
288 * the connection identified by @a cti.
289 *
290 * @param cid connection identifier where we got an ACK for a message
291 * that was originally sent via this connection (the ACK
292 * may have gotten back to us via a different connection).
293 */
294void
295GCC_ack_observed (const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid);
296
297
298/**
299 * We observed some the given @a latency on the connection
300 * identified by @a cti. (The same connection was taken
301 * in both directions.)
302 *
303 * @param cti connection identifier where we measured latency
304 * @param latency the observed latency
305 */
306void
307GCC_latency_observed (const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti,
308 struct GNUNET_TIME_Relative latency);
309
310
311/**
312 * Return the tunnel associated with this connection.
313 *
314 * @param cc connection to query
315 * @return corresponding entry in the tunnel's connection list
316 */
317struct CadetTConnection *
318GCC_get_ct (struct CadetConnection *cc);
319
320
321/**
322 * Obtain the path used by this connection.
323 *
324 * @param cc connection
325 * @param[out] off set to offset in this path where the connection @a cc ends
326 * @return path to @a cc
327 */
328struct CadetPeerPath *
329GCC_get_path (struct CadetConnection *cc,
330 unsigned int *off);
331
332
333/**
334 * Obtain unique ID for the connection.
335 *
336 * @param cc connection.
337 * @return unique number of the connection
338 */
339const struct GNUNET_CADET_ConnectionTunnelIdentifier *
340GCC_get_id (struct CadetConnection *cc);
341
342
343/**
344 * Get a (static) string for a connection.
345 *
346 * @param cc Connection.
347 */
348const char *
349GCC_2s (const struct CadetConnection *cc);
350
351
352/**
353 * Log connection info.
354 *
355 * @param cc connection
356 * @param level Debug level to use.
357 */
358void
359GCC_debug (struct CadetConnection *cc,
360 enum GNUNET_ErrorType level);
361
362
363#endif