aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-10-04 10:58:58 +0000
committerChristian Grothoff <christian@grothoff.org>2013-10-04 10:58:58 +0000
commitc7d80251ce87a5015409446d9ac93658ad5ca5d7 (patch)
tree75823f5b5e30fefc443ca41efdf96b6cfc41d109 /src
parentb4f52cedf1afd0e53b2f205f2e543a7900b385be (diff)
downloadgnunet-c7d80251ce87a5015409446d9ac93658ad5ca5d7.tar.gz
gnunet-c7d80251ce87a5015409446d9ac93658ad5ca5d7.zip
-sync before server reboot, work on conversation service
Diffstat (limited to 'src')
-rw-r--r--src/conversation/conversation.h5
-rw-r--r--src/conversation/gnunet-service-conversation-new.c101
-rw-r--r--src/include/gnunet_crypto_lib.h23
-rw-r--r--src/include/gnunet_signatures.h5
4 files changed, 116 insertions, 18 deletions
diff --git a/src/conversation/conversation.h b/src/conversation/conversation.h
index 540f7de5b..05fdc326b 100644
--- a/src/conversation/conversation.h
+++ b/src/conversation/conversation.h
@@ -55,9 +55,10 @@ struct VoipClient
55 struct GNUNET_SERVER_Client *client; 55 struct GNUNET_SERVER_Client *client;
56}; 56};
57 57
58
58/** 59/**
59* The connection status of the service 60 * The connection status of the service
60*/ 61 */
61struct ConnectionStatus 62struct ConnectionStatus
62{ 63{
63 /** 64 /**
diff --git a/src/conversation/gnunet-service-conversation-new.c b/src/conversation/gnunet-service-conversation-new.c
index 39d043254..b02c9094e 100644
--- a/src/conversation/gnunet-service-conversation-new.c
+++ b/src/conversation/gnunet-service-conversation-new.c
@@ -29,12 +29,21 @@
29#include "gnunet_protocols.h" 29#include "gnunet_protocols.h"
30#include "gnunet_applications.h" 30#include "gnunet_applications.h"
31#include "gnunet_constants.h" 31#include "gnunet_constants.h"
32#include "gnunet_signatures.h"
32#include "gnunet_mesh_service.h" 33#include "gnunet_mesh_service.h"
33#include "gnunet_conversation_service.h" 34#include "gnunet_conversation_service.h"
34#include "conversation.h" 35#include "conversation.h"
35 36
36 37
37/** 38/**
39 * How long is our signature on a call valid? Needs to be long enough for time zone
40 * differences and network latency to not matter. No strong need for it to be short,
41 * but we simply like all signatures to eventually expire.
42 */
43#define RING_TIMEOUT GNUNET_TIME_UNIT_DAYS
44
45
46/**
38 * The possible connection status 47 * The possible connection status
39 */ 48 */
40enum LineStatus 49enum LineStatus
@@ -100,7 +109,12 @@ struct Line
100 /** 109 /**
101 * Transmit handle for pending audio messages 110 * Transmit handle for pending audio messages
102 */ 111 */
103 struct GNUNET_MESH_TransmitHandle *mth; 112 struct GNUNET_MESH_TransmitHandle *unreliable_mth;
113
114 /**
115 * Transmit handle for pending audio messages
116 */
117 struct GNUNET_MQ_Handle *reliable_mq;
104 118
105 /** 119 /**
106 * Our line number. 120 * Our line number.
@@ -131,6 +145,11 @@ static struct GNUNET_SERVER_NotificationContext *nc;
131static struct GNUNET_MESH_Handle *mesh; 145static struct GNUNET_MESH_Handle *mesh;
132 146
133/** 147/**
148 * Identity of this peer.
149 */
150static struct GNUNET_PeerIdentity my_identity;
151
152/**
134 * Head of DLL of active lines. 153 * Head of DLL of active lines.
135 */ 154 */
136static struct Line *lines_head; 155static struct Line *lines_head;
@@ -154,9 +173,21 @@ handle_client_register_message (void *cls,
154 const struct GNUNET_MessageHeader *message) 173 const struct GNUNET_MessageHeader *message)
155{ 174{
156 const struct ClientPhoneRegisterMessage *msg; 175 const struct ClientPhoneRegisterMessage *msg;
176 struct Line *line;
157 177
158 msg = (struct ClientPhoneRegisterMessage *) message; 178 msg = (struct ClientPhoneRegisterMessage *) message;
159 GNUNET_break (0); // FIXME 179 line = GNUNET_SERVER_client_get_user_context (client, struct Line);
180 if (NULL != line)
181 {
182 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
183 return;
184 }
185 line = GNUNET_new (struct Line);
186 GNUNET_CONTAINER_DLL_insert (lines_head,
187 lines_tail,
188 line);
189 line->line = ntohl (msg->line);
190 GNUNET_SERVER_client_set_user_context (client, line);
160 GNUNET_SERVER_receive_done (client, GNUNET_OK); 191 GNUNET_SERVER_receive_done (client, GNUNET_OK);
161} 192}
162 193
@@ -214,9 +245,53 @@ handle_client_call_message (void *cls,
214 const struct GNUNET_MessageHeader *message) 245 const struct GNUNET_MessageHeader *message)
215{ 246{
216 const struct ClientCallMessage *msg; 247 const struct ClientCallMessage *msg;
248 struct Line *line;
249 struct GNUNET_MQ_Envelope *e;
250 struct MeshPhoneRingMessage *ring;
217 251
218 msg = (struct ClientCallMessage *) message; 252 msg = (struct ClientCallMessage *) message;
219 GNUNET_break (0); // FIXME 253 line = GNUNET_SERVER_client_get_user_context (client, struct Line);
254 if (NULL != line)
255 {
256 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
257 return;
258 }
259 line = GNUNET_new (struct Line);
260 GNUNET_CONTAINER_DLL_insert (lines_head,
261 lines_tail,
262 line);
263 line->line = ntohl (msg->line);
264 line->status = LS_CALLER_CALLING;
265 line->tunnel_reliable = GNUNET_MESH_tunnel_create (mesh,
266 line,
267 &msg->target,
268 GNUNET_APPLICATION_TYPE_CONVERSATION_CONTROL,
269 GNUNET_NO,
270 GNUNET_YES);
271 line->tunnel_unreliable = GNUNET_MESH_tunnel_create (mesh,
272 line,
273 &msg->target,
274 GNUNET_APPLICATION_TYPE_CONVERSATION_AUDIO,
275 GNUNET_YES,
276 GNUNET_NO);
277 line->reliable_mq = GNUNET_MESH_mq_create (line->tunnel_reliable);
278 e = GNUNET_MQ_msg (ring, GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PHONE_RING);
279 ring->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CONVERSATION_RING);
280 ring->purpose.size = htonl (sizeof (struct GNUNET_PeerIdentity) * 2 +
281 sizeof (struct GNUNET_TIME_AbsoluteNBO) +
282 sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) +
283 sizeof (struct GNUNET_CRYPTO_EccPublicSignKey));
284 GNUNET_CRYPTO_ecc_key_get_public_for_signature (&msg->caller_id,
285 &ring->caller_id);
286 ring->line = msg->line;
287 ring->target = msg->target;
288 ring->source = my_identity;
289 ring->expiration_time = GNUNET_TIME_absolute_hton (GNUNET_TIME_relative_to_absolute (RING_TIMEOUT));
290 GNUNET_CRYPTO_ecc_sign (&msg->caller_id,
291 &ring->purpose,
292 &ring->signature);
293 GNUNET_MQ_send (line->reliable_mq, e);
294 GNUNET_SERVER_client_set_user_context (client, line);
220 GNUNET_SERVER_receive_done (client, GNUNET_OK); 295 GNUNET_SERVER_receive_done (client, GNUNET_OK);
221} 296}
222 297
@@ -372,6 +447,7 @@ inbound_tunnel (void *cls,
372 const struct GNUNET_PeerIdentity *initiator, 447 const struct GNUNET_PeerIdentity *initiator,
373 uint32_t port) 448 uint32_t port)
374{ 449{
450
375 GNUNET_break (0); // FIXME 451 GNUNET_break (0); // FIXME
376 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 452 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
377 _("Received incoming tunnel on port %d\n"), port); 453 _("Received incoming tunnel on port %d\n"), port);
@@ -405,9 +481,18 @@ inbound_end (void *cls,
405 */ 481 */
406static void 482static void
407handle_client_disconnect (void *cls, 483handle_client_disconnect (void *cls,
408 struct GNUNET_SERVER_Client *cl) 484 struct GNUNET_SERVER_Client *client)
409{ 485{
410 GNUNET_break (0); // FIXME 486 struct Line *line;
487
488 line = GNUNET_SERVER_client_get_user_context (client, struct Line);
489 if (NULL == line)
490 return;
491 GNUNET_CONTAINER_DLL_remove (lines_head,
492 lines_tail,
493 line);
494 GNUNET_free (line);
495 GNUNET_SERVER_client_set_user_context (client, NULL);
411} 496}
412 497
413 498
@@ -418,7 +503,8 @@ handle_client_disconnect (void *cls,
418 * @param tc the task context 503 * @param tc the task context
419 */ 504 */
420static void 505static void
421do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 506do_shutdown (void *cls,
507 const struct GNUNET_SCHEDULER_TaskContext *tc)
422{ 508{
423 GNUNET_break (0); // FIXME 509 GNUNET_break (0); // FIXME
424 if (NULL != mesh) 510 if (NULL != mesh)
@@ -488,6 +574,9 @@ run (void *cls,
488 }; 574 };
489 575
490 cfg = c; 576 cfg = c;
577 GNUNET_assert (GNUNET_OK ==
578 GNUNET_CRYPTO_get_host_identity (cfg,
579 &my_identity));
491 mesh = GNUNET_MESH_connect (cfg, 580 mesh = GNUNET_MESH_connect (cfg,
492 NULL, 581 NULL,
493 &inbound_tunnel, 582 &inbound_tunnel,
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h
index a0935363b..7c30482c2 100644
--- a/src/include/gnunet_crypto_lib.h
+++ b/src/include/gnunet_crypto_lib.h
@@ -397,9 +397,9 @@ GNUNET_CRYPTO_symmetric_create_session_key (struct GNUNET_CRYPTO_SymmetricSessio
397 */ 397 */
398ssize_t 398ssize_t
399GNUNET_CRYPTO_symmetric_encrypt (const void *block, size_t len, 399GNUNET_CRYPTO_symmetric_encrypt (const void *block, size_t len,
400 const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, 400 const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey,
401 const struct GNUNET_CRYPTO_SymmetricInitializationVector 401 const struct GNUNET_CRYPTO_SymmetricInitializationVector *iv,
402 *iv, void *result); 402 void *result);
403 403
404 404
405/** 405/**
@@ -415,9 +415,9 @@ GNUNET_CRYPTO_symmetric_encrypt (const void *block, size_t len,
415 */ 415 */
416ssize_t 416ssize_t
417GNUNET_CRYPTO_symmetric_decrypt (const void *block, size_t size, 417GNUNET_CRYPTO_symmetric_decrypt (const void *block, size_t size,
418 const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, 418 const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey,
419 const struct GNUNET_CRYPTO_SymmetricInitializationVector 419 const struct GNUNET_CRYPTO_SymmetricInitializationVector *iv,
420 *iv, void *result); 420 void *result);
421 421
422 422
423/** 423/**
@@ -431,8 +431,9 @@ GNUNET_CRYPTO_symmetric_decrypt (const void *block, size_t size,
431 */ 431 */
432void 432void
433GNUNET_CRYPTO_symmetric_derive_iv (struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, 433GNUNET_CRYPTO_symmetric_derive_iv (struct GNUNET_CRYPTO_SymmetricInitializationVector *iv,
434 const struct GNUNET_CRYPTO_SymmetricSessionKey *skey, 434 const struct GNUNET_CRYPTO_SymmetricSessionKey *skey,
435 const void *salt, size_t salt_len, ...); 435 const void *salt,
436 size_t salt_len, ...);
436 437
437 438
438/** 439/**
@@ -445,8 +446,10 @@ GNUNET_CRYPTO_symmetric_derive_iv (struct GNUNET_CRYPTO_SymmetricInitializationV
445 */ 446 */
446void 447void
447GNUNET_CRYPTO_symmetric_derive_iv_v (struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, 448GNUNET_CRYPTO_symmetric_derive_iv_v (struct GNUNET_CRYPTO_SymmetricInitializationVector *iv,
448 const struct GNUNET_CRYPTO_SymmetricSessionKey *skey, 449 const struct GNUNET_CRYPTO_SymmetricSessionKey *skey,
449 const void *salt, size_t salt_len, va_list argp); 450 const void *salt,
451 size_t salt_len,
452 va_list argp);
450 453
451 454
452/** 455/**
diff --git a/src/include/gnunet_signatures.h b/src/include/gnunet_signatures.h
index 54cf36209..1493f2901 100644
--- a/src/include/gnunet_signatures.h
+++ b/src/include/gnunet_signatures.h
@@ -141,6 +141,11 @@ extern "C"
141 */ 141 */
142#define GNUNET_SIGNATURE_PURPOSE_MULTICAST_MESSAGE 19 142#define GNUNET_SIGNATURE_PURPOSE_MULTICAST_MESSAGE 19
143 143
144/**
145 * Signature of a conversation ring.
146 */
147#define GNUNET_SIGNATURE_PURPOSE_CONVERSATION_RING 20
148
144 149
145#if 0 /* keep Emacsens' auto-indent happy */ 150#if 0 /* keep Emacsens' auto-indent happy */
146{ 151{