aboutsummaryrefslogtreecommitdiff
path: root/src/dht/dht_api_get_put.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dht/dht_api_get_put.c')
-rw-r--r--src/dht/dht_api_get_put.c43
1 files changed, 17 insertions, 26 deletions
diff --git a/src/dht/dht_api_get_put.c b/src/dht/dht_api_get_put.c
index 30b73e1f1..6b0bf1e26 100644
--- a/src/dht/dht_api_get_put.c
+++ b/src/dht/dht_api_get_put.c
@@ -52,16 +52,13 @@
52 * @return GNUNET_YES if put message is queued for transmission 52 * @return GNUNET_YES if put message is queued for transmission
53 */ 53 */
54void 54void
55GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, 55GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, const GNUNET_HashCode * key,
56 const GNUNET_HashCode * key,
57 uint32_t desired_replication_level, 56 uint32_t desired_replication_level,
58 enum GNUNET_DHT_RouteOption options, 57 enum GNUNET_DHT_RouteOption options,
59 enum GNUNET_BLOCK_Type type, 58 enum GNUNET_BLOCK_Type type, size_t size, const char *data,
60 size_t size,
61 const char *data,
62 struct GNUNET_TIME_Absolute exp, 59 struct GNUNET_TIME_Absolute exp,
63 struct GNUNET_TIME_Relative timeout, 60 struct GNUNET_TIME_Relative timeout, GNUNET_SCHEDULER_Task cont,
64 GNUNET_SCHEDULER_Task cont, void *cont_cls) 61 void *cont_cls)
65{ 62{
66 char buf[GNUNET_SERVER_MAX_MESSAGE_SIZE]; 63 char buf[GNUNET_SERVER_MAX_MESSAGE_SIZE];
67 struct GNUNET_DHT_PutMessage *put_msg; 64 struct GNUNET_DHT_PutMessage *put_msg;
@@ -82,11 +79,9 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle,
82 (unsigned int) (sizeof (struct GNUNET_DHT_PutMessage) + size), 79 (unsigned int) (sizeof (struct GNUNET_DHT_PutMessage) + size),
83 "PUT", type); 80 "PUT", type);
84 GNUNET_break (NULL == 81 GNUNET_break (NULL ==
85 GNUNET_DHT_route_start (handle, 82 GNUNET_DHT_route_start (handle, key, desired_replication_level,
86 key, 83 options, &put_msg->header, timeout,
87 desired_replication_level, options, 84 NULL, NULL, cont, cont_cls));
88 &put_msg->header,
89 timeout, NULL, NULL, cont, cont_cls));
90} 85}
91 86
92 87
@@ -126,8 +121,7 @@ struct GNUNET_DHT_GetHandle
126 * @param reply response 121 * @param reply response
127 */ 122 */
128static void 123static void
129get_reply_iterator (void *cls, 124get_reply_iterator (void *cls, const GNUNET_HashCode * key,
130 const GNUNET_HashCode * key,
131 const struct GNUNET_PeerIdentity *const *outgoing_path, 125 const struct GNUNET_PeerIdentity *const *outgoing_path,
132 const struct GNUNET_MessageHeader *reply) 126 const struct GNUNET_MessageHeader *reply)
133{ 127{
@@ -177,10 +171,9 @@ get_reply_iterator (void *cls,
177 171
178 payload = ntohs (reply->size) - sizeof (struct GNUNET_DHT_GetResultMessage); 172 payload = ntohs (reply->size) - sizeof (struct GNUNET_DHT_GetResultMessage);
179 get_handle->iter (get_handle->iter_cls, 173 get_handle->iter (get_handle->iter_cls,
180 GNUNET_TIME_absolute_ntoh (result->expiration), 174 GNUNET_TIME_absolute_ntoh (result->expiration), key,
181 key, 175 outgoing_path, put_path, ntohs (result->type), payload,
182 outgoing_path, 176 &result[1]);
183 put_path, ntohs (result->type), payload, &result[1]);
184 GNUNET_free_non_null (put_path); 177 GNUNET_free_non_null (put_path);
185} 178}
186 179
@@ -209,15 +202,13 @@ get_reply_iterator (void *cls,
209struct GNUNET_DHT_GetHandle * 202struct GNUNET_DHT_GetHandle *
210GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle, 203GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle,
211 struct GNUNET_TIME_Relative timeout, 204 struct GNUNET_TIME_Relative timeout,
212 enum GNUNET_BLOCK_Type type, 205 enum GNUNET_BLOCK_Type type, const GNUNET_HashCode * key,
213 const GNUNET_HashCode * key,
214 uint32_t desired_replication_level, 206 uint32_t desired_replication_level,
215 enum GNUNET_DHT_RouteOption options, 207 enum GNUNET_DHT_RouteOption options,
216 const struct GNUNET_CONTAINER_BloomFilter *bf, 208 const struct GNUNET_CONTAINER_BloomFilter *bf,
217 int32_t bf_mutator, 209 int32_t bf_mutator, const void *xquery,
218 const void *xquery, 210 size_t xquery_size, GNUNET_DHT_GetIterator iter,
219 size_t xquery_size, 211 void *iter_cls)
220 GNUNET_DHT_GetIterator iter, void *iter_cls)
221{ 212{
222 struct GNUNET_DHT_GetHandle *get_handle; 213 struct GNUNET_DHT_GetHandle *get_handle;
223 char buf[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1]; 214 char buf[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1];
@@ -237,8 +228,8 @@ GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle,
237 get_handle->iter_cls = iter_cls; 228 get_handle->iter_cls = iter_cls;
238 get_msg = (struct GNUNET_DHT_GetMessage *) buf; 229 get_msg = (struct GNUNET_DHT_GetMessage *) buf;
239 get_msg->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_GET); 230 get_msg->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_GET);
240 get_msg->header.size = htons (sizeof (struct GNUNET_DHT_GetMessage) + 231 get_msg->header.size =
241 xquery_size + bf_size); 232 htons (sizeof (struct GNUNET_DHT_GetMessage) + xquery_size + bf_size);
242 get_msg->type = htonl ((uint32_t) type); 233 get_msg->type = htonl ((uint32_t) type);
243 get_msg->bf_mutator = bf_mutator; 234 get_msg->bf_mutator = bf_mutator;
244 get_msg->xquery_size = htons ((uint16_t) xquery_size); 235 get_msg->xquery_size = htons ((uint16_t) xquery_size);