diff options
Diffstat (limited to 'src/service/core/core.h')
-rw-r--r-- | src/service/core/core.h | 326 |
1 files changed, 326 insertions, 0 deletions
diff --git a/src/service/core/core.h b/src/service/core/core.h new file mode 100644 index 000000000..d4596f038 --- /dev/null +++ b/src/service/core/core.h | |||
@@ -0,0 +1,326 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2009-2014 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero 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. | ||
9 | |||
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. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file core/core.h | ||
23 | * @brief common internal definitions for core service | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #ifndef CORE_H | ||
27 | #define CORE_H | ||
28 | |||
29 | #include "gnunet_util_lib.h" | ||
30 | #include "gnunet_time_lib.h" | ||
31 | |||
32 | /** | ||
33 | * General core debugging. | ||
34 | */ | ||
35 | #define DEBUG_CORE GNUNET_EXTRA_LOGGING | ||
36 | |||
37 | /** | ||
38 | * Definition of bits in the InitMessage's options field that specify | ||
39 | * which events this client cares about. Note that inbound messages | ||
40 | * for handlers that were specifically registered are always | ||
41 | * transmitted to the client. | ||
42 | */ | ||
43 | #define GNUNET_CORE_OPTION_NOTHING 0 | ||
44 | |||
45 | /** | ||
46 | * Client cares about connectivity changes. | ||
47 | */ | ||
48 | #define GNUNET_CORE_OPTION_SEND_STATUS_CHANGE 4 | ||
49 | |||
50 | /** | ||
51 | * Client wants all inbound messages in full. | ||
52 | */ | ||
53 | #define GNUNET_CORE_OPTION_SEND_FULL_INBOUND 8 | ||
54 | |||
55 | /** | ||
56 | * Client just wants the 4-byte message headers of | ||
57 | * all inbound messages. | ||
58 | */ | ||
59 | #define GNUNET_CORE_OPTION_SEND_HDR_INBOUND 16 | ||
60 | |||
61 | /** | ||
62 | * Client wants all outbound messages in full. | ||
63 | */ | ||
64 | #define GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND 32 | ||
65 | |||
66 | /** | ||
67 | * Client just wants the 4-byte message headers of | ||
68 | * all outbound messages. | ||
69 | */ | ||
70 | #define GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND 64 | ||
71 | |||
72 | |||
73 | GNUNET_NETWORK_STRUCT_BEGIN | ||
74 | |||
75 | /** | ||
76 | * Message transmitted core clients to gnunet-service-core | ||
77 | * to start the interaction. This header is followed by | ||
78 | * uint16_t type values specifying which messages this | ||
79 | * client is interested in. | ||
80 | */ | ||
81 | struct InitMessage | ||
82 | { | ||
83 | /** | ||
84 | * Header with type #GNUNET_MESSAGE_TYPE_CORE_INIT. | ||
85 | */ | ||
86 | struct GNUNET_MessageHeader header; | ||
87 | |||
88 | /** | ||
89 | * Options, see GNUNET_CORE_OPTION_ values. | ||
90 | */ | ||
91 | uint32_t options GNUNET_PACKED; | ||
92 | }; | ||
93 | |||
94 | |||
95 | /** | ||
96 | * Message transmitted by the gnunet-service-core process | ||
97 | * to its clients in response to an INIT message. | ||
98 | */ | ||
99 | struct InitReplyMessage | ||
100 | { | ||
101 | /** | ||
102 | * Header with type #GNUNET_MESSAGE_TYPE_CORE_INIT_REPLY | ||
103 | */ | ||
104 | struct GNUNET_MessageHeader header; | ||
105 | |||
106 | /** | ||
107 | * Always zero. | ||
108 | */ | ||
109 | uint32_t reserved GNUNET_PACKED; | ||
110 | |||
111 | /** | ||
112 | * Public key of the local peer. | ||
113 | */ | ||
114 | struct GNUNET_PeerIdentity my_identity; | ||
115 | }; | ||
116 | |||
117 | |||
118 | /** | ||
119 | * Message sent by the service to clients to notify them | ||
120 | * about a peer connecting. | ||
121 | */ | ||
122 | struct ConnectNotifyMessage | ||
123 | { | ||
124 | /** | ||
125 | * Header with type #GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT | ||
126 | */ | ||
127 | struct GNUNET_MessageHeader header; | ||
128 | |||
129 | /** | ||
130 | * Always zero. | ||
131 | */ | ||
132 | uint32_t reserved GNUNET_PACKED; | ||
133 | |||
134 | /** | ||
135 | * Identity of the connecting peer. | ||
136 | */ | ||
137 | struct GNUNET_PeerIdentity peer; | ||
138 | }; | ||
139 | |||
140 | |||
141 | /** | ||
142 | * Message sent by the service to clients to notify them | ||
143 | * about a peer disconnecting. | ||
144 | */ | ||
145 | struct DisconnectNotifyMessage | ||
146 | { | ||
147 | /** | ||
148 | * Header with type #GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT. | ||
149 | */ | ||
150 | struct GNUNET_MessageHeader header; | ||
151 | |||
152 | /** | ||
153 | * Always zero. | ||
154 | */ | ||
155 | uint32_t reserved GNUNET_PACKED; | ||
156 | |||
157 | /** | ||
158 | * Identity of the connecting peer. | ||
159 | */ | ||
160 | struct GNUNET_PeerIdentity peer; | ||
161 | }; | ||
162 | |||
163 | |||
164 | /** | ||
165 | * Message sent by the service to clients to notify them about | ||
166 | * messages being received or transmitted. This overall message is | ||
167 | * followed by the real message, or just the header of the real | ||
168 | * message (depending on the client's preferences). The receiver can | ||
169 | * tell if it got the full message or only a partial message by | ||
170 | * looking at the size field in the header of NotifyTrafficMessage and | ||
171 | * checking it with the size field in the message that follows. | ||
172 | */ | ||
173 | struct NotifyTrafficMessage | ||
174 | { | ||
175 | /** | ||
176 | * Header with type #GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND | ||
177 | * or #GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND. | ||
178 | */ | ||
179 | struct GNUNET_MessageHeader header; | ||
180 | |||
181 | /** | ||
182 | * Identity of the receiver or sender. | ||
183 | */ | ||
184 | struct GNUNET_PeerIdentity peer; | ||
185 | |||
186 | /* Followed by payload (message or just header), variable size */ | ||
187 | }; | ||
188 | |||
189 | |||
190 | /** | ||
191 | * Client notifying core about the maximum-priority | ||
192 | * message it has in the queue for a particular target. | ||
193 | */ | ||
194 | struct SendMessageRequest | ||
195 | { | ||
196 | /** | ||
197 | * Header with type #GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST | ||
198 | */ | ||
199 | struct GNUNET_MessageHeader header; | ||
200 | |||
201 | /** | ||
202 | * How important is this message? | ||
203 | */ | ||
204 | uint32_t priority GNUNET_PACKED; | ||
205 | |||
206 | /** | ||
207 | * By what time would the sender really like to see this | ||
208 | * message transmitted? | ||
209 | */ | ||
210 | struct GNUNET_TIME_AbsoluteNBO deadline; | ||
211 | |||
212 | /** | ||
213 | * Identity of the intended target. | ||
214 | */ | ||
215 | struct GNUNET_PeerIdentity peer; | ||
216 | |||
217 | /** | ||
218 | * Always zero. | ||
219 | */ | ||
220 | uint32_t reserved GNUNET_PACKED; | ||
221 | |||
222 | /** | ||
223 | * How large is the message? | ||
224 | */ | ||
225 | uint16_t size GNUNET_PACKED; | ||
226 | |||
227 | /** | ||
228 | * Counter for this peer to match SMRs to replies. | ||
229 | */ | ||
230 | uint16_t smr_id GNUNET_PACKED; | ||
231 | }; | ||
232 | |||
233 | |||
234 | /** | ||
235 | * Core notifying client that it is allowed to now | ||
236 | * transmit a message to the given target | ||
237 | * (response to #GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST). | ||
238 | */ | ||
239 | struct SendMessageReady | ||
240 | { | ||
241 | /** | ||
242 | * Header with type #GNUNET_MESSAGE_TYPE_CORE_SEND_READY | ||
243 | */ | ||
244 | struct GNUNET_MessageHeader header; | ||
245 | |||
246 | /** | ||
247 | * How many bytes are allowed for transmission? | ||
248 | * Guaranteed to be at least as big as the requested size, | ||
249 | * or ZERO if the request is rejected (will timeout, | ||
250 | * peer disconnected, queue full, etc.). | ||
251 | */ | ||
252 | uint16_t size GNUNET_PACKED; | ||
253 | |||
254 | /** | ||
255 | * smr_id from the request. | ||
256 | */ | ||
257 | uint16_t smr_id GNUNET_PACKED; | ||
258 | |||
259 | /** | ||
260 | * Identity of the intended target. | ||
261 | */ | ||
262 | struct GNUNET_PeerIdentity peer; | ||
263 | }; | ||
264 | |||
265 | |||
266 | /** | ||
267 | * Client asking core to transmit a particular message to a particular | ||
268 | * target (response to #GNUNET_MESSAGE_TYPE_CORE_SEND_READY). | ||
269 | */ | ||
270 | struct SendMessage | ||
271 | { | ||
272 | /** | ||
273 | * Header with type #GNUNET_MESSAGE_TYPE_CORE_SEND | ||
274 | */ | ||
275 | struct GNUNET_MessageHeader header; | ||
276 | |||
277 | /** | ||
278 | * How important is this message? Contains a | ||
279 | * `enum GNUNET_MQ_PriorityPreferences` in NBO. | ||
280 | */ | ||
281 | uint32_t priority GNUNET_PACKED; | ||
282 | |||
283 | /** | ||
284 | * By what time would the sender really like to see this | ||
285 | * message transmitted? | ||
286 | */ | ||
287 | struct GNUNET_TIME_AbsoluteNBO deadline; | ||
288 | |||
289 | /** | ||
290 | * Identity of the intended receiver. | ||
291 | */ | ||
292 | struct GNUNET_PeerIdentity peer; | ||
293 | }; | ||
294 | |||
295 | |||
296 | /** | ||
297 | * Message sent by the service to monitor clients to notify them | ||
298 | * about a peer changing status. | ||
299 | */ | ||
300 | struct MonitorNotifyMessage | ||
301 | { | ||
302 | /** | ||
303 | * Header with type #GNUNET_MESSAGE_TYPE_CORE_MONITOR_NOTIFY | ||
304 | */ | ||
305 | struct GNUNET_MessageHeader header; | ||
306 | |||
307 | /** | ||
308 | * New peer state, an `enum GNUNET_CORE_KxState` in NBO. | ||
309 | */ | ||
310 | uint32_t state GNUNET_PACKED; | ||
311 | |||
312 | /** | ||
313 | * Identity of the peer. | ||
314 | */ | ||
315 | struct GNUNET_PeerIdentity peer; | ||
316 | |||
317 | /** | ||
318 | * How long will we stay in this state (if nothing else happens)? | ||
319 | */ | ||
320 | struct GNUNET_TIME_AbsoluteNBO timeout; | ||
321 | }; | ||
322 | |||
323 | |||
324 | GNUNET_NETWORK_STRUCT_END | ||
325 | #endif | ||
326 | /* end of core.h */ | ||