diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-04-24 13:08:05 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-04-24 13:08:05 +0000 |
commit | 32892c4aa7736eb8039f28d79b5cdb53cdc0061c (patch) | |
tree | 9729d165562c1780934a9a979dbc06d7f8470592 /src | |
parent | bf6e480c1dda383bd55b311039d8d41189c5feea (diff) | |
download | gnunet-32892c4aa7736eb8039f28d79b5cdb53cdc0061c.tar.gz gnunet-32892c4aa7736eb8039f28d79b5cdb53cdc0061c.zip |
off-line hack fest
Diffstat (limited to 'src')
42 files changed, 990 insertions, 527 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 94092e1a8..d54db16fe 100644 --- a/src/Makefile.am +++ b/src/Makefile.am | |||
@@ -9,6 +9,7 @@ endif | |||
9 | SUBDIRS = \ | 9 | SUBDIRS = \ |
10 | include $(INTLEMU_SUBDIRS) \ | 10 | include $(INTLEMU_SUBDIRS) \ |
11 | util \ | 11 | util \ |
12 | block \ | ||
12 | statistics \ | 13 | statistics \ |
13 | arm \ | 14 | arm \ |
14 | hello \ | 15 | hello \ |
@@ -23,4 +24,5 @@ SUBDIRS = \ | |||
23 | hostlist \ | 24 | hostlist \ |
24 | topology \ | 25 | topology \ |
25 | $(NAT_DIR) \ | 26 | $(NAT_DIR) \ |
26 | fs | 27 | fs \ |
28 | migration | ||
diff --git a/src/datacache/datacache.c b/src/datacache/datacache.c index c8530055d..4c474e9ba 100644 --- a/src/datacache/datacache.c +++ b/src/datacache/datacache.c | |||
@@ -224,7 +224,7 @@ GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h, | |||
224 | const GNUNET_HashCode * key, | 224 | const GNUNET_HashCode * key, |
225 | uint32_t size, | 225 | uint32_t size, |
226 | const char *data, | 226 | const char *data, |
227 | unsigned int type, | 227 | enum GNUNET_BLOCK_Type type, |
228 | struct GNUNET_TIME_Absolute discard_time) | 228 | struct GNUNET_TIME_Absolute discard_time) |
229 | { | 229 | { |
230 | uint32_t used; | 230 | uint32_t used; |
@@ -259,7 +259,7 @@ GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h, | |||
259 | unsigned int | 259 | unsigned int |
260 | GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h, | 260 | GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h, |
261 | const GNUNET_HashCode * key, | 261 | const GNUNET_HashCode * key, |
262 | unsigned int type, | 262 | enum GNUNET_BLOCK_Type type, |
263 | GNUNET_DATACACHE_Iterator iter, | 263 | GNUNET_DATACACHE_Iterator iter, |
264 | void *iter_cls) | 264 | void *iter_cls) |
265 | { | 265 | { |
diff --git a/src/datacache/perf_datacache.c b/src/datacache/perf_datacache.c index 818b6f816..45d2d008b 100644 --- a/src/datacache/perf_datacache.c +++ b/src/datacache/perf_datacache.c | |||
@@ -42,7 +42,7 @@ checkIt (void *cls, | |||
42 | const GNUNET_HashCode * key, | 42 | const GNUNET_HashCode * key, |
43 | uint32_t size, | 43 | uint32_t size, |
44 | const char *data, | 44 | const char *data, |
45 | uint32_t type) | 45 | enum GNUNET_BLOCK_Type type) |
46 | { | 46 | { |
47 | if ( (size == sizeof (GNUNET_HashCode)) && | 47 | if ( (size == sizeof (GNUNET_HashCode)) && |
48 | (0 == memcmp (data, cls, size)) ) | 48 | (0 == memcmp (data, cls, size)) ) |
diff --git a/src/datacache/plugin_datacache.h b/src/datacache/plugin_datacache.h index d3768cf44..c7360834b 100644 --- a/src/datacache/plugin_datacache.h +++ b/src/datacache/plugin_datacache.h | |||
@@ -116,7 +116,7 @@ struct GNUNET_DATACACHE_PluginFunctions { | |||
116 | const GNUNET_HashCode * key, | 116 | const GNUNET_HashCode * key, |
117 | uint32_t size, | 117 | uint32_t size, |
118 | const char *data, | 118 | const char *data, |
119 | uint32_t type, | 119 | enum GNUNET_BLOCK_Type type, |
120 | struct GNUNET_TIME_Absolute discard_time); | 120 | struct GNUNET_TIME_Absolute discard_time); |
121 | 121 | ||
122 | 122 | ||
@@ -133,7 +133,7 @@ struct GNUNET_DATACACHE_PluginFunctions { | |||
133 | */ | 133 | */ |
134 | unsigned int (*get) (void *cls, | 134 | unsigned int (*get) (void *cls, |
135 | const GNUNET_HashCode * key, | 135 | const GNUNET_HashCode * key, |
136 | uint32_t type, | 136 | enum GNUNET_BLOCK_Type type, |
137 | GNUNET_DATACACHE_Iterator iter, | 137 | GNUNET_DATACACHE_Iterator iter, |
138 | void *iter_cls); | 138 | void *iter_cls); |
139 | 139 | ||
diff --git a/src/datacache/plugin_datacache_sqlite.c b/src/datacache/plugin_datacache_sqlite.c index 7595211c1..98bcae788 100644 --- a/src/datacache/plugin_datacache_sqlite.c +++ b/src/datacache/plugin_datacache_sqlite.c | |||
@@ -99,7 +99,7 @@ sqlite_plugin_put (void *cls, | |||
99 | const GNUNET_HashCode * key, | 99 | const GNUNET_HashCode * key, |
100 | uint32_t size, | 100 | uint32_t size, |
101 | const char *data, | 101 | const char *data, |
102 | uint32_t type, | 102 | enum GNUNET_BLOCK_Type type, |
103 | struct GNUNET_TIME_Absolute discard_time) | 103 | struct GNUNET_TIME_Absolute discard_time) |
104 | { | 104 | { |
105 | struct Plugin *plugin = cls; | 105 | struct Plugin *plugin = cls; |
@@ -166,7 +166,7 @@ sqlite_plugin_put (void *cls, | |||
166 | static unsigned int | 166 | static unsigned int |
167 | sqlite_plugin_get (void *cls, | 167 | sqlite_plugin_get (void *cls, |
168 | const GNUNET_HashCode * key, | 168 | const GNUNET_HashCode * key, |
169 | uint32_t type, | 169 | enum GNUNET_BLOCK_Type type, |
170 | GNUNET_DATACACHE_Iterator iter, | 170 | GNUNET_DATACACHE_Iterator iter, |
171 | void *iter_cls) | 171 | void *iter_cls) |
172 | { | 172 | { |
diff --git a/src/datacache/plugin_datacache_template.c b/src/datacache/plugin_datacache_template.c index 163f72a7a..8488d5a32 100644 --- a/src/datacache/plugin_datacache_template.c +++ b/src/datacache/plugin_datacache_template.c | |||
@@ -56,7 +56,7 @@ template_plugin_put (void *cls, | |||
56 | const GNUNET_HashCode * key, | 56 | const GNUNET_HashCode * key, |
57 | uint32_t size, | 57 | uint32_t size, |
58 | const char *data, | 58 | const char *data, |
59 | uint32_t type, | 59 | enum GNUNET_BLOCK_Type type, |
60 | struct GNUNET_TIME_Absolute discard_time) | 60 | struct GNUNET_TIME_Absolute discard_time) |
61 | { | 61 | { |
62 | GNUNET_break (0); | 62 | GNUNET_break (0); |
@@ -78,7 +78,7 @@ template_plugin_put (void *cls, | |||
78 | static unsigned int | 78 | static unsigned int |
79 | template_plugin_get (void *cls, | 79 | template_plugin_get (void *cls, |
80 | const GNUNET_HashCode * key, | 80 | const GNUNET_HashCode * key, |
81 | uint32_t type, | 81 | enum GNUNET_BLOCK_Type type, |
82 | GNUNET_DATACACHE_Iterator iter, | 82 | GNUNET_DATACACHE_Iterator iter, |
83 | void *iter_cls) | 83 | void *iter_cls) |
84 | { | 84 | { |
diff --git a/src/datacache/test_datacache.c b/src/datacache/test_datacache.c index c896b667b..babbff72e 100644 --- a/src/datacache/test_datacache.c +++ b/src/datacache/test_datacache.c | |||
@@ -39,7 +39,7 @@ checkIt (void *cls, | |||
39 | const GNUNET_HashCode * key, | 39 | const GNUNET_HashCode * key, |
40 | uint32_t size, | 40 | uint32_t size, |
41 | const char *data, | 41 | const char *data, |
42 | uint32_t type) | 42 | enum GNUNET_BLOCK_Type type) |
43 | { | 43 | { |
44 | if (size != sizeof (GNUNET_HashCode)) | 44 | if (size != sizeof (GNUNET_HashCode)) |
45 | { | 45 | { |
diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c index 7e7bf02c8..1c50dabee 100644 --- a/src/datastore/datastore_api.c +++ b/src/datastore/datastore_api.c | |||
@@ -319,7 +319,7 @@ GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h, | |||
319 | const GNUNET_HashCode * key, | 319 | const GNUNET_HashCode * key, |
320 | uint32_t size, | 320 | uint32_t size, |
321 | const void *data, | 321 | const void *data, |
322 | uint32_t type, | 322 | enum GNUNET_BLOCK_Type type, |
323 | uint32_t priority, | 323 | uint32_t priority, |
324 | uint32_t anonymity, | 324 | uint32_t anonymity, |
325 | struct GNUNET_TIME_Absolute expiration, | 325 | struct GNUNET_TIME_Absolute expiration, |
@@ -668,7 +668,7 @@ transmit_for_result (struct GNUNET_DATASTORE_Handle *h, | |||
668 | void | 668 | void |
669 | GNUNET_DATASTORE_get (struct GNUNET_DATASTORE_Handle *h, | 669 | GNUNET_DATASTORE_get (struct GNUNET_DATASTORE_Handle *h, |
670 | const GNUNET_HashCode * key, | 670 | const GNUNET_HashCode * key, |
671 | uint32_t type, | 671 | enum GNUNET_BLOCK_Type type, |
672 | GNUNET_DATASTORE_Iterator iter, void *iter_cls, | 672 | GNUNET_DATASTORE_Iterator iter, void *iter_cls, |
673 | struct GNUNET_TIME_Relative timeout) | 673 | struct GNUNET_TIME_Relative timeout) |
674 | { | 674 | { |
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c index 79fcd70e9..6d0f29671 100644 --- a/src/datastore/gnunet-service-datastore.c +++ b/src/datastore/gnunet-service-datastore.c | |||
@@ -288,7 +288,7 @@ expired_processor (void *cls, | |||
288 | const GNUNET_HashCode * key, | 288 | const GNUNET_HashCode * key, |
289 | uint32_t size, | 289 | uint32_t size, |
290 | const void *data, | 290 | const void *data, |
291 | uint32_t type, | 291 | enum GNUNET_BLOCK_Type type, |
292 | uint32_t priority, | 292 | uint32_t priority, |
293 | uint32_t anonymity, | 293 | uint32_t anonymity, |
294 | struct GNUNET_TIME_Absolute | 294 | struct GNUNET_TIME_Absolute |
@@ -375,7 +375,7 @@ manage (void *cls, | |||
375 | const GNUNET_HashCode * key, | 375 | const GNUNET_HashCode * key, |
376 | uint32_t size, | 376 | uint32_t size, |
377 | const void *data, | 377 | const void *data, |
378 | uint32_t type, | 378 | enum GNUNET_BLOCK_Type type, |
379 | uint32_t priority, | 379 | uint32_t priority, |
380 | uint32_t anonymity, | 380 | uint32_t anonymity, |
381 | struct GNUNET_TIME_Absolute | 381 | struct GNUNET_TIME_Absolute |
@@ -644,7 +644,7 @@ transmit_item (void *cls, | |||
644 | const GNUNET_HashCode * key, | 644 | const GNUNET_HashCode * key, |
645 | uint32_t size, | 645 | uint32_t size, |
646 | const void *data, | 646 | const void *data, |
647 | uint32_t type, | 647 | enum GNUNET_BLOCK_Type type, |
648 | uint32_t priority, | 648 | uint32_t priority, |
649 | uint32_t anonymity, | 649 | uint32_t anonymity, |
650 | struct GNUNET_TIME_Absolute | 650 | struct GNUNET_TIME_Absolute |
@@ -1094,7 +1094,7 @@ remove_callback (void *cls, | |||
1094 | const GNUNET_HashCode * key, | 1094 | const GNUNET_HashCode * key, |
1095 | uint32_t size, | 1095 | uint32_t size, |
1096 | const void *data, | 1096 | const void *data, |
1097 | uint32_t type, | 1097 | enum GNUNET_BLOCK_Type type, |
1098 | uint32_t priority, | 1098 | uint32_t priority, |
1099 | uint32_t anonymity, | 1099 | uint32_t anonymity, |
1100 | struct GNUNET_TIME_Absolute | 1100 | struct GNUNET_TIME_Absolute |
diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c index 93e875c8c..b92fefe4d 100644 --- a/src/datastore/perf_datastore_api.c +++ b/src/datastore/perf_datastore_api.c | |||
@@ -198,7 +198,7 @@ delete_value (void *cls, | |||
198 | const GNUNET_HashCode * key, | 198 | const GNUNET_HashCode * key, |
199 | uint32_t size, | 199 | uint32_t size, |
200 | const void *data, | 200 | const void *data, |
201 | uint32_t type, | 201 | enum GNUNET_BLOCK_Type type, |
202 | uint32_t priority, | 202 | uint32_t priority, |
203 | uint32_t anonymity, | 203 | uint32_t anonymity, |
204 | struct GNUNET_TIME_Absolute | 204 | struct GNUNET_TIME_Absolute |
diff --git a/src/datastore/perf_plugin_datastore.c b/src/datastore/perf_plugin_datastore.c index a23569875..ea1df5efa 100644 --- a/src/datastore/perf_plugin_datastore.c +++ b/src/datastore/perf_plugin_datastore.c | |||
@@ -140,7 +140,7 @@ iterateDummy (void *cls, | |||
140 | const GNUNET_HashCode * key, | 140 | const GNUNET_HashCode * key, |
141 | uint32_t size, | 141 | uint32_t size, |
142 | const void *data, | 142 | const void *data, |
143 | uint32_t type, | 143 | enum GNUNET_BLOCK_Type type, |
144 | uint32_t priority, | 144 | uint32_t priority, |
145 | uint32_t anonymity, | 145 | uint32_t anonymity, |
146 | struct GNUNET_TIME_Absolute | 146 | struct GNUNET_TIME_Absolute |
diff --git a/src/datastore/plugin_datastore.h b/src/datastore/plugin_datastore.h index 775a6641a..e8f433671 100644 --- a/src/datastore/plugin_datastore.h +++ b/src/datastore/plugin_datastore.h | |||
@@ -30,6 +30,7 @@ | |||
30 | #ifndef PLUGIN_DATASTORE_H | 30 | #ifndef PLUGIN_DATASTORE_H |
31 | #define PLUGIN_DATASTORE_H | 31 | #define PLUGIN_DATASTORE_H |
32 | 32 | ||
33 | #include "gnunet_block_lib.h" | ||
33 | #include "gnunet_configuration_lib.h" | 34 | #include "gnunet_configuration_lib.h" |
34 | #include "gnunet_datastore_service.h" | 35 | #include "gnunet_datastore_service.h" |
35 | #include "gnunet_statistics_service.h" | 36 | #include "gnunet_statistics_service.h" |
@@ -103,7 +104,7 @@ typedef int (*PluginIterator) (void *cls, | |||
103 | const GNUNET_HashCode * key, | 104 | const GNUNET_HashCode * key, |
104 | uint32_t size, | 105 | uint32_t size, |
105 | const void *data, | 106 | const void *data, |
106 | uint32_t type, | 107 | enum GNUNET_BLOCK_Type type, |
107 | uint32_t priority, | 108 | uint32_t priority, |
108 | uint32_t anonymity, | 109 | uint32_t anonymity, |
109 | struct GNUNET_TIME_Absolute | 110 | struct GNUNET_TIME_Absolute |
@@ -142,7 +143,7 @@ typedef int (*PluginPut) (void *cls, | |||
142 | const GNUNET_HashCode * key, | 143 | const GNUNET_HashCode * key, |
143 | uint32_t size, | 144 | uint32_t size, |
144 | const void *data, | 145 | const void *data, |
145 | uint32_t type, | 146 | enum GNUNET_BLOCK_Type type, |
146 | uint32_t priority, | 147 | uint32_t priority, |
147 | uint32_t anonymity, | 148 | uint32_t anonymity, |
148 | struct GNUNET_TIME_Absolute expiration, | 149 | struct GNUNET_TIME_Absolute expiration, |
@@ -173,7 +174,7 @@ typedef int (*PluginPut) (void *cls, | |||
173 | typedef void (*PluginGet) (void *cls, | 174 | typedef void (*PluginGet) (void *cls, |
174 | const GNUNET_HashCode * key, | 175 | const GNUNET_HashCode * key, |
175 | const GNUNET_HashCode * vhash, | 176 | const GNUNET_HashCode * vhash, |
176 | uint32_t type, | 177 | enum GNUNET_BLOCK_Type type, |
177 | PluginIterator iter, void *iter_cls); | 178 | PluginIterator iter, void *iter_cls); |
178 | 179 | ||
179 | 180 | ||
@@ -222,7 +223,7 @@ typedef int (*PluginUpdate) (void *cls, | |||
222 | * @param iter_cls closure for iter | 223 | * @param iter_cls closure for iter |
223 | */ | 224 | */ |
224 | typedef void (*PluginSelector) (void *cls, | 225 | typedef void (*PluginSelector) (void *cls, |
225 | uint32_t type, | 226 | enum GNUNET_BLOCK_Type type, |
226 | PluginIterator iter, | 227 | PluginIterator iter, |
227 | void *iter_cls); | 228 | void *iter_cls); |
228 | 229 | ||
diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c index 0d4170e56..824b74ad2 100644 --- a/src/datastore/plugin_datastore_sqlite.c +++ b/src/datastore/plugin_datastore_sqlite.c | |||
@@ -719,7 +719,7 @@ sqlite_plugin_put (void *cls, | |||
719 | const GNUNET_HashCode * key, | 719 | const GNUNET_HashCode * key, |
720 | uint32_t size, | 720 | uint32_t size, |
721 | const void *data, | 721 | const void *data, |
722 | uint32_t type, | 722 | enum GNUNET_BLOCK_Type type, |
723 | uint32_t priority, | 723 | uint32_t priority, |
724 | uint32_t anonymity, | 724 | uint32_t anonymity, |
725 | struct GNUNET_TIME_Absolute expiration, | 725 | struct GNUNET_TIME_Absolute expiration, |
@@ -892,7 +892,7 @@ struct IterContext | |||
892 | /** | 892 | /** |
893 | * Desired type for blocks returned by this iterator. | 893 | * Desired type for blocks returned by this iterator. |
894 | */ | 894 | */ |
895 | uint32_t type; | 895 | enum GNUNET_BLOCK_Type type; |
896 | }; | 896 | }; |
897 | 897 | ||
898 | 898 | ||
@@ -1026,7 +1026,7 @@ iter_next_prepare (void *cls, | |||
1026 | */ | 1026 | */ |
1027 | static void | 1027 | static void |
1028 | basic_iter (struct Plugin *plugin, | 1028 | basic_iter (struct Plugin *plugin, |
1029 | uint32_t type, | 1029 | enum GNUNET_BLOCK_Type type, |
1030 | int is_asc, | 1030 | int is_asc, |
1031 | int is_prio, | 1031 | int is_prio, |
1032 | int is_migr, | 1032 | int is_migr, |
@@ -1110,7 +1110,7 @@ basic_iter (struct Plugin *plugin, | |||
1110 | */ | 1110 | */ |
1111 | static void | 1111 | static void |
1112 | sqlite_plugin_iter_low_priority (void *cls, | 1112 | sqlite_plugin_iter_low_priority (void *cls, |
1113 | uint32_t type, | 1113 | enum GNUNET_BLOCK_Type type, |
1114 | PluginIterator iter, | 1114 | PluginIterator iter, |
1115 | void *iter_cls) | 1115 | void *iter_cls) |
1116 | { | 1116 | { |
@@ -1137,7 +1137,7 @@ sqlite_plugin_iter_low_priority (void *cls, | |||
1137 | */ | 1137 | */ |
1138 | static void | 1138 | static void |
1139 | sqlite_plugin_iter_zero_anonymity (void *cls, | 1139 | sqlite_plugin_iter_zero_anonymity (void *cls, |
1140 | uint32_t type, | 1140 | enum GNUNET_BLOCK_Type type, |
1141 | PluginIterator iter, | 1141 | PluginIterator iter, |
1142 | void *iter_cls) | 1142 | void *iter_cls) |
1143 | { | 1143 | { |
@@ -1176,7 +1176,7 @@ sqlite_plugin_iter_zero_anonymity (void *cls, | |||
1176 | */ | 1176 | */ |
1177 | static void | 1177 | static void |
1178 | sqlite_plugin_iter_ascending_expiration (void *cls, | 1178 | sqlite_plugin_iter_ascending_expiration (void *cls, |
1179 | uint32_t type, | 1179 | enum GNUNET_BLOCK_Type type, |
1180 | PluginIterator iter, | 1180 | PluginIterator iter, |
1181 | void *iter_cls) | 1181 | void *iter_cls) |
1182 | { | 1182 | { |
@@ -1213,7 +1213,7 @@ sqlite_plugin_iter_ascending_expiration (void *cls, | |||
1213 | */ | 1213 | */ |
1214 | static void | 1214 | static void |
1215 | sqlite_plugin_iter_migration_order (void *cls, | 1215 | sqlite_plugin_iter_migration_order (void *cls, |
1216 | uint32_t type, | 1216 | enum GNUNET_BLOCK_Type type, |
1217 | PluginIterator iter, | 1217 | PluginIterator iter, |
1218 | void *iter_cls) | 1218 | void *iter_cls) |
1219 | { | 1219 | { |
@@ -1288,7 +1288,7 @@ all_next_prepare (void *cls, | |||
1288 | */ | 1288 | */ |
1289 | static void | 1289 | static void |
1290 | sqlite_plugin_iter_all_now (void *cls, | 1290 | sqlite_plugin_iter_all_now (void *cls, |
1291 | uint32_t type, | 1291 | enum GNUNET_BLOCK_Type type, |
1292 | PluginIterator iter, | 1292 | PluginIterator iter, |
1293 | void *iter_cls) | 1293 | void *iter_cls) |
1294 | { | 1294 | { |
@@ -1439,7 +1439,7 @@ static void | |||
1439 | sqlite_plugin_get (void *cls, | 1439 | sqlite_plugin_get (void *cls, |
1440 | const GNUNET_HashCode * key, | 1440 | const GNUNET_HashCode * key, |
1441 | const GNUNET_HashCode * vhash, | 1441 | const GNUNET_HashCode * vhash, |
1442 | uint32_t type, | 1442 | enum GNUNET_BLOCK_Type type, |
1443 | PluginIterator iter, void *iter_cls) | 1443 | PluginIterator iter, void *iter_cls) |
1444 | { | 1444 | { |
1445 | struct Plugin *plugin = cls; | 1445 | struct Plugin *plugin = cls; |
diff --git a/src/datastore/plugin_datastore_template.c b/src/datastore/plugin_datastore_template.c index 6439bc019..7656f6a7d 100644 --- a/src/datastore/plugin_datastore_template.c +++ b/src/datastore/plugin_datastore_template.c | |||
@@ -70,12 +70,12 @@ static unsigned long long template_plugin_get_size (void *cls) | |||
70 | */ | 70 | */ |
71 | static int | 71 | static int |
72 | template_plugin_put (void *cls, | 72 | template_plugin_put (void *cls, |
73 | const GNUNET_HashCode * key, | 73 | const GNUNET_HashCode * key, |
74 | uint32_t size, | 74 | uint32_t size, |
75 | const void *data, | 75 | const void *data, |
76 | uint32_t type, | 76 | enum GNUNET_BLOCK_Type type, |
77 | uint32_t priority, | 77 | uint32_t priority, |
78 | uint32_t anonymity, | 78 | uint32_t anonymity, |
79 | struct GNUNET_TIME_Absolute expiration, | 79 | struct GNUNET_TIME_Absolute expiration, |
80 | char **msg) | 80 | char **msg) |
81 | { | 81 | { |
@@ -126,7 +126,7 @@ static void | |||
126 | template_plugin_get (void *cls, | 126 | template_plugin_get (void *cls, |
127 | const GNUNET_HashCode * key, | 127 | const GNUNET_HashCode * key, |
128 | const GNUNET_HashCode * vhash, | 128 | const GNUNET_HashCode * vhash, |
129 | uint32_t type, | 129 | enum GNUNET_BLOCK_Type type, |
130 | PluginIterator iter, void *iter_cls) | 130 | PluginIterator iter, void *iter_cls) |
131 | { | 131 | { |
132 | GNUNET_break (0); | 132 | GNUNET_break (0); |
@@ -181,7 +181,7 @@ template_plugin_update (void *cls, | |||
181 | */ | 181 | */ |
182 | static void | 182 | static void |
183 | template_plugin_iter_low_priority (void *cls, | 183 | template_plugin_iter_low_priority (void *cls, |
184 | uint32_t type, | 184 | enum GNUNET_BLOCK_Type type, |
185 | PluginIterator iter, | 185 | PluginIterator iter, |
186 | void *iter_cls) | 186 | void *iter_cls) |
187 | { | 187 | { |
@@ -203,9 +203,9 @@ template_plugin_iter_low_priority (void *cls, | |||
203 | */ | 203 | */ |
204 | static void | 204 | static void |
205 | template_plugin_iter_zero_anonymity (void *cls, | 205 | template_plugin_iter_zero_anonymity (void *cls, |
206 | uint32_t type, | 206 | enum GNUNET_BLOCK_Type type, |
207 | PluginIterator iter, | 207 | PluginIterator iter, |
208 | void *iter_cls) | 208 | void *iter_cls) |
209 | { | 209 | { |
210 | GNUNET_break (0); | 210 | GNUNET_break (0); |
211 | } | 211 | } |
@@ -225,9 +225,9 @@ template_plugin_iter_zero_anonymity (void *cls, | |||
225 | */ | 225 | */ |
226 | static void | 226 | static void |
227 | template_plugin_iter_ascending_expiration (void *cls, | 227 | template_plugin_iter_ascending_expiration (void *cls, |
228 | uint32_t type, | 228 | enum GNUNET_BLOCK_Type type, |
229 | PluginIterator iter, | 229 | PluginIterator iter, |
230 | void *iter_cls) | 230 | void *iter_cls) |
231 | { | 231 | { |
232 | GNUNET_break (0); | 232 | GNUNET_break (0); |
233 | } | 233 | } |
@@ -247,9 +247,9 @@ template_plugin_iter_ascending_expiration (void *cls, | |||
247 | */ | 247 | */ |
248 | static void | 248 | static void |
249 | template_plugin_iter_migration_order (void *cls, | 249 | template_plugin_iter_migration_order (void *cls, |
250 | uint32_t type, | 250 | enum GNUNET_BLOCK_Type type, |
251 | PluginIterator iter, | 251 | PluginIterator iter, |
252 | void *iter_cls) | 252 | void *iter_cls) |
253 | { | 253 | { |
254 | GNUNET_break (0); | 254 | GNUNET_break (0); |
255 | } | 255 | } |
@@ -269,9 +269,9 @@ template_plugin_iter_migration_order (void *cls, | |||
269 | */ | 269 | */ |
270 | static void | 270 | static void |
271 | template_plugin_iter_all_now (void *cls, | 271 | template_plugin_iter_all_now (void *cls, |
272 | uint32_t type, | 272 | enum GNUNET_BLOCK_Type type, |
273 | PluginIterator iter, | 273 | PluginIterator iter, |
274 | void *iter_cls) | 274 | void *iter_cls) |
275 | { | 275 | { |
276 | GNUNET_break (0); | 276 | GNUNET_break (0); |
277 | } | 277 | } |
diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c index 74c2ae206..07f1dc426 100644 --- a/src/datastore/test_datastore_api.c +++ b/src/datastore/test_datastore_api.c | |||
@@ -174,7 +174,7 @@ check_value (void *cls, | |||
174 | const GNUNET_HashCode * key, | 174 | const GNUNET_HashCode * key, |
175 | uint32_t size, | 175 | uint32_t size, |
176 | const void *data, | 176 | const void *data, |
177 | uint32_t type, | 177 | enum GNUNET_BLOCK_Type type, |
178 | uint32_t priority, | 178 | uint32_t priority, |
179 | uint32_t anonymity, | 179 | uint32_t anonymity, |
180 | struct GNUNET_TIME_Absolute | 180 | struct GNUNET_TIME_Absolute |
@@ -209,14 +209,14 @@ check_value (void *cls, | |||
209 | 209 | ||
210 | static void | 210 | static void |
211 | delete_value (void *cls, | 211 | delete_value (void *cls, |
212 | const GNUNET_HashCode * key, | 212 | const GNUNET_HashCode * key, |
213 | uint32_t size, | 213 | uint32_t size, |
214 | const void *data, | 214 | const void *data, |
215 | uint32_t type, | 215 | enum GNUNET_BLOCK_Type type, |
216 | uint32_t priority, | 216 | uint32_t priority, |
217 | uint32_t anonymity, | 217 | uint32_t anonymity, |
218 | struct GNUNET_TIME_Absolute | 218 | struct GNUNET_TIME_Absolute |
219 | expiration, uint64_t uid) | 219 | expiration, uint64_t uid) |
220 | { | 220 | { |
221 | struct CpsRunContext *crc = cls; | 221 | struct CpsRunContext *crc = cls; |
222 | if (key == NULL) | 222 | if (key == NULL) |
@@ -239,14 +239,14 @@ delete_value (void *cls, | |||
239 | 239 | ||
240 | static void | 240 | static void |
241 | check_nothing (void *cls, | 241 | check_nothing (void *cls, |
242 | const GNUNET_HashCode * key, | 242 | const GNUNET_HashCode * key, |
243 | uint32_t size, | 243 | uint32_t size, |
244 | const void *data, | 244 | const void *data, |
245 | uint32_t type, | 245 | enum GNUNET_BLOCK_Type type, |
246 | uint32_t priority, | 246 | uint32_t priority, |
247 | uint32_t anonymity, | 247 | uint32_t anonymity, |
248 | struct GNUNET_TIME_Absolute | 248 | struct GNUNET_TIME_Absolute |
249 | expiration, uint64_t uid) | 249 | expiration, uint64_t uid) |
250 | { | 250 | { |
251 | struct CpsRunContext *crc = cls; | 251 | struct CpsRunContext *crc = cls; |
252 | GNUNET_assert (key == NULL); | 252 | GNUNET_assert (key == NULL); |
@@ -266,7 +266,7 @@ check_multiple (void *cls, | |||
266 | const GNUNET_HashCode * key, | 266 | const GNUNET_HashCode * key, |
267 | uint32_t size, | 267 | uint32_t size, |
268 | const void *data, | 268 | const void *data, |
269 | uint32_t type, | 269 | enum GNUNET_BLOCK_Type type, |
270 | uint32_t priority, | 270 | uint32_t priority, |
271 | uint32_t anonymity, | 271 | uint32_t anonymity, |
272 | struct GNUNET_TIME_Absolute | 272 | struct GNUNET_TIME_Absolute |
@@ -296,7 +296,7 @@ check_update (void *cls, | |||
296 | const GNUNET_HashCode * key, | 296 | const GNUNET_HashCode * key, |
297 | uint32_t size, | 297 | uint32_t size, |
298 | const void *data, | 298 | const void *data, |
299 | uint32_t type, | 299 | enum GNUNET_BLOCK_Type type, |
300 | uint32_t priority, | 300 | uint32_t priority, |
301 | uint32_t anonymity, | 301 | uint32_t anonymity, |
302 | struct GNUNET_TIME_Absolute | 302 | struct GNUNET_TIME_Absolute |
diff --git a/src/datastore/test_datastore_api_management.c b/src/datastore/test_datastore_api_management.c index 62d1e5d26..169cef554 100644 --- a/src/datastore/test_datastore_api_management.c +++ b/src/datastore/test_datastore_api_management.c | |||
@@ -144,7 +144,7 @@ check_value (void *cls, | |||
144 | const GNUNET_HashCode * key, | 144 | const GNUNET_HashCode * key, |
145 | uint32_t size, | 145 | uint32_t size, |
146 | const void *data, | 146 | const void *data, |
147 | uint32_t type, | 147 | enum GNUNET_BLOCK_Type type, |
148 | uint32_t priority, | 148 | uint32_t priority, |
149 | uint32_t anonymity, | 149 | uint32_t anonymity, |
150 | struct GNUNET_TIME_Absolute | 150 | struct GNUNET_TIME_Absolute |
@@ -189,14 +189,14 @@ check_value (void *cls, | |||
189 | 189 | ||
190 | static void | 190 | static void |
191 | check_nothing (void *cls, | 191 | check_nothing (void *cls, |
192 | const GNUNET_HashCode * key, | 192 | const GNUNET_HashCode * key, |
193 | uint32_t size, | 193 | uint32_t size, |
194 | const void *data, | 194 | const void *data, |
195 | uint32_t type, | 195 | enum GNUNET_BLOCK_Type type, |
196 | uint32_t priority, | 196 | uint32_t priority, |
197 | uint32_t anonymity, | 197 | uint32_t anonymity, |
198 | struct GNUNET_TIME_Absolute | 198 | struct GNUNET_TIME_Absolute |
199 | expiration, uint64_t uid) | 199 | expiration, uint64_t uid) |
200 | { | 200 | { |
201 | struct CpsRunContext *crc = cls; | 201 | struct CpsRunContext *crc = cls; |
202 | 202 | ||
diff --git a/src/fs/Makefile.am b/src/fs/Makefile.am index e1b85092a..3d825ff10 100644 --- a/src/fs/Makefile.am +++ b/src/fs/Makefile.am | |||
@@ -98,6 +98,7 @@ gnunet_service_fs_SOURCES = \ | |||
98 | gnunet-service-fs_indexing.c gnunet-service-fs_indexing.h | 98 | gnunet-service-fs_indexing.c gnunet-service-fs_indexing.h |
99 | gnunet_service_fs_LDADD = \ | 99 | gnunet_service_fs_LDADD = \ |
100 | $(top_builddir)/src/fs/libgnunetfs.la \ | 100 | $(top_builddir)/src/fs/libgnunetfs.la \ |
101 | $(top_builddir)/src/block/libgnunetblock.la \ | ||
101 | $(top_builddir)/src/datastore/libgnunetdatastore.la \ | 102 | $(top_builddir)/src/datastore/libgnunetdatastore.la \ |
102 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 103 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
103 | $(top_builddir)/src/core/libgnunetcore.la \ | 104 | $(top_builddir)/src/core/libgnunetcore.la \ |
diff --git a/src/fs/fs.h b/src/fs/fs.h index a9a585a15..fdf501b44 100644 --- a/src/fs/fs.h +++ b/src/fs/fs.h | |||
@@ -29,6 +29,7 @@ | |||
29 | #include "gnunet_constants.h" | 29 | #include "gnunet_constants.h" |
30 | #include "gnunet_datastore_service.h" | 30 | #include "gnunet_datastore_service.h" |
31 | #include "gnunet_fs_service.h" | 31 | #include "gnunet_fs_service.h" |
32 | #include "gnunet_block_lib.h" | ||
32 | 33 | ||
33 | /** | 34 | /** |
34 | * Size of the individual blocks used for file-sharing. | 35 | * Size of the individual blocks used for file-sharing. |
@@ -1124,139 +1125,6 @@ struct GNUNET_FS_Namespace | |||
1124 | 1125 | ||
1125 | 1126 | ||
1126 | /** | 1127 | /** |
1127 | * @brief index block (indexing a DBlock that | ||
1128 | * can be obtained directly from reading | ||
1129 | * the plaintext file) | ||
1130 | */ | ||
1131 | struct OnDemandBlock | ||
1132 | { | ||
1133 | /** | ||
1134 | * Hash code of the entire content of the | ||
1135 | * file that was indexed (used to uniquely | ||
1136 | * identify the plaintext file). | ||
1137 | */ | ||
1138 | GNUNET_HashCode file_id; | ||
1139 | |||
1140 | /** | ||
1141 | * At which offset should we be able to find | ||
1142 | * this on-demand encoded block? (in NBO) | ||
1143 | */ | ||
1144 | uint64_t offset GNUNET_PACKED; | ||
1145 | |||
1146 | }; | ||
1147 | |||
1148 | |||
1149 | /** | ||
1150 | * @brief keyword block (advertising data under a keyword) | ||
1151 | */ | ||
1152 | struct KBlock | ||
1153 | { | ||
1154 | |||
1155 | /** | ||
1156 | * GNUNET_RSA_Signature using RSA-key generated from search keyword. | ||
1157 | */ | ||
1158 | struct GNUNET_CRYPTO_RsaSignature signature; | ||
1159 | |||
1160 | /** | ||
1161 | * What is being signed and why? | ||
1162 | */ | ||
1163 | struct GNUNET_CRYPTO_RsaSignaturePurpose purpose; | ||
1164 | |||
1165 | /** | ||
1166 | * Key generated (!) from the H(keyword) as the seed! | ||
1167 | */ | ||
1168 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded keyspace; | ||
1169 | |||
1170 | /* 0-terminated URI here */ | ||
1171 | |||
1172 | /* variable-size Meta-Data follows here */ | ||
1173 | |||
1174 | }; | ||
1175 | |||
1176 | /** | ||
1177 | * @brief namespace content block (advertising data under an identifier in a namespace) | ||
1178 | */ | ||
1179 | struct SBlock | ||
1180 | { | ||
1181 | |||
1182 | /** | ||
1183 | * GNUNET_RSA_Signature using RSA-key of the namespace | ||
1184 | */ | ||
1185 | struct GNUNET_CRYPTO_RsaSignature signature; | ||
1186 | |||
1187 | /** | ||
1188 | * What is being signed and why? | ||
1189 | */ | ||
1190 | struct GNUNET_CRYPTO_RsaSignaturePurpose purpose; | ||
1191 | |||
1192 | /** | ||
1193 | * Hash of the hash of the human-readable identifier used for | ||
1194 | * this entry (the hash of the human-readable identifier is | ||
1195 | * used as the key for decryption; the xor of this identifier | ||
1196 | * and the hash of the "keyspace" is the datastore-query hash). | ||
1197 | */ | ||
1198 | GNUNET_HashCode identifier; | ||
1199 | |||
1200 | /** | ||
1201 | * Public key of the namespace. | ||
1202 | */ | ||
1203 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded subspace; | ||
1204 | |||
1205 | /* 0-terminated update-identifier here */ | ||
1206 | |||
1207 | /* 0-terminated URI here (except for NBlocks) */ | ||
1208 | |||
1209 | /* variable-size Meta-Data follows here */ | ||
1210 | |||
1211 | }; | ||
1212 | |||
1213 | |||
1214 | /** | ||
1215 | * @brief namespace advertisement block (advertising root of a namespace) | ||
1216 | */ | ||
1217 | struct NBlock | ||
1218 | { | ||
1219 | |||
1220 | /** | ||
1221 | * GNUNET_RSA_Signature using RSA-key generated from search keyword. | ||
1222 | */ | ||
1223 | struct GNUNET_CRYPTO_RsaSignature ksk_signature; | ||
1224 | |||
1225 | /** | ||
1226 | * What is being signed and why? | ||
1227 | */ | ||
1228 | struct GNUNET_CRYPTO_RsaSignaturePurpose ksk_purpose; | ||
1229 | |||
1230 | /** | ||
1231 | * Key generated (!) from the H(keyword) as the seed! | ||
1232 | */ | ||
1233 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded keyspace; | ||
1234 | |||
1235 | /** | ||
1236 | * GNUNET_RSA_Signature using RSA-key of the namespace | ||
1237 | */ | ||
1238 | struct GNUNET_CRYPTO_RsaSignature ns_signature; | ||
1239 | |||
1240 | /** | ||
1241 | * What is being signed and why? | ||
1242 | */ | ||
1243 | struct GNUNET_CRYPTO_RsaSignaturePurpose ns_purpose; | ||
1244 | |||
1245 | /** | ||
1246 | * Public key of the namespace. | ||
1247 | */ | ||
1248 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded subspace; | ||
1249 | |||
1250 | /* from here on, data is encrypted with H(keyword) */ | ||
1251 | |||
1252 | /* 0-terminated root identifier here */ | ||
1253 | |||
1254 | /* variable-size Meta-Data follows here */ | ||
1255 | |||
1256 | }; | ||
1257 | |||
1258 | |||
1259 | /** | ||
1260 | * Message sent from a GNUnet (fs) publishing activity to the | 1128 | * Message sent from a GNUnet (fs) publishing activity to the |
1261 | * gnunet-fs-service to initiate indexing of a file. The service is | 1129 | * gnunet-fs-service to initiate indexing of a file. The service is |
1262 | * supposed to check if the specified file is available and has the | 1130 | * supposed to check if the specified file is available and has the |
diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c index 7bdf6902b..b179c70dc 100644 --- a/src/fs/fs_download.c +++ b/src/fs/fs_download.c | |||
@@ -219,7 +219,7 @@ struct ProcessResultClosure | |||
219 | /** | 219 | /** |
220 | * Type of data. | 220 | * Type of data. |
221 | */ | 221 | */ |
222 | uint32_t type; | 222 | enum GNUNET_BLOCK_Type type; |
223 | 223 | ||
224 | /** | 224 | /** |
225 | * Flag to indicate if this block should be stored on disk. | 225 | * Flag to indicate if this block should be stored on disk. |
@@ -333,8 +333,8 @@ schedule_block_download (struct GNUNET_FS_DownloadContext *dc, | |||
333 | prc.data = enc; | 333 | prc.data = enc; |
334 | prc.size = len; | 334 | prc.size = len; |
335 | prc.type = (dc->treedepth == depth) | 335 | prc.type = (dc->treedepth == depth) |
336 | ? GNUNET_DATASTORE_BLOCKTYPE_DBLOCK | 336 | ? GNUNET_BLOCK_TYPE_DBLOCK |
337 | : GNUNET_DATASTORE_BLOCKTYPE_IBLOCK; | 337 | : GNUNET_BLOCK_TYPE_IBLOCK; |
338 | prc.query = chk->query; | 338 | prc.query = chk->query; |
339 | prc.do_store = GNUNET_NO; /* useless */ | 339 | prc.do_store = GNUNET_NO; /* useless */ |
340 | process_result_with_request (&prc, | 340 | process_result_with_request (&prc, |
@@ -1021,7 +1021,7 @@ process_result_with_request (void *cls, | |||
1021 | */ | 1021 | */ |
1022 | static void | 1022 | static void |
1023 | process_result (struct GNUNET_FS_DownloadContext *dc, | 1023 | process_result (struct GNUNET_FS_DownloadContext *dc, |
1024 | uint32_t type, | 1024 | enum GNUNET_BLOCK_Type type, |
1025 | const void *data, | 1025 | const void *data, |
1026 | size_t size) | 1026 | size_t size) |
1027 | { | 1027 | { |
@@ -1128,9 +1128,9 @@ transmit_download_request (void *cls, | |||
1128 | sm->header.size = htons (sizeof (struct SearchMessage)); | 1128 | sm->header.size = htons (sizeof (struct SearchMessage)); |
1129 | sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH); | 1129 | sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH); |
1130 | if (dc->pending->depth == dc->treedepth) | 1130 | if (dc->pending->depth == dc->treedepth) |
1131 | sm->type = htonl (GNUNET_DATASTORE_BLOCKTYPE_DBLOCK); | 1131 | sm->type = htonl (GNUNET_BLOCK_TYPE_DBLOCK); |
1132 | else | 1132 | else |
1133 | sm->type = htonl (GNUNET_DATASTORE_BLOCKTYPE_IBLOCK); | 1133 | sm->type = htonl (GNUNET_BLOCK_TYPE_IBLOCK); |
1134 | sm->anonymity_level = htonl (dc->anonymity); | 1134 | sm->anonymity_level = htonl (dc->anonymity); |
1135 | sm->target = dc->target.hashPubKey; | 1135 | sm->target = dc->target.hashPubKey; |
1136 | sm->query = dc->pending->chk.query; | 1136 | sm->query = dc->pending->chk.query; |
diff --git a/src/fs/fs_namespace.c b/src/fs/fs_namespace.c index 462080305..267a90228 100644 --- a/src/fs/fs_namespace.c +++ b/src/fs/fs_namespace.c | |||
@@ -199,7 +199,7 @@ advertisement_cont (void *cls, | |||
199 | &query, | 199 | &query, |
200 | ac->pt_size + sizeof (struct NBlock), | 200 | ac->pt_size + sizeof (struct NBlock), |
201 | ac->nb, | 201 | ac->nb, |
202 | GNUNET_DATASTORE_BLOCKTYPE_NBLOCK, | 202 | GNUNET_BLOCK_TYPE_NBLOCK, |
203 | ac->priority, | 203 | ac->priority, |
204 | ac->anonymity, | 204 | ac->anonymity, |
205 | ac->expiration, | 205 | ac->expiration, |
diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c index fac75a848..1260d1c7c 100644 --- a/src/fs/fs_publish.c +++ b/src/fs/fs_publish.c | |||
@@ -451,7 +451,7 @@ static void | |||
451 | block_proc (void *cls, | 451 | block_proc (void *cls, |
452 | const GNUNET_HashCode *query, | 452 | const GNUNET_HashCode *query, |
453 | uint64_t offset, | 453 | uint64_t offset, |
454 | uint32_t type, | 454 | enum GNUNET_BLOCK_Type type, |
455 | const void *block, | 455 | const void *block, |
456 | uint16_t block_size) | 456 | uint16_t block_size) |
457 | { | 457 | { |
@@ -480,7 +480,7 @@ block_proc (void *cls, | |||
480 | dpc_cls->p = p; | 480 | dpc_cls->p = p; |
481 | if ( (! p->is_directory) && | 481 | if ( (! p->is_directory) && |
482 | (GNUNET_YES == p->data.file.do_index) && | 482 | (GNUNET_YES == p->data.file.do_index) && |
483 | (type == GNUNET_DATASTORE_BLOCKTYPE_DBLOCK) ) | 483 | (type == GNUNET_BLOCK_TYPE_DBLOCK) ) |
484 | { | 484 | { |
485 | #if DEBUG_PUBLISH | 485 | #if DEBUG_PUBLISH |
486 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 486 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -496,7 +496,7 @@ block_proc (void *cls, | |||
496 | query, | 496 | query, |
497 | sizeof(struct OnDemandBlock), | 497 | sizeof(struct OnDemandBlock), |
498 | &odb, | 498 | &odb, |
499 | GNUNET_DATASTORE_BLOCKTYPE_ONDEMAND, | 499 | GNUNET_BLOCK_TYPE_ONDEMAND, |
500 | p->priority, | 500 | p->priority, |
501 | p->anonymity, | 501 | p->anonymity, |
502 | p->expirationTime, | 502 | p->expirationTime, |
@@ -1281,7 +1281,7 @@ publish_ksk_cont (void *cls, | |||
1281 | sizeof (struct KBlock) + | 1281 | sizeof (struct KBlock) + |
1282 | pkc->slen, | 1282 | pkc->slen, |
1283 | pkc->cpy, | 1283 | pkc->cpy, |
1284 | GNUNET_DATASTORE_BLOCKTYPE_KBLOCK, | 1284 | GNUNET_BLOCK_TYPE_KBLOCK, |
1285 | pkc->priority, | 1285 | pkc->priority, |
1286 | pkc->anonymity, | 1286 | pkc->anonymity, |
1287 | pkc->expirationTime, | 1287 | pkc->expirationTime, |
@@ -1594,7 +1594,7 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h, | |||
1594 | &sb_enc->identifier, | 1594 | &sb_enc->identifier, |
1595 | size, | 1595 | size, |
1596 | sb_enc, | 1596 | sb_enc, |
1597 | GNUNET_DATASTORE_BLOCKTYPE_SBLOCK, | 1597 | GNUNET_BLOCK_TYPE_SBLOCK, |
1598 | priority, | 1598 | priority, |
1599 | anonymity, | 1599 | anonymity, |
1600 | expirationTime, | 1600 | expirationTime, |
diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c index 8674f824c..294d3d454 100644 --- a/src/fs/fs_search.c +++ b/src/fs/fs_search.c | |||
@@ -574,7 +574,7 @@ process_sblock (struct GNUNET_FS_SearchContext *sc, | |||
574 | */ | 574 | */ |
575 | static void | 575 | static void |
576 | process_result (struct GNUNET_FS_SearchContext *sc, | 576 | process_result (struct GNUNET_FS_SearchContext *sc, |
577 | uint32_t type, | 577 | enum GNUNET_BLOCK_Type type, |
578 | struct GNUNET_TIME_Absolute expiration, | 578 | struct GNUNET_TIME_Absolute expiration, |
579 | const void *data, | 579 | const void *data, |
580 | size_t size) | 580 | size_t size) |
@@ -587,7 +587,7 @@ process_result (struct GNUNET_FS_SearchContext *sc, | |||
587 | } | 587 | } |
588 | switch (type) | 588 | switch (type) |
589 | { | 589 | { |
590 | case GNUNET_DATASTORE_BLOCKTYPE_KBLOCK: | 590 | case GNUNET_BLOCK_TYPE_KBLOCK: |
591 | if (! GNUNET_FS_uri_test_ksk (sc->uri)) | 591 | if (! GNUNET_FS_uri_test_ksk (sc->uri)) |
592 | { | 592 | { |
593 | GNUNET_break (0); | 593 | GNUNET_break (0); |
@@ -600,7 +600,7 @@ process_result (struct GNUNET_FS_SearchContext *sc, | |||
600 | } | 600 | } |
601 | process_kblock (sc, data, size); | 601 | process_kblock (sc, data, size); |
602 | break; | 602 | break; |
603 | case GNUNET_DATASTORE_BLOCKTYPE_SBLOCK: | 603 | case GNUNET_BLOCK_TYPE_SBLOCK: |
604 | if (! GNUNET_FS_uri_test_sks (sc->uri)) | 604 | if (! GNUNET_FS_uri_test_sks (sc->uri)) |
605 | { | 605 | { |
606 | GNUNET_break (0); | 606 | GNUNET_break (0); |
@@ -613,7 +613,7 @@ process_result (struct GNUNET_FS_SearchContext *sc, | |||
613 | } | 613 | } |
614 | process_sblock (sc, data, size); | 614 | process_sblock (sc, data, size); |
615 | break; | 615 | break; |
616 | case GNUNET_DATASTORE_BLOCKTYPE_NBLOCK: | 616 | case GNUNET_BLOCK_TYPE_NBLOCK: |
617 | if (! GNUNET_FS_uri_test_ksk (sc->uri)) | 617 | if (! GNUNET_FS_uri_test_ksk (sc->uri)) |
618 | { | 618 | { |
619 | GNUNET_break (0); | 619 | GNUNET_break (0); |
@@ -626,10 +626,10 @@ process_result (struct GNUNET_FS_SearchContext *sc, | |||
626 | } | 626 | } |
627 | process_nblock (sc, data, size); | 627 | process_nblock (sc, data, size); |
628 | break; | 628 | break; |
629 | case GNUNET_DATASTORE_BLOCKTYPE_ANY: | 629 | case GNUNET_BLOCK_TYPE_ANY: |
630 | case GNUNET_DATASTORE_BLOCKTYPE_DBLOCK: | 630 | case GNUNET_BLOCK_TYPE_DBLOCK: |
631 | case GNUNET_DATASTORE_BLOCKTYPE_ONDEMAND: | 631 | case GNUNET_BLOCK_TYPE_ONDEMAND: |
632 | case GNUNET_DATASTORE_BLOCKTYPE_IBLOCK: | 632 | case GNUNET_BLOCK_TYPE_IBLOCK: |
633 | GNUNET_break (0); | 633 | GNUNET_break (0); |
634 | break; | 634 | break; |
635 | default: | 635 | default: |
@@ -729,7 +729,7 @@ transmit_search_request (void *cls, | |||
729 | { | 729 | { |
730 | sm[i].header.size = htons (sizeof (struct SearchMessage)); | 730 | sm[i].header.size = htons (sizeof (struct SearchMessage)); |
731 | sm[i].header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH); | 731 | sm[i].header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH); |
732 | sm[i].type = htonl (GNUNET_DATASTORE_BLOCKTYPE_ANY); | 732 | sm[i].type = htonl (GNUNET_BLOCK_TYPE_ANY); |
733 | sm[i].anonymity_level = htonl (sc->anonymity); | 733 | sm[i].anonymity_level = htonl (sc->anonymity); |
734 | sm[i].query = sc->requests[i].query; | 734 | sm[i].query = sc->requests[i].query; |
735 | } | 735 | } |
@@ -743,7 +743,7 @@ transmit_search_request (void *cls, | |||
743 | memset (sm, 0, msize); | 743 | memset (sm, 0, msize); |
744 | sm->header.size = htons (sizeof (struct SearchMessage)); | 744 | sm->header.size = htons (sizeof (struct SearchMessage)); |
745 | sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH); | 745 | sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH); |
746 | sm->type = htonl (GNUNET_DATASTORE_BLOCKTYPE_SBLOCK); | 746 | sm->type = htonl (GNUNET_BLOCK_TYPE_SBLOCK); |
747 | sm->anonymity_level = htonl (sc->anonymity); | 747 | sm->anonymity_level = htonl (sc->anonymity); |
748 | sm->target = sc->uri->data.sks.namespace; | 748 | sm->target = sc->uri->data.sks.namespace; |
749 | identifier = sc->uri->data.sks.identifier; | 749 | identifier = sc->uri->data.sks.identifier; |
diff --git a/src/fs/fs_tree.c b/src/fs/fs_tree.c index ef7c560d6..15e13be21 100644 --- a/src/fs/fs_tree.c +++ b/src/fs/fs_tree.c | |||
@@ -389,8 +389,8 @@ void GNUNET_FS_tree_encoder_next (struct GNUNET_FS_TreeEncoder * te) | |||
389 | &mychk->query, | 389 | &mychk->query, |
390 | te->publish_offset, | 390 | te->publish_offset, |
391 | (te->current_depth == te->chk_tree_depth) | 391 | (te->current_depth == te->chk_tree_depth) |
392 | ? GNUNET_DATASTORE_BLOCKTYPE_DBLOCK | 392 | ? GNUNET_BLOCK_TYPE_DBLOCK |
393 | : GNUNET_DATASTORE_BLOCKTYPE_IBLOCK, | 393 | : GNUNET_BLOCK_TYPE_IBLOCK, |
394 | enc, | 394 | enc, |
395 | pt_size); | 395 | pt_size); |
396 | if (NULL != te->progress) | 396 | if (NULL != te->progress) |
diff --git a/src/fs/fs_tree.h b/src/fs/fs_tree.h index 82b897bd3..c8863589a 100644 --- a/src/fs/fs_tree.h +++ b/src/fs/fs_tree.h | |||
@@ -67,7 +67,7 @@ struct GNUNET_FS_TreeEncoder; | |||
67 | typedef void (*GNUNET_FS_TreeBlockProcessor)(void *cls, | 67 | typedef void (*GNUNET_FS_TreeBlockProcessor)(void *cls, |
68 | const GNUNET_HashCode *query, | 68 | const GNUNET_HashCode *query, |
69 | uint64_t offset, | 69 | uint64_t offset, |
70 | uint32_t type, | 70 | enum GNUNET_BLOCK_Type type, |
71 | const void *block, | 71 | const void *block, |
72 | uint16_t block_size); | 72 | uint16_t block_size); |
73 | 73 | ||
diff --git a/src/fs/fs_unindex.c b/src/fs/fs_unindex.c index 5d1e7c8f0..1b41e0c7a 100644 --- a/src/fs/fs_unindex.c +++ b/src/fs/fs_unindex.c | |||
@@ -198,7 +198,7 @@ static void | |||
198 | unindex_process (void *cls, | 198 | unindex_process (void *cls, |
199 | const GNUNET_HashCode *query, | 199 | const GNUNET_HashCode *query, |
200 | uint64_t offset, | 200 | uint64_t offset, |
201 | uint32_t type, | 201 | enum GNUNET_BLOCK_Type type, |
202 | const void *block, | 202 | const void *block, |
203 | uint16_t block_size) | 203 | uint16_t block_size) |
204 | { | 204 | { |
@@ -207,7 +207,7 @@ unindex_process (void *cls, | |||
207 | const void *data; | 207 | const void *data; |
208 | struct OnDemandBlock odb; | 208 | struct OnDemandBlock odb; |
209 | 209 | ||
210 | if (type != GNUNET_DATASTORE_BLOCKTYPE_DBLOCK) | 210 | if (type != GNUNET_BLOCK_TYPE_DBLOCK) |
211 | { | 211 | { |
212 | size = block_size; | 212 | size = block_size; |
213 | data = block; | 213 | data = block; |
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index 2c3e6e666..41be75e98 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c | |||
@@ -540,7 +540,7 @@ struct PendingRequest | |||
540 | /** | 540 | /** |
541 | * Type of the content that this request is for. | 541 | * Type of the content that this request is for. |
542 | */ | 542 | */ |
543 | uint32_t type; | 543 | enum GNUNET_BLOCK_Type type; |
544 | 544 | ||
545 | /** | 545 | /** |
546 | * Remove this request after transmission of the current response. | 546 | * Remove this request after transmission of the current response. |
@@ -1680,14 +1680,14 @@ transmit_reply_continuation (void *cls, | |||
1680 | 1680 | ||
1681 | switch (pr->type) | 1681 | switch (pr->type) |
1682 | { | 1682 | { |
1683 | case GNUNET_DATASTORE_BLOCKTYPE_DBLOCK: | 1683 | case GNUNET_BLOCK_TYPE_DBLOCK: |
1684 | case GNUNET_DATASTORE_BLOCKTYPE_IBLOCK: | 1684 | case GNUNET_BLOCK_TYPE_IBLOCK: |
1685 | /* only one reply expected, done with the request! */ | 1685 | /* only one reply expected, done with the request! */ |
1686 | destroy_pending_request (pr); | 1686 | destroy_pending_request (pr); |
1687 | break; | 1687 | break; |
1688 | case GNUNET_DATASTORE_BLOCKTYPE_ANY: | 1688 | case GNUNET_BLOCK_TYPE_ANY: |
1689 | case GNUNET_DATASTORE_BLOCKTYPE_KBLOCK: | 1689 | case GNUNET_BLOCK_TYPE_KBLOCK: |
1690 | case GNUNET_DATASTORE_BLOCKTYPE_SBLOCK: | 1690 | case GNUNET_BLOCK_TYPE_SBLOCK: |
1691 | break; | 1691 | break; |
1692 | default: | 1692 | default: |
1693 | GNUNET_break (0); | 1693 | GNUNET_break (0); |
@@ -1697,152 +1697,6 @@ transmit_reply_continuation (void *cls, | |||
1697 | 1697 | ||
1698 | 1698 | ||
1699 | /** | 1699 | /** |
1700 | * Check if the given KBlock is well-formed. | ||
1701 | * | ||
1702 | * @param kb the kblock data (or at least "dsize" bytes claiming to be one) | ||
1703 | * @param dsize size of "kb" in bytes; check for < sizeof(struct KBlock)! | ||
1704 | * @param query where to store the query that this block answers | ||
1705 | * @return GNUNET_OK if this is actually a well-formed KBlock | ||
1706 | */ | ||
1707 | static int | ||
1708 | check_kblock (const struct KBlock *kb, | ||
1709 | size_t dsize, | ||
1710 | GNUNET_HashCode *query) | ||
1711 | { | ||
1712 | if (dsize < sizeof (struct KBlock)) | ||
1713 | { | ||
1714 | GNUNET_break_op (0); | ||
1715 | return GNUNET_SYSERR; | ||
1716 | } | ||
1717 | if (dsize - sizeof (struct KBlock) != | ||
1718 | ntohl (kb->purpose.size) | ||
1719 | - sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) | ||
1720 | - sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) ) | ||
1721 | { | ||
1722 | GNUNET_break_op (0); | ||
1723 | return GNUNET_SYSERR; | ||
1724 | } | ||
1725 | if (GNUNET_OK != | ||
1726 | GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_FS_KBLOCK, | ||
1727 | &kb->purpose, | ||
1728 | &kb->signature, | ||
1729 | &kb->keyspace)) | ||
1730 | { | ||
1731 | GNUNET_break_op (0); | ||
1732 | return GNUNET_SYSERR; | ||
1733 | } | ||
1734 | if (query != NULL) | ||
1735 | GNUNET_CRYPTO_hash (&kb->keyspace, | ||
1736 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | ||
1737 | query); | ||
1738 | return GNUNET_OK; | ||
1739 | } | ||
1740 | |||
1741 | |||
1742 | /** | ||
1743 | * Check if the given NBlock is well-formed. | ||
1744 | * | ||
1745 | * @param nb the nblock data (or at least "dsize" bytes claiming to be one) | ||
1746 | * @param dsize size of "nb" in bytes; check for < sizeof(struct NBlock)! | ||
1747 | * @param query where to store the query that this block answers | ||
1748 | * @return GNUNET_OK if this is actually a well-formed NBlock | ||
1749 | */ | ||
1750 | static int | ||
1751 | check_nblock (const struct NBlock *nb, | ||
1752 | size_t dsize, | ||
1753 | GNUNET_HashCode *query) | ||
1754 | { | ||
1755 | if (dsize < sizeof (struct NBlock)) | ||
1756 | { | ||
1757 | GNUNET_break_op (0); | ||
1758 | return GNUNET_SYSERR; | ||
1759 | } | ||
1760 | if (dsize - sizeof (struct NBlock) != | ||
1761 | ntohl (nb->ns_purpose.size) | ||
1762 | - sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) | ||
1763 | - sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) ) | ||
1764 | { | ||
1765 | GNUNET_break_op (0); | ||
1766 | return GNUNET_SYSERR; | ||
1767 | } | ||
1768 | if (dsize != | ||
1769 | ntohl (nb->ksk_purpose.size) + sizeof (struct GNUNET_CRYPTO_RsaSignature)) | ||
1770 | { | ||
1771 | GNUNET_break_op (0); | ||
1772 | return GNUNET_SYSERR; | ||
1773 | } | ||
1774 | if (GNUNET_OK != | ||
1775 | GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK_KSIG, | ||
1776 | &nb->ksk_purpose, | ||
1777 | &nb->ksk_signature, | ||
1778 | &nb->keyspace)) | ||
1779 | { | ||
1780 | GNUNET_break_op (0); | ||
1781 | return GNUNET_SYSERR; | ||
1782 | } | ||
1783 | if (GNUNET_OK != | ||
1784 | GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK, | ||
1785 | &nb->ns_purpose, | ||
1786 | &nb->ns_signature, | ||
1787 | &nb->subspace)) | ||
1788 | { | ||
1789 | GNUNET_break_op (0); | ||
1790 | return GNUNET_SYSERR; | ||
1791 | } | ||
1792 | if (query != NULL) | ||
1793 | GNUNET_CRYPTO_hash (&nb->keyspace, | ||
1794 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | ||
1795 | query); | ||
1796 | return GNUNET_OK; | ||
1797 | } | ||
1798 | |||
1799 | |||
1800 | /** | ||
1801 | * Check if the given SBlock is well-formed. | ||
1802 | * | ||
1803 | * @param sb the sblock data (or at least "dsize" bytes claiming to be one) | ||
1804 | * @param dsize size of "kb" in bytes; check for < sizeof(struct SBlock)! | ||
1805 | * @param query where to store the query that this block answers | ||
1806 | * @param namespace where to store the namespace that this block belongs to | ||
1807 | * @return GNUNET_OK if this is actually a well-formed SBlock | ||
1808 | */ | ||
1809 | static int | ||
1810 | check_sblock (const struct SBlock *sb, | ||
1811 | size_t dsize, | ||
1812 | GNUNET_HashCode *query, | ||
1813 | GNUNET_HashCode *namespace) | ||
1814 | { | ||
1815 | if (dsize < sizeof (struct SBlock)) | ||
1816 | { | ||
1817 | GNUNET_break_op (0); | ||
1818 | return GNUNET_SYSERR; | ||
1819 | } | ||
1820 | if (dsize != | ||
1821 | ntohl (sb->purpose.size) + sizeof (struct GNUNET_CRYPTO_RsaSignature)) | ||
1822 | { | ||
1823 | GNUNET_break_op (0); | ||
1824 | return GNUNET_SYSERR; | ||
1825 | } | ||
1826 | if (GNUNET_OK != | ||
1827 | GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_FS_SBLOCK, | ||
1828 | &sb->purpose, | ||
1829 | &sb->signature, | ||
1830 | &sb->subspace)) | ||
1831 | { | ||
1832 | GNUNET_break_op (0); | ||
1833 | return GNUNET_SYSERR; | ||
1834 | } | ||
1835 | if (query != NULL) | ||
1836 | *query = sb->identifier; | ||
1837 | if (namespace != NULL) | ||
1838 | GNUNET_CRYPTO_hash (&sb->subspace, | ||
1839 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | ||
1840 | namespace); | ||
1841 | return GNUNET_OK; | ||
1842 | } | ||
1843 | |||
1844 | |||
1845 | /** | ||
1846 | * Transmit the given message by copying it to the target buffer | 1700 | * Transmit the given message by copying it to the target buffer |
1847 | * "buf". "buf" will be NULL and "size" zero if the socket was closed | 1701 | * "buf". "buf" will be NULL and "size" zero if the socket was closed |
1848 | * for writing in the meantime. In that case, do nothing | 1702 | * for writing in the meantime. In that case, do nothing |
@@ -1931,7 +1785,7 @@ struct ProcessReplyClosure | |||
1931 | /** | 1785 | /** |
1932 | * Type of the block. | 1786 | * Type of the block. |
1933 | */ | 1787 | */ |
1934 | uint32_t type; | 1788 | enum GNUNET_BLOCK_Type type; |
1935 | 1789 | ||
1936 | /** | 1790 | /** |
1937 | * How much was this reply worth to us? | 1791 | * How much was this reply worth to us? |
@@ -1979,8 +1833,8 @@ process_reply (void *cls, | |||
1979 | &chash); | 1833 | &chash); |
1980 | switch (prq->type) | 1834 | switch (prq->type) |
1981 | { | 1835 | { |
1982 | case GNUNET_DATASTORE_BLOCKTYPE_DBLOCK: | 1836 | case GNUNET_BLOCK_TYPE_DBLOCK: |
1983 | case GNUNET_DATASTORE_BLOCKTYPE_IBLOCK: | 1837 | case GNUNET_BLOCK_TYPE_IBLOCK: |
1984 | /* only possible reply, stop requesting! */ | 1838 | /* only possible reply, stop requesting! */ |
1985 | while (NULL != pr->pending_head) | 1839 | while (NULL != pr->pending_head) |
1986 | destroy_pending_message_list_entry (pr->pending_head); | 1840 | destroy_pending_message_list_entry (pr->pending_head); |
@@ -2004,7 +1858,7 @@ process_reply (void *cls, | |||
2004 | key, | 1858 | key, |
2005 | pr)); | 1859 | pr)); |
2006 | break; | 1860 | break; |
2007 | case GNUNET_DATASTORE_BLOCKTYPE_SBLOCK: | 1861 | case GNUNET_BLOCK_TYPE_SBLOCK: |
2008 | if (pr->namespace == NULL) | 1862 | if (pr->namespace == NULL) |
2009 | { | 1863 | { |
2010 | GNUNET_break (0); | 1864 | GNUNET_break (0); |
@@ -2019,8 +1873,8 @@ process_reply (void *cls, | |||
2019 | return GNUNET_YES; /* wrong namespace */ | 1873 | return GNUNET_YES; /* wrong namespace */ |
2020 | } | 1874 | } |
2021 | /* then: fall-through! */ | 1875 | /* then: fall-through! */ |
2022 | case GNUNET_DATASTORE_BLOCKTYPE_KBLOCK: | 1876 | case GNUNET_BLOCK_TYPE_KBLOCK: |
2023 | case GNUNET_DATASTORE_BLOCKTYPE_NBLOCK: | 1877 | case GNUNET_BLOCK_TYPE_NBLOCK: |
2024 | if (pr->bf != NULL) | 1878 | if (pr->bf != NULL) |
2025 | { | 1879 | { |
2026 | mingle_hash (&chash, pr->mingle, &mhash); | 1880 | mingle_hash (&chash, pr->mingle, &mhash); |
@@ -2156,10 +2010,11 @@ handle_p2p_put (void *cls, | |||
2156 | const struct PutMessage *put; | 2010 | const struct PutMessage *put; |
2157 | uint16_t msize; | 2011 | uint16_t msize; |
2158 | size_t dsize; | 2012 | size_t dsize; |
2159 | uint32_t type; | 2013 | enum GNUNET_BLOCK_Type type; |
2160 | struct GNUNET_TIME_Absolute expiration; | 2014 | struct GNUNET_TIME_Absolute expiration; |
2161 | GNUNET_HashCode query; | 2015 | GNUNET_HashCode query; |
2162 | struct ProcessReplyClosure prq; | 2016 | struct ProcessReplyClosure prq; |
2017 | const struct SBlock *sb; | ||
2163 | 2018 | ||
2164 | msize = ntohs (message->size); | 2019 | msize = ntohs (message->size); |
2165 | if (msize < sizeof (struct PutMessage)) | 2020 | if (msize < sizeof (struct PutMessage)) |
@@ -2172,40 +2027,24 @@ handle_p2p_put (void *cls, | |||
2172 | type = ntohl (put->type); | 2027 | type = ntohl (put->type); |
2173 | expiration = GNUNET_TIME_absolute_ntoh (put->expiration); | 2028 | expiration = GNUNET_TIME_absolute_ntoh (put->expiration); |
2174 | 2029 | ||
2175 | /* first, validate! */ | 2030 | if (GNUNET_OK != |
2176 | switch (type) | 2031 | GNUNET_BLOCK_check_block (type, |
2032 | &put[1], | ||
2033 | dsize, | ||
2034 | &query)) | ||
2177 | { | 2035 | { |
2178 | case GNUNET_DATASTORE_BLOCKTYPE_DBLOCK: | ||
2179 | case GNUNET_DATASTORE_BLOCKTYPE_IBLOCK: | ||
2180 | GNUNET_CRYPTO_hash (&put[1], dsize, &query); | ||
2181 | break; | ||
2182 | case GNUNET_DATASTORE_BLOCKTYPE_KBLOCK: | ||
2183 | if (GNUNET_OK != | ||
2184 | check_kblock ((const struct KBlock*) &put[1], | ||
2185 | dsize, | ||
2186 | &query)) | ||
2187 | return GNUNET_SYSERR; | ||
2188 | break; | ||
2189 | case GNUNET_DATASTORE_BLOCKTYPE_SBLOCK: | ||
2190 | if (GNUNET_OK != | ||
2191 | check_sblock ((const struct SBlock*) &put[1], | ||
2192 | dsize, | ||
2193 | &query, | ||
2194 | &prq.namespace)) | ||
2195 | return GNUNET_SYSERR; | ||
2196 | break; | ||
2197 | case GNUNET_DATASTORE_BLOCKTYPE_NBLOCK: | ||
2198 | if (GNUNET_OK != | ||
2199 | check_nblock ((const struct NBlock*) &put[1], | ||
2200 | dsize, | ||
2201 | &query)) | ||
2202 | return GNUNET_SYSERR; | ||
2203 | return GNUNET_OK; | ||
2204 | default: | ||
2205 | /* unknown block type */ | ||
2206 | GNUNET_break_op (0); | 2036 | GNUNET_break_op (0); |
2207 | return GNUNET_SYSERR; | 2037 | return GNUNET_SYSERR; |
2208 | } | 2038 | } |
2039 | if (type == GNUNET_BLOCK_TYPE_ONDEMAND) | ||
2040 | return GNUNET_SYSERR; | ||
2041 | if (GNUNET_BLOCK_TYPE_SBLOCK == type) | ||
2042 | { | ||
2043 | sb = (const struct SBlock*) &put[1]; | ||
2044 | GNUNET_CRYPTO_hash (&sb->subspace, | ||
2045 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | ||
2046 | &prq.namespace); | ||
2047 | } | ||
2209 | 2048 | ||
2210 | #if DEBUG_FS | 2049 | #if DEBUG_FS |
2211 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2050 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -2309,7 +2148,7 @@ process_local_reply (void *cls, | |||
2309 | const GNUNET_HashCode * key, | 2148 | const GNUNET_HashCode * key, |
2310 | uint32_t size, | 2149 | uint32_t size, |
2311 | const void *data, | 2150 | const void *data, |
2312 | uint32_t type, | 2151 | enum GNUNET_BLOCK_Type type, |
2313 | uint32_t priority, | 2152 | uint32_t priority, |
2314 | uint32_t anonymity, | 2153 | uint32_t anonymity, |
2315 | struct GNUNET_TIME_Absolute | 2154 | struct GNUNET_TIME_Absolute |
@@ -2319,6 +2158,7 @@ process_local_reply (void *cls, | |||
2319 | struct PendingRequest *pr = cls; | 2158 | struct PendingRequest *pr = cls; |
2320 | struct ProcessReplyClosure prq; | 2159 | struct ProcessReplyClosure prq; |
2321 | struct CheckDuplicateRequestClosure cdrc; | 2160 | struct CheckDuplicateRequestClosure cdrc; |
2161 | const struct SBlock *sb; | ||
2322 | GNUNET_HashCode dhash; | 2162 | GNUNET_HashCode dhash; |
2323 | GNUNET_HashCode mhash; | 2163 | GNUNET_HashCode mhash; |
2324 | GNUNET_HashCode query; | 2164 | GNUNET_HashCode query; |
@@ -2368,7 +2208,7 @@ process_local_reply (void *cls, | |||
2368 | GNUNET_h2s (key), | 2208 | GNUNET_h2s (key), |
2369 | type); | 2209 | type); |
2370 | #endif | 2210 | #endif |
2371 | if (type == GNUNET_DATASTORE_BLOCKTYPE_ONDEMAND) | 2211 | if (type == GNUNET_BLOCK_TYPE_ONDEMAND) |
2372 | { | 2212 | { |
2373 | #if DEBUG_FS | 2213 | #if DEBUG_FS |
2374 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2214 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -2421,11 +2261,17 @@ process_local_reply (void *cls, | |||
2421 | prq.data = data; | 2261 | prq.data = data; |
2422 | prq.expiration = expiration; | 2262 | prq.expiration = expiration; |
2423 | prq.size = size; | 2263 | prq.size = size; |
2424 | if ( (type == GNUNET_DATASTORE_BLOCKTYPE_SBLOCK) && | 2264 | if (GNUNET_BLOCK_TYPE_SBLOCK == type) |
2425 | (GNUNET_OK != check_sblock ((const struct SBlock*) data, | 2265 | { |
2426 | size, | 2266 | sb = (const struct SBlock*) data; |
2427 | &query, | 2267 | GNUNET_CRYPTO_hash (&sb->subspace, |
2428 | &prq.namespace)) ) | 2268 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), |
2269 | &prq.namespace); | ||
2270 | } | ||
2271 | if (GNUNET_OK != GNUNET_BLOCK_check_block (type, | ||
2272 | data, | ||
2273 | size, | ||
2274 | &query)) | ||
2429 | { | 2275 | { |
2430 | GNUNET_break (0); | 2276 | GNUNET_break (0); |
2431 | /* FIXME: consider removing the block? */ | 2277 | /* FIXME: consider removing the block? */ |
@@ -2436,8 +2282,8 @@ process_local_reply (void *cls, | |||
2436 | prq.priority = priority; | 2282 | prq.priority = priority; |
2437 | process_reply (&prq, key, pr); | 2283 | process_reply (&prq, key, pr); |
2438 | 2284 | ||
2439 | if ( (type == GNUNET_DATASTORE_BLOCKTYPE_DBLOCK) || | 2285 | if ( (type == GNUNET_BLOCK_TYPE_DBLOCK) || |
2440 | (type == GNUNET_DATASTORE_BLOCKTYPE_IBLOCK) ) | 2286 | (type == GNUNET_BLOCK_TYPE_IBLOCK) ) |
2441 | { | 2287 | { |
2442 | GNUNET_FS_drq_get_next (GNUNET_NO); | 2288 | GNUNET_FS_drq_get_next (GNUNET_NO); |
2443 | return; | 2289 | return; |
@@ -2538,7 +2384,7 @@ handle_p2p_get (void *cls, | |||
2538 | uint32_t bm; | 2384 | uint32_t bm; |
2539 | size_t bfsize; | 2385 | size_t bfsize; |
2540 | uint32_t ttl_decrement; | 2386 | uint32_t ttl_decrement; |
2541 | uint32_t type; | 2387 | enum GNUNET_BLOCK_Type type; |
2542 | double preference; | 2388 | double preference; |
2543 | int have_ns; | 2389 | int have_ns; |
2544 | 2390 | ||
@@ -2552,11 +2398,11 @@ handle_p2p_get (void *cls, | |||
2552 | type = ntohl (gm->type); | 2398 | type = ntohl (gm->type); |
2553 | switch (type) | 2399 | switch (type) |
2554 | { | 2400 | { |
2555 | case GNUNET_DATASTORE_BLOCKTYPE_ANY: | 2401 | case GNUNET_BLOCK_TYPE_ANY: |
2556 | case GNUNET_DATASTORE_BLOCKTYPE_DBLOCK: | 2402 | case GNUNET_BLOCK_TYPE_DBLOCK: |
2557 | case GNUNET_DATASTORE_BLOCKTYPE_IBLOCK: | 2403 | case GNUNET_BLOCK_TYPE_IBLOCK: |
2558 | case GNUNET_DATASTORE_BLOCKTYPE_KBLOCK: | 2404 | case GNUNET_BLOCK_TYPE_KBLOCK: |
2559 | case GNUNET_DATASTORE_BLOCKTYPE_SBLOCK: | 2405 | case GNUNET_BLOCK_TYPE_SBLOCK: |
2560 | break; | 2406 | break; |
2561 | default: | 2407 | default: |
2562 | GNUNET_break_op (0); | 2408 | GNUNET_break_op (0); |
@@ -2579,7 +2425,7 @@ handle_p2p_get (void *cls, | |||
2579 | bfsize = msize - sizeof (struct GetMessage) + bits * sizeof (GNUNET_HashCode); | 2425 | bfsize = msize - sizeof (struct GetMessage) + bits * sizeof (GNUNET_HashCode); |
2580 | bm = ntohl (gm->hash_bitmap); | 2426 | bm = ntohl (gm->hash_bitmap); |
2581 | if ( (0 != (bm & GET_MESSAGE_BIT_SKS_NAMESPACE)) && | 2427 | if ( (0 != (bm & GET_MESSAGE_BIT_SKS_NAMESPACE)) && |
2582 | (type != GNUNET_DATASTORE_BLOCKTYPE_SBLOCK) ) | 2428 | (type != GNUNET_BLOCK_TYPE_SBLOCK) ) |
2583 | { | 2429 | { |
2584 | GNUNET_break_op (0); | 2430 | GNUNET_break_op (0); |
2585 | return GNUNET_SYSERR; | 2431 | return GNUNET_SYSERR; |
@@ -2764,8 +2610,8 @@ handle_p2p_get (void *cls, | |||
2764 | cps->inc_preference += preference; | 2610 | cps->inc_preference += preference; |
2765 | 2611 | ||
2766 | /* process locally */ | 2612 | /* process locally */ |
2767 | if (type == GNUNET_DATASTORE_BLOCKTYPE_DBLOCK) | 2613 | if (type == GNUNET_BLOCK_TYPE_DBLOCK) |
2768 | type = GNUNET_DATASTORE_BLOCKTYPE_ANY; /* to get on-demand as well */ | 2614 | type = GNUNET_BLOCK_TYPE_ANY; /* to get on-demand as well */ |
2769 | timeout = GNUNET_TIME_relative_multiply (BASIC_DATASTORE_REQUEST_DELAY, | 2615 | timeout = GNUNET_TIME_relative_multiply (BASIC_DATASTORE_REQUEST_DELAY, |
2770 | (pr->priority + 1)); | 2616 | (pr->priority + 1)); |
2771 | pr->drq = GNUNET_FS_drq_get (&gm->query, | 2617 | pr->drq = GNUNET_FS_drq_get (&gm->query, |
@@ -2778,8 +2624,8 @@ handle_p2p_get (void *cls, | |||
2778 | /* Are multiple results possible? If so, start processing remotely now! */ | 2624 | /* Are multiple results possible? If so, start processing remotely now! */ |
2779 | switch (pr->type) | 2625 | switch (pr->type) |
2780 | { | 2626 | { |
2781 | case GNUNET_DATASTORE_BLOCKTYPE_DBLOCK: | 2627 | case GNUNET_BLOCK_TYPE_DBLOCK: |
2782 | case GNUNET_DATASTORE_BLOCKTYPE_IBLOCK: | 2628 | case GNUNET_BLOCK_TYPE_IBLOCK: |
2783 | /* only one result, wait for datastore */ | 2629 | /* only one result, wait for datastore */ |
2784 | break; | 2630 | break; |
2785 | default: | 2631 | default: |
@@ -2821,7 +2667,7 @@ handle_start_search (void *cls, | |||
2821 | struct PendingRequest *pr; | 2667 | struct PendingRequest *pr; |
2822 | uint16_t msize; | 2668 | uint16_t msize; |
2823 | unsigned int sc; | 2669 | unsigned int sc; |
2824 | uint32_t type; | 2670 | enum GNUNET_BLOCK_Type type; |
2825 | 2671 | ||
2826 | msize = ntohs (message->size); | 2672 | msize = ntohs (message->size); |
2827 | if ( (msize < sizeof (struct SearchMessage)) || | 2673 | if ( (msize < sizeof (struct SearchMessage)) || |
@@ -2847,12 +2693,12 @@ handle_start_search (void *cls, | |||
2847 | #endif | 2693 | #endif |
2848 | switch (type) | 2694 | switch (type) |
2849 | { | 2695 | { |
2850 | case GNUNET_DATASTORE_BLOCKTYPE_ANY: | 2696 | case GNUNET_BLOCK_TYPE_ANY: |
2851 | case GNUNET_DATASTORE_BLOCKTYPE_DBLOCK: | 2697 | case GNUNET_BLOCK_TYPE_DBLOCK: |
2852 | case GNUNET_DATASTORE_BLOCKTYPE_IBLOCK: | 2698 | case GNUNET_BLOCK_TYPE_IBLOCK: |
2853 | case GNUNET_DATASTORE_BLOCKTYPE_KBLOCK: | 2699 | case GNUNET_BLOCK_TYPE_KBLOCK: |
2854 | case GNUNET_DATASTORE_BLOCKTYPE_SBLOCK: | 2700 | case GNUNET_BLOCK_TYPE_SBLOCK: |
2855 | case GNUNET_DATASTORE_BLOCKTYPE_NBLOCK: | 2701 | case GNUNET_BLOCK_TYPE_NBLOCK: |
2856 | break; | 2702 | break; |
2857 | default: | 2703 | default: |
2858 | GNUNET_break (0); | 2704 | GNUNET_break (0); |
@@ -2874,9 +2720,9 @@ handle_start_search (void *cls, | |||
2874 | client_list = cl; | 2720 | client_list = cl; |
2875 | } | 2721 | } |
2876 | /* detect duplicate KBLOCK requests */ | 2722 | /* detect duplicate KBLOCK requests */ |
2877 | if ( (type == GNUNET_DATASTORE_BLOCKTYPE_KBLOCK) || | 2723 | if ( (type == GNUNET_BLOCK_TYPE_KBLOCK) || |
2878 | (type == GNUNET_DATASTORE_BLOCKTYPE_NBLOCK) || | 2724 | (type == GNUNET_BLOCK_TYPE_NBLOCK) || |
2879 | (type == GNUNET_DATASTORE_BLOCKTYPE_ANY) ) | 2725 | (type == GNUNET_BLOCK_TYPE_ANY) ) |
2880 | { | 2726 | { |
2881 | crl = cl->rl_head; | 2727 | crl = cl->rl_head; |
2882 | while ( (crl != NULL) && | 2728 | while ( (crl != NULL) && |
@@ -2917,7 +2763,7 @@ handle_start_search (void *cls, | |||
2917 | 1, | 2763 | 1, |
2918 | GNUNET_NO); | 2764 | GNUNET_NO); |
2919 | pr = GNUNET_malloc (sizeof (struct PendingRequest) + | 2765 | pr = GNUNET_malloc (sizeof (struct PendingRequest) + |
2920 | ((type == GNUNET_DATASTORE_BLOCKTYPE_SBLOCK) ? sizeof(GNUNET_HashCode) : 0)); | 2766 | ((type == GNUNET_BLOCK_TYPE_SBLOCK) ? sizeof(GNUNET_HashCode) : 0)); |
2921 | crl = GNUNET_malloc (sizeof (struct ClientRequestList)); | 2767 | crl = GNUNET_malloc (sizeof (struct ClientRequestList)); |
2922 | memset (crl, 0, sizeof (struct ClientRequestList)); | 2768 | memset (crl, 0, sizeof (struct ClientRequestList)); |
2923 | crl->client_list = cl; | 2769 | crl->client_list = cl; |
@@ -2939,14 +2785,14 @@ handle_start_search (void *cls, | |||
2939 | pr->query = sm->query; | 2785 | pr->query = sm->query; |
2940 | switch (type) | 2786 | switch (type) |
2941 | { | 2787 | { |
2942 | case GNUNET_DATASTORE_BLOCKTYPE_DBLOCK: | 2788 | case GNUNET_BLOCK_TYPE_DBLOCK: |
2943 | case GNUNET_DATASTORE_BLOCKTYPE_IBLOCK: | 2789 | case GNUNET_BLOCK_TYPE_IBLOCK: |
2944 | if (0 != memcmp (&sm->target, | 2790 | if (0 != memcmp (&sm->target, |
2945 | &all_zeros, | 2791 | &all_zeros, |
2946 | sizeof (GNUNET_HashCode))) | 2792 | sizeof (GNUNET_HashCode))) |
2947 | pr->target_pid = GNUNET_PEER_intern ((const struct GNUNET_PeerIdentity*) &sm->target); | 2793 | pr->target_pid = GNUNET_PEER_intern ((const struct GNUNET_PeerIdentity*) &sm->target); |
2948 | break; | 2794 | break; |
2949 | case GNUNET_DATASTORE_BLOCKTYPE_SBLOCK: | 2795 | case GNUNET_BLOCK_TYPE_SBLOCK: |
2950 | pr->namespace = (GNUNET_HashCode*) &pr[1]; | 2796 | pr->namespace = (GNUNET_HashCode*) &pr[1]; |
2951 | memcpy (&pr[1], &sm->target, sizeof (GNUNET_HashCode)); | 2797 | memcpy (&pr[1], &sm->target, sizeof (GNUNET_HashCode)); |
2952 | break; | 2798 | break; |
@@ -2957,8 +2803,8 @@ handle_start_search (void *cls, | |||
2957 | &sm->query, | 2803 | &sm->query, |
2958 | pr, | 2804 | pr, |
2959 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 2805 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
2960 | if (type == GNUNET_DATASTORE_BLOCKTYPE_DBLOCK) | 2806 | if (type == GNUNET_BLOCK_TYPE_DBLOCK) |
2961 | type = GNUNET_DATASTORE_BLOCKTYPE_ANY; /* get on-demand blocks too! */ | 2807 | type = GNUNET_BLOCK_TYPE_ANY; /* get on-demand blocks too! */ |
2962 | pr->drq = GNUNET_FS_drq_get (&sm->query, | 2808 | pr->drq = GNUNET_FS_drq_get (&sm->query, |
2963 | type, | 2809 | type, |
2964 | &process_local_reply, | 2810 | &process_local_reply, |
diff --git a/src/fs/gnunet-service-fs_drq.c b/src/fs/gnunet-service-fs_drq.c index 8edcacf3d..fde34187a 100644 --- a/src/fs/gnunet-service-fs_drq.c +++ b/src/fs/gnunet-service-fs_drq.c | |||
@@ -83,7 +83,7 @@ struct DatastoreRequestQueue | |||
83 | /** | 83 | /** |
84 | * Datastore entry type we are doing the 'get' for. | 84 | * Datastore entry type we are doing the 'get' for. |
85 | */ | 85 | */ |
86 | uint32_t type; | 86 | enum GNUNET_BLOCK_Type type; |
87 | 87 | ||
88 | /** | 88 | /** |
89 | * Is this request at the head of the queue irrespective of its | 89 | * Is this request at the head of the queue irrespective of its |
@@ -154,7 +154,7 @@ get_iterator (void *cls, | |||
154 | const GNUNET_HashCode * key, | 154 | const GNUNET_HashCode * key, |
155 | uint32_t size, | 155 | uint32_t size, |
156 | const void *data, | 156 | const void *data, |
157 | uint32_t type, | 157 | enum GNUNET_BLOCK_Type type, |
158 | uint32_t priority, | 158 | uint32_t priority, |
159 | uint32_t anonymity, | 159 | uint32_t anonymity, |
160 | struct GNUNET_TIME_Absolute | 160 | struct GNUNET_TIME_Absolute |
@@ -345,7 +345,7 @@ shutdown_task (void *cls, | |||
345 | */ | 345 | */ |
346 | struct DatastoreRequestQueue * | 346 | struct DatastoreRequestQueue * |
347 | GNUNET_FS_drq_get (const GNUNET_HashCode * key, | 347 | GNUNET_FS_drq_get (const GNUNET_HashCode * key, |
348 | uint32_t type, | 348 | enum GNUNET_BLOCK_Type type, |
349 | GNUNET_DATASTORE_Iterator iter, | 349 | GNUNET_DATASTORE_Iterator iter, |
350 | void *iter_cls, | 350 | void *iter_cls, |
351 | struct GNUNET_TIME_Relative timeout, | 351 | struct GNUNET_TIME_Relative timeout, |
diff --git a/src/fs/gnunet-service-fs_drq.h b/src/fs/gnunet-service-fs_drq.h index ec86b99be..08a355370 100644 --- a/src/fs/gnunet-service-fs_drq.h +++ b/src/fs/gnunet-service-fs_drq.h | |||
@@ -54,7 +54,7 @@ struct DatastoreRequestQueue; | |||
54 | */ | 54 | */ |
55 | struct DatastoreRequestQueue * | 55 | struct DatastoreRequestQueue * |
56 | GNUNET_FS_drq_get (const GNUNET_HashCode * key, | 56 | GNUNET_FS_drq_get (const GNUNET_HashCode * key, |
57 | uint32_t type, | 57 | enum GNUNET_BLOCK_Type type, |
58 | GNUNET_DATASTORE_Iterator iter, | 58 | GNUNET_DATASTORE_Iterator iter, |
59 | void *iter_cls, | 59 | void *iter_cls, |
60 | struct GNUNET_TIME_Relative timeout, | 60 | struct GNUNET_TIME_Relative timeout, |
diff --git a/src/fs/gnunet-service-fs_indexing.c b/src/fs/gnunet-service-fs_indexing.c index 3095092b8..a5ac0dda3 100644 --- a/src/fs/gnunet-service-fs_indexing.c +++ b/src/fs/gnunet-service-fs_indexing.c | |||
@@ -539,7 +539,7 @@ int | |||
539 | GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key, | 539 | GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key, |
540 | uint32_t size, | 540 | uint32_t size, |
541 | const void *data, | 541 | const void *data, |
542 | uint32_t type, | 542 | enum GNUNET_BLOCK_Type type, |
543 | uint32_t priority, | 543 | uint32_t priority, |
544 | uint32_t anonymity, | 544 | uint32_t anonymity, |
545 | struct GNUNET_TIME_Absolute | 545 | struct GNUNET_TIME_Absolute |
@@ -641,7 +641,7 @@ GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key, | |||
641 | key, | 641 | key, |
642 | nsize, | 642 | nsize, |
643 | edata, | 643 | edata, |
644 | GNUNET_DATASTORE_BLOCKTYPE_DBLOCK, | 644 | GNUNET_BLOCK_TYPE_DBLOCK, |
645 | priority, | 645 | priority, |
646 | anonymity, | 646 | anonymity, |
647 | expiration, | 647 | expiration, |
diff --git a/src/fs/gnunet-service-fs_indexing.h b/src/fs/gnunet-service-fs_indexing.h index 9749b42a0..37df50042 100644 --- a/src/fs/gnunet-service-fs_indexing.h +++ b/src/fs/gnunet-service-fs_indexing.h | |||
@@ -26,6 +26,7 @@ | |||
26 | #ifndef GNUNET_SERVICE_FS_INDEXING_H | 26 | #ifndef GNUNET_SERVICE_FS_INDEXING_H |
27 | #define GNUNET_SERVICE_FS_INDEXING_H | 27 | #define GNUNET_SERVICE_FS_INDEXING_H |
28 | 28 | ||
29 | #include "gnunet_block_lib.h" | ||
29 | #include "gnunet_core_service.h" | 30 | #include "gnunet_core_service.h" |
30 | #include "gnunet_datastore_service.h" | 31 | #include "gnunet_datastore_service.h" |
31 | #include "gnunet_peer_lib.h" | 32 | #include "gnunet_peer_lib.h" |
@@ -57,7 +58,7 @@ int | |||
57 | GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key, | 58 | GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key, |
58 | uint32_t size, | 59 | uint32_t size, |
59 | const void *data, | 60 | const void *data, |
60 | uint32_t type, | 61 | enum GNUNET_BLOCK_Type type, |
61 | uint32_t priority, | 62 | uint32_t priority, |
62 | uint32_t anonymity, | 63 | uint32_t anonymity, |
63 | struct GNUNET_TIME_Absolute | 64 | struct GNUNET_TIME_Absolute |
diff --git a/src/include/gnunet_datacache_lib.h b/src/include/gnunet_datacache_lib.h index 3bd76df32..e0866416d 100644 --- a/src/include/gnunet_datacache_lib.h +++ b/src/include/gnunet_datacache_lib.h | |||
@@ -32,6 +32,7 @@ | |||
32 | #define GNUNET_DATACACHE_LIB_H | 32 | #define GNUNET_DATACACHE_LIB_H |
33 | 33 | ||
34 | #include "gnunet_util_lib.h" | 34 | #include "gnunet_util_lib.h" |
35 | #include "gnunet_block_lib.h" | ||
35 | 36 | ||
36 | #ifdef __cplusplus | 37 | #ifdef __cplusplus |
37 | extern "C" | 38 | extern "C" |
@@ -86,7 +87,7 @@ typedef int (*GNUNET_DATACACHE_Iterator) (void *cls, | |||
86 | const GNUNET_HashCode * key, | 87 | const GNUNET_HashCode * key, |
87 | uint32_t size, | 88 | uint32_t size, |
88 | const char *data, | 89 | const char *data, |
89 | uint32_t type); | 90 | enum GNUNET_BLOCK_Type type); |
90 | 91 | ||
91 | 92 | ||
92 | /** | 93 | /** |
@@ -105,7 +106,7 @@ GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h, | |||
105 | const GNUNET_HashCode * key, | 106 | const GNUNET_HashCode * key, |
106 | uint32_t size, | 107 | uint32_t size, |
107 | const char *data, | 108 | const char *data, |
108 | unsigned int type, | 109 | enum GNUNET_BLOCK_Type type, |
109 | struct GNUNET_TIME_Absolute discard_time); | 110 | struct GNUNET_TIME_Absolute discard_time); |
110 | 111 | ||
111 | 112 | ||
@@ -123,7 +124,7 @@ GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h, | |||
123 | unsigned int | 124 | unsigned int |
124 | GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h, | 125 | GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h, |
125 | const GNUNET_HashCode * key, | 126 | const GNUNET_HashCode * key, |
126 | unsigned int type, | 127 | enum GNUNET_BLOCK_Type type, |
127 | GNUNET_DATACACHE_Iterator iter, | 128 | GNUNET_DATACACHE_Iterator iter, |
128 | void *iter_cls); | 129 | void *iter_cls); |
129 | 130 | ||
diff --git a/src/include/gnunet_datastore_service.h b/src/include/gnunet_datastore_service.h index 2bf0f8f34..bf18860a6 100644 --- a/src/include/gnunet_datastore_service.h +++ b/src/include/gnunet_datastore_service.h | |||
@@ -32,6 +32,7 @@ | |||
32 | #define GNUNET_DATASTORE_SERVICE_H | 32 | #define GNUNET_DATASTORE_SERVICE_H |
33 | 33 | ||
34 | #include "gnunet_util_lib.h" | 34 | #include "gnunet_util_lib.h" |
35 | #include "gnunet_block_lib.h" | ||
35 | 36 | ||
36 | #ifdef __cplusplus | 37 | #ifdef __cplusplus |
37 | extern "C" | 38 | extern "C" |
@@ -41,43 +42,6 @@ extern "C" | |||
41 | #endif | 42 | #endif |
42 | #endif | 43 | #endif |
43 | 44 | ||
44 | /** | ||
45 | * Any type of block, used as a wildcard when searching. Should | ||
46 | * never be attached to a specific block. | ||
47 | */ | ||
48 | #define GNUNET_DATASTORE_BLOCKTYPE_ANY 0 | ||
49 | |||
50 | /** | ||
51 | * Data block (leaf) in the CHK tree. | ||
52 | */ | ||
53 | #define GNUNET_DATASTORE_BLOCKTYPE_DBLOCK 1 | ||
54 | |||
55 | /** | ||
56 | * Inner block in the CHK tree. | ||
57 | */ | ||
58 | #define GNUNET_DATASTORE_BLOCKTYPE_IBLOCK 2 | ||
59 | |||
60 | /** | ||
61 | * Type of a block representing a keyword search result. | ||
62 | */ | ||
63 | #define GNUNET_DATASTORE_BLOCKTYPE_KBLOCK 3 | ||
64 | |||
65 | /** | ||
66 | * Type of a block that is used to advertise content in a namespace. | ||
67 | */ | ||
68 | #define GNUNET_DATASTORE_BLOCKTYPE_SBLOCK 4 | ||
69 | |||
70 | /** | ||
71 | * Type of a block representing a block to be encoded on demand from disk. | ||
72 | * Should never appear on the network directly. | ||
73 | */ | ||
74 | #define GNUNET_DATASTORE_BLOCKTYPE_ONDEMAND 5 | ||
75 | |||
76 | /** | ||
77 | * Type of a block that is used to advertise a namespace. | ||
78 | */ | ||
79 | #define GNUNET_DATASTORE_BLOCKTYPE_NBLOCK 6 | ||
80 | |||
81 | 45 | ||
82 | /** | 46 | /** |
83 | * Handle to the datastore service. | 47 | * Handle to the datastore service. |
@@ -171,7 +135,7 @@ GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h, | |||
171 | const GNUNET_HashCode * key, | 135 | const GNUNET_HashCode * key, |
172 | uint32_t size, | 136 | uint32_t size, |
173 | const void *data, | 137 | const void *data, |
174 | uint32_t type, | 138 | enum GNUNET_BLOCK_Type type, |
175 | uint32_t priority, | 139 | uint32_t priority, |
176 | uint32_t anonymity, | 140 | uint32_t anonymity, |
177 | struct GNUNET_TIME_Absolute expiration, | 141 | struct GNUNET_TIME_Absolute expiration, |
@@ -239,7 +203,7 @@ typedef void (*GNUNET_DATASTORE_Iterator) (void *cls, | |||
239 | const GNUNET_HashCode * key, | 203 | const GNUNET_HashCode * key, |
240 | uint32_t size, | 204 | uint32_t size, |
241 | const void *data, | 205 | const void *data, |
242 | uint32_t type, | 206 | enum GNUNET_BLOCK_Type type, |
243 | uint32_t priority, | 207 | uint32_t priority, |
244 | uint32_t anonymity, | 208 | uint32_t anonymity, |
245 | struct GNUNET_TIME_Absolute | 209 | struct GNUNET_TIME_Absolute |
@@ -264,7 +228,7 @@ typedef void (*GNUNET_DATASTORE_Iterator) (void *cls, | |||
264 | void | 228 | void |
265 | GNUNET_DATASTORE_get (struct GNUNET_DATASTORE_Handle *h, | 229 | GNUNET_DATASTORE_get (struct GNUNET_DATASTORE_Handle *h, |
266 | const GNUNET_HashCode * key, | 230 | const GNUNET_HashCode * key, |
267 | uint32_t type, | 231 | enum GNUNET_BLOCK_Type type, |
268 | GNUNET_DATASTORE_Iterator iter, | 232 | GNUNET_DATASTORE_Iterator iter, |
269 | void *iter_cls, | 233 | void *iter_cls, |
270 | struct GNUNET_TIME_Relative timeout); | 234 | struct GNUNET_TIME_Relative timeout); |
diff --git a/src/include/gnunet_dht_service.h b/src/include/gnunet_dht_service.h index d14606d70..dcbe3dc98 100644 --- a/src/include/gnunet_dht_service.h +++ b/src/include/gnunet_dht_service.h | |||
@@ -147,7 +147,7 @@ typedef void (*GNUNET_DHT_GetIterator)(void *cls, | |||
147 | * @param handle handle to the DHT service | 147 | * @param handle handle to the DHT service |
148 | * @param timeout timeout for this request to be sent to the | 148 | * @param timeout timeout for this request to be sent to the |
149 | * service (this is NOT a timeout for receiving responses) | 149 | * service (this is NOT a timeout for receiving responses) |
150 | * @param type expected type of the response object (GNUNET_DATASTORE_BLOCKTYPE_*) | 150 | * @param type expected type of the response object (GNUNET_BLOCK_TYPE_*) |
151 | * @param key the key to look up | 151 | * @param key the key to look up |
152 | * @param iter function to call on each result | 152 | * @param iter function to call on each result |
153 | * @param iter_cls closure for iter | 153 | * @param iter_cls closure for iter |
diff --git a/src/migration/Makefile.am b/src/migration/Makefile.am new file mode 100644 index 000000000..2bc4a1d2d --- /dev/null +++ b/src/migration/Makefile.am | |||
@@ -0,0 +1,34 @@ | |||
1 | INCLUDES = -I$(top_srcdir)/src/include | ||
2 | |||
3 | if MINGW | ||
4 | WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols | ||
5 | endif | ||
6 | |||
7 | if USE_COVERAGE | ||
8 | AM_CFLAGS = --coverage -O0 | ||
9 | XLIBS = -lgcov | ||
10 | endif | ||
11 | |||
12 | bin_PROGRAMS = \ | ||
13 | gnunet-daemon-migration | ||
14 | |||
15 | gnunet_daemon_migration_SOURCES = \ | ||
16 | gnunet-daemon-migration.c | ||
17 | gnunet_daemon_migration_LDADD = \ | ||
18 | $(top_builddir)/src/datastore/libgnunetdatastore.la \ | ||
19 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
20 | $(top_builddir)/src/core/libgnunetcore.la \ | ||
21 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
22 | $(GN_LIBINTL) | ||
23 | |||
24 | check_PROGRAMS = test_gnunet_daemon_migration | ||
25 | #TESTS = $(check_PROGRAMS) | ||
26 | |||
27 | test_gnunet_daemon_migration_SOURCES = \ | ||
28 | test_gnunet_daemon_migration.c | ||
29 | test_gnunet_daemon_migration_LDADD = \ | ||
30 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
31 | $(top_builddir)/src/util/libgnunetutil.la | ||
32 | |||
33 | EXTRA_DIST = \ | ||
34 | test_gnunet_daemon_migration_data.conf | ||
diff --git a/src/migration/gnunet-daemon-migration b/src/migration/gnunet-daemon-migration new file mode 100755 index 000000000..ff6f5cea1 --- /dev/null +++ b/src/migration/gnunet-daemon-migration | |||
@@ -0,0 +1,148 @@ | |||
1 | #! /bin/sh | ||
2 | |||
3 | # gnunet-daemon-migration - temporary wrapper script for .libs/gnunet-daemon-migration | ||
4 | # Generated by ltmain.sh (GNU libtool) 2.2.6b Debian-2.2.6b-2 | ||
5 | # | ||
6 | # The gnunet-daemon-migration program cannot be directly executed until all the libtool | ||
7 | # libraries that it depends on are installed. | ||
8 | # | ||
9 | # This wrapper script should never be moved out of the build directory. | ||
10 | # If it is, it will not operate correctly. | ||
11 | |||
12 | # Sed substitution that helps us do robust quoting. It backslashifies | ||
13 | # metacharacters that are still active within double-quoted strings. | ||
14 | Xsed='/bin/sed -e 1s/^X//' | ||
15 | sed_quote_subst='s/\([`"$\\]\)/\\\1/g' | ||
16 | |||
17 | # Be Bourne compatible | ||
18 | if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then | ||
19 | emulate sh | ||
20 | NULLCMD=: | ||
21 | # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which | ||
22 | # is contrary to our usage. Disable this feature. | ||
23 | alias -g '${1+"$@"}'='"$@"' | ||
24 | setopt NO_GLOB_SUBST | ||
25 | else | ||
26 | case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac | ||
27 | fi | ||
28 | BIN_SH=xpg4; export BIN_SH # for Tru64 | ||
29 | DUALCASE=1; export DUALCASE # for MKS sh | ||
30 | |||
31 | # The HP-UX ksh and POSIX shell print the target directory to stdout | ||
32 | # if CDPATH is set. | ||
33 | (unset CDPATH) >/dev/null 2>&1 && unset CDPATH | ||
34 | |||
35 | relink_command="(cd /home/grothoff/svn/gnunet/src/migration; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=/home/grothoff/bin:/home/grothoff/private/software/prevent-linux-4.3.0/bin/:/home/grothoff/bin:/usr/local/bin:/usr/bin:/bin:/usr/games; export PATH; gcc -fno-strict-aliasing -Wall -g -O0 -o \$progdir/\$file gnunet-daemon-migration.o -L/home/grothoff//lib ../../src/datastore/.libs/libgnunetdatastore.so ../../src/statistics/.libs/libgnunetstatistics.so ../../src/core/.libs/libgnunetcore.so ../../src/util/.libs/libgnunetutil.so -lm -ldl -Wl,-rpath -Wl,/home/grothoff/svn/gnunet/src/datastore/.libs -Wl,-rpath -Wl,/home/grothoff/svn/gnunet/src/statistics/.libs -Wl,-rpath -Wl,/home/grothoff/svn/gnunet/src/core/.libs -Wl,-rpath -Wl,/home/grothoff/svn/gnunet/src/util/.libs -Wl,-rpath -Wl,/home/grothoff/lib)" | ||
36 | |||
37 | # This environment variable determines our operation mode. | ||
38 | if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then | ||
39 | # install mode needs the following variables: | ||
40 | generated_by_libtool_version='2.2.6b' | ||
41 | notinst_deplibs=' ../../src/datastore/libgnunetdatastore.la ../../src/statistics/libgnunetstatistics.la ../../src/core/libgnunetcore.la ../../src/util/libgnunetutil.la' | ||
42 | else | ||
43 | # When we are sourced in execute mode, $file and $ECHO are already set. | ||
44 | if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then | ||
45 | ECHO="echo" | ||
46 | file="$0" | ||
47 | # Make sure echo works. | ||
48 | if test "X$1" = X--no-reexec; then | ||
49 | # Discard the --no-reexec flag, and continue. | ||
50 | shift | ||
51 | elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then | ||
52 | # Yippee, $ECHO works! | ||
53 | : | ||
54 | else | ||
55 | # Restart under the correct shell, and then maybe $ECHO will work. | ||
56 | exec /bin/sh "$0" --no-reexec ${1+"$@"} | ||
57 | fi | ||
58 | fi | ||
59 | |||
60 | # Find the directory that this script lives in. | ||
61 | thisdir=`$ECHO "X$file" | $Xsed -e 's%/[^/]*$%%'` | ||
62 | test "x$thisdir" = "x$file" && thisdir=. | ||
63 | |||
64 | # Follow symbolic links until we get to the real thisdir. | ||
65 | file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'` | ||
66 | while test -n "$file"; do | ||
67 | destdir=`$ECHO "X$file" | $Xsed -e 's%/[^/]*$%%'` | ||
68 | |||
69 | # If there was a directory component, then change thisdir. | ||
70 | if test "x$destdir" != "x$file"; then | ||
71 | case "$destdir" in | ||
72 | [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;; | ||
73 | *) thisdir="$thisdir/$destdir" ;; | ||
74 | esac | ||
75 | fi | ||
76 | |||
77 | file=`$ECHO "X$file" | $Xsed -e 's%^.*/%%'` | ||
78 | file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'` | ||
79 | done | ||
80 | |||
81 | |||
82 | # Usually 'no', except on cygwin/mingw when embedded into | ||
83 | # the cwrapper. | ||
84 | WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no | ||
85 | if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then | ||
86 | # special case for '.' | ||
87 | if test "$thisdir" = "."; then | ||
88 | thisdir=`pwd` | ||
89 | fi | ||
90 | # remove .libs from thisdir | ||
91 | case "$thisdir" in | ||
92 | *[\\/].libs ) thisdir=`$ECHO "X$thisdir" | $Xsed -e 's%[\\/][^\\/]*$%%'` ;; | ||
93 | .libs ) thisdir=. ;; | ||
94 | esac | ||
95 | fi | ||
96 | |||
97 | # Try to get the absolute directory name. | ||
98 | absdir=`cd "$thisdir" && pwd` | ||
99 | test -n "$absdir" && thisdir="$absdir" | ||
100 | |||
101 | program=lt-'gnunet-daemon-migration' | ||
102 | progdir="$thisdir/.libs" | ||
103 | |||
104 | if test ! -f "$progdir/$program" || | ||
105 | { file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /bin/sed 1q`; \ | ||
106 | test "X$file" != "X$progdir/$program"; }; then | ||
107 | |||
108 | file="$$-$program" | ||
109 | |||
110 | if test ! -d "$progdir"; then | ||
111 | mkdir "$progdir" | ||
112 | else | ||
113 | rm -f "$progdir/$file" | ||
114 | fi | ||
115 | |||
116 | # relink executable if necessary | ||
117 | if test -n "$relink_command"; then | ||
118 | if relink_command_output=`eval $relink_command 2>&1`; then : | ||
119 | else | ||
120 | echo "$relink_command_output" >&2 | ||
121 | rm -f "$progdir/$file" | ||
122 | exit 1 | ||
123 | fi | ||
124 | fi | ||
125 | |||
126 | mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null || | ||
127 | { rm -f "$progdir/$program"; | ||
128 | mv -f "$progdir/$file" "$progdir/$program"; } | ||
129 | rm -f "$progdir/$file" | ||
130 | fi | ||
131 | |||
132 | if test -f "$progdir/$program"; then | ||
133 | if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then | ||
134 | # Run the actual program with our arguments. | ||
135 | |||
136 | exec "$progdir/$program" ${1+"$@"} | ||
137 | |||
138 | $ECHO "$0: cannot exec $program $*" 1>&2 | ||
139 | exit 1 | ||
140 | fi | ||
141 | else | ||
142 | # The program doesn't exist. | ||
143 | $ECHO "$0: error: \`$progdir/$program' does not exist" 1>&2 | ||
144 | $ECHO "This script is just a wrapper for $program." 1>&2 | ||
145 | echo "See the libtool documentation for more information." 1>&2 | ||
146 | exit 1 | ||
147 | fi | ||
148 | fi | ||
diff --git a/src/migration/gnunet-daemon-migration.c b/src/migration/gnunet-daemon-migration.c new file mode 100644 index 000000000..14f7461f6 --- /dev/null +++ b/src/migration/gnunet-daemon-migration.c | |||
@@ -0,0 +1,377 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2010 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 2, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file migration/gnunet-daemon-migration.c | ||
23 | * @brief migrating (file-sharing) content through the network; this | ||
24 | * daemon is only responsible for pushing content out (not for | ||
25 | * processing inbound messages) | ||
26 | * @author Christian Grothoff | ||
27 | */ | ||
28 | #include <stdlib.h> | ||
29 | #include "platform.h" | ||
30 | #include "../fs/fs.h" | ||
31 | #include "gnunet_constants.h" | ||
32 | #include "gnunet_core_service.h" | ||
33 | #include "gnunet_datastore_service.h" | ||
34 | #include "gnunet_protocols.h" | ||
35 | #include "gnunet_statistics_service.h" | ||
36 | #include "gnunet_util_lib.h" | ||
37 | |||
38 | |||
39 | #define DEBUG_MIGRATION GNUNET_YES | ||
40 | |||
41 | /** | ||
42 | * Information we keep per peer. | ||
43 | */ | ||
44 | struct Peer | ||
45 | { | ||
46 | /** | ||
47 | * Last time we migrated data to this peer. | ||
48 | */ | ||
49 | struct GNUNET_TIME_Absolute last_migration; | ||
50 | |||
51 | }; | ||
52 | |||
53 | |||
54 | /** | ||
55 | * Our scheduler. | ||
56 | */ | ||
57 | static struct GNUNET_SCHEDULER_Handle *sched; | ||
58 | |||
59 | /** | ||
60 | * Our configuration. | ||
61 | */ | ||
62 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
63 | |||
64 | /** | ||
65 | * Handle to the core API. | ||
66 | */ | ||
67 | static struct GNUNET_CORE_Handle *handle; | ||
68 | |||
69 | /** | ||
70 | * Handle for reporting statistics. | ||
71 | */ | ||
72 | static struct GNUNET_STATISTICS_Handle *stats; | ||
73 | |||
74 | /** | ||
75 | * Handle for the core service. | ||
76 | */ | ||
77 | static struct GNUNET_CORE_Handle *handle; | ||
78 | |||
79 | /** | ||
80 | * Handle to the datastore. | ||
81 | */ | ||
82 | static struct GNUNET_DATASTORE_Handle *datastore; | ||
83 | |||
84 | /** | ||
85 | * Anonymity level for the current block. | ||
86 | */ | ||
87 | static unsigned int current_anonymity; | ||
88 | |||
89 | /** | ||
90 | * Type of the current block. | ||
91 | */ | ||
92 | static enum GNUNET_BLOCK_Type current_type; | ||
93 | |||
94 | /** | ||
95 | * Data of the current block (already encrypted). | ||
96 | */ | ||
97 | static char current_block[GNUNET_SERVER_MAX_MESSAGE_SIZE]; | ||
98 | |||
99 | /** | ||
100 | * Size of the current block. | ||
101 | */ | ||
102 | static size_t current_block_size; | ||
103 | |||
104 | /** | ||
105 | * Key of the current block. | ||
106 | */ | ||
107 | static GNUNET_HashCode current_key; | ||
108 | |||
109 | /** | ||
110 | * Task scheduled to receive content from the datastore (with some delay). | ||
111 | */ | ||
112 | static GNUNET_SCHEDULER_TaskIdentifier get_task; | ||
113 | |||
114 | |||
115 | /** | ||
116 | * Select a peer for transmitting the current block to. | ||
117 | */ | ||
118 | static void | ||
119 | select_peer () | ||
120 | { | ||
121 | /* FIXME: select a peer for transmission... */ | ||
122 | } | ||
123 | |||
124 | |||
125 | /** | ||
126 | * Method called whenever a peer connects. | ||
127 | * | ||
128 | * @param cls closure | ||
129 | * @param peer peer identity this notification is about | ||
130 | * @param latency reported latency of the connection with 'other' | ||
131 | * @param distance reported distance (DV) to 'other' | ||
132 | */ | ||
133 | static void | ||
134 | connect_notify (void *cls, | ||
135 | const struct | ||
136 | GNUNET_PeerIdentity * peer, | ||
137 | struct GNUNET_TIME_Relative latency, | ||
138 | uint32_t distance) | ||
139 | { | ||
140 | /* FIXME: track peer */ | ||
141 | } | ||
142 | |||
143 | |||
144 | /** | ||
145 | * Method called whenever a peer disconnects. | ||
146 | * | ||
147 | * @param cls closure | ||
148 | * @param peer peer identity this notification is about | ||
149 | */ | ||
150 | static void | ||
151 | disconnect_notify (void *cls, | ||
152 | const struct | ||
153 | GNUNET_PeerIdentity * peer) | ||
154 | { | ||
155 | /* FIXME: untrack peer */ | ||
156 | } | ||
157 | |||
158 | |||
159 | /** | ||
160 | * Ask datastore for more content. | ||
161 | * @param cls closure | ||
162 | * @param tc scheduler context | ||
163 | */ | ||
164 | static void | ||
165 | get_content (void *cls, | ||
166 | const struct GNUNET_SCHEDULER_TaskContext *tc); | ||
167 | |||
168 | |||
169 | /** | ||
170 | * An iterator over a set of items stored in the datastore. | ||
171 | * | ||
172 | * @param cls closure | ||
173 | * @param key key for the content | ||
174 | * @param size number of bytes in data | ||
175 | * @param data content stored | ||
176 | * @param type type of the content | ||
177 | * @param priority priority of the content | ||
178 | * @param anonymity anonymity-level for the content | ||
179 | * @param expiration expiration time for the content | ||
180 | * @param uid unique identifier for the datum; | ||
181 | * maybe 0 if no unique identifier is available | ||
182 | */ | ||
183 | static void | ||
184 | content_processor (void *cls, | ||
185 | const GNUNET_HashCode * key, | ||
186 | uint32_t size, | ||
187 | const void *data, | ||
188 | enum GNUNET_BLOCK_Type type, | ||
189 | uint32_t priority, | ||
190 | uint32_t anonymity, | ||
191 | struct GNUNET_TIME_Absolute | ||
192 | expiration, uint64_t uid) | ||
193 | { | ||
194 | if (key != NULL) | ||
195 | { | ||
196 | memcpy (current_block, data, size); | ||
197 | current_block_size = size; | ||
198 | current_type = type; | ||
199 | current_anonymity = anonymity; | ||
200 | current_key = *key; | ||
201 | return; | ||
202 | } | ||
203 | if (current_block_size == 0) | ||
204 | { | ||
205 | get_task = GNUNET_SCHEDULER_add_delayed (sched, | ||
206 | GNUNET_TIME_UNIT_MINUTES, | ||
207 | &get_content, | ||
208 | NULL); | ||
209 | return; | ||
210 | } | ||
211 | if (current_type == GNUNET_BLOCK_TYPE_ONDEMAND) | ||
212 | { | ||
213 | /* FIXME: do on-demand encoding... */ | ||
214 | return; | ||
215 | } | ||
216 | select_peer (); | ||
217 | } | ||
218 | |||
219 | |||
220 | /** | ||
221 | * Ask datastore for more content. | ||
222 | * @param cls closure | ||
223 | * @param tc scheduler context | ||
224 | */ | ||
225 | static void | ||
226 | get_content (void *cls, | ||
227 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
228 | { | ||
229 | get_task = GNUNET_SCHEDULER_NO_TASK; | ||
230 | GNUNET_DATASTORE_get_random (datastore, | ||
231 | &content_processor, | ||
232 | NULL, | ||
233 | GNUNET_CONSTANTS_SERVICE_TIMEOUT); | ||
234 | } | ||
235 | |||
236 | |||
237 | /** | ||
238 | * Function called after GNUNET_CORE_connect has succeeded | ||
239 | * (or failed for good). | ||
240 | * | ||
241 | * @param cls closure | ||
242 | * @param server handle to the server, NULL if we failed | ||
243 | * @param my_id ID of this peer, NULL if we failed | ||
244 | * @param publicKey public key of this peer, NULL if we failed | ||
245 | */ | ||
246 | static void | ||
247 | core_init (void *cls, | ||
248 | struct GNUNET_CORE_Handle * server, | ||
249 | const struct GNUNET_PeerIdentity * | ||
250 | my_id, | ||
251 | const struct | ||
252 | GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded * | ||
253 | publicKey) | ||
254 | { | ||
255 | handle = server; | ||
256 | if (datastore != NULL) | ||
257 | get_task = GNUNET_SCHEDULER_add_now (sched, | ||
258 | &get_content, | ||
259 | NULL); | ||
260 | } | ||
261 | |||
262 | |||
263 | /** | ||
264 | * Last task run during shutdown. Disconnects us from | ||
265 | * the core. | ||
266 | * | ||
267 | * @param cls unused, NULL | ||
268 | * @param tc scheduler context | ||
269 | */ | ||
270 | static void | ||
271 | cleaning_task (void *cls, | ||
272 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
273 | { | ||
274 | if (get_task != GNUNET_SCHEDULER_NO_TASK) | ||
275 | { | ||
276 | GNUNET_SCHEDULER_cancel (sched, | ||
277 | get_task); | ||
278 | get_task = GNUNET_SCHEDULER_NO_TASK; | ||
279 | } | ||
280 | if (handle != NULL) | ||
281 | { | ||
282 | GNUNET_CORE_disconnect (handle); | ||
283 | handle = NULL; | ||
284 | } | ||
285 | if (datastore != NULL) | ||
286 | { | ||
287 | GNUNET_DATASTORE_disconnect (datastore, GNUNET_NO); | ||
288 | datastore = NULL; | ||
289 | } | ||
290 | if (stats != NULL) | ||
291 | { | ||
292 | GNUNET_STATISTICS_destroy (stats, GNUNET_NO); | ||
293 | stats = NULL; | ||
294 | } | ||
295 | } | ||
296 | |||
297 | |||
298 | /** | ||
299 | * Main function that will be run. | ||
300 | * | ||
301 | * @param cls closure | ||
302 | * @param s the scheduler to use | ||
303 | * @param args remaining command-line arguments | ||
304 | * @param cfgfile name of the configuration file used (for saving, can be NULL!) | ||
305 | * @param c configuration | ||
306 | */ | ||
307 | static void | ||
308 | run (void *cls, | ||
309 | struct GNUNET_SCHEDULER_Handle * s, | ||
310 | char *const *args, | ||
311 | const char *cfgfile, | ||
312 | const struct GNUNET_CONFIGURATION_Handle * c) | ||
313 | { | ||
314 | struct GNUNET_CORE_MessageHandler handlers[] = | ||
315 | { | ||
316 | { NULL, 0, 0 } | ||
317 | }; | ||
318 | sched = s; | ||
319 | cfg = c; | ||
320 | stats = GNUNET_STATISTICS_create (sched, "topology", cfg); | ||
321 | handle = GNUNET_CORE_connect (sched, | ||
322 | cfg, | ||
323 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
324 | NULL, | ||
325 | &core_init, | ||
326 | &connect_notify, | ||
327 | &disconnect_notify, | ||
328 | NULL, GNUNET_NO, | ||
329 | NULL, GNUNET_NO, | ||
330 | handlers); | ||
331 | datastore = GNUNET_DATASTORE_connect (cfg, sched); | ||
332 | GNUNET_SCHEDULER_add_delayed (sched, | ||
333 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
334 | &cleaning_task, NULL); | ||
335 | if ( (NULL == handle) || | ||
336 | (NULL == datastore) ) | ||
337 | { | ||
338 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
339 | _("Failed to connect to `%s' service.\n"), | ||
340 | (NULL == handle) ? "core" : "datastore"); | ||
341 | GNUNET_SCHEDULER_shutdown (sched); | ||
342 | return; | ||
343 | } | ||
344 | } | ||
345 | |||
346 | |||
347 | /** | ||
348 | * gnunet-daemon-topology command line options. | ||
349 | */ | ||
350 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
351 | GNUNET_GETOPT_OPTION_END | ||
352 | }; | ||
353 | |||
354 | |||
355 | /** | ||
356 | * The main function for the topology daemon. | ||
357 | * | ||
358 | * @param argc number of arguments from the command line | ||
359 | * @param argv command line arguments | ||
360 | * @return 0 ok, 1 on error | ||
361 | */ | ||
362 | int | ||
363 | main (int argc, char *const *argv) | ||
364 | { | ||
365 | int ret; | ||
366 | |||
367 | ret = (GNUNET_OK == | ||
368 | GNUNET_PROGRAM_run (argc, | ||
369 | argv, | ||
370 | "migration", | ||
371 | _("Content migration for anonymous file-sharing"), | ||
372 | options, | ||
373 | &run, NULL)) ? 0 : 1; | ||
374 | return ret; | ||
375 | } | ||
376 | |||
377 | /* end of gnunet-daemon-migration.c */ | ||
diff --git a/src/topology/test_gnunet_service_topology.c b/src/migration/test_gnunet_daemon_migration.c index 5f0f5cc91..a3f699935 100644 --- a/src/topology/test_gnunet_service_topology.c +++ b/src/migration/test_gnunet_daemon_migration.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2009 Christian Grothoff (and other contributing authors) | 3 | (C) 2010 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -18,8 +18,8 @@ | |||
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file topology/test_gnunet_service_topology.c | 21 | * @file topology/test_gnunet_daemon_migration.c |
22 | * @brief testcase for topology maintenance code | 22 | * @brief testcase for content migration code |
23 | */ | 23 | */ |
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_testing_lib.h" | 25 | #include "gnunet_testing_lib.h" |
@@ -166,7 +166,7 @@ main (int argc, char *argv[]) | |||
166 | { | 166 | { |
167 | int ret; | 167 | int ret; |
168 | 168 | ||
169 | GNUNET_log_setup ("test-gnunet-service-topology", | 169 | GNUNET_log_setup ("test-gnunet-daemon-migration", |
170 | #if VERBOSE | 170 | #if VERBOSE |
171 | "DEBUG", | 171 | "DEBUG", |
172 | #else | 172 | #else |
@@ -179,4 +179,4 @@ main (int argc, char *argv[]) | |||
179 | return ret; | 179 | return ret; |
180 | } | 180 | } |
181 | 181 | ||
182 | /* end of test_gnunet_service_topology.c */ | 182 | /* end of test_gnunet_daemon_migration.c */ |
diff --git a/src/topology/test_gnunet_service_topology_data.conf b/src/migration/test_gnunet_daemon_migration_data.conf index d920e9e88..d920e9e88 100644 --- a/src/topology/test_gnunet_service_topology_data.conf +++ b/src/migration/test_gnunet_daemon_migration_data.conf | |||
diff --git a/src/topology/Makefile.am b/src/topology/Makefile.am index 88d8800a1..7bedd0910 100644 --- a/src/topology/Makefile.am +++ b/src/topology/Makefile.am | |||
@@ -21,15 +21,15 @@ gnunet_daemon_topology_LDADD = \ | |||
21 | 21 | ||
22 | 22 | ||
23 | check_PROGRAMS = \ | 23 | check_PROGRAMS = \ |
24 | test_gnunet_service_topology | 24 | test_gnunet_daemon_topology |
25 | 25 | ||
26 | TESTS = $(check_PROGRAMS) | 26 | TESTS = $(check_PROGRAMS) |
27 | 27 | ||
28 | test_gnunet_service_topology_SOURCES = \ | 28 | test_gnunet_daemon_topology_SOURCES = \ |
29 | test_gnunet_service_topology.c | 29 | test_gnunet_daemon_topology.c |
30 | test_gnunet_service_topology_LDADD = \ | 30 | test_gnunet_daemon_topology_LDADD = \ |
31 | $(top_builddir)/src/testing/libgnunettesting.la \ | 31 | $(top_builddir)/src/testing/libgnunettesting.la \ |
32 | $(top_builddir)/src/util/libgnunetutil.la | 32 | $(top_builddir)/src/util/libgnunetutil.la |
33 | 33 | ||
34 | EXTRA_DIST = \ | 34 | EXTRA_DIST = \ |
35 | test_gnunet_service_topology_data.conf | 35 | test_gnunet_daemon_topology_data.conf |
diff --git a/src/topology/test_gnunet_daemon_topology.c b/src/topology/test_gnunet_daemon_topology.c new file mode 100644 index 000000000..b181e7b2c --- /dev/null +++ b/src/topology/test_gnunet_daemon_topology.c | |||
@@ -0,0 +1,182 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2009 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 2, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | /** | ||
21 | * @file topology/test_gnunet_daemon_topology.c | ||
22 | * @brief testcase for topology maintenance code | ||
23 | */ | ||
24 | #include "platform.h" | ||
25 | #include "gnunet_testing_lib.h" | ||
26 | |||
27 | #define VERBOSE GNUNET_YES | ||
28 | |||
29 | #define NUM_PEERS 2 | ||
30 | |||
31 | /** | ||
32 | * How long until we give up on connecting the peers? | ||
33 | */ | ||
34 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) | ||
35 | |||
36 | #define CONNECT_ATTEMPTS 3 | ||
37 | |||
38 | |||
39 | static int ok; | ||
40 | |||
41 | static int peers_left; | ||
42 | |||
43 | static int connect_left; | ||
44 | |||
45 | static struct GNUNET_TESTING_PeerGroup *pg; | ||
46 | |||
47 | static struct GNUNET_TESTING_Daemon *first; | ||
48 | |||
49 | static struct GNUNET_TESTING_Daemon *last; | ||
50 | |||
51 | static struct GNUNET_SCHEDULER_Handle *sched; | ||
52 | |||
53 | |||
54 | static void | ||
55 | clean_up_task (void *cls, | ||
56 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
57 | { | ||
58 | GNUNET_TESTING_daemons_stop (pg); | ||
59 | ok = 0; | ||
60 | } | ||
61 | |||
62 | |||
63 | static void | ||
64 | notify_connect_complete(void *cls, | ||
65 | const struct GNUNET_PeerIdentity *first, | ||
66 | const struct GNUNET_PeerIdentity *second, | ||
67 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, | ||
68 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, | ||
69 | struct GNUNET_TESTING_Daemon *first_daemon, | ||
70 | struct GNUNET_TESTING_Daemon *second_daemon, | ||
71 | const char *emsg) | ||
72 | { | ||
73 | if (NULL != emsg) | ||
74 | { | ||
75 | fprintf (stderr, | ||
76 | "Failed to connect two peers: %s\n", | ||
77 | emsg); | ||
78 | GNUNET_TESTING_daemons_stop (pg); | ||
79 | GNUNET_assert (0); | ||
80 | return; | ||
81 | } | ||
82 | connect_left--; | ||
83 | if (connect_left == 0) | ||
84 | { | ||
85 | /* FIXME: check that topology adds a few more links | ||
86 | in addition to those that were seeded */ | ||
87 | /* For now, sleep so we can have the daemon do some work */ | ||
88 | GNUNET_SCHEDULER_add_delayed (sched, | ||
89 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), | ||
90 | &clean_up_task, | ||
91 | NULL); | ||
92 | } | ||
93 | } | ||
94 | |||
95 | |||
96 | static void my_cb(void *cls, | ||
97 | const struct GNUNET_PeerIdentity *id, | ||
98 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
99 | struct GNUNET_TESTING_Daemon *d, | ||
100 | const char *emsg) | ||
101 | { | ||
102 | GNUNET_assert (id != NULL); | ||
103 | peers_left--; | ||
104 | if (first == NULL) | ||
105 | { | ||
106 | connect_left = NUM_PEERS; | ||
107 | first = d; | ||
108 | last = d; | ||
109 | return; | ||
110 | } | ||
111 | GNUNET_TESTING_daemons_connect (last, d, TIMEOUT, CONNECT_ATTEMPTS, | ||
112 | ¬ify_connect_complete, | ||
113 | NULL); | ||
114 | if (peers_left == 0) | ||
115 | { | ||
116 | /* close circle */ | ||
117 | GNUNET_TESTING_daemons_connect (d, first, TIMEOUT, CONNECT_ATTEMPTS, | ||
118 | ¬ify_connect_complete, | ||
119 | NULL); | ||
120 | } | ||
121 | } | ||
122 | |||
123 | |||
124 | static void | ||
125 | run (void *cls, | ||
126 | struct GNUNET_SCHEDULER_Handle *s, | ||
127 | char *const *args, | ||
128 | const char *cfgfile, | ||
129 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
130 | { | ||
131 | sched = s; | ||
132 | ok = 1; | ||
133 | #if VERBOSE | ||
134 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
135 | "Starting daemons.\n"); | ||
136 | #endif | ||
137 | peers_left = NUM_PEERS; | ||
138 | pg = GNUNET_TESTING_daemons_start (sched, cfg, | ||
139 | peers_left, | ||
140 | &my_cb, NULL, NULL, NULL, NULL); | ||
141 | GNUNET_assert (pg != NULL); | ||
142 | } | ||
143 | |||
144 | static int | ||
145 | check () | ||
146 | { | ||
147 | char *const argv[] = { "test-testing", | ||
148 | "-c", | ||
149 | "test_gnunet_daemon_topology_data.conf", | ||
150 | #if VERBOSE | ||
151 | "-L", "DEBUG", | ||
152 | #endif | ||
153 | NULL | ||
154 | }; | ||
155 | struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
156 | GNUNET_GETOPT_OPTION_END | ||
157 | }; | ||
158 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | ||
159 | argv, "test-gnunet-daemon-topology", "nohelp", | ||
160 | options, &run, &ok); | ||
161 | return ok; | ||
162 | } | ||
163 | |||
164 | int | ||
165 | main (int argc, char *argv[]) | ||
166 | { | ||
167 | int ret; | ||
168 | |||
169 | GNUNET_log_setup ("test-gnunet-daemon-topology", | ||
170 | #if VERBOSE | ||
171 | "DEBUG", | ||
172 | #else | ||
173 | "WARNING", | ||
174 | #endif | ||
175 | NULL); | ||
176 | ret = check (); | ||
177 | sleep (1); /* FIXME: needed? */ | ||
178 | GNUNET_DISK_directory_remove ("/tmp/test-gnunet-topology"); | ||
179 | return ret; | ||
180 | } | ||
181 | |||
182 | /* end of test_gnunet_daemon_topology.c */ | ||
diff --git a/src/topology/test_gnunet_daemon_topology_data.conf b/src/topology/test_gnunet_daemon_topology_data.conf new file mode 100644 index 000000000..d920e9e88 --- /dev/null +++ b/src/topology/test_gnunet_daemon_topology_data.conf | |||
@@ -0,0 +1,37 @@ | |||
1 | [PATHS] | ||
2 | SERVICEHOME = /tmp/test-gnunet-topology/ | ||
3 | # DEFAULTCONFIG = test_gnunet_service_topology_data.conf | ||
4 | |||
5 | [resolver] | ||
6 | PORT = 2664 | ||
7 | |||
8 | [transport] | ||
9 | PORT = 2665 | ||
10 | PLUGINS = tcp | ||
11 | # DEBUG = YES | ||
12 | #PREFIX = xterm -e xterm -T transport -e gdb -x cmd --args | ||
13 | #PREFIX = valgrind --tool=memcheck --log-file=logs%p | ||
14 | |||
15 | [arm] | ||
16 | PORT = 2666 | ||
17 | DEFAULTSERVICES = peerinfo transport core topology | ||
18 | |||
19 | [statistics] | ||
20 | PORT = 2667 | ||
21 | |||
22 | [transport-tcp] | ||
23 | PORT = 2668 | ||
24 | |||
25 | [peerinfo] | ||
26 | PORT = 2669 | ||
27 | |||
28 | [core] | ||
29 | PORT = 2670 | ||
30 | # DEBUG = YES | ||
31 | |||
32 | [topology] | ||
33 | # DEBUG = YES | ||
34 | #PREFIX = valgrind --tool=memcheck | ||
35 | |||
36 | [testing] | ||
37 | WEAKRANDOM = YES | ||
diff --git a/src/util/test_resolver_api.c b/src/util/test_resolver_api.c index daf676d01..e6496e7ac 100644 --- a/src/util/test_resolver_api.c +++ b/src/util/test_resolver_api.c | |||
@@ -265,7 +265,8 @@ run(void *cls, struct GNUNET_SCHEDULER_Handle *sched, char * const *args, | |||
265 | _("gethostbyname() could not lookup IP address: %s\n"), | 265 | _("gethostbyname() could not lookup IP address: %s\n"), |
266 | hstrerror (h_errno)); | 266 | hstrerror (h_errno)); |
267 | #endif | 267 | #endif |
268 | GNUNET_break(0); | 268 | fprintf (stderr, |
269 | "System seems to be off-line, will not run all DNS tests\n"); | ||
269 | return; | 270 | return; |
270 | } | 271 | } |
271 | 272 | ||