gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated (722feeecc -> 18406d491)


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated (722feeecc -> 18406d491)
Date: Fri, 11 Jan 2019 22:22:42 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a change to branch master
in repository gnunet.

    from 722feeecc try helping rexxnor with flow control
     new ee86e7da4 missing file
     new 963cdcfe3 fix testcases, do not skip needlessly (typos)
     new 18406d491 do longest prefix match on egos as well

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/gns/gns_tld_api.c                    | 120 ++++++++++++++++++--------
 src/gns/test_gns_gns2dns_cname_lookup.sh |   7 +-
 src/gns/test_gns_gns2dns_lookup.sh       |   4 +-
 src/transport/communicator.h             | 139 +++++++++++++++++++++++++++++++
 4 files changed, 230 insertions(+), 40 deletions(-)
 create mode 100644 src/transport/communicator.h

diff --git a/src/gns/gns_tld_api.c b/src/gns/gns_tld_api.c
index 55ee30bd9..d9856ea90 100644
--- a/src/gns/gns_tld_api.c
+++ b/src/gns/gns_tld_api.c
@@ -11,7 +11,7 @@
      WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      Affero General Public License for more details.
-    
+
      You should have received a copy of the GNU Affero General Public License
      along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
@@ -71,7 +71,18 @@ struct GNUNET_GNS_LookupWithTldRequest
   /**
    * Lookup an ego with the identity service.
    */
-  struct GNUNET_IDENTITY_EgoLookup *id_op;
+  struct GNUNET_IDENTITY_Handle *id_co;
+
+  /**
+   * Name of the longest matching ego found so far.
+   * Must be freed on termination.
+   */
+  char *longest_match;
+
+  /**
+   * Ego corresponding to @e longest_match.
+   */
+  struct GNUNET_IDENTITY_Ego *longest_match_ego;
 
   /**
    * Desired result record type.
@@ -179,31 +190,82 @@ lookup_with_public_key (struct 
GNUNET_GNS_LookupWithTldRequest *ltr,
  * when the ego is determined by a name.
  *
  * @param cls a `struct GNUNET_GNS_LookupWithTldRequest *`
- * @param ego ego handle, NULL if not found
+ * @param ego ego handle, NULL at the end of the iteration
+ * @param ctx context we could store data to associate with @e ego
+ * @param name name of the ego
  */
 static void
 identity_zone_cb (void *cls,
-                 const struct GNUNET_IDENTITY_Ego *ego)
+                  struct GNUNET_IDENTITY_Ego *ego,
+                  void **ctx,
+                  const char *name)
 {
   struct GNUNET_GNS_LookupWithTldRequest *ltr = cls;
   struct GNUNET_CRYPTO_EcdsaPublicKey pkey;
 
-  ltr->id_op = NULL;
   if (NULL == ego)
   {
-    ltr->lookup_proc (ltr->lookup_proc_cls,
-                     GNUNET_NO,
-                     0,
-                     NULL);
-    GNUNET_GNS_lookup_with_tld_cancel (ltr);
+    if (NULL != ltr->longest_match)
+    {
+      /* Final case: TLD matches one of our egos */
+      // FIXME: eat all of the match (not just TLD!)
+      if (0 == strcmp (ltr->name,
+                       ltr->longest_match))
+      {
+        /* name matches ego name perfectly, only "@" remains */
+        strcpy (ltr->name,
+                GNUNET_GNS_EMPTY_LABEL_AT);
+      }
+      else
+      {
+        GNUNET_assert (strlen (ltr->longest_match) < strlen (ltr->name));
+        ltr->name[strlen(ltr->name) - strlen (ltr->longest_match) - 1] = '\0';
+      }
+
+      /* if the name is of the form 'label' (and not 'label.SUBDOMAIN'), never 
go to the DHT */
+      GNUNET_free (ltr->longest_match);
+      ltr->longest_match = NULL;
+      if (NULL == strchr (ltr->name,
+                          (unsigned char) '.'))
+        ltr->options = GNUNET_GNS_LO_NO_DHT;
+      else
+        ltr->options = GNUNET_GNS_LO_LOCAL_MASTER;
+
+      GNUNET_IDENTITY_ego_get_public_key (ltr->longest_match_ego,
+                                          &pkey);
+      GNUNET_IDENTITY_disconnect (ltr->id_co);
+      ltr->id_co = NULL;
+      lookup_with_public_key (ltr,
+                              &pkey);
+    }
+    else
+    {
+      /* no matching ego found */
+      GNUNET_IDENTITY_disconnect (ltr->id_co);
+      ltr->id_co = NULL;
+      ltr->lookup_proc (ltr->lookup_proc_cls,
+                        GNUNET_NO,
+                        0,
+                        NULL);
+      GNUNET_GNS_lookup_with_tld_cancel (ltr);
+    }
     return;
   }
-  else
+  else if (NULL != name)
   {
-    GNUNET_IDENTITY_ego_get_public_key (ego,
-                                        &pkey);
-    lookup_with_public_key (ltr,
-                           &pkey);
+    if ( (strlen (name) <= strlen (ltr->name)) &&
+         (0 == strcmp (name,
+                       &ltr->name[strlen(ltr->name) - strlen (name)])) &&
+         ( (strlen (name) == strlen (ltr->name)) ||
+           ('.' == ltr->name[strlen(ltr->name) - strlen (name) - 1]) ) &&
+         ( (NULL == ltr->longest_match) ||
+           (strlen (name) > strlen (ltr->longest_match)) ) )
+    {
+      /* found better match, update! */
+      GNUNET_free_non_null (ltr->longest_match);
+      ltr->longest_match = GNUNET_strdup (name);
+      ltr->longest_match_ego = ego;
+    }
   }
 }
 
@@ -299,21 +361,10 @@ GNUNET_GNS_lookup_with_tld (struct GNUNET_GNS_Handle 
*handle,
     GNUNET_free (dot_tld);
   }
 
-  /* Final case: TLD matches one of our egos */
-  eat_tld (ltr->name,
-          tld);
-
-  /* if the name is of the form 'label' (and not 'label.SUBDOMAIN'), never go 
to the DHT */
-  if (NULL == strchr (ltr->name,
-                      (unsigned char) '.'))
-    ltr->options = GNUNET_GNS_LO_NO_DHT;
-  else
-    ltr->options = GNUNET_GNS_LO_LOCAL_MASTER;
-  ltr->id_op = GNUNET_IDENTITY_ego_lookup (ltr->gns_handle->cfg,
-                                          tld,
-                                          &identity_zone_cb,
-                                          ltr);
-  if (NULL == ltr->id_op)
+  ltr->id_co = GNUNET_IDENTITY_connect (ltr->gns_handle->cfg,
+                                        &identity_zone_cb,
+                                        ltr);
+  if (NULL == ltr->id_co)
   {
     GNUNET_free (ltr->name);
     GNUNET_free (ltr);
@@ -333,17 +384,18 @@ void *
 GNUNET_GNS_lookup_with_tld_cancel (struct GNUNET_GNS_LookupWithTldRequest *ltr)
 {
   void *ret = ltr->lookup_proc_cls;
-  
-  if (NULL != ltr->id_op)
+
+  if (NULL != ltr->id_co)
   {
-    GNUNET_IDENTITY_ego_lookup_cancel (ltr->id_op);
-    ltr->id_op = NULL;
+    GNUNET_IDENTITY_disconnect (ltr->id_co);
+    ltr->id_co = NULL;
   }
   if (NULL != ltr->lr)
   {
     GNUNET_GNS_lookup_cancel (ltr->lr);
     ltr->lr = NULL;
   }
+  GNUNET_free_non_null (ltr->longest_match);
   GNUNET_free (ltr->name);
   GNUNET_free (ltr);
   return ret;
diff --git a/src/gns/test_gns_gns2dns_cname_lookup.sh 
b/src/gns/test_gns_gns2dns_cname_lookup.sh
index 17196f820..c07905d83 100755
--- a/src/gns/test_gns_gns2dns_cname_lookup.sh
+++ b/src/gns/test_gns_gns2dns_cname_lookup.sh
@@ -45,11 +45,10 @@ TEST_DOMAIN="www.${TEST_RECORD_NAME}.$MY_EGO"
 
 which timeout &> /dev/null && DO_TIMEOUT="timeout 15"
 
-
 gnunet-arm -s -c test_gns_lookup.conf
-
-echo $OUT | grep $TEST_IP - > /dev/null || { gnunet-arm -e -c 
test_gns_lookup.conf ; echo "IPv4 for gnunet.org not found, skipping test"; 
exit 77; }
-echo $OUT | grep $TEST6_IP - > /dev/null || { gnunet-arm -e -c 
test_gns_lookup.conf ; echo "IPv6 for gnunet.org not found, skipping test"; 
exit 77; }
+OUT=`$DO_TIMEOUT gnunet-resolver -c test_gns_lookup.conf gnunet.org`
+echo $OUT | grep $TEST_IP - > /dev/null || { gnunet-arm -e -c 
test_gns_lookup.conf ; echo "IPv4 for gnunet.org not found ($OUT), skipping 
test"; exit 77; }
+echo $OUT | grep $TEST_IP6 - > /dev/null || { gnunet-arm -e -c 
test_gns_lookup.conf ; echo "IPv6 for gnunet.org not found ($OUT), skipping 
test"; exit 77; }
 
 
 gnunet-identity -C $MY_EGO -c test_gns_lookup.conf
diff --git a/src/gns/test_gns_gns2dns_lookup.sh 
b/src/gns/test_gns_gns2dns_lookup.sh
index 431f01086..24fb36b9d 100755
--- a/src/gns/test_gns_gns2dns_lookup.sh
+++ b/src/gns/test_gns_gns2dns_lookup.sh
@@ -50,8 +50,8 @@ which timeout &> /dev/null && DO_TIMEOUT="timeout 15"
 gnunet-arm -s -c test_gns_lookup.conf
 
 OUT=`$DO_TIMEOUT gnunet-resolver -c test_gns_lookup.conf gnunet.org`
-echo $OUT | grep $TEST_IP - > /dev/null || { gnunet-arm -e -c 
test_gns_lookup.conf ; echo "IPv4 for gnunet.org not found, skipping test"; 
exit 77; }
-echo $OUT | grep $TEST6_IP - > /dev/null || { gnunet-arm -e -c 
test_gns_lookup.conf ; echo "IPv6 for gnunet.org not found, skipping test"; 
exit 77; }
+echo $OUT | grep $TEST_IP - > /dev/null || { gnunet-arm -e -c 
test_gns_lookup.conf ; echo "IPv4 for gnunet.org not found ($OUT), skipping 
test"; exit 77; }
+echo $OUT | grep $TEST_IP6 - > /dev/null || { gnunet-arm -e -c 
test_gns_lookup.conf ; echo "IPv6 for gnunet.org not found ($OUT), skipping 
test"; exit 77; }
 
 
 
diff --git a/src/transport/communicator.h b/src/transport/communicator.h
new file mode 100644
index 000000000..38b9f93b1
--- /dev/null
+++ b/src/transport/communicator.h
@@ -0,0 +1,139 @@
+/*
+     This file is part of GNUnet.
+     Copyright (C) 2009-2014 GNUnet e.V.
+
+     GNUnet is free software: you can redistribute it and/or modify it
+     under the terms of the GNU Affero General Public License as published
+     by the Free Software Foundation, either version 3 of the License,
+     or (at your option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     Affero General Public License for more details.
+
+     You should have received a copy of the GNU Affero General Public License
+     along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file transport/communicator.h
+ * @brief common internal definitions for communicator services
+ * @author Christian Grothoff
+ */
+#ifndef COMMUNICATOR_H
+#define COMMUNICAOTR_H
+
+#include "gnunet_util_lib.h"
+#include "gnunet_protocols.h"
+
+GNUNET_NETWORK_STRUCT_BEGIN
+
+/**
+ * Message used to tell a communicator about a successful
+ * key exchange.
+ *
+ * Note that this style of KX acknowledgement typically only applies
+ * for communicators where the underlying network protocol is
+ * unidirectional and/or lacks cryptography.  Furthermore, this is
+ * just the recommended "generic" style, communicators are always free
+ * to implement original designs that better fit their requirements.
+ */
+struct GNUNET_TRANSPORT_CommunicatorGenericKXConfirmation
+{
+  /**
+   * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_KX_CONFIRMATION
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * Timestamp from the original sender which identifies the original KX.
+   */
+  struct GNUNET_TIME_AbsoluteNBO monotonic_time;
+
+  /**
+   * How long does the receiver of the KX believe that the address
+   * on which the KX was received will continue to be valid.
+   */
+  struct GNUNET_TIME_RelativeNBO validity;
+
+  /**
+   * Hash of the shared secret. Specific hash function may depend on
+   * the communicator's protocol details.
+   */
+  struct GNUNET_HashCode token;
+};
+
+
+/**
+ * Message used to tell a communicator about the receiver's
+ * flow control limits and to acknowledge receipt of certain
+ * messages.
+ *
+ * Note that a sender MAY choose to violate the flow-control
+ * limits provided in this message by a receiver, which may
+ * result in messages being lost (after all, transport is an
+ * unreliable channel).  So if the sender violates these
+ * constraints, it should expect that the receive will simply
+ * discard the (partially) received "old" messages.
+ *
+ * This way, if a sender or receiver crashes, there is no protocol
+ * violation.
+ *
+ * Note that this style of flow control typically only applies
+ * for communicators where the underlying network protocol does
+ * not already implement flow control.  Furthermore, this is
+ * just the recommended "generic" style, communicators are always
+ * free to implement original designs that better fit their
+ * requirements.
+ */
+struct GNUNET_TRANSPORT_CommunicatorGenericFCLimits
+{
+  /**
+   * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_FC_LIMITS
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * Maximum number of messages beyond the acknowledged message
+   * number that can still be transmitted concurrently without
+   * further acknowledgements.
+   */
+  uint32_t msg_window_size;
+
+  /**
+   * Up to which message number were all messages received.
+   */
+  uint64_t msg_cummulative_ack;
+
+  /**
+   * Maximum number of payload bytes beyond the acknowledged
+   * number of bytes can still be transmitted without further
+   * acknowledgements.
+   */
+  uint64_t bytes_window_size;
+
+  /**
+   * Cummulative acknowledgement for number of bytes received.
+   */
+  uint64_t bytes_cummulative_ack;
+
+  /**
+   * Followed by a variable-size bitfield for messages received
+   * beyond @e msg_cummulative_ack. Index at offset 0 must thus
+   * be zero, otherwise @e msg_cummulative_ack should be
+   * increased.  Note that this field can be overall of 0 bytes.
+   * The variable-size bitfield must be a multiple of 64 bits
+   * long.
+   */
+  /* uint64_t msg_selective_ack_field[]; */
+};
+
+
+
+
+
+GNUNET_NETWORK_STRUCT_END
+
+/* end of communicator.h */
+#endif

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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