removing dead code / unused variables
[oweals/gnunet.git] / src / core / core.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 core/core.h
23  * @brief common internal definitions for core service
24  * @author Christian Grothoff
25  */
26 #include "gnunet_crypto_lib.h"
27 #include "gnunet_time_lib.h"
28
29 /**
30  * General core debugging.
31  */
32 #define DEBUG_CORE GNUNET_NO
33
34 /**
35  * Debugging interaction core-clients.
36  */
37 #define DEBUG_CORE_CLIENT GNUNET_NO
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_CONNECT        1
47 #define GNUNET_CORE_OPTION_SEND_DISCONNECT     2
48 #define GNUNET_CORE_OPTION_SEND_BFC            4
49 #define GNUNET_CORE_OPTION_SEND_FULL_INBOUND   8
50 #define GNUNET_CORE_OPTION_SEND_HDR_INBOUND   16
51 #define GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND 32
52 #define GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND  64
53
54
55 /**
56  * Message transmitted core clients to gnunet-service-core
57  * to start the interaction.  This header is followed by
58  * uint16_t type values specifying which messages this
59  * client is interested in.
60  */
61 struct InitMessage
62 {
63
64   /**
65    * Header with type GNUNET_MESSAGE_TYPE_CORE_INIT.
66    */
67   struct GNUNET_MessageHeader header;
68
69   /**
70    * Options, see GNUNET_CORE_OPTION_ values.
71    */
72   uint32_t options GNUNET_PACKED;
73
74 };
75
76
77 /**
78  * Message transmitted by the gnunet-service-core process
79  * to its clients in response to an INIT message.
80  */
81 struct InitReplyMessage
82 {
83
84   /**
85    * Header with type GNUNET_MESSAGE_TYPE_CORE_INIT_REPLY
86    */
87   struct GNUNET_MessageHeader header;
88
89   /**
90    * Always zero.
91    */
92   uint32_t reserved GNUNET_PACKED;
93
94   /**
95    * Public key of the local peer.
96    */
97   struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded publicKey;
98
99 };
100
101
102 /**
103  * Message sent by the service to clients to notify them
104  * about a peer connecting or disconnecting.
105  */
106 struct ConnectNotifyMessage
107 {
108   /**
109    * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT
110    * or GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT.
111    */
112   struct GNUNET_MessageHeader header;
113
114   /**
115    * Always zero.
116    */
117   uint32_t reserved GNUNET_PACKED;
118
119   /**
120    * Identity of the connecting peer.
121    */
122   struct GNUNET_PeerIdentity peer;
123
124 };
125
126
127
128 /**
129  * Message sent by the service to clients to notify them about
130  * messages being received or transmitted.  This overall message is
131  * followed by the real message, or just the header of the real
132  * message (depending on the client's preferences).  The receiver can
133  * tell if he got the full message or only a partial message by
134  * looking at the size field in the header of NotifyTrafficMessage and
135  * checking it with the size field in the message that follows.
136  */
137 struct NotifyTrafficMessage
138 {
139   /**
140    * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND
141    * or GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND.
142    */
143   struct GNUNET_MessageHeader header;
144
145   /**
146    * Always zero.
147    */
148   uint32_t reserved GNUNET_PACKED;
149
150   /**
151    * Identity of the receiver or sender.
152    */
153   struct GNUNET_PeerIdentity peer;
154
155 };
156
157
158 /**
159  * Message sent to the core asking for configuration
160  * information and possibly preference changes.
161  */
162 struct RequestConfigureMessage
163 {
164   /**
165    * Header with type GNUNET_MESSAGE_TYPE_CORE_REQUEST_CONFIGURE
166    */
167   struct GNUNET_MessageHeader header;
168
169   /**
170    * Always zero.
171    */
172   uint32_t reserved GNUNET_PACKED;
173
174   /**
175    * Limit the number of bytes of outbound traffic to this
176    * peer to at most the specified amount (naturally, the
177    * amount is also limited by the receiving peer).
178    */
179   uint32_t limit_outbound_bpm GNUNET_PACKED;
180
181   /**
182    * Number of bytes of inbound traffic to reserve, can
183    * be negative (to unreserve).  NBO.
184    */
185   int32_t reserve_inbound GNUNET_PACKED;
186
187   /**
188    * Increment the current traffic preference for the given peer by
189    * the specified amont.  The traffic preference is used to determine
190    * the share of bandwidth this peer will typcially be assigned.
191    */
192   uint64_t preference_change GNUNET_PACKED;
193
194   /**
195    * Identity of the peer being configured.
196    */
197   struct GNUNET_PeerIdentity peer;
198
199 };
200
201
202 /**
203  * Response from the core to a "RequestConfigureMessage"
204  * providing traffic status information for a peer.
205  */
206 struct ConfigurationInfoMessage
207 {
208   /**
209    * Header with type GNUNET_MESSAGE_TYPE_CORE_CONFIGURATION_INFO
210    */
211   struct GNUNET_MessageHeader header;
212
213   /**
214    * Amount of traffic (inbound number of bytes) that was reserved in
215    * response to the configuration change request.  Negative for
216    * "unreserved" bytes.
217    */
218   int32_t reserved_amount GNUNET_PACKED;
219
220   /**
221    * Available bandwidth in (in bytes per minute) for this peer.
222    * 0 if we have been disconnected.
223    */
224   uint32_t bpm_in GNUNET_PACKED;
225
226   /**
227    * Available bandwidth out (in bytes per minute) for this peer,
228    * 0 if we have been disconnected.
229    */
230   uint32_t bpm_out GNUNET_PACKED;
231
232   /**
233    * Latest transport latency estimate for the peer.
234    * FOREVER if we have been disconnected.
235    */
236   struct GNUNET_TIME_RelativeNBO latency;
237
238   /**
239    * Current traffic preference for the peer.
240    * 0 if we have been disconnected.
241    */
242   double preference;
243
244   /**
245    * Identity of the receiver or sender.
246    */
247   struct GNUNET_PeerIdentity peer;
248
249 };
250
251
252 /**
253  * Core asking a client to generate traffic for a particular
254  * target.
255  */
256 struct SolicitTrafficMessage
257 {
258   /**
259    * Header with type GNUNET_MESSAGE_TYPE_CORE_SOLICIT_TRAFFIC
260    * or GNUNET_MESSAGE_TYPE_CORE_RECV_OK
261    */
262   struct GNUNET_MessageHeader header;
263
264   /**
265    * Number of bytes of traffic being solicited.
266    */
267   uint32_t solicit_size GNUNET_PACKED;
268
269   /**
270    * Identity of the receiver or sender.
271    */
272   struct GNUNET_PeerIdentity peer;
273
274 };
275
276
277 /**
278  * Client asking core to transmit a particular message to
279  * a particular target.  Does NOT have to be solicited.
280  */
281 struct SendMessage
282 {
283   /**
284    * Header with type GNUNET_MESSAGE_TYPE_CORE_SEND
285    */
286   struct GNUNET_MessageHeader header;
287
288   /**
289    * How important is this message?
290    */
291   uint32_t priority GNUNET_PACKED;
292
293   /**
294    * By what time would the sender really like to see this
295    * message transmitted?
296    */
297   struct GNUNET_TIME_AbsoluteNBO deadline;
298
299   /**
300    * Identity of the receiver or sender.
301    */
302   struct GNUNET_PeerIdentity peer;
303
304 };
305
306
307 /* end of core.h */