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