remove unused options -- these bits were always set, no need to pass them
[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 #ifndef CORE_H
27 #define CORE_H
28
29 #include "gnunet_bandwidth_lib.h"
30 #include "gnunet_transport_service.h"
31 #include "gnunet_crypto_lib.h"
32 #include "gnunet_time_lib.h"
33
34 /**
35  * General core debugging.
36  */
37 #define DEBUG_CORE GNUNET_EXTRA_LOGGING
38
39 /**
40  * Definition of bits in the InitMessage's options field that specify
41  * which events this client cares about.  Note that inbound messages
42  * for handlers that were specifically registered are always
43  * transmitted to the client.
44  */
45 #define GNUNET_CORE_OPTION_NOTHING             0
46 #define GNUNET_CORE_OPTION_SEND_STATUS_CHANGE  4
47 #define GNUNET_CORE_OPTION_SEND_FULL_INBOUND   8
48 #define GNUNET_CORE_OPTION_SEND_HDR_INBOUND   16
49 #define GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND 32
50 #define GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND  64
51
52
53 /**
54  * Message transmitted core clients to gnunet-service-core
55  * to start the interaction.  This header is followed by
56  * uint16_t type values specifying which messages this
57  * client is interested in.
58  */
59 struct InitMessage
60 {
61
62   /**
63    * Header with type GNUNET_MESSAGE_TYPE_CORE_INIT.
64    */
65   struct GNUNET_MessageHeader header;
66
67   /**
68    * Options, see GNUNET_CORE_OPTION_ values.
69    */
70   uint32_t options GNUNET_PACKED;
71
72 };
73
74
75 /**
76  * Message transmitted by the gnunet-service-core process
77  * to its clients in response to an INIT message.
78  */
79 struct InitReplyMessage
80 {
81
82   /**
83    * Header with type GNUNET_MESSAGE_TYPE_CORE_INIT_REPLY
84    */
85   struct GNUNET_MessageHeader header;
86
87   /**
88    * Always zero.
89    */
90   uint32_t reserved GNUNET_PACKED;
91
92   /**
93    * Public key of the local peer.
94    */
95   struct GNUNET_PeerIdentity my_identity;
96
97 };
98
99
100 /**
101  * Message sent by the service to clients to notify them
102  * about a peer connecting.
103  */
104 struct ConnectNotifyMessage
105 {
106   /**
107    * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT
108    */
109   struct GNUNET_MessageHeader header;
110
111   /**
112    * Number of ATS key-value pairs that follow this struct
113    * (excluding the 0-terminator).
114    */
115   uint32_t ats_count GNUNET_PACKED;
116
117   /**
118    * Identity of the connecting peer.
119    */
120   struct GNUNET_PeerIdentity peer;
121
122   /**
123    * First of the ATS information blocks (we must have at least
124    * one due to the 0-termination requirement).
125    */
126   struct GNUNET_ATS_Information ats;
127
128 };
129
130
131 /**
132  * Message sent by the service to clients to notify them
133  * about a peer changing status.
134  */
135 struct PeerStatusNotifyMessage
136 {
137   /**
138    * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_PEER_STATUS
139    */
140   struct GNUNET_MessageHeader header;
141
142   /**
143    * Number of ATS key-value pairs that follow this struct
144    * (excluding the 0-terminator).
145    */
146   uint32_t ats_count GNUNET_PACKED;
147
148   /**
149    * When the peer would time out (unless we see activity)
150    */
151   struct GNUNET_TIME_AbsoluteNBO timeout;
152
153   /**
154    * Available bandwidth from the peer.
155    */
156   struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
157
158   /**
159    * Available bandwidth to the peer.
160    */
161   struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
162
163   /**
164    * Identity of the peer.
165    */
166   struct GNUNET_PeerIdentity peer;
167
168   /**
169    * First of the ATS information blocks (we must have at least
170    * one due to the 0-termination requirement).
171    */
172   struct GNUNET_ATS_Information ats;
173
174 };
175
176
177 /**
178  * Message sent by the service to clients to notify them
179  * about a peer disconnecting.
180  */
181 struct DisconnectNotifyMessage
182 {
183   /**
184    * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT.
185    */
186   struct GNUNET_MessageHeader header;
187
188   /**
189    * Always zero.
190    */
191   uint32_t reserved GNUNET_PACKED;
192
193   /**
194    * Identity of the connecting peer.
195    */
196   struct GNUNET_PeerIdentity peer;
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    * Number of ATS key-value pairs that follow this struct
220    * (excluding the 0-terminator).
221    */
222   uint32_t ats_count GNUNET_PACKED;
223
224   /**
225    * Identity of the receiver or sender.
226    */
227   struct GNUNET_PeerIdentity peer;
228
229   /**
230    * First of the ATS information blocks (we must have at least
231    * one due to the 0-termination requirement).
232    */
233   struct GNUNET_ATS_Information ats;
234
235 };
236
237
238 /**
239  * Client notifying core about the maximum-priority
240  * message it has in the queue for a particular target.
241  */
242 struct SendMessageRequest
243 {
244   /**
245    * Header with type GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST
246    */
247   struct GNUNET_MessageHeader header;
248
249   /**
250    * How important is this message?
251    */
252   uint32_t priority GNUNET_PACKED;
253
254   /**
255    * By what time would the sender really like to see this
256    * message transmitted?
257    */
258   struct GNUNET_TIME_AbsoluteNBO deadline;
259
260   /**
261    * Identity of the intended target.
262    */
263   struct GNUNET_PeerIdentity peer;
264
265   /**
266    * How large is the client's message queue for this peer?
267    */
268   uint32_t queue_size GNUNET_PACKED;
269
270   /**
271    * How large is the message?
272    */
273   uint16_t size GNUNET_PACKED;
274
275   /**
276    * Counter for this peer to match SMRs to replies.
277    */
278   uint16_t smr_id GNUNET_PACKED;
279
280 };
281
282
283 /**
284  * Core notifying client that it is allowed to now
285  * transmit a message to the given target
286  * (response to GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST).
287  */
288 struct SendMessageReady
289 {
290   /**
291    * Header with type GNUNET_MESSAGE_TYPE_CORE_SEND_READY
292    */
293   struct GNUNET_MessageHeader header;
294
295   /**
296    * How many bytes are allowed for transmission?
297    * Guaranteed to be at least as big as the requested size,
298    * or ZERO if the request is rejected (will timeout,
299    * peer disconnected, queue full, etc.).
300    */
301   uint16_t size GNUNET_PACKED;
302
303   /**
304    * smr_id from the request.
305    */
306   uint16_t smr_id GNUNET_PACKED;
307
308   /**
309    * Identity of the intended target.
310    */
311   struct GNUNET_PeerIdentity peer;
312
313 };
314
315
316 /**
317  * Client asking core to transmit a particular message to a particular
318  * target (response to GNUNET_MESSAGE_TYPE_CORE_SEND_READY).
319  */
320 struct SendMessage
321 {
322   /**
323    * Header with type GNUNET_MESSAGE_TYPE_CORE_SEND
324    */
325   struct GNUNET_MessageHeader header;
326
327   /**
328    * How important is this message?
329    */
330   uint32_t priority GNUNET_PACKED;
331
332   /**
333    * By what time would the sender really like to see this
334    * message transmitted?
335    */
336   struct GNUNET_TIME_AbsoluteNBO deadline;
337
338   /**
339    * Identity of the receiver or sender.
340    */
341   struct GNUNET_PeerIdentity peer;
342
343   /**
344    * GNUNET_YES if corking is allowed, GNUNET_NO if not.
345    */
346   uint32_t cork GNUNET_PACKED;
347
348   /**
349    * Always 0.
350    */
351   uint64_t reserved GNUNET_PACKED;
352
353 };
354
355
356 /**
357  * Client asking core to connect to a particular target.  There is no
358  * response from the core to this type of request (however, if an
359  * actual connection is created or destroyed, be it because of this
360  * type request or not, the core generally needs to notify the
361  * clients).
362  */
363 struct ConnectMessage
364 {
365   /**
366    * Header with type GNUNET_MESSAGE_TYPE_REQUEST_CONNECT or
367    * GNUNET_MESSAGE_TYPE_REQUEST_DISCONNECT.
368    */
369   struct GNUNET_MessageHeader header;
370
371   /**
372    * For alignment.
373    */
374   uint32_t reserved GNUNET_PACKED;
375
376   /**
377    * Identity of the other peer.
378    */
379   struct GNUNET_PeerIdentity peer;
380
381 };
382
383 #endif
384 /* end of core.h */