refactor DHT for new service API
[oweals/gnunet.git] / src / cadet / cadet_path.h
index 9991b380d9567ab5f8dcc9b044cb45ec15239e17..bb68eec42e5344ca948eec77a6a94c0e1b216d25 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2001 - 2013 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2001 - 2013 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
@@ -14,8 +14,8 @@
 
      You should have received a copy of the GNU General Public License
      along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
+     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+     Boston, MA 02110-1301, USA.
 */
 
 /**
@@ -35,8 +35,6 @@ extern "C"
 #endif
 #endif
 
-#include "gnunet-service-cadet_connection.h"
-
 
 /******************************************************************************/
 /************************      DATA STRUCTURES     ****************************/
@@ -78,7 +76,7 @@ struct CadetPeerPath
    * Task to delete the path.
    * We tried it, it didn't work, don't try again in a while.
    */
-  GNUNET_SCHEDULER_TaskIdentifier path_delete;
+  struct GNUNET_SCHEDULER_Task * path_delete;
 
 };
 
@@ -137,6 +135,19 @@ path_get_length (struct CadetPeerPath *path);
 void
 path_invalidate (struct CadetPeerPath *p);
 
+/**
+ * Test if two paths are equivalent (equal or revese of each other).
+ *
+ * @param p1 First path
+ * @param p2 Second path
+ *
+ * @return GNUNET_YES if both paths are equivalent
+ *         GNUNET_NO otherwise
+ */
+int
+path_equivalent (const struct CadetPeerPath *p1,
+                 const struct CadetPeerPath *p2);
+
 /**
  * Test if a path is valid (or at least not known to be invalid).
  *
@@ -158,6 +169,35 @@ path_is_valid (const struct CadetPeerPath *path);
 int
 path_destroy (struct CadetPeerPath *p);
 
+/**
+ * Compare two paths.
+ *
+ * @param p1 First path.
+ * @param p2 Second path.
+ *
+ * @return > 0 if p1 is longer, or the first differing PEER_Id is higher on p1.
+ *         < 0 if p2 is longer, or the first differing PEER_Id is higher on p2.
+ *         0 if they are identical.
+ */
+int
+path_cmp (const struct CadetPeerPath *p1, const struct CadetPeerPath *p2);
+
+/**
+ * Builds a path from a PeerIdentity array.
+ *
+ * @param peers PeerIdentity array.
+ * @param size Size of the @c peers array.
+ * @param myid ID of local peer, to find @c own_pos.
+ * @param own_pos Output parameter: own position in the path.
+ *
+ * @return Fixed and shortened path.
+ */
+struct CadetPeerPath *
+path_build_from_peer_ids (struct GNUNET_PeerIdentity *peers,
+                          unsigned int size,
+                          GNUNET_PEER_Id myid,
+                          unsigned int *own_pos);
+
 /**
  * Path -> allocated one line string. Caller must free.
  *