aboutsummaryrefslogtreecommitdiff
path: root/src/vpn
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-09-22 14:41:24 +0000
committerChristian Grothoff <christian@grothoff.org>2013-09-22 14:41:24 +0000
commit2e1bfb2f75c216e0dbacb31a9e58e01bd1dff6d4 (patch)
treee4427969b7ed0161722484ca04f034d431390f9b /src/vpn
parentf3658260ec94e9874e0c773c762b4b49fda29b8e (diff)
downloadgnunet-2e1bfb2f75c216e0dbacb31a9e58e01bd1dff6d4.tar.gz
gnunet-2e1bfb2f75c216e0dbacb31a9e58e01bd1dff6d4.zip
-dead code elimination in VPN
Diffstat (limited to 'src/vpn')
-rw-r--r--src/vpn/gnunet-service-vpn.c79
1 files changed, 4 insertions, 75 deletions
diff --git a/src/vpn/gnunet-service-vpn.c b/src/vpn/gnunet-service-vpn.c
index 2b5b41e14..f26369d11 100644
--- a/src/vpn/gnunet-service-vpn.c
+++ b/src/vpn/gnunet-service-vpn.c
@@ -218,11 +218,6 @@ struct TunnelState
218 struct DestinationEntry destination; 218 struct DestinationEntry destination;
219 219
220 /** 220 /**
221 * Task scheduled to destroy the tunnel (or NO_TASK).
222 */
223 GNUNET_SCHEDULER_TaskIdentifier destroy_task;
224
225 /**
226 * Addess family used for this tunnel on the local TUN interface. 221 * Addess family used for this tunnel on the local TUN interface.
227 */ 222 */
228 int af; 223 int af;
@@ -536,11 +531,6 @@ free_tunnel_state (struct TunnelState *ts)
536 GNUNET_REGEX_search_cancel (ts->search); 531 GNUNET_REGEX_search_cancel (ts->search);
537 ts->search = NULL; 532 ts->search = NULL;
538 } 533 }
539 if (GNUNET_SCHEDULER_NO_TASK != ts->destroy_task)
540 {
541 GNUNET_SCHEDULER_cancel (ts->destroy_task);
542 ts->destroy_task = GNUNET_SCHEDULER_NO_TASK;
543 }
544 if (NULL != ts->heap_node) 534 if (NULL != ts->heap_node)
545 { 535 {
546 GNUNET_CONTAINER_heap_remove_node (ts->heap_node); 536 GNUNET_CONTAINER_heap_remove_node (ts->heap_node);
@@ -568,63 +558,6 @@ free_tunnel_state (struct TunnelState *ts)
568 558
569 559
570/** 560/**
571 * Destroy the mesh tunnel.
572 *
573 * @param cls the `struct TunnelState` with the tunnel to destroy
574 * @param tc scheduler context
575 */
576static void
577destroy_tunnel_task (void *cls,
578 const struct GNUNET_SCHEDULER_TaskContext *tc)
579{
580 struct TunnelState *ts = cls;
581 struct GNUNET_MESH_Tunnel *tunnel;
582
583 ts->destroy_task = GNUNET_SCHEDULER_NO_TASK;
584 GNUNET_assert (NULL != ts->tunnel);
585 tunnel = ts->tunnel;
586 ts->tunnel = NULL;
587 GNUNET_MESH_tunnel_destroy (tunnel);
588 free_tunnel_state (ts);
589}
590
591
592/**
593 * Method called whenever a peer has disconnected from the tunnel.
594 *
595 * FIXME merge with inbound_cleaner
596 *
597 * @param cls closure
598 * @param peer peer identity the tunnel stopped working with
599 */
600void
601tunnel_peer_disconnect_handler (void *cls,
602 const struct
603 GNUNET_PeerIdentity *peer)
604{
605 struct TunnelState *ts = cls;
606
607 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
608 "Peer %s disconnected from tunnel.\n",
609 GNUNET_i2s (peer));
610 GNUNET_STATISTICS_update (stats,
611 gettext_noop ("# peers connected to mesh tunnels"),
612 -1, GNUNET_NO);
613 if (NULL != ts->th)
614 {
615 GNUNET_MESH_notify_transmit_ready_cancel (ts->th);
616 ts->th = NULL;
617 }
618 if (ts->destination.is_service)
619 return; /* hope for reconnect eventually */
620 /* as we are most likely going to change the exit node now,
621 we should just destroy the tunnel entirely... */
622 if (GNUNET_SCHEDULER_NO_TASK == ts->destroy_task)
623 ts->destroy_task = GNUNET_SCHEDULER_add_now (&destroy_tunnel_task, ts);
624}
625
626
627/**
628 * Send a message from the message queue via mesh. 561 * Send a message from the message queue via mesh.
629 * 562 *
630 * @param cls the `struct TunnelState` with the message queue 563 * @param cls the `struct TunnelState` with the message queue
@@ -752,13 +685,11 @@ handle_regex_result (void *cls,
752 * 685 *
753 * @param de destination entry for which we need to setup a tunnel 686 * @param de destination entry for which we need to setup a tunnel
754 * @param client_af address family of the address returned to the client 687 * @param client_af address family of the address returned to the client
755 * @param request_id request ID to send in client notification (unused if client is NULL)
756 * @return tunnel state of the tunnel that was created 688 * @return tunnel state of the tunnel that was created
757 */ 689 */
758static struct TunnelState * 690static struct TunnelState *
759create_tunnel_to_destination (struct DestinationEntry *de, 691create_tunnel_to_destination (struct DestinationEntry *de,
760 int client_af, 692 int client_af)
761 uint64_t request_id)
762{ 693{
763 struct TunnelState *ts; 694 struct TunnelState *ts;
764 695
@@ -1041,7 +972,7 @@ route_packet (struct DestinationEntry *destination,
1041 available) or create a fresh one */ 972 available) or create a fresh one */
1042 is_new = GNUNET_YES; 973 is_new = GNUNET_YES;
1043 if (NULL == destination->ts) 974 if (NULL == destination->ts)
1044 ts = create_tunnel_to_destination (destination, af, 0); 975 ts = create_tunnel_to_destination (destination, af);
1045 else 976 else
1046 ts = destination->ts; 977 ts = destination->ts;
1047 if (NULL == ts) 978 if (NULL == ts)
@@ -2646,8 +2577,7 @@ service_redirect_to_ip (void *cls,
2646 2577
2647 /* setup tunnel to destination */ 2578 /* setup tunnel to destination */
2648 ts = create_tunnel_to_destination (de, 2579 ts = create_tunnel_to_destination (de,
2649 result_af, 2580 result_af);
2650 msg->request_id);
2651 switch (result_af) 2581 switch (result_af)
2652 { 2582 {
2653 case AF_INET: 2583 case AF_INET:
@@ -2741,8 +2671,7 @@ service_redirect_to_service (void *cls GNUNET_UNUSED, struct GNUNET_SERVER_Clien
2741 while (GNUNET_CONTAINER_multihashmap_size (destination_map) > max_destination_mappings) 2671 while (GNUNET_CONTAINER_multihashmap_size (destination_map) > max_destination_mappings)
2742 expire_destination (de); 2672 expire_destination (de);
2743 ts = create_tunnel_to_destination (de, 2673 ts = create_tunnel_to_destination (de,
2744 result_af, 2674 result_af);
2745 msg->request_id);
2746 switch (result_af) 2675 switch (result_af)
2747 { 2676 {
2748 case AF_INET: 2677 case AF_INET: