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
29 #include "gnunet_bandwidth_lib.h"
30 #include "gnunet_transport_service.h"
31 #include "gnunet_crypto_lib.h"
32 #include "gnunet_time_lib.h"
35 * General core debugging.
37 #define DEBUG_CORE GNUNET_EXTRA_LOGGING
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_STATUS_CHANGE 4
47 #define GNUNET_CORE_OPTION_SEND_FULL_INBOUND 8
48 #define GNUNET_CORE_OPTION_SEND_HDR_INBOUND 16
49 #define GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND 32
50 #define GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND 64
54 * Message transmitted core clients to gnunet-service-core
55 * to start the interaction. This header is followed by
56 * uint16_t type values specifying which messages this
57 * client is interested in.
63 * Header with type GNUNET_MESSAGE_TYPE_CORE_INIT.
65 struct GNUNET_MessageHeader header;
68 * Options, see GNUNET_CORE_OPTION_ values.
70 uint32_t options GNUNET_PACKED;
76 * Message transmitted by the gnunet-service-core process
77 * to its clients in response to an INIT message.
79 struct InitReplyMessage
83 * Header with type GNUNET_MESSAGE_TYPE_CORE_INIT_REPLY
85 struct GNUNET_MessageHeader header;
90 uint32_t reserved GNUNET_PACKED;
93 * Public key of the local peer.
95 struct GNUNET_PeerIdentity my_identity;
101 * Message sent by the service to clients to notify them
102 * about a peer connecting.
104 struct ConnectNotifyMessage
107 * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT
109 struct GNUNET_MessageHeader header;
112 * Number of ATS key-value pairs that follow this struct
113 * (excluding the 0-terminator).
115 uint32_t ats_count GNUNET_PACKED;
118 * Identity of the connecting peer.
120 struct GNUNET_PeerIdentity peer;
123 * First of the ATS information blocks (we must have at least
124 * one due to the 0-termination requirement).
126 struct GNUNET_ATS_Information ats;
132 * Message sent by the service to clients to notify them
133 * about a peer changing status.
135 struct PeerStatusNotifyMessage
138 * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_PEER_STATUS
140 struct GNUNET_MessageHeader header;
143 * Number of ATS key-value pairs that follow this struct
144 * (excluding the 0-terminator).
146 uint32_t ats_count GNUNET_PACKED;
149 * When the peer would time out (unless we see activity)
151 struct GNUNET_TIME_AbsoluteNBO timeout;
154 * Available bandwidth from the peer.
156 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
159 * Available bandwidth to the peer.
161 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
164 * Identity of the peer.
166 struct GNUNET_PeerIdentity peer;
169 * First of the ATS information blocks (we must have at least
170 * one due to the 0-termination requirement).
172 struct GNUNET_ATS_Information ats;
178 * Message sent by the service to clients to notify them
179 * about a peer disconnecting.
181 struct DisconnectNotifyMessage
184 * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT.
186 struct GNUNET_MessageHeader header;
191 uint32_t reserved GNUNET_PACKED;
194 * Identity of the connecting peer.
196 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 * Number of ATS key-value pairs that follow this struct
220 * (excluding the 0-terminator).
222 uint32_t ats_count GNUNET_PACKED;
225 * Identity of the receiver or sender.
227 struct GNUNET_PeerIdentity peer;
230 * First of the ATS information blocks (we must have at least
231 * one due to the 0-termination requirement).
233 struct GNUNET_ATS_Information ats;
239 * Client notifying core about the maximum-priority
240 * message it has in the queue for a particular target.
242 struct SendMessageRequest
245 * Header with type GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST
247 struct GNUNET_MessageHeader header;
250 * How important is this message?
252 uint32_t priority GNUNET_PACKED;
255 * By what time would the sender really like to see this
256 * message transmitted?
258 struct GNUNET_TIME_AbsoluteNBO deadline;
261 * Identity of the intended target.
263 struct GNUNET_PeerIdentity peer;
266 * How large is the client's message queue for this peer?
268 uint32_t queue_size GNUNET_PACKED;
271 * How large is the message?
273 uint16_t size GNUNET_PACKED;
276 * Counter for this peer to match SMRs to replies.
278 uint16_t smr_id GNUNET_PACKED;
284 * Core notifying client that it is allowed to now
285 * transmit a message to the given target
286 * (response to GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST).
288 struct SendMessageReady
291 * Header with type GNUNET_MESSAGE_TYPE_CORE_SEND_READY
293 struct GNUNET_MessageHeader header;
296 * How many bytes are allowed for transmission?
297 * Guaranteed to be at least as big as the requested size,
298 * or ZERO if the request is rejected (will timeout,
299 * peer disconnected, queue full, etc.).
301 uint16_t size GNUNET_PACKED;
304 * smr_id from the request.
306 uint16_t smr_id GNUNET_PACKED;
309 * Identity of the intended target.
311 struct GNUNET_PeerIdentity peer;
317 * Client asking core to transmit a particular message to a particular
318 * target (response to GNUNET_MESSAGE_TYPE_CORE_SEND_READY).
323 * Header with type GNUNET_MESSAGE_TYPE_CORE_SEND
325 struct GNUNET_MessageHeader header;
328 * How important is this message?
330 uint32_t priority GNUNET_PACKED;
333 * By what time would the sender really like to see this
334 * message transmitted?
336 struct GNUNET_TIME_AbsoluteNBO deadline;
339 * Identity of the receiver or sender.
341 struct GNUNET_PeerIdentity peer;
344 * GNUNET_YES if corking is allowed, GNUNET_NO if not.
346 uint32_t cork GNUNET_PACKED;
351 uint64_t reserved GNUNET_PACKED;
357 * Client asking core to connect to a particular target. There is no
358 * response from the core to this type of request (however, if an
359 * actual connection is created or destroyed, be it because of this
360 * type request or not, the core generally needs to notify the
363 struct ConnectMessage
366 * Header with type GNUNET_MESSAGE_TYPE_REQUEST_CONNECT or
367 * GNUNET_MESSAGE_TYPE_REQUEST_DISCONNECT.
369 struct GNUNET_MessageHeader header;
374 uint32_t reserved GNUNET_PACKED;
377 * Identity of the other peer.
379 struct GNUNET_PeerIdentity peer;