2 This file is part of GNUnet.
3 Copyright (C) 2009-2014 GNUnet e.V.
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., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, 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
48 * The client did properly initialize the connection.
50 #define GNUNET_CORE_OPTION_INIT 1
53 * Client cares about connectivity changes.
55 #define GNUNET_CORE_OPTION_SEND_STATUS_CHANGE 4
58 * Client wants all inbound messages in full.
60 #define GNUNET_CORE_OPTION_SEND_FULL_INBOUND 8
63 * Client just wants the 4-byte message headers of
64 * all inbound messages.
66 #define GNUNET_CORE_OPTION_SEND_HDR_INBOUND 16
69 * Client wants all outbound messages in full.
71 #define GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND 32
74 * Client just wants the 4-byte message headers of
75 * all outbound messages.
77 #define GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND 64
80 GNUNET_NETWORK_STRUCT_BEGIN
83 * Message transmitted core clients to gnunet-service-core
84 * to start the interaction. This header is followed by
85 * uint16_t type values specifying which messages this
86 * client is interested in.
92 * Header with type #GNUNET_MESSAGE_TYPE_CORE_INIT.
94 struct GNUNET_MessageHeader header;
97 * Options, see GNUNET_CORE_OPTION_ values.
99 uint32_t options GNUNET_PACKED;
105 * Message transmitted by the gnunet-service-core process
106 * to its clients in response to an INIT message.
108 struct InitReplyMessage
112 * Header with type #GNUNET_MESSAGE_TYPE_CORE_INIT_REPLY
114 struct GNUNET_MessageHeader header;
119 uint32_t reserved GNUNET_PACKED;
122 * Public key of the local peer.
124 struct GNUNET_PeerIdentity my_identity;
130 * Message sent by the service to clients to notify them
131 * about a peer connecting.
133 struct ConnectNotifyMessage
136 * Header with type #GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT
138 struct GNUNET_MessageHeader header;
143 uint32_t reserved GNUNET_PACKED;
146 * Identity of the connecting peer.
148 struct GNUNET_PeerIdentity peer;
154 * Message sent by the service to clients to notify them
155 * about a peer disconnecting.
157 struct DisconnectNotifyMessage
160 * Header with type #GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT.
162 struct GNUNET_MessageHeader header;
167 uint32_t reserved GNUNET_PACKED;
170 * Identity of the connecting peer.
172 struct GNUNET_PeerIdentity peer;
178 * Message sent by the service to clients to notify them about
179 * messages being received or transmitted. This overall message is
180 * followed by the real message, or just the header of the real
181 * message (depending on the client's preferences). The receiver can
182 * tell if he got the full message or only a partial message by
183 * looking at the size field in the header of NotifyTrafficMessage and
184 * checking it with the size field in the message that follows.
186 struct NotifyTrafficMessage
189 * Header with type #GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND
190 * or #GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND.
192 struct GNUNET_MessageHeader header;
195 * Identity of the receiver or sender.
197 struct GNUNET_PeerIdentity peer;
199 /* Followed by payload (message or just header), variable size */
204 * Client notifying core about the maximum-priority
205 * message it has in the queue for a particular target.
207 struct SendMessageRequest
210 * Header with type #GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST
212 struct GNUNET_MessageHeader header;
215 * How important is this message?
217 uint32_t priority GNUNET_PACKED;
220 * By what time would the sender really like to see this
221 * message transmitted?
223 struct GNUNET_TIME_AbsoluteNBO deadline;
226 * Identity of the intended target.
228 struct GNUNET_PeerIdentity peer;
233 uint32_t reserved GNUNET_PACKED;
236 * How large is the message?
238 uint16_t size GNUNET_PACKED;
241 * Counter for this peer to match SMRs to replies.
243 uint16_t smr_id GNUNET_PACKED;
249 * Core notifying client that it is allowed to now
250 * transmit a message to the given target
251 * (response to #GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST).
253 struct SendMessageReady
256 * Header with type #GNUNET_MESSAGE_TYPE_CORE_SEND_READY
258 struct GNUNET_MessageHeader header;
261 * How many bytes are allowed for transmission?
262 * Guaranteed to be at least as big as the requested size,
263 * or ZERO if the request is rejected (will timeout,
264 * peer disconnected, queue full, etc.).
266 uint16_t size GNUNET_PACKED;
269 * smr_id from the request.
271 uint16_t smr_id GNUNET_PACKED;
274 * Identity of the intended target.
276 struct GNUNET_PeerIdentity peer;
282 * Client asking core to transmit a particular message to a particular
283 * target (response to #GNUNET_MESSAGE_TYPE_CORE_SEND_READY).
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 intended receiver.
306 struct GNUNET_PeerIdentity peer;
309 * #GNUNET_YES if corking is allowed, #GNUNET_NO if not.
311 uint32_t cork GNUNET_PACKED;
316 uint32_t reserved GNUNET_PACKED;
322 * Message sent by the service to monitor clients to notify them
323 * about a peer changing status.
325 struct MonitorNotifyMessage
328 * Header with type #GNUNET_MESSAGE_TYPE_CORE_MONITOR_NOTIFY
330 struct GNUNET_MessageHeader header;
333 * New peer state, an `enum GNUNET_CORE_KxState` in NBO.
335 uint32_t state GNUNET_PACKED;
338 * Identity of the peer.
340 struct GNUNET_PeerIdentity peer;
343 * How long will we stay in this state (if nothing else happens)?
345 struct GNUNET_TIME_AbsoluteNBO timeout;
350 GNUNET_NETWORK_STRUCT_END