d9f5372a1b4d1c77ebfef0b72b8b768013807624
[oweals/gnunet.git] / src / multicast / multicast.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2012, 2013 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
16 /**
17  * @file multicast/multicast.h
18  * @brief multicast IPC messages
19  * @author Christian Grothoff
20  * @author Gabor X Toth
21  */
22 #ifndef MULTICAST_H
23 #define MULTICAST_H
24
25 #include "platform.h"
26 #include "gnunet_multicast_service.h"
27
28 GNUNET_NETWORK_STRUCT_BEGIN
29
30
31 /**
32  * Header of a join request sent to the origin or another member.
33  */
34 struct MulticastJoinRequestMessage
35 {
36   /**
37    * Type: GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_REQUEST
38    */
39   struct GNUNET_MessageHeader header;
40
41   /**
42    * Always zero.
43    */
44   uint32_t reserved;
45
46   /**
47    * ECC signature of the rest of the fields of the join request.
48    *
49    * Signature must match the public key of the joining member.
50    */
51   struct GNUNET_CRYPTO_EcdsaSignature signature;
52
53   /**
54    * Purpose for the signature and size of the signed data.
55    */
56   struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
57
58   /**
59    * Public key of the target group.
60    */
61   struct GNUNET_CRYPTO_EddsaPublicKey group_pub_key;
62
63   /**
64    * Public key of the joining member.
65    */
66   struct GNUNET_CRYPTO_EcdsaPublicKey member_pub_key;
67
68   /**
69    * Peer identity of the joining member.
70    */
71   struct GNUNET_PeerIdentity peer;
72
73   /* Followed by struct GNUNET_MessageHeader join_message */
74 };
75
76
77 /**
78  * Header of a join decision message sent to a peer requesting join.
79  */
80 struct MulticastJoinDecisionMessage
81 {
82   /**
83    * Type: GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_DECISION
84    */
85   struct GNUNET_MessageHeader header;
86
87   /**
88    * #GNUNET_YES    if the peer was admitted
89    * #GNUNET_NO     if entry was refused,
90    * #GNUNET_SYSERR if the request could not be answered.
91    */
92   int32_t is_admitted;
93
94   /**
95    * Number of relays given.
96    */
97   uint32_t relay_count;
98
99   /* Followed by relay_count peer identities */
100
101   /* Followed by the join response message */
102 };
103
104
105 /**
106  * Header added to a struct MulticastJoinDecisionMessage
107  * when sent between the client and service.
108  */
109 struct MulticastJoinDecisionMessageHeader
110 {
111   /**
112    * Type: GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_DECISION
113    */
114   struct GNUNET_MessageHeader header;
115
116   /**
117    * C->S: Peer to send the join decision to.
118    * S->C: Peer we received the join decision from.
119    */
120   struct GNUNET_PeerIdentity peer;
121
122   /**
123    * C->S: Public key of the member requesting join.
124    * S->C: Unused.
125    */
126   struct GNUNET_CRYPTO_EcdsaPublicKey member_pub_key;
127
128   /* Followed by struct MulticastJoinDecisionMessage */
129 };
130
131
132 /**
133  * Message sent from the client to the service to notify the service
134  * about the result of a membership test.
135  */
136 struct MulticastMembershipTestResultMessage
137 {
138   /**
139    * Type: GNUNET_MESSAGE_TYPE_MULTICAST_MEMBERSHIP_TEST_RESULT
140    */
141   struct GNUNET_MessageHeader header;
142
143   /**
144    * Unique ID that identifies the associated membership test.
145    */
146   uint32_t uid;
147
148   /**
149    * #GNUNET_YES    if the peer is a member
150    * #GNUNET_NO     if peer is not a member,
151    * #GNUNET_SYSERR if the test could not be answered.
152    */
153   int32_t is_admitted;
154 };
155
156
157 /**
158  * Message sent from the client to the service OR the service to the
159  * client asking for a message fragment to be replayed.
160  */
161 struct MulticastReplayRequestMessage
162 {
163
164   /**
165    * The message type should be
166    * #GNUNET_MESSAGE_TYPE_MULTICAST_REPLAY_REQUEST.
167    */
168   struct GNUNET_MessageHeader header;
169
170   /**
171    * S->C: Public key of the member requesting replay.
172    * C->S: Unused.
173    */
174   struct GNUNET_CRYPTO_EcdsaPublicKey member_pub_key;
175
176   /**
177    * ID of the message that is being requested.
178    */
179   uint64_t fragment_id;
180
181   /**
182    * ID of the message that is being requested.
183    */
184   uint64_t message_id;
185
186   /**
187    * Offset of the fragment that is being requested.
188    */
189   uint64_t fragment_offset;
190
191   /**
192    * Additional flags for the request.
193    */
194   uint64_t flags;
195
196   /**
197    * Replay request ID.
198    */
199   uint32_t uid;
200 };
201
202
203 /**
204  * Message sent from the client to the service to give the service
205  * a replayed message.
206  */
207 struct MulticastReplayResponseMessage
208 {
209
210   /**
211    * Type: GNUNET_MESSAGE_TYPE_MULTICAST_REPLAY_RESPONSE
212    *    or GNUNET_MESSAGE_TYPE_MULTICAST_REPLAY_RESPONSE_END
213    */
214   struct GNUNET_MessageHeader header;
215
216   /**
217    * ID of the message that is being requested.
218    */
219   uint64_t fragment_id;
220
221   /**
222    * ID of the message that is being requested.
223    */
224   uint64_t message_id;
225
226   /**
227    * Offset of the fragment that is being requested.
228    */
229   uint64_t fragment_offset;
230
231   /**
232    * Additional flags for the request.
233    */
234   uint64_t flags;
235
236   /**
237    * An `enum GNUNET_MULTICAST_ReplayErrorCode` identifying issues (in NBO).
238    */
239   int32_t error_code;
240
241   /* followed by replayed message */
242 };
243
244
245 /**
246  * Message sent from the client to the service to notify the service
247  * about the starting of a multicast group with this peers as its origin.
248  */
249 struct MulticastOriginStartMessage
250 {
251   /**
252    * Type: GNUNET_MESSAGE_TYPE_MULTICAST_ORIGIN_START
253    */
254   struct GNUNET_MessageHeader header;
255
256   /**
257    * Always zero.
258    */
259   uint32_t reserved;
260
261   /**
262    * Private, non-ephemeral key for the multicast group.
263    */
264   struct GNUNET_CRYPTO_EddsaPrivateKey group_key;
265
266   /**
267    * Last fragment ID sent to the group, used to continue counting fragments if
268    * we resume operating * a group.
269    */
270   uint64_t max_fragment_id;
271 };
272
273
274 struct MulticastMemberJoinMessage
275 {
276   /**
277    * Type: GNUNET_MESSAGE_TYPE_MULTICAST_MEMBER_JOIN
278    */
279   struct GNUNET_MessageHeader header;
280
281   uint32_t relay_count GNUNET_PACKED;
282
283   struct GNUNET_CRYPTO_EddsaPublicKey group_pub_key;
284
285   struct GNUNET_CRYPTO_EcdsaPrivateKey member_key;
286
287   struct GNUNET_PeerIdentity origin;
288
289   /* Followed by struct GNUNET_PeerIdentity relays[relay_count] */
290
291   /* Followed by struct GNUNET_MessageHeader join_msg */
292 };
293
294
295 GNUNET_NETWORK_STRUCT_END
296
297 #endif
298 /* end of multicast.h */