2 This file is part of GNUnet.
3 (C) 2009, 2010 Christian Grothoff (and other contributing authors)
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.
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.
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.
23 * @brief common internal definitions for core service
24 * @author Christian Grothoff
26 #include "gnunet_bandwidth_lib.h"
27 #include "gnunet_crypto_lib.h"
28 #include "gnunet_time_lib.h"
31 * General core debugging.
33 #define DEBUG_CORE GNUNET_NO
36 * Debugging interaction core-clients.
38 #define DEBUG_CORE_CLIENT GNUNET_NO
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.
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
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.
66 * Header with type GNUNET_MESSAGE_TYPE_CORE_INIT.
68 struct GNUNET_MessageHeader header;
71 * Options, see GNUNET_CORE_OPTION_ values.
73 uint32_t options GNUNET_PACKED;
79 * Message transmitted by the gnunet-service-core process
80 * to its clients in response to an INIT message.
82 struct InitReplyMessage
86 * Header with type GNUNET_MESSAGE_TYPE_CORE_INIT_REPLY
88 struct GNUNET_MessageHeader header;
93 uint32_t reserved GNUNET_PACKED;
96 * Public key of the local peer.
98 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded publicKey;
104 * Message sent by the service to clients to notify them
105 * about a peer connecting.
107 struct ConnectNotifyMessage
110 * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT
112 struct GNUNET_MessageHeader header;
115 * Distance to the peer.
117 uint32_t distance GNUNET_PACKED;
120 * Currently observed latency.
122 struct GNUNET_TIME_RelativeNBO latency;
125 * Identity of the connecting peer.
127 struct GNUNET_PeerIdentity peer;
133 * Message sent by the service to clients to notify them
134 * about a peer changing status.
136 struct PeerStatusNotifyMessage
139 * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_PEER_STATUS
141 struct GNUNET_MessageHeader header;
144 * Distance to the peer.
146 uint32_t distance GNUNET_PACKED;
149 * Currently observed latency.
151 struct GNUNET_TIME_RelativeNBO latency;
154 * When the peer would time out (unless we see activity)
156 struct GNUNET_TIME_AbsoluteNBO timeout;
159 * Available bandwidth from the peer.
161 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
164 * Available bandwidth to the peer.
166 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
169 * Identity of the peer.
171 struct GNUNET_PeerIdentity peer;
177 * Message sent by the service to clients to notify them
178 * about a peer disconnecting.
180 struct DisconnectNotifyMessage
183 * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT.
185 struct GNUNET_MessageHeader header;
190 uint32_t reserved GNUNET_PACKED;
193 * Identity of the connecting peer.
195 struct GNUNET_PeerIdentity peer;
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.
210 struct NotifyTrafficMessage
213 * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND
214 * or GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND.
216 struct GNUNET_MessageHeader header;
219 * Distance to the peer.
221 uint32_t distance GNUNET_PACKED;
224 * Currently observed latency.
226 struct GNUNET_TIME_RelativeNBO latency;
229 * Identity of the receiver or sender.
231 struct GNUNET_PeerIdentity peer;
237 * Message sent to the core asking for configuration
238 * information and possibly preference changes.
240 struct RequestInfoMessage
243 * Header with type GNUNET_MESSAGE_TYPE_CORE_REQUEST_CONFIGURE
245 struct GNUNET_MessageHeader header;
250 uint32_t reserved GNUNET_PACKED;
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).
257 struct GNUNET_BANDWIDTH_Value32NBO limit_outbound;
260 * Number of bytes of inbound traffic to reserve, can
261 * be negative (to unreserve). NBO.
263 int32_t reserve_inbound GNUNET_PACKED;
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.
270 uint64_t preference_change GNUNET_PACKED;
273 * Identity of the peer being configured.
275 struct GNUNET_PeerIdentity peer;
281 * Response from the core to a "RequestInfoMessage"
282 * providing traffic status information for a peer.
284 struct ConfigurationInfoMessage
287 * Header with type GNUNET_MESSAGE_TYPE_CORE_CONFIGURATION_INFO
289 struct GNUNET_MessageHeader header;
292 * Amount of traffic (inbound number of bytes) that was reserved in
293 * response to the configuration change request. Negative for
294 * "unreserved" bytes.
296 int32_t reserved_amount GNUNET_PACKED;
299 * Available bandwidth in for this peer.
300 * 0 if we have been disconnected.
302 struct GNUNET_BANDWIDTH_Value32NBO bw_in;
305 * Available bandwidth out for this peer,
306 * 0 if we have been disconnected.
308 struct GNUNET_BANDWIDTH_Value32NBO bw_out;
311 * Current traffic preference for the peer.
312 * 0 if we have been disconnected.
317 * Identity of the receiver or sender.
319 struct GNUNET_PeerIdentity peer;
325 * Client asking core to transmit a particular message to
326 * a particular target.
331 * Header with type GNUNET_MESSAGE_TYPE_CORE_SEND
333 struct GNUNET_MessageHeader header;
336 * How important is this message?
338 uint32_t priority GNUNET_PACKED;
341 * By what time would the sender really like to see this
342 * message transmitted?
344 struct GNUNET_TIME_AbsoluteNBO deadline;
347 * Identity of the receiver or sender.
349 struct GNUNET_PeerIdentity peer;
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
361 struct ConnectMessage
364 * Header with type GNUNET_MESSAGE_TYPE_REQUEST_CONNECT or
365 * GNUNET_MESSAGE_TYPE_REQUEST_DISCONNECT.
367 struct GNUNET_MessageHeader header;
372 uint32_t reserved GNUNET_PACKED;
377 struct GNUNET_TIME_RelativeNBO timeout;
380 * Identity of the other peer.
382 struct GNUNET_PeerIdentity peer;