removing fprintfs -- with bad %fmt statements giving warnings
[oweals/gnunet.git] / src / transport / transport.h
1 /*
2      This file is part of GNUnet.
3      (C) 2009 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      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      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20
21 /**
22  * @file transport/transport.h
23  * @brief common internal definitions for transport service
24  * @author Christian Grothoff
25  */
26 #ifndef TRANSPORT_H
27 #define TRANSPORT_H
28
29 #include "gnunet_crypto_lib.h"
30 #include "gnunet_time_lib.h"
31 #include "gnunet_transport_service.h"
32
33 #define DEBUG_TRANSPORT GNUNET_NO
34 #define DEBUG_TRANSPORT_TIMEOUT GNUNET_NO
35 #define DEBUG_TRANSPORT_DISCONNECT GNUNET_NO
36
37 /**
38  * For how long do we allow unused bandwidth
39  * from the past to carry over into the future? (in seconds)
40  */
41 #define MAX_BANDWIDTH_CARRY_S 5
42
43 /**
44  * How often do we (at most) do a full quota
45  * recalculation? (in ms)
46  */
47 #define MIN_QUOTA_REFRESH_TIME 2000
48
49 /**
50  * Message from the transport service to the library
51  * asking to check if both processes agree about this
52  * peers identity.
53  */
54 struct StartMessage
55 {
56
57   /**
58    * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_START
59    */
60   struct GNUNET_MessageHeader header;
61
62   /**
63    * Should the 'self' field be checked?
64    */
65   uint32_t do_check;
66
67   /**
68    * Identity we think we have.  If it does not match, the
69    * receiver should print out an error message and disconnect.
70    */
71   struct GNUNET_PeerIdentity self;
72
73 };
74
75
76 /**
77  * Message from the transport service to the library
78  * informing about neighbors.
79  */
80 struct ConnectInfoMessage
81 {
82
83   /**
84    * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT
85    */
86   struct GNUNET_MessageHeader header;
87
88   /**
89    * Number of ATS key-value pairs that follow this struct
90    * (excluding the 0-terminator).
91    */
92   uint32_t ats_count GNUNET_PACKED;
93
94   /**
95    * Transport distance metric (i.e. hops for DV)
96    */
97   uint32_t distance;
98
99   /**
100    * Latency estimate.
101    */
102   struct GNUNET_TIME_RelativeNBO latency;
103
104   /**
105    * Identity of the new neighbour.
106    */
107   struct GNUNET_PeerIdentity id;
108
109   /**
110    * First of the ATS information blocks (we must have at least
111    * one due to the 0-termination requirement).
112    */
113   struct GNUNET_TRANSPORT_ATS_Information ats;
114 };
115
116
117 /**
118  * Message from the transport service to the library
119  * informing about disconnects.
120  */
121 struct DisconnectInfoMessage
122 {
123
124   /**
125    * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT
126    */
127   struct GNUNET_MessageHeader header;
128
129   /**
130    * Reserved, always zero.
131    */
132   uint32_t reserved GNUNET_PACKED;
133
134   /**
135    * Who got disconnected?
136    */
137   struct GNUNET_PeerIdentity peer;
138
139 };
140
141 /**
142  * Message type for sending a request connect message
143  * to the transport service.  Must be done before transport
144  * api will allow messages to be queued/sent to transport
145  * service for transmission to a peer.
146  */
147 struct TransportRequestConnectMessage
148 {
149   /**
150    *  Message header
151    */
152   struct GNUNET_MessageHeader header;
153
154   /**
155    * Identity of the peer we would like to connect to.
156    */
157   struct GNUNET_PeerIdentity peer;
158 };
159
160 /**
161  * Message used to set a particular bandwidth quota.  Send TO the
162  * service to set an incoming quota, send FROM the service to update
163  * an outgoing quota.
164  */
165 struct QuotaSetMessage
166 {
167
168   /**
169    * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_NEIGHBOUR_INFO
170    */
171   struct GNUNET_MessageHeader header;
172
173   /**
174    * Quota.
175    */
176   struct GNUNET_BANDWIDTH_Value32NBO quota;
177
178   /**
179    * About which peer are we talking here?
180    */
181   struct GNUNET_PeerIdentity peer;
182
183 };
184
185
186 /**
187  * Message used to notify the transport API about a message
188  * received from the network.  The actual message follows.
189  */
190 struct InboundMessage
191 {
192
193   /**
194    * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_RECV
195    */
196   struct GNUNET_MessageHeader header;
197
198   /**
199    * Always zero.
200    */
201   uint32_t reserved GNUNET_PACKED;
202
203   /**
204    * Number of ATS key-value pairs that follow this struct
205    * (excluding the 0-terminator).
206    */
207   uint32_t ats_count GNUNET_PACKED;
208
209   /**
210    * Latency estimate.
211    */
212   //struct GNUNET_TIME_RelativeNBO latency;
213
214   /**
215    * Which peer sent the message?
216    */
217   struct GNUNET_PeerIdentity peer;
218
219   /**
220    * Distance metric.
221    */
222   //uint32_t distance;
223
224   /**
225    * First of the ATS information blocks (we must have at least
226    * one due to the 0-termination requirement).
227    */
228   struct GNUNET_TRANSPORT_ATS_Information ats;
229 };
230
231
232 /**
233  * Message used to notify the transport API that it can
234  * send another message to the transport service.
235  */
236 struct SendOkMessage
237 {
238
239   /**
240    * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK
241    */
242   struct GNUNET_MessageHeader header;
243
244   /**
245    * GNUNET_OK if the transmission succeeded,
246    * GNUNET_SYSERR if it failed (i.e. network disconnect);
247    * in either case, it is now OK for this client to
248    * send us another message for the given peer.
249    */
250   uint32_t success GNUNET_PACKED;
251
252   /**
253    * Latency estimate.
254    */
255   struct GNUNET_TIME_RelativeNBO latency;
256
257   /**
258    * Which peer can send more now?
259    */
260   struct GNUNET_PeerIdentity peer;
261
262 };
263
264
265 /**
266  * Message used to notify the transport service about a message
267  * to be transmitted to another peer.  The actual message follows.
268  */
269 struct OutboundMessage
270 {
271
272   /**
273    * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SEND
274    */
275   struct GNUNET_MessageHeader header;
276
277   /**
278    * Message priority.
279    */
280   uint32_t priority GNUNET_PACKED;
281
282   /**
283    * Allowed delay.
284    */
285   struct GNUNET_TIME_RelativeNBO timeout;
286
287   /**
288    * Which peer should receive the message?
289    */
290   struct GNUNET_PeerIdentity peer;
291
292 };
293
294
295 /**
296  * Message from the library to the transport service
297  * asking for converting a transport address to a
298  * human-readable UTF-8 string.
299  */
300 struct AddressLookupMessage
301 {
302
303   /**
304    * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP
305    */
306   struct GNUNET_MessageHeader header;
307
308   /**
309    * Should the conversion use numeric IP addresses (otherwise
310    * a reverse DNS lookup is OK -- if applicable).
311    */
312   int32_t numeric_only GNUNET_PACKED;
313
314   /**
315    * timeout to give up.
316    */
317   struct GNUNET_TIME_AbsoluteNBO timeout;
318
319   /**
320    * Length of the (binary) address in bytes, in big-endian.
321    */
322   uint32_t addrlen GNUNET_PACKED;
323
324   /* followed by 'addrlen' bytes of the actual address, then
325      followed by the 0-terminated name of the transport */
326 };
327
328
329
330 /**
331  * Change in blacklisting (either request or notification,
332  * depending on which direction it is going).
333  */
334 struct BlacklistMessage
335 {
336
337   /**
338    * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY or
339    * GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_REPLY.
340    */
341   struct GNUNET_MessageHeader header;
342
343   /**
344    * 0 for the query, GNUNET_OK (allowed) or GNUNET_SYSERR (disallowed)
345    * for the response.
346    */
347   uint32_t is_allowed GNUNET_PACKED;
348
349   /**
350    * Which peer is being blacklisted or queried?
351    */
352   struct GNUNET_PeerIdentity peer;
353
354 };
355
356
357 /* end of transport.h */
358 #endif