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"
29 #define DEBUG_CORE GNUNET_YES
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.
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
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.
57 * Header with type GNUNET_MESSAGE_TYPE_CORE_INIT.
59 struct GNUNET_MessageHeader header;
62 * Options, see GNUNET_CORE_OPTION_ values.
64 uint32_t options GNUNET_PACKED;
70 * Message transmitted by the gnunet-service-core process
71 * to its clients in response to an INIT message.
73 struct InitReplyMessage
77 * Header with type GNUNET_MESSAGE_TYPE_CORE_INIT_REPLY
79 struct GNUNET_MessageHeader header;
84 uint32_t reserved GNUNET_PACKED;
87 * Public key of the local peer.
89 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded publicKey;
95 * Message sent by the service to clients to notify them
96 * about a peer connecting or disconnecting.
98 struct ConnectNotifyMessage
101 * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT
102 * or GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT.
104 struct GNUNET_MessageHeader header;
107 * Available bandwidth to this peer; zero for disconnect.
108 * [TODO: currently set to hard-coded constant and hence
109 * not really useful, right?]
111 uint32_t bpm_available GNUNET_PACKED;
114 * Identity of the connecting peer.
116 struct GNUNET_PeerIdentity peer;
119 * Time of our last interaction with the peer; close
120 * to "now" for connect messages.
121 * [TODO: is this useful?]
123 struct GNUNET_TIME_AbsoluteNBO last_activity;
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.
138 struct NotifyTrafficMessage
141 * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND
142 * or GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND.
144 struct GNUNET_MessageHeader header;
149 uint32_t reserved GNUNET_PACKED;
152 * Identity of the receiver or sender.
154 struct GNUNET_PeerIdentity peer;
160 * Message sent to the core asking for configuration
161 * information and possibly preference changes.
163 struct RequestConfigureMessage
166 * Header with type GNUNET_MESSAGE_TYPE_CORE_REQUEST_CONFIGURE
168 struct GNUNET_MessageHeader header;
173 uint32_t reserved GNUNET_PACKED;
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).
180 uint32_t limit_outbound_bpm GNUNET_PACKED;
183 * Number of bytes of inbound traffic to reserve, can
184 * be negative (to unreserve). NBO.
186 int32_t reserve_inbound GNUNET_PACKED;
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.
193 double preference_change GNUNET_PACKED;
196 * Identity of the peer being configured.
198 struct GNUNET_PeerIdentity peer;
204 * Response from the core to a "RequestConfigureMessage"
205 * providing traffic status information for a peer.
207 struct ConfigurationInfoMessage
210 * Header with type GNUNET_MESSAGE_TYPE_CORE_CONFIGURATION_INFO
212 struct GNUNET_MessageHeader header;
215 * Amount of traffic (inbound number of bytes) that was reserved in
216 * response to the configuration change request. Negative for
217 * "unreserved" bytes.
219 int32_t reserved_amount GNUNET_PACKED;
222 * Available bandwidth in (in bytes per minute) for this peer.
223 * 0 if we have been disconnected.
225 uint32_t bpm_in GNUNET_PACKED;
228 * Available bandwidth out (in bytes per minute) for this peer,
229 * 0 if we have been disconnected.
231 uint32_t bpm_out GNUNET_PACKED;
234 * Latest transport latency estimate for the peer.
235 * FOREVER if we have been disconnected.
237 struct GNUNET_TIME_RelativeNBO latency;
240 * Current traffic preference for the peer.
241 * 0 if we have been disconnected.
246 * Identity of the receiver or sender.
248 struct GNUNET_PeerIdentity peer;
254 * Core asking a client to generate traffic for a particular
257 struct SolicitTrafficMessage
260 * Header with type GNUNET_MESSAGE_TYPE_CORE_SOLICIT_TRAFFIC
261 * or GNUNET_MESSAGE_TYPE_CORE_RECV_OK
263 struct GNUNET_MessageHeader header;
266 * Number of bytes of traffic being solicited.
268 uint32_t solicit_size GNUNET_PACKED;
271 * Identity of the receiver or sender.
273 struct GNUNET_PeerIdentity peer;
279 * Client asking core to transmit a particular message to
280 * a particular target. Does NOT have to be solicited.
285 * Header with type GNUNET_MESSAGE_TYPE_CORE_SEND
287 struct GNUNET_MessageHeader header;
290 * How important is this message?
292 uint32_t priority GNUNET_PACKED;
295 * By what time would the sender really like to see this
296 * message transmitted?
298 struct GNUNET_TIME_AbsoluteNBO deadline;
301 * Identity of the receiver or sender.
303 struct GNUNET_PeerIdentity peer;