aboutsummaryrefslogtreecommitdiff
path: root/src/datacache
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-01-09 12:22:04 +0100
committerChristian Grothoff <christian@grothoff.org>2022-01-09 12:22:04 +0100
commitec19c1e316efdd29a7af0524fc2ff33cc4b19d09 (patch)
tree184a59ff1c8408c462254e53f7e2004be829e237 /src/datacache
parentc3ecadd45b11f82e22ba81b42864c7826d0f97c6 (diff)
downloadgnunet-ec19c1e316efdd29a7af0524fc2ff33cc4b19d09.tar.gz
gnunet-ec19c1e316efdd29a7af0524fc2ff33cc4b19d09.zip
DHT: modify API and protocol messages to add path signatures, except for now the actual signatures are just placeholders (signing and signature verification are missing)
Diffstat (limited to 'src/datacache')
-rw-r--r--src/datacache/datacache.c2
-rw-r--r--src/datacache/perf_datacache.c16
-rw-r--r--src/datacache/plugin_datacache_heap.c11
-rw-r--r--src/datacache/plugin_datacache_postgres.c16
-rw-r--r--src/datacache/plugin_datacache_sqlite.c16
-rw-r--r--src/datacache/plugin_datacache_template.c2
-rw-r--r--src/datacache/test_datacache.c2
-rw-r--r--src/datacache/test_datacache_data_postgres.conf4
8 files changed, 37 insertions, 32 deletions
diff --git a/src/datacache/datacache.c b/src/datacache/datacache.c
index 8b665e705..944a99aad 100644
--- a/src/datacache/datacache.c
+++ b/src/datacache/datacache.c
@@ -243,7 +243,7 @@ GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h,
243 enum GNUNET_BLOCK_Type type, 243 enum GNUNET_BLOCK_Type type,
244 struct GNUNET_TIME_Absolute discard_time, 244 struct GNUNET_TIME_Absolute discard_time,
245 unsigned int path_info_len, 245 unsigned int path_info_len,
246 const struct GNUNET_PeerIdentity *path_info) 246 const struct GNUNET_DHT_PathElement *path_info)
247{ 247{
248 ssize_t used; 248 ssize_t used;
249 249
diff --git a/src/datacache/perf_datacache.c b/src/datacache/perf_datacache.c
index ce3b4c25d..84bc4a852 100644
--- a/src/datacache/perf_datacache.c
+++ b/src/datacache/perf_datacache.c
@@ -47,21 +47,27 @@ static const char *plugin_name;
47 47
48static int 48static int
49checkIt (void *cls, 49checkIt (void *cls,
50 const struct GNUNET_HashCode *key, size_t size, const char *data, 50 const struct GNUNET_HashCode *key,
51 size_t size,
52 const char *data,
51 enum GNUNET_BLOCK_Type type, 53 enum GNUNET_BLOCK_Type type,
52 struct GNUNET_TIME_Absolute exp, 54 struct GNUNET_TIME_Absolute exp,
53 unsigned int path_len, 55 unsigned int path_len,
54 const struct GNUNET_PeerIdentity *path) 56 const struct GNUNET_DHT_PathElement *path)
55{ 57{
56 if ((size == sizeof(struct GNUNET_HashCode)) && (0 == memcmp (data, cls, 58 if ( (size == sizeof(struct GNUNET_HashCode)) &&
57 size))) 59 (0 == memcmp (data,
60 cls,
61 size)) )
58 found++; 62 found++;
59 return GNUNET_OK; 63 return GNUNET_OK;
60} 64}
61 65
62 66
63static void 67static void
64run (void *cls, char *const *args, const char *cfgfile, 68run (void *cls,
69 char *const *args,
70 const char *cfgfile,
65 const struct GNUNET_CONFIGURATION_Handle *cfg) 71 const struct GNUNET_CONFIGURATION_Handle *cfg)
66{ 72{
67 struct GNUNET_DATACACHE_Handle *h; 73 struct GNUNET_DATACACHE_Handle *h;
diff --git a/src/datacache/plugin_datacache_heap.c b/src/datacache/plugin_datacache_heap.c
index 20d18458d..fbd3aea9a 100644
--- a/src/datacache/plugin_datacache_heap.c
+++ b/src/datacache/plugin_datacache_heap.c
@@ -80,7 +80,7 @@ struct Value
80 /** 80 /**
81 * Path information. 81 * Path information.
82 */ 82 */
83 struct GNUNET_PeerIdentity *path_info; 83 struct GNUNET_DHT_PathElement *path_info;
84 84
85 /** 85 /**
86 * Payload (actual payload follows this struct) 86 * Payload (actual payload follows this struct)
@@ -125,7 +125,7 @@ struct PutContext
125 /** 125 /**
126 * Path information. 126 * Path information.
127 */ 127 */
128 const struct GNUNET_PeerIdentity *path_info; 128 const struct GNUNET_DHT_PathElement *path_info;
129 129
130 /** 130 /**
131 * Number of bytes in @e data. 131 * Number of bytes in @e data.
@@ -181,7 +181,8 @@ put_cb (void *cls,
181 put_ctx->path_info_len); 181 put_ctx->path_info_len);
182 GNUNET_memcpy (val->path_info, 182 GNUNET_memcpy (val->path_info,
183 put_ctx->path_info, 183 put_ctx->path_info,
184 put_ctx->path_info_len * sizeof(struct GNUNET_PeerIdentity)); 184 put_ctx->path_info_len * sizeof(struct
185 GNUNET_DHT_PathElement));
185 GNUNET_CONTAINER_heap_update_cost (val->hn, 186 GNUNET_CONTAINER_heap_update_cost (val->hn,
186 val->discard_time.abs_value_us); 187 val->discard_time.abs_value_us);
187 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 188 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -219,7 +220,7 @@ heap_plugin_put (void *cls,
219 enum GNUNET_BLOCK_Type type, 220 enum GNUNET_BLOCK_Type type,
220 struct GNUNET_TIME_Absolute discard_time, 221 struct GNUNET_TIME_Absolute discard_time,
221 unsigned int path_info_len, 222 unsigned int path_info_len,
222 const struct GNUNET_PeerIdentity *path_info) 223 const struct GNUNET_DHT_PathElement *path_info)
223{ 224{
224 struct Plugin *plugin = cls; 225 struct Plugin *plugin = cls;
225 struct Value *val; 226 struct Value *val;
@@ -255,7 +256,7 @@ heap_plugin_put (void *cls,
255 path_info_len); 256 path_info_len);
256 GNUNET_memcpy (val->path_info, 257 GNUNET_memcpy (val->path_info,
257 path_info, 258 path_info,
258 path_info_len * sizeof(struct GNUNET_PeerIdentity)); 259 path_info_len * sizeof(struct GNUNET_DHT_PathElement));
259 (void) GNUNET_CONTAINER_multihashmap_put (plugin->map, 260 (void) GNUNET_CONTAINER_multihashmap_put (plugin->map,
260 &val->key, 261 &val->key,
261 val, 262 val,
diff --git a/src/datacache/plugin_datacache_postgres.c b/src/datacache/plugin_datacache_postgres.c
index 070619137..6a44c44a5 100644
--- a/src/datacache/plugin_datacache_postgres.c
+++ b/src/datacache/plugin_datacache_postgres.c
@@ -156,7 +156,7 @@ postgres_plugin_put (void *cls,
156 enum GNUNET_BLOCK_Type type, 156 enum GNUNET_BLOCK_Type type,
157 struct GNUNET_TIME_Absolute discard_time, 157 struct GNUNET_TIME_Absolute discard_time,
158 unsigned int path_info_len, 158 unsigned int path_info_len,
159 const struct GNUNET_PeerIdentity *path_info) 159 const struct GNUNET_DHT_PathElement *path_info)
160{ 160{
161 struct Plugin *plugin = cls; 161 struct Plugin *plugin = cls;
162 uint32_t type32 = (uint32_t) type; 162 uint32_t type32 = (uint32_t) type;
@@ -168,7 +168,7 @@ postgres_plugin_put (void *cls,
168 GNUNET_PQ_query_param_fixed_size (data, data_size), 168 GNUNET_PQ_query_param_fixed_size (data, data_size),
169 GNUNET_PQ_query_param_fixed_size (path_info, 169 GNUNET_PQ_query_param_fixed_size (path_info,
170 path_info_len * sizeof(struct 170 path_info_len * sizeof(struct
171 GNUNET_PeerIdentity)), 171 GNUNET_DHT_PathElement)),
172 GNUNET_PQ_query_param_end 172 GNUNET_PQ_query_param_end
173 }; 173 };
174 enum GNUNET_DB_QueryStatus ret; 174 enum GNUNET_DB_QueryStatus ret;
@@ -227,7 +227,7 @@ handle_results (void *cls,
227 uint32_t type; 227 uint32_t type;
228 void *data; 228 void *data;
229 size_t data_size; 229 size_t data_size;
230 struct GNUNET_PeerIdentity *path; 230 struct GNUNET_DHT_PathElement *path;
231 size_t path_len; 231 size_t path_len;
232 struct GNUNET_PQ_ResultSpec rs[] = { 232 struct GNUNET_PQ_ResultSpec rs[] = {
233 GNUNET_PQ_result_spec_absolute_time ("discard_time", 233 GNUNET_PQ_result_spec_absolute_time ("discard_time",
@@ -251,12 +251,12 @@ handle_results (void *cls,
251 GNUNET_break (0); 251 GNUNET_break (0);
252 return; 252 return;
253 } 253 }
254 if (0 != (path_len % sizeof(struct GNUNET_PeerIdentity))) 254 if (0 != (path_len % sizeof(struct GNUNET_DHT_PathElement)))
255 { 255 {
256 GNUNET_break (0); 256 GNUNET_break (0);
257 path_len = 0; 257 path_len = 0;
258 } 258 }
259 path_len %= sizeof(struct GNUNET_PeerIdentity); 259 path_len %= sizeof(struct GNUNET_DHT_PathElement);
260 LOG (GNUNET_ERROR_TYPE_DEBUG, 260 LOG (GNUNET_ERROR_TYPE_DEBUG,
261 "Found result of size %u bytes and type %u in database\n", 261 "Found result of size %u bytes and type %u in database\n",
262 (unsigned int) data_size, 262 (unsigned int) data_size,
@@ -446,7 +446,7 @@ extract_result_cb (void *cls,
446 uint32_t type; 446 uint32_t type;
447 void *data; 447 void *data;
448 size_t data_size; 448 size_t data_size;
449 struct GNUNET_PeerIdentity *path; 449 struct GNUNET_DHT_PathElement *path;
450 size_t path_len; 450 size_t path_len;
451 struct GNUNET_HashCode key; 451 struct GNUNET_HashCode key;
452 struct GNUNET_PQ_ResultSpec rs[] = { 452 struct GNUNET_PQ_ResultSpec rs[] = {
@@ -473,12 +473,12 @@ extract_result_cb (void *cls,
473 GNUNET_break (0); 473 GNUNET_break (0);
474 return; 474 return;
475 } 475 }
476 if (0 != (path_len % sizeof(struct GNUNET_PeerIdentity))) 476 if (0 != (path_len % sizeof(struct GNUNET_DHT_PathElement)))
477 { 477 {
478 GNUNET_break (0); 478 GNUNET_break (0);
479 path_len = 0; 479 path_len = 0;
480 } 480 }
481 path_len %= sizeof(struct GNUNET_PeerIdentity); 481 path_len %= sizeof(struct GNUNET_DHT_PathElement);
482 LOG (GNUNET_ERROR_TYPE_DEBUG, 482 LOG (GNUNET_ERROR_TYPE_DEBUG,
483 "Found result of size %u bytes and type %u in database\n", 483 "Found result of size %u bytes and type %u in database\n",
484 (unsigned int) data_size, 484 (unsigned int) data_size,
diff --git a/src/datacache/plugin_datacache_sqlite.c b/src/datacache/plugin_datacache_sqlite.c
index 0c894556b..d08b32caf 100644
--- a/src/datacache/plugin_datacache_sqlite.c
+++ b/src/datacache/plugin_datacache_sqlite.c
@@ -192,7 +192,7 @@ sqlite_plugin_put (void *cls,
192 enum GNUNET_BLOCK_Type type, 192 enum GNUNET_BLOCK_Type type,
193 struct GNUNET_TIME_Absolute discard_time, 193 struct GNUNET_TIME_Absolute discard_time,
194 unsigned int path_info_len, 194 unsigned int path_info_len,
195 const struct GNUNET_PeerIdentity *path_info) 195 const struct GNUNET_DHT_PathElement *path_info)
196{ 196{
197 struct Plugin *plugin = cls; 197 struct Plugin *plugin = cls;
198 uint32_t type32 = type; 198 uint32_t type32 = type;
@@ -204,7 +204,7 @@ sqlite_plugin_put (void *cls,
204 GNUNET_SQ_query_param_fixed_size (data, size), 204 GNUNET_SQ_query_param_fixed_size (data, size),
205 GNUNET_SQ_query_param_fixed_size (path_info, 205 GNUNET_SQ_query_param_fixed_size (path_info,
206 path_info_len 206 path_info_len
207 * sizeof(struct GNUNET_PeerIdentity)), 207 * sizeof(struct GNUNET_DHT_PathElement)),
208 GNUNET_SQ_query_param_end }; 208 GNUNET_SQ_query_param_end };
209 209
210 LOG (GNUNET_ERROR_TYPE_DEBUG, 210 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -265,7 +265,7 @@ sqlite_plugin_get (void *cls,
265 uint32_t off; 265 uint32_t off;
266 unsigned int total; 266 unsigned int total;
267 size_t psize; 267 size_t psize;
268 struct GNUNET_PeerIdentity *path; 268 struct GNUNET_DHT_PathElement *path;
269 struct GNUNET_SQ_QueryParam params_count[] = 269 struct GNUNET_SQ_QueryParam params_count[] =
270 { GNUNET_SQ_query_param_auto_from_type (key), 270 { GNUNET_SQ_query_param_auto_from_type (key),
271 GNUNET_SQ_query_param_uint32 (&type32), 271 GNUNET_SQ_query_param_uint32 (&type32),
@@ -339,13 +339,13 @@ sqlite_plugin_get (void *cls,
339 GNUNET_SQ_reset (plugin->dbh, plugin->get_stmt); 339 GNUNET_SQ_reset (plugin->dbh, plugin->get_stmt);
340 break; 340 break;
341 } 341 }
342 if (0 != psize % sizeof(struct GNUNET_PeerIdentity)) 342 if (0 != psize % sizeof(struct GNUNET_DHT_PathElement))
343 { 343 {
344 GNUNET_break (0); 344 GNUNET_break (0);
345 psize = 0; 345 psize = 0;
346 path = NULL; 346 path = NULL;
347 } 347 }
348 psize /= sizeof(struct GNUNET_PeerIdentity); 348 psize /= sizeof(struct GNUNET_DHT_PathElement);
349 cnt++; 349 cnt++;
350 LOG (GNUNET_ERROR_TYPE_DEBUG, 350 LOG (GNUNET_ERROR_TYPE_DEBUG,
351 "Found %u-byte result when processing GET for key `%s'\n", 351 "Found %u-byte result when processing GET for key `%s'\n",
@@ -476,7 +476,7 @@ sqlite_plugin_get_closest (void *cls,
476 size_t psize; 476 size_t psize;
477 uint32_t type; 477 uint32_t type;
478 struct GNUNET_HashCode hc; 478 struct GNUNET_HashCode hc;
479 struct GNUNET_PeerIdentity *path; 479 struct GNUNET_DHT_PathElement *path;
480 struct GNUNET_SQ_QueryParam params[] = 480 struct GNUNET_SQ_QueryParam params[] =
481 { GNUNET_SQ_query_param_auto_from_type (key), 481 { GNUNET_SQ_query_param_auto_from_type (key),
482 GNUNET_SQ_query_param_absolute_time (&now), 482 GNUNET_SQ_query_param_absolute_time (&now),
@@ -510,13 +510,13 @@ sqlite_plugin_get_closest (void *cls,
510 GNUNET_break (0); 510 GNUNET_break (0);
511 break; 511 break;
512 } 512 }
513 if (0 != psize % sizeof(struct GNUNET_PeerIdentity)) 513 if (0 != psize % sizeof(struct GNUNET_DHT_PathElement))
514 { 514 {
515 GNUNET_break (0); 515 GNUNET_break (0);
516 psize = 0; 516 psize = 0;
517 path = NULL; 517 path = NULL;
518 } 518 }
519 psize /= sizeof(struct GNUNET_PeerIdentity); 519 psize /= sizeof(struct GNUNET_DHT_PathElement);
520 cnt++; 520 cnt++;
521 LOG (GNUNET_ERROR_TYPE_DEBUG, 521 LOG (GNUNET_ERROR_TYPE_DEBUG,
522 "Found %u-byte result at %s when processing GET_CLOSE\n", 522 "Found %u-byte result at %s when processing GET_CLOSE\n",
diff --git a/src/datacache/plugin_datacache_template.c b/src/datacache/plugin_datacache_template.c
index 09279f55c..231413ce9 100644
--- a/src/datacache/plugin_datacache_template.c
+++ b/src/datacache/plugin_datacache_template.c
@@ -63,7 +63,7 @@ template_plugin_put (void *cls,
63 enum GNUNET_BLOCK_Type type, 63 enum GNUNET_BLOCK_Type type,
64 struct GNUNET_TIME_Absolute discard_time, 64 struct GNUNET_TIME_Absolute discard_time,
65 unsigned int path_info_len, 65 unsigned int path_info_len,
66 const struct GNUNET_PeerIdentity *path_info) 66 const struct GNUNET_DHT_PathElement *path_info)
67{ 67{
68 GNUNET_break (0); 68 GNUNET_break (0);
69 return -1; 69 return -1;
diff --git a/src/datacache/test_datacache.c b/src/datacache/test_datacache.c
index 6f6e4eec1..5740d2b7d 100644
--- a/src/datacache/test_datacache.c
+++ b/src/datacache/test_datacache.c
@@ -46,7 +46,7 @@ checkIt (void *cls,
46 enum GNUNET_BLOCK_Type type, 46 enum GNUNET_BLOCK_Type type,
47 struct GNUNET_TIME_Absolute exp, 47 struct GNUNET_TIME_Absolute exp,
48 unsigned int path_len, 48 unsigned int path_len,
49 const struct GNUNET_PeerIdentity *path) 49 const struct GNUNET_DHT_PathElement *path)
50{ 50{
51 (void) key; 51 (void) key;
52 (void) type; 52 (void) type;
diff --git a/src/datacache/test_datacache_data_postgres.conf b/src/datacache/test_datacache_data_postgres.conf
index 47c954b55..92313157c 100644
--- a/src/datacache/test_datacache_data_postgres.conf
+++ b/src/datacache/test_datacache_data_postgres.conf
@@ -4,6 +4,4 @@ QUOTA = 1 MB
4DATABASE = postgres 4DATABASE = postgres
5 5
6[datacache-postgres] 6[datacache-postgres]
7CONFIG = connect_timeout=10; dbname=gnunetcheck 7CONFIG = postgres:///gnunetcheck
8
9