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