HKDF (does not work yet)
[oweals/gnunet.git] / src / include / gnunet_dht_service.h
index 09a89184269ce730583c5dc8ecb9af32fc471c59..dcbe3dc98dc6a3193699cfdb097eef0fa163af7a 100644 (file)
@@ -28,6 +28,7 @@
 #define GNUNET_DHT_SERVICE_H
 
 #include "gnunet_util_lib.h"
+#include "gnunet_hello_lib.h"
 
 #ifdef __cplusplus
 extern "C"
@@ -43,6 +44,22 @@ extern "C"
  */
 struct GNUNET_DHT_Handle;
 
+/**
+ * Handle to control a route operation.
+ */
+struct GNUNET_DHT_RouteHandle;
+
+/**
+ * Handle to control a get operation.
+ */
+struct GNUNET_DHT_GetHandle;
+
+/**
+ * Handle to control a find peer operation.
+ */
+struct GNUNET_DHT_FindPeerHandle;
+
+
 /**
  * Iterator called on each result obtained from a generic route
  * operation
@@ -62,7 +79,7 @@ typedef void (*GNUNET_DHT_MessageCallback)(void *cls,
 struct GNUNET_DHT_Handle *
 GNUNET_DHT_connect (struct GNUNET_SCHEDULER_Handle *sched,
                     const struct GNUNET_CONFIGURATION_Handle *cfg,
-                   unsigned int ht_len);
+                    unsigned int ht_len);
 
 
 /**
@@ -104,12 +121,6 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle,
                 void *cont_cls);
 
 
-/**
- * Handle to control a GET operation.
- */
-struct GNUNET_DHT_GetHandle;
-
-
 /**
  * Iterator called on each result obtained for a DHT
  * operation that expects a reply
@@ -131,57 +142,43 @@ typedef void (*GNUNET_DHT_GetIterator)(void *cls,
 
 
 /**
- * Perform an asynchronous GET operation on the DHT identified.
+ * Perform an asynchronous GET operation on the DHT.
  *
  * @param handle handle to the DHT service
  * @param timeout timeout for this request to be sent to the
- *        service
- * @param type expected type of the response object
+ *        service (this is NOT a timeout for receiving responses)
+ * @param type expected type of the response object (GNUNET_BLOCK_TYPE_*)
  * @param key the key to look up
  * @param iter function to call on each result
  * @param iter_cls closure for iter
- * @param cont continuation to call once message sent
+ * @param cont continuation to call once message sent (and it is now
+ *             safe to do another operation on the DHT)
  * @param cont_cls closure for continuation
- *
- * @return handle to stop the async get, NULL on error
+ * @return handle to stop the async get, NULL on error (two
+ *         concurrent operations scheduled)
  */
-struct GNUNET_DHT_RouteHandle *
+struct GNUNET_DHT_GetHandle *
 GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle,
                       struct GNUNET_TIME_Relative timeout,
-                     uint32_t type,
-                     const GNUNET_HashCode * key,
-                     GNUNET_DHT_GetIterator iter,
-                     void *iter_cls,
-                     GNUNET_SCHEDULER_Task cont,
-          void *cont_cls);
+                      uint32_t type,
+                      const GNUNET_HashCode * key,
+                      GNUNET_DHT_GetIterator iter,
+                      void *iter_cls,
+                      GNUNET_SCHEDULER_Task cont,
+                      void *cont_cls);
+
 
 /**
  * Stop async DHT-get.  Frees associated resources.
  *
  * @param get_handle GET operation to stop.
+ * @param cont continuation to call once this message is sent to the service 
+ * @param cont_cls closure for the continuation
  */
 void
-GNUNET_DHT_get_stop (struct GNUNET_DHT_RouteHandle *get_handle);
-
-
-/**
- * Iterator called on each result obtained from a find peer
- * operation
- *
- * @param cls closure
- * @param reply response
- */
-typedef void (*GNUNET_DHT_FindPeerProcessor)(void *cls,
-                                         const struct GNUNET_PeerIdentity *peer,
-                                         const struct GNUNET_MessageHeader *reply);
-
-
-/**
- * Iterator called on each result obtained from a generic route
- * operation
- */
-typedef void (*GNUNET_DHT_ReplyProcessor)(void *cls,
-                                          const struct GNUNET_MessageHeader *reply);
+GNUNET_DHT_get_stop (struct GNUNET_DHT_GetHandle *get_handle, 
+                    GNUNET_SCHEDULER_Task cont, 
+                    void *cont_cls);
 
 
 /**
@@ -201,13 +198,69 @@ enum GNUNET_DHT_RouteOption
     GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE = 1
   };
 
+
 /**
- * Handle to control a route operation.
+ * Iterator called on each result obtained from a find peer
+ * operation
+ *
+ * @param cls closure
+ * @param peer hello of a target (peer near key)
  */
-struct GNUNET_DHT_RouteHandle;
+typedef void (*GNUNET_DHT_FindPeerProcessor)(void *cls,
+                                            const struct GNUNET_HELLO_Message *peer);
+
+
+/**
+ * Perform an asynchronous FIND PEER operation on the DHT.
+ *
+ * @param handle handle to the DHT service
+ * @param timeout timeout for this request to be sent to the
+ *        service
+ * @param options routing options for this message
+ * @param key the key to look up
+ * @param proc function to call on each result
+ * @param proc_cls closure for proc
+ * @param cont continuation to call once message sent
+ * @param cont_cls closure for continuation
+ * @return handle to stop the async get, NULL on error
+ */
+struct GNUNET_DHT_FindPeerHandle *
+GNUNET_DHT_find_peer_start (struct GNUNET_DHT_Handle *handle,
+                           struct GNUNET_TIME_Relative timeout,
+                           enum GNUNET_DHT_RouteOption options,
+                           const GNUNET_HashCode * key,
+                           GNUNET_DHT_FindPeerProcessor proc,
+                           void *proc_cls,
+                           GNUNET_SCHEDULER_Task cont,
+                           void *cont_cls);
+
+
+/**
+ * Stop async find peer.  Frees associated resources.
+ *
+ * @param find_peer_handle GET operation to stop.
+ * @param cont continuation to call once this message is sent to the service
+ * @param cont_cls closure for the continuation
+ */
+void
+GNUNET_DHT_find_peer_stop (struct GNUNET_DHT_FindPeerHandle *find_peer_handle,
+                          GNUNET_SCHEDULER_Task cont, 
+                          void *cont_cls);
+
 
 /**
- * Perform an asynchronous FIND_PEER operation on the DHT.
+ * Iterator called on each result obtained from a generic route
+ * operation
+ *
+ * @param cls closure
+ * @param reply response
+ */
+typedef void (*GNUNET_DHT_ReplyProcessor)(void *cls,
+                                          const struct GNUNET_MessageHeader *reply);
+
+
+/**
+ * Perform an asynchronous ROUTE_START operation on the DHT.
  *
  * @param handle handle to the DHT service
  * @param key the key to look up
@@ -218,10 +271,9 @@ struct GNUNET_DHT_RouteHandle;
  * @param enc send the encapsulated message to a peer close to the key
  * @param timeout when to abort with an error if we fail to get
  *                a confirmation for the request (when necessary) or how long
- *                to wait for tramission to the service
+ *                to wait for transmission to the service
  * @param iter function to call on each result, NULL if no replies are expected
  * @param iter_cls closure for iter
-
  * @param cont continuation to call when done, GNUNET_SYSERR if failed
  *             GNUNET_OK otherwise
  * @param cont_cls closure for cont
@@ -239,8 +291,18 @@ GNUNET_DHT_route_start (struct GNUNET_DHT_Handle *handle,
                        GNUNET_SCHEDULER_Task cont,
                        void *cont_cls);
 
+
+/**
+ * Stop async route stop.  Frees associated resources.
+ *
+ * @param route_handle  operation to stop.
+ * @param cont continuation to call once this message is sent to the service
+ * @param cont_cls closure for the continuation
+ */
 void
-GNUNET_DHT_route_stop (struct GNUNET_DHT_RouteHandle *fph);
+GNUNET_DHT_route_stop (struct GNUNET_DHT_RouteHandle *route_handle,
+                      GNUNET_SCHEDULER_Task cont, 
+                      void *cont_cls);
 
 
 #if 0                           /* keep Emacsens' auto-indent happy */