uncrustify as demanded.
[oweals/gnunet.git] / src / conversation / conversation.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2013-2016 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 conversation/conversation.h
23  * @brief constants for network protocols
24  * @author Siomon Dieterle
25  * @author Andreas Fuchs
26  */
27 #ifndef CONVERSATION_H
28 #define CONVERSATION_H
29
30 #ifdef __cplusplus
31 extern "C"
32 {
33 #if 0                           /* keep Emacsens' auto-indent happy */
34 }
35 #endif
36 #endif
37
38
39 #define MAX_TRANSMIT_DELAY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 60)
40
41
42 /**
43  * Highest bit in a 32-bit unsigned integer,
44  * bit set if we are making an outgoing call,
45  * bit unset for local lines.
46  */
47 #define HIGH_BIT ((uint32_t)(1LL << 31))
48
49 GNUNET_NETWORK_STRUCT_BEGIN
50
51
52 /**
53  * Message to transmit the audio (between client and helpers).
54  */
55 struct AudioMessage {
56   /**
57    * Type is #GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO
58    */
59   struct GNUNET_MessageHeader header;
60
61   /* followed by audio data */
62 };
63
64
65 /**
66  * Client -> Service message to register a phone.
67  */
68 struct ClientPhoneRegisterMessage {
69   /**
70    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_REGISTER
71    */
72   struct GNUNET_MessageHeader header;
73
74   /**
75    * Always zero.
76    */
77   uint32_t reserved GNUNET_PACKED;
78
79   /**
80    * Phone line / CADET port to register.
81    */
82   struct GNUNET_HashCode line_port;
83 };
84
85
86 /**
87  * Service -> Client message for phone is ringing.
88  */
89 struct ClientPhoneRingMessage {
90   /**
91    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RING
92    */
93   struct GNUNET_MessageHeader header;
94
95   /**
96    * CID, internal caller ID number used in the future to identify
97    * which active call we are talking about.
98    */
99   uint32_t cid GNUNET_PACKED;
100
101   /**
102    * Who is calling us?
103    */
104   struct GNUNET_CRYPTO_EcdsaPublicKey caller_id;
105 };
106
107
108 /**
109  * Service <-> Client message for phone was suspended.
110  */
111 struct ClientPhoneSuspendMessage {
112   /**
113    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND
114    */
115   struct GNUNET_MessageHeader header;
116
117   /**
118    * CID, internal caller ID to identify which active call we are
119    * talking about.
120    */
121   uint32_t cid GNUNET_PACKED;
122 };
123
124
125 /**
126  * Service <-> Client message for phone was resumed.
127  */
128 struct ClientPhoneResumeMessage {
129   /**
130    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME
131    */
132   struct GNUNET_MessageHeader header;
133
134   /**
135    * CID, internal caller ID to identify which active call we are
136    * talking about.
137    */
138   uint32_t cid GNUNET_PACKED;
139 };
140
141
142 /**
143  * Client -> Service pick up phone that is ringing.
144  */
145 struct ClientPhonePickupMessage {
146   /**
147    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICK_UP
148    */
149   struct GNUNET_MessageHeader header;
150
151   /**
152    * CID, internal caller ID to identify which active call we are
153    * talking about.
154    */
155   uint32_t cid GNUNET_PACKED;
156 };
157
158
159 /**
160  * Client <-> Service hang up phone that may or may not be ringing.
161  * Also sent in response to a (failed) `struct ClientCallMessage`.
162  */
163 struct ClientPhoneHangupMessage {
164   /**
165    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP
166    */
167   struct GNUNET_MessageHeader header;
168
169   /**
170    * CID, internal caller ID to identify which active call we are
171    * talking about.
172    */
173   uint32_t cid GNUNET_PACKED;
174 };
175
176
177 /**
178  * Message Client <-> Service to transmit the audio.
179  */
180 struct ClientAudioMessage {
181   /**
182    * Type is #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO
183    */
184   struct GNUNET_MessageHeader header;
185
186   /**
187    * CID, internal caller ID to identify which active call we are
188    * sending data to.
189    */
190   uint32_t cid GNUNET_PACKED;
191
192   /* followed by audio data */
193 };
194
195
196 /**
197  * Client -> Service message to call a phone.
198  */
199 struct ClientCallMessage {
200   /**
201    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_CALL
202    */
203   struct GNUNET_MessageHeader header;
204
205   /**
206    * Always zero.
207    */
208   uint32_t reserved GNUNET_PACKED;
209
210   /**
211    * Which peer is hosting the line?
212    */
213   struct GNUNET_PeerIdentity target;
214
215   /**
216    * Which phone line to call at the peer?
217    */
218   struct GNUNET_HashCode line_port;
219
220   /**
221    * Identity of the caller.
222    */
223   struct GNUNET_CRYPTO_EcdsaPrivateKey caller_id;
224 };
225
226
227 /**
228  * Service -> Client: other peer has picked up the phone, we are
229  * now talking.
230  */
231 struct ClientPhonePickedupMessage {
232   /**
233    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICKED_UP
234    */
235   struct GNUNET_MessageHeader header;
236
237   /**
238    * Call ID of the corresponding
239    * #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_CALL
240    */
241   uint32_t cid GNUNET_PACKED;
242 };
243
244
245 /**
246  * Information signed in a `struct CadetPhoneRingMessage`
247  * whereby the caller self-identifies to the receiver.
248  */
249 struct CadetPhoneRingInfoPS {
250   /**
251    * Purpose for the signature, must be
252    * #GNUNET_SIGNATURE_PURPOSE_CONVERSATION_RING.
253    */
254   struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
255
256   /**
257    * Which port did the call go to?
258    */
259   struct GNUNET_HashCode line_port;
260
261   /**
262    * Which peer is the call for?
263    */
264   struct GNUNET_PeerIdentity target_peer;
265
266   /**
267    * When does the signature expire?
268    */
269   struct GNUNET_TIME_AbsoluteNBO expiration_time;
270 };
271
272
273 /**
274  * Cadet message to make a phone ring.  Sent to the port
275  * of the respective phone.
276  */
277 struct CadetPhoneRingMessage {
278   /**
279    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_RING
280    */
281   struct GNUNET_MessageHeader header;
282
283   /**
284    * Always zero.
285    */
286   uint32_t reserved GNUNET_PACKED;
287
288   /**
289    * Who is calling us? (also who is signing).
290    */
291   struct GNUNET_CRYPTO_EcdsaPublicKey caller_id;
292
293   /**
294    * When does the signature expire?
295    */
296   struct GNUNET_TIME_AbsoluteNBO expiration_time;
297
298   /**
299    * Signature over a `struct CadetPhoneRingInfoPS`
300    */
301   struct GNUNET_CRYPTO_EcdsaSignature signature;
302 };
303
304
305 /**
306  * Cadet message for hanging up.
307  */
308 struct CadetPhoneHangupMessage {
309   /**
310    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_HANG_UP
311    */
312   struct GNUNET_MessageHeader header;
313 };
314
315
316 /**
317  * Cadet message for picking up.
318  */
319 struct CadetPhonePickupMessage {
320   /**
321    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_PICK_UP
322    */
323   struct GNUNET_MessageHeader header;
324 };
325
326
327 /**
328  * Cadet message for phone suspended.
329  */
330 struct CadetPhoneSuspendMessage {
331   /**
332    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_SUSPEND
333    */
334   struct GNUNET_MessageHeader header;
335 };
336
337
338 /**
339  * Cadet message for phone resumed.
340  */
341 struct CadetPhoneResumeMessage {
342   /**
343    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_RESUME
344    */
345   struct GNUNET_MessageHeader header;
346 };
347
348
349 /**
350  * Cadet message to transmit the audio.
351  */
352 struct CadetAudioMessage {
353   /**
354    * Type is #GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_AUDIO
355    */
356   struct GNUNET_MessageHeader header;
357
358   /* followed by audio data */
359 };
360
361
362 GNUNET_NETWORK_STRUCT_END
363
364
365 #if 0                           /* keep Emacsens' auto-indent happy */
366 {
367 #endif
368 #ifdef __cplusplus
369 }
370 #endif
371
372 /* ifndef GNUNET_PROTOCOLS_CONVERSATION_H */
373 #endif
374 /* end of gnunet_protocols_conversation.h */