-convert vpn/exit/pt to use new CADET ports
authorChristian Grothoff <christian@grothoff.org>
Thu, 11 Aug 2016 13:02:01 +0000 (13:02 +0000)
committerChristian Grothoff <christian@grothoff.org>
Thu, 11 Aug 2016 13:02:01 +0000 (13:02 +0000)
src/exit/gnunet-daemon-exit.c
src/include/gnunet_applications.h
src/include/gnunet_common.h
src/pt/gnunet-daemon-pt.c
src/testbed/gnunet-service-testbed_barriers.c
src/util/crypto_kdf.c
src/vpn/gnunet-service-vpn.c
src/vpn/vpn_api.c

index 2b9ddc722aef6a93466d3aa3726ca41145ca800e..c8a2e85ef2ae9f42cf330e4eee5ed5bff570e2a2 100644 (file)
@@ -3480,81 +3480,30 @@ do_dht_put (void *cls)
                            sizeof (struct GNUNET_DNS_Advertisement),
                            &dns_advertisement,
                            expiration,
-                           &dht_put_cont, NULL);
+                           &dht_put_cont,
+                            NULL);
 }
 
 
 /**
- * @brief Main function that will be run by the scheduler.
- *
- * @param cls closure
- * @param args remaining command-line arguments
- * @param cfgfile name of the configuration file used (for saving, can be NULL!)
- * @param cfg_ configuration
+ * Figure out which IP versions we should support (and which
+ * are supported by the OS) according to our configuration.
  */
 static void
-run (void *cls,
-     char *const *args,
-     const char *cfgfile,
-     const struct GNUNET_CONFIGURATION_Handle *cfg_)
+parse_ip_options ()
 {
-  static struct GNUNET_CADET_MessageHandler handlers[] = {
-    {&receive_icmp_service, GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_SERVICE, 0},
-    {&receive_icmp_remote, GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_INTERNET, 0},
-    {&receive_udp_service, GNUNET_MESSAGE_TYPE_VPN_UDP_TO_SERVICE, 0},
-    {&receive_udp_remote, GNUNET_MESSAGE_TYPE_VPN_UDP_TO_INTERNET, 0},
-    {&receive_tcp_service, GNUNET_MESSAGE_TYPE_VPN_TCP_TO_SERVICE_START, 0},
-    {&receive_tcp_remote, GNUNET_MESSAGE_TYPE_VPN_TCP_TO_INTERNET_START, 0},
-    {&receive_tcp_data, GNUNET_MESSAGE_TYPE_VPN_TCP_DATA_TO_EXIT, 0},
-    {&receive_dns_request, GNUNET_MESSAGE_TYPE_VPN_DNS_TO_INTERNET, 0},
-    {NULL, 0, 0}
-  };
-
-  static uint32_t apptypes[] = {
-    GNUNET_APPLICATION_TYPE_END,
-    GNUNET_APPLICATION_TYPE_END,
-    GNUNET_APPLICATION_TYPE_END,
-    GNUNET_APPLICATION_TYPE_END
-  };
-  unsigned int app_idx;
-  char *exit_ifname;
-  char *tun_ifname;
-  char *policy;
-  char *ipv6addr;
-  char *ipv6prefix_s;
-  char *ipv4addr;
-  char *ipv4mask;
-  char *binary;
-  char *regex;
-  char *prefixed_regex;
-  struct in_addr dns_exit4;
-  struct in6_addr dns_exit6;
-  char *dns_exit;
-
-  cfg = cfg_;
-  ipv4_exit = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "EXIT_IPV4");
-  ipv6_exit = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "EXIT_IPV6");
-  ipv4_enabled = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "ENABLE_IPV4");
-  ipv6_enabled = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "ENABLE_IPV6");
-  if ( (ipv4_exit) || (ipv6_exit) )
-  {
-    binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-exit");
-    if (GNUNET_YES !=
-       GNUNET_OS_check_helper_binary (binary, GNUNET_YES, "-d gnunet-vpn - - - 169.1.3.3.7 255.255.255.0")) //no nat, ipv4 only
-    {
-      GNUNET_free (binary);
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                 _("`%s' must be installed SUID, EXIT will not work\n"),
-                 "gnunet-helper-exit");
-      GNUNET_SCHEDULER_add_shutdown (&dummy_task,
-                                    NULL);
-      global_ret = 1;
-      return;
-    }
-    GNUNET_free (binary);
-  }
-  stats = GNUNET_STATISTICS_create ("exit", cfg);
-
+  ipv4_exit = GNUNET_CONFIGURATION_get_value_yesno (cfg,
+                                                    "exit",
+                                                    "EXIT_IPV4");
+  ipv6_exit = GNUNET_CONFIGURATION_get_value_yesno (cfg,
+                                                    "exit",
+                                                    "EXIT_IPV6");
+  ipv4_enabled = GNUNET_CONFIGURATION_get_value_yesno (cfg,
+                                                       "exit",
+                                                       "ENABLE_IPV4");
+  ipv6_enabled = GNUNET_CONFIGURATION_get_value_yesno (cfg,
+                                                       "exit",
+                                                       "ENABLE_IPV6");
   if ( (ipv4_exit || ipv4_enabled) &&
        GNUNET_OK != GNUNET_NETWORK_test_pf (PF_INET))
   {
@@ -3583,83 +3532,110 @@ run (void *cls,
                _("Cannot enable IPv6 exit but disable IPv6 on TUN interface, will use ENABLE_IPv6=YES\n"));
     ipv6_enabled = GNUNET_YES;
   }
-  if (! (ipv4_enabled || ipv6_enabled))
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-               _("No useful service enabled.  Exiting.\n"));
-    GNUNET_SCHEDULER_shutdown ();
-    return;
-  }
+}
+
+
+/**
+ * Helper function to open the CADET port for DNS exits and to
+ * advertise the DNS exit (if applicable).
+ */
+static void
+advertise_dns_exit ()
+{
+  char *dns_exit;
+  struct GNUNET_HashCode port;
+  struct in_addr dns_exit4;
+  struct in6_addr dns_exit6;
 
-  dns_exit = NULL;
-  if ( (GNUNET_YES ==
-       GNUNET_CONFIGURATION_get_value_yesno (cfg_, "exit", "EXIT_DNS")) &&
-       ( (GNUNET_OK !=
-         GNUNET_CONFIGURATION_get_value_string (cfg, "exit",
-                                                "DNS_RESOLVER",
-                                                &dns_exit)) ||
-        ( (1 != inet_pton (AF_INET, dns_exit, &dns_exit4)) &&
-          (1 != inet_pton (AF_INET6, dns_exit, &dns_exit6)) ) ) )
+  if (GNUNET_YES !=
+      GNUNET_CONFIGURATION_get_value_yesno (cfg,
+                                            "exit",
+                                            "EXIT_DNS"))
+    return;
+  if ( (GNUNET_OK !=
+        GNUNET_CONFIGURATION_get_value_string (cfg,
+                                               "exit",
+                                               "DNS_RESOLVER",
+                                               &dns_exit)) ||
+       ( (1 != inet_pton (AF_INET,
+                          dns_exit,
+                          &dns_exit4)) &&
+         (1 != inet_pton (AF_INET6,
+                          dns_exit,
+                          &dns_exit6)) ) )
   {
     GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
-                              "dns", "DNS_RESOLVER",
+                              "dns",
+                               "DNS_RESOLVER",
                               _("need a valid IPv4 or IPv6 address\n"));
-    GNUNET_free_non_null (dns_exit);
-    dns_exit = NULL;
-  }
-  app_idx = 0;
-  if (GNUNET_YES == ipv4_exit)
-  {
-    apptypes[app_idx] = GNUNET_APPLICATION_TYPE_IPV4_GATEWAY;
-    app_idx++;
-  }
-  if (GNUNET_YES == ipv6_exit)
-  {
-    apptypes[app_idx] = GNUNET_APPLICATION_TYPE_IPV6_GATEWAY;
-    app_idx++;
-  }
-  if (NULL != dns_exit)
-  {
-    dht = GNUNET_DHT_connect (cfg, 1);
-    peer_key = GNUNET_CRYPTO_eddsa_key_create_from_configuration (cfg);
-    GNUNET_CRYPTO_eddsa_key_get_public (peer_key,
-                                                   &dns_advertisement.peer.public_key);
-    dns_advertisement.purpose.size = htonl (sizeof (struct GNUNET_DNS_Advertisement) -
-                                           sizeof (struct GNUNET_CRYPTO_EddsaSignature));
-    dns_advertisement.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_DNS_RECORD);
-    GNUNET_CRYPTO_hash ("dns",
-                       strlen ("dns"),
-                       &dht_put_key);
-    dht_task = GNUNET_SCHEDULER_add_now (&do_dht_put,
-                                        NULL);
-    apptypes[app_idx] = GNUNET_APPLICATION_TYPE_INTERNET_RESOLVER;
-    app_idx++;
-  }
-  GNUNET_free_non_null (dns_exit);
-  GNUNET_SCHEDULER_add_shutdown (&cleanup,
-                                NULL);
+    return;
+  }
+  /* open port */
+  GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_INTERNET_RESOLVER,
+                      strlen (GNUNET_APPLICATION_PORT_INTERNET_RESOLVER),
+                      &port);
+  GNUNET_CADET_open_port (cadet_handle,
+                          &port,
+                          &new_channel,
+                          NULL);
+  /* advertise exit */
+  dht = GNUNET_DHT_connect (cfg,
+                            1);
+  peer_key = GNUNET_CRYPTO_eddsa_key_create_from_configuration (cfg);
+  GNUNET_CRYPTO_eddsa_key_get_public (peer_key,
+                                      &dns_advertisement.peer.public_key);
+  dns_advertisement.purpose.size = htonl (sizeof (struct GNUNET_DNS_Advertisement) -
+                                          sizeof (struct GNUNET_CRYPTO_EddsaSignature));
+  dns_advertisement.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_DNS_RECORD);
+  GNUNET_CRYPTO_hash ("dns",
+                      strlen ("dns"),
+                      &dht_put_key);
+  dht_task = GNUNET_SCHEDULER_add_now (&do_dht_put,
+                                       NULL);
+  GNUNET_free (dns_exit);
+}
+
+
+/**
+ * Initialize #exit_argv.
+ *
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR if we should shutdown
+ */
+static int
+setup_exit_helper_args ()
+{
+  char *exit_ifname;
+  char *tun_ifname;
+  char *ipv6addr;
+  char *ipv6prefix_s;
+  char *ipv4addr;
+  char *ipv4mask;
 
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_number (cfg, "exit", "MAX_CONNECTIONS",
-                                             &max_connections))
-    max_connections = 1024;
   exit_argv[0] = GNUNET_strdup ("exit-gnunet");
   if (GNUNET_SYSERR ==
-      GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "TUN_IFNAME", &tun_ifname))
+      GNUNET_CONFIGURATION_get_value_string (cfg,
+                                             "exit",
+                                             "TUN_IFNAME",
+                                             &tun_ifname))
   {
-    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "EXIT", "TUN_IFNAME");
-    GNUNET_SCHEDULER_shutdown ();
-    return;
+    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+                               "EXIT",
+                               "TUN_IFNAME");
+    return GNUNET_SYSERR;
   }
   exit_argv[1] = tun_ifname;
   if (ipv4_enabled)
   {
     if (GNUNET_SYSERR ==
-       GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "EXIT_IFNAME", &exit_ifname))
+       GNUNET_CONFIGURATION_get_value_string (cfg,
+                                               "exit",
+                                               "EXIT_IFNAME",
+                                               &exit_ifname))
     {
-      GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "EXIT", "EXIT_IFNAME");
-      GNUNET_SCHEDULER_shutdown ();
-      return;
+      GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+                                 "EXIT",
+                                 "EXIT_IFNAME");
+      return GNUNET_SYSERR;
     }
     exit_argv[2] = exit_ifname;
   }
@@ -3668,7 +3644,6 @@ run (void *cls,
     exit_argv[2] = GNUNET_strdup ("-");
   }
 
-
   if (GNUNET_YES == ipv6_enabled)
   {
     ipv6addr = NULL;
@@ -3677,33 +3652,41 @@ run (void *cls,
                                                  "exit",
                                                  "IPV6ADDR",
                                                 &ipv6addr) ||
-         (1 != inet_pton (AF_INET6, ipv6addr, &exit_ipv6addr))) )
+         (1 != inet_pton (AF_INET6,
+                           ipv6addr,
+                           &exit_ipv6addr))) )
     {
-      GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "EXIT", "IPV6ADDR");
-      GNUNET_SCHEDULER_shutdown ();
+      GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+                                 "EXIT",
+                                 "IPV6ADDR");
       GNUNET_free_non_null (ipv6addr);
-      return;
+      return GNUNET_SYSERR;
     }
     exit_argv[3] = ipv6addr;
     if (GNUNET_SYSERR ==
-       GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV6PREFIX",
+       GNUNET_CONFIGURATION_get_value_string (cfg,
+                                               "exit",
+                                               "IPV6PREFIX",
                                               &ipv6prefix_s))
     {
-      GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "EXIT", "IPV6PREFIX");
-      GNUNET_SCHEDULER_shutdown ();
-      return;
+      GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+                                 "EXIT",
+                                 "IPV6PREFIX");
+      return GNUNET_SYSERR;
     }
     exit_argv[4] = ipv6prefix_s;
     if ( (GNUNET_OK !=
-         GNUNET_CONFIGURATION_get_value_number (cfg, "exit",
+         GNUNET_CONFIGURATION_get_value_number (cfg,
+                                                 "exit",
                                                 "IPV6PREFIX",
                                                 &ipv6prefix)) ||
         (ipv6prefix >= 127) )
     {
-      GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, "EXIT", "IPV6PREFIX",
+      GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
+                                 "EXIT",
+                                 "IPV6PREFIX",
                                 _("Must be a number"));
-      GNUNET_SCHEDULER_shutdown ();
-      return;
+      return GNUNET_SYSERR;
     }
   }
   else
@@ -3716,26 +3699,36 @@ run (void *cls,
   {
     ipv4addr = NULL;
     if ( (GNUNET_SYSERR ==
-         GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV4ADDR",
+         GNUNET_CONFIGURATION_get_value_string (cfg,
+                                                 "exit",
+                                                 "IPV4ADDR",
                                                 &ipv4addr) ||
-         (1 != inet_pton (AF_INET, ipv4addr, &exit_ipv4addr))) )
+         (1 != inet_pton (AF_INET,
+                           ipv4addr,
+                           &exit_ipv4addr))) )
       {
-       GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "EXIT", "IPV4ADDR");
-       GNUNET_SCHEDULER_shutdown ();
+       GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+                                   "EXIT",
+                                   "IPV4ADDR");
         GNUNET_free_non_null (ipv4addr);
-       return;
+       return GNUNET_SYSERR;
       }
     exit_argv[5] = ipv4addr;
     ipv4mask = NULL;
     if ( (GNUNET_SYSERR ==
-         GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV4MASK",
+         GNUNET_CONFIGURATION_get_value_string (cfg,
+                                                 "exit",
+                                                 "IPV4MASK",
                                                 &ipv4mask) ||
-         (1 != inet_pton (AF_INET, ipv4mask, &exit_ipv4mask))) )
+         (1 != inet_pton (AF_INET,
+                           ipv4mask,
+                           &exit_ipv4mask))) )
     {
-      GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "EXIT", "IPV4MASK");
-      GNUNET_SCHEDULER_shutdown ();
+      GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+                                 "EXIT",
+                                 "IPV4MASK");
       GNUNET_free_non_null (ipv4mask);
-      return;
+      return GNUNET_SYSERR;
     }
     exit_argv[6] = ipv4mask;
   }
@@ -3746,38 +3739,119 @@ run (void *cls,
     exit_argv[6] = GNUNET_strdup ("-");
   }
   exit_argv[7] = NULL;
+  return GNUNET_OK;
+}
 
-  udp_services = GNUNET_CONTAINER_multihashmap_create (65536, GNUNET_NO);
-  tcp_services = GNUNET_CONTAINER_multihashmap_create (65536, GNUNET_NO);
-  GNUNET_CONFIGURATION_iterate_sections (cfg, &read_service_conf, NULL);
 
-  connections_map = GNUNET_CONTAINER_multihashmap_create (65536, GNUNET_NO);
-  connections_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
-  if (0 == app_idx)
+/**
+ * @brief Main function that will be run by the scheduler.
+ *
+ * @param cls closure
+ * @param args remaining command-line arguments
+ * @param cfgfile name of the configuration file used (for saving, can be NULL!)
+ * @param cfg_ configuration
+ */
+static void
+run (void *cls,
+     char *const *args,
+     const char *cfgfile,
+     const struct GNUNET_CONFIGURATION_Handle *cfg_)
+{
+  static struct GNUNET_CADET_MessageHandler handlers[] = {
+    {&receive_icmp_service, GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_SERVICE, 0},
+    {&receive_icmp_remote, GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_INTERNET, 0},
+    {&receive_udp_service, GNUNET_MESSAGE_TYPE_VPN_UDP_TO_SERVICE, 0},
+    {&receive_udp_remote, GNUNET_MESSAGE_TYPE_VPN_UDP_TO_INTERNET, 0},
+    {&receive_tcp_service, GNUNET_MESSAGE_TYPE_VPN_TCP_TO_SERVICE_START, 0},
+    {&receive_tcp_remote, GNUNET_MESSAGE_TYPE_VPN_TCP_TO_INTERNET_START, 0},
+    {&receive_tcp_data, GNUNET_MESSAGE_TYPE_VPN_TCP_DATA_TO_EXIT, 0},
+    {&receive_dns_request, GNUNET_MESSAGE_TYPE_VPN_DNS_TO_INTERNET, 0},
+    {NULL, 0, 0}
+  };
+  struct GNUNET_HashCode port;
+  char *policy;
+  char *binary;
+  char *regex;
+  char *prefixed_regex;
+
+  cfg = cfg_;
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_number (cfg,
+                                             "exit",
+                                             "MAX_CONNECTIONS",
+                                             &max_connections))
+    max_connections = 1024;
+  parse_ip_options ();
+  if ( (ipv4_exit) || (ipv6_exit) )
+  {
+    binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-exit");
+    if (GNUNET_YES !=
+       GNUNET_OS_check_helper_binary (binary,
+                                       GNUNET_YES,
+                                       "-d gnunet-vpn - - - 169.1.3.3.7 255.255.255.0")) //no nat, ipv4 only
+    {
+      GNUNET_free (binary);
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                 _("`%s' must be installed SUID, EXIT will not work\n"),
+                 "gnunet-helper-exit");
+      GNUNET_SCHEDULER_add_shutdown (&dummy_task,
+                                    NULL);
+      global_ret = 1;
+      return;
+    }
+    GNUNET_free (binary);
+  }
+  if (! (ipv4_enabled || ipv6_enabled))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                _("No useful service enabled.  Exiting.\n"));
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
-  cadet_handle = GNUNET_CADET_connect (cfg, NULL, &clean_channel, handlers);
+
+  GNUNET_SCHEDULER_add_shutdown (&cleanup,
+                                NULL);
+  stats = GNUNET_STATISTICS_create ("exit",
+                                    cfg);
+  cadet_handle = GNUNET_CADET_connect (cfg,
+                                       NULL,
+                                       &clean_channel,
+                                       handlers);
   if (NULL == cadet_handle)
   {
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
-  for (int i = 0;
-       GNUNET_APPLICATION_TYPE_END != apptypes[i]
-       && i < sizeof (apptypes)/sizeof (*apptypes);
-       i++)
+  advertise_dns_exit ();
+  if (GNUNET_OK !=
+      setup_exit_helper_args ())
   {
-    GNUNET_CADET_open_port (cadet_handle, GC_u2h (apptypes[i]),
-                            &new_channel, NULL);
+    GNUNET_SCHEDULER_shutdown ();
+    return;
   }
 
-  /* Cadet handle acquired, now announce regular expressions matching our exit */
+  udp_services = GNUNET_CONTAINER_multihashmap_create (65536,
+                                                       GNUNET_NO);
+  tcp_services = GNUNET_CONTAINER_multihashmap_create (65536,
+                                                       GNUNET_NO);
+  connections_map = GNUNET_CONTAINER_multihashmap_create (65536,
+                                                          GNUNET_NO);
+  connections_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
+  GNUNET_CONFIGURATION_iterate_sections (cfg,
+                                         &read_service_conf,
+                                         NULL);
+
+  /* Cadet handle acquired, now open ports and announce regular
+     expressions matching our exit */
   if ( (GNUNET_YES == ipv4_enabled) && (GNUNET_YES == ipv4_exit) )
   {
+    GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_IPV4_GATEWAY,
+                        strlen (GNUNET_APPLICATION_PORT_IPV4_GATEWAY),
+                        &port);
+    GNUNET_CADET_open_port (cadet_handle,
+                            &port,
+                            &new_channel,
+                            NULL);
     policy = NULL;
     if (GNUNET_OK !=
        GNUNET_CONFIGURATION_get_value_string (cfg,
@@ -3803,8 +3877,15 @@ run (void *cls,
     }
   }
 
-  if (GNUNET_YES == ipv6_enabled && GNUNET_YES == ipv6_exit)
+  if ( (GNUNET_YES == ipv6_enabled) && (GNUNET_YES == ipv6_exit) )
   {
+    GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_IPV6_GATEWAY,
+                        strlen (GNUNET_APPLICATION_PORT_IPV6_GATEWAY),
+                        &port);
+    GNUNET_CADET_open_port (cadet_handle,
+                            &port,
+                            &new_channel,
+                            NULL);
     policy = NULL;
     if (GNUNET_OK !=
        GNUNET_CONFIGURATION_get_value_string (cfg,
index 6d05cee17e2b4e7aa29e93ca3e9c0a5920cc1ad3..1817fcac76abe98beb01d657122e613fff8db0c2 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2011 GNUnet e.V.
+     Copyright (C) 2011, 2016 GNUnet e.V.
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -51,80 +51,70 @@ extern "C"
 #define GNUNET_APPLICATION_TYPE_TEST 1
 
 /**
- * Internet DNS resolution (external DNS gateway).
+ * Transfer of blocks for non-anonymmous file-sharing.
  */
-#define GNUNET_APPLICATION_TYPE_INTERNET_RESOLVER 2
+#define GNUNET_APPLICATION_TYPE_FS_BLOCK_TRANSFER 3
 
 /**
- * Transfer of blocks for non-anonymmous file-sharing.
+ * Internet DNS resolution (external DNS gateway).  This is a "well-known"
+ * service a peer may offer over CADET where the port is the hash of this
+ * string.
  */
-#define GNUNET_APPLICATION_TYPE_FS_BLOCK_TRANSFER 3
+#define GNUNET_APPLICATION_PORT_INTERNET_RESOLVER "exit-dns"
 
 /**
  * Internet IPv4 gateway (any TCP/UDP/ICMP).
  */
-#define GNUNET_APPLICATION_TYPE_IPV4_GATEWAY 16
+#define GNUNET_APPLICATION_PORT_IPV4_GATEWAY "exit-ipv4"
 
 /**
  * Internet IPv6 gateway (any TCP/UDP/ICMP).
  */
-#define GNUNET_APPLICATION_TYPE_IPV6_GATEWAY 17
+#define GNUNET_APPLICATION_PORT_IPV6_GATEWAY "exit-ipv6"
 
 /**
- * Internet exit regex prefix. Consisting of application ID, followed by version
- * and padding.
+ * Internet exit regex prefix. Consisting of application ID, followed
+ * by version and padding.
  */
 #define GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX "GNUNET-VPN-VER-0001-"
 
 /**
  * Consensus.
+ *
+ * @deprecated
  */
 #define GNUNET_APPLICATION_TYPE_CONSENSUS 18
 
 /**
  * Set. Used for two-peer set operations implemented using stream.
+ * @deprecated
  */
 #define GNUNET_APPLICATION_TYPE_SET 19
 
-/**
- * Vectorproduct. Used for two-peer scalarproduct operations
- */
-#define GNUNET_APPLICATION_TYPE_SCALARPRODUCT 20
-
 /**
  * Conversation control data.
+ * @deprecated
  */
 #define GNUNET_APPLICATION_TYPE_CONVERSATION_CONTROL 21
 
 /**
  * Conversation audio data.
+ * @deprecated
  */
 #define GNUNET_APPLICATION_TYPE_CONVERSATION_AUDIO 22
 
 /**
  * MQTT publish-subscribe.
+ * @deprecated
  */
 #define GNUNET_APPLICATION_TYPE_MQTT 23
 
-/**
- * Application receiving sensor measurements from peers
- */
-#define GNUNET_APPLICATION_TYPE_SENSORDASHBOARD 24
-
-/**
- * Application offering sensor updates
- */
-#define GNUNET_APPLICATION_TYPE_SENSORUPDATE 25
-
 /**
  * Multicast data.
+ * @deprecated
  */
 #define GNUNET_APPLICATION_TYPE_MULTICAST 26
 
-/**
- * Vectorproduct, ECC variant. Used for two-peer scalarproduct operations
- */
-#define GNUNET_APPLICATION_TYPE_SCALARPRODUCT_ECC 27
 
 #if 0                           /* keep Emacsens' auto-indent happy */
 {
index 5b23389988857225269998c7b1e44cb641f16326..cc42cac8667f3e2658e5693fbf579458ca274ee3 100644 (file)
@@ -786,6 +786,7 @@ GNUNET_ntoh_double (double d);
  */
 #define GNUNET_memcpy(dst,src,n) do { if (0 != n) { (void) memcpy (dst,src,n); } } while (0)
 
+
 /**
  * @ingroup memory
  * Allocate a size @a n array with structs or unions of the given @a type.
index 7f4852e4b6472fa0130505fa354a1cd63c4f7829..443ff8ae6e4b714662741102708915aba071c228 100644 (file)
@@ -333,7 +333,11 @@ try_open_exit ()
   struct CadetExit *pos;
   uint32_t candidate_count;
   uint32_t candidate_selected;
+  struct GNUNET_HashCode port;
 
+  GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_INTERNET_RESOLVER,
+                      strlen (GNUNET_APPLICATION_PORT_INTERNET_RESOLVER),
+                      &port);
   candidate_count = 0;
   for (pos = exit_head; NULL != pos; pos = pos->next)
     if (NULL == pos->cadet_channel)
@@ -348,11 +352,12 @@ try_open_exit ()
       if (candidate_selected < candidate_count)
       {
        /* move to the head of the DLL */
-       pos->cadet_channel = GNUNET_CADET_channel_create (cadet_handle,
-                                                     pos,
-                                                     &pos->peer,
-                                                     GC_u2h (GNUNET_APPLICATION_TYPE_INTERNET_RESOLVER),
-                                                     GNUNET_CADET_OPTION_DEFAULT);
+       pos->cadet_channel
+          = GNUNET_CADET_channel_create (cadet_handle,
+                                         pos,
+                                         &pos->peer,
+                                         &port,
+                                         GNUNET_CADET_OPTION_DEFAULT);
        if (NULL == pos->cadet_channel)
        {
          GNUNET_break (0);
@@ -488,7 +493,8 @@ finish_request (struct ReplyContext *rc)
                              gettext_noop ("# DNS requests mapped to VPN"),
                              1, GNUNET_NO);
     GNUNET_DNS_request_answer (rc->rh,
-                              buf_len, buf);
+                              buf_len,
+                               buf);
     GNUNET_free (buf);
   }
   GNUNET_DNSPARSER_free_packet (rc->dns);
@@ -539,16 +545,21 @@ vpn_allocation_callback (void *cls,
   }
   GNUNET_STATISTICS_update (stats,
                            gettext_noop ("# DNS records modified"),
-                           1, GNUNET_NO);
+                           1,
+                            GNUNET_NO);
   switch (rc->rec->type)
   {
   case GNUNET_DNSPARSER_TYPE_A:
     GNUNET_assert (AF_INET == af);
-    GNUNET_memcpy (rc->rec->data.raw.data, address, sizeof (struct in_addr));
+    GNUNET_memcpy (rc->rec->data.raw.data,
+                   address,
+                   sizeof (struct in_addr));
     break;
   case GNUNET_DNSPARSER_TYPE_AAAA:
     GNUNET_assert (AF_INET6 == af);
-    GNUNET_memcpy (rc->rec->data.raw.data, address, sizeof (struct in6_addr));
+    GNUNET_memcpy (rc->rec->data.raw.data,
+                   address,
+                   sizeof (struct in6_addr));
     break;
   default:
     GNUNET_assert (0);
@@ -590,7 +601,8 @@ modify_address (struct ReplyContext *rc,
   }
   rc->rec = rec;
   rc->rr = GNUNET_VPN_redirect_to_ip (vpn_handle,
-                                     af, af,
+                                     af,
+                                      af,
                                      rec->data.raw.data,
                                      GNUNET_TIME_relative_to_absolute (TIMEOUT),
                                      &vpn_allocation_callback,
@@ -642,7 +654,8 @@ submit_request (struct ReplyContext *rc)
        if (ipv4_pt)
        {
          rc->offset = i + 1;
-         modify_address (rc, &ra[i]);
+         modify_address (rc,
+                          &ra[i]);
          return;
        }
        break;
@@ -650,7 +663,8 @@ submit_request (struct ReplyContext *rc)
        if (ipv6_pt)
        {
          rc->offset = i + 1;
-         modify_address (rc, &ra[i]);
+         modify_address (rc,
+                          &ra[i]);
          return;
        }
        break;
@@ -716,7 +730,8 @@ dns_post_request_handler (void *cls,
   GNUNET_STATISTICS_update (stats,
                            gettext_noop ("# DNS replies intercepted"),
                            1, GNUNET_NO);
-  dns = GNUNET_DNSPARSER_parse (request, request_length);
+  dns = GNUNET_DNSPARSER_parse (request,
+                                request_length);
   if (NULL == dns)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -725,9 +740,12 @@ dns_post_request_handler (void *cls,
     return;
   }
   work = GNUNET_NO;
-  work |= work_test (dns->answers, dns->num_answers);
-  work |= work_test (dns->authority_records, dns->num_authority_records);
-  work |= work_test (dns->additional_records, dns->num_additional_records);
+  work |= work_test (dns->answers,
+                     dns->num_answers);
+  work |= work_test (dns->authority_records,
+                     dns->num_authority_records);
+  work |= work_test (dns->additional_records,
+                     dns->num_additional_records);
   if (! work)
   {
     GNUNET_DNS_request_forward (rh);
@@ -767,16 +785,19 @@ transmit_dns_request_to_cadet (void *cls,
   mlen = rc->mlen;
   if (mlen > size)
   {
-    exit->cadet_th = GNUNET_CADET_notify_transmit_ready (exit->cadet_channel,
-                                                      GNUNET_NO,
-                                                      TIMEOUT,
-                                                      mlen,
-                                                      &transmit_dns_request_to_cadet,
-                                                      exit);
+    exit->cadet_th
+      = GNUNET_CADET_notify_transmit_ready (exit->cadet_channel,
+                                            GNUNET_NO,
+                                            TIMEOUT,
+                                            mlen,
+                                            &transmit_dns_request_to_cadet,
+                                            exit);
     return 0;
   }
   GNUNET_assert (GNUNET_NO == rc->was_transmitted);
-  GNUNET_memcpy (buf, rc->cadet_message, mlen);
+  GNUNET_memcpy (buf,
+                 rc->cadet_message,
+                 mlen);
   GNUNET_CONTAINER_DLL_remove (exit->transmit_queue_head,
                               exit->transmit_queue_tail,
                               rc);
@@ -822,7 +843,8 @@ timeout_request (void *cls)
   }
   GNUNET_STATISTICS_update (stats,
                            gettext_noop ("# DNS requests dropped (timeout)"),
-                           1, GNUNET_NO);
+                           1,
+                            GNUNET_NO);
   GNUNET_DNS_request_drop (rc->rh);
   GNUNET_free (rc);
   if ( (0 == get_channel_weight (exit)) &&
@@ -1148,12 +1170,13 @@ cadet_channel_end_cb (void *cls,
   }
   if ( (NULL == alt->cadet_th) &&
        (NULL != (rc = alt->transmit_queue_head)) )
-    alt->cadet_th = GNUNET_CADET_notify_transmit_ready (alt->cadet_channel,
-                                                     GNUNET_NO,
-                                                     TIMEOUT,
-                                                     rc->mlen,
-                                                     &transmit_dns_request_to_cadet,
-                                                     alt);
+    alt->cadet_th
+      = GNUNET_CADET_notify_transmit_ready (alt->cadet_channel,
+                                            GNUNET_NO,
+                                            TIMEOUT,
+                                            rc->mlen,
+                                            &transmit_dns_request_to_cadet,
+                                            alt);
 }
 
 
@@ -1233,10 +1256,17 @@ run (void *cls, char *const *args GNUNET_UNUSED,
   struct GNUNET_HashCode dns_key;
 
   cfg = cfg_;
-  stats = GNUNET_STATISTICS_create ("pt", cfg);
-  ipv4_pt = GNUNET_CONFIGURATION_get_value_yesno (cfg, "pt", "TUNNEL_IPV4");
-  ipv6_pt = GNUNET_CONFIGURATION_get_value_yesno (cfg, "pt", "TUNNEL_IPV6");
-  dns_channel = GNUNET_CONFIGURATION_get_value_yesno (cfg, "pt", "TUNNEL_DNS");
+  stats = GNUNET_STATISTICS_create ("pt",
+                                    cfg);
+  ipv4_pt = GNUNET_CONFIGURATION_get_value_yesno (cfg,
+                                                  "pt",
+                                                  "TUNNEL_IPV4");
+  ipv6_pt = GNUNET_CONFIGURATION_get_value_yesno (cfg,
+                                                  "pt",
+                                                  "TUNNEL_IPV6");
+  dns_channel = GNUNET_CONFIGURATION_get_value_yesno (cfg,
+                                                      "pt",
+                                                      "TUNNEL_DNS");
   if (! (ipv4_pt || ipv6_pt || dns_channel))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -1250,7 +1280,8 @@ run (void *cls, char *const *args GNUNET_UNUSED,
     dns_post_handle
       = GNUNET_DNS_connect (cfg,
                            GNUNET_DNS_FLAG_POST_RESOLUTION,
-                           &dns_post_request_handler, NULL);
+                           &dns_post_request_handler,
+                            NULL);
     if (NULL == dns_post_handle)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -1279,7 +1310,8 @@ run (void *cls, char *const *args GNUNET_UNUSED,
     dns_pre_handle
       = GNUNET_DNS_connect (cfg,
                            GNUNET_DNS_FLAG_PRE_RESOLUTION,
-                           &dns_pre_request_handler, NULL);
+                           &dns_pre_request_handler,
+                            NULL);
     if (NULL == dns_pre_handle)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -1288,9 +1320,10 @@ run (void *cls, char *const *args GNUNET_UNUSED,
       GNUNET_SCHEDULER_shutdown ();
       return;
     }
-    cadet_handle = GNUNET_CADET_connect (cfg, NULL,
-                                      &cadet_channel_end_cb,
-                                      cadet_handlers);
+    cadet_handle = GNUNET_CADET_connect (cfg,
+                                         NULL,
+                                         &cadet_channel_end_cb,
+                                         cadet_handlers);
     if (NULL == cadet_handle)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -1308,14 +1341,17 @@ run (void *cls, char *const *args GNUNET_UNUSED,
       GNUNET_SCHEDULER_shutdown ();
       return;
     }
-    GNUNET_CRYPTO_hash ("dns", strlen ("dns"), &dns_key);
+    GNUNET_CRYPTO_hash ("dns",
+                        strlen ("dns"),
+                        &dns_key);
     dht_get = GNUNET_DHT_get_start (dht,
                                    GNUNET_BLOCK_TYPE_DNS,
                                    &dns_key,
                                    1,
                                    GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
                                    NULL, 0,
-                                   &handle_dht_result, NULL);
+                                   &handle_dht_result,
+                                    NULL);
   }
 }
 
@@ -1328,20 +1364,29 @@ run (void *cls, char *const *args GNUNET_UNUSED,
  * @return 0 ok, 1 on error
  */
 int
-main (int argc, char *const *argv)
+main (int argc,
+      char *const *argv)
 {
   static const struct GNUNET_GETOPT_CommandLineOption options[] = {
     GNUNET_GETOPT_OPTION_END
   };
   int ret;
 
-  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc,
+                                                 argv,
+                                                 &argc,
+                                                 &argv))
     return 2;
   ret = (GNUNET_OK ==
-        GNUNET_PROGRAM_run (argc, argv, "gnunet-daemon-pt",
-                            gettext_noop
-                            ("Daemon to run to perform IP protocol translation to GNUnet"),
-                            options, &run, NULL)) ? 0 : 1;
+        GNUNET_PROGRAM_run (argc,
+                             argv,
+                             "gnunet-daemon-pt",
+                            gettext_noop ("Daemon to run to perform IP protocol translation to GNUnet"),
+                            options,
+                             &run,
+                             NULL))
+    ? 0
+    : 1;
   GNUNET_free ((void*) argv);
   return ret;
 }
index b994a7d15f8d47b39cf2b5e08767025f8a6e7f05..c3ae82ed8d18a89a9d6ee2f3cb15764e5f0af079 100644 (file)
@@ -862,7 +862,8 @@ GST_handle_barrier_cancel (void *cls, struct GNUNET_SERVER_Client *client,
  * @param message the actual message
  */
 void
-GST_handle_barrier_status (void *cls, struct GNUNET_SERVER_Client *client,
+GST_handle_barrier_status (void *cls,
+                           struct GNUNET_SERVER_Client *client,
                            const struct GNUNET_MessageHeader *message)
 {
   const struct GNUNET_TESTBED_BarrierStatusMsg *msg;
index 2617e9a7d8b69bc6e9a470dae629f9196a80759d..78fb1911aa342f70be04fafa28ed56e728ff3b69 100644 (file)
  * @return #GNUNET_YES on success
  */
 int
-GNUNET_CRYPTO_kdf_v (void *result, size_t out_len,
-                     const void *xts, size_t xts_len,
-                     const void *skm, size_t skm_len,
+GNUNET_CRYPTO_kdf_v (void *result,
+                     size_t out_len,
+                     const void *xts,
+                     size_t xts_len,
+                     const void *skm,
+                     size_t skm_len,
                      va_list argp)
 {
   /*
@@ -61,8 +64,15 @@ GNUNET_CRYPTO_kdf_v (void *result, size_t out_len,
    * http://eprint.iacr.org/2010/264
    */
 
-  return GNUNET_CRYPTO_hkdf_v (result, out_len, GCRY_MD_SHA512, GCRY_MD_SHA256,
-                               xts, xts_len, skm, skm_len, argp);
+  return GNUNET_CRYPTO_hkdf_v (result,
+                               out_len,
+                               GCRY_MD_SHA512,
+                               GCRY_MD_SHA256,
+                               xts,
+                               xts_len,
+                               skm,
+                               skm_len,
+                               argp);
 }
 
 
@@ -78,15 +88,24 @@ GNUNET_CRYPTO_kdf_v (void *result, size_t out_len,
  * @return #GNUNET_YES on success
  */
 int
-GNUNET_CRYPTO_kdf (void *result, size_t out_len,
-                   const void *xts, size_t xts_len,
-                   const void *skm, size_t skm_len, ...)
+GNUNET_CRYPTO_kdf (void *result,
+                   size_t out_len,
+                   const void *xts,
+                   size_t xts_len,
+                   const void *skm,
+                   size_t skm_len, ...)
 {
   va_list argp;
   int ret;
 
   va_start (argp, skm_len);
-  ret = GNUNET_CRYPTO_kdf_v (result, out_len, xts, xts_len, skm, skm_len, argp);
+  ret = GNUNET_CRYPTO_kdf_v (result,
+                             out_len,
+                             xts,
+                             xts_len,
+                             skm,
+                             skm_len,
+                             argp);
   va_end (argp);
 
   return ret;
@@ -151,3 +170,5 @@ GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r,
     gcry_mpi_release (*r);
   }
 }
+
+/* end of crypto_kdf.c */
index 812016205fa043f06d0d6aca9e77d12e3700b9ed..785bf7be194709409dff8c00a81c126c5bdf270a 100644 (file)
@@ -622,12 +622,15 @@ send_to_peer_notify_callback (void *cls, size_t size, void *buf)
   ret = tnq->len;
   GNUNET_free (tnq);
   if (NULL != (tnq = ts->tmq_head))
-    ts->th = GNUNET_CADET_notify_transmit_ready (ts->channel,
-                                               GNUNET_NO /* cork */,
-                                               GNUNET_TIME_UNIT_FOREVER_REL,
-                                               tnq->len,
-                                               &send_to_peer_notify_callback,
-                                               ts);
+  {
+    if (NULL == ts->th)
+      ts->th = GNUNET_CADET_notify_transmit_ready (ts->channel,
+                                                   GNUNET_NO /* cork */,
+                                                   GNUNET_TIME_UNIT_FOREVER_REL,
+                                                   tnq->len,
+                                                   &send_to_peer_notify_callback,
+                                                   ts);
+  }
   GNUNET_STATISTICS_update (stats,
                            gettext_noop ("# Bytes given to cadet for transmission"),
                            ret, GNUNET_NO);
@@ -731,7 +734,7 @@ handle_regex_result (void *cls,
                     unsigned int put_path_length)
 {
   struct ChannelState *ts = cls;
-  unsigned int apptype;
+  struct GNUNET_HashCode port;
 
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "Exit %s found for destination %s!\n",
@@ -742,10 +745,16 @@ handle_regex_result (void *cls,
   switch (ts->af)
   {
   case AF_INET:
-    apptype = GNUNET_APPLICATION_TYPE_IPV4_GATEWAY;
+    /* these must match the strings used in gnunet-daemon-exit */
+    GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_IPV4_GATEWAY,
+                        strlen (GNUNET_APPLICATION_PORT_IPV4_GATEWAY),
+                        &port);
     break;
   case AF_INET6:
-    apptype = GNUNET_APPLICATION_TYPE_IPV6_GATEWAY;
+    /* these must match the strings used in gnunet-daemon-exit */
+    GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_IPV6_GATEWAY,
+                        strlen (GNUNET_APPLICATION_PORT_IPV6_GATEWAY),
+                        &port);
     break;
   default:
     GNUNET_break (0);
@@ -758,7 +767,7 @@ handle_regex_result (void *cls,
   ts->channel = GNUNET_CADET_channel_create (cadet_handle,
                                              ts,
                                              id,
-                                             GC_u2h (apptype),
+                                             &port,
                                              GNUNET_CADET_OPTION_DEFAULT);
 }
 
@@ -775,23 +784,11 @@ create_channel_to_destination (struct DestinationChannel *dt,
                                int client_af)
 {
   struct ChannelState *ts;
-  unsigned int apptype;
 
   GNUNET_STATISTICS_update (stats,
                            gettext_noop ("# Cadet channels created"),
-                           1, GNUNET_NO);
-  switch (client_af)
-  {
-  case AF_INET:
-    apptype = GNUNET_APPLICATION_TYPE_IPV4_GATEWAY;
-    break;
-  case AF_INET6:
-    apptype = GNUNET_APPLICATION_TYPE_IPV6_GATEWAY;
-    break;
-  default:
-    GNUNET_break (0);
-    return NULL;
-  }
+                           1,
+                            GNUNET_NO);
   ts = GNUNET_new (struct ChannelState);
   ts->af = client_af;
   ts->destination = *dt->destination;
@@ -801,12 +798,11 @@ create_channel_to_destination (struct DestinationChannel *dt,
     ts->channel = GNUNET_CADET_channel_create (cadet_handle,
                                                ts,
                                                &dt->destination->details.service_destination.target,
-                                               GC_u2h (apptype),
+                                               &ts->destination.details.service_destination.service_descriptor,
                                                GNUNET_CADET_OPTION_DEFAULT);
     if (NULL == ts->channel)
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                 _("Failed to setup cadet channel!\n"));
+      GNUNET_break (0);
       GNUNET_free (ts);
       return NULL;
     }
@@ -1032,9 +1028,15 @@ route_packet (struct DestinationEntry *destination,
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                  "Routing %s packet from [%s]:%u -> [%s]:%u to destination [%s]:%u\n",
                  (protocol == IPPROTO_TCP) ? "TCP" : "UDP",
-                 inet_ntop (af, source_ip, sbuf, sizeof (sbuf)),
+                 inet_ntop (af,
+                             source_ip,
+                             sbuf,
+                             sizeof (sbuf)),
                  source_port,
-                 inet_ntop (af, destination_ip, dbuf, sizeof (dbuf)),
+                 inet_ntop (af,
+                             destination_ip,
+                             dbuf,
+                             sizeof (dbuf)),
                  destination_port,
                  inet_ntop (destination->details.exit_destination.af,
                             &destination->details.exit_destination.ip,
@@ -1054,9 +1056,15 @@ route_packet (struct DestinationEntry *destination,
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                  "Routing %s packet from [%s]:%u -> [%s]:%u to service %s at peer %s\n",
                  (protocol == IPPROTO_TCP) ? "TCP" : "UDP",
-                 inet_ntop (af, source_ip, sbuf, sizeof (sbuf)),
+                 inet_ntop (af,
+                             source_ip,
+                             sbuf,
+                             sizeof (sbuf)),
                  source_port,
-                 inet_ntop (af, destination_ip, dbuf, sizeof (dbuf)),
+                 inet_ntop (af,
+                             destination_ip,
+                             dbuf,
+                             sizeof (dbuf)),
                  destination_port,
                  GNUNET_h2s (&destination->details.service_destination.service_descriptor),
                  GNUNET_i2s (&destination->details.service_destination.target));
@@ -1163,8 +1171,8 @@ route_packet (struct DestinationEntry *destination,
       usm->destination_port = udp->destination_port;
       usm->service_descriptor = destination->details.service_destination.service_descriptor;
       GNUNET_memcpy (&usm[1],
-             &udp[1],
-             payload_length - sizeof (struct GNUNET_TUN_UdpHeader));
+                     &udp[1],
+                     payload_length - sizeof (struct GNUNET_TUN_UdpHeader));
     }
     else
     {
@@ -1233,8 +1241,8 @@ route_packet (struct DestinationEntry *destination,
        tsm->service_descriptor = destination->details.service_destination.service_descriptor;
        tsm->tcp_header = *tcp;
        GNUNET_memcpy (&tsm[1],
-               &tcp[1],
-               payload_length - sizeof (struct GNUNET_TUN_TcpHeader));
+                       &tcp[1],
+                       payload_length - sizeof (struct GNUNET_TUN_TcpHeader));
       }
       else
       {
@@ -2760,7 +2768,10 @@ service_redirect_to_service (void *cls,
 
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                "Allocated address %s for redirection to service %s on peer %s\n",
-               inet_ntop (result_af, addr, sbuf, sizeof (sbuf)),
+               inet_ntop (result_af,
+                           addr,
+                           sbuf,
+                           sizeof (sbuf)),
                GNUNET_h2s (&msg->service_descriptor),
                GNUNET_i2s (&msg->target));
   }
index 42fe7d4b450eccdf1d76772e03895b841643a07d..ad0b5e9f017e61b13faa01f33c1b759835cd2d64 100644 (file)
@@ -279,8 +279,8 @@ send_request (struct GNUNET_VPN_RedirectionRequest *rr)
     rip->addr_af = htonl (rr->addr_af);
     rip->request_id = rr->request_id = ++vh->request_id_gen;
     GNUNET_memcpy (&rip[1],
-            rr->addr,
-            alen);
+                   rr->addr,
+                   alen);
   }
   GNUNET_MQ_send (vh->mq,
                   env);