aboutsummaryrefslogtreecommitdiff
path: root/src/dht
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-07-07 13:42:52 +0200
committerChristian Grothoff <christian@grothoff.org>2022-07-07 13:42:52 +0200
commit2906241b6a21d6009a0d195199f3a08e8f4d4e2a (patch)
treec9946fd81f343008877b41fc8471d13d0051f48a /src/dht
parent374e3cf6de48f26f67cf93091a2bfbdab019a6eb (diff)
downloadgnunet-2906241b6a21d6009a0d195199f3a08e8f4d4e2a.tar.gz
gnunet-2906241b6a21d6009a0d195199f3a08e8f4d4e2a.zip
major modification to datacache to store route options (and clean up the API)
Diffstat (limited to 'src/dht')
-rw-r--r--src/dht/gnunet-service-dht.h8
-rw-r--r--src/dht/gnunet-service-dht_clients.c36
-rw-r--r--src/dht/gnunet-service-dht_datacache.c53
-rw-r--r--src/dht/gnunet-service-dht_datacache.h47
-rw-r--r--src/dht/gnunet-service-dht_neighbours.c50
-rw-r--r--src/dht/gnunet-service-dht_neighbours.h6
-rw-r--r--src/dht/gnunet-service-dht_routing.c6
-rw-r--r--src/dht/gnunet-service-dht_routing.h2
8 files changed, 63 insertions, 145 deletions
diff --git a/src/dht/gnunet-service-dht.h b/src/dht/gnunet-service-dht.h
index a1513fcce..5507dcea0 100644
--- a/src/dht/gnunet-service-dht.h
+++ b/src/dht/gnunet-service-dht.h
@@ -149,7 +149,7 @@ GDS_u_hold (struct GDS_Underlay *u,
149 * @return true on success, false on failures 149 * @return true on success, false on failures
150 */ 150 */
151bool 151bool
152GDS_CLIENTS_handle_reply (const struct GDS_DATACACHE_BlockData *bd, 152GDS_CLIENTS_handle_reply (const struct GNUNET_DATACACHE_Block *bd,
153 const struct GNUNET_HashCode *query_hash, 153 const struct GNUNET_HashCode *query_hash,
154 unsigned int get_path_length, 154 unsigned int get_path_length,
155 const struct GNUNET_DHT_PathElement *get_path); 155 const struct GNUNET_DHT_PathElement *get_path);
@@ -186,7 +186,7 @@ GDS_CLIENTS_process_get (enum GNUNET_DHT_RouteOption options,
186 * @param get_path_length number of entries in @a get_path. 186 * @param get_path_length number of entries in @a get_path.
187 */ 187 */
188void 188void
189GDS_CLIENTS_process_get_resp (const struct GDS_DATACACHE_BlockData *bd, 189GDS_CLIENTS_process_get_resp (const struct GNUNET_DATACACHE_Block *bd,
190 const struct GNUNET_DHT_PathElement *get_path, 190 const struct GNUNET_DHT_PathElement *get_path,
191 unsigned int get_path_length); 191 unsigned int get_path_length);
192 192
@@ -196,14 +196,12 @@ GDS_CLIENTS_process_get_resp (const struct GDS_DATACACHE_BlockData *bd,
196 * them in that case. The @a path should include our own 196 * them in that case. The @a path should include our own
197 * peer ID (if recorded). 197 * peer ID (if recorded).
198 * 198 *
199 * @param options routing options to apply
200 * @param bd details about the block 199 * @param bd details about the block
201 * @param hop_count Hop count so far. 200 * @param hop_count Hop count so far.
202 * @param desired_replication_level Desired replication level. 201 * @param desired_replication_level Desired replication level.
203 */ 202 */
204void 203void
205GDS_CLIENTS_process_put (enum GNUNET_DHT_RouteOption options, 204GDS_CLIENTS_process_put (const struct GNUNET_DATACACHE_Block *bd,
206 const struct GDS_DATACACHE_BlockData *bd,
207 uint32_t hop_count, 205 uint32_t hop_count,
208 uint32_t desired_replication_level); 206 uint32_t desired_replication_level);
209 207
diff --git a/src/dht/gnunet-service-dht_clients.c b/src/dht/gnunet-service-dht_clients.c
index fd65102b3..631c4f68b 100644
--- a/src/dht/gnunet-service-dht_clients.c
+++ b/src/dht/gnunet-service-dht_clients.c
@@ -490,16 +490,15 @@ handle_dht_local_put (void *cls,
490{ 490{
491 struct ClientHandle *ch = cls; 491 struct ClientHandle *ch = cls;
492 uint16_t size = ntohs (dht_msg->header.size); 492 uint16_t size = ntohs (dht_msg->header.size);
493 enum GNUNET_DHT_RouteOption options
494 = (enum GNUNET_DHT_RouteOption) ntohl (dht_msg->options);
495 uint32_t replication_level 493 uint32_t replication_level
496 = ntohl (dht_msg->desired_replication_level); 494 = ntohl (dht_msg->desired_replication_level);
497 struct GDS_DATACACHE_BlockData bd = { 495 struct GNUNET_DATACACHE_Block bd = {
498 .key = dht_msg->key, 496 .key = dht_msg->key,
499 .expiration_time = GNUNET_TIME_absolute_ntoh (dht_msg->expiration), 497 .expiration_time = GNUNET_TIME_absolute_ntoh (dht_msg->expiration),
500 .data = &dht_msg[1], 498 .data = &dht_msg[1],
501 .data_size = size - sizeof (*dht_msg), 499 .data_size = size - sizeof (*dht_msg),
502 .type = ntohl (dht_msg->type) 500 .type = ntohl (dht_msg->type),
501 .ro = (enum GNUNET_DHT_RouteOption) ntohl (dht_msg->options)
503 }; 502 };
504 503
505 LOG (GNUNET_ERROR_TYPE_DEBUG, 504 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -536,14 +535,13 @@ handle_dht_local_put (void *cls,
536 DHT_BLOOM_SIZE, 535 DHT_BLOOM_SIZE,
537 GNUNET_CONSTANTS_BLOOMFILTER_K); 536 GNUNET_CONSTANTS_BLOOMFILTER_K);
538 /* store locally */ 537 /* store locally */
539 if ( (0 != (options & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE)) || 538 if ( (0 != (bd.ro & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE)) ||
540 (GDS_am_closest_peer (&dht_msg->key, 539 (GDS_am_closest_peer (&dht_msg->key,
541 peer_bf))) 540 peer_bf)))
542 GDS_DATACACHE_handle_put (&bd); 541 GDS_DATACACHE_handle_put (&bd);
543 /* route to other peers */ 542 /* route to other peers */
544 if (GNUNET_OK != 543 if (GNUNET_OK !=
545 GDS_NEIGHBOURS_handle_put (&bd, 544 GDS_NEIGHBOURS_handle_put (&bd,
546 options,
547 replication_level, 545 replication_level,
548 0 /* hop count */, 546 0 /* hop count */,
549 peer_bf)) 547 peer_bf))
@@ -556,7 +554,6 @@ handle_dht_local_put (void *cls,
556 GNUNET_CONTAINER_bloomfilter_free (peer_bf); 554 GNUNET_CONTAINER_bloomfilter_free (peer_bf);
557 } 555 }
558 GDS_CLIENTS_process_put ( 556 GDS_CLIENTS_process_put (
559 options,
560 &bd, 557 &bd,
561 0, /* hop count */ 558 0, /* hop count */
562 replication_level); 559 replication_level);
@@ -572,7 +569,7 @@ handle_dht_local_put (void *cls,
572 */ 569 */
573static void 570static void
574handle_local_result (void *cls, 571handle_local_result (void *cls,
575 const struct GDS_DATACACHE_BlockData *bd) 572 const struct GNUNET_DATACACHE_Block *bd)
576{ 573{
577 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 574 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
578 "Datacache provided result for query key %s\n", 575 "Datacache provided result for query key %s\n",
@@ -877,7 +874,7 @@ struct ForwardReplyContext
877 /** 874 /**
878 * Block details. 875 * Block details.
879 */ 876 */
880 const struct GDS_DATACACHE_BlockData *bd; 877 const struct GNUNET_DATACACHE_Block *bd;
881 878
882 /** 879 /**
883 * GET path taken. 880 * GET path taken.
@@ -1034,7 +1031,7 @@ forward_reply (void *cls,
1034 1031
1035 1032
1036bool 1033bool
1037GDS_CLIENTS_handle_reply (const struct GDS_DATACACHE_BlockData *bd, 1034GDS_CLIENTS_handle_reply (const struct GNUNET_DATACACHE_Block *bd,
1038 const struct GNUNET_HashCode *query_hash, 1035 const struct GNUNET_HashCode *query_hash,
1039 unsigned int get_path_length, 1036 unsigned int get_path_length,
1040 const struct GNUNET_DHT_PathElement *get_path) 1037 const struct GNUNET_DHT_PathElement *get_path)
@@ -1414,7 +1411,7 @@ GDS_CLIENTS_process_get (enum GNUNET_DHT_RouteOption options,
1414 */ 1411 */
1415struct ResponseActionContext 1412struct ResponseActionContext
1416{ 1413{
1417 const struct GDS_DATACACHE_BlockData *bd; 1414 const struct GNUNET_DATACACHE_Block *bd;
1418 const struct GNUNET_DHT_PathElement *get_path; 1415 const struct GNUNET_DHT_PathElement *get_path;
1419 unsigned int get_path_length; 1416 unsigned int get_path_length;
1420}; 1417};
@@ -1432,7 +1429,7 @@ response_action (void *cls,
1432 struct ClientMonitorRecord *m) 1429 struct ClientMonitorRecord *m)
1433{ 1430{
1434 const struct ResponseActionContext *resp_ctx = cls; 1431 const struct ResponseActionContext *resp_ctx = cls;
1435 const struct GDS_DATACACHE_BlockData *bd = resp_ctx->bd; 1432 const struct GNUNET_DATACACHE_Block *bd = resp_ctx->bd;
1436 1433
1437 struct GNUNET_MQ_Envelope *env; 1434 struct GNUNET_MQ_Envelope *env;
1438 struct GNUNET_DHT_MonitorGetRespMessage *mmsg; 1435 struct GNUNET_DHT_MonitorGetRespMessage *mmsg;
@@ -1467,7 +1464,7 @@ response_action (void *cls,
1467 1464
1468 1465
1469void 1466void
1470GDS_CLIENTS_process_get_resp (const struct GDS_DATACACHE_BlockData *bd, 1467GDS_CLIENTS_process_get_resp (const struct GNUNET_DATACACHE_Block *bd,
1471 const struct GNUNET_DHT_PathElement *get_path, 1468 const struct GNUNET_DHT_PathElement *get_path,
1472 unsigned int get_path_length) 1469 unsigned int get_path_length)
1473{ 1470{
@@ -1489,8 +1486,7 @@ GDS_CLIENTS_process_get_resp (const struct GDS_DATACACHE_BlockData *bd,
1489 */ 1486 */
1490struct PutActionContext 1487struct PutActionContext
1491{ 1488{
1492 const struct GDS_DATACACHE_BlockData *bd; 1489 const struct GNUNET_DATACACHE_Block *bd;
1493 enum GNUNET_DHT_RouteOption options;
1494 uint32_t hop_count; 1490 uint32_t hop_count;
1495 uint32_t desired_replication_level; 1491 uint32_t desired_replication_level;
1496}; 1492};
@@ -1508,7 +1504,7 @@ put_action (void *cls,
1508 struct ClientMonitorRecord *m) 1504 struct ClientMonitorRecord *m)
1509{ 1505{
1510 const struct PutActionContext *put_ctx = cls; 1506 const struct PutActionContext *put_ctx = cls;
1511 const struct GDS_DATACACHE_BlockData *bd = put_ctx->bd; 1507 const struct GNUNET_DATACACHE_Block *bd = put_ctx->bd;
1512 struct GNUNET_MQ_Envelope *env; 1508 struct GNUNET_MQ_Envelope *env;
1513 struct GNUNET_DHT_MonitorPutMessage *mmsg; 1509 struct GNUNET_DHT_MonitorPutMessage *mmsg;
1514 struct GNUNET_DHT_PathElement *msg_path; 1510 struct GNUNET_DHT_PathElement *msg_path;
@@ -1520,7 +1516,7 @@ put_action (void *cls,
1520 env = GNUNET_MQ_msg_extra (mmsg, 1516 env = GNUNET_MQ_msg_extra (mmsg,
1521 msize, 1517 msize,
1522 GNUNET_MESSAGE_TYPE_DHT_MONITOR_PUT); 1518 GNUNET_MESSAGE_TYPE_DHT_MONITOR_PUT);
1523 mmsg->options = htonl (put_ctx->options); 1519 mmsg->options = htonl (bd->ro);
1524 mmsg->type = htonl (bd->type); 1520 mmsg->type = htonl (bd->type);
1525 mmsg->hop_count = htonl (put_ctx->hop_count); 1521 mmsg->hop_count = htonl (put_ctx->hop_count);
1526 mmsg->desired_replication_level = htonl (put_ctx->desired_replication_level); 1522 mmsg->desired_replication_level = htonl (put_ctx->desired_replication_level);
@@ -1540,16 +1536,14 @@ put_action (void *cls,
1540 1536
1541 1537
1542void 1538void
1543GDS_CLIENTS_process_put (enum GNUNET_DHT_RouteOption options, 1539GDS_CLIENTS_process_put (const struct GNUNET_DATACACHE_Block *bd,
1544 const struct GDS_DATACACHE_BlockData *bd,
1545 uint32_t hop_count, 1540 uint32_t hop_count,
1546 uint32_t desired_replication_level) 1541 uint32_t desired_replication_level)
1547{ 1542{
1548 struct PutActionContext put_ctx = { 1543 struct PutActionContext put_ctx = {
1549 .bd = bd, 1544 .bd = bd,
1550 .hop_count = hop_count, 1545 .hop_count = hop_count,
1551 .desired_replication_level = desired_replication_level, 1546 .desired_replication_level = desired_replication_level
1552 .options = options
1553 }; 1547 };
1554 1548
1555 for_matching_monitors (bd->type, 1549 for_matching_monitors (bd->type,
diff --git a/src/dht/gnunet-service-dht_datacache.c b/src/dht/gnunet-service-dht_datacache.c
index be0a6db81..dcb6308a9 100644
--- a/src/dht/gnunet-service-dht_datacache.c
+++ b/src/dht/gnunet-service-dht_datacache.c
@@ -46,7 +46,7 @@ static struct GNUNET_DATACACHE_Handle *datacache;
46 46
47 47
48void 48void
49GDS_DATACACHE_handle_put (const struct GDS_DATACACHE_BlockData *bd) 49GDS_DATACACHE_handle_put (const struct GNUNET_DATACACHE_Block *bd)
50{ 50{
51 struct GNUNET_HashCode xor; 51 struct GNUNET_HashCode xor;
52 enum GNUNET_GenericReturnValue r; 52 enum GNUNET_GenericReturnValue r;
@@ -71,14 +71,8 @@ GDS_DATACACHE_handle_put (const struct GDS_DATACACHE_BlockData *bd)
71 &GDS_my_identity_hash, 71 &GDS_my_identity_hash,
72 &xor); 72 &xor);
73 r = GNUNET_DATACACHE_put (datacache, 73 r = GNUNET_DATACACHE_put (datacache,
74 &bd->key,
75 GNUNET_CRYPTO_hash_count_leading_zeros (&xor), 74 GNUNET_CRYPTO_hash_count_leading_zeros (&xor),
76 bd->data_size, 75 bd);
77 bd->data,
78 bd->type,
79 bd->expiration_time,
80 bd->put_path_length,
81 bd->put_path);
82 LOG (GNUNET_ERROR_TYPE_DEBUG, 76 LOG (GNUNET_ERROR_TYPE_DEBUG,
83 "DATACACHE PUT for key %s [%lu] completed (%d) after %u hops\n", 77 "DATACACHE PUT for key %s [%lu] completed (%d) after %u hops\n",
84 GNUNET_h2s (&bd->key), 78 GNUNET_h2s (&bd->key),
@@ -134,55 +128,34 @@ struct GetRequestContext
134 * Iterator for local get request results, 128 * Iterator for local get request results,
135 * 129 *
136 * @param cls closure for iterator, a `struct GetRequestContext` 130 * @param cls closure for iterator, a `struct GetRequestContext`
137 * @param exp when does this value expire? 131 * @param bd block data
138 * @param key the key this data is stored under
139 * @param data_size the size of the data identified by key
140 * @param data the actual data
141 * @param type the type of the @a data
142 * @param put_path_length number of peers in @a put_path
143 * @param put_path path the reply took on put
144 * @return #GNUNET_OK to continue iteration, anything else 132 * @return #GNUNET_OK to continue iteration, anything else
145 * to stop iteration. 133 * to stop iteration.
146 */ 134 */
147static enum GNUNET_GenericReturnValue 135static enum GNUNET_GenericReturnValue
148datacache_get_iterator (void *cls, 136datacache_get_iterator (void *cls,
149 const struct GNUNET_HashCode *key, 137 const struct GNUNET_DATACACHE_Block *bd)
150 size_t data_size,
151 const char *data,
152 enum GNUNET_BLOCK_Type type,
153 struct GNUNET_TIME_Absolute exp,
154 unsigned int put_path_length,
155 const struct GNUNET_DHT_PathElement *put_path)
156{ 138{
157 struct GetRequestContext *ctx = cls; 139 struct GetRequestContext *ctx = cls;
158 enum GNUNET_BLOCK_ReplyEvaluationResult eval; 140 enum GNUNET_BLOCK_ReplyEvaluationResult eval;
159 struct GDS_DATACACHE_BlockData bd = {
160 .key = *key,
161 .expiration_time = exp,
162 .put_path = put_path,
163 .data = data,
164 .data_size = data_size,
165 .put_path_length = put_path_length,
166 .type = type
167 };
168 141
169 if (GNUNET_TIME_absolute_is_past (exp)) 142 if (GNUNET_TIME_absolute_is_past (bd->expiration_time))
170 { 143 {
171 GNUNET_break (0); /* why does datacache return expired values? */ 144 GNUNET_break (0); /* why does datacache return expired values? */
172 return GNUNET_OK; /* skip expired record */ 145 return GNUNET_OK; /* skip expired record */
173 } 146 }
174 eval 147 eval
175 = GNUNET_BLOCK_check_reply (GDS_block_context, 148 = GNUNET_BLOCK_check_reply (GDS_block_context,
176 bd.type, 149 bd->type,
177 ctx->bg, 150 ctx->bg,
178 &bd.key, 151 &bd->key,
179 ctx->xquery, 152 ctx->xquery,
180 ctx->xquery_size, 153 ctx->xquery_size,
181 bd.data, 154 bd->data,
182 bd.data_size); 155 bd->data_size);
183 LOG (GNUNET_ERROR_TYPE_DEBUG, 156 LOG (GNUNET_ERROR_TYPE_DEBUG,
184 "Evaluated reply for query %s in datacache, result is %d\n", 157 "Evaluated reply for query %s in datacache, result is %d\n",
185 GNUNET_h2s (key), 158 GNUNET_h2s (&bd->key),
186 (int) eval); 159 (int) eval);
187 ctx->eval = eval; 160 ctx->eval = eval;
188 switch (eval) 161 switch (eval)
@@ -196,7 +169,7 @@ datacache_get_iterator (void *cls,
196 1, 169 1,
197 GNUNET_NO); 170 GNUNET_NO);
198 ctx->gc (ctx->gc_cls, 171 ctx->gc (ctx->gc_cls,
199 &bd); 172 bd);
200 break; 173 break;
201 case GNUNET_BLOCK_REPLY_OK_DUPLICATE: 174 case GNUNET_BLOCK_REPLY_OK_DUPLICATE:
202 GNUNET_STATISTICS_update (GDS_stats, 175 GNUNET_STATISTICS_update (GDS_stats,
@@ -225,7 +198,7 @@ GDS_DATACACHE_handle_get (const struct GNUNET_HashCode *key,
225 void *gc_cls) 198 void *gc_cls)
226{ 199{
227 struct GetRequestContext ctx = { 200 struct GetRequestContext ctx = {
228 .eval = GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED, 201 .eval = GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED,
229 .key = *key, 202 .key = *key,
230 .xquery = xquery, 203 .xquery = xquery,
231 .xquery_size = xquery_size, 204 .xquery_size = xquery_size,
@@ -265,7 +238,7 @@ GDS_DATACACHE_get_closest (const struct GNUNET_HashCode *key,
265 void *cb_cls) 238 void *cb_cls)
266{ 239{
267 struct GetRequestContext ctx = { 240 struct GetRequestContext ctx = {
268 .eval = GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED, 241 .eval = GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED,
269 .key = *key, 242 .key = *key,
270 .xquery = xquery, 243 .xquery = xquery,
271 .xquery_size = xquery_size, 244 .xquery_size = xquery_size,
diff --git a/src/dht/gnunet-service-dht_datacache.h b/src/dht/gnunet-service-dht_datacache.h
index d860139f5..b15e5378f 100644
--- a/src/dht/gnunet-service-dht_datacache.h
+++ b/src/dht/gnunet-service-dht_datacache.h
@@ -30,48 +30,7 @@
30#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
31#include "gnunet_block_lib.h" 31#include "gnunet_block_lib.h"
32#include "gnunet_dht_service.h" 32#include "gnunet_dht_service.h"
33 33#include "gnunet_datacache_lib.h"
34
35/**
36 * Information about a block stored in the datacache.
37 */
38struct GDS_DATACACHE_BlockData
39{
40 /**
41 * Key of the block.
42 */
43 struct GNUNET_HashCode key;
44
45 /**
46 * When does the block expire?
47 */
48 struct GNUNET_TIME_Absolute expiration_time;
49
50 /**
51 * PUT path taken by the block, array of peer identities.
52 */
53 const struct GNUNET_DHT_PathElement *put_path;
54
55 /**
56 * Actual block data.
57 */
58 const void *data;
59
60 /**
61 * Number of bytes in @a data.
62 */
63 size_t data_size;
64
65 /**
66 * Length of the @e put_path array.
67 */
68 unsigned int put_path_length;
69
70 /**
71 * Type of the block.
72 */
73 enum GNUNET_BLOCK_Type type;
74};
75 34
76 35
77/** 36/**
@@ -81,7 +40,7 @@ struct GDS_DATACACHE_BlockData
81 * @param bd block data to cache 40 * @param bd block data to cache
82 */ 41 */
83void 42void
84GDS_DATACACHE_handle_put (const struct GDS_DATACACHE_BlockData *bd); 43GDS_DATACACHE_handle_put (const struct GNUNET_DATACACHE_Block *bd);
85 44
86 45
87/** 46/**
@@ -92,7 +51,7 @@ GDS_DATACACHE_handle_put (const struct GDS_DATACACHE_BlockData *bd);
92 */ 51 */
93typedef void 52typedef void
94(*GDS_DATACACHE_GetCallback)(void *cls, 53(*GDS_DATACACHE_GetCallback)(void *cls,
95 const struct GDS_DATACACHE_BlockData *bd); 54 const struct GNUNET_DATACACHE_Block *bd);
96 55
97 56
98/** 57/**
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c
index fde25936f..2a54f715a 100644
--- a/src/dht/gnunet-service-dht_neighbours.c
+++ b/src/dht/gnunet-service-dht_neighbours.c
@@ -1285,7 +1285,7 @@ get_target_peers (const struct GNUNET_HashCode *key,
1285 * @param bd block data we got 1285 * @param bd block data we got
1286 */ 1286 */
1287static void 1287static void
1288hello_check (const struct GDS_DATACACHE_BlockData *bd) 1288hello_check (const struct GNUNET_DATACACHE_Block *bd)
1289{ 1289{
1290 struct GNUNET_PeerIdentity pid; 1290 struct GNUNET_PeerIdentity pid;
1291 struct GNUNET_HELLO_Builder *b; 1291 struct GNUNET_HELLO_Builder *b;
@@ -1305,8 +1305,7 @@ hello_check (const struct GDS_DATACACHE_BlockData *bd)
1305 1305
1306 1306
1307enum GNUNET_GenericReturnValue 1307enum GNUNET_GenericReturnValue
1308GDS_NEIGHBOURS_handle_put (const struct GDS_DATACACHE_BlockData *bd, 1308GDS_NEIGHBOURS_handle_put (const struct GNUNET_DATACACHE_Block *bd,
1309 enum GNUNET_DHT_RouteOption options,
1310 uint16_t desired_replication_level, 1309 uint16_t desired_replication_level,
1311 uint16_t hop_count, 1310 uint16_t hop_count,
1312 struct GNUNET_CONTAINER_BloomFilter *bf) 1311 struct GNUNET_CONTAINER_BloomFilter *bf)
@@ -1336,8 +1335,8 @@ GDS_NEIGHBOURS_handle_put (const struct GDS_DATACACHE_BlockData *bd,
1336 "Adding myself (%s) to PUT bloomfilter for %s with RO(%s/%s)\n", 1335 "Adding myself (%s) to PUT bloomfilter for %s with RO(%s/%s)\n",
1337 GNUNET_i2s (&GDS_my_identity), 1336 GNUNET_i2s (&GDS_my_identity),
1338 GNUNET_h2s (&bd->key), 1337 GNUNET_h2s (&bd->key),
1339 (options & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE) ? "x" : "-", 1338 (bd->ro & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE) ? "x" : "-",
1340 (options & GNUNET_DHT_RO_RECORD_ROUTE) ? "R" : "-"); 1339 (bd->ro & GNUNET_DHT_RO_RECORD_ROUTE) ? "R" : "-");
1341 1340
1342 /* if we got a HELLO, consider it for our own routing table */ 1341 /* if we got a HELLO, consider it for our own routing table */
1343 hello_check (bd); 1342 hello_check (bd);
@@ -1394,7 +1393,7 @@ GDS_NEIGHBOURS_handle_put (const struct GDS_DATACACHE_BlockData *bd,
1394 ppm->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_PUT); 1393 ppm->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_PUT);
1395 ppm->header.size = htons (sizeof (buf)); 1394 ppm->header.size = htons (sizeof (buf));
1396 ppm->type = htonl (bd->type); 1395 ppm->type = htonl (bd->type);
1397 ppm->options = htons (options); 1396 ppm->options = htons (bd->ro);
1398 ppm->hop_count = htons (hop_count + 1); 1397 ppm->hop_count = htons (hop_count + 1);
1399 ppm->desired_replication_level = htons (desired_replication_level); 1398 ppm->desired_replication_level = htons (desired_replication_level);
1400 ppm->put_path_length = htons (put_path_length); 1399 ppm->put_path_length = htons (put_path_length);
@@ -1565,7 +1564,7 @@ GDS_NEIGHBOURS_lookup_peer (const struct GNUNET_PeerIdentity *target)
1565 1564
1566bool 1565bool
1567GDS_NEIGHBOURS_handle_reply (struct PeerInfo *pi, 1566GDS_NEIGHBOURS_handle_reply (struct PeerInfo *pi,
1568 const struct GDS_DATACACHE_BlockData *bd, 1567 const struct GNUNET_DATACACHE_Block *bd,
1569 const struct GNUNET_HashCode *query_hash, 1568 const struct GNUNET_HashCode *query_hash,
1570 unsigned int get_path_length, 1569 unsigned int get_path_length,
1571 const struct GNUNET_DHT_PathElement *get_path) 1570 const struct GNUNET_DHT_PathElement *get_path)
@@ -1748,16 +1747,15 @@ handle_dht_p2p_put (void *cls,
1748 struct Target *t = cls; 1747 struct Target *t = cls;
1749 struct PeerInfo *peer = t->pi; 1748 struct PeerInfo *peer = t->pi;
1750 uint16_t msize = ntohs (put->header.size); 1749 uint16_t msize = ntohs (put->header.size);
1751 enum GNUNET_DHT_RouteOption options
1752 = (enum GNUNET_DHT_RouteOption) ntohs (put->options);
1753 const struct GNUNET_DHT_PathElement *put_path 1750 const struct GNUNET_DHT_PathElement *put_path
1754 = (const struct GNUNET_DHT_PathElement *) &put[1]; 1751 = (const struct GNUNET_DHT_PathElement *) &put[1];
1755 uint16_t putlen 1752 uint16_t putlen
1756 = ntohs (put->put_path_length); 1753 = ntohs (put->put_path_length);
1757 struct GDS_DATACACHE_BlockData bd = { 1754 struct GNUNET_DATACACHE_Block bd = {
1758 .key = put->key, 1755 .key = put->key,
1759 .expiration_time = GNUNET_TIME_absolute_ntoh (put->expiration_time), 1756 .expiration_time = GNUNET_TIME_absolute_ntoh (put->expiration_time),
1760 .type = ntohl (put->type), 1757 .type = ntohl (put->type),
1758 .ro = (enum GNUNET_DHT_RouteOption) ntohs (put->options),
1761 .data_size = msize - (sizeof(*put) 1759 .data_size = msize - (sizeof(*put)
1762 + putlen * sizeof(struct GNUNET_DHT_PathElement)), 1760 + putlen * sizeof(struct GNUNET_DHT_PathElement)),
1763 .data = &put_path[putlen] 1761 .data = &put_path[putlen]
@@ -1767,8 +1765,8 @@ handle_dht_p2p_put (void *cls,
1767 "PUT for `%s' from %s with RO (%s/%s)\n", 1765 "PUT for `%s' from %s with RO (%s/%s)\n",
1768 GNUNET_h2s (&put->key), 1766 GNUNET_h2s (&put->key),
1769 GNUNET_i2s (&peer->id), 1767 GNUNET_i2s (&peer->id),
1770 (options & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE) ? "x" : "-", 1768 (bd.ro & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE) ? "x" : "-",
1771 (options & GNUNET_DHT_RO_RECORD_ROUTE) ? "R" : "-"); 1769 (bd.ro & GNUNET_DHT_RO_RECORD_ROUTE) ? "R" : "-");
1772 if (GNUNET_TIME_absolute_is_past (bd.expiration_time)) 1770 if (GNUNET_TIME_absolute_is_past (bd.expiration_time))
1773 { 1771 {
1774 GNUNET_STATISTICS_update (GDS_stats, 1772 GNUNET_STATISTICS_update (GDS_stats,
@@ -1786,7 +1784,7 @@ handle_dht_p2p_put (void *cls,
1786 GNUNET_break_op (0); 1784 GNUNET_break_op (0);
1787 return; 1785 return;
1788 } 1786 }
1789 if (0 == (options & GNUNET_DHT_RO_RECORD_ROUTE)) 1787 if (0 == (bd.ro & GNUNET_DHT_RO_RECORD_ROUTE))
1790 putlen = 0; 1788 putlen = 0;
1791 GNUNET_STATISTICS_update (GDS_stats, 1789 GNUNET_STATISTICS_update (GDS_stats,
1792 "# P2P PUT requests received", 1790 "# P2P PUT requests received",
@@ -1837,7 +1835,7 @@ handle_dht_p2p_put (void *cls,
1837 /* extend 'put path' by sender */ 1835 /* extend 'put path' by sender */
1838 bd.put_path = (const struct GNUNET_DHT_PathElement *) pp; 1836 bd.put_path = (const struct GNUNET_DHT_PathElement *) pp;
1839 bd.put_path_length = putlen + 1; 1837 bd.put_path_length = putlen + 1;
1840 if (0 != (options & GNUNET_DHT_RO_RECORD_ROUTE)) 1838 if (0 != (bd.ro & GNUNET_DHT_RO_RECORD_ROUTE))
1841 { 1839 {
1842 unsigned int failure_offset; 1840 unsigned int failure_offset;
1843 1841
@@ -1884,7 +1882,7 @@ handle_dht_p2p_put (void *cls,
1884 0, NULL /* get path */)); 1882 0, NULL /* get path */));
1885 1883
1886 /* store locally */ 1884 /* store locally */
1887 if ( (0 != (options & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE)) || 1885 if ( (0 != (bd.ro & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE)) ||
1888 (GDS_am_closest_peer (&put->key, 1886 (GDS_am_closest_peer (&put->key,
1889 bf)) ) 1887 bf)) )
1890 GDS_DATACACHE_handle_put (&bd); 1888 GDS_DATACACHE_handle_put (&bd);
@@ -1894,16 +1892,14 @@ handle_dht_p2p_put (void *cls,
1894 /* route to other peers */ 1892 /* route to other peers */
1895 forwarded 1893 forwarded
1896 = GDS_NEIGHBOURS_handle_put (&bd, 1894 = GDS_NEIGHBOURS_handle_put (&bd,
1897 options,
1898 ntohs (put->desired_replication_level), 1895 ntohs (put->desired_replication_level),
1899 ntohs (put->hop_count), 1896 ntohs (put->hop_count),
1900 bf); 1897 bf);
1901 /* notify monitoring clients */ 1898 /* notify monitoring clients */
1902 GDS_CLIENTS_process_put (options 1899 bd.ro |= ((GNUNET_OK == forwarded)
1903 | ((GNUNET_OK == forwarded) 1900 ? GNUNET_DHT_RO_LAST_HOP
1904 ? GNUNET_DHT_RO_LAST_HOP 1901 : 0);
1905 : 0), 1902 GDS_CLIENTS_process_put (&bd,
1906 &bd,
1907 ntohs (put->hop_count), 1903 ntohs (put->hop_count),
1908 ntohs (put->desired_replication_level)); 1904 ntohs (put->desired_replication_level));
1909 } 1905 }
@@ -1957,7 +1953,7 @@ handle_find_my_hello (struct PeerInfo *pi,
1957 block, 1953 block,
1958 block_size)) 1954 block_size))
1959 { 1955 {
1960 struct GDS_DATACACHE_BlockData bd = { 1956 struct GNUNET_DATACACHE_Block bd = {
1961 .type = GNUNET_BLOCK_TYPE_DHT_URL_HELLO, 1957 .type = GNUNET_BLOCK_TYPE_DHT_URL_HELLO,
1962 .expiration_time 1958 .expiration_time
1963 = GNUNET_TIME_relative_to_absolute ( 1959 = GNUNET_TIME_relative_to_absolute (
@@ -2014,7 +2010,7 @@ handle_find_local_hello (struct PeerInfo *pi,
2014 peer->hello, 2010 peer->hello,
2015 peer->hello_size)) ) 2011 peer->hello_size)) )
2016 { 2012 {
2017 struct GDS_DATACACHE_BlockData bd = { 2013 struct GNUNET_DATACACHE_Block bd = {
2018 .type = GNUNET_BLOCK_TYPE_DHT_URL_HELLO, 2014 .type = GNUNET_BLOCK_TYPE_DHT_URL_HELLO,
2019 .expiration_time = peer->hello_expiration, 2015 .expiration_time = peer->hello_expiration,
2020 .key = peer->phash, 2016 .key = peer->phash,
@@ -2038,7 +2034,7 @@ handle_find_local_hello (struct PeerInfo *pi,
2038 */ 2034 */
2039static void 2035static void
2040handle_local_result (void *cls, 2036handle_local_result (void *cls,
2041 const struct GDS_DATACACHE_BlockData *bd) 2037 const struct GNUNET_DATACACHE_Block *bd)
2042{ 2038{
2043 struct PeerInfo *peer = cls; 2039 struct PeerInfo *peer = cls;
2044 2040
@@ -2242,7 +2238,7 @@ handle_dht_p2p_get (void *cls,
2242 * @return true on success 2238 * @return true on success
2243 */ 2239 */
2244static bool 2240static bool
2245process_reply_with_path (const struct GDS_DATACACHE_BlockData *bd, 2241process_reply_with_path (const struct GNUNET_DATACACHE_Block *bd,
2246 const struct GNUNET_HashCode *query_hash, 2242 const struct GNUNET_HashCode *query_hash,
2247 unsigned int get_path_length, 2243 unsigned int get_path_length,
2248 const struct GNUNET_DHT_PathElement *get_path) 2244 const struct GNUNET_DHT_PathElement *get_path)
@@ -2265,7 +2261,7 @@ process_reply_with_path (const struct GDS_DATACACHE_BlockData *bd,
2265 { 2261 {
2266 struct GNUNET_DHT_PathElement xput_path[GNUNET_NZL (get_path_length 2262 struct GNUNET_DHT_PathElement xput_path[GNUNET_NZL (get_path_length
2267 + bd->put_path_length)]; 2263 + bd->put_path_length)];
2268 struct GDS_DATACACHE_BlockData bdx = *bd; 2264 struct GNUNET_DATACACHE_Block bdx = *bd;
2269 2265
2270 GNUNET_memcpy (xput_path, 2266 GNUNET_memcpy (xput_path,
2271 bd->put_path, 2267 bd->put_path,
@@ -2332,7 +2328,7 @@ handle_dht_p2p_result (void *cls,
2332 struct PeerInfo *peer = t->pi; 2328 struct PeerInfo *peer = t->pi;
2333 uint16_t msize = ntohs (prm->header.size); 2329 uint16_t msize = ntohs (prm->header.size);
2334 uint16_t get_path_length = ntohs (prm->get_path_length); 2330 uint16_t get_path_length = ntohs (prm->get_path_length);
2335 struct GDS_DATACACHE_BlockData bd = { 2331 struct GNUNET_DATACACHE_Block bd = {
2336 .expiration_time = GNUNET_TIME_absolute_ntoh (prm->expiration_time), 2332 .expiration_time = GNUNET_TIME_absolute_ntoh (prm->expiration_time),
2337 .put_path = (const struct GNUNET_DHT_PathElement *) &prm[1], 2333 .put_path = (const struct GNUNET_DHT_PathElement *) &prm[1],
2338 .put_path_length = ntohs (prm->put_path_length), 2334 .put_path_length = ntohs (prm->put_path_length),
diff --git a/src/dht/gnunet-service-dht_neighbours.h b/src/dht/gnunet-service-dht_neighbours.h
index 4f4172f71..96db21b9b 100644
--- a/src/dht/gnunet-service-dht_neighbours.h
+++ b/src/dht/gnunet-service-dht_neighbours.h
@@ -54,15 +54,13 @@ GDS_NEIGHBOURS_lookup_peer (const struct GNUNET_PeerIdentity *target);
54 * network). 54 * network).
55 * 55 *
56 * @param bd data about the block 56 * @param bd data about the block
57 * @param options routing options
58 * @param desired_replication_level desired replication level 57 * @param desired_replication_level desired replication level
59 * @param hop_count how many hops has this message traversed so far 58 * @param hop_count how many hops has this message traversed so far
60 * @param bf Bloom filter of peers this PUT has already traversed 59 * @param bf Bloom filter of peers this PUT has already traversed
61 * @return #GNUNET_OK if the request was forwarded, #GNUNET_NO if not 60 * @return #GNUNET_OK if the request was forwarded, #GNUNET_NO if not
62 */ 61 */
63enum GNUNET_GenericReturnValue 62enum GNUNET_GenericReturnValue
64GDS_NEIGHBOURS_handle_put (const struct GDS_DATACACHE_BlockData *bd, 63GDS_NEIGHBOURS_handle_put (const struct GNUNET_DATACACHE_Block *bd,
65 enum GNUNET_DHT_RouteOption options,
66 uint16_t desired_replication_level, 64 uint16_t desired_replication_level,
67 uint16_t hop_count, 65 uint16_t hop_count,
68 struct GNUNET_CONTAINER_BloomFilter *bf); 66 struct GNUNET_CONTAINER_BloomFilter *bf);
@@ -112,7 +110,7 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
112 */ 110 */
113bool 111bool
114GDS_NEIGHBOURS_handle_reply (struct PeerInfo *pi, 112GDS_NEIGHBOURS_handle_reply (struct PeerInfo *pi,
115 const struct GDS_DATACACHE_BlockData *bd, 113 const struct GNUNET_DATACACHE_Block *bd,
116 const struct GNUNET_HashCode *query_hash, 114 const struct GNUNET_HashCode *query_hash,
117 unsigned int get_path_length, 115 unsigned int get_path_length,
118 const struct GNUNET_DHT_PathElement *get_path); 116 const struct GNUNET_DHT_PathElement *get_path);
diff --git a/src/dht/gnunet-service-dht_routing.c b/src/dht/gnunet-service-dht_routing.c
index 6deb5fa16..8f87751bb 100644
--- a/src/dht/gnunet-service-dht_routing.c
+++ b/src/dht/gnunet-service-dht_routing.c
@@ -105,7 +105,7 @@ struct ProcessContext
105 /** 105 /**
106 * Block data. 106 * Block data.
107 */ 107 */
108 const struct GDS_DATACACHE_BlockData *bd; 108 const struct GNUNET_DATACACHE_Block *bd;
109 109
110 /** 110 /**
111 * Path of the reply. 111 * Path of the reply.
@@ -137,7 +137,7 @@ process (void *cls,
137 struct RecentRequest *rr = value; 137 struct RecentRequest *rr = value;
138 enum GNUNET_BLOCK_ReplyEvaluationResult eval; 138 enum GNUNET_BLOCK_ReplyEvaluationResult eval;
139 unsigned int get_path_length; 139 unsigned int get_path_length;
140 struct GDS_DATACACHE_BlockData bdx = *pc->bd; 140 struct GNUNET_DATACACHE_Block bdx = *pc->bd;
141 141
142 if ( (rr->type != GNUNET_BLOCK_TYPE_ANY) && 142 if ( (rr->type != GNUNET_BLOCK_TYPE_ANY) &&
143 (rr->type != pc->bd->type) ) 143 (rr->type != pc->bd->type) )
@@ -252,7 +252,7 @@ process (void *cls,
252 * @param get_path peers this reply has traversed so far (if tracked) 252 * @param get_path peers this reply has traversed so far (if tracked)
253 */ 253 */
254void 254void
255GDS_ROUTING_process (const struct GDS_DATACACHE_BlockData *bd, 255GDS_ROUTING_process (const struct GNUNET_DATACACHE_Block *bd,
256 const struct GNUNET_HashCode *query_hash, 256 const struct GNUNET_HashCode *query_hash,
257 unsigned int get_path_length, 257 unsigned int get_path_length,
258 const struct GNUNET_DHT_PathElement *get_path) 258 const struct GNUNET_DHT_PathElement *get_path)
diff --git a/src/dht/gnunet-service-dht_routing.h b/src/dht/gnunet-service-dht_routing.h
index 1e35f3dc0..08c7de870 100644
--- a/src/dht/gnunet-service-dht_routing.h
+++ b/src/dht/gnunet-service-dht_routing.h
@@ -44,7 +44,7 @@
44 * @param get_path peers this reply has traversed so far (if tracked) 44 * @param get_path peers this reply has traversed so far (if tracked)
45 */ 45 */
46void 46void
47GDS_ROUTING_process (const struct GDS_DATACACHE_BlockData *bd, 47GDS_ROUTING_process (const struct GNUNET_DATACACHE_Block *bd,
48 const struct GNUNET_HashCode *query_hash, 48 const struct GNUNET_HashCode *query_hash,
49 unsigned int get_path_length, 49 unsigned int get_path_length,
50 const struct GNUNET_DHT_PathElement *get_path); 50 const struct GNUNET_DHT_PathElement *get_path);