aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-service-dht_datacache.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-09-27 09:58:15 +0000
committerChristian Grothoff <christian@grothoff.org>2011-09-27 09:58:15 +0000
commitedab319f07cc940f64111b6e89da245a2afcf71a (patch)
tree20124181cbcc8e0e36d98b448369b7e62a1b0192 /src/dht/gnunet-service-dht_datacache.c
parent4f3f80d05ac7101b8049c352d70abe97bc81ab23 (diff)
downloadgnunet-edab319f07cc940f64111b6e89da245a2afcf71a.tar.gz
gnunet-edab319f07cc940f64111b6e89da245a2afcf71a.zip
making some files compile
Diffstat (limited to 'src/dht/gnunet-service-dht_datacache.c')
-rw-r--r--src/dht/gnunet-service-dht_datacache.c67
1 files changed, 19 insertions, 48 deletions
diff --git a/src/dht/gnunet-service-dht_datacache.c b/src/dht/gnunet-service-dht_datacache.c
index 2c1a3fe20..fc1983419 100644
--- a/src/dht/gnunet-service-dht_datacache.c
+++ b/src/dht/gnunet-service-dht_datacache.c
@@ -24,7 +24,12 @@
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 * @author Nathan Evans 25 * @author Nathan Evans
26 */ 26 */
27#include "platform.h"
28#include "gnunet_datacache_lib.h"
29#include "gnunet-service-dht_clients.h"
27#include "gnunet-service-dht_datacache.h" 30#include "gnunet-service-dht_datacache.h"
31#include "gnunet-service-dht_routing.h"
32#include "gnunet-service-dht.h"
28 33
29 34
30/** 35/**
@@ -80,7 +85,6 @@ GDS_DATACACHE_handle_put (struct GNUNET_TIME_Absolute expiration,
80 char buf[plen]; 85 char buf[plen];
81 struct DHTPutEntry *pe; 86 struct DHTPutEntry *pe;
82 struct GNUNET_PeerIdentity *pp; 87 struct GNUNET_PeerIdentity *pp;
83 char *path_offset;
84 88
85 if (datacache == NULL) 89 if (datacache == NULL)
86 { 90 {
@@ -162,32 +166,32 @@ datacache_get_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
162 struct GetRequestContext *ctx = cls; 166 struct GetRequestContext *ctx = cls;
163 const struct DHTPutEntry *pe; 167 const struct DHTPutEntry *pe;
164 const struct GNUNET_PeerIdentity *pp; 168 const struct GNUNET_PeerIdentity *pp;
165 const char *data; 169 const char *rdata;
166 size_t data_size; 170 size_t rdata_size;
167 uint16_t put_path_length; 171 uint16_t put_path_length;
168 enum GNUNET_BLOCK_EvaluationResult eval; 172 enum GNUNET_BLOCK_EvaluationResult eval;
169 173
170 pe = (const struct DHTPutEntry *) data; 174 pe = (const struct DHTPutEntry *) data;
171 put_path_length = ntohs (pe->path_length); 175 put_path_length = ntohs (pe->path_length);
172 data_size = ntohs (pe->data_size); 176 rdata_size = ntohs (pe->data_size);
173 177
174 if (size != 178 if (size !=
175 sizeof (struct DHTPutEntry) + data_size + 179 sizeof (struct DHTPutEntry) + rdata_size +
176 (put_path_length * sizeof (struct GNUNET_PeerIdentity))) 180 (put_path_length * sizeof (struct GNUNET_PeerIdentity)))
177 { 181 {
178 GNUNET_break (0); 182 GNUNET_break (0);
179 return GNUNET_OK; 183 return GNUNET_OK;
180 } 184 }
181 pp = (const struct GNUNET_PeerIdentity *) &pe[1]; 185 pp = (const struct GNUNET_PeerIdentity *) &pe[1];
182 data = (const char*) &pp[put_path_length]; 186 rdata = (const char*) &pp[put_path_length];
183 eval = 187 eval =
184 GNUNET_BLOCK_evaluate (block_context, type, key, 188 GNUNET_BLOCK_evaluate (GDS_block_context, type, key,
185 ctx->reply_bf, 189 ctx->reply_bf,
186 ctx->reply_bf_mutator, 190 ctx->reply_bf_mutator,
187 ctx->xquery, 191 ctx->xquery,
188 ctx->xquery_size, 192 ctx->xquery_size,
189 data, 193 rdata,
190 data_size); 194 rdata_size);
191 switch (eval) 195 switch (eval)
192 { 196 {
193 case GNUNET_BLOCK_EVALUATION_OK_LAST: 197 case GNUNET_BLOCK_EVALUATION_OK_LAST:
@@ -197,11 +201,11 @@ datacache_get_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
197 key, 201 key,
198 0, NULL, 202 0, NULL,
199 put_path_length, pp, 203 put_path_length, pp,
200 type, data_size, data); 204 type, rdata_size, rdata);
201 /* forward to other peers */ 205 /* forward to other peers */
202 GDS_NEIGHBOURS_handle_reply (type, exp, 206 GDS_ROUTING_process (type, exp,
203 key, put_path_length, pp, 207 key, put_path_length, pp,
204 0, NULL, data, data_size); 208 0, NULL, rdata, rdata_size);
205 break; 209 break;
206 case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE: 210 case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE:
207 break; 211 break;
@@ -224,39 +228,6 @@ datacache_get_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
224 228
225 229
226/** 230/**
227 * Context containing information about a GET request.
228 */
229struct GetRequestContext
230{
231 /**
232 * extended query (see gnunet_block_lib.h).
233 */
234 const void *xquery;
235
236 /**
237 * Bloomfilter to filter out duplicate replies (updated)
238 */
239 struct GNUNET_CONTAINER_BloomFilter **reply_bf;
240
241 /**
242 * The key this request was about
243 */
244 GNUNET_HashCode key;
245
246 /**
247 * Number of bytes in xquery.
248 */
249 size_t xquery_size;
250
251 /**
252 * Mutator value for the reply_bf, see gnunet_block_lib.h
253 */
254 uint32_t reply_bf_mutator;
255
256};
257
258
259/**
260 * Handle a GET request we've received from another peer. 231 * Handle a GET request we've received from another peer.
261 * 232 *
262 * @param key the query 233 * @param key the query
@@ -283,7 +254,7 @@ GDS_DATACACHE_handle_get (const GNUNET_HashCode *key,
283 ctx.xquery_size = xquery_size; 254 ctx.xquery_size = xquery_size;
284 ctx.reply_bf = reply_bf; 255 ctx.reply_bf = reply_bf;
285 ctx.reply_bf_mutator = reply_bf_mutator; 256 ctx.reply_bf_mutator = reply_bf_mutator;
286 (void) GNUNET_DATACACHE_get (datacache, &msg_ctx->key, type, 257 (void) GNUNET_DATACACHE_get (datacache, key, type,
287 &datacache_get_iterator, &ctx); 258 &datacache_get_iterator, &ctx);
288} 259}
289 260
@@ -294,7 +265,7 @@ GDS_DATACACHE_handle_get (const GNUNET_HashCode *key,
294void 265void
295GDS_DATACACHE_init () 266GDS_DATACACHE_init ()
296{ 267{
297 datacache = GNUNET_DATACACHE_create (cfg, "dhtcache"); 268 datacache = GNUNET_DATACACHE_create (GDS_cfg, "dhtcache");
298} 269}
299 270
300 271