SET service: accurate results for symmetric mode
[oweals/gnunet.git] / src / include / gnunet_dht_service.h
index 1370e6bd9d35b4b4909574e98552dfc45b7cb32b..c5b980ba92124f0050e79f7fe388da3b1a3b93de 100644 (file)
@@ -1,6 +1,6 @@
 /*
       This file is part of GNUnet
-      (C) 2004-2013 Christian Grothoff (and other contributing authors)
+      Copyright (C) 2004-2013 Christian Grothoff (and other contributing authors)
 
       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.
  */
 
 /**
@@ -95,7 +95,12 @@ enum GNUNET_DHT_RouteOption
   /**
    * Possible message option for query key randomization.
    */
-  GNUNET_DHT_RO_BART = 8
+  GNUNET_DHT_RO_BART = 8,
+
+  /**
+   * Flag given to monitors if this was the last hop for a GET/PUT.
+   */
+  GNUNET_DHT_RO_LAST_HOP = 16
 };
 
 
@@ -165,7 +170,7 @@ typedef void (*GNUNET_DHT_PutContinuation)(void *cls,
  *        (size too big)
  */
 struct GNUNET_DHT_PutHandle *
-GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, 
+GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle,
                 const struct GNUNET_HashCode *key,
                 uint32_t desired_replication_level,
                 enum GNUNET_DHT_RouteOption options,
@@ -182,7 +187,7 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle,
  * go out over the network (we can't stop that); However, if the PUT
  * has not yet been sent to the service, cancelling the PUT will stop
  * this from happening (but there is no way for the user of this API
- * to tell if that is the case).  The only use for this API is to 
+ * to tell if that is the case).  The only use for this API is to
  * prevent a later call to 'cont' from #GNUNET_DHT_put (i.e. because
  * the system is shutting down).
  *
@@ -212,9 +217,9 @@ GNUNET_DHT_put_cancel (struct GNUNET_DHT_PutHandle *ph);
 typedef void (*GNUNET_DHT_GetIterator) (void *cls,
                                         struct GNUNET_TIME_Absolute exp,
                                         const struct GNUNET_HashCode *key,
-                                        const struct GNUNET_PeerIdentity *get_path, 
+                                        const struct GNUNET_PeerIdentity *get_path,
                                        unsigned int get_path_length,
-                                        const struct GNUNET_PeerIdentity *put_path, 
+                                        const struct GNUNET_PeerIdentity *put_path,
                                        unsigned int put_path_length,
                                         enum GNUNET_BLOCK_Type type,
                                         size_t size, const void *data);
@@ -239,11 +244,11 @@ typedef void (*GNUNET_DHT_GetIterator) (void *cls,
  */
 struct GNUNET_DHT_GetHandle *
 GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle,
-                      enum GNUNET_BLOCK_Type type, 
+                      enum GNUNET_BLOCK_Type type,
                       const struct GNUNET_HashCode *key,
                       uint32_t desired_replication_level,
-                      enum GNUNET_DHT_RouteOption options, 
-                      const void *xquery, size_t xquery_size, 
+                      enum GNUNET_DHT_RouteOption options,
+                      const void *xquery, size_t xquery_size,
                       GNUNET_DHT_GetIterator iter, void *iter_cls);
 
 
@@ -297,7 +302,7 @@ typedef void (*GNUNET_DHT_MonitorGetCB) (void *cls,
                                          enum GNUNET_DHT_RouteOption options,
                                          enum GNUNET_BLOCK_Type type,
                                          uint32_t hop_count,
-                                         uint32_t desired_replication_level, 
+                                         uint32_t desired_replication_level,
                                          unsigned int path_length,
                                          const struct GNUNET_PeerIdentity *path,
                                          const struct GNUNET_HashCode * key);
@@ -346,7 +351,7 @@ typedef void (*GNUNET_DHT_MonitorPutCB) (void *cls,
                                          enum GNUNET_DHT_RouteOption options,
                                          enum GNUNET_BLOCK_Type type,
                                          uint32_t hop_count,
-                                         uint32_t desired_replication_level, 
+                                         uint32_t desired_replication_level,
                                          unsigned int path_length,
                                          const struct GNUNET_PeerIdentity *path,
                                          struct GNUNET_TIME_Absolute exp,
@@ -386,6 +391,36 @@ void
 GNUNET_DHT_monitor_stop (struct GNUNET_DHT_MonitorHandle *handle);
 
 
+#if ENABLE_MALICIOUS
+/**
+ * Type of a Malicious continuation.  You must not call
+ * #GNUNET_DHT_disconnect in this continuation.
+ *
+ * @param cls closure
+ * @param success #GNUNET_OK if the set malicious request was transmitted,
+ *                #GNUNET_NO on timeout,
+ *                #GNUNET_SYSERR on disconnect from service
+ *                after the PUT message was transmitted
+ *                (so we don't know if it was received or not)
+ */
+typedef void (*GNUNET_DHT_ActMaliciousContinuation)(void *cls,
+                                                int success);
+
+/**
+ * Turn the DHT service to act malicious
+ *
+ * @param handle the DHT handle
+ * @param action 1 to make the service malicious; 0 to make it benign
+          FIXME: perhaps make this an enum of known malicious behaviors?
+ */
+struct GNUNET_DHT_ActMaliciousHandle *
+GNUNET_DHT_act_malicious (struct GNUNET_DHT_Handle *handle, 
+                      unsigned int action, 
+                      GNUNET_DHT_PutContinuation cont,
+                      void *cont_cls);
+#endif
+
+
 #if 0                           /* keep Emacsens' auto-indent happy */
 {
 #endif