gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r31620 - in gnunet/src: exit gns include regex tun vpn


From: gnunet
Subject: [GNUnet-SVN] r31620 - in gnunet/src: exit gns include regex tun vpn
Date: Fri, 20 Dec 2013 16:26:03 +0100

Author: grothoff
Date: 2013-12-20 16:26:03 +0100 (Fri, 20 Dec 2013)
New Revision: 31620

Modified:
   gnunet/src/exit/gnunet-daemon-exit.c
   gnunet/src/gns/Makefile.am
   gnunet/src/gns/gnunet-service-gns_resolver.c
   gnunet/src/include/gnunet_tun_lib.h
   gnunet/src/regex/regex_api.c
   gnunet/src/tun/regex.c
   gnunet/src/vpn/Makefile.am
   gnunet/src/vpn/gnunet-vpn.c
   gnunet/src/vpn/vpn_api.c
Log:
-use the same hash function to map service name to hash, not once strlen and 
then strlen+1

Modified: gnunet/src/exit/gnunet-daemon-exit.c
===================================================================
--- gnunet/src/exit/gnunet-daemon-exit.c        2013-12-20 14:54:23 UTC (rev 
31619)
+++ gnunet/src/exit/gnunet-daemon-exit.c        2013-12-20 15:26:03 UTC (rev 
31620)
@@ -787,7 +787,7 @@
   char key[sizeof (struct GNUNET_HashCode) + sizeof (uint16_t)];
   struct GNUNET_HashCode desc;
 
-  GNUNET_CRYPTO_hash (name, strlen (name) + 1, &desc);
+  GNUNET_TUN_service_name_to_hash (name, &desc);
   service->name = GNUNET_strdup (name);
   memcpy (&key[0], &destination_port, sizeof (uint16_t));
   memcpy (&key[sizeof(uint16_t)], &desc, sizeof (struct GNUNET_HashCode));
@@ -3220,7 +3220,7 @@
     if (NULL == (hostname = strstr (redirect, ":")))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                 "option `%s' for domain `%s' is not formatted correctly!\n",
+                 _("Option `%s' for domain `%s' is not formatted 
correctly!\n"),
                  redirect,
                  name);
       continue;
@@ -3230,7 +3230,7 @@
     if (NULL == (hostport = strstr (hostname, ":")))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                 "option `%s' for domain `%s' is not formatted correctly!\n",
+                 _("Option `%s' for domain `%s' is not formatted 
correctly!\n"),
                  redirect,
                  name);
       continue;
@@ -3244,14 +3244,16 @@
     if (!((local_port > 0) && (local_port < 65536)))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                 "`%s' is not a valid port number (for domain `%s')!", 
redirect,
+                 _("`%s' is not a valid port number (for domain `%s')!"),
+                  redirect,
                  name);
       continue;
     }
     if (!((remote_port > 0) && (remote_port < 65536)))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                 "`%s' is not a valid port number (for domain `%s')!", 
hostport,
+                 _("`%s' is not a valid port number (for domain `%s')!"),
+                  hostport,
                  name);
       continue;
     }

Modified: gnunet/src/gns/Makefile.am
===================================================================
--- gnunet/src/gns/Makefile.am  2013-12-20 14:54:23 UTC (rev 31619)
+++ gnunet/src/gns/Makefile.am  2013-12-20 15:26:03 UTC (rev 31620)
@@ -190,6 +190,7 @@
   $(top_builddir)/src/dns/libgnunetdnsparser.la \
   $(top_builddir)/src/dns/libgnunetdnsstub.la \
   $(top_builddir)/src/dht/libgnunetdht.la \
+  $(top_builddir)/src/tun/libgnunettun.la \
   $(top_builddir)/src/namecache/libgnunetnamecache.la \
   $(top_builddir)/src/namestore/libgnunetnamestore.la \
   $(USE_VPN) \
@@ -199,6 +200,7 @@
   $(top_builddir)/src/revocation/libgnunetrevocation.la \
   $(top_builddir)/src/statistics/libgnunetstatistics.la \
   $(top_builddir)/src/util/libgnunetutil.la \
+  $(top_builddir)/src/tun/libgnunettun.la \
   $(top_builddir)/src/dns/libgnunetdns.la \
   $(top_builddir)/src/dns/libgnunetdnsparser.la \
   $(top_builddir)/src/dht/libgnunetdht.la \

Modified: gnunet/src/gns/gnunet-service-gns_resolver.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns_resolver.c        2013-12-20 14:54:23 UTC 
(rev 31619)
+++ gnunet/src/gns/gnunet-service-gns_resolver.c        2013-12-20 15:26:03 UTC 
(rev 31620)
@@ -41,6 +41,7 @@
 #include "gnunet_resolver_service.h"
 #include "gnunet_revocation_service.h"
 #include "gnunet_dnsparser_lib.h"
+#include "gnunet_tun_lib.h"
 #include "gnunet_gns_service.h"
 #include "gns.h"
 #include "gnunet-service-gns_resolver.h"
@@ -1413,9 +1414,8 @@
              GNS_resolver_lookup_cancel (rh);
              return;
            }
-           GNUNET_CRYPTO_hash (vname,
-                               strlen (vname), // FIXME: +1?
-                               &vhash);
+           GNUNET_TUN_service_name_to_hash (vname,
+                                             &vhash);
             GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                         "Attempting VPN allocation for %s-%s (AF: %d, proto 
%d)\n",
                         GNUNET_i2s (&vpn->peer),

Modified: gnunet/src/include/gnunet_tun_lib.h
===================================================================
--- gnunet/src/include/gnunet_tun_lib.h 2013-12-20 14:54:23 UTC (rev 31619)
+++ gnunet/src/include/gnunet_tun_lib.h 2013-12-20 15:26:03 UTC (rev 31620)
@@ -887,4 +887,16 @@
 GNUNET_TUN_ipv4policy2regex (const char *policy);
 
 
+/**
+ * Hash the service name of a hosted service to the
+ * hash code that is used to identify the service on
+ * the network.
+ *
+ * @param service_name a string
+ * @param hc corresponding hash
+ */
+void
+GNUNET_TUN_service_name_to_hash (const char *service_name,
+                                 struct GNUNET_HashCode *hc);
+
 #endif

Modified: gnunet/src/regex/regex_api.c
===================================================================
--- gnunet/src/regex/regex_api.c        2013-12-20 14:54:23 UTC (rev 31619)
+++ gnunet/src/regex/regex_api.c        2013-12-20 15:26:03 UTC (rev 31620)
@@ -186,7 +186,7 @@
   GNUNET_REGEX_Found callback;
 
   /**
-   * Closure for 'callback'.
+   * Closure for @e callback.
    */
   void *callback_cls;
 
@@ -201,7 +201,7 @@
  * We got a response or disconnect after asking regex
  * to do the search.  Handle it.
  *
- * @param cls the 'struct GNUNET_REGEX_Search' to retry
+ * @param cls the `struct GNUNET_REGEX_Search` to retry
  * @param msg NULL on disconnect
  */
 static void

Modified: gnunet/src/tun/regex.c
===================================================================
--- gnunet/src/tun/regex.c      2013-12-20 14:54:23 UTC (rev 31619)
+++ gnunet/src/tun/regex.c      2013-12-20 15:26:03 UTC (rev 31620)
@@ -460,4 +460,22 @@
 }
 
 
+/**
+ * Hash the service name of a hosted service to the
+ * hash code that is used to identify the service on
+ * the network.
+ *
+ * @param service_name a string
+ * @param hc corresponding hash
+ */
+void
+GNUNET_TUN_service_name_to_hash (const char *service_name,
+                                 struct GNUNET_HashCode *hc)
+{
+  GNUNET_CRYPTO_hash (service_name,
+                      strlen (service_name),
+                      hc);
+}
+
+
 /* end of regex.c */

Modified: gnunet/src/vpn/Makefile.am
===================================================================
--- gnunet/src/vpn/Makefile.am  2013-12-20 14:54:23 UTC (rev 31619)
+++ gnunet/src/vpn/Makefile.am  2013-12-20 15:26:03 UTC (rev 31620)
@@ -40,7 +40,7 @@
 
 if MINGW
   gnunet_helper_vpn_LDFLAGS = \
-    -no-undefined -Wl,--export-all-symbols 
+    -no-undefined -Wl,--export-all-symbols
 
   gnunet_helper_vpn_LDADD = \
     -lsetupapi -lnewdev -lshell32 -liconv -lstdc++ \
@@ -53,7 +53,7 @@
        gnunet-helper-vpn.c
 endif
 gnunet_service_vpn_SOURCES = \
- gnunet-service-vpn.c 
+ gnunet-service-vpn.c
 gnunet_service_vpn_LDADD = \
   $(top_builddir)/src/statistics/libgnunetstatistics.la \
   $(top_builddir)/src/tun/libgnunettun.la \
@@ -68,6 +68,7 @@
  gnunet-vpn.c
 gnunet_vpn_LDADD = \
   $(top_builddir)/src/vpn/libgnunetvpn.la \
+  $(top_builddir)/src/tun/libgnunettun.la \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(GN_LIBINTL)
 gnunet_vpn_DEPENDENCIES = \

Modified: gnunet/src/vpn/gnunet-vpn.c
===================================================================
--- gnunet/src/vpn/gnunet-vpn.c 2013-12-20 14:54:23 UTC (rev 31619)
+++ gnunet/src/vpn/gnunet-vpn.c 2013-12-20 15:26:03 UTC (rev 31620)
@@ -26,6 +26,7 @@
 
 #include "platform.h"
 #include "gnunet_util_lib.h"
+#include "gnunet_tun_lib.h"
 #include "gnunet_vpn_service.h"
 
 
@@ -227,16 +228,16 @@
       protocol = IPPROTO_UDP;
     if (GNUNET_OK !=
        GNUNET_CRYPTO_eddsa_public_key_from_string (peer_id,
-                                                      strlen (peer_id),
-                                                      &peer.public_key))
+                                                    strlen (peer_id),
+                                                    &peer.public_key))
     {
-      FPRINTF (stderr, _("`%s' is not a valid peer identifier.\n"),
+      FPRINTF (stderr,
+               _("`%s' is not a valid peer identifier.\n"),
                peer_id);
       goto error;
     }
-    GNUNET_CRYPTO_hash (service_name,
-                       strlen (service_name),
-                       &sd);
+    GNUNET_TUN_service_name_to_hash (service_name,
+                                     &sd);
     request = GNUNET_VPN_redirect_to_peer (handle,
                                           req_af,
                                           protocol,

Modified: gnunet/src/vpn/vpn_api.c
===================================================================
--- gnunet/src/vpn/vpn_api.c    2013-12-20 14:54:23 UTC (rev 31619)
+++ gnunet/src/vpn/vpn_api.c    2013-12-20 15:26:03 UTC (rev 31620)
@@ -120,7 +120,7 @@
   /**
    * For service redirection, service descriptor.
    */
-  struct GNUNET_HashCode serv;         
+  struct GNUNET_HashCode serv;
 
   /**
    * At what time should the created service mapping expire?
@@ -162,7 +162,7 @@
 /**
  * Function called when we receive a message from the VPN service.
  *
- * @param cls the 'struct GNUNET_VPN_Handle'
+ * @param cls the `struct GNUNET_VPN_Handle`
  * @param msg message received, NULL on timeout or fatal error
  */
 static void
@@ -475,7 +475,7 @@
   return rr;
 }
 
-               
+
 /**
  * Tell the VPN that forwarding to the Internet via some exit node is
  * requested.  Note that both UDP and TCP traffic will be forwarded,




reply via email to

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