Framework for trail rejection and threshold on links
[oweals/gnunet.git] / src / dht / gnunet-service-xdht_neighbours.h
index 50d39ac99938e7080bad8149dbdbd433fc0d94a8..e8809d11a679765aa0d19e2c0f89969b8f231362 100644 (file)
 #include "gnunet_block_lib.h"
 #include "gnunet_dht_service.h"
 
+/**
+ * FIXME: Change the comment to explain about usage of this in find successor.
+ * Field in trail setup message to understand if the message is sent to an
+ * intermediate finger, friend or me. 
+ */
+enum current_destination_type
+{
+  FRIEND ,
+  FINGER ,
+  MY_ID ,
+  VALUE
+};
+
 /**
  * Perform a PUT operation.  Forwards the given request to other
  * peers.   Does not store the data locally.  Does not give the
  *
  * @param type type of the block
  * @param options routing options
- * @param desired_replication_level desired replication level
+ * @param desired_replication_level desired replication count
  * @param expiration_time when does the content expire
  * @param hop_count how many hops has this message traversed so far
- * @param bf Bloom filter of peers this PUT has already traversed
  * @param key key for the content
- * @param put_path_length number of entries in put_path
+ * @param put_path_length number of entries in @a put_path
  * @param put_path peers this request has traversed so far (if tracked)
  * @param data payload to store
- * @param data_size number of bytes in data
+ * @param data_size number of bytes in @a data
  */
 void
 GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type,
@@ -56,67 +68,89 @@ GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type,
                            uint32_t desired_replication_level,
                            struct GNUNET_TIME_Absolute expiration_time,
                            uint32_t hop_count,
-                           struct GNUNET_CONTAINER_BloomFilter *bf,
                            const struct GNUNET_HashCode * key,
                            unsigned int put_path_length,
                            struct GNUNET_PeerIdentity *put_path,
-                           const void *data, size_t data_size);
+                           const void *data, size_t data_size,
+                           struct GNUNET_PeerIdentity *current_destination,
+                           struct GNUNET_PeerIdentity *current_source,
+                           enum current_destination_type dest_type,
+                           struct GNUNET_PeerIdentity *target_peer_id);
 
 
 /**
- * Perform a GET operation.  Forwards the given request to other
- * peers.  Does not lookup the key locally.  May do nothing if this is
- * the only peer in the network (or if we are the closest peer in the
- * network).
- *
- * @param type type of the block
- * @param options routing options
- * @param desired_replication_level desired replication count
- * @param hop_count how many hops did this request traverse so far?
- * @param key key for the content
- * @param xquery extended query
- * @param xquery_size number of bytes in xquery
- * @param reply_bf bloomfilter to filter duplicates
- * @param reply_bf_mutator mutator for reply_bf
- * @param peer_bf filter for peers not to select (again, updated)
+ * 
+ * @param source_peer
+ * @param get_path
+ * @param get_path_length
+ * @param key
  */
 void
-GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
+GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type block_type,
                            enum GNUNET_DHT_RouteOption options,
                            uint32_t desired_replication_level,
-                           uint32_t hop_count, const struct GNUNET_HashCode * key,
-                           const void *xquery, size_t xquery_size,
-                           const struct GNUNET_CONTAINER_BloomFilter *reply_bf,
-                           uint32_t reply_bf_mutator,
-                           struct GNUNET_CONTAINER_BloomFilter *peer_bf);
+                           uint32_t hop_count,
+                           struct GNUNET_PeerIdentity *get_peer_path,
+                           unsigned int get_path_length,
+                           struct GNUNET_HashCode *key,
+                           struct GNUNET_PeerIdentity *target_peer,
+                           struct GNUNET_PeerIdentity *current_destination,
+                           struct GNUNET_PeerIdentity *current_source,
+                           enum current_destination_type *current_dest_type);
 
 
 /**
- * Handle a reply (route to origin).  Only forwards the reply back to
- * other peers waiting for it.  Does not do local caching or
- * forwarding to local clients.
- *
- * @param target neighbour that should receive the block (if still connected)
- * @param type type of the block
- * @param expiration_time when does the content expire
- * @param key key for the content
- * @param put_path_length number of entries in put_path
- * @param put_path peers the original PUT traversed (if tracked)
- * @param get_path_length number of entries in put_path
- * @param get_path peers this reply has traversed so far (if tracked)
- * @param data payload of the reply
- * @param data_size number of bytes in data
+ * FIXME: I am removing source peer as the first element in the trail
+ * is source identity.
+ * Send get result back to requesting client. 
+ * @param expiration when will the reply expire
+ * @param key the query this reply is for
+ * @param get_path_length number of peers in @a get_path
+ * @param get_path path the reply took on get
+ * @param put_path_length number of peers in @a put_path
+ * @param put_path path the reply took on put
+ * @param type type of the reply
+ * @param data_size number of bytes in @a data
+ * @param data application payload data
+ * @param get_path
+ * @param get_path_length
  */
-void
-GDS_NEIGHBOURS_handle_reply (const struct GNUNET_PeerIdentity *target,
-                             enum GNUNET_BLOCK_Type type,
-                             struct GNUNET_TIME_Absolute expiration_time,
-                             const struct GNUNET_HashCode * key,
-                             unsigned int put_path_length,
-                             const struct GNUNET_PeerIdentity *put_path,
-                             unsigned int get_path_length,
-                             const struct GNUNET_PeerIdentity *get_path,
-                             const void *data, size_t data_size);
+void 
+GDS_NEIGHBOURS_send_get_result (struct GNUNET_TIME_Absolute expiration,
+                                const struct GNUNET_HashCode *key,
+                                unsigned int put_path_length,
+                                const struct GNUNET_PeerIdentity *put_path,
+                                enum GNUNET_BLOCK_Type type, size_t data_size,
+                                const void *data,
+                                struct GNUNET_PeerIdentity *get_path,
+                                unsigned int get_path_length,
+                                unsigned int current_trail_index,
+                                struct GNUNET_PeerIdentity *next_hop);
+
+/**
+ * FIXME: Here you should update the fields of struct PeerGetResultMessage.
+ * At the end of this message you should add the data and get path and send 
+ * to the original requesting client. and there you should call GDS_CLIENT_handle_reply
+ * with correct parameter. 
+ * @param expiration
+ * @param key
+ * @param get_path_length
+ * @param get_path
+ * @param put_path_length
+ * @param put_path
+ * @param type
+ * @param data_size
+ * @param data
+ */
+void 
+GDS_NEIGHBOURS_datacache_get (struct GNUNET_TIME_Absolute expiration,
+                              const struct GNUNET_HashCode *key,
+                              unsigned int get_path_length,
+                              const struct GNUNET_PeerIdentity *get_path,
+                              unsigned int put_path_length,
+                              const struct GNUNET_PeerIdentity *put_path,
+                              enum GNUNET_BLOCK_Type type, size_t data_size,
+                              const void *data);
 
 
 /**