2 This file is part of GNUnet.
3 (C) 2009 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 2, 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_crypto_lib.h"
27 #include "gnunet_time_lib.h"
30 * General core debugging.
32 #define DEBUG_CORE GNUNET_NO
35 * Debugging interaction core-clients.
37 #define DEBUG_CORE_CLIENT GNUNET_YES
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.
45 #define GNUNET_CORE_OPTION_NOTHING 0
46 #define GNUNET_CORE_OPTION_SEND_PRE_CONNECT 1
47 #define GNUNET_CORE_OPTION_SEND_CONNECT 2
48 #define GNUNET_CORE_OPTION_SEND_DISCONNECT 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
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.
65 * Header with type GNUNET_MESSAGE_TYPE_CORE_INIT.
67 struct GNUNET_MessageHeader header;
70 * Options, see GNUNET_CORE_OPTION_ values.
72 uint32_t options GNUNET_PACKED;
78 * Message transmitted by the gnunet-service-core process
79 * to its clients in response to an INIT message.
81 struct InitReplyMessage
85 * Header with type GNUNET_MESSAGE_TYPE_CORE_INIT_REPLY
87 struct GNUNET_MessageHeader header;
92 uint32_t reserved GNUNET_PACKED;
95 * Public key of the local peer.
97 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded publicKey;
103 * Message sent by the service to clients to notify them
104 * about a peer connecting or disconnecting.
106 struct ConnectNotifyMessage
109 * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT
110 * or GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT.
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;
134 * Message sent by the service to clients to notify them
135 * about a peer disconnecting.
137 struct DisconnectNotifyMessage
140 * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT.
142 struct GNUNET_MessageHeader header;
147 uint32_t reserved GNUNET_PACKED;
150 * Identity of the connecting peer.
152 struct GNUNET_PeerIdentity peer;
159 * Message sent by the service to clients to notify them about
160 * messages being received or transmitted. This overall message is
161 * followed by the real message, or just the header of the real
162 * message (depending on the client's preferences). The receiver can
163 * tell if he got the full message or only a partial message by
164 * looking at the size field in the header of NotifyTrafficMessage and
165 * checking it with the size field in the message that follows.
167 struct NotifyTrafficMessage
170 * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND
171 * or GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND.
173 struct GNUNET_MessageHeader header;
176 * Distance to the peer.
178 uint32_t distance GNUNET_PACKED;
181 * Currently observed latency.
183 struct GNUNET_TIME_RelativeNBO latency;
186 * Identity of the receiver or sender.
188 struct GNUNET_PeerIdentity peer;
194 * Message sent to the core asking for configuration
195 * information and possibly preference changes.
197 struct RequestInfoMessage
200 * Header with type GNUNET_MESSAGE_TYPE_CORE_REQUEST_CONFIGURE
202 struct GNUNET_MessageHeader header;
207 uint32_t reserved GNUNET_PACKED;
210 * Limit the number of bytes of outbound traffic to this
211 * peer to at most the specified amount (naturally, the
212 * amount is also limited by the receiving peer).
214 uint32_t limit_outbound_bpm GNUNET_PACKED;
217 * Number of bytes of inbound traffic to reserve, can
218 * be negative (to unreserve). NBO.
220 int32_t reserve_inbound GNUNET_PACKED;
223 * Increment the current traffic preference for the given peer by
224 * the specified amont. The traffic preference is used to determine
225 * the share of bandwidth this peer will typcially be assigned.
227 uint64_t preference_change GNUNET_PACKED;
230 * Identity of the peer being configured.
232 struct GNUNET_PeerIdentity peer;
238 * Response from the core to a "RequestInfoMessage"
239 * providing traffic status information for a peer.
241 struct ConfigurationInfoMessage
244 * Header with type GNUNET_MESSAGE_TYPE_CORE_CONFIGURATION_INFO
246 struct GNUNET_MessageHeader header;
249 * Amount of traffic (inbound number of bytes) that was reserved in
250 * response to the configuration change request. Negative for
251 * "unreserved" bytes.
253 int32_t reserved_amount GNUNET_PACKED;
256 * Available bandwidth in (in bytes per minute) for this peer.
257 * 0 if we have been disconnected.
259 uint32_t bpm_in GNUNET_PACKED;
262 * Available bandwidth out (in bytes per minute) for this peer,
263 * 0 if we have been disconnected.
265 uint32_t bpm_out GNUNET_PACKED;
268 * Current traffic preference for the peer.
269 * 0 if we have been disconnected.
274 * Identity of the receiver or sender.
276 struct GNUNET_PeerIdentity peer;
282 * Client asking core to transmit a particular message to
283 * a particular target.
288 * Header with type GNUNET_MESSAGE_TYPE_CORE_SEND
290 struct GNUNET_MessageHeader header;
293 * How important is this message?
295 uint32_t priority GNUNET_PACKED;
298 * By what time would the sender really like to see this
299 * message transmitted?
301 struct GNUNET_TIME_AbsoluteNBO deadline;
304 * Identity of the receiver or sender.
306 struct GNUNET_PeerIdentity peer;
312 * Client asking core to connect to a particular target. There is no
313 * response from the core to this type of request (however, if an
314 * actual connection is created or destroyed, be it because of this
315 * type request or not, the core generally needs to notify the
318 struct ConnectMessage
321 * Header with type GNUNET_MESSAGE_TYPE_REQUEST_CONNECT or
322 * GNUNET_MESSAGE_TYPE_REQUEST_DISCONNECT.
324 struct GNUNET_MessageHeader header;
329 uint32_t reserved GNUNET_PACKED;
332 * Identity of the other peer.
334 struct GNUNET_PeerIdentity peer;