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