aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/gnunet-service-mesh_local.c
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-10-11 10:59:32 +0000
committerBart Polot <bart@net.in.tum.de>2013-10-11 10:59:32 +0000
commitef2231cf7c1b83ac45c6fbe75f2ef73280815024 (patch)
tree4f3aa6d15bc26ded2de7c983c9df689000b354a6 /src/mesh/gnunet-service-mesh_local.c
parent23cd779d3db3edd280ca9f760f1a98efa49e6653 (diff)
downloadgnunet-ef2231cf7c1b83ac45c6fbe75f2ef73280815024.tar.gz
gnunet-ef2231cf7c1b83ac45c6fbe75f2ef73280815024.zip
- sync
Diffstat (limited to 'src/mesh/gnunet-service-mesh_local.c')
-rw-r--r--src/mesh/gnunet-service-mesh_local.c68
1 files changed, 2 insertions, 66 deletions
diff --git a/src/mesh/gnunet-service-mesh_local.c b/src/mesh/gnunet-service-mesh_local.c
index 6ee23e6e0..b77b7be8d 100644
--- a/src/mesh/gnunet-service-mesh_local.c
+++ b/src/mesh/gnunet-service-mesh_local.c
@@ -328,17 +328,12 @@ static void
328handle_channel_create (void *cls, struct GNUNET_SERVER_Client *client, 328handle_channel_create (void *cls, struct GNUNET_SERVER_Client *client,
329 const struct GNUNET_MessageHeader *message) 329 const struct GNUNET_MessageHeader *message)
330{ 330{
331 struct GNUNET_MESH_ChannelMessage *msg;
332 struct MeshPeer *peer;
333 struct MeshTunnel2 *t;
334 struct MeshChannel *ch;
335 struct MeshClient *c; 331 struct MeshClient *c;
336 MESH_ChannelNumber chid;
337 332
338 LOG (GNUNET_ERROR_TYPE_DEBUG, "new channel requested\n"); 333 LOG (GNUNET_ERROR_TYPE_DEBUG, "new channel requested\n");
339 334
340 /* Sanity check for client registration */ 335 /* Sanity check for client registration */
341 if (NULL == (c = client_get (client))) 336 if (NULL == (c = GML_client_get (client)))
342 { 337 {
343 GNUNET_break (0); 338 GNUNET_break (0);
344 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 339 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
@@ -354,66 +349,7 @@ handle_channel_create (void *cls, struct GNUNET_SERVER_Client *client,
354 return; 349 return;
355 } 350 }
356 351
357 msg = (struct GNUNET_MESH_ChannelMessage *) message; 352 GMCH_handle_local_create (c, (struct GNUNET_MESH_ChannelMessage *) message);
358 LOG (GNUNET_ERROR_TYPE_DEBUG, " towards %s:%u\n",
359 GNUNET_i2s (&msg->peer), ntohl (msg->port));
360 chid = ntohl (msg->channel_id);
361
362 /* Sanity check for duplicate channel IDs */
363 if (NULL != channel_get_by_local_id (c, chid))
364 {
365 GNUNET_break (0);
366 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
367 return;
368 }
369
370 peer = peer_get (&msg->peer);
371 if (NULL == peer->tunnel)
372 {
373 peer->tunnel = tunnel_new ();
374 peer->tunnel->peer = peer;
375 if (peer->id == myid)
376 {
377 tunnel_change_state (peer->tunnel, MESH_TUNNEL_READY);
378 }
379 else
380 {
381 peer_connect (peer);
382 }
383 }
384 t = peer->tunnel;
385
386 /* Create channel */
387 ch = channel_new (t, c, chid);
388 if (NULL == ch)
389 {
390 GNUNET_break (0);
391 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
392 return;
393 }
394 ch->port = ntohl (msg->port);
395 channel_set_options (ch, ntohl (msg->opt));
396
397 /* In unreliable channels, we'll use the DLL to buffer BCK data */
398 ch->root_rel = GNUNET_new (struct MeshChannelReliability);
399 ch->root_rel->ch = ch;
400 ch->root_rel->expected_delay = MESH_RETRANSMIT_TIME;
401
402 LOG (GNUNET_ERROR_TYPE_DEBUG, "CREATED CHANNEL %s[%x]:%u (%x)\n",
403 peer2s (t->peer), ch->gid, ch->port, ch->lid_root);
404
405 /* Send create channel */
406 {
407 struct GNUNET_MESH_ChannelCreate msgcc;
408
409 msgcc.header.size = htons (sizeof (msgcc));
410 msgcc.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE);
411 msgcc.chid = htonl (ch->gid);
412 msgcc.port = msg->port;
413 msgcc.opt = msg->opt;
414
415 GMT_queue_data (t, ch, &msgcc.header, GNUNET_YES);
416 }
417 353
418 GNUNET_SERVER_receive_done (client, GNUNET_OK); 354 GNUNET_SERVER_receive_done (client, GNUNET_OK);
419 return; 355 return;