gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r15615 - gnunet/src/vpn


From: gnunet
Subject: [GNUnet-SVN] r15615 - gnunet/src/vpn
Date: Wed, 15 Jun 2011 09:15:43 +0200

Author: toelke
Date: 2011-06-15 09:15:43 +0200 (Wed, 15 Jun 2011)
New Revision: 15615

Modified:
   gnunet/src/vpn/gnunet-daemon-exit.c
Log:
make the exit configurable;

Modified: gnunet/src/vpn/gnunet-daemon-exit.c
===================================================================
--- gnunet/src/vpn/gnunet-daemon-exit.c 2011-06-15 07:15:42 UTC (rev 15614)
+++ gnunet/src/vpn/gnunet-daemon-exit.c 2011-06-15 07:15:43 UTC (rev 15615)
@@ -1174,6 +1174,56 @@
   return GNUNET_YES;
 }
 
+static void
+connect_to_mesh()
+{
+  int udp, tcp;
+  int handler_idx, app_idx;
+
+  udp = GNUNET_CONFIGURATION_get_value_yesno(cfg, "exit", "ENABLE_UDP");
+  tcp = GNUNET_CONFIGURATION_get_value_yesno(cfg, "exit", "ENABLE_TCP");
+
+  static struct GNUNET_MESH_MessageHandler handlers[] = {
+    {receive_udp_service, GNUNET_MESSAGE_TYPE_SERVICE_UDP, 0},
+    {receive_tcp_service, GNUNET_MESSAGE_TYPE_SERVICE_TCP, 0},
+    {NULL, 0, 0},
+    {NULL, 0, 0},
+    {NULL, 0, 0}
+  };
+
+  static GNUNET_MESH_ApplicationType apptypes[] =
+    {
+      GNUNET_APPLICATION_TYPE_END,
+      GNUNET_APPLICATION_TYPE_END,
+      GNUNET_APPLICATION_TYPE_END
+    };
+
+  app_idx = 0;
+  handler_idx = 2;
+
+  if (GNUNET_YES == udp)
+    {
+      handlers[handler_idx].callback = receive_udp_remote;
+      handlers[handler_idx].expected_size = 0;
+      handlers[handler_idx].type = GNUNET_MESSAGE_TYPE_REMOTE_UDP;
+      apptypes[app_idx] = GNUNET_APPLICATION_TYPE_INTERNET_UDP_GATEWAY;
+      handler_idx++;
+      app_idx++;
+    }
+
+  if (GNUNET_YES == tcp)
+    {
+      handlers[handler_idx].callback = receive_tcp_remote;
+      handlers[handler_idx].expected_size = 0;
+      handlers[handler_idx].type = GNUNET_MESSAGE_TYPE_REMOTE_TCP;
+      apptypes[app_idx] = GNUNET_APPLICATION_TYPE_INTERNET_TCP_GATEWAY;
+      handler_idx++;
+      app_idx++;
+    }
+
+  mesh_handle = GNUNET_MESH_connect (cfg, NULL, NULL, handlers, apptypes);
+}
+
 /**
  * @brief Main function that will be run by the scheduler.
  *
@@ -1187,24 +1237,10 @@
      char *const *args __attribute__((unused)),
      const char *cfgfile __attribute__((unused)), const struct 
GNUNET_CONFIGURATION_Handle *cfg_)
 {
-  static const struct GNUNET_MESH_MessageHandler handlers[] = {
-    {receive_udp_service, GNUNET_MESSAGE_TYPE_SERVICE_UDP, 0},
-    {receive_tcp_service, GNUNET_MESSAGE_TYPE_SERVICE_TCP, 0},
-    {receive_udp_remote,  GNUNET_MESSAGE_TYPE_REMOTE_UDP, 0},
-    {receive_tcp_remote,  GNUNET_MESSAGE_TYPE_REMOTE_TCP, 0},
-    {NULL, 0, 0}
-  };
+  cfg = cfg_;
 
-  static const GNUNET_MESH_ApplicationType apptypes[] =
-    {
-      GNUNET_APPLICATION_TYPE_INTERNET_TCP_GATEWAY,
-      GNUNET_APPLICATION_TYPE_INTERNET_UDP_GATEWAY,
-      GNUNET_APPLICATION_TYPE_END
-    };
+  connect_to_mesh();
 
-  mesh_handle = GNUNET_MESH_connect (cfg_, NULL, NULL, handlers, apptypes);
-
-  cfg = cfg_;
   udp_connections = GNUNET_CONTAINER_multihashmap_create (65536);
   udp_connections_heap =
     GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]