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