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