diff options
Diffstat (limited to 'src/mesh')
-rw-r--r-- | src/mesh/mesh_api_new.c | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/src/mesh/mesh_api_new.c b/src/mesh/mesh_api_new.c index b639df812..a2e05e822 100644 --- a/src/mesh/mesh_api_new.c +++ b/src/mesh/mesh_api_new.c | |||
@@ -363,30 +363,30 @@ create_tunnel (struct GNUNET_MESH_Handle *h, MESH_TunnelNumber tid) | |||
363 | static void | 363 | static void |
364 | destroy_tunnel (struct GNUNET_MESH_Handle *h, MESH_TunnelNumber tid) | 364 | destroy_tunnel (struct GNUNET_MESH_Handle *h, MESH_TunnelNumber tid) |
365 | { | 365 | { |
366 | struct GNUNET_MESH_Tunnel *t; | 366 | struct GNUNET_MESH_Tunnel *t; |
367 | struct GNUNET_PeerIdentity pi; | 367 | struct GNUNET_PeerIdentity pi; |
368 | unsigned int i; | 368 | unsigned int i; |
369 | 369 | ||
370 | t = retrieve_tunnel(h, tid); | 370 | t = retrieve_tunnel (h, tid); |
371 | if (NULL == t) | 371 | if (NULL == t) |
372 | { | 372 | { |
373 | GNUNET_break (0); | 373 | GNUNET_break (0); |
374 | return; | ||
375 | } | ||
376 | GNUNET_CONTAINER_DLL_remove (h->tunnels_head, h->tunnels_tail, t); | ||
377 | for (i = 0; i < t->npeers; i++) | ||
378 | { | ||
379 | GNUNET_PEER_resolve(t->peers[i]->id, &pi); | ||
380 | t->disconnect_handler(t->cls, &pi); | ||
381 | GNUNET_PEER_change_rc(t->peers[i]->id, -1); | ||
382 | GNUNET_free (t->peers[i]); | ||
383 | } | ||
384 | h->cleaner(h->cls, t, NULL); /* FIXME ctx? */ | ||
385 | if (0 != t->owner) | ||
386 | GNUNET_PEER_change_rc(t->owner, -1); | ||
387 | GNUNET_free(t->peers); | ||
388 | GNUNET_free(t); | ||
389 | return; | 374 | return; |
375 | } | ||
376 | GNUNET_CONTAINER_DLL_remove (h->tunnels_head, h->tunnels_tail, t); | ||
377 | for (i = 0; i < t->npeers; i++) | ||
378 | { | ||
379 | GNUNET_PEER_resolve (t->peers[i]->id, &pi); | ||
380 | t->disconnect_handler (t->cls, &pi); | ||
381 | GNUNET_PEER_change_rc (t->peers[i]->id, -1); | ||
382 | GNUNET_free (t->peers[i]); | ||
383 | } | ||
384 | h->cleaner (h->cls, t, NULL); /* FIXME ctx? */ | ||
385 | if (0 != t->owner) | ||
386 | GNUNET_PEER_change_rc (t->owner, -1); | ||
387 | GNUNET_free (t->peers); | ||
388 | GNUNET_free (t); | ||
389 | return; | ||
390 | } | 390 | } |
391 | 391 | ||
392 | 392 | ||
@@ -600,7 +600,7 @@ process_tunnel_create (struct GNUNET_MESH_Handle *h, | |||
600 | t->cls = h->cls; | 600 | t->cls = h->cls; |
601 | t->mesh = h; | 601 | t->mesh = h; |
602 | t->tid = tid; | 602 | t->tid = tid; |
603 | GNUNET_CONTAINER_DLL_insert(h->tunnels_head, h->tunnels_tail, t); | 603 | GNUNET_CONTAINER_DLL_insert (h->tunnels_head, h->tunnels_tail, t); |
604 | return; | 604 | return; |
605 | } | 605 | } |
606 | 606 | ||
@@ -615,17 +615,17 @@ static void | |||
615 | process_tunnel_destroy (struct GNUNET_MESH_Handle *h, | 615 | process_tunnel_destroy (struct GNUNET_MESH_Handle *h, |
616 | const struct GNUNET_MESH_TunnelMessage *msg) | 616 | const struct GNUNET_MESH_TunnelMessage *msg) |
617 | { | 617 | { |
618 | struct GNUNET_MESH_Tunnel *t; | 618 | struct GNUNET_MESH_Tunnel *t; |
619 | MESH_TunnelNumber tid; | 619 | MESH_TunnelNumber tid; |
620 | 620 | ||
621 | tid = ntohl (msg->tunnel_id); | 621 | tid = ntohl (msg->tunnel_id); |
622 | t = retrieve_tunnel(h, tid); | 622 | t = retrieve_tunnel (h, tid); |
623 | 623 | ||
624 | t->cls = h->cls; | 624 | t->cls = h->cls; |
625 | t->mesh = h; | 625 | t->mesh = h; |
626 | t->tid = tid; | 626 | t->tid = tid; |
627 | GNUNET_CONTAINER_DLL_insert(h->tunnels_head, h->tunnels_tail, t); | 627 | GNUNET_CONTAINER_DLL_insert (h->tunnels_head, h->tunnels_tail, t); |
628 | return; | 628 | return; |
629 | } | 629 | } |
630 | 630 | ||
631 | 631 | ||
@@ -1101,21 +1101,21 @@ GNUNET_MESH_tunnel_create (struct GNUNET_MESH_Handle *h, | |||
1101 | * @param tun tunnel handle | 1101 | * @param tun tunnel handle |
1102 | */ | 1102 | */ |
1103 | void | 1103 | void |
1104 | GNUNET_MESH_tunnel_destroy (struct GNUNET_MESH_Tunnel *t) | 1104 | GNUNET_MESH_tunnel_destroy (struct GNUNET_MESH_Tunnel *tun) |
1105 | { | 1105 | { |
1106 | struct GNUNET_MESH_Handle *h; | 1106 | struct GNUNET_MESH_Handle *h; |
1107 | struct GNUNET_MESH_TunnelMessage msg; | 1107 | struct GNUNET_MESH_TunnelMessage msg; |
1108 | 1108 | ||
1109 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: Destroying tunnel\n"); | 1109 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: Destroying tunnel\n"); |
1110 | h = t->mesh; | 1110 | h = tun->mesh; |
1111 | 1111 | ||
1112 | if (0 != t->owner) | 1112 | if (0 != tun->owner) |
1113 | GNUNET_PEER_change_rc (t->owner, -1); | 1113 | GNUNET_PEER_change_rc (tun->owner, -1); |
1114 | 1114 | ||
1115 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY); | 1115 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY); |
1116 | msg.header.size = htons (sizeof (struct GNUNET_MESH_TunnelMessage)); | 1116 | msg.header.size = htons (sizeof (struct GNUNET_MESH_TunnelMessage)); |
1117 | msg.tunnel_id = htonl (t->tid); | 1117 | msg.tunnel_id = htonl (tun->tid); |
1118 | GNUNET_free (t); | 1118 | GNUNET_free (tun); |
1119 | send_packet (h, &msg.header); | 1119 | send_packet (h, &msg.header); |
1120 | } | 1120 | } |
1121 | 1121 | ||