pack network structs
[oweals/gnunet.git] / src / conversation / conversation.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2013 GNUnet e.V.
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., 51 Franklin Street, Fifth Floor,
18      Boston, MA 02110-1301, 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  * 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   /**
58    * Type is #GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO
59    */
60   struct GNUNET_MessageHeader header;
61
62   /* followed by audio data */
63
64 };
65
66
67 /**
68  * Client -> Service message to register a phone.
69  */
70 struct ClientPhoneRegisterMessage
71 {
72   /**
73    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_REGISTER
74    */
75   struct GNUNET_MessageHeader header;
76
77   /**
78    * Phone line to register.
79    */
80   uint32_t line GNUNET_PACKED;
81 };
82
83
84 /**
85  * Service -> Client message for phone is ringing.
86  */
87 struct ClientPhoneRingMessage
88 {
89   /**
90    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RING
91    */
92   struct GNUNET_MessageHeader header;
93
94   /**
95    * CID, internal caller ID to identify which active call we are
96    * talking about.
97    */
98   uint32_t cid GNUNET_PACKED;
99
100   /**
101    * Who is calling us?
102    */
103   struct GNUNET_CRYPTO_EcdsaPublicKey caller_id;
104
105 };
106
107
108 /**
109  * Service <-> Client message for phone was suspended.
110  */
111 struct ClientPhoneSuspendMessage
112 {
113   /**
114    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND
115    */
116   struct GNUNET_MessageHeader header;
117
118   /**
119    * CID, internal caller ID to identify which active call we are
120    * talking about.
121    */
122   uint32_t cid GNUNET_PACKED;
123
124 };
125
126
127 /**
128  * Service <-> Client message for phone was resumed.
129  */
130 struct ClientPhoneResumeMessage
131 {
132   /**
133    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME
134    */
135   struct GNUNET_MessageHeader header;
136
137   /**
138    * CID, internal caller ID to identify which active call we are
139    * talking about.
140    */
141   uint32_t cid GNUNET_PACKED;
142
143 };
144
145
146 /**
147  * Client -> Service pick up phone that is ringing.
148  */
149 struct ClientPhonePickupMessage
150 {
151   /**
152    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICK_UP
153    */
154   struct GNUNET_MessageHeader header;
155
156   /**
157    * CID, internal caller ID to identify which active call we are
158    * talking about.
159    */
160   uint32_t cid GNUNET_PACKED;
161
162 };
163
164
165 /**
166  * Client <-> Service hang up phone that may or may not be ringing.
167  * Also sent in response to a (failed) `struct ClientCallMessage`.
168  */
169 struct ClientPhoneHangupMessage
170 {
171   /**
172    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP
173    */
174   struct GNUNET_MessageHeader header;
175
176   /**
177    * CID, internal caller ID to identify which active call we are
178    * talking about.
179    */
180   uint32_t cid GNUNET_PACKED;
181
182 };
183
184
185 /**
186  * Message Client <->Service to transmit the audio.
187  */
188 struct ClientAudioMessage
189 {
190   /**
191    * Type is #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO
192    */
193   struct GNUNET_MessageHeader header;
194
195   /**
196    * CID, internal caller ID to identify which active call we are
197    * sending data to.
198    */
199   uint32_t cid GNUNET_PACKED;
200
201   /* followed by audio data */
202
203 };
204
205
206 /**
207  * Client -> Service message to call a phone.
208  */
209 struct ClientCallMessage
210 {
211   /**
212    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_CALL
213    */
214   struct GNUNET_MessageHeader header;
215
216   /**
217    * Which phone line to call at the peer?
218    */
219   uint32_t line GNUNET_PACKED;
220
221   /**
222    * Which peer is hosting the line?
223    */
224   struct GNUNET_PeerIdentity target;
225
226   /**
227    * Identity of the caller.
228    */
229   struct GNUNET_CRYPTO_EcdsaPrivateKey caller_id;
230 };
231
232
233 /**
234  * Service -> Client: other peer has picked up the phone, we are
235  * now talking.
236  */
237 struct ClientPhonePickedupMessage
238 {
239   /**
240    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICKED_UP
241    */
242   struct GNUNET_MessageHeader header;
243
244 };
245
246
247 /**
248  * Cadet message for phone is ringing.
249  */
250 struct CadetPhoneRingMessage
251 {
252   /**
253    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_RING
254    */
255   struct GNUNET_MessageHeader header;
256
257   /**
258    * Desired target line.
259    */
260   uint32_t remote_line GNUNET_PACKED;
261
262   /**
263    * Purpose for the signature.
264    */
265   struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
266
267   /**
268    * Who is calling us? (also who is signing).
269    */
270   struct GNUNET_CRYPTO_EcdsaPublicKey caller_id;
271
272   /**
273    * Who are we calling?
274    */
275   struct GNUNET_PeerIdentity target;
276
277   /**
278    * From where are we calling?
279    */
280   struct GNUNET_PeerIdentity source;
281
282   /**
283    * When does the signature expire?
284    */
285   struct GNUNET_TIME_AbsoluteNBO expiration_time;
286
287   /**
288    * Signature on the above.
289    */
290   struct GNUNET_CRYPTO_EcdsaSignature signature;
291
292   /**
293    * Source line for audio data in the other direction.
294    */
295   uint32_t source_line GNUNET_PACKED;
296
297 };
298
299
300 /**
301  * Cadet message for hanging up.
302  */
303 struct CadetPhoneHangupMessage
304 {
305   /**
306    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_HANG_UP
307    */
308   struct GNUNET_MessageHeader header;
309
310 };
311
312
313 /**
314  * Cadet message for picking up.
315  */
316 struct CadetPhonePickupMessage
317 {
318   /**
319    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_PICK_UP
320    */
321   struct GNUNET_MessageHeader header;
322
323 };
324
325
326 /**
327  * Cadet message for phone suspended.
328  */
329 struct CadetPhoneSuspendMessage
330 {
331   /**
332    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_SUSPEND
333    */
334   struct GNUNET_MessageHeader header;
335
336 };
337
338
339 /**
340  * Cadet message for phone resumed.
341  */
342 struct CadetPhoneResumeMessage
343 {
344   /**
345    * Type is: #GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_RESUME
346    */
347   struct GNUNET_MessageHeader header;
348
349 };
350
351
352 /**
353  * Cadet message to transmit the audio.
354  */
355 struct CadetAudioMessage
356 {
357   /**
358    * Type is #GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_AUDIO
359    */
360   struct GNUNET_MessageHeader header;
361
362   /**
363    * Target line on the receiving end.
364    */
365   uint32_t remote_line GNUNET_PACKED;
366
367   /**
368    * The source line sending this data
369    */
370   uint32_t source_line GNUNET_PACKED;
371
372   /* followed by audio data */
373
374 };
375
376
377 GNUNET_NETWORK_STRUCT_END
378
379
380 #if 0                           /* keep Emacsens' auto-indent happy */
381 {
382 #endif
383 #ifdef __cplusplus
384 }
385 #endif
386
387 /* ifndef GNUNET_PROTOCOLS_CONVERSATION_H */
388 #endif
389 /* end of gnunet_protocols_conversation.h */