497d67683cfd8a9c652bede835ebe76a57a695cc
[oweals/gnunet.git] / src / multicast / multicast.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2012, 2013 Christian Grothoff (and other contributing authors)
4
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.
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      General Public License for more details.
14
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.
19 */
20
21 /**
22  * @file multicast/multicast.h
23  * @brief multicast IPC messages
24  * @author Christian Grothoff
25  * @author Gabor X Toth
26  */
27 #ifndef MULTICAST_H
28 #define MULTICAST_H
29
30 #include "platform.h"
31 #include "gnunet_multicast_service.h"
32
33 GNUNET_NETWORK_STRUCT_BEGIN
34
35
36 /**
37  * Header of a join request sent to the origin or another member.
38  */
39 struct MulticastJoinRequestMessage
40 {
41   /**
42    * Type: GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_REQUEST
43    */
44   struct GNUNET_MessageHeader header;
45
46   /**
47    * Always zero.
48    */
49   uint32_t reserved;
50
51   /**
52    * ECC signature of the rest of the fields of the join request.
53    *
54    * Signature must match the public key of the joining member.
55    */
56   struct GNUNET_CRYPTO_EcdsaSignature signature;
57
58   /**
59    * Purpose for the signature and size of the signed data.
60    */
61   struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
62
63   /**
64    * Public key of the target group.
65    */
66   struct GNUNET_CRYPTO_EddsaPublicKey group_key;
67
68   /**
69    * Public key of the joining member.
70    */
71   struct GNUNET_CRYPTO_EcdsaPublicKey member_key;
72
73   /**
74    * Peer identity of the joining member.
75    */
76   struct GNUNET_PeerIdentity peer;
77
78   /* Followed by struct GNUNET_MessageHeader join_message */
79 };
80
81
82 /**
83  * Header of a join decision message sent to a peer requesting join.
84  */
85 struct MulticastJoinDecisionMessage
86 {
87   /**
88    * Type: GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_DECISION
89    */
90   struct GNUNET_MessageHeader header;
91
92   /**
93    * #GNUNET_YES    if the peer was admitted
94    * #GNUNET_NO     if entry was refused,
95    * #GNUNET_SYSERR if the request could not be answered.
96    */
97   int32_t is_admitted;
98
99   /**
100    * Number of relays given.
101    */
102   uint32_t relay_count;
103
104   /* Followed by relay_count peer identities */
105
106   /* Followed by the join response message */
107 };
108
109
110 /**
111  * Header added to a struct MulticastJoinDecisionMessage
112  * when sent between the client and service.
113  */
114 struct MulticastJoinDecisionMessageHeader
115 {
116   /**
117    * Type: GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_DECISION
118    */
119   struct GNUNET_MessageHeader header;
120
121   /**
122    * C->S: Peer to send the join decision to.
123    * S->C: Peer we received the join decision from.
124    */
125   struct GNUNET_PeerIdentity peer;
126
127   /**
128    * C->S: Public key of the member requesting join.
129    * S->C: Unused.
130    */
131   struct GNUNET_CRYPTO_EcdsaPublicKey member_key;
132
133   /* Followed by struct MulticastJoinDecisionMessage */
134 };
135
136
137 /**
138  * Message sent from the client to the service to notify the service
139  * about the result of a membership test.
140  */
141 struct MulticastMembershipTestResultMessage
142 {
143   /**
144    * Type: GNUNET_MESSAGE_TYPE_MULTICAST_MEMBERSHIP_TEST_RESULT
145    */
146   struct GNUNET_MessageHeader header;
147
148   /**
149    * Unique ID that identifies the associated membership test.
150    */
151   uint32_t uid;
152
153   /**
154    * #GNUNET_YES    if the peer is a member
155    * #GNUNET_NO     if peer is not a member,
156    * #GNUNET_SYSERR if the test could not be answered.
157    */
158   int32_t is_admitted;
159 };
160
161
162 /**
163  * Message sent from the client to the service OR the service to the
164  * client asking for a message fragment to be replayed.
165  */
166 struct MulticastReplayRequestMessage
167 {
168
169   /**
170    * The message type can be either
171    * #GNUNET_MESSAGE_TYPE_MULTICAST_REPLAY_REQUEST or
172    * #GNUNET_MESSAGE_TYPE_MULTICAST_REPLAY_REQUEST_CANCEL.
173    */
174   struct GNUNET_MessageHeader header;
175
176   /**
177    * S->C: Public key of the member requesting replay.
178    * C->S: Unused.
179    */
180   struct GNUNET_CRYPTO_EcdsaPublicKey member_key;
181
182   /**
183    * ID of the message that is being requested.
184    */
185   uint64_t fragment_id;
186
187   /**
188    * ID of the message that is being requested.
189    */
190   uint64_t message_id;
191
192   /**
193    * Offset of the fragment that is being requested.
194    */
195   uint64_t fragment_offset;
196
197   /**
198    * Additional flags for the request.
199    */
200   uint64_t flags;
201
202   /**
203    * Replay request ID.
204    */
205   uint32_t uid;
206 };
207
208
209 /**
210  * Message sent from the client to the service to give the service
211  * a replayed message.
212  */
213 struct MulticastReplayResponseMessage
214 {
215
216   /**
217    * Type: GNUNET_MESSAGE_TYPE_MULTICAST_REPLAY_RESPONSE
218    *    or GNUNET_MESSAGE_TYPE_MULTICAST_REPLAY_RESPONSE_END
219    */
220   struct GNUNET_MessageHeader header;
221
222   /**
223    * ID of the message that is being requested.
224    */
225   uint64_t fragment_id;
226
227   /**
228    * ID of the message that is being requested.
229    */
230   uint64_t message_id;
231
232   /**
233    * Offset of the fragment that is being requested.
234    */
235   uint64_t fragment_offset;
236
237   /**
238    * Additional flags for the request.
239    */
240   uint64_t flags;
241
242   /**
243    * An `enum GNUNET_MULTICAST_ReplayErrorCode` identifying issues (in NBO).
244    */
245   int32_t error_code;
246
247   /* followed by replayed message */
248 };
249
250
251 /**
252  * Message sent from the client to the service to notify the service
253  * about the starting of a multicast group with this peers as its origin.
254  */
255 struct MulticastOriginStartMessage
256 {
257   /**
258    * Type: GNUNET_MESSAGE_TYPE_MULTICAST_ORIGIN_START
259    */
260   struct GNUNET_MessageHeader header;
261
262   /**
263    * Always zero.
264    */
265   uint32_t reserved;
266
267   /**
268    * Private, non-ephemeral key for the multicast group.
269    */
270   struct GNUNET_CRYPTO_EddsaPrivateKey group_key;
271
272   /**
273    * Last fragment ID sent to the group, used to continue counting fragments if
274    * we resume operating * a group.
275    */
276   uint64_t max_fragment_id;
277
278 };
279
280
281 struct MulticastMemberJoinMessage
282 {
283   /**
284    * Type: GNUNET_MESSAGE_TYPE_MULTICAST_MEMBER_JOIN
285    */
286   struct GNUNET_MessageHeader header;
287
288   uint32_t relay_count GNUNET_PACKED;
289
290   struct GNUNET_CRYPTO_EddsaPublicKey group_key;
291
292   struct GNUNET_CRYPTO_EcdsaPrivateKey member_key;
293
294   struct GNUNET_PeerIdentity origin;
295
296   /* Followed by struct GNUNET_PeerIdentity relays[relay_count] */
297
298   /* Followed by struct GNUNET_MessageHeader join_msg */
299 };
300
301
302 #if NOT_USED
303 /**
304  * Message sent from the client to the service to broadcast to all group
305  * members.
306  */
307 struct MulticastBroadcastMessage
308 {
309
310   /**
311    *
312    */
313   struct GNUNET_MessageHeader header;
314
315   /**
316    * #GNUNET_OK normally, #GNUNET_SYSERR if the origin aborted the
317    * transmission.
318    */
319   int32_t status;
320
321   /**
322    * Message ID.
323    */
324   uint64_t message_id;
325
326   /**
327    * Group generation.
328    */
329   uint64_t group_generation;
330
331   /**
332    * Total message size.
333    */
334   uint64_t total_size;
335
336 };
337
338
339 /**
340  * Message sent from the client to the service to join a multicast group.
341  */
342 struct MulticastJoinMessage
343 {
344
345   /**
346    *
347    */
348   struct GNUNET_MessageHeader header;
349
350   /**
351    * Number of relays we (think) we already know about.
352    */
353   uint32_t relay_count;
354
355   /**
356    * Public non-ephemeral key of the mutlicast group.
357    */
358   struct GNUNET_CRYPTO_EddsaPublicKey group_key;
359
360   /**
361    * Our private key for the group.
362    */
363   struct GNUNET_CRYPTO_EcdsaPrivateKey member_key;
364
365   /* followed by 'relay_count' `struct GNUNET_PeerIdentity`s */
366
367 };
368
369
370
371 /**
372  * Message sent from the client to the service to unicast to the group origin.
373  */
374 struct MulticastUnicastToOriginMessage
375 {
376
377   /**
378    *
379    */
380   struct GNUNET_MessageHeader header;
381
382   /**
383    * Reserved (always 0).
384    */
385   uint32_t reserved;
386
387   /**
388    * Message ID.
389    */
390   uint64_t message_id;
391
392   /**
393    * Total message size.
394    */
395   uint64_t total_size;
396
397   /* followed by payload */
398
399 };
400
401
402 /**
403  * Message sent from the client to the service to
404  * cancel unicast to the group origin.
405  */
406 struct MulticastUnicastToOriginCancelMessage
407 {
408
409   /**
410    *
411    */
412   struct GNUNET_MessageHeader header;
413
414   /**
415    * Reserved (always 0).
416    */
417   uint32_t reserved;
418
419   /**
420    * Message ID.
421    */
422   uint64_t message_id;
423
424 };
425 #endif // NOT_USED
426
427 GNUNET_NETWORK_STRUCT_END
428
429 #endif
430 /* end of multicast.h */