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 * Client cares about connectivity changes.
50 #define GNUNET_CORE_OPTION_SEND_STATUS_CHANGE 4
53 * Client wants all inbound messages in full.
55 #define GNUNET_CORE_OPTION_SEND_FULL_INBOUND 8
58 * Client just wants the 4-byte message headers of
59 * all inbound messages.
61 #define GNUNET_CORE_OPTION_SEND_HDR_INBOUND 16
64 * Client wants all outbound messages in full.
66 #define GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND 32
69 * Client just wants the 4-byte message headers of
70 * all outbound messages.
72 #define GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND 64
75 GNUNET_NETWORK_STRUCT_BEGIN
78 * Message transmitted core clients to gnunet-service-core
79 * to start the interaction. This header is followed by
80 * uint16_t type values specifying which messages this
81 * client is interested in.
87 * Header with type #GNUNET_MESSAGE_TYPE_CORE_INIT.
89 struct GNUNET_MessageHeader header;
92 * Options, see GNUNET_CORE_OPTION_ values.
94 uint32_t options GNUNET_PACKED;
100 * Message transmitted by the gnunet-service-core process
101 * to its clients in response to an INIT message.
103 struct InitReplyMessage
107 * Header with type #GNUNET_MESSAGE_TYPE_CORE_INIT_REPLY
109 struct GNUNET_MessageHeader header;
114 uint32_t reserved GNUNET_PACKED;
117 * Public key of the local peer.
119 struct GNUNET_PeerIdentity my_identity;
125 * Message sent by the service to clients to notify them
126 * about a peer connecting.
128 struct ConnectNotifyMessage
131 * Header with type #GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT
133 struct GNUNET_MessageHeader header;
138 uint32_t reserved GNUNET_PACKED;
141 * Identity of the connecting peer.
143 struct GNUNET_PeerIdentity peer;
149 * Message sent by the service to clients to notify them
150 * about a peer disconnecting.
152 struct DisconnectNotifyMessage
155 * Header with type #GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT.
157 struct GNUNET_MessageHeader header;
162 uint32_t reserved GNUNET_PACKED;
165 * Identity of the connecting peer.
167 struct GNUNET_PeerIdentity peer;
173 * Message sent by the service to clients to notify them about
174 * messages being received or transmitted. This overall message is
175 * followed by the real message, or just the header of the real
176 * message (depending on the client's preferences). The receiver can
177 * tell if he got the full message or only a partial message by
178 * looking at the size field in the header of NotifyTrafficMessage and
179 * checking it with the size field in the message that follows.
181 struct NotifyTrafficMessage
184 * Header with type #GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND
185 * or #GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND.
187 struct GNUNET_MessageHeader header;
190 * Identity of the receiver or sender.
192 struct GNUNET_PeerIdentity peer;
194 /* Followed by payload (message or just header), variable size */
199 * Client notifying core about the maximum-priority
200 * message it has in the queue for a particular target.
202 struct SendMessageRequest
205 * Header with type #GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST
207 struct GNUNET_MessageHeader header;
210 * How important is this message?
212 uint32_t priority GNUNET_PACKED;
215 * By what time would the sender really like to see this
216 * message transmitted?
218 struct GNUNET_TIME_AbsoluteNBO deadline;
221 * Identity of the intended target.
223 struct GNUNET_PeerIdentity peer;
228 uint32_t reserved GNUNET_PACKED;
231 * How large is the message?
233 uint16_t size GNUNET_PACKED;
236 * Counter for this peer to match SMRs to replies.
238 uint16_t smr_id GNUNET_PACKED;
244 * Core notifying client that it is allowed to now
245 * transmit a message to the given target
246 * (response to #GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST).
248 struct SendMessageReady
251 * Header with type #GNUNET_MESSAGE_TYPE_CORE_SEND_READY
253 struct GNUNET_MessageHeader header;
256 * How many bytes are allowed for transmission?
257 * Guaranteed to be at least as big as the requested size,
258 * or ZERO if the request is rejected (will timeout,
259 * peer disconnected, queue full, etc.).
261 uint16_t size GNUNET_PACKED;
264 * smr_id from the request.
266 uint16_t smr_id GNUNET_PACKED;
269 * Identity of the intended target.
271 struct GNUNET_PeerIdentity peer;
277 * Client asking core to transmit a particular message to a particular
278 * target (response to #GNUNET_MESSAGE_TYPE_CORE_SEND_READY).
283 * Header with type #GNUNET_MESSAGE_TYPE_CORE_SEND
285 struct GNUNET_MessageHeader header;
288 * How important is this message?
290 uint32_t priority GNUNET_PACKED;
293 * By what time would the sender really like to see this
294 * message transmitted?
296 struct GNUNET_TIME_AbsoluteNBO deadline;
299 * Identity of the intended receiver.
301 struct GNUNET_PeerIdentity peer;
304 * #GNUNET_YES if corking is allowed, #GNUNET_NO if not.
306 uint32_t cork GNUNET_PACKED;
311 uint32_t reserved GNUNET_PACKED;
317 * Message sent by the service to monitor clients to notify them
318 * about a peer changing status.
320 struct MonitorNotifyMessage
323 * Header with type #GNUNET_MESSAGE_TYPE_CORE_MONITOR_NOTIFY
325 struct GNUNET_MessageHeader header;
328 * New peer state, an `enum GNUNET_CORE_KxState` in NBO.
330 uint32_t state GNUNET_PACKED;
333 * Identity of the peer.
335 struct GNUNET_PeerIdentity peer;
338 * How long will we stay in this state (if nothing else happens)?
340 struct GNUNET_TIME_AbsoluteNBO timeout;
345 GNUNET_NETWORK_STRUCT_END