even longer timeout, still timing out on hostkey generation (sparcbot)
[oweals/gnunet.git] / src / core / core.h
1 /*
2      This file is part of GNUnet.
3      (C) 2009, 2010 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 core/core.h
23  * @brief common internal definitions for core service
24  * @author Christian Grothoff
25  */
26 #include "gnunet_bandwidth_lib.h"
27 #include "gnunet_crypto_lib.h"
28 #include "gnunet_time_lib.h"
29
30 /**
31  * General core debugging.
32  */
33 #define DEBUG_CORE GNUNET_NO
34
35 /**
36  * Debugging interaction core-clients.
37  */
38 #define DEBUG_CORE_CLIENT GNUNET_NO
39
40 /**
41  * Definition of bits in the InitMessage's options field that specify
42  * which events this client cares about.  Note that inbound messages
43  * for handlers that were specifically registered are always
44  * transmitted to the client.
45  */
46 #define GNUNET_CORE_OPTION_NOTHING             0
47 #define GNUNET_CORE_OPTION_SEND_CONNECT        1
48 #define GNUNET_CORE_OPTION_SEND_DISCONNECT     2
49 #define GNUNET_CORE_OPTION_SEND_STATUS_CHANGE  4
50 #define GNUNET_CORE_OPTION_SEND_FULL_INBOUND   8
51 #define GNUNET_CORE_OPTION_SEND_HDR_INBOUND   16
52 #define GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND 32
53 #define GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND  64
54
55
56 /**
57  * Message transmitted core clients to gnunet-service-core
58  * to start the interaction.  This header is followed by
59  * uint16_t type values specifying which messages this
60  * client is interested in.
61  */
62 struct InitMessage
63 {
64
65   /**
66    * Header with type GNUNET_MESSAGE_TYPE_CORE_INIT.
67    */
68   struct GNUNET_MessageHeader header;
69
70   /**
71    * Options, see GNUNET_CORE_OPTION_ values.
72    */
73   uint32_t options GNUNET_PACKED;
74
75 };
76
77
78 /**
79  * Message transmitted by the gnunet-service-core process
80  * to its clients in response to an INIT message.
81  */
82 struct InitReplyMessage
83 {
84
85   /**
86    * Header with type GNUNET_MESSAGE_TYPE_CORE_INIT_REPLY
87    */
88   struct GNUNET_MessageHeader header;
89
90   /**
91    * Always zero.
92    */
93   uint32_t reserved GNUNET_PACKED;
94
95   /**
96    * Public key of the local peer.
97    */
98   struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded publicKey;
99
100 };
101
102
103 /**
104  * Message sent by the service to clients to notify them
105  * about a peer connecting.
106  */
107 struct ConnectNotifyMessage
108 {
109   /**
110    * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT
111    */
112   struct GNUNET_MessageHeader header;
113
114   /**
115    * Distance to the peer.
116    */
117   uint32_t distance GNUNET_PACKED;
118
119   /**
120    * Currently observed latency.
121    */
122   struct GNUNET_TIME_RelativeNBO latency;
123
124   /**
125    * Identity of the connecting peer.
126    */
127   struct GNUNET_PeerIdentity peer;
128
129 };
130
131
132 /**
133  * Message sent by the service to clients to notify them
134  * about a peer changing status.
135  */
136 struct PeerStatusNotifyMessage
137 {
138   /**
139    * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_PEER_STATUS
140    */
141   struct GNUNET_MessageHeader header;
142
143   /**
144    * Distance to the peer.
145    */
146   uint32_t distance GNUNET_PACKED;
147
148   /**
149    * Currently observed latency.
150    */
151   struct GNUNET_TIME_RelativeNBO latency;
152
153   /**
154    * When the peer would time out (unless we see activity)
155    */
156   struct GNUNET_TIME_AbsoluteNBO timeout;
157
158   /**
159    * Available bandwidth from the peer.
160    */
161   struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
162
163   /**
164    * Available bandwidth to the peer.
165    */
166   struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
167
168   /**
169    * Identity of the peer.
170    */
171   struct GNUNET_PeerIdentity peer;
172
173 };
174
175
176 /**
177  * Message sent by the service to clients to notify them
178  * about a peer disconnecting.
179  */
180 struct DisconnectNotifyMessage
181 {
182   /**
183    * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT.
184    */
185   struct GNUNET_MessageHeader header;
186
187   /**
188    * Always zero.
189    */
190   uint32_t reserved GNUNET_PACKED;
191
192   /**
193    * Identity of the connecting peer.
194    */
195   struct GNUNET_PeerIdentity peer;
196
197 };
198
199
200
201 /**
202  * Message sent by the service to clients to notify them about
203  * messages being received or transmitted.  This overall message is
204  * followed by the real message, or just the header of the real
205  * message (depending on the client's preferences).  The receiver can
206  * tell if he got the full message or only a partial message by
207  * looking at the size field in the header of NotifyTrafficMessage and
208  * checking it with the size field in the message that follows.
209  */
210 struct NotifyTrafficMessage
211 {
212   /**
213    * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND
214    * or GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND.
215    */
216   struct GNUNET_MessageHeader header;
217
218   /**
219    * Distance to the peer.
220    */
221   uint32_t distance GNUNET_PACKED;
222
223   /**
224    * Currently observed latency.
225    */
226   struct GNUNET_TIME_RelativeNBO latency;
227
228   /**
229    * Identity of the receiver or sender.
230    */
231   struct GNUNET_PeerIdentity peer;
232
233 };
234
235
236 /**
237  * Message sent to the core asking for configuration
238  * information and possibly preference changes.
239  */
240 struct RequestInfoMessage
241 {
242   /**
243    * Header with type GNUNET_MESSAGE_TYPE_CORE_REQUEST_CONFIGURE
244    */
245   struct GNUNET_MessageHeader header;
246
247   /**
248    * Always zero.
249    */
250   uint32_t reserved GNUNET_PACKED;
251
252   /**
253    * Limit the number of bytes of outbound traffic to this
254    * peer to at most the specified amount (naturally, the
255    * amount is also limited by the receiving peer).
256    */
257   struct GNUNET_BANDWIDTH_Value32NBO limit_outbound;
258
259   /**
260    * Number of bytes of inbound traffic to reserve, can
261    * be negative (to unreserve).  NBO.
262    */
263   int32_t reserve_inbound GNUNET_PACKED;
264
265   /**
266    * Increment the current traffic preference for the given peer by
267    * the specified amont.  The traffic preference is used to determine
268    * the share of bandwidth this peer will typcially be assigned.
269    */
270   uint64_t preference_change GNUNET_PACKED;
271
272   /**
273    * Identity of the peer being configured.
274    */
275   struct GNUNET_PeerIdentity peer;
276
277 };
278
279
280 /**
281  * Response from the core to a "RequestInfoMessage"
282  * providing traffic status information for a peer.
283  */
284 struct ConfigurationInfoMessage
285 {
286   /**
287    * Header with type GNUNET_MESSAGE_TYPE_CORE_CONFIGURATION_INFO
288    */
289   struct GNUNET_MessageHeader header;
290
291   /**
292    * Amount of traffic (inbound number of bytes) that was reserved in
293    * response to the configuration change request.  Negative for
294    * "unreserved" bytes.
295    */
296   int32_t reserved_amount GNUNET_PACKED;
297
298   /**
299    * Available bandwidth in for this peer.
300    * 0 if we have been disconnected.
301    */
302   struct GNUNET_BANDWIDTH_Value32NBO bw_in;
303
304   /**
305    * Available bandwidth out for this peer,
306    * 0 if we have been disconnected.
307    */
308   struct GNUNET_BANDWIDTH_Value32NBO bw_out;
309
310   /**
311    * Current traffic preference for the peer.
312    * 0 if we have been disconnected.
313    */
314   uint64_t preference;
315
316   /**
317    * Identity of the receiver or sender.
318    */
319   struct GNUNET_PeerIdentity peer;
320
321 };
322
323
324 /**
325  * Client asking core to transmit a particular message to
326  * a particular target.  
327  */
328 struct SendMessage
329 {
330   /**
331    * Header with type GNUNET_MESSAGE_TYPE_CORE_SEND
332    */
333   struct GNUNET_MessageHeader header;
334
335   /**
336    * How important is this message?
337    */
338   uint32_t priority GNUNET_PACKED;
339
340   /**
341    * By what time would the sender really like to see this
342    * message transmitted?
343    */
344   struct GNUNET_TIME_AbsoluteNBO deadline;
345
346   /**
347    * Identity of the receiver or sender.
348    */
349   struct GNUNET_PeerIdentity peer;
350
351 };
352
353
354 /**
355  * Client asking core to connect to a particular target.  There is no
356  * response from the core to this type of request (however, if an
357  * actual connection is created or destroyed, be it because of this
358  * type request or not, the core generally needs to notify the
359  * clients).
360  */
361 struct ConnectMessage
362 {
363   /**
364    * Header with type GNUNET_MESSAGE_TYPE_REQUEST_CONNECT or
365    * GNUNET_MESSAGE_TYPE_REQUEST_DISCONNECT.
366    */
367   struct GNUNET_MessageHeader header;
368
369   /**
370    * For alignment.
371    */
372   uint32_t reserved GNUNET_PACKED;
373
374   /**
375    * When to time out.
376    */
377   struct GNUNET_TIME_RelativeNBO timeout;
378
379   /**
380    * Identity of the other peer.
381    */
382   struct GNUNET_PeerIdentity peer;
383
384 };
385
386 /* end of core.h */