diff options
author | Christian Grothoff <grothoff@gnunet.org> | 2022-03-12 04:01:02 +0100 |
---|---|---|
committer | Christian Grothoff <grothoff@gnunet.org> | 2022-03-12 04:01:02 +0100 |
commit | ff992f47e6528b00937c3951b812f6938e1ee21a (patch) | |
tree | 96917d63e24d2cc02b0e09a4e1dc29987541ffe8 /src/dht | |
parent | 06f6791f2d55ab3a1b4ca4c3ba9ed5c315f8d79b (diff) | |
download | gnunet-ff992f47e6528b00937c3951b812f6938e1ee21a.tar.gz gnunet-ff992f47e6528b00937c3951b812f6938e1ee21a.zip |
revise block API to match latest DHT specs
Diffstat (limited to 'src/dht')
-rw-r--r-- | src/dht/gnunet-service-dht_clients.c | 3 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht_datacache.c | 21 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht_datacache.h | 4 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht_neighbours.c | 44 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht_routing.c | 7 | ||||
-rw-r--r-- | src/dht/plugin_block_dht.c | 163 |
6 files changed, 64 insertions, 178 deletions
diff --git a/src/dht/gnunet-service-dht_clients.c b/src/dht/gnunet-service-dht_clients.c index 5735b2420..c50406ada 100644 --- a/src/dht/gnunet-service-dht_clients.c +++ b/src/dht/gnunet-service-dht_clients.c | |||
@@ -982,9 +982,6 @@ forward_reply (void *cls, | |||
982 | /* should be impossible to encounter here */ | 982 | /* should be impossible to encounter here */ |
983 | GNUNET_break (0); | 983 | GNUNET_break (0); |
984 | return GNUNET_YES; | 984 | return GNUNET_YES; |
985 | case GNUNET_BLOCK_REPLY_INVALID: | ||
986 | GNUNET_break_op (0); | ||
987 | return GNUNET_NO; | ||
988 | case GNUNET_BLOCK_REPLY_IRRELEVANT: | 985 | case GNUNET_BLOCK_REPLY_IRRELEVANT: |
989 | return GNUNET_YES; | 986 | return GNUNET_YES; |
990 | default: | 987 | default: |
diff --git a/src/dht/gnunet-service-dht_datacache.c b/src/dht/gnunet-service-dht_datacache.c index 91bdfe3da..be0a6db81 100644 --- a/src/dht/gnunet-service-dht_datacache.c +++ b/src/dht/gnunet-service-dht_datacache.c | |||
@@ -126,7 +126,7 @@ struct GetRequestContext | |||
126 | /** | 126 | /** |
127 | * Return value to give back. | 127 | * Return value to give back. |
128 | */ | 128 | */ |
129 | enum GNUNET_BLOCK_EvaluationResult eval; | 129 | enum GNUNET_BLOCK_ReplyEvaluationResult eval; |
130 | }; | 130 | }; |
131 | 131 | ||
132 | 132 | ||
@@ -204,13 +204,6 @@ datacache_get_iterator (void *cls, | |||
204 | 1, | 204 | 1, |
205 | GNUNET_NO); | 205 | GNUNET_NO); |
206 | break; | 206 | break; |
207 | case GNUNET_BLOCK_REPLY_INVALID: | ||
208 | /* maybe it expired? */ | ||
209 | GNUNET_STATISTICS_update (GDS_stats, | ||
210 | "# Invalid RESULTS found in datacache", | ||
211 | 1, | ||
212 | GNUNET_NO); | ||
213 | break; | ||
214 | case GNUNET_BLOCK_REPLY_IRRELEVANT: | 207 | case GNUNET_BLOCK_REPLY_IRRELEVANT: |
215 | GNUNET_STATISTICS_update (GDS_stats, | 208 | GNUNET_STATISTICS_update (GDS_stats, |
216 | "# Irrelevant RESULTS found in datacache", | 209 | "# Irrelevant RESULTS found in datacache", |
@@ -222,7 +215,7 @@ datacache_get_iterator (void *cls, | |||
222 | } | 215 | } |
223 | 216 | ||
224 | 217 | ||
225 | enum GNUNET_BLOCK_EvaluationResult | 218 | enum GNUNET_BLOCK_ReplyEvaluationResult |
226 | GDS_DATACACHE_handle_get (const struct GNUNET_HashCode *key, | 219 | GDS_DATACACHE_handle_get (const struct GNUNET_HashCode *key, |
227 | enum GNUNET_BLOCK_Type type, | 220 | enum GNUNET_BLOCK_Type type, |
228 | const void *xquery, | 221 | const void *xquery, |
@@ -232,7 +225,7 @@ GDS_DATACACHE_handle_get (const struct GNUNET_HashCode *key, | |||
232 | void *gc_cls) | 225 | void *gc_cls) |
233 | { | 226 | { |
234 | struct GetRequestContext ctx = { | 227 | struct GetRequestContext ctx = { |
235 | .eval = GNUNET_BLOCK_EVALUATION_REQUEST_VALID, | 228 | .eval = GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED, |
236 | .key = *key, | 229 | .key = *key, |
237 | .xquery = xquery, | 230 | .xquery = xquery, |
238 | .xquery_size = xquery_size, | 231 | .xquery_size = xquery_size, |
@@ -243,7 +236,7 @@ GDS_DATACACHE_handle_get (const struct GNUNET_HashCode *key, | |||
243 | unsigned int r; | 236 | unsigned int r; |
244 | 237 | ||
245 | if (NULL == datacache) | 238 | if (NULL == datacache) |
246 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; | 239 | return GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED; |
247 | GNUNET_STATISTICS_update (GDS_stats, | 240 | GNUNET_STATISTICS_update (GDS_stats, |
248 | "# GET requests given to datacache", | 241 | "# GET requests given to datacache", |
249 | 1, | 242 | 1, |
@@ -262,7 +255,7 @@ GDS_DATACACHE_handle_get (const struct GNUNET_HashCode *key, | |||
262 | } | 255 | } |
263 | 256 | ||
264 | 257 | ||
265 | enum GNUNET_BLOCK_EvaluationResult | 258 | enum GNUNET_BLOCK_ReplyEvaluationResult |
266 | GDS_DATACACHE_get_closest (const struct GNUNET_HashCode *key, | 259 | GDS_DATACACHE_get_closest (const struct GNUNET_HashCode *key, |
267 | enum GNUNET_BLOCK_Type type, | 260 | enum GNUNET_BLOCK_Type type, |
268 | const void *xquery, | 261 | const void *xquery, |
@@ -272,7 +265,7 @@ GDS_DATACACHE_get_closest (const struct GNUNET_HashCode *key, | |||
272 | void *cb_cls) | 265 | void *cb_cls) |
273 | { | 266 | { |
274 | struct GetRequestContext ctx = { | 267 | struct GetRequestContext ctx = { |
275 | .eval = GNUNET_BLOCK_EVALUATION_REQUEST_VALID, | 268 | .eval = GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED, |
276 | .key = *key, | 269 | .key = *key, |
277 | .xquery = xquery, | 270 | .xquery = xquery, |
278 | .xquery_size = xquery_size, | 271 | .xquery_size = xquery_size, |
@@ -283,7 +276,7 @@ GDS_DATACACHE_get_closest (const struct GNUNET_HashCode *key, | |||
283 | unsigned int r; | 276 | unsigned int r; |
284 | 277 | ||
285 | if (NULL == datacache) | 278 | if (NULL == datacache) |
286 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; | 279 | return GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED; |
287 | GNUNET_STATISTICS_update (GDS_stats, | 280 | GNUNET_STATISTICS_update (GDS_stats, |
288 | "# GET closest requests given to datacache", | 281 | "# GET closest requests given to datacache", |
289 | 1, | 282 | 1, |
diff --git a/src/dht/gnunet-service-dht_datacache.h b/src/dht/gnunet-service-dht_datacache.h index 69a18c605..d860139f5 100644 --- a/src/dht/gnunet-service-dht_datacache.h +++ b/src/dht/gnunet-service-dht_datacache.h | |||
@@ -107,7 +107,7 @@ typedef void | |||
107 | * @param gc_cls closure for @a gc | 107 | * @param gc_cls closure for @a gc |
108 | * @return evaluation result for the local replies | 108 | * @return evaluation result for the local replies |
109 | */ | 109 | */ |
110 | enum GNUNET_BLOCK_EvaluationResult | 110 | enum GNUNET_BLOCK_ReplyEvaluationResult |
111 | GDS_DATACACHE_handle_get (const struct GNUNET_HashCode *key, | 111 | GDS_DATACACHE_handle_get (const struct GNUNET_HashCode *key, |
112 | enum GNUNET_BLOCK_Type type, | 112 | enum GNUNET_BLOCK_Type type, |
113 | const void *xquery, | 113 | const void *xquery, |
@@ -130,7 +130,7 @@ GDS_DATACACHE_handle_get (const struct GNUNET_HashCode *key, | |||
130 | * @param cb_cls closure for @a cb | 130 | * @param cb_cls closure for @a cb |
131 | * @return evaluation result for the local replies | 131 | * @return evaluation result for the local replies |
132 | */ | 132 | */ |
133 | enum GNUNET_BLOCK_EvaluationResult | 133 | enum GNUNET_BLOCK_ReplyEvaluationResult |
134 | GDS_DATACACHE_get_closest (const struct GNUNET_HashCode *key, | 134 | GDS_DATACACHE_get_closest (const struct GNUNET_HashCode *key, |
135 | enum GNUNET_BLOCK_Type type, | 135 | enum GNUNET_BLOCK_Type type, |
136 | const void *xquery, | 136 | const void *xquery, |
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c index db4ecb34a..7e570d4f5 100644 --- a/src/dht/gnunet-service-dht_neighbours.c +++ b/src/dht/gnunet-service-dht_neighbours.c | |||
@@ -1821,6 +1821,16 @@ handle_dht_p2p_put (void *cls, | |||
1821 | GNUNET_NO); | 1821 | GNUNET_NO); |
1822 | return; | 1822 | return; |
1823 | } | 1823 | } |
1824 | if (GNUNET_NO == | ||
1825 | GNUNET_BLOCK_check_block (GDS_block_context, | ||
1826 | bd.type, | ||
1827 | bd.data, | ||
1828 | bd.data_size)) | ||
1829 | { | ||
1830 | GNUNET_break_op (0); | ||
1831 | return; | ||
1832 | } | ||
1833 | |||
1824 | GNUNET_STATISTICS_update (GDS_stats, | 1834 | GNUNET_STATISTICS_update (GDS_stats, |
1825 | "# P2P PUT requests received", | 1835 | "# P2P PUT requests received", |
1826 | 1, | 1836 | 1, |
@@ -1857,17 +1867,6 @@ handle_dht_p2p_put (void *cls, | |||
1857 | } | 1867 | } |
1858 | } | 1868 | } |
1859 | 1869 | ||
1860 | if (GNUNET_NO == | ||
1861 | GNUNET_BLOCK_check_block (GDS_block_context, | ||
1862 | bd.type, | ||
1863 | &bd.key, | ||
1864 | bd.data, | ||
1865 | bd.data_size)) | ||
1866 | { | ||
1867 | GNUNET_break_op (0); | ||
1868 | return; | ||
1869 | } | ||
1870 | |||
1871 | { | 1870 | { |
1872 | struct GNUNET_CONTAINER_BloomFilter *bf; | 1871 | struct GNUNET_CONTAINER_BloomFilter *bf; |
1873 | struct GNUNET_DHT_PathElement pp[putlen + 1]; | 1872 | struct GNUNET_DHT_PathElement pp[putlen + 1]; |
@@ -2465,6 +2464,15 @@ handle_dht_p2p_result (void *cls, | |||
2465 | bd.data_size = msize - (sizeof(struct PeerResultMessage) | 2464 | bd.data_size = msize - (sizeof(struct PeerResultMessage) |
2466 | + (get_path_length + bd.put_path_length) | 2465 | + (get_path_length + bd.put_path_length) |
2467 | * sizeof(struct GNUNET_DHT_PathElement)); | 2466 | * sizeof(struct GNUNET_DHT_PathElement)); |
2467 | if (GNUNET_OK != | ||
2468 | GNUNET_BLOCK_check_block (GDS_block_context, | ||
2469 | bd.type, | ||
2470 | bd.data, | ||
2471 | bd.data_size)) | ||
2472 | { | ||
2473 | GNUNET_break_op (0); | ||
2474 | return; | ||
2475 | } | ||
2468 | GNUNET_STATISTICS_update (GDS_stats, | 2476 | GNUNET_STATISTICS_update (GDS_stats, |
2469 | "# P2P RESULTS received", | 2477 | "# P2P RESULTS received", |
2470 | 1, | 2478 | 1, |
@@ -2475,7 +2483,6 @@ handle_dht_p2p_result (void *cls, | |||
2475 | GNUNET_NO); | 2483 | GNUNET_NO); |
2476 | { | 2484 | { |
2477 | enum GNUNET_GenericReturnValue ret; | 2485 | enum GNUNET_GenericReturnValue ret; |
2478 | const struct GNUNET_HashCode *pquery; | ||
2479 | 2486 | ||
2480 | ret = GNUNET_BLOCK_get_key (GDS_block_context, | 2487 | ret = GNUNET_BLOCK_get_key (GDS_block_context, |
2481 | bd.type, | 2488 | bd.type, |
@@ -2484,18 +2491,7 @@ handle_dht_p2p_result (void *cls, | |||
2484 | &bd.key); | 2491 | &bd.key); |
2485 | if (GNUNET_NO == ret) | 2492 | if (GNUNET_NO == ret) |
2486 | { | 2493 | { |
2487 | GNUNET_break_op (0); | 2494 | bd.key = prm->key; |
2488 | return; | ||
2489 | } | ||
2490 | pquery = (GNUNET_OK == ret) ? &bd.key : &prm->key; | ||
2491 | if (GNUNET_OK != | ||
2492 | GNUNET_BLOCK_check_block (GDS_block_context, | ||
2493 | bd.type, | ||
2494 | pquery, | ||
2495 | bd.data, | ||
2496 | bd.data_size)) | ||
2497 | { | ||
2498 | GNUNET_break_op (0); | ||
2499 | return; | 2495 | return; |
2500 | } | 2496 | } |
2501 | } | 2497 | } |
diff --git a/src/dht/gnunet-service-dht_routing.c b/src/dht/gnunet-service-dht_routing.c index da9919e82..05902b941 100644 --- a/src/dht/gnunet-service-dht_routing.c +++ b/src/dht/gnunet-service-dht_routing.c | |||
@@ -208,13 +208,6 @@ process (void *cls, | |||
208 | 1, | 208 | 1, |
209 | GNUNET_NO); | 209 | GNUNET_NO); |
210 | return GNUNET_OK; | 210 | return GNUNET_OK; |
211 | case GNUNET_BLOCK_REPLY_INVALID: | ||
212 | GNUNET_break (0); | ||
213 | GNUNET_STATISTICS_update (GDS_stats, | ||
214 | "# Invalid REPLIES matched against routing table", | ||
215 | 1, | ||
216 | GNUNET_NO); | ||
217 | return GNUNET_OK; | ||
218 | case GNUNET_BLOCK_REPLY_IRRELEVANT: | 211 | case GNUNET_BLOCK_REPLY_IRRELEVANT: |
219 | GNUNET_STATISTICS_update (GDS_stats, | 212 | GNUNET_STATISTICS_update (GDS_stats, |
220 | "# Irrelevant REPLIES matched against routing table", | 213 | "# Irrelevant REPLIES matched against routing table", |
diff --git a/src/dht/plugin_block_dht.c b/src/dht/plugin_block_dht.c index 0dbe21af9..9ff67fa4e 100644 --- a/src/dht/plugin_block_dht.c +++ b/src/dht/plugin_block_dht.c | |||
@@ -90,88 +90,9 @@ block_plugin_dht_create_group (void *cls, | |||
90 | 90 | ||
91 | 91 | ||
92 | /** | 92 | /** |
93 | * Function called to validate a reply or a request. For | ||
94 | * request evaluation, simply pass "NULL" for the @a reply_block. | ||
95 | * | ||
96 | * @param cls closure | ||
97 | * @param ctx context | ||
98 | * @param type block type | ||
99 | * @param group block group to check against | ||
100 | * @param eo control flags | ||
101 | * @param query original query (hash) | ||
102 | * @param xquery extended query data (can be NULL, depending on type) | ||
103 | * @param xquery_size number of bytes in @a xquery | ||
104 | * @param reply_block response to validate | ||
105 | * @param reply_block_size number of bytes in @a reply_block | ||
106 | * @return characterization of result | ||
107 | */ | ||
108 | static enum GNUNET_BLOCK_EvaluationResult | ||
109 | block_plugin_dht_evaluate (void *cls, | ||
110 | struct GNUNET_BLOCK_Context *ctx, | ||
111 | enum GNUNET_BLOCK_Type type, | ||
112 | struct GNUNET_BLOCK_Group *group, | ||
113 | enum GNUNET_BLOCK_EvaluationOptions eo, | ||
114 | const struct GNUNET_HashCode *query, | ||
115 | const void *xquery, | ||
116 | size_t xquery_size, | ||
117 | const void *reply_block, | ||
118 | size_t reply_block_size) | ||
119 | { | ||
120 | switch (type) | ||
121 | { | ||
122 | case GNUNET_BLOCK_TYPE_DHT_HELLO: | ||
123 | { | ||
124 | const struct GNUNET_HELLO_Message *hello; | ||
125 | struct GNUNET_PeerIdentity pid; | ||
126 | const struct GNUNET_MessageHeader *msg; | ||
127 | struct GNUNET_HashCode phash; | ||
128 | |||
129 | if (0 != xquery_size) | ||
130 | { | ||
131 | GNUNET_break_op (0); | ||
132 | return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID; | ||
133 | } | ||
134 | if (NULL == reply_block) | ||
135 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; | ||
136 | if (reply_block_size < sizeof(struct GNUNET_MessageHeader)) | ||
137 | { | ||
138 | GNUNET_break_op (0); | ||
139 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | ||
140 | } | ||
141 | msg = reply_block; | ||
142 | if (reply_block_size != ntohs (msg->size)) | ||
143 | { | ||
144 | GNUNET_break_op (0); | ||
145 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | ||
146 | } | ||
147 | hello = reply_block; | ||
148 | if (GNUNET_OK != GNUNET_HELLO_get_id (hello, &pid)) | ||
149 | { | ||
150 | GNUNET_break_op (0); | ||
151 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | ||
152 | } | ||
153 | GNUNET_CRYPTO_hash (&pid, | ||
154 | sizeof(pid), | ||
155 | &phash); | ||
156 | if (GNUNET_YES == | ||
157 | GNUNET_BLOCK_GROUP_bf_test_and_set (group, | ||
158 | &phash)) | ||
159 | return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE; | ||
160 | return GNUNET_BLOCK_EVALUATION_OK_MORE; | ||
161 | } | ||
162 | case GNUNET_BLOCK_TYPE_DHT_URL_HELLO: | ||
163 | GNUNET_break (0); // legacy API not implemented | ||
164 | default: | ||
165 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; | ||
166 | } | ||
167 | } | ||
168 | |||
169 | |||
170 | /** | ||
171 | * Function called to validate a query. | 93 | * Function called to validate a query. |
172 | * | 94 | * |
173 | * @param cls closure | 95 | * @param cls closure |
174 | * @param ctx block context | ||
175 | * @param type block type | 96 | * @param type block type |
176 | * @param query original query (hash) | 97 | * @param query original query (hash) |
177 | * @param xquery extrended query data (can be NULL, depending on type) | 98 | * @param xquery extrended query data (can be NULL, depending on type) |
@@ -202,6 +123,7 @@ block_plugin_dht_check_query (void *cls, | |||
202 | } | 123 | } |
203 | return GNUNET_OK; | 124 | return GNUNET_OK; |
204 | default: | 125 | default: |
126 | GNUNET_break (0); | ||
205 | return GNUNET_SYSERR; | 127 | return GNUNET_SYSERR; |
206 | } | 128 | } |
207 | } | 129 | } |
@@ -212,7 +134,6 @@ block_plugin_dht_check_query (void *cls, | |||
212 | * | 134 | * |
213 | * @param cls closure | 135 | * @param cls closure |
214 | * @param type block type | 136 | * @param type block type |
215 | * @param query key for the block (hash), must match exactly | ||
216 | * @param block block data to validate | 137 | * @param block block data to validate |
217 | * @param block_size number of bytes in @a block | 138 | * @param block_size number of bytes in @a block |
218 | * @return #GNUNET_OK if the block is fine, #GNUNET_NO if not | 139 | * @return #GNUNET_OK if the block is fine, #GNUNET_NO if not |
@@ -220,7 +141,6 @@ block_plugin_dht_check_query (void *cls, | |||
220 | static enum GNUNET_GenericReturnValue | 141 | static enum GNUNET_GenericReturnValue |
221 | block_plugin_dht_check_block (void *cls, | 142 | block_plugin_dht_check_block (void *cls, |
222 | enum GNUNET_BLOCK_Type type, | 143 | enum GNUNET_BLOCK_Type type, |
223 | const struct GNUNET_HashCode *query, | ||
224 | const void *block, | 144 | const void *block, |
225 | size_t block_size) | 145 | size_t block_size) |
226 | { | 146 | { |
@@ -273,16 +193,10 @@ block_plugin_dht_check_block (void *cls, | |||
273 | sizeof (pid), | 193 | sizeof (pid), |
274 | &h_pid); | 194 | &h_pid); |
275 | GNUNET_HELLO_builder_free (b); | 195 | GNUNET_HELLO_builder_free (b); |
276 | if (0 != | ||
277 | GNUNET_memcmp (&h_pid, | ||
278 | query)) | ||
279 | { | ||
280 | GNUNET_break_op (0); | ||
281 | return GNUNET_NO; | ||
282 | } | ||
283 | return GNUNET_OK; | 196 | return GNUNET_OK; |
284 | } | 197 | } |
285 | default: | 198 | default: |
199 | GNUNET_break (0); | ||
286 | return GNUNET_SYSERR; | 200 | return GNUNET_SYSERR; |
287 | } | 201 | } |
288 | } | 202 | } |
@@ -319,30 +233,16 @@ block_plugin_dht_check_reply ( | |||
319 | { | 233 | { |
320 | case GNUNET_BLOCK_TYPE_DHT_HELLO: | 234 | case GNUNET_BLOCK_TYPE_DHT_HELLO: |
321 | { | 235 | { |
322 | const struct GNUNET_HELLO_Message *hello; | 236 | const struct GNUNET_MessageHeader *msg = reply_block; |
237 | const struct GNUNET_HELLO_Message *hello = reply_block; | ||
323 | struct GNUNET_PeerIdentity pid; | 238 | struct GNUNET_PeerIdentity pid; |
324 | const struct GNUNET_MessageHeader *msg; | ||
325 | struct GNUNET_HashCode phash; | 239 | struct GNUNET_HashCode phash; |
326 | 240 | ||
327 | if (reply_block_size < sizeof(struct GNUNET_MessageHeader)) | 241 | GNUNET_assert (reply_block_size >= sizeof(struct GNUNET_MessageHeader)); |
328 | { | 242 | GNUNET_assert (reply_block_size == ntohs (msg->size)); |
329 | GNUNET_break_op (0); | 243 | GNUNET_assert (GNUNET_OK != |
330 | return GNUNET_BLOCK_REPLY_INVALID; | 244 | GNUNET_HELLO_get_id (hello, |
331 | } | 245 | &pid)); |
332 | msg = reply_block; | ||
333 | if (reply_block_size != ntohs (msg->size)) | ||
334 | { | ||
335 | GNUNET_break_op (0); | ||
336 | return GNUNET_BLOCK_REPLY_INVALID; | ||
337 | } | ||
338 | hello = reply_block; | ||
339 | if (GNUNET_OK != | ||
340 | GNUNET_HELLO_get_id (hello, | ||
341 | &pid)) | ||
342 | { | ||
343 | GNUNET_break_op (0); | ||
344 | return GNUNET_BLOCK_REPLY_INVALID; | ||
345 | } | ||
346 | GNUNET_CRYPTO_hash (&pid, | 246 | GNUNET_CRYPTO_hash (&pid, |
347 | sizeof(pid), | 247 | sizeof(pid), |
348 | &phash); | 248 | &phash); |
@@ -399,31 +299,35 @@ block_plugin_dht_get_key (void *cls, | |||
399 | 299 | ||
400 | if (block_size < sizeof(struct GNUNET_MessageHeader)) | 300 | if (block_size < sizeof(struct GNUNET_MessageHeader)) |
401 | { | 301 | { |
402 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, | 302 | GNUNET_break_op (0); |
403 | "block-dht", | 303 | memset (key, |
404 | _ ("Block not of type %u\n"), | 304 | 0, |
405 | GNUNET_BLOCK_TYPE_DHT_HELLO); | 305 | sizeof (*key)); |
406 | return GNUNET_NO; | 306 | return GNUNET_OK; |
407 | } | 307 | } |
408 | msg = block; | 308 | msg = block; |
409 | if (block_size != ntohs (msg->size)) | 309 | if (block_size != ntohs (msg->size)) |
410 | { | 310 | { |
411 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, | 311 | GNUNET_break_op (0); |
412 | "block-dht", | 312 | memset (key, |
413 | _ ("Size mismatch for block with type %u\n"), | 313 | 0, |
414 | GNUNET_BLOCK_TYPE_DHT_HELLO); | 314 | sizeof (*key)); |
415 | return GNUNET_NO; | 315 | return GNUNET_OK; |
416 | } | 316 | } |
417 | hello = block; | 317 | hello = block; |
418 | memset (key, 0, sizeof(*key)); | 318 | memset (key, |
319 | 0, | ||
320 | sizeof(*key)); | ||
419 | pid = (struct GNUNET_PeerIdentity *) key; | 321 | pid = (struct GNUNET_PeerIdentity *) key; |
420 | if (GNUNET_OK != GNUNET_HELLO_get_id (hello, pid)) | 322 | if (GNUNET_OK != |
323 | GNUNET_HELLO_get_id (hello, | ||
324 | pid)) | ||
421 | { | 325 | { |
422 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, | 326 | GNUNET_break_op (0); |
423 | "block-dht", | 327 | memset (key, |
424 | _ ("Block of type %u is malformed\n"), | 328 | 0, |
425 | GNUNET_BLOCK_TYPE_DHT_HELLO); | 329 | sizeof (*key)); |
426 | return GNUNET_NO; | 330 | return GNUNET_OK; |
427 | } | 331 | } |
428 | return GNUNET_OK; | 332 | return GNUNET_OK; |
429 | } | 333 | } |
@@ -437,7 +341,10 @@ block_plugin_dht_get_key (void *cls, | |||
437 | if (NULL == b) | 341 | if (NULL == b) |
438 | { | 342 | { |
439 | GNUNET_break (0); | 343 | GNUNET_break (0); |
440 | return GNUNET_NO; | 344 | memset (key, |
345 | 0, | ||
346 | sizeof (*key)); | ||
347 | return GNUNET_OK; | ||
441 | } | 348 | } |
442 | GNUNET_HELLO_builder_iterate (b, | 349 | GNUNET_HELLO_builder_iterate (b, |
443 | &pid, | 350 | &pid, |
@@ -449,6 +356,7 @@ block_plugin_dht_get_key (void *cls, | |||
449 | return GNUNET_OK; | 356 | return GNUNET_OK; |
450 | } | 357 | } |
451 | default: | 358 | default: |
359 | GNUNET_break (0); | ||
452 | return GNUNET_SYSERR; | 360 | return GNUNET_SYSERR; |
453 | } | 361 | } |
454 | } | 362 | } |
@@ -468,7 +376,6 @@ libgnunet_plugin_block_dht_init (void *cls) | |||
468 | struct GNUNET_BLOCK_PluginFunctions *api; | 376 | struct GNUNET_BLOCK_PluginFunctions *api; |
469 | 377 | ||
470 | api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions); | 378 | api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions); |
471 | api->evaluate = &block_plugin_dht_evaluate; | ||
472 | api->get_key = &block_plugin_dht_get_key; | 379 | api->get_key = &block_plugin_dht_get_key; |
473 | api->check_query = &block_plugin_dht_check_query; | 380 | api->check_query = &block_plugin_dht_check_query; |
474 | api->check_block = &block_plugin_dht_check_block; | 381 | api->check_block = &block_plugin_dht_check_block; |