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 it
6 under the terms of the GNU General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your 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 Affero General Public License for more details.
18 * @brief common internal definitions for core service
19 * @author Christian Grothoff
24 #include "gnunet_bandwidth_lib.h"
25 #include "gnunet_transport_service.h"
26 #include "gnunet_crypto_lib.h"
27 #include "gnunet_time_lib.h"
30 * General core debugging.
32 #define DEBUG_CORE GNUNET_EXTRA_LOGGING
35 * Definition of bits in the InitMessage's options field that specify
36 * which events this client cares about. Note that inbound messages
37 * for handlers that were specifically registered are always
38 * transmitted to the client.
40 #define GNUNET_CORE_OPTION_NOTHING 0
43 * Client cares about connectivity changes.
45 #define GNUNET_CORE_OPTION_SEND_STATUS_CHANGE 4
48 * Client wants all inbound messages in full.
50 #define GNUNET_CORE_OPTION_SEND_FULL_INBOUND 8
53 * Client just wants the 4-byte message headers of
54 * all inbound messages.
56 #define GNUNET_CORE_OPTION_SEND_HDR_INBOUND 16
59 * Client wants all outbound messages in full.
61 #define GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND 32
64 * Client just wants the 4-byte message headers of
65 * all outbound messages.
67 #define GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND 64
70 GNUNET_NETWORK_STRUCT_BEGIN
73 * Message transmitted core clients to gnunet-service-core
74 * to start the interaction. This header is followed by
75 * uint16_t type values specifying which messages this
76 * client is interested in.
82 * Header with type #GNUNET_MESSAGE_TYPE_CORE_INIT.
84 struct GNUNET_MessageHeader header;
87 * Options, see GNUNET_CORE_OPTION_ values.
89 uint32_t options GNUNET_PACKED;
95 * Message transmitted by the gnunet-service-core process
96 * to its clients in response to an INIT message.
98 struct InitReplyMessage
102 * Header with type #GNUNET_MESSAGE_TYPE_CORE_INIT_REPLY
104 struct GNUNET_MessageHeader header;
109 uint32_t reserved GNUNET_PACKED;
112 * Public key of the local peer.
114 struct GNUNET_PeerIdentity my_identity;
120 * Message sent by the service to clients to notify them
121 * about a peer connecting.
123 struct ConnectNotifyMessage
126 * Header with type #GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT
128 struct GNUNET_MessageHeader header;
133 uint32_t reserved GNUNET_PACKED;
136 * Identity of the connecting peer.
138 struct GNUNET_PeerIdentity peer;
144 * Message sent by the service to clients to notify them
145 * about a peer disconnecting.
147 struct DisconnectNotifyMessage
150 * Header with type #GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT.
152 struct GNUNET_MessageHeader header;
157 uint32_t reserved GNUNET_PACKED;
160 * Identity of the connecting peer.
162 struct GNUNET_PeerIdentity peer;
168 * Message sent by the service to clients to notify them about
169 * messages being received or transmitted. This overall message is
170 * followed by the real message, or just the header of the real
171 * message (depending on the client's preferences). The receiver can
172 * tell if he got the full message or only a partial message by
173 * looking at the size field in the header of NotifyTrafficMessage and
174 * checking it with the size field in the message that follows.
176 struct NotifyTrafficMessage
179 * Header with type #GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND
180 * or #GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND.
182 struct GNUNET_MessageHeader header;
185 * Identity of the receiver or sender.
187 struct GNUNET_PeerIdentity peer;
189 /* Followed by payload (message or just header), variable size */
194 * Client notifying core about the maximum-priority
195 * message it has in the queue for a particular target.
197 struct SendMessageRequest
200 * Header with type #GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST
202 struct GNUNET_MessageHeader header;
205 * How important is this message?
207 uint32_t priority GNUNET_PACKED;
210 * By what time would the sender really like to see this
211 * message transmitted?
213 struct GNUNET_TIME_AbsoluteNBO deadline;
216 * Identity of the intended target.
218 struct GNUNET_PeerIdentity peer;
223 uint32_t reserved GNUNET_PACKED;
226 * How large is the message?
228 uint16_t size GNUNET_PACKED;
231 * Counter for this peer to match SMRs to replies.
233 uint16_t smr_id GNUNET_PACKED;
239 * Core notifying client that it is allowed to now
240 * transmit a message to the given target
241 * (response to #GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST).
243 struct SendMessageReady
246 * Header with type #GNUNET_MESSAGE_TYPE_CORE_SEND_READY
248 struct GNUNET_MessageHeader header;
251 * How many bytes are allowed for transmission?
252 * Guaranteed to be at least as big as the requested size,
253 * or ZERO if the request is rejected (will timeout,
254 * peer disconnected, queue full, etc.).
256 uint16_t size GNUNET_PACKED;
259 * smr_id from the request.
261 uint16_t smr_id GNUNET_PACKED;
264 * Identity of the intended target.
266 struct GNUNET_PeerIdentity peer;
272 * Client asking core to transmit a particular message to a particular
273 * target (response to #GNUNET_MESSAGE_TYPE_CORE_SEND_READY).
278 * Header with type #GNUNET_MESSAGE_TYPE_CORE_SEND
280 struct GNUNET_MessageHeader header;
283 * How important is this message?
285 uint32_t priority GNUNET_PACKED;
288 * By what time would the sender really like to see this
289 * message transmitted?
291 struct GNUNET_TIME_AbsoluteNBO deadline;
294 * Identity of the intended receiver.
296 struct GNUNET_PeerIdentity peer;
299 * #GNUNET_YES if corking is allowed, #GNUNET_NO if not.
301 uint32_t cork GNUNET_PACKED;
306 uint32_t reserved GNUNET_PACKED;
312 * Message sent by the service to monitor clients to notify them
313 * about a peer changing status.
315 struct MonitorNotifyMessage
318 * Header with type #GNUNET_MESSAGE_TYPE_CORE_MONITOR_NOTIFY
320 struct GNUNET_MessageHeader header;
323 * New peer state, an `enum GNUNET_CORE_KxState` in NBO.
325 uint32_t state GNUNET_PACKED;
328 * Identity of the peer.
330 struct GNUNET_PeerIdentity peer;
333 * How long will we stay in this state (if nothing else happens)?
335 struct GNUNET_TIME_AbsoluteNBO timeout;
340 GNUNET_NETWORK_STRUCT_END