more work on peer and paths structures
[oweals/gnunet.git] / src / cadet / gnunet-service-cadet-new.h
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-new.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
33 /**
34  * A client to the CADET service.
35  */
36 struct CadetClient;
37
38 /**
39  * A peer in the GNUnet network.
40  */
41 struct CadetPeer;
42
43 /**
44  * Tunnel from us to another peer.
45  */
46 struct CadetTunnel;
47
48 /**
49  * Entry in the message queue of a `struct CadetTunnel`
50  */
51 struct CadetTunnelQueueEntry;
52
53 /**
54  * A path of peer in the GNUnet network.
55  */
56 struct CadetPeerPath;
57
58 /**
59  * Entry in a peer path.
60  */
61 struct CadetPeerPathEntry
62 {
63   /**
64    * DLL of paths where the same @e peer is at the same offset.
65    */
66   struct CadetPeerPathEntry *next;
67
68   /**
69    * DLL of paths where the same @e peer is at the same offset.
70    */
71   struct CadetPeerPathEntry *prev;
72
73   /**
74    * The peer at this offset of the path.
75    */
76   struct CadetPeer *peer;
77
78   /**
79    * Path this entry belongs to.
80    */
81   struct CadetPeerPath *path;
82
83   /**
84    * Path's historic score up to this point.  Basically, how often did
85    * we succeed or fail to use the path up to this entry in a
86    * connection.  Positive values indicate good experiences, negative
87    * values bad experiences.  Code updating the score must guard
88    * against overflows.
89    */
90   int score;
91
92 };
93
94
95 /**
96  * Active path through the network (used by a tunnel).
97  */
98 struct CadetConnection;
99
100 /**
101  * Logical end-to-end conenction between clients.
102  */
103 struct CadetChannel;
104
105 /**
106  * Handle to the statistics service.
107  */
108 extern struct GNUNET_STATISTICS_Handle *stats;
109
110 /**
111  * Handle to communicate with ATS.
112  */
113 extern struct GNUNET_ATS_ConnectivityHandle *ats_ch;
114
115 /**
116  * Local peer own ID.
117  */
118 extern struct GNUNET_PeerIdentity my_full_id;
119
120 /**
121  * Own private key.
122  */
123 extern struct GNUNET_CRYPTO_EddsaPrivateKey *my_private_key;
124
125 /**
126  * All ports clients of this peer have opened.
127  */
128 extern struct GNUNET_CONTAINER_MultiHashMap *open_ports;
129
130 /**
131  * Map from ports to channels where the ports were closed at the
132  * time we got the inbound connection.
133  * Indexed by port, contains `struct CadetChannel`.
134  */
135 extern struct GNUNET_CONTAINER_MultiHashMap *loose_channels;
136
137 /**
138  * Map from PIDs to `struct CadetPeer` entries.
139  */
140 extern struct GNUNET_CONTAINER_MultiPeerMap *peers;
141
142
143 /**
144  * Send a message to a client.
145  *
146  * @param c client to get the message
147  * @param env envelope with the message
148  */
149 void
150 GSC_send_to_client (struct CadetClient *c,
151                     struct GNUNET_MQ_Envelope *env);
152
153
154 /**
155  * Bind incoming channel to this client, and notify client
156  * about incoming connection.
157  *
158  * @param c client to bind to
159  * @param ch channel to be bound
160  * @param dest peer that establishes the connection
161  * @param port port number
162  * @param options options
163  * @return local channel number assigned to the new client
164  */
165 struct GNUNET_CADET_ClientChannelNumber
166 GSC_bind (struct CadetClient *c,
167           struct CadetChannel *ch,
168           struct CadetPeer *dest,
169           const struct GNUNET_HashCode *port,
170           uint32_t options);
171
172
173 /**
174  * Return identifier for a client as a string.
175  *
176  * @param c client to identify
177  * @return string for debugging
178  */
179 const char *
180 GSC_2s (struct CadetClient *c);
181
182
183 #endif