3 This file is part of GNUnet.
4 Copyright (C) 2001-2017 GNUnet e.V.
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.
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.
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.
23 * @file cadet/gnunet-service-cadet-new.h
24 * @brief Information we track per peer.
25 * @author Bartlomiej Polot
26 * @author Christian Grothoff
28 #ifndef GNUNET_SERVICE_CADET_H
29 #define GNUNET_SERVICE_CADET_H
31 #include "gnunet_util_lib.h"
33 #include "cadet_protocol.h"
36 * A client to the CADET service. Each client gets a unique handle.
41 * A peer in the GNUnet network. Each peer we care about must have one globally
42 * unique such handle within this process.
47 * Tunnel from us to another peer. There can only be at most one
53 * Entry in the message queue of a `struct CadetTunnel`.
55 struct CadetTunnelQueueEntry;
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.
66 * Entry in a peer path.
68 struct CadetPeerPathEntry
71 * DLL of paths where the same @e peer is at the same offset.
73 struct CadetPeerPathEntry *next;
76 * DLL of paths where the same @e peer is at the same offset.
78 struct CadetPeerPathEntry *prev;
81 * The peer at this offset of the path.
83 struct CadetPeer *peer;
86 * Path this entry belongs to.
88 struct CadetPeerPath *path;
91 * Connection using this path, or NULL for none.
93 struct CadetConnection *cc;
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
107 * Entry in list of connections used by tunnel, with metadata.
109 struct CadetTConnection
114 struct CadetTConnection *next;
119 struct CadetTConnection *prev;
124 struct CadetConnection *cc;
127 * Tunnel this connection belongs to.
129 struct CadetTunnel *t;
132 * Creation time, to keep oldest connection alive.
134 struct GNUNET_TIME_Absolute created;
137 * Connection throughput, to keep fastest connection alive.
142 * Is the connection currently ready for transmission?
149 * Active path through the network (used by a tunnel). There may
150 * be at most one connection per path.
152 struct CadetConnection;
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
165 * Logical end-to-end conenction between clients. There can be
166 * any number of channels between clients.
171 * Handle to our configuration.
173 extern const struct GNUNET_CONFIGURATION_Handle *cfg;
176 * Handle to the statistics service.
178 extern struct GNUNET_STATISTICS_Handle *stats;
181 * Handle to communicate with ATS.
183 extern struct GNUNET_ATS_ConnectivityHandle *ats_ch;
188 extern struct GNUNET_PeerIdentity my_full_id;
193 extern struct GNUNET_CRYPTO_EddsaPrivateKey *my_private_key;
196 * All ports clients of this peer have opened.
198 extern struct GNUNET_CONTAINER_MultiHashMap *open_ports;
201 * Map from `struct GNUNET_CADET_ConnectionTunnelIdentifier`
202 * hash codes to `struct CadetConnection` objects.
204 extern struct GNUNET_CONTAINER_MultiShortmap *connections;
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`.
211 extern struct GNUNET_CONTAINER_MultiHashMap *loose_channels;
214 * Map from PIDs to `struct CadetPeer` entries.
216 extern struct GNUNET_CONTAINER_MultiPeerMap *peers;
219 * How many messages are needed to trigger an AXOLOTL ratchet advance.
221 extern unsigned long long ratchet_messages;
224 * How long until we trigger a ratched advance due to time.
226 extern struct GNUNET_TIME_Relative ratchet_time;
229 * Signal that shutdown is happening: prevent recovery measures.
231 extern int shutting_down;
235 * Send a message to a client.
237 * @param c client to get the message
238 * @param env envelope with the message
241 GSC_send_to_client (struct CadetClient *c,
242 struct GNUNET_MQ_Envelope *env);
246 * A channel was destroyed by the other peer. Tell our client.
248 * @param c client that lost a channel
249 * @param ccn channel identification number for the client
250 * @param ch the channel object
253 GSC_handle_remote_channel_destroy (struct CadetClient *c,
254 struct GNUNET_CADET_ClientChannelNumber ccn,
255 struct CadetChannel *ch);
259 * Bind incoming channel to this client, and notify client
260 * about incoming connection.
262 * @param c client to bind to
263 * @param ch channel to be bound
264 * @param dest peer that establishes the connection
265 * @param port port number
266 * @param options options
267 * @return local channel number assigned to the new client
269 struct GNUNET_CADET_ClientChannelNumber
270 GSC_bind (struct CadetClient *c,
271 struct CadetChannel *ch,
272 struct CadetPeer *dest,
273 const struct GNUNET_HashCode *port,
278 * Return identifier for a client as a string.
280 * @param c client to identify
281 * @return string for debugging
284 GSC_2s (struct CadetClient *c);