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
53 GNUNET_NETWORK_STRUCT_BEGIN
56 * Message transmitted core clients to gnunet-service-core
57 * to start the interaction. This header is followed by
58 * uint16_t type values specifying which messages this
59 * client is interested in.
65 * Header with type GNUNET_MESSAGE_TYPE_CORE_INIT.
67 struct GNUNET_MessageHeader header;
70 * Options, see GNUNET_CORE_OPTION_ values.
72 uint32_t options GNUNET_PACKED;
78 * Message transmitted by the gnunet-service-core process
79 * to its clients in response to an INIT message.
81 struct InitReplyMessage
85 * Header with type GNUNET_MESSAGE_TYPE_CORE_INIT_REPLY
87 struct GNUNET_MessageHeader header;
92 uint32_t reserved GNUNET_PACKED;
95 * Public key of the local peer.
97 struct GNUNET_PeerIdentity my_identity;
103 * Message sent by the service to clients to notify them
104 * about a peer connecting.
106 struct ConnectNotifyMessage
109 * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT
111 struct GNUNET_MessageHeader header;
114 * Identity of the connecting peer.
116 struct GNUNET_PeerIdentity peer;
122 * Message sent by the service to clients to notify them
123 * about a peer disconnecting.
125 struct DisconnectNotifyMessage
128 * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT.
130 struct GNUNET_MessageHeader header;
135 uint32_t reserved GNUNET_PACKED;
138 * Identity of the connecting peer.
140 struct GNUNET_PeerIdentity peer;
146 * Message sent by the service to clients to notify them about
147 * messages being received or transmitted. This overall message is
148 * followed by the real message, or just the header of the real
149 * message (depending on the client's preferences). The receiver can
150 * tell if he got the full message or only a partial message by
151 * looking at the size field in the header of NotifyTrafficMessage and
152 * checking it with the size field in the message that follows.
154 struct NotifyTrafficMessage
157 * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND
158 * or GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND.
160 struct GNUNET_MessageHeader header;
163 * Identity of the receiver or sender.
165 struct GNUNET_PeerIdentity peer;
167 /* Followed by payload (message or just header), variable size */
172 * Client notifying core about the maximum-priority
173 * message it has in the queue for a particular target.
175 struct SendMessageRequest
178 * Header with type GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST
180 struct GNUNET_MessageHeader header;
183 * How important is this message?
185 uint32_t priority GNUNET_PACKED;
188 * By what time would the sender really like to see this
189 * message transmitted?
191 struct GNUNET_TIME_AbsoluteNBO deadline;
194 * Identity of the intended target.
196 struct GNUNET_PeerIdentity peer;
201 uint32_t reserved GNUNET_PACKED;
204 * How large is the message?
206 uint16_t size GNUNET_PACKED;
209 * Counter for this peer to match SMRs to replies.
211 uint16_t smr_id GNUNET_PACKED;
217 * Core notifying client that it is allowed to now
218 * transmit a message to the given target
219 * (response to GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST).
221 struct SendMessageReady
224 * Header with type GNUNET_MESSAGE_TYPE_CORE_SEND_READY
226 struct GNUNET_MessageHeader header;
229 * How many bytes are allowed for transmission?
230 * Guaranteed to be at least as big as the requested size,
231 * or ZERO if the request is rejected (will timeout,
232 * peer disconnected, queue full, etc.).
234 uint16_t size GNUNET_PACKED;
237 * smr_id from the request.
239 uint16_t smr_id GNUNET_PACKED;
242 * Identity of the intended target.
244 struct GNUNET_PeerIdentity peer;
250 * Client asking core to transmit a particular message to a particular
251 * target (response to GNUNET_MESSAGE_TYPE_CORE_SEND_READY).
256 * Header with type GNUNET_MESSAGE_TYPE_CORE_SEND
258 struct GNUNET_MessageHeader header;
261 * How important is this message?
263 uint32_t priority GNUNET_PACKED;
266 * By what time would the sender really like to see this
267 * message transmitted?
269 struct GNUNET_TIME_AbsoluteNBO deadline;
272 * Identity of the intended receiver.
274 struct GNUNET_PeerIdentity peer;
277 * GNUNET_YES if corking is allowed, GNUNET_NO if not.
279 uint32_t cork GNUNET_PACKED;
284 uint64_t reserved GNUNET_PACKED;
289 GNUNET_NETWORK_STRUCT_END