gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated: bug 5228: made gnunet-cadet


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated: bug 5228: made gnunet-cadet -p work as intended
Date: Mon, 25 Jun 2018 23:48:59 +0200

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

t3sserakt pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new 1aac0fdea bug 5228: made gnunet-cadet -p work as intended
     new 82077f4b2 Merge branch 'master' of ssh://gnunet.org/gnunet
1aac0fdea is described below

commit 1aac0fdeaa4af2c7b14b81f0a90f0465b9c681f4
Author: t3sserakt <address@hidden>
AuthorDate: Mon Jun 25 23:46:01 2018 +0200

    bug 5228: made gnunet-cadet -p work as intended
---
 src/cadet/cadet.h                      | 10 ++++++
 src/cadet/cadet_api.c                  | 22 +++++-------
 src/cadet/gnunet-cadet.c               | 52 +++++++++++++++++----------
 src/cadet/gnunet-service-cadet.c       | 64 +++++++++++++++++++++++++++++-----
 src/cadet/gnunet-service-cadet_paths.c |  2 +-
 src/cadet/gnunet-service-cadet_peer.c  | 35 +++++++++++++++++++
 src/cadet/gnunet-service-cadet_peer.h  | 13 +++++++
 src/include/gnunet_cadet_service.h     |  4 ++-
 8 files changed, 160 insertions(+), 42 deletions(-)

diff --git a/src/cadet/cadet.h b/src/cadet/cadet.h
index 69be4e537..bac4bc49d 100644
--- a/src/cadet/cadet.h
+++ b/src/cadet/cadet.h
@@ -258,6 +258,11 @@ struct GNUNET_CADET_LocalInfoPeer
    * #GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS
    */
   struct GNUNET_MessageHeader header;
+  
+  /**
+   * Offset the peer has in the path this message is about.
+   */
+  uint16_t offset GNUNET_PACKED;
 
   /**
    * Number of paths.
@@ -268,6 +273,11 @@ struct GNUNET_CADET_LocalInfoPeer
    * Do we have a tunnel toward this peer?
    */
   int16_t tunnel GNUNET_PACKED;
+  
+  /**
+   * We are finished with the paths.
+   */
+  uint16_t finished_with_paths;
 
   /**
    * ID of the peer (can be local peer).
diff --git a/src/cadet/cadet_api.c b/src/cadet/cadet_api.c
index 91054cd4f..b019424f9 100644
--- a/src/cadet/cadet_api.c
+++ b/src/cadet/cadet_api.c
@@ -898,7 +898,6 @@ check_get_peer (void *cls,
   const struct GNUNET_PeerIdentity *paths_array;
   size_t esize;
   unsigned int epaths;
-  unsigned int paths;
   unsigned int peers;
 
   esize = ntohs (message->header.size);
@@ -915,17 +914,7 @@ check_get_peer (void *cls,
   peers = (esize - msize) / sizeof (struct GNUNET_PeerIdentity);
   epaths = ntohs (message->paths);
   paths_array = (const struct GNUNET_PeerIdentity *) &message[1];
-  paths = 0;
-  for (unsigned int i = 0; i < peers; i++)
-    if (0 == memcmp (&paths_array[i],
-                     &message->destination,
-                     sizeof (struct GNUNET_PeerIdentity)))
-      paths++;
-  if (paths != epaths)
-  {
-    GNUNET_break (0);
-    return GNUNET_SYSERR;
-  }
+  
   return GNUNET_OK;
 }
 
@@ -949,6 +938,11 @@ handle_get_peer (void *cls,
 
   if (NULL == h->info_cb.peer_cb)
     return;
+  
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+    "number of paths %u\n",
+    ntohs (message->paths));
+  
   paths = ntohs (message->paths);
   paths_array = (const struct GNUNET_PeerIdentity *) &message[1];
   peers = (ntohs (message->header.size) - sizeof (*message))
@@ -978,7 +972,9 @@ handle_get_peer (void *cls,
                       (int) ntohs (message->tunnel),
                       neighbor,
                       paths,
-                      paths_array);
+                      paths_array,
+                      (int) ntohs (message->offset),
+                      (int) ntohs (message->finished_with_paths));
 }
 
 
diff --git a/src/cadet/gnunet-cadet.c b/src/cadet/gnunet-cadet.c
index ed297196e..67cebf02b 100644
--- a/src/cadet/gnunet-cadet.c
+++ b/src/cadet/gnunet-cadet.c
@@ -530,34 +530,48 @@ peer_callback (void *cls,
                int tunnel,
                int neighbor,
                unsigned int n_paths,
-               const struct GNUNET_PeerIdentity *paths)
+               const struct GNUNET_PeerIdentity *paths,
+               int offset,
+               int finished_with_paths)
 {
   unsigned int i;
   const struct GNUNET_PeerIdentity *p;
-
-  FPRINTF (stdout,
-           "%s [TUNNEL: %s, NEIGHBOR: %s, PATHS: %u]\n",
-           GNUNET_i2s_full (peer),
-           tunnel ? "Y" : "N",
-           neighbor ? "Y" : "N",
-           n_paths);
-  p = paths;
-  for (i = 0; i < n_paths && NULL != p;)
+  
+  
+  if (GNUNET_YES == finished_with_paths)
   {
+    GNUNET_SCHEDULER_shutdown();
+    return;
+  }
+  
+  if (offset == 0){
+    FPRINTF (stdout,
+             "%s [TUNNEL: %s, NEIGHBOR: %s, PATHS: %u]\n",
+             GNUNET_i2s_full (peer),
+             tunnel ? "Y" : "N",
+             neighbor ? "Y" : "N",
+             n_paths);
+  }else{
+    p = paths;
     FPRINTF (stdout,
-             "%s ",
-             GNUNET_i2s (p));
-    if (0 == memcmp (p,
-                     peer,
-                     sizeof (*p)))
+                "Path with offset %u: ",
+                offset);
+    for (i = 0; i < offset && NULL != p;)
     {
-      FPRINTF (stdout, "\n");
-      i++;
+        FPRINTF (stdout,
+                "%s ",
+                GNUNET_i2s (p));
+        i++;
+        p++;
     }
-    p++;
+    
+    FPRINTF (stdout,
+                "\n");
+    
   }
+  
 
-  GNUNET_SCHEDULER_shutdown();
+  
 }
 
 
diff --git a/src/cadet/gnunet-service-cadet.c b/src/cadet/gnunet-service-cadet.c
index 38037e92f..dd693731f 100644
--- a/src/cadet/gnunet-service-cadet.c
+++ b/src/cadet/gnunet-service-cadet.c
@@ -822,7 +822,7 @@ get_all_peers_iterator (void *cls,
   struct GNUNET_CADET_LocalInfoPeer *msg;
 
   env = GNUNET_MQ_msg (msg,
-                       GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS);
+                       GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS);  
   msg->destination = *peer;
   msg->paths = htons (GCP_count_paths (p));
   msg->tunnel = htons (NULL != GCP_get_tunnel (p,
@@ -892,6 +892,11 @@ path_info_iterator (void *cls,
   env = GNUNET_MQ_msg_extra (resp,
                              path_size,
                              GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEER);
+  
+  
+  resp->offset = htons(off);
+  resp->finished_with_paths = htons(0);
+  
   id = (struct GNUNET_PeerIdentity *) &resp[1];
 
   /* Don't copy first peer.  First peer is always the local one.  Last
@@ -905,6 +910,45 @@ path_info_iterator (void *cls,
   return GNUNET_YES;
 }
 
+/**
+ * Getting summary information about the number of paths and if a tunnel 
exists, 
+ * and the indirect paths to a peer, if there are ones.
+ *
+ * @param cls Closure ().
+ * @param peer Peer ID (tunnel remote peer).
+ * @param value Peer info.
+ * @return #GNUNET_YES, to keep iterating.
+ */
+static void
+get_peer_info (void *cls,
+                const struct GNUNET_PeerIdentity *peer,
+                struct CadetPeer *p)
+{
+  struct CadetClient *c = cls;
+  struct GNUNET_MQ_Envelope *env;
+  struct GNUNET_CADET_LocalInfoPeer *msg;
+
+  
+  env = GNUNET_MQ_msg (msg,
+                       GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEER);
+  
+  msg->offset = htons(0);
+  msg->destination = *peer;
+  msg->paths = htons (GCP_count_paths (p));
+  msg->tunnel = htons (NULL != GCP_get_tunnel (p,
+                                               GNUNET_NO));
+  msg->finished_with_paths = htons(0);
+  
+  GNUNET_MQ_send (c->mq,
+                  env);
+  
+  GCP_iterate_indirect_paths(p,
+                            &path_info_iterator,
+                            c->mq);
+  
+}
+
+
 
 /**
  * Handler for client's SHOW_PEER request.
@@ -919,19 +963,23 @@ handle_show_peer (void *cls,
   struct CadetClient *c = cls;
   struct CadetPeer *p;
   struct GNUNET_MQ_Envelope *env;
-  struct GNUNET_MessageHeader *resp;
+  struct GNUNET_CADET_LocalInfoPeer *resp;
 
   p = GCP_get (&msg->peer,
                GNUNET_NO);
-  if (NULL != p)
-    GCP_iterate_paths (p,
-                       &path_info_iterator,
-                       c->mq);
-  /* Send message with 0/0 to indicate the end */
+  if (NULL != p){
+    get_peer_info(c, &(msg->peer), p);  
+  }
+  
+  
   env = GNUNET_MQ_msg (resp,
-                       GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEER_END);
+                       GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEER);
+  resp->finished_with_paths = htons(1);
+  resp->destination = msg->peer;
+  
   GNUNET_MQ_send (c->mq,
                   env);
+  
   GNUNET_SERVICE_client_continue (c->client);
 }
 
diff --git a/src/cadet/gnunet-service-cadet_paths.c 
b/src/cadet/gnunet-service-cadet_paths.c
index e77d54e55..593617ff6 100644
--- a/src/cadet/gnunet-service-cadet_paths.c
+++ b/src/cadet/gnunet-service-cadet_paths.c
@@ -17,7 +17,7 @@
 */
 /**
  * @file cadet/gnunet-service-cadet_paths.c
- * @brief Information we track per path.
+ * @brief Information we track per path.    
  * @author Bartlomiej Polot
  * @author Christian Grothoff
  */
diff --git a/src/cadet/gnunet-service-cadet_peer.c 
b/src/cadet/gnunet-service-cadet_peer.c
index 9cd1f5229..8e536e376 100644
--- a/src/cadet/gnunet-service-cadet_peer.c
+++ b/src/cadet/gnunet-service-cadet_peer.c
@@ -1235,6 +1235,41 @@ GCP_iterate_paths (struct CadetPeer *cp,
   return ret;
 }
 
+/**
+ * Iterate over the paths to a peer without direct link.
+ *
+ * @param cp Peer to get path info.
+ * @param callback Function to call for every path.
+ * @param callback_cls Closure for @a callback.
+ * @return Number of iterated paths.
+ */
+unsigned int
+GCP_iterate_indirect_paths (struct CadetPeer *cp,
+                               GCP_PathIterator callback,
+                               void *callback_cls)
+{
+  unsigned int ret = 0;
+
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Iterating over paths to peer %s without direct link\n",
+       GCP_2s (cp));
+  for (unsigned int i=1;i<cp->path_dll_length;i++)
+  {
+    for (struct CadetPeerPathEntry *pe = cp->path_heads[i];
+         NULL != pe;
+         pe = pe->next)
+    {
+      ret++;
+      if (GNUNET_NO ==
+          callback (callback_cls,
+                    pe->path,
+                    i))
+        return ret;
+    }
+  }
+  return ret;
+}
+
 
 /**
  * Iterate over the paths to @a cp where
diff --git a/src/cadet/gnunet-service-cadet_peer.h 
b/src/cadet/gnunet-service-cadet_peer.h
index 2357a293d..3b8b31b9a 100644
--- a/src/cadet/gnunet-service-cadet_peer.h
+++ b/src/cadet/gnunet-service-cadet_peer.h
@@ -139,6 +139,19 @@ GCP_iterate_paths (struct CadetPeer *cp,
                    GCP_PathIterator callback,
                    void *callback_cls);
 
+/**
+ * Iterate over the paths to a peer without direct link.
+ *
+ * @param cp Peer to get path info.
+ * @param callback Function to call for every path.
+ * @param callback_cls Closure for @a callback.
+ * @return Number of iterated paths.
+ */
+unsigned int
+GCP_iterate_indirect_paths (struct CadetPeer *cp,
+                   GCP_PathIterator callback,
+                   void *callback_cls);
+
 
 /**
  * Iterate over the paths to @a peer where
diff --git a/src/include/gnunet_cadet_service.h 
b/src/include/gnunet_cadet_service.h
index 4f35a3f1f..552763055 100644
--- a/src/include/gnunet_cadet_service.h
+++ b/src/include/gnunet_cadet_service.h
@@ -425,7 +425,9 @@ typedef void
                         int tunnel,
                         int neighbor,
                         unsigned int n_paths,
-                        const struct GNUNET_PeerIdentity *paths);
+                        const struct GNUNET_PeerIdentity *paths,
+                        int offset,
+                        int finished_with_paths);
 
 
 /**

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



reply via email to

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