dht related changes to message types and whatnot
authorNathan S. Evans <evans@in.tum.de>
Thu, 18 Mar 2010 16:33:14 +0000 (16:33 +0000)
committerNathan S. Evans <evans@in.tum.de>
Thu, 18 Mar 2010 16:33:14 +0000 (16:33 +0000)
src/include/gnunet_dht_service.h
src/include/gnunet_protocols.h

index be7594e3213a48ae9e80b04fd43ab4e906ac1fa0..9e2e5d1636425a8d622166f2b80aca2a18966eaa 100644 (file)
@@ -43,6 +43,12 @@ extern "C"
  */
 struct GNUNET_DHT_Handle;
 
+/**
+ * Iterator called on each result obtained from a generic route
+ * operation
+ */
+typedef void (*GNUNET_DHT_MessageCallback)(void *cls,
+                                           int code);
 
 /**
  * Initialize the connection with the DHT service.
@@ -87,14 +93,14 @@ GNUNET_DHT_disconnect (struct GNUNET_DHT_Handle *h);
  * @param cont_cls closure for cont
  */
 void
-GNUNET_DHT_put (struct GNUNET_DHT_Handle *h
+GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle,
                const GNUNET_HashCode * key,
                uint32_t type,              
                uint32_t size, 
                const char *data,
                struct GNUNET_TIME_Absolute exp,
                struct GNUNET_TIME_Relative timeout,
-               GNUNET_SCHEDULER_Task cont,
+               GNUNET_DHT_MessageCallback cont,
                void *cont_cls);
 
 
@@ -105,8 +111,8 @@ struct GNUNET_DHT_GetHandle;
 
 
 /**
- * Iterator called on each result obtained for a GET
- * operation.
+ * Iterator called on each result obtained for a DHT
+ * operation that expects a reply
  *
  * @param cls closure
  * @param exp when will this value expire
@@ -115,7 +121,7 @@ struct GNUNET_DHT_GetHandle;
  * @param size number of bytes in data
  * @param data pointer to the result data
  */
-typedef void (*GNUNET_DHT_Iterator)(void *cls,
+typedef void (*GNUNET_DHT_GetIterator)(void *cls,
                                    struct GNUNET_TIME_Absolute exp,
                                    const GNUNET_HashCode * key,
                                    uint32_t type,
@@ -128,17 +134,20 @@ typedef void (*GNUNET_DHT_Iterator)(void *cls,
  * Perform an asynchronous GET operation on the DHT identified.
  *
  * @param h 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
  * @param key the key to look up
  * @param iter function to call on each result
  * @param iter_cls closure for iter
  * @return handle to stop the async get, NULL on error
  */
-struct GNUNET_DHT_GetHandle *
+struct GNUNET_DHT_RouteHandle *
 GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *h,
+                      struct GNUNET_TIME_Relative timeout,
                      uint32_t type,
                      const GNUNET_HashCode * key,
-                     GNUNET_DHT_Iterator iter,
+                     GNUNET_DHT_GetIterator iter,
                      void *iter_cls);
 
 /**
@@ -147,22 +156,29 @@ GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *h,
  * @param get_handle GET operation to stop.
  */
 void
-GNUNET_DHT_get_stop (struct GNUNET_DHT_GetHandle *get_handle);
+GNUNET_DHT_get_stop (struct GNUNET_DHT_RouteHandle *get_handle);
 
 
 /**
- * Iterator called on each result obtained from a FIND_PEER
+ * Iterator called on each result obtained from a find peer
  * operation
  *
  * @param cls closure
- * @param peer a peer that was located
- * @param reply response generated by the peer (for example, a HELLO); or NULL
+ * @param reply response
  */
-typedef void (*GNUNET_DHT_ReplyProcessor)(void *cls,
+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);
+
+
 /**
  * Options for routing.
  */
@@ -180,6 +196,10 @@ enum GNUNET_DHT_RouteOption
     GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE = 1
   };
 
+/**
+ * Handle to control a route operation.
+ */
+struct GNUNET_DHT_RouteHandle;
 
 /**
  * Perform an asynchronous FIND_PEER operation on the DHT.
@@ -195,13 +215,12 @@ enum GNUNET_DHT_RouteOption
  * @param iter_cls closure for iter
  * @param timeout when to abort with an error if we fail to get
  *                a confirmation for the PUT from the local DHT service
- * @param cont continuation to call when done; 
- *             reason will be TIMEOUT on error,
- *             reason will be PREREQ_DONE on success
+ * @param cont continuation to call when done, GNUNET_SYSERR if failed
+ *             GNUNET_OK otherwise
  * @param cont_cls closure for cont
  * @return handle to stop the request
  */
-struct GNUNET_DHT_FindPeerHandle *
+struct GNUNET_DHT_RouteHandle *
 GNUNET_DHT_route_start (struct GNUNET_DHT_Handle *handle,
                        const GNUNET_HashCode *key,
                        unsigned int desired_replication_level,
@@ -210,11 +229,11 @@ GNUNET_DHT_route_start (struct GNUNET_DHT_Handle *handle,
                        struct GNUNET_TIME_Relative timeout,
                        GNUNET_DHT_ReplyProcessor iter,
                        void *iter_cls,
-                       GNUNET_SCHEDULER_Task cont,
+                       GNUNET_DHT_MessageCallback cont,
                        void *cont_cls);
 
 void
-GNUNET_DHT_route_stop (struct GNUNET_DHT_FindPeerHandle *fph);
+GNUNET_DHT_route_stop (struct GNUNET_DHT_RouteHandle *fph);
 
 
 #if 0                           /* keep Emacsens' auto-indent happy */
index f5ce449ce570379cfb069a4bfa36c450d32101d7..564ad81822106d6bef0731e00b79e3c9cfb772f4 100644 (file)
@@ -489,40 +489,49 @@ extern "C"
  */
 
 /**
- * Local DHT Get message, from API to service
+ * Local and P2P generic DHT message start type
  */
-#define GNUNET_MESSAGE_TYPE_DHT_GET 143
+#define GNUNET_MESSAGE_TYPE_DHT 142
 
 /**
- * Local DHT Get stop message, from API to service
+ * Local and P2P generic DHT message stop type
  */
-#define GNUNET_MESSAGE_TYPE_DHT_GET_STOP 144
+#define GNUNET_MESSAGE_TYPE_DHT_STOP 143
+
+/**
+ * Local and message acknowledgment
+ */
+#define GNUNET_MESSAGE_TYPE_DHT_ACK 145
 
 /**
  * Local DHT Get message, from API to service
  */
-#define GNUNET_MESSAGE_TYPE_DHT_FIND_PEER 145
+#define GNUNET_MESSAGE_TYPE_DHT_GET 146
 
 /**
  * Local DHT Get stop message, from API to service
  */
-#define GNUNET_MESSAGE_TYPE_DHT_FIND_PEER_STOP 146
+#define GNUNET_MESSAGE_TYPE_DHT_GET_STOP 147
 
 /**
- * Local DHT Put message, from API to service
+ * Local DHT Get message, from API to service
  */
-#define GNUNET_MESSAGE_TYPE_DHT_PUT 147
+#define GNUNET_MESSAGE_TYPE_DHT_FIND_PEER 148
 
 /**
- * Local DHT Get result message, from service to API
+ * Local DHT Get stop message, from API to service
  */
-#define GNUNET_MESSAGE_TYPE_DHT_GET_RESULT 149
+#define GNUNET_MESSAGE_TYPE_DHT_FIND_PEER_STOP 149
 
 /**
- * Local DHT Put result message, from service to API
+ * Local DHT Put message, from API to service
  */
-#define GNUNET_MESSAGE_TYPE_DHT_PUT_RESULT 151
+#define GNUNET_MESSAGE_TYPE_DHT_PUT 150
 
+/**
+ * Local DHT Get result message, from service to API
+ */
+#define GNUNET_MESSAGE_TYPE_DHT_GET_RESULT 151
 
 
 /**