diff options
Diffstat (limited to 'src/dht')
34 files changed, 765 insertions, 965 deletions
diff --git a/src/dht/dht.conf.in b/src/dht/dht.conf.in index f828b725f..405ef1917 100644 --- a/src/dht/dht.conf.in +++ b/src/dht/dht.conf.in | |||
@@ -1,6 +1,6 @@ | |||
1 | [dht] | 1 | [dht] |
2 | FORCESTART = YES | 2 | IMMEDIATE_START = YES |
3 | AUTOSTART = @AUTOSTART@ | 3 | START_ON_DEMAND = @START_ON_DEMAND@ |
4 | @JAVAPORT@PORT = 2095 | 4 | @JAVAPORT@PORT = 2095 |
5 | HOSTNAME = localhost | 5 | HOSTNAME = localhost |
6 | BINARY = gnunet-service-dht | 6 | BINARY = gnunet-service-dht |
diff --git a/src/dht/dht.h b/src/dht/dht.h index 95ffa33ca..35d9e7cdb 100644 --- a/src/dht/dht.h +++ b/src/dht/dht.h | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2001, 2002, 2003, 2004, 2009, 2011 GNUnet e.V. | 3 | Copyright (C) 2001, 2002, 2003, 2004, 2009, 2011 GNUnet e.V. |
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 it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | 18 | ||
21 | /** | 19 | /** |
diff --git a/src/dht/dht_api.c b/src/dht/dht_api.c index af0dafbf3..ec5da3b0a 100644 --- a/src/dht/dht_api.c +++ b/src/dht/dht_api.c | |||
@@ -1,21 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2009, 2010, 2011, 2012, 2016 GNUnet e.V. | 3 | Copyright (C) 2009, 2010, 2011, 2012, 2016, 2018 GNUnet e.V. |
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 it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | 18 | ||
21 | /** | 19 | /** |
@@ -86,7 +84,7 @@ struct GNUNET_DHT_GetHandle | |||
86 | GNUNET_DHT_GetIterator iter; | 84 | GNUNET_DHT_GetIterator iter; |
87 | 85 | ||
88 | /** | 86 | /** |
89 | * Closure for @a iter. | 87 | * Closure for @e iter. |
90 | */ | 88 | */ |
91 | void *iter_cls; | 89 | void *iter_cls; |
92 | 90 | ||
@@ -292,8 +290,8 @@ send_get (struct GNUNET_DHT_GetHandle *gh) | |||
292 | get_msg->key = gh->key; | 290 | get_msg->key = gh->key; |
293 | get_msg->unique_id = gh->unique_id; | 291 | get_msg->unique_id = gh->unique_id; |
294 | GNUNET_memcpy (&get_msg[1], | 292 | GNUNET_memcpy (&get_msg[1], |
295 | &gh[1], | 293 | &gh[1], |
296 | gh->xquery_size); | 294 | gh->xquery_size); |
297 | GNUNET_MQ_send (h->mq, | 295 | GNUNET_MQ_send (h->mq, |
298 | env); | 296 | env); |
299 | } | 297 | } |
diff --git a/src/dht/dht_test_lib.c b/src/dht/dht_test_lib.c index 52d5a3731..f9bd2c9e3 100644 --- a/src/dht/dht_test_lib.c +++ b/src/dht/dht_test_lib.c | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2012 GNUnet e.V. | 3 | Copyright (C) 2012 GNUnet e.V. |
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 it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | /** | 18 | /** |
21 | * @file dht/dht_test_lib.c | 19 | * @file dht/dht_test_lib.c |
diff --git a/src/dht/dht_test_lib.h b/src/dht/dht_test_lib.h index 0b4a51c8f..2bdcf0158 100644 --- a/src/dht/dht_test_lib.h +++ b/src/dht/dht_test_lib.h | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2012 GNUnet e.V. | 3 | Copyright (C) 2012 GNUnet e.V. |
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 it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | /** | 18 | /** |
21 | * @file dht/dht_test_lib.h | 19 | * @file dht/dht_test_lib.h |
diff --git a/src/dht/gnunet-dht-get.c b/src/dht/gnunet-dht-get.c index 842ec6270..3742ed739 100644 --- a/src/dht/gnunet-dht-get.c +++ b/src/dht/gnunet-dht-get.c | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009 GNUnet e.V. | 3 | Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009 GNUnet e.V. |
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 it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | /** | 18 | /** |
21 | * @file dht/gnunet-dht-get.c | 19 | * @file dht/gnunet-dht-get.c |
@@ -154,7 +152,9 @@ get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp, | |||
154 | const void *data) | 152 | const void *data) |
155 | { | 153 | { |
156 | FPRINTF (stdout, | 154 | FPRINTF (stdout, |
157 | _("Result %d, type %d:\n%.*s\n"), | 155 | (GNUNET_BLOCK_TYPE_TEST == type) |
156 | ? _("Result %d, type %d:\n%.*s\n") | ||
157 | : _("Result %d, type %d:\n"), | ||
158 | result_count, | 158 | result_count, |
159 | type, | 159 | type, |
160 | (unsigned int) size, | 160 | (unsigned int) size, |
@@ -196,8 +196,6 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
196 | { | 196 | { |
197 | struct GNUNET_HashCode key; | 197 | struct GNUNET_HashCode key; |
198 | 198 | ||
199 | |||
200 | |||
201 | cfg = c; | 199 | cfg = c; |
202 | if (NULL == query_key) | 200 | if (NULL == query_key) |
203 | { | 201 | { |
@@ -215,17 +213,22 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
215 | query_type = GNUNET_BLOCK_TYPE_TEST; | 213 | query_type = GNUNET_BLOCK_TYPE_TEST; |
216 | GNUNET_CRYPTO_hash (query_key, strlen (query_key), &key); | 214 | GNUNET_CRYPTO_hash (query_key, strlen (query_key), &key); |
217 | if (verbose) | 215 | if (verbose) |
218 | FPRINTF (stderr, "%s `%s' \n", _("Issueing DHT GET with key"), GNUNET_h2s_full (&key)); | 216 | FPRINTF (stderr, "%s `%s' \n", |
217 | _("Issueing DHT GET with key"), | ||
218 | GNUNET_h2s_full (&key)); | ||
219 | GNUNET_SCHEDULER_add_shutdown (&cleanup_task, NULL); | 219 | GNUNET_SCHEDULER_add_shutdown (&cleanup_task, NULL); |
220 | tt = GNUNET_SCHEDULER_add_delayed (timeout_request, | 220 | tt = GNUNET_SCHEDULER_add_delayed (timeout_request, |
221 | &timeout_task, NULL); | 221 | &timeout_task, |
222 | NULL); | ||
222 | get_handle = | 223 | get_handle = |
223 | GNUNET_DHT_get_start (dht_handle, query_type, &key, replication, | 224 | GNUNET_DHT_get_start (dht_handle, query_type, &key, replication, |
224 | (demultixplex_everywhere) ? GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE : GNUNET_DHT_RO_NONE, | 225 | (demultixplex_everywhere) ? GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE : GNUNET_DHT_RO_NONE, |
225 | NULL, 0, &get_result_iterator, NULL); | 226 | NULL, 0, |
226 | 227 | &get_result_iterator, | |
228 | NULL); | ||
227 | } | 229 | } |
228 | 230 | ||
231 | |||
229 | /** | 232 | /** |
230 | * Entry point for gnunet-dht-get | 233 | * Entry point for gnunet-dht-get |
231 | * | 234 | * |
@@ -236,15 +239,12 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
236 | int | 239 | int |
237 | main (int argc, char *const *argv) | 240 | main (int argc, char *const *argv) |
238 | { | 241 | { |
239 | |||
240 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 242 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
241 | |||
242 | GNUNET_GETOPT_option_string ('k', | 243 | GNUNET_GETOPT_option_string ('k', |
243 | "key", | 244 | "key", |
244 | "KEY", | 245 | "KEY", |
245 | gettext_noop ("the query key"), | 246 | gettext_noop ("the query key"), |
246 | &query_key), | 247 | &query_key), |
247 | |||
248 | GNUNET_GETOPT_option_uint ('r', | 248 | GNUNET_GETOPT_option_uint ('r', |
249 | "replication", | 249 | "replication", |
250 | "LEVEL", | 250 | "LEVEL", |
diff --git a/src/dht/gnunet-dht-monitor.c b/src/dht/gnunet-dht-monitor.c index b7360bbab..b08521c7b 100644 --- a/src/dht/gnunet-dht-monitor.c +++ b/src/dht/gnunet-dht-monitor.c | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2012 GNUnet e.V. | 3 | Copyright (C) 2012 GNUnet e.V. |
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 it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | /** | 18 | /** |
21 | * @file dht/gnunet-dht-monitor.c | 19 | * @file dht/gnunet-dht-monitor.c |
@@ -141,7 +139,8 @@ get_callback (void *cls, | |||
141 | const struct GNUNET_PeerIdentity *path, | 139 | const struct GNUNET_PeerIdentity *path, |
142 | const struct GNUNET_HashCode * key) | 140 | const struct GNUNET_HashCode * key) |
143 | { | 141 | { |
144 | FPRINTF (stdout, "GET #%u: type %d, key `%s'\n", | 142 | FPRINTF (stdout, |
143 | "GET #%u: type %d, key `%s'\n", | ||
145 | result_count, | 144 | result_count, |
146 | (int) type, | 145 | (int) type, |
147 | GNUNET_h2s_full(key)); | 146 | GNUNET_h2s_full(key)); |
@@ -176,8 +175,11 @@ get_resp_callback (void *cls, | |||
176 | size_t size) | 175 | size_t size) |
177 | { | 176 | { |
178 | FPRINTF (stdout, | 177 | FPRINTF (stdout, |
179 | "RESPONSE #%u: type %d, key `%s', data `%.*s'\n", | 178 | (GNUNET_BLOCK_TYPE_TEST == type) |
179 | ? "RESPONSE #%u (%s): type %d, key `%s', data `%.*s'\n" | ||
180 | : "RESPONSE #%u (%s): type %d, key `%s'\n", | ||
180 | result_count, | 181 | result_count, |
182 | GNUNET_STRINGS_absolute_time_to_string (exp), | ||
181 | (int) type, | 183 | (int) type, |
182 | GNUNET_h2s_full (key), | 184 | GNUNET_h2s_full (key), |
183 | (unsigned int) size, | 185 | (unsigned int) size, |
@@ -215,8 +217,11 @@ put_callback (void *cls, | |||
215 | size_t size) | 217 | size_t size) |
216 | { | 218 | { |
217 | FPRINTF (stdout, | 219 | FPRINTF (stdout, |
218 | "PUT %u: type %d, key `%s', data `%.*s'\n", | 220 | (GNUNET_BLOCK_TYPE_TEST == type) |
221 | ? "PUT %u (%s): type %d, key `%s', data `%.*s'\n" | ||
222 | : "PUT %u (%s): type %d, key `%s'\n", | ||
219 | result_count, | 223 | result_count, |
224 | GNUNET_STRINGS_absolute_time_to_string (exp), | ||
220 | (int) type, | 225 | (int) type, |
221 | GNUNET_h2s_full(key), | 226 | GNUNET_h2s_full(key), |
222 | (unsigned int) size, | 227 | (unsigned int) size, |
@@ -234,7 +239,9 @@ put_callback (void *cls, | |||
234 | * @param c configuration | 239 | * @param c configuration |
235 | */ | 240 | */ |
236 | static void | 241 | static void |
237 | run (void *cls, char *const *args, const char *cfgfile, | 242 | run (void *cls, |
243 | char *const *args, | ||
244 | const char *cfgfile, | ||
238 | const struct GNUNET_CONFIGURATION_Handle *c) | 245 | const struct GNUNET_CONFIGURATION_Handle *c) |
239 | { | 246 | { |
240 | struct GNUNET_HashCode *key; | 247 | struct GNUNET_HashCode *key; |
@@ -291,30 +298,30 @@ int | |||
291 | main (int argc, char *const *argv) | 298 | main (int argc, char *const *argv) |
292 | { | 299 | { |
293 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 300 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
294 | 301 | ||
295 | GNUNET_GETOPT_option_string ('k', | 302 | GNUNET_GETOPT_option_string ('k', |
296 | "key", | 303 | "key", |
297 | "KEY", | 304 | "KEY", |
298 | gettext_noop ("the query key"), | 305 | gettext_noop ("the query key"), |
299 | &query_key), | 306 | &query_key), |
300 | 307 | ||
301 | GNUNET_GETOPT_option_uint ('t', | 308 | GNUNET_GETOPT_option_uint ('t', |
302 | "type", | 309 | "type", |
303 | "TYPE", | 310 | "TYPE", |
304 | gettext_noop ("the type of data to look for"), | 311 | gettext_noop ("the type of data to look for"), |
305 | &block_type), | 312 | &block_type), |
306 | 313 | ||
307 | GNUNET_GETOPT_option_relative_time ('T', | 314 | GNUNET_GETOPT_option_relative_time ('T', |
308 | "timeout", | 315 | "timeout", |
309 | "TIMEOUT", | 316 | "TIMEOUT", |
310 | gettext_noop ("how long should the monitor command run"), | 317 | gettext_noop ("how long should the monitor command run"), |
311 | &timeout_request), | 318 | &timeout_request), |
312 | 319 | ||
313 | GNUNET_GETOPT_option_flag ('V', | 320 | GNUNET_GETOPT_option_flag ('V', |
314 | "verbose", | 321 | "verbose", |
315 | gettext_noop ("be verbose (print progress information)"), | 322 | gettext_noop ("be verbose (print progress information)"), |
316 | &verbose), | 323 | &verbose), |
317 | 324 | ||
318 | GNUNET_GETOPT_OPTION_END | 325 | GNUNET_GETOPT_OPTION_END |
319 | }; | 326 | }; |
320 | 327 | ||
diff --git a/src/dht/gnunet-dht-put.c b/src/dht/gnunet-dht-put.c index db4d04681..fd784871d 100644 --- a/src/dht/gnunet-dht-put.c +++ b/src/dht/gnunet-dht-put.c | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009, 2017 GNUnet e.V. | 3 | Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009, 2017 GNUnet e.V. |
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 it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | /** | 18 | /** |
21 | * @file dht/gnunet-dht-put.c | 19 | * @file dht/gnunet-dht-put.c |
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c index 829c53aea..f9d705873 100644 --- a/src/dht/gnunet-service-dht.c +++ b/src/dht/gnunet-service-dht.c | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2009, 2010, 2011, 2016 GNUnet e.V. | 3 | Copyright (C) 2009, 2010, 2011, 2016 GNUnet e.V. |
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 it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | 18 | ||
21 | /** | 19 | /** |
diff --git a/src/dht/gnunet-service-dht.h b/src/dht/gnunet-service-dht.h index 8b0602104..fa5aa7a55 100644 --- a/src/dht/gnunet-service-dht.h +++ b/src/dht/gnunet-service-dht.h | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2009-2016 GNUnet e.V. | 3 | Copyright (C) 2009-2016 GNUnet e.V. |
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 it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | 18 | ||
21 | /** | 19 | /** |
diff --git a/src/dht/gnunet-service-dht_clients.c b/src/dht/gnunet-service-dht_clients.c index 503d7867b..862654c83 100644 --- a/src/dht/gnunet-service-dht_clients.c +++ b/src/dht/gnunet-service-dht_clients.c | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2009, 2010, 2011, 2016, 2017 GNUnet e.V. | 3 | Copyright (C) 2009, 2010, 2011, 2016, 2017 GNUnet e.V. |
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 it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | 18 | ||
21 | /** | 19 | /** |
diff --git a/src/dht/gnunet-service-dht_datacache.c b/src/dht/gnunet-service-dht_datacache.c index 36047d561..7ad9aa728 100644 --- a/src/dht/gnunet-service-dht_datacache.c +++ b/src/dht/gnunet-service-dht_datacache.c | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2009, 2010, 2011, 2015, 2017 GNUnet e.V. | 3 | Copyright (C) 2009, 2010, 2011, 2015, 2017 GNUnet e.V. |
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 it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | /** | 18 | /** |
21 | * @file dht/gnunet-service-dht_datacache.c | 19 | * @file dht/gnunet-service-dht_datacache.c |
@@ -26,6 +24,7 @@ | |||
26 | #include "platform.h" | 24 | #include "platform.h" |
27 | #include "gnunet_datacache_lib.h" | 25 | #include "gnunet_datacache_lib.h" |
28 | #include "gnunet-service-dht_datacache.h" | 26 | #include "gnunet-service-dht_datacache.h" |
27 | #include "gnunet-service-dht_neighbours.h" | ||
29 | #include "gnunet-service-dht_routing.h" | 28 | #include "gnunet-service-dht_routing.h" |
30 | #include "gnunet-service-dht.h" | 29 | #include "gnunet-service-dht.h" |
31 | 30 | ||
@@ -79,10 +78,13 @@ GDS_DATACACHE_handle_put (struct GNUNET_TIME_Absolute expiration, | |||
79 | } | 78 | } |
80 | /* Put size is actual data size plus struct overhead plus path length (if any) */ | 79 | /* Put size is actual data size plus struct overhead plus path length (if any) */ |
81 | GNUNET_STATISTICS_update (GDS_stats, | 80 | GNUNET_STATISTICS_update (GDS_stats, |
82 | gettext_noop ("# ITEMS stored in datacache"), 1, | 81 | gettext_noop ("# ITEMS stored in datacache"), |
82 | 1, | ||
83 | GNUNET_NO); | 83 | GNUNET_NO); |
84 | r = GNUNET_DATACACHE_put (datacache, | 84 | r = GNUNET_DATACACHE_put (datacache, |
85 | key, | 85 | key, |
86 | GNUNET_CRYPTO_hash_matching_bits (key, | ||
87 | &my_identity_hash), | ||
86 | data_size, | 88 | data_size, |
87 | data, | 89 | data, |
88 | type, | 90 | type, |
@@ -169,6 +171,11 @@ datacache_get_iterator (void *cls, | |||
169 | struct GetRequestContext *ctx = cls; | 171 | struct GetRequestContext *ctx = cls; |
170 | enum GNUNET_BLOCK_EvaluationResult eval; | 172 | enum GNUNET_BLOCK_EvaluationResult eval; |
171 | 173 | ||
174 | if (0 == GNUNET_TIME_absolute_get_remaining (exp).rel_value_us) | ||
175 | { | ||
176 | GNUNET_break (0); /* why does datacache return expired values? */ | ||
177 | return GNUNET_OK; /* skip expired record */ | ||
178 | } | ||
172 | if ( (NULL == data) && | 179 | if ( (NULL == data) && |
173 | (0 == data_size) ) | 180 | (0 == data_size) ) |
174 | data = &non_null; /* point anywhere, but not to NULL */ | 181 | data = &non_null; /* point anywhere, but not to NULL */ |
diff --git a/src/dht/gnunet-service-dht_datacache.h b/src/dht/gnunet-service-dht_datacache.h index ff6ae23da..6f65982a5 100644 --- a/src/dht/gnunet-service-dht_datacache.h +++ b/src/dht/gnunet-service-dht_datacache.h | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2009, 2010, 2011 GNUnet e.V. | 3 | Copyright (C) 2009, 2010, 2011 GNUnet e.V. |
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 it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | 18 | ||
21 | /** | 19 | /** |
diff --git a/src/dht/gnunet-service-dht_hello.c b/src/dht/gnunet-service-dht_hello.c index 5a5c41567..142d44bcc 100644 --- a/src/dht/gnunet-service-dht_hello.c +++ b/src/dht/gnunet-service-dht_hello.c | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2011 GNUnet e.V. | 3 | Copyright (C) 2011 GNUnet e.V. |
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 it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | 18 | ||
21 | /** | 19 | /** |
diff --git a/src/dht/gnunet-service-dht_hello.h b/src/dht/gnunet-service-dht_hello.h index 8d9b940ad..41351da34 100644 --- a/src/dht/gnunet-service-dht_hello.h +++ b/src/dht/gnunet-service-dht_hello.h | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2011 GNUnet e.V. | 3 | Copyright (C) 2011 GNUnet e.V. |
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 it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | 18 | ||
21 | /** | 19 | /** |
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c index 0309bea88..56639448f 100644 --- a/src/dht/gnunet-service-dht_neighbours.c +++ b/src/dht/gnunet-service-dht_neighbours.c | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2009-2017 GNUnet e.V. | 3 | Copyright (C) 2009-2017 GNUnet e.V. |
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 it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | 18 | ||
21 | /** | 19 | /** |
@@ -404,7 +402,7 @@ static struct GNUNET_PeerIdentity my_identity; | |||
404 | /** | 402 | /** |
405 | * Hash of the identity of this peer. | 403 | * Hash of the identity of this peer. |
406 | */ | 404 | */ |
407 | static struct GNUNET_HashCode my_identity_hash; | 405 | struct GNUNET_HashCode my_identity_hash; |
408 | 406 | ||
409 | /** | 407 | /** |
410 | * Handle to CORE. | 408 | * Handle to CORE. |
@@ -421,7 +419,7 @@ static struct GNUNET_ATS_ConnectivityHandle *ats_ch; | |||
421 | * Find the optimal bucket for this key. | 419 | * Find the optimal bucket for this key. |
422 | * | 420 | * |
423 | * @param hc the hashcode to compare our identity to | 421 | * @param hc the hashcode to compare our identity to |
424 | * @return the proper bucket index, or GNUNET_SYSERR | 422 | * @return the proper bucket index, or #GNUNET_SYSERR |
425 | * on error (same hashcode) | 423 | * on error (same hashcode) |
426 | */ | 424 | */ |
427 | static int | 425 | static int |
@@ -470,6 +468,7 @@ free_connect_info (void *cls, | |||
470 | { | 468 | { |
471 | struct ConnectInfo *ci = value; | 469 | struct ConnectInfo *ci = value; |
472 | 470 | ||
471 | (void) cls; | ||
473 | GNUNET_assert (GNUNET_YES == | 472 | GNUNET_assert (GNUNET_YES == |
474 | GNUNET_CONTAINER_multipeermap_remove (all_desired_peers, | 473 | GNUNET_CONTAINER_multipeermap_remove (all_desired_peers, |
475 | peer, | 474 | peer, |
@@ -581,7 +580,10 @@ update_desire_strength (void *cls, | |||
581 | const struct GNUNET_PeerIdentity *pid, | 580 | const struct GNUNET_PeerIdentity *pid, |
582 | void *value) | 581 | void *value) |
583 | { | 582 | { |
584 | try_connect (pid, NULL); | 583 | (void) cls; |
584 | (void) value; | ||
585 | try_connect (pid, | ||
586 | NULL); | ||
585 | return GNUNET_YES; | 587 | return GNUNET_YES; |
586 | } | 588 | } |
587 | 589 | ||
@@ -618,6 +620,8 @@ add_known_to_bloom (void *cls, | |||
618 | struct GNUNET_BLOCK_Group *bg = cls; | 620 | struct GNUNET_BLOCK_Group *bg = cls; |
619 | struct GNUNET_HashCode key_hash; | 621 | struct GNUNET_HashCode key_hash; |
620 | 622 | ||
623 | (void) cls; | ||
624 | (void) value; | ||
621 | GNUNET_CRYPTO_hash (key, | 625 | GNUNET_CRYPTO_hash (key, |
622 | sizeof (struct GNUNET_PeerIdentity), | 626 | sizeof (struct GNUNET_PeerIdentity), |
623 | &key_hash); | 627 | &key_hash); |
@@ -645,7 +649,8 @@ send_find_peer_message (void *cls) | |||
645 | struct GNUNET_BLOCK_Group *bg; | 649 | struct GNUNET_BLOCK_Group *bg; |
646 | struct GNUNET_CONTAINER_BloomFilter *peer_bf; | 650 | struct GNUNET_CONTAINER_BloomFilter *peer_bf; |
647 | 651 | ||
648 | find_peer_task = NULL; | 652 | (void) cls; |
653 | find_peer_task = NULL; | ||
649 | if (newly_found_peers > bucket_size) | 654 | if (newly_found_peers > bucket_size) |
650 | { | 655 | { |
651 | /* If we are finding many peers already, no need to send out our request right now! */ | 656 | /* If we are finding many peers already, no need to send out our request right now! */ |
@@ -718,7 +723,8 @@ handle_core_connect (void *cls, | |||
718 | { | 723 | { |
719 | struct PeerInfo *pi; | 724 | struct PeerInfo *pi; |
720 | 725 | ||
721 | /* Check for connect to self message */ | 726 | (void) cls; |
727 | /* Check for connect to self message */ | ||
722 | if (0 == memcmp (&my_identity, | 728 | if (0 == memcmp (&my_identity, |
723 | peer, | 729 | peer, |
724 | sizeof (struct GNUNET_PeerIdentity))) | 730 | sizeof (struct GNUNET_PeerIdentity))) |
@@ -741,13 +747,13 @@ handle_core_connect (void *cls, | |||
741 | &pi->phash); | 747 | &pi->phash); |
742 | pi->peer_bucket = find_bucket (&pi->phash); | 748 | pi->peer_bucket = find_bucket (&pi->phash); |
743 | GNUNET_assert ( (pi->peer_bucket >= 0) && | 749 | GNUNET_assert ( (pi->peer_bucket >= 0) && |
744 | (pi->peer_bucket < MAX_BUCKETS) ); | 750 | ((unsigned int) pi->peer_bucket < MAX_BUCKETS) ); |
745 | GNUNET_CONTAINER_DLL_insert_tail (k_buckets[pi->peer_bucket].head, | 751 | GNUNET_CONTAINER_DLL_insert_tail (k_buckets[pi->peer_bucket].head, |
746 | k_buckets[pi->peer_bucket].tail, | 752 | k_buckets[pi->peer_bucket].tail, |
747 | pi); | 753 | pi); |
748 | k_buckets[pi->peer_bucket].peers_size++; | 754 | k_buckets[pi->peer_bucket].peers_size++; |
749 | closest_bucket = GNUNET_MAX (closest_bucket, | 755 | closest_bucket = GNUNET_MAX (closest_bucket, |
750 | pi->peer_bucket); | 756 | (unsigned int) pi->peer_bucket); |
751 | GNUNET_assert (GNUNET_OK == | 757 | GNUNET_assert (GNUNET_OK == |
752 | GNUNET_CONTAINER_multipeermap_put (all_connected_peers, | 758 | GNUNET_CONTAINER_multipeermap_put (all_connected_peers, |
753 | pi->id, | 759 | pi->id, |
@@ -785,6 +791,7 @@ handle_core_disconnect (void *cls, | |||
785 | { | 791 | { |
786 | struct PeerInfo *to_remove = internal_cls; | 792 | struct PeerInfo *to_remove = internal_cls; |
787 | 793 | ||
794 | (void) cls; | ||
788 | /* Check for disconnect from self message */ | 795 | /* Check for disconnect from self message */ |
789 | if (NULL == to_remove) | 796 | if (NULL == to_remove) |
790 | return; | 797 | return; |
@@ -941,30 +948,30 @@ get_distance (const struct GNUNET_HashCode *target, | |||
941 | * @return #GNUNET_YES if node location is closest, | 948 | * @return #GNUNET_YES if node location is closest, |
942 | * #GNUNET_NO otherwise. | 949 | * #GNUNET_NO otherwise. |
943 | */ | 950 | */ |
944 | static int | 951 | int |
945 | am_closest_peer (const struct GNUNET_HashCode *key, | 952 | GDS_am_closest_peer (const struct GNUNET_HashCode *key, |
946 | const struct GNUNET_CONTAINER_BloomFilter *bloom) | 953 | const struct GNUNET_CONTAINER_BloomFilter *bloom) |
947 | { | 954 | { |
948 | int bits; | 955 | int bits; |
949 | int other_bits; | 956 | int other_bits; |
950 | int bucket_num; | 957 | int bucket_num; |
951 | int count; | ||
952 | struct PeerInfo *pos; | 958 | struct PeerInfo *pos; |
953 | 959 | ||
954 | if (0 == memcmp (&my_identity_hash, key, sizeof (struct GNUNET_HashCode))) | 960 | if (0 == memcmp (&my_identity_hash, |
961 | key, | ||
962 | sizeof (struct GNUNET_HashCode))) | ||
955 | return GNUNET_YES; | 963 | return GNUNET_YES; |
956 | bucket_num = find_bucket (key); | 964 | bucket_num = find_bucket (key); |
957 | GNUNET_assert (bucket_num >= 0); | 965 | GNUNET_assert (bucket_num >= 0); |
958 | bits = GNUNET_CRYPTO_hash_matching_bits (&my_identity_hash, | 966 | bits = GNUNET_CRYPTO_hash_matching_bits (&my_identity_hash, |
959 | key); | 967 | key); |
960 | pos = k_buckets[bucket_num].head; | 968 | pos = k_buckets[bucket_num].head; |
961 | count = 0; | 969 | while (NULL != pos) |
962 | while ((NULL != pos) && (count < bucket_size)) | ||
963 | { | 970 | { |
964 | if ((NULL != bloom) && | 971 | if ( (NULL != bloom) && |
965 | (GNUNET_YES == | 972 | (GNUNET_YES == |
966 | GNUNET_CONTAINER_bloomfilter_test (bloom, | 973 | GNUNET_CONTAINER_bloomfilter_test (bloom, |
967 | &pos->phash))) | 974 | &pos->phash)) ) |
968 | { | 975 | { |
969 | pos = pos->next; | 976 | pos = pos->next; |
970 | continue; /* Skip already checked entries */ | 977 | continue; /* Skip already checked entries */ |
@@ -1596,6 +1603,7 @@ static void | |||
1596 | core_init (void *cls, | 1603 | core_init (void *cls, |
1597 | const struct GNUNET_PeerIdentity *identity) | 1604 | const struct GNUNET_PeerIdentity *identity) |
1598 | { | 1605 | { |
1606 | (void) cls; | ||
1599 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1607 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1600 | "CORE called, I am %s\n", | 1608 | "CORE called, I am %s\n", |
1601 | GNUNET_i2s (identity)); | 1609 | GNUNET_i2s (identity)); |
@@ -1621,6 +1629,7 @@ check_dht_p2p_put (void *cls, | |||
1621 | uint32_t putlen; | 1629 | uint32_t putlen; |
1622 | uint16_t msize; | 1630 | uint16_t msize; |
1623 | 1631 | ||
1632 | (void) cls; | ||
1624 | msize = ntohs (put->header.size); | 1633 | msize = ntohs (put->header.size); |
1625 | putlen = ntohl (put->put_path_length); | 1634 | putlen = ntohl (put->put_path_length); |
1626 | if ((msize < | 1635 | if ((msize < |
@@ -1656,7 +1665,17 @@ handle_dht_p2p_put (void *cls, | |||
1656 | struct GNUNET_CONTAINER_BloomFilter *bf; | 1665 | struct GNUNET_CONTAINER_BloomFilter *bf; |
1657 | struct GNUNET_HashCode test_key; | 1666 | struct GNUNET_HashCode test_key; |
1658 | int forwarded; | 1667 | int forwarded; |
1668 | struct GNUNET_TIME_Absolute exp_time; | ||
1659 | 1669 | ||
1670 | exp_time = GNUNET_TIME_absolute_ntoh (put->expiration_time); | ||
1671 | if (0 == GNUNET_TIME_absolute_get_remaining (exp_time).rel_value_us) | ||
1672 | { | ||
1673 | GNUNET_STATISTICS_update (GDS_stats, | ||
1674 | gettext_noop ("# Expired PUTs discarded"), | ||
1675 | 1, | ||
1676 | GNUNET_NO); | ||
1677 | return; | ||
1678 | } | ||
1660 | msize = ntohs (put->header.size); | 1679 | msize = ntohs (put->header.size); |
1661 | putlen = ntohl (put->put_path_length); | 1680 | putlen = ntohl (put->put_path_length); |
1662 | GNUNET_STATISTICS_update (GDS_stats, | 1681 | GNUNET_STATISTICS_update (GDS_stats, |
@@ -1792,7 +1811,7 @@ handle_dht_p2p_put (void *cls, | |||
1792 | putlen = 0; | 1811 | putlen = 0; |
1793 | 1812 | ||
1794 | /* give to local clients */ | 1813 | /* give to local clients */ |
1795 | GDS_CLIENTS_handle_reply (GNUNET_TIME_absolute_ntoh (put->expiration_time), | 1814 | GDS_CLIENTS_handle_reply (exp_time, |
1796 | &put->key, | 1815 | &put->key, |
1797 | 0, | 1816 | 0, |
1798 | NULL, | 1817 | NULL, |
@@ -1803,8 +1822,8 @@ handle_dht_p2p_put (void *cls, | |||
1803 | payload); | 1822 | payload); |
1804 | /* store locally */ | 1823 | /* store locally */ |
1805 | if ((0 != (options & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE)) || | 1824 | if ((0 != (options & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE)) || |
1806 | (am_closest_peer (&put->key, bf))) | 1825 | (GDS_am_closest_peer (&put->key, bf))) |
1807 | GDS_DATACACHE_handle_put (GNUNET_TIME_absolute_ntoh (put->expiration_time), | 1826 | GDS_DATACACHE_handle_put (exp_time, |
1808 | &put->key, | 1827 | &put->key, |
1809 | putlen, | 1828 | putlen, |
1810 | pp, | 1829 | pp, |
@@ -1815,7 +1834,7 @@ handle_dht_p2p_put (void *cls, | |||
1815 | forwarded = GDS_NEIGHBOURS_handle_put (ntohl (put->type), | 1834 | forwarded = GDS_NEIGHBOURS_handle_put (ntohl (put->type), |
1816 | options, | 1835 | options, |
1817 | ntohl (put->desired_replication_level), | 1836 | ntohl (put->desired_replication_level), |
1818 | GNUNET_TIME_absolute_ntoh (put->expiration_time), | 1837 | exp_time, |
1819 | ntohl (put->hop_count), | 1838 | ntohl (put->hop_count), |
1820 | bf, | 1839 | bf, |
1821 | &put->key, | 1840 | &put->key, |
@@ -1832,7 +1851,7 @@ handle_dht_p2p_put (void *cls, | |||
1832 | ntohl (put->hop_count), | 1851 | ntohl (put->hop_count), |
1833 | ntohl (put->desired_replication_level), | 1852 | ntohl (put->desired_replication_level), |
1834 | putlen, pp, | 1853 | putlen, pp, |
1835 | GNUNET_TIME_absolute_ntoh (put->expiration_time), | 1854 | exp_time, |
1836 | &put->key, | 1855 | &put->key, |
1837 | payload, | 1856 | payload, |
1838 | payload_size); | 1857 | payload_size); |
@@ -1909,9 +1928,9 @@ handle_find_peer (const struct GNUNET_PeerIdentity *sender, | |||
1909 | sizeof (struct GNUNET_HashCode))) | 1928 | sizeof (struct GNUNET_HashCode))) |
1910 | bucket_idx = closest_bucket; | 1929 | bucket_idx = closest_bucket; |
1911 | else | 1930 | else |
1912 | bucket_idx = GNUNET_MIN (closest_bucket, | 1931 | bucket_idx = GNUNET_MIN ((int) closest_bucket, |
1913 | find_bucket (key)); | 1932 | find_bucket (key)); |
1914 | if (bucket_idx == GNUNET_SYSERR) | 1933 | if (bucket_idx < 0) |
1915 | return; | 1934 | return; |
1916 | bucket = &k_buckets[bucket_idx]; | 1935 | bucket = &k_buckets[bucket_idx]; |
1917 | if (bucket->peers_size == 0) | 1936 | if (bucket->peers_size == 0) |
@@ -2018,6 +2037,7 @@ check_dht_p2p_get (void *cls, | |||
2018 | uint32_t xquery_size; | 2037 | uint32_t xquery_size; |
2019 | uint16_t msize; | 2038 | uint16_t msize; |
2020 | 2039 | ||
2040 | (void) cls; | ||
2021 | msize = ntohs (get->header.size); | 2041 | msize = ntohs (get->header.size); |
2022 | xquery_size = ntohl (get->xquery_size); | 2042 | xquery_size = ntohl (get->xquery_size); |
2023 | if (msize < sizeof (struct PeerGetMessage) + xquery_size) | 2043 | if (msize < sizeof (struct PeerGetMessage) + xquery_size) |
@@ -2122,7 +2142,7 @@ handle_dht_p2p_get (void *cls, | |||
2122 | (unsigned int) ntohl (get->hop_count)); | 2142 | (unsigned int) ntohl (get->hop_count)); |
2123 | /* local lookup (this may update the reply_bf) */ | 2143 | /* local lookup (this may update the reply_bf) */ |
2124 | if ((0 != (options & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE)) || | 2144 | if ((0 != (options & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE)) || |
2125 | (am_closest_peer (&get->key, | 2145 | (GDS_am_closest_peer (&get->key, |
2126 | peer_bf))) | 2146 | peer_bf))) |
2127 | { | 2147 | { |
2128 | if ((0 != (options & GNUNET_DHT_RO_FIND_PEER))) | 2148 | if ((0 != (options & GNUNET_DHT_RO_FIND_PEER))) |
@@ -2205,6 +2225,7 @@ check_dht_p2p_result (void *cls, | |||
2205 | uint32_t put_path_length; | 2225 | uint32_t put_path_length; |
2206 | uint16_t msize; | 2226 | uint16_t msize; |
2207 | 2227 | ||
2228 | (void) cls; | ||
2208 | msize = ntohs (prm->header.size); | 2229 | msize = ntohs (prm->header.size); |
2209 | put_path_length = ntohl (prm->put_path_length); | 2230 | put_path_length = ntohl (prm->put_path_length); |
2210 | get_path_length = ntohl (prm->get_path_length); | 2231 | get_path_length = ntohl (prm->get_path_length); |
@@ -2318,8 +2339,18 @@ handle_dht_p2p_result (void *cls, | |||
2318 | uint16_t msize; | 2339 | uint16_t msize; |
2319 | size_t data_size; | 2340 | size_t data_size; |
2320 | enum GNUNET_BLOCK_Type type; | 2341 | enum GNUNET_BLOCK_Type type; |
2342 | struct GNUNET_TIME_Absolute exp_time; | ||
2321 | 2343 | ||
2322 | /* parse and validate message */ | 2344 | /* parse and validate message */ |
2345 | exp_time = GNUNET_TIME_absolute_ntoh (prm->expiration_time); | ||
2346 | if (0 == GNUNET_TIME_absolute_get_remaining (exp_time).rel_value_us) | ||
2347 | { | ||
2348 | GNUNET_STATISTICS_update (GDS_stats, | ||
2349 | gettext_noop ("# Expired results discarded"), | ||
2350 | 1, | ||
2351 | GNUNET_NO); | ||
2352 | return; | ||
2353 | } | ||
2323 | msize = ntohs (prm->header.size); | 2354 | msize = ntohs (prm->header.size); |
2324 | put_path_length = ntohl (prm->put_path_length); | 2355 | put_path_length = ntohl (prm->put_path_length); |
2325 | get_path_length = ntohl (prm->get_path_length); | 2356 | get_path_length = ntohl (prm->get_path_length); |
@@ -2393,7 +2424,6 @@ handle_dht_p2p_result (void *cls, | |||
2393 | h); | 2424 | h); |
2394 | } | 2425 | } |
2395 | 2426 | ||
2396 | |||
2397 | /* First, check if 'peer' is already on the path, and if | 2427 | /* First, check if 'peer' is already on the path, and if |
2398 | so, truncate it instead of expanding. */ | 2428 | so, truncate it instead of expanding. */ |
2399 | for (unsigned int i=0;i<=get_path_length;i++) | 2429 | for (unsigned int i=0;i<=get_path_length;i++) |
@@ -2401,7 +2431,7 @@ handle_dht_p2p_result (void *cls, | |||
2401 | peer->id, | 2431 | peer->id, |
2402 | sizeof (struct GNUNET_PeerIdentity))) | 2432 | sizeof (struct GNUNET_PeerIdentity))) |
2403 | { | 2433 | { |
2404 | process_reply_with_path (GNUNET_TIME_absolute_ntoh (prm->expiration_time), | 2434 | process_reply_with_path (exp_time, |
2405 | &prm->key, | 2435 | &prm->key, |
2406 | i, | 2436 | i, |
2407 | get_path, | 2437 | get_path, |
@@ -2422,7 +2452,7 @@ handle_dht_p2p_result (void *cls, | |||
2422 | get_path_length * sizeof (struct GNUNET_PeerIdentity)); | 2452 | get_path_length * sizeof (struct GNUNET_PeerIdentity)); |
2423 | xget_path[get_path_length] = *peer->id; | 2453 | xget_path[get_path_length] = *peer->id; |
2424 | 2454 | ||
2425 | process_reply_with_path (GNUNET_TIME_absolute_ntoh (prm->expiration_time), | 2455 | process_reply_with_path (exp_time, |
2426 | &prm->key, | 2456 | &prm->key, |
2427 | get_path_length + 1, | 2457 | get_path_length + 1, |
2428 | xget_path, | 2458 | xget_path, |
diff --git a/src/dht/gnunet-service-dht_neighbours.h b/src/dht/gnunet-service-dht_neighbours.h index 34b76ee8a..fb740c766 100644 --- a/src/dht/gnunet-service-dht_neighbours.h +++ b/src/dht/gnunet-service-dht_neighbours.h | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2009, 2010, 2011 GNUnet e.V. | 3 | Copyright (C) 2009, 2010, 2011 GNUnet e.V. |
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 it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | 18 | ||
21 | /** | 19 | /** |
@@ -32,6 +30,12 @@ | |||
32 | #include "gnunet_dht_service.h" | 30 | #include "gnunet_dht_service.h" |
33 | 31 | ||
34 | /** | 32 | /** |
33 | * Hash of the identity of this peer. | ||
34 | */ | ||
35 | extern struct GNUNET_HashCode my_identity_hash; | ||
36 | |||
37 | |||
38 | /** | ||
35 | * Perform a PUT operation. Forwards the given request to other | 39 | * Perform a PUT operation. Forwards the given request to other |
36 | * peers. Does not store the data locally. Does not give the | 40 | * peers. Does not store the data locally. Does not give the |
37 | * data to local clients. May do nothing if this is the only | 41 | * data to local clients. May do nothing if this is the only |
@@ -123,6 +127,22 @@ GDS_NEIGHBOURS_handle_reply (const struct GNUNET_PeerIdentity *target, | |||
123 | 127 | ||
124 | 128 | ||
125 | /** | 129 | /** |
130 | * Check whether my identity is closer than any known peers. If a | ||
131 | * non-null bloomfilter is given, check if this is the closest peer | ||
132 | * that hasn't already been routed to. | ||
133 | * | ||
134 | * @param key hash code to check closeness to | ||
135 | * @param bloom bloomfilter, exclude these entries from the decision | ||
136 | * @return #GNUNET_YES if node location is closest, | ||
137 | * #GNUNET_NO otherwise. | ||
138 | */ | ||
139 | int | ||
140 | GDS_am_closest_peer (const struct GNUNET_HashCode *key, | ||
141 | const struct GNUNET_CONTAINER_BloomFilter *bloom); | ||
142 | |||
143 | |||
144 | |||
145 | /** | ||
126 | * Initialize neighbours subsystem. | 146 | * Initialize neighbours subsystem. |
127 | * | 147 | * |
128 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 148 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
diff --git a/src/dht/gnunet-service-dht_nse.c b/src/dht/gnunet-service-dht_nse.c index da4aae60c..446ae2dbd 100644 --- a/src/dht/gnunet-service-dht_nse.c +++ b/src/dht/gnunet-service-dht_nse.c | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2009, 2010, 2011 GNUnet e.V. | 3 | Copyright (C) 2009, 2010, 2011 GNUnet e.V. |
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 it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | 18 | ||
21 | /** | 19 | /** |
diff --git a/src/dht/gnunet-service-dht_nse.h b/src/dht/gnunet-service-dht_nse.h index 075a872b3..a5e259cba 100644 --- a/src/dht/gnunet-service-dht_nse.h +++ b/src/dht/gnunet-service-dht_nse.h | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2011 GNUnet e.V. | 3 | Copyright (C) 2011 GNUnet e.V. |
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 it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | 18 | ||
21 | /** | 19 | /** |
diff --git a/src/dht/gnunet-service-dht_routing.c b/src/dht/gnunet-service-dht_routing.c index 098b6e895..0098ce096 100644 --- a/src/dht/gnunet-service-dht_routing.c +++ b/src/dht/gnunet-service-dht_routing.c | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2011 GNUnet e.V. | 3 | Copyright (C) 2011 GNUnet e.V. |
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 it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | 18 | ||
21 | /** | 19 | /** |
diff --git a/src/dht/gnunet-service-dht_routing.h b/src/dht/gnunet-service-dht_routing.h index ad7958363..d9c0345b6 100644 --- a/src/dht/gnunet-service-dht_routing.h +++ b/src/dht/gnunet-service-dht_routing.h | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2011 GNUnet e.V. | 3 | Copyright (C) 2011 GNUnet e.V. |
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 it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | 18 | ||
21 | /** | 19 | /** |
diff --git a/src/dht/gnunet_dht_profiler.c b/src/dht/gnunet_dht_profiler.c index a8807bea8..a729d1b01 100644 --- a/src/dht/gnunet_dht_profiler.c +++ b/src/dht/gnunet_dht_profiler.c | |||
@@ -1,21 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2014 GNUnet e.V. | 3 | Copyright (C) 2014, 2018 GNUnet e.V. |
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 it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | 18 | ||
21 | /** | 19 | /** |
@@ -28,9 +26,11 @@ | |||
28 | #include "gnunet_util_lib.h" | 26 | #include "gnunet_util_lib.h" |
29 | #include "gnunet_testbed_service.h" | 27 | #include "gnunet_testbed_service.h" |
30 | #include "gnunet_dht_service.h" | 28 | #include "gnunet_dht_service.h" |
29 | #include "gnunet_constants.h" | ||
30 | |||
31 | 31 | ||
32 | #define INFO(...) \ | 32 | #define MESSAGE(...) \ |
33 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, __VA_ARGS__) | 33 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, __VA_ARGS__) |
34 | 34 | ||
35 | #define DEBUG(...) \ | 35 | #define DEBUG(...) \ |
36 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) | 36 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) |
@@ -38,12 +38,12 @@ | |||
38 | /** | 38 | /** |
39 | * Number of peers which should perform a PUT out of 100 peers | 39 | * Number of peers which should perform a PUT out of 100 peers |
40 | */ | 40 | */ |
41 | #define PUT_PROBABILITY 50 | 41 | static unsigned int put_probability = 100; |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * Configuration | 44 | * Configuration |
45 | */ | 45 | */ |
46 | static struct GNUNET_CONFIGURATION_Handle *cfg; | 46 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
47 | 47 | ||
48 | /** | 48 | /** |
49 | * Name of the file with the hosts to run the test over | 49 | * Name of the file with the hosts to run the test over |
@@ -94,11 +94,6 @@ struct ActiveContext | |||
94 | struct GNUNET_DHT_Handle *dht; | 94 | struct GNUNET_DHT_Handle *dht; |
95 | 95 | ||
96 | /** | 96 | /** |
97 | * The data used for do a PUT. Will be NULL if a PUT hasn't been performed yet | ||
98 | */ | ||
99 | void *put_data; | ||
100 | |||
101 | /** | ||
102 | * The active context used for our DHT GET | 97 | * The active context used for our DHT GET |
103 | */ | 98 | */ |
104 | struct ActiveContext *get_ac; | 99 | struct ActiveContext *get_ac; |
@@ -114,19 +109,20 @@ struct ActiveContext | |||
114 | struct GNUNET_DHT_GetHandle *dht_get; | 109 | struct GNUNET_DHT_GetHandle *dht_get; |
115 | 110 | ||
116 | /** | 111 | /** |
117 | * The hash of the @e put_data | 112 | * The hashes of the values stored via this activity context. |
113 | * Array of length #num_puts_per_peer. | ||
118 | */ | 114 | */ |
119 | struct GNUNET_HashCode hash; | 115 | struct GNUNET_HashCode *hash; |
120 | 116 | ||
121 | /** | 117 | /** |
122 | * Delay task | 118 | * Delay task |
123 | */ | 119 | */ |
124 | struct GNUNET_SCHEDULER_Task * delay_task; | 120 | struct GNUNET_SCHEDULER_Task *delay_task; |
125 | 121 | ||
126 | /** | 122 | /** |
127 | * The size of the @e put_data | 123 | * How many puts should we still issue? |
128 | */ | 124 | */ |
129 | uint16_t put_data_size; | 125 | unsigned int put_count; |
130 | 126 | ||
131 | /** | 127 | /** |
132 | * The number of peers currently doing GET on our data | 128 | * The number of peers currently doing GET on our data |
@@ -183,17 +179,17 @@ static unsigned int n_dht; | |||
183 | /** | 179 | /** |
184 | * Number of DHT PUTs made | 180 | * Number of DHT PUTs made |
185 | */ | 181 | */ |
186 | static unsigned int n_puts; | 182 | static unsigned long long n_puts; |
187 | 183 | ||
188 | /** | 184 | /** |
189 | * Number of DHT PUTs succeeded | 185 | * Number of DHT PUTs to be made per peer. |
190 | */ | 186 | */ |
191 | static unsigned int n_puts_ok; | 187 | static unsigned int num_puts_per_peer = 1; |
192 | 188 | ||
193 | /** | 189 | /** |
194 | * Number of DHT PUTs failed | 190 | * Number of DHT PUTs succeeded |
195 | */ | 191 | */ |
196 | static unsigned int n_puts_fail; | 192 | static unsigned long long n_puts_ok; |
197 | 193 | ||
198 | /** | 194 | /** |
199 | * Number of DHT GETs made | 195 | * Number of DHT GETs made |
@@ -216,21 +212,11 @@ static unsigned int n_gets_fail; | |||
216 | static unsigned int replication; | 212 | static unsigned int replication; |
217 | 213 | ||
218 | /** | 214 | /** |
219 | * Number of times we try to find the successor circle formation | ||
220 | */ | ||
221 | static unsigned int max_searches; | ||
222 | |||
223 | /** | ||
224 | * Testbed Operation (to get stats). | 215 | * Testbed Operation (to get stats). |
225 | */ | 216 | */ |
226 | static struct GNUNET_TESTBED_Operation *bandwidth_stats_op; | 217 | static struct GNUNET_TESTBED_Operation *bandwidth_stats_op; |
227 | 218 | ||
228 | /** | 219 | /** |
229 | * To get successor stats. | ||
230 | */ | ||
231 | static struct GNUNET_TESTBED_Operation *successor_stats_op; | ||
232 | |||
233 | /** | ||
234 | * Testbed peer handles. | 220 | * Testbed peer handles. |
235 | */ | 221 | */ |
236 | static struct GNUNET_TESTBED_Peer **testbed_handles; | 222 | static struct GNUNET_TESTBED_Peer **testbed_handles; |
@@ -266,47 +252,6 @@ static unsigned int total_put_path_length; | |||
266 | static unsigned int total_get_path_length; | 252 | static unsigned int total_get_path_length; |
267 | 253 | ||
268 | /** | 254 | /** |
269 | * Hashmap to store pair of peer and its corresponding successor. | ||
270 | */ | ||
271 | static struct GNUNET_CONTAINER_MultiHashMap *successor_peer_hashmap; | ||
272 | |||
273 | /** | ||
274 | * Key to start the lookup on successor_peer_hashmap. | ||
275 | */ | ||
276 | static struct GNUNET_HashCode *start_key; | ||
277 | |||
278 | /** | ||
279 | * Flag used to get the start_key. | ||
280 | */ | ||
281 | static int flag = 0; | ||
282 | |||
283 | /** | ||
284 | * Task to collect peer and its current successor statistics. | ||
285 | */ | ||
286 | static struct GNUNET_SCHEDULER_Task * successor_stats_task; | ||
287 | |||
288 | /** | ||
289 | * Closure for successor_stats_task. | ||
290 | */ | ||
291 | struct Collect_Stat_Context | ||
292 | { | ||
293 | /** | ||
294 | * Current Peer Context. | ||
295 | */ | ||
296 | struct Context *service_connect_ctx; | ||
297 | |||
298 | /** | ||
299 | * Testbed operation acting on this peer | ||
300 | */ | ||
301 | struct GNUNET_TESTBED_Operation *op; | ||
302 | }; | ||
303 | |||
304 | /** | ||
305 | * List of all the peers contexts. | ||
306 | */ | ||
307 | struct Context **peer_contexts = NULL; | ||
308 | |||
309 | /** | ||
310 | * Counter to keep track of peers added to peer_context lists. | 255 | * Counter to keep track of peers added to peer_context lists. |
311 | */ | 256 | */ |
312 | static int peers_started = 0; | 257 | static int peers_started = 0; |
@@ -327,20 +272,6 @@ static enum | |||
327 | */ | 272 | */ |
328 | static int in_shutdown = 0; | 273 | static int in_shutdown = 0; |
329 | 274 | ||
330 | /** | ||
331 | * Total number of times to check if circle is formed or not. | ||
332 | */ | ||
333 | static unsigned int tries; | ||
334 | |||
335 | |||
336 | /** | ||
337 | * Task that collects successor statistics from all the peers. | ||
338 | * | ||
339 | * @param cls | ||
340 | */ | ||
341 | static void | ||
342 | collect_stats (void *cls); | ||
343 | |||
344 | 275 | ||
345 | /** | 276 | /** |
346 | * Connect to DHT services of active peers | 277 | * Connect to DHT services of active peers |
@@ -358,12 +289,11 @@ static void | |||
358 | do_shutdown (void *cls) | 289 | do_shutdown (void *cls) |
359 | { | 290 | { |
360 | struct ActiveContext *ac; | 291 | struct ActiveContext *ac; |
361 | unsigned int cnt; | ||
362 | 292 | ||
363 | in_shutdown = GNUNET_YES; | 293 | in_shutdown = GNUNET_YES; |
364 | if (NULL != a_ctx) | 294 | if (NULL != a_ctx) |
365 | { | 295 | { |
366 | for (cnt=0; cnt < num_peers; cnt++) | 296 | for (unsigned int cnt=0; cnt < num_peers; cnt++) |
367 | { | 297 | { |
368 | /* Cleanup active context if this peer is an active peer */ | 298 | /* Cleanup active context if this peer is an active peer */ |
369 | ac = a_ctx[cnt].ac; | 299 | ac = a_ctx[cnt].ac; |
@@ -371,8 +301,8 @@ do_shutdown (void *cls) | |||
371 | { | 301 | { |
372 | if (NULL != ac->delay_task) | 302 | if (NULL != ac->delay_task) |
373 | GNUNET_SCHEDULER_cancel (ac->delay_task); | 303 | GNUNET_SCHEDULER_cancel (ac->delay_task); |
374 | if (NULL != ac->put_data) | 304 | if (NULL != ac->hash) |
375 | GNUNET_free (ac->put_data); | 305 | free (ac->hash); |
376 | if (NULL != ac->dht_put) | 306 | if (NULL != ac->dht_put) |
377 | GNUNET_DHT_put_cancel (ac->dht_put); | 307 | GNUNET_DHT_put_cancel (ac->dht_put); |
378 | if (NULL != ac->dht_get) | 308 | if (NULL != ac->dht_get) |
@@ -392,16 +322,6 @@ do_shutdown (void *cls) | |||
392 | GNUNET_TESTBED_operation_done (bandwidth_stats_op); | 322 | GNUNET_TESTBED_operation_done (bandwidth_stats_op); |
393 | bandwidth_stats_op = NULL; | 323 | bandwidth_stats_op = NULL; |
394 | } | 324 | } |
395 | if (NULL != successor_stats_op) | ||
396 | { | ||
397 | GNUNET_TESTBED_operation_done (successor_stats_op); | ||
398 | successor_stats_op = NULL; | ||
399 | } | ||
400 | if (NULL != successor_stats_task) | ||
401 | { | ||
402 | GNUNET_SCHEDULER_cancel (successor_stats_task); | ||
403 | successor_stats_task = NULL; | ||
404 | } | ||
405 | GNUNET_free_non_null (a_ac); | 325 | GNUNET_free_non_null (a_ac); |
406 | } | 326 | } |
407 | 327 | ||
@@ -420,10 +340,13 @@ bandwidth_stats_cont (void *cls, | |||
420 | struct GNUNET_TESTBED_Operation *op, | 340 | struct GNUNET_TESTBED_Operation *op, |
421 | const char *emsg) | 341 | const char *emsg) |
422 | { | 342 | { |
423 | INFO ("# Outgoing bandwidth: %llu\n", | 343 | MESSAGE ("# Outgoing (core) bandwidth: %llu bytes\n", |
424 | (unsigned long long) outgoing_bandwidth); | 344 | (unsigned long long) outgoing_bandwidth); |
425 | INFO ("# Incoming bandwidth: %llu\n", | 345 | MESSAGE ("# Incoming (core) bandwidth: %llu bytes\n", |
426 | (unsigned long long) incoming_bandwidth); | 346 | (unsigned long long) incoming_bandwidth); |
347 | fprintf (stderr, | ||
348 | "Benchmark done. Collect data via gnunet-statistics, then press ENTER to exit.\n"); | ||
349 | (void) getchar (); | ||
427 | GNUNET_SCHEDULER_shutdown (); | 350 | GNUNET_SCHEDULER_shutdown (); |
428 | } | 351 | } |
429 | 352 | ||
@@ -447,40 +370,48 @@ bandwidth_stats_iterator (void *cls, | |||
447 | uint64_t value, | 370 | uint64_t value, |
448 | int is_persistent) | 371 | int is_persistent) |
449 | { | 372 | { |
450 | static const char *s_sent = "# Bytes transmitted to other peers"; | 373 | static const char *s_sent = "# bytes encrypted"; |
451 | static const char *s_recv = "# Bytes received from other peers"; | 374 | static const char *s_recv = "# bytes decrypted"; |
452 | 375 | ||
453 | if (0 == strncmp (s_sent, name, strlen (s_sent))) | 376 | if (0 == strncmp (s_sent, name, strlen (s_sent))) |
454 | outgoing_bandwidth = outgoing_bandwidth + value; | 377 | outgoing_bandwidth = outgoing_bandwidth + value; |
455 | else if (0 == strncmp(s_recv, name, strlen (s_recv))) | 378 | else if (0 == strncmp(s_recv, name, strlen (s_recv))) |
456 | incoming_bandwidth = incoming_bandwidth + value; | 379 | incoming_bandwidth = incoming_bandwidth + value; |
457 | 380 | return GNUNET_OK; | |
458 | return GNUNET_OK; | ||
459 | } | 381 | } |
460 | 382 | ||
461 | 383 | ||
462 | static void | 384 | static void |
463 | summarize () | 385 | summarize () |
464 | { | 386 | { |
465 | INFO ("# PUTS made: %u\n", n_puts); | 387 | MESSAGE ("# PUTS started: %llu\n", |
466 | INFO ("# PUTS succeeded: %u\n", n_puts_ok); | 388 | n_puts); |
467 | INFO ("# PUTS failed: %u\n", n_puts_fail); | 389 | MESSAGE ("# PUTS succeeded: %llu\n", |
468 | INFO ("# GETS made: %u\n", n_gets); | 390 | n_puts_ok); |
469 | INFO ("# GETS succeeded: %u\n", n_gets_ok); | 391 | MESSAGE ("# GETS made: %u\n", |
470 | INFO ("# GETS failed: %u\n", n_gets_fail); | 392 | n_gets); |
471 | INFO ("# average_put_path_length: %f\n", average_put_path_length); | 393 | MESSAGE ("# GETS succeeded: %u\n", |
472 | INFO ("# average_get_path_length: %f\n", average_get_path_length); | 394 | n_gets_ok); |
395 | MESSAGE ("# GETS failed: %u\n", | ||
396 | n_gets_fail); | ||
397 | MESSAGE ("# average_put_path_length: %f\n", | ||
398 | average_put_path_length); | ||
399 | MESSAGE ("# average_get_path_length: %f\n", | ||
400 | average_get_path_length); | ||
473 | 401 | ||
474 | if (NULL == testbed_handles) | 402 | if (NULL == testbed_handles) |
475 | { | 403 | { |
476 | INFO ("No peers found\n"); | 404 | MESSAGE ("No peers found\n"); |
477 | return; | 405 | return; |
478 | } | 406 | } |
479 | /* Collect Stats*/ | 407 | /* Collect Stats*/ |
480 | bandwidth_stats_op = GNUNET_TESTBED_get_statistics (n_active, testbed_handles, | 408 | bandwidth_stats_op = GNUNET_TESTBED_get_statistics (n_active, |
481 | "dht", NULL, | 409 | testbed_handles, |
482 | bandwidth_stats_iterator, | 410 | "core", |
483 | bandwidth_stats_cont, NULL); | 411 | NULL, |
412 | &bandwidth_stats_iterator, | ||
413 | &bandwidth_stats_cont, | ||
414 | NULL); | ||
484 | } | 415 | } |
485 | 416 | ||
486 | 417 | ||
@@ -546,10 +477,9 @@ get_iter (void *cls, | |||
546 | struct ActiveContext *get_ac = ac->get_ac; | 477 | struct ActiveContext *get_ac = ac->get_ac; |
547 | struct Context *ctx = ac->ctx; | 478 | struct Context *ctx = ac->ctx; |
548 | 479 | ||
549 | /* Check the keys of put and get match or not. */ | ||
550 | GNUNET_assert (0 == memcmp (key, &get_ac->hash, sizeof (struct GNUNET_HashCode))); | ||
551 | /* we found the data we are looking for */ | 480 | /* we found the data we are looking for */ |
552 | DEBUG ("We found a GET request; %u remaining\n", n_gets - (n_gets_fail + n_gets_ok)); //FIXME: It always prints 1. | 481 | DEBUG ("We found a GET request; %u remaining\n", |
482 | n_gets - (n_gets_fail + n_gets_ok)); //FIXME: It always prints 1. | ||
553 | n_gets_ok++; | 483 | n_gets_ok++; |
554 | get_ac->nrefs--; | 484 | get_ac->nrefs--; |
555 | GNUNET_DHT_get_stop (ac->dht_get); | 485 | GNUNET_DHT_get_stop (ac->dht_get); |
@@ -591,79 +521,69 @@ delayed_get (void *cls) | |||
591 | get_ac = NULL; | 521 | get_ac = NULL; |
592 | while (1) | 522 | while (1) |
593 | { | 523 | { |
594 | r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, n_active); | 524 | r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
525 | n_active); | ||
595 | get_ac = &a_ac[r]; | 526 | get_ac = &a_ac[r]; |
596 | if (NULL != get_ac->put_data) | 527 | if (NULL != get_ac->hash) |
597 | break; | 528 | break; |
598 | } | 529 | } |
599 | get_ac->nrefs++; | 530 | get_ac->nrefs++; |
600 | ac->get_ac = get_ac; | 531 | ac->get_ac = get_ac; |
601 | DEBUG ("GET_REQUEST_START key %s \n", GNUNET_h2s((struct GNUNET_HashCode *)ac->put_data)); | 532 | r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
533 | num_puts_per_peer); | ||
534 | DEBUG ("GET_REQUEST_START key %s \n", | ||
535 | GNUNET_h2s(&get_ac->hash[r])); | ||
602 | ac->dht_get = GNUNET_DHT_get_start (ac->dht, | 536 | ac->dht_get = GNUNET_DHT_get_start (ac->dht, |
603 | GNUNET_BLOCK_TYPE_TEST, | 537 | GNUNET_BLOCK_TYPE_TEST, |
604 | &get_ac->hash, | 538 | &get_ac->hash[r], |
605 | 1, /* replication level */ | 539 | 1, /* replication level */ |
606 | GNUNET_DHT_RO_NONE, | 540 | GNUNET_DHT_RO_NONE, |
607 | NULL, 0, /* extended query and size */ | 541 | NULL, |
608 | get_iter, ac); /* GET iterator and closure | 542 | 0, /* extended query and size */ |
609 | */ | 543 | &get_iter, |
544 | ac); /* GET iterator and closure */ | ||
610 | n_gets++; | 545 | n_gets++; |
611 | 546 | ||
612 | /* schedule the timeout task for GET */ | 547 | /* schedule the timeout task for GET */ |
613 | ac->delay_task = GNUNET_SCHEDULER_add_delayed (timeout, &cancel_get, ac); | 548 | ac->delay_task = GNUNET_SCHEDULER_add_delayed (timeout, |
549 | &cancel_get, | ||
550 | ac); | ||
614 | } | 551 | } |
615 | 552 | ||
616 | 553 | ||
617 | /** | 554 | /** |
618 | * Task to teardown the dht connection. We do it as a task because calling | 555 | * Task to do DHT PUTs. If the "put_count" hits zero, |
619 | * GNUNET_DHT_disconnect() from put_continutation_callback seems illegal (the | 556 | * we stop the TESTBED operation (connection to DHT) |
620 | * put_continuation_callback() is getting called again synchronously). Also, | 557 | * so that others PUTs have a chance. |
621 | * only free the operation when we are not shutting down; the shutdown task will | ||
622 | * clear the operation during shutdown. | ||
623 | * | 558 | * |
624 | * @param cls the context | 559 | * @param cls the active context |
625 | */ | 560 | */ |
626 | static void | 561 | static void |
627 | teardown_dht_connection (void *cls) | 562 | delayed_put (void *cls); |
628 | { | ||
629 | struct Context *ctx = cls; | ||
630 | struct GNUNET_TESTBED_Operation *op; | ||
631 | |||
632 | GNUNET_assert (NULL != ctx); | ||
633 | GNUNET_assert (NULL != (op = ctx->op)); | ||
634 | ctx->op = NULL; | ||
635 | GNUNET_TESTBED_operation_done (op); | ||
636 | } | ||
637 | 563 | ||
638 | 564 | ||
639 | /** | 565 | /** |
640 | * Queue up a delayed task for doing DHT GET | 566 | * Conclude individual PUT operation, schedule the |
567 | * next one. | ||
641 | * | 568 | * |
642 | * @param cls the active context | 569 | * @param cls the active context |
643 | * @param success #GNUNET_OK if the PUT was transmitted, | ||
644 | * #GNUNET_NO on timeout, | ||
645 | * #GNUNET_SYSERR on disconnect from service | ||
646 | * after the PUT message was transmitted | ||
647 | * (so we don't know if it was received or not) | ||
648 | */ | 570 | */ |
649 | static void | 571 | static void |
650 | put_cont (void *cls, int success) | 572 | put_cont (void *cls) |
651 | { | 573 | { |
652 | struct ActiveContext *ac = cls; | 574 | struct ActiveContext *ac = cls; |
653 | struct Context *ctx = ac->ctx; | ||
654 | 575 | ||
655 | ac->dht_put = NULL; | 576 | ac->dht_put = NULL; |
656 | if (success) | 577 | n_puts_ok++; |
657 | n_puts_ok++; | 578 | ac->delay_task = GNUNET_SCHEDULER_add_now (&delayed_put, |
658 | else | 579 | ac); |
659 | n_puts_fail++; | ||
660 | GNUNET_assert (NULL != ctx); | ||
661 | (void) GNUNET_SCHEDULER_add_now (&teardown_dht_connection, ctx); | ||
662 | } | 580 | } |
663 | 581 | ||
664 | 582 | ||
665 | /** | 583 | /** |
666 | * Task to do DHT PUTs | 584 | * Task to do DHT PUTs. If the "put_count" hits zero, |
585 | * we stop the TESTBED operation (connection to DHT) | ||
586 | * so that others PUTs have a chance. | ||
667 | * | 587 | * |
668 | * @param cls the active context | 588 | * @param cls the active context |
669 | */ | 589 | */ |
@@ -671,27 +591,47 @@ static void | |||
671 | delayed_put (void *cls) | 591 | delayed_put (void *cls) |
672 | { | 592 | { |
673 | struct ActiveContext *ac = cls; | 593 | struct ActiveContext *ac = cls; |
594 | char block[65536]; | ||
595 | size_t block_size; | ||
674 | 596 | ||
675 | ac->delay_task = NULL; | 597 | ac->delay_task = NULL; |
598 | if (0 == ac->put_count) | ||
599 | { | ||
600 | struct Context *ctx = ac->ctx; | ||
601 | struct GNUNET_TESTBED_Operation *op; | ||
602 | |||
603 | GNUNET_assert (NULL != ctx); | ||
604 | op = ctx->op; | ||
605 | ctx->op = NULL; | ||
606 | GNUNET_TESTBED_operation_done (op); | ||
607 | return; | ||
608 | } | ||
609 | |||
610 | |||
676 | /* Generate and DHT PUT some random data */ | 611 | /* Generate and DHT PUT some random data */ |
677 | ac->put_data_size = 16; /* minimum */ | 612 | block_size = 16; /* minimum */ |
678 | ac->put_data_size += GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 613 | /* make random payload, reserve 512 - 16 bytes for DHT headers */ |
679 | (63*1024)); | 614 | block_size += GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
680 | ac->put_data = GNUNET_malloc (ac->put_data_size); | 615 | GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE - 512); |
681 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, | 616 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, |
682 | ac->put_data, ac->put_data_size); | 617 | block, |
683 | GNUNET_CRYPTO_hash (ac->put_data, ac->put_data_size, &ac->hash); | 618 | block_size); |
619 | ac->put_count--; | ||
620 | GNUNET_CRYPTO_hash (block, | ||
621 | block_size, | ||
622 | &ac->hash[ac->put_count]); | ||
684 | DEBUG ("PUT_REQUEST_START key %s\n", | 623 | DEBUG ("PUT_REQUEST_START key %s\n", |
685 | GNUNET_h2s((struct GNUNET_HashCode *)ac->put_data)); | 624 | GNUNET_h2s (&ac->hash[ac->put_count])); |
686 | ac->dht_put = GNUNET_DHT_put (ac->dht, | 625 | ac->dht_put = GNUNET_DHT_put (ac->dht, |
687 | &ac->hash, | 626 | &ac->hash[ac->put_count], |
688 | replication, | 627 | replication, |
689 | GNUNET_DHT_RO_RECORD_ROUTE, | 628 | GNUNET_DHT_RO_RECORD_ROUTE, |
690 | GNUNET_BLOCK_TYPE_TEST, | 629 | GNUNET_BLOCK_TYPE_TEST, |
691 | ac->put_data_size, | 630 | block_size, |
692 | ac->put_data, | 631 | block, |
693 | GNUNET_TIME_UNIT_FOREVER_ABS, /* expiration time */ | 632 | GNUNET_TIME_UNIT_FOREVER_ABS, /* expiration time */ |
694 | &put_cont, ac); /* continuation and its closure */ | 633 | &put_cont, |
634 | ac); /* continuation and its closure */ | ||
695 | n_puts++; | 635 | n_puts++; |
696 | } | 636 | } |
697 | 637 | ||
@@ -720,7 +660,9 @@ dht_connected (void *cls, | |||
720 | ac->dht = (struct GNUNET_DHT_Handle *) ca_result; | 660 | ac->dht = (struct GNUNET_DHT_Handle *) ca_result; |
721 | if (NULL != emsg) | 661 | if (NULL != emsg) |
722 | { | 662 | { |
723 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Connection to DHT service failed: %s\n", emsg); | 663 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
664 | "Connection to DHT service failed: %s\n", | ||
665 | emsg); | ||
724 | GNUNET_TESTBED_operation_done (ctx->op); /* Calls dht_disconnect() */ | 666 | GNUNET_TESTBED_operation_done (ctx->op); /* Calls dht_disconnect() */ |
725 | ctx->op = NULL; | 667 | ctx->op = NULL; |
726 | return; | 668 | return; |
@@ -728,24 +670,40 @@ dht_connected (void *cls, | |||
728 | switch (mode) | 670 | switch (mode) |
729 | { | 671 | { |
730 | case MODE_PUT: | 672 | case MODE_PUT: |
731 | { | 673 | { |
732 | struct GNUNET_TIME_Relative peer_delay_put; | 674 | struct GNUNET_TIME_Relative peer_delay_put; |
733 | peer_delay_put.rel_value_us = | 675 | |
734 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, | 676 | peer_delay_put.rel_value_us = |
735 | delay_put.rel_value_us); | 677 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, |
736 | ac->delay_task = GNUNET_SCHEDULER_add_delayed (peer_delay_put, &delayed_put, ac); | 678 | delay_put.rel_value_us); |
737 | break; | 679 | ac->put_count = num_puts_per_peer; |
738 | } | 680 | ac->hash = calloc (ac->put_count, |
681 | sizeof (struct GNUNET_HashCode)); | ||
682 | if (NULL == ac->hash) | ||
683 | { | ||
684 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, | ||
685 | "calloc"); | ||
686 | GNUNET_SCHEDULER_shutdown (); | ||
687 | return; | ||
688 | } | ||
689 | ac->delay_task = GNUNET_SCHEDULER_add_delayed (peer_delay_put, | ||
690 | &delayed_put, | ||
691 | ac); | ||
692 | break; | ||
693 | } | ||
739 | case MODE_GET: | 694 | case MODE_GET: |
740 | { | 695 | { |
741 | struct GNUNET_TIME_Relative peer_delay_get; | 696 | struct GNUNET_TIME_Relative peer_delay_get; |
742 | peer_delay_get.rel_value_us = | 697 | |
743 | delay_get.rel_value_us + | 698 | peer_delay_get.rel_value_us = |
744 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, | 699 | delay_get.rel_value_us + |
745 | delay_get.rel_value_us); | 700 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, |
746 | ac->delay_task = GNUNET_SCHEDULER_add_delayed (peer_delay_get, &delayed_get, ac); | 701 | delay_get.rel_value_us); |
747 | break; | 702 | ac->delay_task = GNUNET_SCHEDULER_add_delayed (peer_delay_get, |
748 | } | 703 | &delayed_get, |
704 | ac); | ||
705 | break; | ||
706 | } | ||
749 | } | 707 | } |
750 | } | 708 | } |
751 | 709 | ||
@@ -760,10 +718,12 @@ dht_connected (void *cls, | |||
760 | * @return service handle to return in 'op_result', NULL on error | 718 | * @return service handle to return in 'op_result', NULL on error |
761 | */ | 719 | */ |
762 | static void * | 720 | static void * |
763 | dht_connect (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) | 721 | dht_connect (void *cls, |
722 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
764 | { | 723 | { |
765 | n_dht++; | 724 | n_dht++; |
766 | return GNUNET_DHT_connect (cfg, 10); | 725 | return GNUNET_DHT_connect (cfg, |
726 | 10); | ||
767 | } | 727 | } |
768 | 728 | ||
769 | 729 | ||
@@ -775,7 +735,8 @@ dht_connect (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
775 | * @param op_result service handle returned from the connect adapter | 735 | * @param op_result service handle returned from the connect adapter |
776 | */ | 736 | */ |
777 | static void | 737 | static void |
778 | dht_disconnect (void *cls, void *op_result) | 738 | dht_disconnect (void *cls, |
739 | void *op_result) | ||
779 | { | 740 | { |
780 | struct ActiveContext *ac = cls; | 741 | struct ActiveContext *ac = cls; |
781 | 742 | ||
@@ -791,11 +752,10 @@ dht_disconnect (void *cls, void *op_result) | |||
791 | switch (mode) | 752 | switch (mode) |
792 | { | 753 | { |
793 | case MODE_PUT: | 754 | case MODE_PUT: |
794 | if ((n_puts_ok + n_puts_fail) != n_active) | 755 | if (n_puts_ok != ((unsigned long long) n_active) * num_puts_per_peer) |
795 | return; | 756 | return; |
796 | /* Start GETs if all PUTs have been made */ | 757 | /* Start GETs if all PUTs have been made */ |
797 | mode = MODE_GET; | 758 | mode = MODE_GET; |
798 | //(void) GNUNET_SCHEDULER_add_now (&call_start_profiling, NULL); | ||
799 | start_profiling (); | 759 | start_profiling (); |
800 | return; | 760 | return; |
801 | case MODE_GET: | 761 | case MODE_GET: |
@@ -805,6 +765,7 @@ dht_disconnect (void *cls, void *op_result) | |||
805 | } | 765 | } |
806 | } | 766 | } |
807 | 767 | ||
768 | |||
808 | /** | 769 | /** |
809 | * Connect to DHT services of active peers | 770 | * Connect to DHT services of active peers |
810 | */ | 771 | */ |
@@ -812,229 +773,22 @@ static void | |||
812 | start_profiling() | 773 | start_profiling() |
813 | { | 774 | { |
814 | struct Context *ctx; | 775 | struct Context *ctx; |
815 | unsigned int i; | ||
816 | 776 | ||
817 | DEBUG("GNUNET_TESTBED_service_connect \n"); | 777 | DEBUG ("GNUNET_TESTBED_service_connect\n"); |
818 | GNUNET_break (GNUNET_YES != in_shutdown); | 778 | GNUNET_break (GNUNET_YES != in_shutdown); |
819 | for(i = 0; i < n_active; i++) | 779 | for (unsigned int i = 0; i < n_active; i++) |
820 | { | 780 | { |
821 | struct ActiveContext *ac = &a_ac[i]; | 781 | struct ActiveContext *ac = &a_ac[i]; |
822 | GNUNET_assert (NULL != (ctx = ac->ctx)); | 782 | GNUNET_assert (NULL != (ctx = ac->ctx)); |
823 | GNUNET_assert (NULL == ctx->op); | 783 | GNUNET_assert (NULL == ctx->op); |
824 | ctx->op = | 784 | ctx->op = GNUNET_TESTBED_service_connect (ctx, |
825 | GNUNET_TESTBED_service_connect (ctx, | 785 | ctx->peer, |
826 | ctx->peer, | 786 | "dht", |
827 | "dht", | 787 | &dht_connected, ac, |
828 | &dht_connected, ac, | 788 | &dht_connect, |
829 | &dht_connect, | 789 | &dht_disconnect, |
830 | &dht_disconnect, | 790 | ac); |
831 | ac); | ||
832 | } | ||
833 | } | ||
834 | |||
835 | /** | ||
836 | * Start collecting relevant statistics. If ENABLE_MALICIOUS set, first | ||
837 | * set the malicious peers. If not, then start with PUT operation on active | ||
838 | * peers. | ||
839 | */ | ||
840 | static void | ||
841 | start_func() | ||
842 | { | ||
843 | start_profiling(); | ||
844 | } | ||
845 | |||
846 | |||
847 | /** | ||
848 | * Remove entry from successor peer hashmap. | ||
849 | * @param cls closure | ||
850 | * @param key current public key | ||
851 | * @param value value in the hash map | ||
852 | * @return #GNUNET_YES if we should continue to iterate, | ||
853 | * #GNUNET_NO if not. | ||
854 | */ | ||
855 | static int | ||
856 | hashmap_iterate_remove(void *cls, | ||
857 | const struct GNUNET_HashCode *key, | ||
858 | void *value) | ||
859 | { | ||
860 | GNUNET_assert (GNUNET_YES == | ||
861 | GNUNET_CONTAINER_multihashmap_remove(successor_peer_hashmap, key, value)); | ||
862 | return GNUNET_YES; | ||
863 | } | ||
864 | |||
865 | |||
866 | /** | ||
867 | * Stats callback. Iterate over the hashmap and check if all th peers form | ||
868 | * a virtual ring topology. | ||
869 | * | ||
870 | * @param cls closure | ||
871 | * @param op the operation that has been finished | ||
872 | * @param emsg error message in case the operation has failed; will be NULL if | ||
873 | * operation has executed successfully. | ||
874 | */ | ||
875 | static void | ||
876 | successor_stats_cont (void *cls, | ||
877 | struct GNUNET_TESTBED_Operation *op, | ||
878 | const char *emsg) | ||
879 | { | ||
880 | struct GNUNET_HashCode *val; | ||
881 | struct GNUNET_HashCode *start_val; | ||
882 | struct GNUNET_HashCode *key; | ||
883 | int count; | ||
884 | |||
885 | /* Don't schedule the task till we are looking for circle here. */ | ||
886 | successor_stats_task = NULL; | ||
887 | GNUNET_TESTBED_operation_done (successor_stats_op); | ||
888 | successor_stats_op = NULL; | ||
889 | if (0 == max_searches) | ||
890 | { | ||
891 | start_func (); | ||
892 | return; | ||
893 | } | ||
894 | |||
895 | GNUNET_assert (NULL != start_key); | ||
896 | start_val = GNUNET_CONTAINER_multihashmap_get (successor_peer_hashmap, | ||
897 | start_key); | ||
898 | GNUNET_assert (NULL != start_val); | ||
899 | val = start_val; | ||
900 | for (count = 0; count < num_peers; count++) | ||
901 | { | ||
902 | key = val; | ||
903 | val = GNUNET_CONTAINER_multihashmap_get (successor_peer_hashmap, | ||
904 | key); | ||
905 | if (NULL == val) | ||
906 | break; | ||
907 | /* Remove the entry from hashmap. This is done to take care of loop. */ | ||
908 | if (GNUNET_NO == | ||
909 | GNUNET_CONTAINER_multihashmap_remove (successor_peer_hashmap, | ||
910 | key, val)) | ||
911 | { | ||
912 | DEBUG ("Failed to remove entry from hashmap\n"); | ||
913 | break; | ||
914 | } | ||
915 | /* If a peer has its own identity as its successor. */ | ||
916 | if (0 == memcmp(key, val, sizeof (struct GNUNET_HashCode))) | ||
917 | break; | ||
918 | } | 791 | } |
919 | |||
920 | GNUNET_assert (GNUNET_SYSERR != | ||
921 | GNUNET_CONTAINER_multihashmap_iterate (successor_peer_hashmap, | ||
922 | &hashmap_iterate_remove, | ||
923 | NULL)); | ||
924 | |||
925 | successor_peer_hashmap = GNUNET_CONTAINER_multihashmap_create (num_peers, | ||
926 | GNUNET_NO); | ||
927 | if ((start_val == val) && (count == num_peers)) | ||
928 | { | ||
929 | DEBUG ("CIRCLE COMPLETED after %u tries", tries); | ||
930 | if(NULL == successor_stats_task) | ||
931 | { | ||
932 | start_func(); | ||
933 | } | ||
934 | return; | ||
935 | } | ||
936 | if (max_searches == ++tries) | ||
937 | { | ||
938 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
939 | "Maximum tries %u exceeded while checking successor TOTAL TRIES %u" | ||
940 | " circle formation. Exiting\n", | ||
941 | max_searches,tries); | ||
942 | start_func(); | ||
943 | return; | ||
944 | } | ||
945 | flag = 0; | ||
946 | successor_stats_task | ||
947 | = GNUNET_SCHEDULER_add_delayed (delay_stats, | ||
948 | &collect_stats, | ||
949 | cls); | ||
950 | } | ||
951 | |||
952 | |||
953 | /** | ||
954 | * Process successor statistic values. | ||
955 | * | ||
956 | * @param cls closure | ||
957 | * @param peer the peer the statistic belong to | ||
958 | * @param subsystem name of subsystem that created the statistic | ||
959 | * @param name the name of the datum | ||
960 | * @param value the current value | ||
961 | * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not | ||
962 | * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration | ||
963 | */ | ||
964 | static int | ||
965 | successor_stats_iterator (void *cls, | ||
966 | const struct GNUNET_TESTBED_Peer *peer, | ||
967 | const char *subsystem, | ||
968 | const char *name, | ||
969 | uint64_t value, | ||
970 | int is_persistent) | ||
971 | { | ||
972 | static const char *key_string = "XDHT"; | ||
973 | if (0 == max_searches) | ||
974 | return GNUNET_OK; | ||
975 | |||
976 | if (0 == strncmp (key_string, name, strlen (key_string))) | ||
977 | { | ||
978 | char *my_id_str; | ||
979 | char successor_str[13]; | ||
980 | char truncated_my_id_str[13]; | ||
981 | char truncated_successor_str[13]; | ||
982 | struct GNUNET_HashCode *my_id_key; | ||
983 | struct GNUNET_HashCode *succ_key; | ||
984 | |||
985 | strtok((char *)name,":"); | ||
986 | my_id_str = strtok(NULL,":"); | ||
987 | |||
988 | strncpy(truncated_my_id_str, my_id_str, 12); | ||
989 | truncated_my_id_str[12] = '\0'; | ||
990 | my_id_key = GNUNET_new(struct GNUNET_HashCode); | ||
991 | GNUNET_CRYPTO_hash (truncated_my_id_str, sizeof(truncated_my_id_str),my_id_key); | ||
992 | GNUNET_STRINGS_data_to_string(&value, sizeof(uint64_t), successor_str, 13); | ||
993 | strncpy(truncated_successor_str, successor_str, 12); | ||
994 | truncated_successor_str[12] ='\0'; | ||
995 | |||
996 | succ_key = GNUNET_new(struct GNUNET_HashCode); | ||
997 | GNUNET_CRYPTO_hash (truncated_successor_str, sizeof(truncated_successor_str),succ_key); | ||
998 | |||
999 | if (0 == flag) | ||
1000 | { | ||
1001 | GNUNET_assert(NULL != my_id_key); | ||
1002 | start_key = my_id_key; | ||
1003 | GNUNET_assert(NULL != start_key); | ||
1004 | flag = 1; | ||
1005 | } | ||
1006 | GNUNET_CONTAINER_multihashmap_put (successor_peer_hashmap, | ||
1007 | my_id_key, (void *)succ_key, | ||
1008 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); | ||
1009 | } | ||
1010 | |||
1011 | return GNUNET_OK; | ||
1012 | } | ||
1013 | |||
1014 | |||
1015 | /* | ||
1016 | * Task that collects peer and its corresponding successors. | ||
1017 | * | ||
1018 | * @param cls Closure (NULL). | ||
1019 | */ | ||
1020 | static void | ||
1021 | collect_stats (void *cls) | ||
1022 | { | ||
1023 | successor_stats_task = NULL; | ||
1024 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
1025 | "Start collecting statistics...\n"); | ||
1026 | GNUNET_assert(NULL != testbed_handles); | ||
1027 | |||
1028 | if (0 != max_searches) | ||
1029 | successor_peer_hashmap | ||
1030 | = GNUNET_CONTAINER_multihashmap_create (num_peers, | ||
1031 | GNUNET_NO); | ||
1032 | successor_stats_op | ||
1033 | = GNUNET_TESTBED_get_statistics (num_peers, testbed_handles, | ||
1034 | "dht", NULL, | ||
1035 | successor_stats_iterator, | ||
1036 | successor_stats_cont, cls); | ||
1037 | GNUNET_assert (NULL != successor_stats_op); | ||
1038 | } | 792 | } |
1039 | 793 | ||
1040 | 794 | ||
@@ -1058,19 +812,11 @@ service_started (void *cls, | |||
1058 | GNUNET_TESTBED_operation_done (ctx->op); | 812 | GNUNET_TESTBED_operation_done (ctx->op); |
1059 | ctx->op = NULL; | 813 | ctx->op = NULL; |
1060 | peers_started++; | 814 | peers_started++; |
1061 | DEBUG("Peers Started = %d; num_peers = %d \n", peers_started, num_peers); | 815 | DEBUG ("Peers Started = %d; num_peers = %d \n", |
1062 | if (NULL == successor_stats_task && peers_started == num_peers) | 816 | peers_started, |
1063 | { | 817 | num_peers); |
1064 | DEBUG("successor_stats_task \n"); | 818 | if (peers_started == num_peers) |
1065 | struct Collect_Stat_Context *collect_stat_cls = GNUNET_new(struct Collect_Stat_Context); | 819 | start_profiling (); |
1066 | collect_stat_cls->service_connect_ctx = cls; | ||
1067 | collect_stat_cls->op = op; | ||
1068 | |||
1069 | successor_stats_task | ||
1070 | = GNUNET_SCHEDULER_add_delayed (delay_stats, | ||
1071 | &collect_stats, | ||
1072 | collect_stat_cls); | ||
1073 | } | ||
1074 | } | 820 | } |
1075 | 821 | ||
1076 | 822 | ||
@@ -1088,36 +834,42 @@ service_started (void *cls, | |||
1088 | static void | 834 | static void |
1089 | test_run (void *cls, | 835 | test_run (void *cls, |
1090 | struct GNUNET_TESTBED_RunHandle *h, | 836 | struct GNUNET_TESTBED_RunHandle *h, |
1091 | unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, | 837 | unsigned int num_peers, |
838 | struct GNUNET_TESTBED_Peer **peers, | ||
1092 | unsigned int links_succeeded, | 839 | unsigned int links_succeeded, |
1093 | unsigned int links_failed) | 840 | unsigned int links_failed) |
1094 | { | 841 | { |
1095 | unsigned int cnt; | ||
1096 | unsigned int ac_cnt; | 842 | unsigned int ac_cnt; |
843 | |||
1097 | testbed_handles = peers; | 844 | testbed_handles = peers; |
1098 | if (NULL == peers) | 845 | if (NULL == peers) |
1099 | { | 846 | { |
1100 | /* exit */ | 847 | /* exit */ |
1101 | GNUNET_assert (0); | 848 | GNUNET_assert (0); |
1102 | } | 849 | } |
1103 | INFO ("%u peers started\n", num_peers); | 850 | MESSAGE ("%u peers started, %u/%u links up\n", |
1104 | a_ctx = GNUNET_malloc (sizeof (struct Context) * num_peers); | 851 | num_peers, |
1105 | 852 | links_succeeded, | |
853 | links_succeeded + links_failed); | ||
854 | a_ctx = GNUNET_new_array (num_peers, | ||
855 | struct Context); | ||
1106 | /* select the peers which actively participate in profiling */ | 856 | /* select the peers which actively participate in profiling */ |
1107 | n_active = num_peers * PUT_PROBABILITY / 100; | 857 | n_active = num_peers * put_probability / 100; |
1108 | if (0 == n_active) | 858 | if (0 == n_active) |
1109 | { | 859 | { |
1110 | GNUNET_SCHEDULER_shutdown (); | 860 | GNUNET_SCHEDULER_shutdown (); |
1111 | GNUNET_free (a_ctx); | 861 | GNUNET_free (a_ctx); |
862 | a_ctx = NULL; | ||
1112 | return; | 863 | return; |
1113 | } | 864 | } |
1114 | 865 | ||
1115 | a_ac = GNUNET_malloc (n_active * sizeof (struct ActiveContext)); | 866 | a_ac = GNUNET_new_array (n_active, |
867 | struct ActiveContext); | ||
1116 | ac_cnt = 0; | 868 | ac_cnt = 0; |
1117 | for (cnt = 0; cnt < num_peers && ac_cnt < n_active; cnt++) | 869 | for (unsigned int cnt = 0; cnt < num_peers && ac_cnt < n_active; cnt++) |
1118 | { | 870 | { |
1119 | if ((GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100) >= | 871 | if (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
1120 | PUT_PROBABILITY)) | 872 | 100) >= put_probability) |
1121 | continue; | 873 | continue; |
1122 | 874 | ||
1123 | a_ctx[cnt].ac = &a_ac[ac_cnt]; | 875 | a_ctx[cnt].ac = &a_ac[ac_cnt]; |
@@ -1125,10 +877,9 @@ test_run (void *cls, | |||
1125 | ac_cnt++; | 877 | ac_cnt++; |
1126 | } | 878 | } |
1127 | n_active = ac_cnt; | 879 | n_active = ac_cnt; |
1128 | INFO ("Active peers: %u\n", n_active); | ||
1129 | 880 | ||
1130 | /* start DHT service on all peers */ | 881 | /* start DHT service on all peers */ |
1131 | for (cnt = 0; cnt < num_peers; cnt++) | 882 | for (unsigned int cnt = 0; cnt < num_peers; cnt++) |
1132 | { | 883 | { |
1133 | a_ctx[cnt].peer = peers[cnt]; | 884 | a_ctx[cnt].peer = peers[cnt]; |
1134 | a_ctx[cnt].op = GNUNET_TESTBED_peer_manage_service (&a_ctx[cnt], | 885 | a_ctx[cnt].op = GNUNET_TESTBED_peer_manage_service (&a_ctx[cnt], |
@@ -1150,7 +901,9 @@ test_run (void *cls, | |||
1150 | * @param config configuration | 901 | * @param config configuration |
1151 | */ | 902 | */ |
1152 | static void | 903 | static void |
1153 | run (void *cls, char *const *args, const char *cfgfile, | 904 | run (void *cls, |
905 | char *const *args, | ||
906 | const char *cfgfile, | ||
1154 | const struct GNUNET_CONFIGURATION_Handle *config) | 907 | const struct GNUNET_CONFIGURATION_Handle *config) |
1155 | { | 908 | { |
1156 | uint64_t event_mask; | 909 | uint64_t event_mask; |
@@ -1162,10 +915,16 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1162 | num_peers); | 915 | num_peers); |
1163 | return; | 916 | return; |
1164 | } | 917 | } |
1165 | cfg = GNUNET_CONFIGURATION_dup (config); | 918 | cfg = config; |
1166 | event_mask = 0; | 919 | event_mask = 0; |
1167 | GNUNET_TESTBED_run (hosts_file, cfg, num_peers, event_mask, NULL, | 920 | GNUNET_TESTBED_run (hosts_file, |
1168 | NULL, &test_run, NULL); | 921 | cfg, |
922 | num_peers, | ||
923 | event_mask, | ||
924 | NULL, | ||
925 | NULL, | ||
926 | &test_run, | ||
927 | NULL); | ||
1169 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, | 928 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, |
1170 | NULL); | 929 | NULL); |
1171 | } | 930 | } |
@@ -1177,63 +936,62 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1177 | * @return 0 on success | 936 | * @return 0 on success |
1178 | */ | 937 | */ |
1179 | int | 938 | int |
1180 | main (int argc, char *const *argv) | 939 | main (int argc, |
940 | char *const *argv) | ||
1181 | { | 941 | { |
1182 | int rc; | 942 | int rc; |
1183 | |||
1184 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 943 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
1185 | GNUNET_GETOPT_option_uint ('n', | 944 | GNUNET_GETOPT_option_uint ('n', |
1186 | "peers", | 945 | "peers", |
1187 | "COUNT", | 946 | "COUNT", |
1188 | gettext_noop ("number of peers to start"), | 947 | gettext_noop ("number of peers to start"), |
1189 | &num_peers), | 948 | &num_peers), |
1190 | 949 | GNUNET_GETOPT_option_uint ('p', | |
1191 | GNUNET_GETOPT_option_uint ('s', | 950 | "peer-put-count", |
1192 | "searches", | 951 | "COUNT", |
1193 | "COUNT", | 952 | gettext_noop ("number of PUTs to perform per peer"), |
1194 | gettext_noop ("maximum number of times we try to search for successor circle formation (0 for R5N)"), | 953 | &num_puts_per_peer), |
1195 | &max_searches), | ||
1196 | |||
1197 | GNUNET_GETOPT_option_string ('H', | 954 | GNUNET_GETOPT_option_string ('H', |
1198 | "hosts", | 955 | "hosts", |
1199 | "FILENAME", | 956 | "FILENAME", |
1200 | gettext_noop ("name of the file with the login information for the testbed"), | 957 | gettext_noop ("name of the file with the login information for the testbed"), |
1201 | &hosts_file), | 958 | &hosts_file), |
1202 | |||
1203 | GNUNET_GETOPT_option_relative_time ('D', | 959 | GNUNET_GETOPT_option_relative_time ('D', |
1204 | "delay", | 960 | "delay", |
1205 | "DELAY", | 961 | "DELAY", |
1206 | gettext_noop ("delay between rounds for collecting statistics (default: 30 sec)"), | 962 | gettext_noop ("delay between rounds for collecting statistics (default: 30 sec)"), |
1207 | &delay_stats), | 963 | &delay_stats), |
1208 | |||
1209 | GNUNET_GETOPT_option_relative_time ('P', | 964 | GNUNET_GETOPT_option_relative_time ('P', |
1210 | "PUT-delay", | 965 | "PUT-delay", |
1211 | "DELAY", | 966 | "DELAY", |
1212 | gettext_noop ("delay to start doing PUTs (default: 1 sec)"), | 967 | gettext_noop ("delay to start doing PUTs (default: 1 sec)"), |
1213 | &delay_put), | 968 | &delay_put), |
1214 | |||
1215 | GNUNET_GETOPT_option_relative_time ('G', | 969 | GNUNET_GETOPT_option_relative_time ('G', |
1216 | "GET-delay", | 970 | "GET-delay", |
1217 | "DELAY", | 971 | "DELAY", |
1218 | gettext_noop ("delay to start doing GETs (default: 5 min)"), | 972 | gettext_noop ("delay to start doing GETs (default: 5 min)"), |
1219 | &delay_get), | 973 | &delay_get), |
1220 | GNUNET_GETOPT_option_uint ('r', | 974 | GNUNET_GETOPT_option_uint ('r', |
1221 | "replication", | 975 | "replication", |
1222 | "DEGREE", | 976 | "DEGREE", |
1223 | gettext_noop ("replication degree for DHT PUTs"), | 977 | gettext_noop ("replication degree for DHT PUTs"), |
1224 | &replication), | 978 | &replication), |
1225 | 979 | GNUNET_GETOPT_option_uint ('R', | |
1226 | 980 | "random-chance", | |
981 | "PROBABILITY", | ||
982 | gettext_noop ("chance that a peer is selected at random for PUTs"), | ||
983 | &put_probability), | ||
1227 | GNUNET_GETOPT_option_relative_time ('t', | 984 | GNUNET_GETOPT_option_relative_time ('t', |
1228 | "timeout", | 985 | "timeout", |
1229 | "TIMEOUT", | 986 | "TIMEOUT", |
1230 | gettext_noop ("timeout for DHT PUT and GET requests (default: 1 min)"), | 987 | gettext_noop ("timeout for DHT PUT and GET requests (default: 1 min)"), |
1231 | &timeout), | 988 | &timeout), |
1232 | GNUNET_GETOPT_OPTION_END | 989 | GNUNET_GETOPT_OPTION_END |
1233 | }; | 990 | }; |
1234 | 991 | ||
1235 | max_searches = 5; | 992 | if (GNUNET_OK != |
1236 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 993 | GNUNET_STRINGS_get_utf8_args (argc, argv, |
994 | &argc, &argv)) | ||
1237 | return 2; | 995 | return 2; |
1238 | /* set default delays */ | 996 | /* set default delays */ |
1239 | delay_stats = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10); | 997 | delay_stats = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10); |
@@ -1243,10 +1001,13 @@ main (int argc, char *const *argv) | |||
1243 | replication = 1; /* default replication */ | 1001 | replication = 1; /* default replication */ |
1244 | rc = 0; | 1002 | rc = 0; |
1245 | if (GNUNET_OK != | 1003 | if (GNUNET_OK != |
1246 | GNUNET_PROGRAM_run (argc, argv, "dht-profiler", | 1004 | GNUNET_PROGRAM_run (argc, |
1247 | gettext_noop | 1005 | argv, |
1248 | ("Measure quality and performance of the DHT service."), | 1006 | "gnunet-dht-profiler", |
1249 | options, &run, NULL)) | 1007 | gettext_noop ("Measure quality and performance of the DHT service."), |
1008 | options, | ||
1009 | &run, | ||
1010 | NULL)) | ||
1250 | rc = 1; | 1011 | rc = 1; |
1251 | return rc; | 1012 | return rc; |
1252 | } | 1013 | } |
diff --git a/src/dht/plugin_block_dht.c b/src/dht/plugin_block_dht.c index 24f8b21b2..d4b19677e 100644 --- a/src/dht/plugin_block_dht.c +++ b/src/dht/plugin_block_dht.c | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2010, 2017 GNUnet e.V. | 3 | Copyright (C) 2010, 2017 GNUnet e.V. |
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 it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | 18 | ||
21 | /** | 19 | /** |
@@ -66,7 +64,8 @@ block_plugin_dht_create_group (void *cls, | |||
66 | guard = va_arg (va, const char *); | 64 | guard = va_arg (va, const char *); |
67 | if (0 == strcmp (guard, | 65 | if (0 == strcmp (guard, |
68 | "seen-set-size")) | 66 | "seen-set-size")) |
69 | bf_size = GNUNET_BLOCK_GROUP_compute_bloomfilter_size (va_arg (va, unsigned int), | 67 | bf_size = GNUNET_BLOCK_GROUP_compute_bloomfilter_size (va_arg (va, |
68 | unsigned int), | ||
70 | BLOOMFILTER_K); | 69 | BLOOMFILTER_K); |
71 | else if (0 == strcmp (guard, | 70 | else if (0 == strcmp (guard, |
72 | "filter-size")) | 71 | "filter-size")) |
@@ -183,14 +182,17 @@ block_plugin_dht_get_key (void *cls, | |||
183 | return GNUNET_SYSERR; | 182 | return GNUNET_SYSERR; |
184 | if (block_size < sizeof (struct GNUNET_MessageHeader)) | 183 | if (block_size < sizeof (struct GNUNET_MessageHeader)) |
185 | { | 184 | { |
186 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "block-dht", | 185 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, |
187 | _("Block not of type %u\n"), GNUNET_BLOCK_TYPE_DHT_HELLO); | 186 | "block-dht", |
187 | _("Block not of type %u\n"), | ||
188 | GNUNET_BLOCK_TYPE_DHT_HELLO); | ||
188 | return GNUNET_NO; | 189 | return GNUNET_NO; |
189 | } | 190 | } |
190 | msg = block; | 191 | msg = block; |
191 | if (block_size != ntohs (msg->size)) | 192 | if (block_size != ntohs (msg->size)) |
192 | { | 193 | { |
193 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "block-dht", | 194 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, |
195 | "block-dht", | ||
194 | _("Size mismatch for block\n"), | 196 | _("Size mismatch for block\n"), |
195 | GNUNET_BLOCK_TYPE_DHT_HELLO); | 197 | GNUNET_BLOCK_TYPE_DHT_HELLO); |
196 | return GNUNET_NO; | 198 | return GNUNET_NO; |
@@ -200,7 +202,8 @@ block_plugin_dht_get_key (void *cls, | |||
200 | pid = (struct GNUNET_PeerIdentity *) key; | 202 | pid = (struct GNUNET_PeerIdentity *) key; |
201 | if (GNUNET_OK != GNUNET_HELLO_get_id (hello, pid)) | 203 | if (GNUNET_OK != GNUNET_HELLO_get_id (hello, pid)) |
202 | { | 204 | { |
203 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "block-dht", | 205 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, |
206 | "block-dht", | ||
204 | _("Block of type %u is malformed\n"), | 207 | _("Block of type %u is malformed\n"), |
205 | GNUNET_BLOCK_TYPE_DHT_HELLO); | 208 | GNUNET_BLOCK_TYPE_DHT_HELLO); |
206 | return GNUNET_NO; | 209 | return GNUNET_NO; |
diff --git a/src/dht/test_dht_2dtorus.conf b/src/dht/test_dht_2dtorus.conf index c3fe5135f..0e546cf68 100644 --- a/src/dht/test_dht_2dtorus.conf +++ b/src/dht/test_dht_2dtorus.conf | |||
@@ -1,11 +1,11 @@ | |||
1 | @INLINE@ ../../contrib/no_forcestart.conf | 1 | @INLINE@ ../../contrib/conf/gnunet/no_forcestart.conf |
2 | @INLINE@ ../../contrib/no_autostart_above_core.conf | 2 | @INLINE@ ../../contrib/conf/gnunet/no_autostart_above_core.conf |
3 | [PATHS] | 3 | [PATHS] |
4 | GNUNET_TEST_HOME = /tmp/test_dht_2dtorus/ | 4 | GNUNET_TEST_HOME = $GNUNET_TMP/test_dht_2dtorus/ |
5 | 5 | ||
6 | [dht] | 6 | [dht] |
7 | AUTOSTART = YES | 7 | START_ON_DEMAND = YES |
8 | FORCESTART = YES | 8 | IMMEDIATE_START = YES |
9 | 9 | ||
10 | [dhtcache] | 10 | [dhtcache] |
11 | QUOTA = 1 MB | 11 | QUOTA = 1 MB |
@@ -28,7 +28,7 @@ WAN_QUOTA_OUT = 1 GB | |||
28 | OVERLAY_TOPOLOGY = 2D_TORUS | 28 | OVERLAY_TOPOLOGY = 2D_TORUS |
29 | 29 | ||
30 | [nse] | 30 | [nse] |
31 | AUTOSTART = YES | 31 | START_ON_DEMAND = YES |
32 | WORKDELAY = 500 ms | 32 | WORKDELAY = 500 ms |
33 | INTERVAL = 60 s | 33 | INTERVAL = 60 s |
34 | WORKBITS = 0 | 34 | WORKBITS = 0 |
diff --git a/src/dht/test_dht_api.c b/src/dht/test_dht_api.c index 62d121306..9097a0011 100644 --- a/src/dht/test_dht_api.c +++ b/src/dht/test_dht_api.c | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2009, 2015, 2017 GNUnet e.V. | 3 | Copyright (C) 2009, 2015, 2017 GNUnet e.V. |
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 it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | /** | 18 | /** |
21 | * @file dht/test_dht_api.c | 19 | * @file dht/test_dht_api.c |
diff --git a/src/dht/test_dht_api_data.conf b/src/dht/test_dht_api_data.conf index de9196107..cb875fad4 100644 --- a/src/dht/test_dht_api_data.conf +++ b/src/dht/test_dht_api_data.conf | |||
@@ -1,8 +1,8 @@ | |||
1 | @INLINE@ ../../contrib/no_forcestart.conf | 1 | @INLINE@ ../../contrib/conf/gnunet/no_forcestart.conf |
2 | @INLINE@ ../../contrib/no_autostart_above_core.conf | 2 | @INLINE@ ../../contrib/conf/gnunet/no_autostart_above_core.conf |
3 | 3 | ||
4 | [PATHS] | 4 | [PATHS] |
5 | GNUNET_TEST_HOME = /tmp/test-dht-api/ | 5 | GNUNET_TEST_HOME = $GNUNET_TMP/test-dht-api/ |
6 | 6 | ||
7 | [dhtcache] | 7 | [dhtcache] |
8 | QUOTA = 1 MB | 8 | QUOTA = 1 MB |
@@ -36,9 +36,9 @@ INTERNAL_ADDRESS = 127.0.0.1 | |||
36 | EXTERNAL_ADDRESS = 127.0.0.1 | 36 | EXTERNAL_ADDRESS = 127.0.0.1 |
37 | 37 | ||
38 | [dht] | 38 | [dht] |
39 | AUTOSTART = YES | 39 | START_ON_DEMAND = YES |
40 | FORCESTART = YES | 40 | IMMEDIATE_START = YES |
41 | 41 | ||
42 | [nse] | 42 | [nse] |
43 | AUTOSTART = YES | 43 | START_ON_DEMAND = YES |
44 | WORKBITS = 1 | 44 | WORKBITS = 1 |
diff --git a/src/dht/test_dht_api_peer1.conf b/src/dht/test_dht_api_peer1.conf index 0b9db1f8b..230aa0fa4 100644 --- a/src/dht/test_dht_api_peer1.conf +++ b/src/dht/test_dht_api_peer1.conf | |||
@@ -1,5 +1,5 @@ | |||
1 | @INLINE@ ../../contrib/no_forcestart.conf | 1 | @INLINE@ ../../contrib/conf/gnunet/no_forcestart.conf |
2 | @INLINE@ ../../contrib/no_autostart_above_core.conf | 2 | @INLINE@ ../../contrib/conf/gnunet/no_autostart_above_core.conf |
3 | 3 | ||
4 | [dhtcache] | 4 | [dhtcache] |
5 | QUOTA = 1 MB | 5 | QUOTA = 1 MB |
@@ -21,7 +21,7 @@ TIMEOUT = 300 s | |||
21 | BINDTO = 127.0.0.1 | 21 | BINDTO = 127.0.0.1 |
22 | 22 | ||
23 | [PATHS] | 23 | [PATHS] |
24 | GNUNET_TEST_HOME = /tmp/test-gnunet-dht-peer-1/ | 24 | GNUNET_TEST_HOME = $GNUNET_TMP/test-gnunet-dht-peer-1/ |
25 | 25 | ||
26 | [nat] | 26 | [nat] |
27 | DISABLEV6 = YES | 27 | DISABLEV6 = YES |
@@ -33,9 +33,9 @@ EXTERNAL_ADDRESS = 127.0.0.1 | |||
33 | USE_LOCALADDR = NO | 33 | USE_LOCALADDR = NO |
34 | 34 | ||
35 | [dht] | 35 | [dht] |
36 | AUTOSTART = YES | 36 | START_ON_DEMAND = YES |
37 | FORCESTART = YES | 37 | IMMEDIATE_START = YES |
38 | 38 | ||
39 | [nse] | 39 | [nse] |
40 | AUTOSTART = YES | 40 | START_ON_DEMAND = YES |
41 | WORKBITS = 1 | 41 | WORKBITS = 1 |
diff --git a/src/dht/test_dht_line.conf b/src/dht/test_dht_line.conf index de91ed32b..62e337ef2 100644 --- a/src/dht/test_dht_line.conf +++ b/src/dht/test_dht_line.conf | |||
@@ -1,11 +1,11 @@ | |||
1 | @INLINE@ ../../contrib/no_forcestart.conf | 1 | @INLINE@ ../../contrib/conf/gnunet/no_forcestart.conf |
2 | @INLINE@ ../../contrib/no_autostart_above_core.conf | 2 | @INLINE@ ../../contrib/conf/gnunet/no_autostart_above_core.conf |
3 | [PATHS] | 3 | [PATHS] |
4 | GNUNET_TEST_HOME = /tmp/test_dht_line/ | 4 | GNUNET_TEST_HOME = $GNUNET_TMP/test_dht_line/ |
5 | 5 | ||
6 | [dht] | 6 | [dht] |
7 | AUTOSTART = YES | 7 | START_ON_DEMAND = YES |
8 | FORCESTART = YES | 8 | IMMEDIATE_START = YES |
9 | 9 | ||
10 | [dhtcache] | 10 | [dhtcache] |
11 | QUOTA = 1 MB | 11 | QUOTA = 1 MB |
@@ -32,7 +32,7 @@ OVERLAY_TOPOLOGY = LINE | |||
32 | plugins = unix | 32 | plugins = unix |
33 | 33 | ||
34 | [nse] | 34 | [nse] |
35 | AUTOSTART = YES | 35 | START_ON_DEMAND = YES |
36 | WORKDELAY = 500 ms | 36 | WORKDELAY = 500 ms |
37 | INTERVAL = 60 s | 37 | INTERVAL = 60 s |
38 | WORKBITS = 0 | 38 | WORKBITS = 0 |
diff --git a/src/dht/test_dht_monitor.c b/src/dht/test_dht_monitor.c index 3de800144..33467e89c 100644 --- a/src/dht/test_dht_monitor.c +++ b/src/dht/test_dht_monitor.c | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2011, 2012 GNUnet e.V. | 3 | Copyright (C) 2011, 2012 GNUnet e.V. |
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 it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | /** | 18 | /** |
21 | * @file dht/test_dht_monitor.c | 19 | * @file dht/test_dht_monitor.c |
diff --git a/src/dht/test_dht_monitor.conf b/src/dht/test_dht_monitor.conf index ed0dece58..feefc2f5e 100644 --- a/src/dht/test_dht_monitor.conf +++ b/src/dht/test_dht_monitor.conf | |||
@@ -1,5 +1,5 @@ | |||
1 | @INLINE@ ../../contrib/no_forcestart.conf | 1 | @INLINE@ ../../contrib/conf/gnunet/no_forcestart.conf |
2 | @INLINE@ ../../contrib/no_autostart_above_core.conf | 2 | @INLINE@ ../../contrib/conf/gnunet/no_autostart_above_core.conf |
3 | 3 | ||
4 | 4 | ||
5 | [dhtcache] | 5 | [dhtcache] |
@@ -17,7 +17,7 @@ WAN_QUOTA_OUT = 1 GB | |||
17 | OVERLAY_TOPOLOGY = LINE | 17 | OVERLAY_TOPOLOGY = LINE |
18 | 18 | ||
19 | [PATHS] | 19 | [PATHS] |
20 | GNUNET_TEST_HOME = /tmp/test-dht-monitor/ | 20 | GNUNET_TEST_HOME = $GNUNET_TMP/test-dht-monitor/ |
21 | 21 | ||
22 | [nat] | 22 | [nat] |
23 | DISABLEV6 = YES | 23 | DISABLEV6 = YES |
@@ -31,9 +31,9 @@ RETURN_LOCAL_ADDRESSES = YES | |||
31 | 31 | ||
32 | 32 | ||
33 | [dht] | 33 | [dht] |
34 | AUTOSTART = YES | 34 | START_ON_DEMAND = YES |
35 | FORCESTART = YES | 35 | IMMEDIATE_START = YES |
36 | 36 | ||
37 | [nse] | 37 | [nse] |
38 | AUTOSTART = YES | 38 | START_ON_DEMAND = YES |
39 | WORKBITS = 1 | 39 | WORKBITS = 1 |
diff --git a/src/dht/test_dht_multipeer.conf b/src/dht/test_dht_multipeer.conf index 1d69dacfd..ac35664c4 100644 --- a/src/dht/test_dht_multipeer.conf +++ b/src/dht/test_dht_multipeer.conf | |||
@@ -1,9 +1,9 @@ | |||
1 | @INLINE@ ../../contrib/no_forcestart.conf | 1 | @INLINE@ ../../contrib/conf/gnunet/no_forcestart.conf |
2 | @INLINE@ ../../contrib/no_autostart_above_core.conf | 2 | @INLINE@ ../../contrib/conf/gnunet/no_autostart_above_core.conf |
3 | 3 | ||
4 | [dht] | 4 | [dht] |
5 | AUTOSTART = YES | 5 | START_ON_DEMAND = YES |
6 | FORCESTART = YES | 6 | IMMEDIATE_START = YES |
7 | 7 | ||
8 | [dhtcache] | 8 | [dhtcache] |
9 | QUOTA = 1 MB | 9 | QUOTA = 1 MB |
@@ -21,7 +21,7 @@ OVERLAY_TOPOLOGY = FROM_FILE | |||
21 | OVERLAY_TOPOLOGY_FILE = test_dht_multipeer_topology.dat | 21 | OVERLAY_TOPOLOGY_FILE = test_dht_multipeer_topology.dat |
22 | 22 | ||
23 | [PATHS] | 23 | [PATHS] |
24 | GNUNET_TEST_HOME = /tmp/test-dht-multipeer/ | 24 | GNUNET_TEST_HOME = $GNUNET_TMP/test-dht-multipeer/ |
25 | 25 | ||
26 | [nat] | 26 | [nat] |
27 | DISABLEV6 = YES | 27 | DISABLEV6 = YES |
@@ -34,7 +34,7 @@ EXTERNAL_ADDRESS = 127.0.0.1 | |||
34 | USE_LOCALADDR = YES | 34 | USE_LOCALADDR = YES |
35 | 35 | ||
36 | [nse] | 36 | [nse] |
37 | AUTOSTART = YES | 37 | START_ON_DEMAND = YES |
38 | WORKDELAY = 500 ms | 38 | WORKDELAY = 500 ms |
39 | INTERVAL = 60 s | 39 | INTERVAL = 60 s |
40 | WORKBITS = 0 | 40 | WORKBITS = 0 |
diff --git a/src/dht/test_dht_tools.conf b/src/dht/test_dht_tools.conf index 9306c5dc9..05f7cc0e6 100644 --- a/src/dht/test_dht_tools.conf +++ b/src/dht/test_dht_tools.conf | |||
@@ -18,7 +18,7 @@ TIMEOUT = 300 s | |||
18 | BINDTO = 127.0.0.1 | 18 | BINDTO = 127.0.0.1 |
19 | 19 | ||
20 | [PATHS] | 20 | [PATHS] |
21 | GNUNET_TEST_HOME = /tmp/test-gnunet-dht-peer-1/ | 21 | GNUNET_TEST_HOME = $GNUNET_TMP/test-gnunet-dht-peer-1/ |
22 | 22 | ||
23 | [nat] | 23 | [nat] |
24 | DISABLEV6 = YES | 24 | DISABLEV6 = YES |
@@ -30,128 +30,128 @@ EXTERNAL_ADDRESS = 127.0.0.1 | |||
30 | USE_LOCALADDR = NO | 30 | USE_LOCALADDR = NO |
31 | 31 | ||
32 | [dht] | 32 | [dht] |
33 | AUTOSTART = YES | 33 | START_ON_DEMAND = YES |
34 | FORCESTART = YES | 34 | IMMEDIATE_START = YES |
35 | 35 | ||
36 | [nse] | 36 | [nse] |
37 | AUTOSTART = YES | 37 | START_ON_DEMAND = YES |
38 | WORKBITS = 1 | 38 | WORKBITS = 1 |
39 | # Configuration to disable autostarting of | 39 | # Configuration to disable autostarting of |
40 | # all services above the 'core' level. | 40 | # all services above the 'core' level. |
41 | # (including resolver) | 41 | # (including resolver) |
42 | 42 | ||
43 | [dns] | 43 | [dns] |
44 | AUTOSTART = NO | 44 | START_ON_DEMAND = NO |
45 | 45 | ||
46 | [cadet] | 46 | [cadet] |
47 | AUTOSTART = NO | 47 | START_ON_DEMAND = NO |
48 | 48 | ||
49 | [datastore] | 49 | [datastore] |
50 | AUTOSTART = NO | 50 | START_ON_DEMAND = NO |
51 | 51 | ||
52 | [fs] | 52 | [fs] |
53 | AUTOSTART = NO | 53 | START_ON_DEMAND = NO |
54 | 54 | ||
55 | [dv] | 55 | [dv] |
56 | AUTOSTART = NO | 56 | START_ON_DEMAND = NO |
57 | 57 | ||
58 | [vpn] | 58 | [vpn] |
59 | AUTOSTART = NO | 59 | START_ON_DEMAND = NO |
60 | 60 | ||
61 | [consensus] | 61 | [consensus] |
62 | AUTOSTART = NO | 62 | START_ON_DEMAND = NO |
63 | 63 | ||
64 | [resolver] | 64 | [resolver] |
65 | AUTOSTART = NO | 65 | START_ON_DEMAND = NO |
66 | 66 | ||
67 | [namestore] | 67 | [namestore] |
68 | AUTOSTART = NO | 68 | START_ON_DEMAND = NO |
69 | 69 | ||
70 | [namecache] | 70 | [namecache] |
71 | AUTOSTART = NO | 71 | START_ON_DEMAND = NO |
72 | 72 | ||
73 | [identity] | 73 | [identity] |
74 | AUTOSTART = NO | 74 | START_ON_DEMAND = NO |
75 | 75 | ||
76 | [revocation] | 76 | [revocation] |
77 | AUTOSTART = NO | 77 | START_ON_DEMAND = NO |
78 | 78 | ||
79 | [conversation] | 79 | [conversation] |
80 | AUTOSTART = NO | 80 | START_ON_DEMAND = NO |
81 | 81 | ||
82 | [peerstore] | 82 | [peerstore] |
83 | AUTOSTART = NO | 83 | START_ON_DEMAND = NO |
84 | 84 | ||
85 | [psycstore] | 85 | [psycstore] |
86 | AUTOSTART = NO | 86 | START_ON_DEMAND = NO |
87 | 87 | ||
88 | [gns] | 88 | [gns] |
89 | AUTOSTART = NO | 89 | START_ON_DEMAND = NO |
90 | 90 | ||
91 | [regex] | 91 | [regex] |
92 | AUTOSTART = NO | 92 | START_ON_DEMAND = NO |
93 | 93 | ||
94 | [set] | 94 | [set] |
95 | AUTOSTART = NO | 95 | START_ON_DEMAND = NO |
96 | 96 | ||
97 | [scalarproduct-bob] | 97 | [scalarproduct-bob] |
98 | AUTOSTART = NO | 98 | START_ON_DEMAND = NO |
99 | 99 | ||
100 | [scalarproduct-alice] | 100 | [scalarproduct-alice] |
101 | AUTOSTART = NO | 101 | START_ON_DEMAND = NO |
102 | 102 | ||
103 | [social] | 103 | [social] |
104 | AUTOSTART = NO | 104 | START_ON_DEMAND = NO |
105 | 105 | ||
106 | [psyc] | 106 | [psyc] |
107 | AUTOSTART = NO | 107 | START_ON_DEMAND = NO |
108 | 108 | ||
109 | [rps] | 109 | [rps] |
110 | AUTOSTART = NO | 110 | START_ON_DEMAND = NO |
111 | 111 | ||
112 | [multicast] | 112 | [multicast] |
113 | AUTOSTART = NO | 113 | START_ON_DEMAND = NO |
114 | 114 | ||
115 | [sensordashboard] | 115 | [sensordashboard] |
116 | AUTOSTART = NO | 116 | START_ON_DEMAND = NO |
117 | 117 | ||
118 | [sensor] | 118 | [sensor] |
119 | AUTOSTART = NO | 119 | START_ON_DEMAND = NO |
120 | # Configuration file that can be included to prevent ANY of the usual | 120 | # Configuration file that can be included to prevent ANY of the usual |
121 | # FORCESTART = YES to be set. Also disables NSE POW calculation. | 121 | # IMMEDIATE_START = YES to be set. Also disables NSE POW calculation. |
122 | # | 122 | # |
123 | # This configuration is included from various configuration test files. | 123 | # This configuration is included from various configuration test files. |
124 | # Whenever a new service is added that has FORCESTART = YES for | 124 | # Whenever a new service is added that has IMMEDIATE_START = YES for |
125 | # production should be disabled for (most) test suites, the option should | 125 | # production should be disabled for (most) test suites, the option should |
126 | # be added here instead of all over the place ;-). | 126 | # be added here instead of all over the place ;-). |
127 | 127 | ||
128 | [core] | 128 | [core] |
129 | FORCESTART = NO | 129 | IMMEDIATE_START = NO |
130 | 130 | ||
131 | [fs] | 131 | [fs] |
132 | FORCESTART = NO | 132 | IMMEDIATE_START = NO |
133 | 133 | ||
134 | [dht] | 134 | [dht] |
135 | FORCESTART = NO | 135 | IMMEDIATE_START = NO |
136 | 136 | ||
137 | [cadet] | 137 | [cadet] |
138 | FORCESTART = NO | 138 | IMMEDIATE_START = NO |
139 | 139 | ||
140 | [nse] | 140 | [nse] |
141 | FORCESTART = NO | 141 | IMMEDIATE_START = NO |
142 | WORKBITS = 0 | 142 | WORKBITS = 0 |
143 | 143 | ||
144 | [revocation] | 144 | [revocation] |
145 | FORCESTART = NO | 145 | IMMEDIATE_START = NO |
146 | 146 | ||
147 | [topology] | 147 | [topology] |
148 | FORCESTART = NO | 148 | IMMEDIATE_START = NO |
149 | 149 | ||
150 | [hostlist] | 150 | [hostlist] |
151 | FORCESTART = NO | 151 | IMMEDIATE_START = NO |
152 | 152 | ||
153 | [gns] | 153 | [gns] |
154 | FORCESTART = NO | 154 | IMMEDIATE_START = NO |
155 | 155 | ||
156 | [zonemaster] | 156 | [zonemaster] |
157 | FORCESTART = NO \ No newline at end of file | 157 | IMMEDIATE_START = NO |
diff --git a/src/dht/test_dht_tools.py.in b/src/dht/test_dht_tools.py.in index 2d4ab9adc..05582cbd0 100644 --- a/src/dht/test_dht_tools.py.in +++ b/src/dht/test_dht_tools.py.in | |||
@@ -21,105 +21,113 @@ import subprocess | |||
21 | import time | 21 | import time |
22 | import tempfile | 22 | import tempfile |
23 | 23 | ||
24 | os.environ["PATH"] = "@bindir@" + ":" + os.environ["PATH"]; | 24 | os.environ["PATH"] = "@bindir@" + ":" + os.environ["PATH"] |
25 | 25 | ||
26 | if os.name == "nt": | 26 | if os.name == "nt": |
27 | tmp = os.getenv ("TEMP") | 27 | tmp = os.getenv("TEMP") |
28 | else: | 28 | else: |
29 | tmp = "/tmp" | 29 | tmp = "/tmp" |
30 | 30 | ||
31 | if os.name == 'nt': | 31 | if os.name == 'nt': |
32 | get = './gnunet-dht-get.exe' | 32 | get = './gnunet-dht-get.exe' |
33 | put = './gnunet-dht-put.exe' | 33 | put = './gnunet-dht-put.exe' |
34 | arm = 'gnunet-arm.exe' | 34 | arm = 'gnunet-arm.exe' |
35 | else: | 35 | else: |
36 | get = './gnunet-dht-get' | 36 | get = './gnunet-dht-get' |
37 | put = './gnunet-dht-put' | 37 | put = './gnunet-dht-put' |
38 | arm = 'gnunet-arm' | 38 | arm = 'gnunet-arm' |
39 | 39 | ||
40 | cfgfile = 'test_dht_api_peer1.conf' | 40 | cfgfile = 'test_dht_api_peer1.conf' |
41 | |||
42 | run_get = [get, '-c', cfgfile] | 41 | run_get = [get, '-c', cfgfile] |
43 | run_put = [put, '-c', cfgfile] | 42 | run_put = [put, '-c', cfgfile] |
44 | run_arm = [arm, '-c', cfgfile] | 43 | run_arm = [arm, '-c', cfgfile] |
45 | debug = os.getenv ('DEBUG') | 44 | debug = os.getenv('DEBUG') |
46 | if debug: | 45 | if debug: |
47 | run_arm += [debug.split (' ')] | 46 | run_arm += [debug.split(' ')] |
48 | 47 | ||
49 | def cleanup (exitcode): | 48 | |
50 | sys.exit (exitcode) | 49 | def cleanup(exitcode): |
51 | 50 | sys.exit(exitcode) | |
52 | def sub_run (args, want_stdo = True, want_stde = False, nofail = False): | 51 | |
53 | if want_stdo: | 52 | |
54 | stdo = subprocess.PIPE | 53 | def sub_run(args, want_stdo=True, want_stde=False, nofail=False): |
55 | else: | 54 | if want_stdo: |
56 | stdo = None | 55 | stdo = subprocess.PIPE |
57 | if want_stde: | 56 | else: |
58 | stde = subprocess.PIPE | 57 | stdo = None |
59 | else: | 58 | if want_stde: |
60 | stde = None | 59 | stde = subprocess.PIPE |
61 | p = subprocess.Popen (args, stdout = stdo, stderr = stde) | 60 | else: |
62 | stdo, stde = p.communicate () | 61 | stde = None |
63 | if not nofail: | 62 | p = subprocess.Popen(args, stdout=stdo, stderr=stde) |
64 | if p.returncode != 0: | 63 | stdo, stde = p.communicate() |
65 | sys.exit (p.returncode) | 64 | if not nofail: |
66 | return (p.returncode, stdo, stde) | 65 | if p.returncode != 0: |
67 | 66 | sys.exit(p.returncode) | |
68 | def fail (result): | 67 | return (p.returncode, stdo, stde) |
69 | print (result) | 68 | |
70 | r_arm (['-e'], want_stdo = False) | 69 | |
71 | cleanup (1) | 70 | def fail(result): |
72 | 71 | print(result) | |
73 | def r_something (to_run, extra_args, failer = None, normal = True, **kw): | 72 | r_arm(['-e'], want_stdo=False) |
74 | rc, stdo, stde = sub_run (to_run + extra_args, nofail = True, **kw) | 73 | cleanup(1) |
75 | if failer is not None: | 74 | |
76 | failer (to_run + extra_args, rc, stdo, stde, normal) | 75 | |
77 | return (rc, stdo, stde) | 76 | def r_something(to_run, extra_args, failer=None, normal=True, **kw): |
78 | 77 | rc, stdo, stde = sub_run(to_run + extra_args, nofail=True, **kw) | |
79 | def r_arm (extra_args, **kw): | 78 | if failer is not None: |
80 | return r_something (run_arm, extra_args, **kw) | 79 | failer(to_run + extra_args, rc, stdo, stde, normal) |
81 | 80 | return (rc, stdo, stde) | |
82 | def r_get (extra_args, **kw): | 81 | |
83 | return r_something (run_get, extra_args, **kw) | 82 | |
84 | 83 | def r_arm(extra_args, **kw): | |
85 | def r_put (extra_args, **kw): | 84 | return r_something(run_arm, extra_args, **kw) |
86 | return r_something (run_put, extra_args, **kw) | 85 | |
87 | 86 | ||
88 | def end_arm_failer (command, rc, stdo, stde, normal): | 87 | def r_get(extra_args, **kw): |
89 | if normal: | 88 | return r_something(run_get, extra_args, **kw) |
90 | if rc != 0: | 89 | |
91 | fail ("FAIL: error running {}\nCommand output was:\n{}\n{}".format (command, stdo, stde)) | 90 | |
92 | else: | 91 | def r_put(extra_args, **kw): |
93 | if rc == 0: | 92 | return r_something(run_put, extra_args, **kw) |
94 | fail ("FAIL: expected error while running {}\nCommand output was:\n{}\n{}".format (command, stdo, stde)) | 93 | |
95 | 94 | ||
96 | def print_only_failer (command, rc, stdo, stde, normal): | 95 | def end_arm_failer(command, rc, stdo, stde, normal): |
97 | if normal: | 96 | if normal: |
98 | if rc != 0: | 97 | if rc != 0: |
99 | print ("FAIL: error running {}\nCommand output was:\n{}\n{}".format (command, stdo, stde)) | 98 | fail("FAIL: error running {}\nCommand output was:\n{}\n{}".format(command, stdo, stde)) |
100 | cleanup (1) | 99 | else: |
101 | else: | 100 | if rc == 0: |
102 | if rc == 0: | 101 | fail("FAIL: expected error while running {}\nCommand output was:\n{}\n{}".format(command, stdo, stde)) |
103 | print ("FAIL: expected error while running {}\nCommand output was:\n{}\n{}".format (command, stdo, stde)) | 102 | |
104 | cleanup (1) | 103 | |
105 | 104 | def print_only_failer(command, rc, stdo, stde, normal): | |
106 | 105 | if normal: | |
107 | print ("TEST: Starting ARM...", end='') | 106 | if rc != 0: |
108 | r_arm (['-s'], failer = end_arm_failer, want_stdo = False, want_stde = False) | 107 | print("FAIL: error running {}\nCommand output was:\n{}\n{}".format(command, stdo, stde)) |
109 | print ("PASS") | 108 | cleanup(1) |
110 | time.sleep (1) | 109 | else: |
111 | 110 | if rc == 0: | |
112 | print ("TEST: Testing put...", end='') | 111 | print("FAIL: expected error while running {}\nCommand output was:\n{}\n{}".format(command, stdo, stde)) |
113 | r_put (['-k', 'testkey', '-d', 'testdata', '-t', '8'], failer = end_arm_failer) | 112 | cleanup(1) |
114 | print ("PASS") | 113 | |
115 | time.sleep (1) | 114 | |
116 | 115 | print("TEST: Starting ARM...", end='') | |
117 | print ("TEST: Testing get...", end='') | 116 | r_arm(['-s'], failer=end_arm_failer, want_stdo=False, want_stde=False) |
118 | rc, stdo, stde = r_get (['-k', 'testkey', '-T', '50 ms', '-t', '8'], want_stdo = True, failer = end_arm_failer) | 117 | print("PASS") |
119 | stdo = stdo.replace ('\r', '').splitlines () | 118 | time.sleep(1) |
119 | |||
120 | print("TEST: Testing put...", end='') | ||
121 | r_put(['-k', 'testkey', '-d', 'testdata', '-t', '8'], failer=end_arm_failer) | ||
122 | print("PASS") | ||
123 | time.sleep(1) | ||
124 | |||
125 | print("TEST: Testing get...", end='') | ||
126 | rc, stdo, stde = r_get(['-k', 'testkey', '-T', '50 ms', '-t', '8'], want_stdo=True, failer=end_arm_failer) | ||
127 | stdo = stdo.replace('\r', '').splitlines() | ||
120 | expect = "Result 0, type 8:\ntestdata".splitlines() | 128 | expect = "Result 0, type 8:\ntestdata".splitlines() |
121 | if len (stdo) != 2 or len (expect) != 2 or stdo[0] != expect[0] or stdo[1] != expect[1]: | 129 | if len(stdo) != 2 or len(expect) != 2 or stdo[0] != expect[0] or stdo[1] != expect[1]: |
122 | fail ("output `{}' differs from expected `{}'".format (stdo, expect)) | 130 | fail("output `{}' differs from expected `{}'".format(stdo, expect)) |
123 | print ("PASS") | 131 | print("PASS") |
124 | 132 | ||
125 | r_arm (['-e', '-d'], failer = print_only_failer) | 133 | r_arm(['-e', '-d'], failer=print_only_failer) |
diff --git a/src/dht/test_dht_topo.c b/src/dht/test_dht_topo.c index 79edb2b0c..e09a3be67 100644 --- a/src/dht/test_dht_topo.c +++ b/src/dht/test_dht_topo.c | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2012, 2016 GNUnet e.V. | 3 | Copyright (C) 2012, 2016 GNUnet e.V. |
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 it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | /** | 18 | /** |
21 | * @file dht/test_dht_topo.c | 19 | * @file dht/test_dht_topo.c |