aboutsummaryrefslogtreecommitdiff
path: root/src/conversation
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/conversation
parentb4f52cedf1afd0e53b2f205f2e543a7900b385be (diff)
downloadgnunet-c7d80251ce87a5015409446d9ac93658ad5ca5d7.tar.gz
gnunet-c7d80251ce87a5015409446d9ac93658ad5ca5d7.zip
-sync before server reboot, work on conversation service
Diffstat (limited to 'src/conversation')
-rw-r--r--src/conversation/conversation.h5
-rw-r--r--src/conversation/gnunet-service-conversation-new.c101
2 files changed, 98 insertions, 8 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,