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_EXTRA_LOGGING
36 * Debugging interaction core-clients.
38 #define DEBUG_CORE_CLIENT GNUNET_EXTRA_LOGGING
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_PeerIdentity my_identity;
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 * Number of ATS key-value pairs that follow this struct
116 * (excluding the 0-terminator).
118 uint32_t ats_count GNUNET_PACKED;
121 * Identity of the connecting peer.
123 struct GNUNET_PeerIdentity peer;
126 * First of the ATS information blocks (we must have at least
127 * one due to the 0-termination requirement).
129 struct GNUNET_TRANSPORT_ATS_Information ats;
135 * Message sent by the service to clients to notify them
136 * about a peer changing status.
138 struct PeerStatusNotifyMessage
141 * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_PEER_STATUS
143 struct GNUNET_MessageHeader header;
146 * Number of ATS key-value pairs that follow this struct
147 * (excluding the 0-terminator).
149 uint32_t ats_count GNUNET_PACKED;
152 * When the peer would time out (unless we see activity)
154 struct GNUNET_TIME_AbsoluteNBO timeout;
157 * Available bandwidth from the peer.
159 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
162 * Available bandwidth to the peer.
164 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
167 * Identity of the peer.
169 struct GNUNET_PeerIdentity peer;
172 * First of the ATS information blocks (we must have at least
173 * one due to the 0-termination requirement).
175 struct GNUNET_TRANSPORT_ATS_Information ats;
181 * Message sent by the service to clients to notify them
182 * about a peer disconnecting.
184 struct DisconnectNotifyMessage
187 * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT.
189 struct GNUNET_MessageHeader header;
194 uint32_t reserved GNUNET_PACKED;
197 * Identity of the connecting peer.
199 struct GNUNET_PeerIdentity peer;
205 * Message sent by the service to clients to notify them about
206 * messages being received or transmitted. This overall message is
207 * followed by the real message, or just the header of the real
208 * message (depending on the client's preferences). The receiver can
209 * tell if he got the full message or only a partial message by
210 * looking at the size field in the header of NotifyTrafficMessage and
211 * checking it with the size field in the message that follows.
213 struct NotifyTrafficMessage
216 * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND
217 * or GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND.
219 struct GNUNET_MessageHeader header;
222 * Number of ATS key-value pairs that follow this struct
223 * (excluding the 0-terminator).
225 uint32_t ats_count GNUNET_PACKED;
228 * Identity of the receiver or sender.
230 struct GNUNET_PeerIdentity peer;
233 * First of the ATS information blocks (we must have at least
234 * one due to the 0-termination requirement).
236 struct GNUNET_TRANSPORT_ATS_Information ats;
242 * Client notifying core about the maximum-priority
243 * message it has in the queue for a particular target.
245 struct SendMessageRequest
248 * Header with type GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST
250 struct GNUNET_MessageHeader header;
253 * How important is this message?
255 uint32_t priority GNUNET_PACKED;
258 * By what time would the sender really like to see this
259 * message transmitted?
261 struct GNUNET_TIME_AbsoluteNBO deadline;
264 * Identity of the intended target.
266 struct GNUNET_PeerIdentity peer;
269 * How large is the client's message queue for this peer?
271 uint32_t queue_size GNUNET_PACKED;
274 * How large is the message?
276 uint16_t size GNUNET_PACKED;
279 * Counter for this peer to match SMRs to replies.
281 uint16_t smr_id GNUNET_PACKED;
287 * Core notifying client that it is allowed to now
288 * transmit a message to the given target
289 * (response to GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST).
291 struct SendMessageReady
294 * Header with type GNUNET_MESSAGE_TYPE_CORE_SEND_READY
296 struct GNUNET_MessageHeader header;
299 * How many bytes are allowed for transmission?
300 * Guaranteed to be at least as big as the requested size,
301 * or ZERO if the request is rejected (will timeout,
302 * peer disconnected, queue full, etc.).
304 uint16_t size GNUNET_PACKED;
307 * smr_id from the request.
309 uint16_t smr_id GNUNET_PACKED;
312 * Identity of the intended target.
314 struct GNUNET_PeerIdentity peer;
320 * Client asking core to transmit a particular message to a particular
321 * target (response to GNUNET_MESSAGE_TYPE_CORE_SEND_READY).
326 * Header with type GNUNET_MESSAGE_TYPE_CORE_SEND
328 struct GNUNET_MessageHeader header;
331 * How important is this message?
333 uint32_t priority GNUNET_PACKED;
336 * By what time would the sender really like to see this
337 * message transmitted?
339 struct GNUNET_TIME_AbsoluteNBO deadline;
342 * Identity of the receiver or sender.
344 struct GNUNET_PeerIdentity peer;
347 * GNUNET_YES if corking is allowed, GNUNET_NO if not.
349 uint32_t cork GNUNET_PACKED;
354 uint64_t reserved GNUNET_PACKED;
360 * Client asking core to connect to a particular target. There is no
361 * response from the core to this type of request (however, if an
362 * actual connection is created or destroyed, be it because of this
363 * type request or not, the core generally needs to notify the
366 struct ConnectMessage
369 * Header with type GNUNET_MESSAGE_TYPE_REQUEST_CONNECT or
370 * GNUNET_MESSAGE_TYPE_REQUEST_DISCONNECT.
372 struct GNUNET_MessageHeader header;
377 uint32_t reserved GNUNET_PACKED;
380 * Identity of the other peer.
382 struct GNUNET_PeerIdentity peer;