-mostly finished call API
[oweals/gnunet.git] / src / conversation / conversation.h
1 /*
2      This file is part of GNUnet.
3      (C) 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 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 * Messages for the Client <-> Server communication
44 */
45
46
47 /**
48  * VoipClient.
49  */
50 struct VoipClient
51 {
52   /**
53    * Handle for a conversation client.
54    */
55   struct GNUNET_SERVER_Client *client;
56 };
57
58 /**
59 * The connection status of the service
60 */
61 struct ConnectionStatus
62 {
63         /**
64         * The client which is in interaction
65         */
66   struct GNUNET_SERVER_Client *client;
67
68         /**
69         * The PeerIdentity of the peer
70         */
71   struct GNUNET_PeerIdentity peer;
72
73         /**
74         * The status (see enum)
75         */
76   int status;
77 };
78
79 /**
80 * Information about a missed call
81 */
82 struct MissedCall
83 {
84         /**
85         * The PeerIdentity of the peer
86         */
87   struct GNUNET_PeerIdentity peer;
88
89         /**
90         * The time the call was
91         */
92   struct GNUNET_TIME_Absolute time;
93
94 };
95
96
97
98
99 /**
100  * Client <-> Server message to initiate a new call
101  */
102 struct ClientServerSessionInitiateMessage
103 {
104   /**
105    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_SESSION_INITIATE 
106    */
107   struct GNUNET_MessageHeader header;
108   struct GNUNET_PeerIdentity peer;
109 };
110
111
112 /**
113  * Client <-> Server meessage to accept an incoming call
114  */
115 struct ClientServerSessionAcceptMessage
116 {
117   /**
118    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_SESSION_ACCEPT 
119    */
120   struct GNUNET_MessageHeader header;
121 };
122
123
124 /**
125  * Client <-> Server message to reject an incoming call
126  */
127 struct ClientServerSessionRejectMessage
128 {
129   /**
130    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_SESSION_REJECT
131    */
132   struct GNUNET_MessageHeader header;
133   int reason;
134 };
135
136
137 /**
138  * Client <-> Server message to terminat a call
139  */
140 struct ClientServerSessionTerminateMessage
141 {
142   /**
143    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_SESSION_TERMINATE 
144    */
145   struct GNUNET_MessageHeader header;
146 };
147
148
149 /**
150  * Client <-> Server message to initiate a new call
151  */
152 struct ClientServerTestMessage
153 {
154   /**
155    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_TEST 
156    */
157   struct GNUNET_MessageHeader header;
158   struct GNUNET_PeerIdentity peer;
159 };
160
161 /************************************************************************************************************************
162 * Messages for the Server <-> Client communication
163 */
164
165 /**
166  * Server <-> Client message to initiate a new call
167  */
168 struct ServerClientSessionInitiateMessage
169 {
170   /**
171    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_SC_SESSION_INITIATE
172    */
173   struct GNUNET_MessageHeader header;
174   struct GNUNET_PeerIdentity peer;
175 };
176
177
178 /**
179  * Server <-> Client meessage to accept an incoming call
180  */
181 struct ServerClientSessionAcceptMessage
182 {
183   /**
184    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_SC_SESSION_ACCEPT 
185    */
186   struct GNUNET_MessageHeader header;
187 };
188
189
190 /**
191  * Server <-> Client message to reject an incoming call
192  */
193 struct ServerClientSessionRejectMessage
194 {
195   /**
196    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_SC_SESSION_REJECT 
197    */
198   struct GNUNET_MessageHeader header;
199   int reason;
200   int notify;
201 };
202
203
204 /**
205  * Server <-> Client message to terminat a call
206  */
207 struct ServerClientSessionTerminateMessage
208 {
209   /**
210    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_SC_SESSION_TERMINATE 
211    */
212   struct GNUNET_MessageHeader header;
213 };
214
215
216 /**
217  * Server <-> Client message to signalize the client that the service is already in use
218  */
219 struct ServerClientServiceBlockedMessage
220 {
221   /**
222    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_SC_SERVICE_BLOCKED
223    */
224   struct GNUNET_MessageHeader header;
225 };
226
227 /**
228  * Server <-> Client message to signalize the client that the called peer is not connected
229  */
230 struct ServerClientPeerNotConnectedMessage
231 {
232   /**
233    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_SC_PEER_NOT_CONNECTED 
234    */
235   struct GNUNET_MessageHeader header;
236 };
237
238
239 /**
240  * Server <-> Client message to signalize the client that called peer does not answer
241  */
242 struct ServerClientNoAnswerMessage
243 {
244   /**
245    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_SC_NO_ANSWER
246    */
247   struct GNUNET_MessageHeader header;
248 };
249
250 /**
251  * Server <-> Client message to notify client of missed call
252  */
253 struct ServerClientMissedCallMessage
254 {
255   /**
256    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_SC_MISSED_CALL 
257    */
258   struct GNUNET_MessageHeader header;
259   int number;
260   struct MissedCall *missed_call;
261 };
262
263
264 /**
265  * Server <-> Client message to signalize the client that there occured an error
266  */
267 struct ServerClientErrorMessage
268 {
269   /**
270    * Type is: #define GNUNET_MESSAGE_TYPE_CONVERSATION_SC_ERROR 
271    */
272   struct GNUNET_MessageHeader header;
273 };
274
275
276 /**
277  * Server <-> Client message to notify client of peer being available
278  */
279 struct ServerClientPeerAvailableMessage
280 {
281   /**
282    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_SC_PEER_AVAILABLE
283    */
284   struct GNUNET_MessageHeader header;
285   struct GNUNET_PeerIdentity peer;
286   struct GNUNET_TIME_Absolute time;
287 };
288
289 /************************************************************************************************************************
290 * Messages for the Mesh communication
291 */
292
293 struct VoIPMeshMessageHeader
294 {
295   /**
296    * Type is: 
297    */
298   struct GNUNET_MessageHeader header;
299   int SequenceNumber;
300   struct GNUNET_TIME_Absolute time;
301 };
302
303
304 /**
305  * Mesh message to sinal the remote peer the wish to initiate a new call
306  */
307 struct MeshSessionInitiateMessage
308 {
309   /**
310    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_SESSION_INITIATE
311    */
312   struct GNUNET_MessageHeader header;
313   int SequenceNumber;
314   struct GNUNET_TIME_Absolute time;
315   struct GNUNET_PeerIdentity peer;
316 };
317
318 /**
319  * Mesh message to signal the remote peer the acceptance of an initiated call
320  */
321 struct MeshSessionAcceptMessage
322 {
323   /**
324    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_SESSION_ACCEPT
325    */
326   struct GNUNET_MessageHeader header;
327   int SequenceNumber;
328   struct GNUNET_TIME_Absolute time;
329 };
330
331
332 /**
333  * Mesh message to reject an a wish to initiate a new call
334  */
335 struct MeshSessionRejectMessage
336 {
337   /**
338    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_SESSION_REJECT 
339    */
340   struct GNUNET_MessageHeader header;
341   int SequenceNumber;
342   struct GNUNET_TIME_Absolute time;
343   int reason;
344   int notify;
345 };
346
347
348 /**
349  * Mesh message to signal a remote peer the terminatation of a call
350  */
351 struct MeshSessionTerminateMessage
352 {
353   /**
354    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_SESSION_TERMINATE 
355    */
356   struct GNUNET_MessageHeader header;
357   int SequenceNumber;
358   struct GNUNET_TIME_Absolute time;
359 };
360
361
362 /**
363  * Server <-> Client message to notify client of peer being available
364  */
365 struct MeshPeerAvailableMessage
366 {
367   /**
368    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PEER_AVAILABLE 
369    */
370   struct GNUNET_MessageHeader header;
371   int SequenceNumber;
372   struct GNUNET_TIME_Absolute time;
373   struct GNUNET_PeerIdentity peer;
374   struct GNUNET_TIME_Absolute call;
375 };
376
377
378 /**
379  * Messages for the audio communication
380  */
381 struct TestMessage
382 {
383   /**
384    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_TEST 
385    */
386   struct GNUNET_MessageHeader header;
387 };
388
389 ////////////////////////////////////////////////////////////
390
391 /**
392  * Message to transmit the audio (between client and helpers).
393  */
394 struct AudioMessage
395 {
396   /**
397    * Type is #GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO
398    */
399   struct GNUNET_MessageHeader header;
400
401   /* followed by audio data */
402
403 };
404
405
406 /**
407  * Client -> Service message to register a phone.
408  */
409 struct ClientPhoneRegisterMessage
410 {
411   /**
412    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_REGISTER
413    */
414   struct GNUNET_MessageHeader header;
415
416   /**
417    * Phone line to register.
418    */
419   uint32_t line GNUNET_PACKED;
420 };
421
422
423 /**
424  * Service -> Client message for phone is ringing.
425  */
426 struct ClientPhoneRingMessage
427 {
428   /**
429    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RING
430    */
431   struct GNUNET_MessageHeader header;
432
433   /**
434    * Always zero.
435    */
436   uint32_t reserved GNUNET_PACKED;
437
438   /**
439    * Who is calling us?
440    */
441   struct GNUNET_CRYPTO_EccPublicSignKey caller_id;
442
443 };
444
445
446 /**
447  * Service -> Client message for phone is busy.
448  */
449 struct ClientPhoneBusyMessage
450 {
451   /**
452    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_BUSY
453    */
454   struct GNUNET_MessageHeader header;
455
456 };
457
458
459 /**
460  * Client -> Service pick up phone that is ringing.
461  */
462 struct ClientPhonePickupMessage
463 {
464   /**
465    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICK_UP
466    */
467   struct GNUNET_MessageHeader header;
468   
469   /* followed by variable length 0-terminated string with meta data */
470
471 };
472
473
474 /**
475  * Client <-> Service hang up phone that may or may not be ringing.
476  * Also sent in response to a (failed) `struct ClientCallMessage`.
477  */
478 struct ClientPhoneHangupMessage
479 {
480   /**
481    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP
482    */
483   struct GNUNET_MessageHeader header;
484   
485   /* followed by variable length 0-terminated string with meta data */
486
487 };
488
489
490 /**
491  * Message Client <->Service to transmit the audio.
492  */
493 struct ClientAudioMessage
494 {
495   /**
496    * Type is #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO
497    */
498   struct GNUNET_MessageHeader header;
499
500   /* followed by audio data */
501
502 };
503
504
505 /**
506  * Client -> Service message to call a phone.
507  */
508 struct ClientCallMessage
509 {
510   /**
511    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_CALL
512    */
513   struct GNUNET_MessageHeader header;
514
515   /**
516    * Which phone line to call at the peer?
517    */
518   uint32_t line GNUNET_PACKED;
519
520   /**
521    * Which peer is hosting the line?
522    */
523   struct GNUNET_PeerIdentity target;
524
525   /**
526    * Identity of the caller.
527    */
528   struct GNUNET_CRYPTO_EccPrivateKey caller_id;
529 };
530
531
532 /**
533  * Service -> Client: other peer has picked up the phone, we are
534  * now talking.
535  */
536 struct ClientPhonePickedupMessage
537 {
538   /**
539    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICKED_UP
540    */
541   struct GNUNET_MessageHeader header;
542   
543   /* followed by variable length 0-terminated string with meta data */
544
545 };
546
547
548 /**
549  * Mesh message for phone is ringing.
550  */
551 struct MeshPhoneRingMessage
552 {
553   /**
554    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PHONE_RING
555    */
556   struct GNUNET_MessageHeader header;
557
558   /**
559    * Desired target line.
560    */
561   uint32_t line GNUNET_PACKED;
562
563   /**
564    * Purpose for the signature.
565    */
566   struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
567
568   /**
569    * Who is calling us? (also who is signing).
570    */
571   struct GNUNET_CRYPTO_EccPublicSignKey caller_id;
572
573   /**
574    * Who are we calling?
575    */
576   struct GNUNET_PeerIdentity target;
577
578   /**
579    * From where are we calling?
580    */
581   struct GNUNET_PeerIdentity source;
582
583   /**
584    * When does the signature expire?
585    */ 
586   struct GNUNET_TIME_AbsoluteNBO expiration_time;
587
588   /**
589    * Signature on the above.
590    */
591   struct GNUNET_CRYPTO_EccSignature signature;
592
593 };
594
595
596 /**
597  * Mesh message for hanging up.
598  */
599 struct MeshPhoneHangupMessage
600 {
601   /**
602    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PHONE_HANG_UP
603    */
604   struct GNUNET_MessageHeader header;
605
606   /* followed by variable-size 0-terminated reason string */
607 };
608
609
610 /**
611  * Mesh message for picking up.
612  */
613 struct MeshPhonePickupMessage
614 {
615   /**
616    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PHONE_PICK_UP
617    */
618   struct GNUNET_MessageHeader header;
619
620   /* followed by variable-size 0-terminated metadata string */
621 };
622
623
624 /**
625  * Mesh message for phone busy.
626  */
627 struct MeshPhoneBusyMessage
628 {
629   /**
630    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PHONE_BUSY
631    */
632   struct GNUNET_MessageHeader header;
633
634   /* followed by variable-size 0-terminated metadata string??? */
635 };
636
637
638 /**
639  * Mesh message to transmit the audio.
640  */
641 struct MeshAudioMessage
642 {
643   /**
644    * Type is #GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_AUDIO
645    */
646   struct GNUNET_MessageHeader header;
647
648   /* followed by audio data */
649
650 };
651
652
653
654 #if 0                           /* keep Emacsens' auto-indent happy */
655 {
656 #endif
657 #ifdef __cplusplus
658 }
659 #endif
660
661 /* ifndef GNUNET_PROTOCOLS_CONVERSATION_H */
662 #endif
663 /* end of gnunet_protocols_conversation.h */