no debug
[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  * informing about neighbors.
52  */
53 struct ConnectInfoMessage
54 {
55
56   /**
57    * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT
58    */
59   struct GNUNET_MessageHeader header;
60
61   /**
62    * Transport distance metric (i.e. hops for DV)
63    */
64   uint32_t distance;
65
66   /**
67    * Latency estimate.
68    */
69   struct GNUNET_TIME_RelativeNBO latency;
70
71   /**
72    * Identity of the new neighbour.
73    */
74   struct GNUNET_PeerIdentity id;
75
76 };
77
78
79 /**
80  * Message from the transport service to the library
81  * informing about disconnects.
82  */
83 struct DisconnectInfoMessage
84 {
85
86   /**
87    * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT
88    */
89   struct GNUNET_MessageHeader header;
90
91   /**
92    * Reserved, always zero.
93    */
94   uint32_t reserved GNUNET_PACKED;
95
96   /**
97    * Who got disconnected?
98    */
99   struct GNUNET_PeerIdentity peer;
100
101 };
102
103
104 /**
105  * Message used to set a particular bandwidth quota.  Send TO the
106  * service to set an incoming quota, send FROM the service to update
107  * an outgoing quota.
108  */
109 struct QuotaSetMessage
110 {
111
112   /**
113    * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_NEIGHBOUR_INFO
114    */
115   struct GNUNET_MessageHeader header;
116
117   /**
118    * Quota.
119    */
120   struct GNUNET_BANDWIDTH_Value32NBO quota;
121
122   /**
123    * About which peer are we talking here?
124    */
125   struct GNUNET_PeerIdentity peer;
126
127 };
128
129
130 /**
131  * Message used to notify the transport API about a message
132  * received from the network.  The actual message follows.
133  */
134 struct InboundMessage
135 {
136
137   /**
138    * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_RECV
139    */
140   struct GNUNET_MessageHeader header;
141
142   /**
143    * Always zero.
144    */
145   uint32_t reserved GNUNET_PACKED;
146
147   /**
148    * Latency estimate.
149    */
150   struct GNUNET_TIME_RelativeNBO latency;
151
152   /**
153    * Which peer sent the message?
154    */
155   struct GNUNET_PeerIdentity peer;
156
157   /**
158    * Distance metric.
159    */
160   uint32_t distance;
161
162 };
163
164
165 /**
166  * Message used to notify the transport API that it can
167  * send another message to the transport service.
168  */
169 struct SendOkMessage
170 {
171
172   /**
173    * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK
174    */
175   struct GNUNET_MessageHeader header;
176
177   /**
178    * GNUNET_OK if the transmission succeeded,
179    * GNUNET_SYSERR if it failed (i.e. network disconnect);
180    * in either case, it is now OK for this client to
181    * send us another message for the given peer.
182    */
183   uint32_t success GNUNET_PACKED;
184
185   /**
186    * Latency estimate.
187    */
188   struct GNUNET_TIME_RelativeNBO latency;
189
190   /**
191    * Which peer can send more now?
192    */
193   struct GNUNET_PeerIdentity peer;
194
195 };
196
197
198 /**
199  * Message used to notify the transport service about a message
200  * to be transmitted to another peer.  The actual message follows.
201  */
202 struct OutboundMessage
203 {
204
205   /**
206    * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SEND
207    */
208   struct GNUNET_MessageHeader header;
209
210   /**
211    * Message priority.
212    */
213   uint32_t priority GNUNET_PACKED;
214
215   /**
216    * Allowed delay.
217    */
218   struct GNUNET_TIME_RelativeNBO timeout;
219
220   /**
221    * Which peer should receive the message?
222    */
223   struct GNUNET_PeerIdentity peer;
224
225 };
226
227
228 /**
229  * Message from the library to the transport service
230  * asking for converting a transport address to a
231  * human-readable UTF-8 string.
232  */
233 struct AddressLookupMessage
234 {
235
236   /**
237    * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP
238    */
239   struct GNUNET_MessageHeader header;
240
241   /**
242    * Should the conversion use numeric IP addresses (otherwise
243    * a reverse DNS lookup is OK -- if applicable).
244    */
245   int32_t numeric_only GNUNET_PACKED;
246
247   /**
248    * timeout to give up.
249    */
250   struct GNUNET_TIME_AbsoluteNBO timeout;
251
252   /**
253    * Length of the (binary) address in bytes, in big-endian.
254    */
255   uint32_t addrlen GNUNET_PACKED;
256
257   /* followed by 'addrlen' bytes of the actual address, then
258      followed by the 0-terminated name of the transport */
259 };
260
261
262
263 /**
264  * Change in blacklisting (either request or notification,
265  * depending on which direction it is going).
266  */
267 struct BlacklistMessage
268 {
269
270   /**
271    * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY or
272    * GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_REPLY.
273    */
274   struct GNUNET_MessageHeader header;
275
276   /**
277    * 0 for the query, GNUNET_OK (allowed) or GNUNET_SYSERR (disallowed)
278    * for the response.
279    */
280   uint32_t is_allowed GNUNET_PACKED;
281
282   /**
283    * Which peer is being blacklisted or queried?
284    */
285   struct GNUNET_PeerIdentity peer;
286
287 };
288
289
290 /* end of transport.h */
291 #endif