aboutsummaryrefslogtreecommitdiff
path: root/src/hostlist
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-06-03 08:41:00 +0000
committerChristian Grothoff <christian@grothoff.org>2014-06-03 08:41:00 +0000
commitaf4dff0ff8a129c05c75180446b691a0b2cd74c7 (patch)
treec3c02b821df02ea396e64a9b9a06ea9e9e85553b /src/hostlist
parentd7cf4a2a573e31c21630c08b038c2c648e5d3785 (diff)
downloadgnunet-af4dff0ff8a129c05c75180446b691a0b2cd74c7.tar.gz
gnunet-af4dff0ff8a129c05c75180446b691a0b2cd74c7.zip
-doxygen, code cleanup
Diffstat (limited to 'src/hostlist')
-rw-r--r--src/hostlist/Makefile.am5
-rw-r--r--src/hostlist/gnunet-daemon-hostlist.c48
-rw-r--r--src/hostlist/gnunet-daemon-hostlist.h14
-rw-r--r--src/hostlist/gnunet-daemon-hostlist_client.c (renamed from src/hostlist/hostlist-client.c)130
-rw-r--r--src/hostlist/gnunet-daemon-hostlist_client.h (renamed from src/hostlist/hostlist-client.h)67
-rw-r--r--src/hostlist/gnunet-daemon-hostlist_server.c (renamed from src/hostlist/hostlist-server.c)144
-rw-r--r--src/hostlist/gnunet-daemon-hostlist_server.h (renamed from src/hostlist/hostlist-server.h)17
-rw-r--r--src/hostlist/test_gnunet_daemon_hostlist_learning.c6
8 files changed, 272 insertions, 159 deletions
diff --git a/src/hostlist/Makefile.am b/src/hostlist/Makefile.am
index e647169c0..d777cd658 100644
--- a/src/hostlist/Makefile.am
+++ b/src/hostlist/Makefile.am
@@ -12,7 +12,8 @@ if USE_COVERAGE
12endif 12endif
13 13
14if HAVE_MHD 14if HAVE_MHD
15 HOSTLIST_SERVER_SOURCES = hostlist-server.c hostlist-server.h 15 HOSTLIST_SERVER_SOURCES = \
16 gnunet-daemon-hostlist_server.c gnunet-daemon-hostlist_server.h
16 GN_LIBMHD = -lmicrohttpd 17 GN_LIBMHD = -lmicrohttpd
17endif 18endif
18 19
@@ -23,7 +24,7 @@ endif
23 24
24gnunet_daemon_hostlist_SOURCES = \ 25gnunet_daemon_hostlist_SOURCES = \
25 gnunet-daemon-hostlist.c gnunet-daemon-hostlist.h \ 26 gnunet-daemon-hostlist.c gnunet-daemon-hostlist.h \
26 hostlist-client.c hostlist-client.h \ 27 gnunet-daemon-hostlist_client.c gnunet-daemon-hostlist_client.h \
27 $(HOSTLIST_SERVER_SOURCES) 28 $(HOSTLIST_SERVER_SOURCES)
28 29
29gnunet_daemon_hostlist_LDADD = \ 30gnunet_daemon_hostlist_LDADD = \
diff --git a/src/hostlist/gnunet-daemon-hostlist.c b/src/hostlist/gnunet-daemon-hostlist.c
index a93d7e37d..62ecc5dfd 100644
--- a/src/hostlist/gnunet-daemon-hostlist.c
+++ b/src/hostlist/gnunet-daemon-hostlist.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2007, 2008, 2009 Christian Grothoff (and other contributing authors) 3 (C) 2007, 2008, 2009, 2014 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -23,10 +23,8 @@
23 * @brief code for bootstrapping via hostlist servers 23 * @brief code for bootstrapping via hostlist servers
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
27#include <stdlib.h>
28#include "platform.h" 26#include "platform.h"
29#include "hostlist-client.h" 27#include "gnunet-daemon-hostlist_client.h"
30#include "gnunet_core_service.h" 28#include "gnunet_core_service.h"
31#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
32#include "gnunet_protocols.h" 30#include "gnunet_protocols.h"
@@ -34,7 +32,7 @@
34 32
35#if HAVE_MHD 33#if HAVE_MHD
36 34
37#include "hostlist-server.h" 35#include "gnunet-daemon-hostlist_server.h"
38 36
39/** 37/**
40 * Set if we are allowed to advertise our hostlist to others. 38 * Set if we are allowed to advertise our hostlist to others.
@@ -123,9 +121,19 @@ struct GNUNET_HOSTLIST_ADV_Message
123}; 121};
124GNUNET_NETWORK_STRUCT_END 122GNUNET_NETWORK_STRUCT_END
125 123
124
125/**
126 * Our own peer identity.
127 */
126static struct GNUNET_PeerIdentity me; 128static struct GNUNET_PeerIdentity me;
127 129
128 130
131/**
132 * Callback invoked once our connection to CORE service is up.
133 *
134 * @param cls NULL
135 * @param my_identity our peer's identity
136 */
129static void 137static void
130core_init (void *cls, 138core_init (void *cls,
131 const struct GNUNET_PeerIdentity *my_identity) 139 const struct GNUNET_PeerIdentity *my_identity)
@@ -143,7 +151,8 @@ core_init (void *cls,
143 * @return #GNUNET_OK on success 151 * @return #GNUNET_OK on success
144 */ 152 */
145static int 153static int
146advertisement_handler (void *cls, const struct GNUNET_PeerIdentity *peer, 154advertisement_handler (void *cls,
155 const struct GNUNET_PeerIdentity *peer,
147 const struct GNUNET_MessageHeader *message) 156 const struct GNUNET_MessageHeader *message)
148{ 157{
149 GNUNET_assert (NULL != client_adv_handler); 158 GNUNET_assert (NULL != client_adv_handler);
@@ -182,7 +191,8 @@ connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer)
182 * @param peer peer identity this notification is about 191 * @param peer peer identity this notification is about
183 */ 192 */
184static void 193static void
185disconnect_handler (void *cls, const struct GNUNET_PeerIdentity *peer) 194disconnect_handler (void *cls,
195 const struct GNUNET_PeerIdentity *peer)
186{ 196{
187 if (0 == memcmp (&me, peer, sizeof (struct GNUNET_PeerIdentity))) 197 if (0 == memcmp (&me, peer, sizeof (struct GNUNET_PeerIdentity)))
188 return; 198 return;
@@ -200,13 +210,17 @@ disconnect_handler (void *cls, const struct GNUNET_PeerIdentity *peer)
200/** 210/**
201 * Last task run during shutdown. Disconnects us from 211 * Last task run during shutdown. Disconnects us from
202 * the other services. 212 * the other services.
213 *
214 * @param cls NULL
215 * @param tc scheduler context
203 */ 216 */
204static void 217static void
205cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 218cleaning_task (void *cls,
219 const struct GNUNET_SCHEDULER_TaskContext *tc)
206{ 220{
207 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 221 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
208 "Hostlist daemon is shutting down\n"); 222 "Hostlist daemon is shutting down\n");
209 if (core != NULL) 223 if (NULL != core)
210 { 224 {
211 GNUNET_CORE_disconnect (core); 225 GNUNET_CORE_disconnect (core);
212 core = NULL; 226 core = NULL;
@@ -221,7 +235,7 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
221 GNUNET_HOSTLIST_server_stop (); 235 GNUNET_HOSTLIST_server_stop ();
222 } 236 }
223#endif 237#endif
224 if (stats != NULL) 238 if (NULL != stats)
225 { 239 {
226 GNUNET_STATISTICS_destroy (stats, GNUNET_NO); 240 GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
227 stats = NULL; 241 stats = NULL;
@@ -238,7 +252,9 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
238 * @param cfg configuration 252 * @param cfg configuration
239 */ 253 */
240static void 254static void
241run (void *cls, char *const *args, const char *cfgfile, 255run (void *cls,
256 char *const *args,
257 const char *cfgfile,
242 const struct GNUNET_CONFIGURATION_Handle *cfg) 258 const struct GNUNET_CONFIGURATION_Handle *cfg)
243{ 259{
244 static const struct GNUNET_CORE_MessageHandler learn_handlers[] = { 260 static const struct GNUNET_CORE_MessageHandler learn_handlers[] = {
@@ -248,15 +264,14 @@ run (void *cls, char *const *args, const char *cfgfile,
248 static const struct GNUNET_CORE_MessageHandler no_learn_handlers[] = { 264 static const struct GNUNET_CORE_MessageHandler no_learn_handlers[] = {
249 {NULL, 0, 0} 265 {NULL, 0, 0}
250 }; 266 };
251 if ((!bootstrapping) && (!learning) 267 if ((! bootstrapping) && (! learning)
252#if HAVE_MHD 268#if HAVE_MHD
253 && (!provide_hostlist) 269 && (! provide_hostlist)
254#endif 270#endif
255 ) 271 )
256 { 272 {
257 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 273 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
258 _ 274 _("None of the functions for the hostlist daemon were enabled. I have no reason to run!\n"));
259 ("None of the functions for the hostlist daemon were enabled. I have no reason to run!\n"));
260 return; 275 return;
261 } 276 }
262 stats = GNUNET_STATISTICS_create ("hostlist", cfg); 277 stats = GNUNET_STATISTICS_create ("hostlist", cfg);
@@ -332,7 +347,8 @@ main (int argc, char *const *argv)
332 ret = 347 ret =
333 (GNUNET_OK == 348 (GNUNET_OK ==
334 GNUNET_PROGRAM_run (argc, argv, "hostlist", 349 GNUNET_PROGRAM_run (argc, argv, "hostlist",
335 _("GNUnet hostlist server and client"), options, 350 _("GNUnet hostlist server and client"),
351 options,
336 &run, NULL)) ? 0 : 1; 352 &run, NULL)) ? 0 : 1;
337 GNUNET_free ((void*) argv); 353 GNUNET_free ((void*) argv);
338 return ret; 354 return ret;
diff --git a/src/hostlist/gnunet-daemon-hostlist.h b/src/hostlist/gnunet-daemon-hostlist.h
index 8c9824e0c..ca9895dad 100644
--- a/src/hostlist/gnunet-daemon-hostlist.h
+++ b/src/hostlist/gnunet-daemon-hostlist.h
@@ -25,23 +25,19 @@
25 */ 25 */
26#include <stdlib.h> 26#include <stdlib.h>
27#include "platform.h" 27#include "platform.h"
28#include "hostlist-client.h"
29#include "hostlist-server.h"
30#include "gnunet_core_service.h" 28#include "gnunet_core_service.h"
31#include "gnunet_getopt_lib.h"
32#include "gnunet_protocols.h" 29#include "gnunet_protocols.h"
33#include "gnunet_program_lib.h"
34#include "gnunet_statistics_service.h" 30#include "gnunet_statistics_service.h"
35#include "gnunet_strings_lib.h"
36#include "gnunet_time_lib.h"
37#include "gnunet_util_lib.h" 31#include "gnunet_util_lib.h"
38 32
39/** 33/**
40 * General hostlist daemon debugging. 34 * How long can hostlist URLs be?
41 */ 35 */
42#define DEBUG_HOSTLIST GNUNET_EXTRA_LOGGING
43
44#define MAX_URL_LEN 1000 36#define MAX_URL_LEN 1000
37
38/**
39 * How many bytes do we download at most from a hostlist server?
40 */
45#define MAX_BYTES_PER_HOSTLISTS 500000 41#define MAX_BYTES_PER_HOSTLISTS 500000
46 42
47/* end of gnunet-daemon-hostlist.h */ 43/* end of gnunet-daemon-hostlist.h */
diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/gnunet-daemon-hostlist_client.c
index d4096abc0..20bd8bedd 100644
--- a/src/hostlist/hostlist-client.c
+++ b/src/hostlist/gnunet-daemon-hostlist_client.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2010 Christian Grothoff (and other contributing authors) 3 (C) 2001-2010, 2014 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -17,23 +17,19 @@
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20
21/** 20/**
22 * @file hostlist/hostlist-client.c 21 * @file hostlist/gnunet-daemon-hostlist_client.c
23 * @brief hostlist support. Downloads HELLOs via HTTP. 22 * @brief hostlist support. Downloads HELLOs via HTTP.
24 * @author Christian Grothoff 23 * @author Christian Grothoff
25 * @author Matthias Wachs 24 * @author Matthias Wachs
26 */ 25 */
27
28#include "platform.h" 26#include "platform.h"
29#include "hostlist-client.h" 27#include "gnunet-daemon-hostlist_client.h"
30#include "gnunet_core_service.h"
31#include "gnunet_hello_lib.h" 28#include "gnunet_hello_lib.h"
32#include "gnunet_statistics_service.h" 29#include "gnunet_statistics_service.h"
33#include "gnunet_transport_service.h" 30#include "gnunet_transport_service.h"
34#include "gnunet-daemon-hostlist.h" 31#include "gnunet-daemon-hostlist.h"
35#include <curl/curl.h> 32#include <curl/curl.h>
36#include "gnunet_util_lib.h"
37 33
38 34
39/** 35/**
@@ -43,9 +39,50 @@
43#define MIN_CONNECTIONS 4 39#define MIN_CONNECTIONS 4
44 40
45/** 41/**
46 * Interval between two advertised hostlist tests 42 * Maximum number of hostlist that are saved
43 */
44#define MAX_NUMBER_HOSTLISTS 30
45
46/**
47 * Time interval hostlists are saved to disk
48 */
49#define SAVING_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 30)
50
51/**
52 * Time interval between two hostlist tests
53 */
54#define TESTING_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3)
55
56/**
57 * Time interval for download dispatcher before a download is re-scheduled
58 */
59#define WAITING_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
60
61/**
62 * Defines concerning the hostlist quality metric
63 */
64
65/**
66 * Initial quality of a new created hostlist
67 */
68#define HOSTLIST_INITIAL 10000
69
70/**
71 * Value subtracted each time a hostlist download fails
47 */ 72 */
48#define TESTING_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) 73#define HOSTLIST_FAILED_DOWNLOAD 100
74
75/**
76 * Value added each time a hostlist download is successful
77 */
78#define HOSTLIST_SUCCESSFUL_DOWNLOAD 100
79
80/**
81 * Value added for each valid HELLO recived during a hostlist download
82 */
83#define HOSTLIST_SUCCESSFUL_HELLO 1
84
85
49 86
50/** 87/**
51 * A single hostlist obtained by hostlist advertisements 88 * A single hostlist obtained by hostlist advertisements
@@ -281,7 +318,10 @@ static unsigned int stat_connection_count;
281 * @return number of bytes that were processed (always size*nmemb) 318 * @return number of bytes that were processed (always size*nmemb)
282 */ 319 */
283static size_t 320static size_t
284callback_download (void *ptr, size_t size, size_t nmemb, void *ctx) 321callback_download (void *ptr,
322 size_t size,
323 size_t nmemb,
324 void *ctx)
285{ 325{
286 static char download_buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1]; 326 static char download_buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1];
287 const char *cbuf = ptr; 327 const char *cbuf = ptr;
@@ -486,6 +526,7 @@ download_get_url ()
486 526
487/** 527/**
488 * Method to save hostlist to a file during hostlist client shutdown 528 * Method to save hostlist to a file during hostlist client shutdown
529 *
489 * @param shutdown set if called because of shutdown, entries in linked list will be destroyed 530 * @param shutdown set if called because of shutdown, entries in linked list will be destroyed
490 */ 531 */
491static void 532static void
@@ -493,14 +534,15 @@ save_hostlist_file (int shutdown);
493 534
494 535
495/** 536/**
496 * add val2 to val1 with overflow check 537 * Add val2 to val1 with overflow check
497 * 538 *
498 * @param val1 value 1 539 * @param val1 value 1
499 * @param val2 value 2 540 * @param val2 value 2
500 * @return result 541 * @return result
501 */ 542 */
502static uint64_t 543static uint64_t
503checked_add (uint64_t val1, uint64_t val2) 544checked_add (uint64_t val1,
545 uint64_t val2)
504{ 546{
505 static uint64_t temp; 547 static uint64_t temp;
506 static uint64_t maxv; 548 static uint64_t maxv;
@@ -523,7 +565,8 @@ checked_add (uint64_t val1, uint64_t val2)
523 * @return result 565 * @return result
524 */ 566 */
525static uint64_t 567static uint64_t
526checked_sub (uint64_t val1, uint64_t val2) 568checked_sub (uint64_t val1,
569 uint64_t val2)
527{ 570{
528 if (val1 <= val2) 571 if (val1 <= val2)
529 return 0; 572 return 0;
@@ -726,7 +769,8 @@ clean_up ()
726 * @param tc task context, unused 769 * @param tc task context, unused
727 */ 770 */
728static void 771static void
729task_download (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 772task_download (void *cls,
773 const struct GNUNET_SCHEDULER_TaskContext *tc);
730 774
731 775
732/** 776/**
@@ -795,7 +839,8 @@ download_prepare ()
795 * @param tc task context, unused 839 * @param tc task context, unused
796 */ 840 */
797static void 841static void
798task_download (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 842task_download (void *cls,
843 const struct GNUNET_SCHEDULER_TaskContext *tc)
799{ 844{
800 int running; 845 int running;
801 struct CURLMsg *msg; 846 struct CURLMsg *msg;
@@ -968,10 +1013,6 @@ download_hostlist ()
968 CURL_EASY_SETOPT (curl, CURLOPT_USERAGENT, "GNUnet"); 1013 CURL_EASY_SETOPT (curl, CURLOPT_USERAGENT, "GNUnet");
969 CURL_EASY_SETOPT (curl, CURLOPT_CONNECTTIMEOUT, 60L); 1014 CURL_EASY_SETOPT (curl, CURLOPT_CONNECTTIMEOUT, 60L);
970 CURL_EASY_SETOPT (curl, CURLOPT_TIMEOUT, 60L); 1015 CURL_EASY_SETOPT (curl, CURLOPT_TIMEOUT, 60L);
971#if 0
972 /* this should no longer be needed; we're now single-threaded! */
973 CURL_EASY_SETOPT (curl, CURLOPT_NOSIGNAL, 1);
974#endif
975 multi = curl_multi_init (); 1016 multi = curl_multi_init ();
976 if (multi == NULL) 1017 if (multi == NULL)
977 { 1018 {
@@ -1017,7 +1058,7 @@ task_download_dispatcher (void *cls,
1017 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1058 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1018 "Download in progess, have to wait...\n"); 1059 "Download in progess, have to wait...\n");
1019 ti_download_dispatcher_task = 1060 ti_download_dispatcher_task =
1020 GNUNET_SCHEDULER_add_delayed (WAITING_INTERVALL, 1061 GNUNET_SCHEDULER_add_delayed (WAITING_INTERVAL,
1021 &task_download_dispatcher, NULL); 1062 &task_download_dispatcher, NULL);
1022 } 1063 }
1023} 1064}
@@ -1110,9 +1151,9 @@ task_hostlist_saving (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1110 1151
1111 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1152 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1112 "Hostlists will be saved to file again in %s\n", 1153 "Hostlists will be saved to file again in %s\n",
1113 GNUNET_STRINGS_relative_time_to_string(SAVING_INTERVALL, GNUNET_YES)); 1154 GNUNET_STRINGS_relative_time_to_string(SAVING_INTERVAL, GNUNET_YES));
1114 ti_saving_task = 1155 ti_saving_task =
1115 GNUNET_SCHEDULER_add_delayed (SAVING_INTERVALL, &task_hostlist_saving, 1156 GNUNET_SCHEDULER_add_delayed (SAVING_INTERVAL, &task_hostlist_saving,
1116 NULL); 1157 NULL);
1117} 1158}
1118 1159
@@ -1257,11 +1298,14 @@ primary_task (void *cls, int success)
1257 * @param subsystem should be "hostlist", unused 1298 * @param subsystem should be "hostlist", unused
1258 * @param name will be "milliseconds between hostlist downloads", unused 1299 * @param name will be "milliseconds between hostlist downloads", unused
1259 * @param value previous delay value, in milliseconds (!) 1300 * @param value previous delay value, in milliseconds (!)
1260 * @param is_persistent unused, will be GNUNET_YES 1301 * @param is_persistent unused, will be #GNUNET_YES
1261 */ 1302 */
1262static int 1303static int
1263process_stat (void *cls, const char *subsystem, const char *name, 1304process_stat (void *cls,
1264 uint64_t value, int is_persistent) 1305 const char *subsystem,
1306 const char *name,
1307 uint64_t value,
1308 int is_persistent)
1265{ 1309{
1266 hostlist_delay.rel_value_us = value * 1000LL; 1310 hostlist_delay.rel_value_us = value * 1000LL;
1267 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1311 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1287,6 +1331,7 @@ load_hostlist_file ()
1287 uint64_t last_used; 1331 uint64_t last_used;
1288 uint64_t created; 1332 uint64_t created;
1289 uint32_t counter; 1333 uint32_t counter;
1334 struct GNUNET_BIO_ReadHandle *rh;
1290 1335
1291 uri = NULL; 1336 uri = NULL;
1292 if (GNUNET_OK != 1337 if (GNUNET_OK !=
@@ -1309,13 +1354,11 @@ load_hostlist_file ()
1309 return; 1354 return;
1310 } 1355 }
1311 1356
1312 struct GNUNET_BIO_ReadHandle *rh = GNUNET_BIO_read_open (filename); 1357 rh = GNUNET_BIO_read_open (filename);
1313
1314 if (NULL == rh) 1358 if (NULL == rh)
1315 { 1359 {
1316 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1360 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1317 _ 1361 _("Could not open file `%s' for reading to load hostlists: %s\n"),
1318 ("Could not open file `%s' for reading to load hostlists: %s\n"),
1319 filename, STRERROR (errno)); 1362 filename, STRERROR (errno));
1320 GNUNET_free (filename); 1363 GNUNET_free (filename);
1321 return; 1364 return;
@@ -1348,11 +1391,14 @@ load_hostlist_file ()
1348 break; 1391 break;
1349 } 1392 }
1350 1393
1351 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("%u hostlist URIs loaded from file\n"), 1394 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1395 _("%u hostlist URIs loaded from file\n"),
1352 counter); 1396 counter);
1353 GNUNET_STATISTICS_set (stats, gettext_noop ("# hostlist URIs read from file"), 1397 GNUNET_STATISTICS_set (stats,
1398 gettext_noop ("# hostlist URIs read from file"),
1354 counter, GNUNET_YES); 1399 counter, GNUNET_YES);
1355 GNUNET_STATISTICS_set (stats, gettext_noop ("# advertised hostlist URIs"), 1400 GNUNET_STATISTICS_set (stats,
1401 gettext_noop ("# advertised hostlist URIs"),
1356 linked_list_size, GNUNET_NO); 1402 linked_list_size, GNUNET_NO);
1357 1403
1358 GNUNET_free_non_null (uri); 1404 GNUNET_free_non_null (uri);
@@ -1366,6 +1412,7 @@ load_hostlist_file ()
1366 1412
1367/** 1413/**
1368 * Method to save persistent hostlist file during hostlist client shutdown 1414 * Method to save persistent hostlist file during hostlist client shutdown
1415 *
1369 * @param shutdown set if called because of shutdown, entries in linked list will be destroyed 1416 * @param shutdown set if called because of shutdown, entries in linked list will be destroyed
1370 */ 1417 */
1371static void 1418static void
@@ -1448,13 +1495,22 @@ save_hostlist_file (int shutdown)
1448 1495
1449/** 1496/**
1450 * Start downloading hostlists from hostlist servers as necessary. 1497 * Start downloading hostlists from hostlist servers as necessary.
1498 *
1499 * @param c configuration to use
1500 * @param st statistics handle to use
1501 * @param ch[OUT] set to handler for CORE connect events
1502 * @param dh[OUT] set to handler for CORE disconnect events
1503 * @param msgh[OUT] set to handler for CORE advertisement messages
1504 * @param learn should we learn hostlist URLs from CORE
1505 * @return #GNUNET_OK on success
1451 */ 1506 */
1452int 1507int
1453GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, 1508GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c,
1454 struct GNUNET_STATISTICS_Handle *st, 1509 struct GNUNET_STATISTICS_Handle *st,
1455 GNUNET_CORE_ConnectEventHandler *ch, 1510 GNUNET_CORE_ConnectEventHandler *ch,
1456 GNUNET_CORE_DisconnectEventHandler *dh, 1511 GNUNET_CORE_DisconnectEventHandler *dh,
1457 GNUNET_CORE_MessageCallback *msgh, int learn) 1512 GNUNET_CORE_MessageCallback *msgh,
1513 int learn)
1458{ 1514{
1459 char *filename; 1515 char *filename;
1460 char *proxytype_str; 1516 char *proxytype_str;
@@ -1556,9 +1612,9 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c,
1556 load_hostlist_file (); 1612 load_hostlist_file ();
1557 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1613 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1558 "Hostlists will be saved to file again in %s\n", 1614 "Hostlists will be saved to file again in %s\n",
1559 GNUNET_STRINGS_relative_time_to_string (SAVING_INTERVALL, GNUNET_YES)); 1615 GNUNET_STRINGS_relative_time_to_string (SAVING_INTERVAL, GNUNET_YES));
1560 ti_saving_task = 1616 ti_saving_task =
1561 GNUNET_SCHEDULER_add_delayed (SAVING_INTERVALL, &task_hostlist_saving, 1617 GNUNET_SCHEDULER_add_delayed (SAVING_INTERVAL, &task_hostlist_saving,
1562 NULL); 1618 NULL);
1563 } 1619 }
1564 else 1620 else
@@ -1636,7 +1692,7 @@ GNUNET_HOSTLIST_client_stop ()
1636 ti_check_download = GNUNET_SCHEDULER_NO_TASK; 1692 ti_check_download = GNUNET_SCHEDULER_NO_TASK;
1637 curl_global_cleanup (); 1693 curl_global_cleanup ();
1638 } 1694 }
1639 if (transport != NULL) 1695 if (NULL != transport)
1640 { 1696 {
1641 GNUNET_TRANSPORT_disconnect (transport); 1697 GNUNET_TRANSPORT_disconnect (transport);
1642 transport = NULL; 1698 transport = NULL;
@@ -1651,4 +1707,4 @@ GNUNET_HOSTLIST_client_stop ()
1651 cfg = NULL; 1707 cfg = NULL;
1652} 1708}
1653 1709
1654/* end of hostlist-client.c */ 1710/* end of gnunet-daemon-hostlist_client.c */
diff --git a/src/hostlist/hostlist-client.h b/src/hostlist/gnunet-daemon-hostlist_client.h
index 3def865e4..55f355649 100644
--- a/src/hostlist/hostlist-client.h
+++ b/src/hostlist/gnunet-daemon-hostlist_client.h
@@ -17,65 +17,17 @@
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20
21/** 20/**
22 * @file hostlist/hostlist-client.h 21 * @file hostlist/gnunet-daemon-hostlist_client.h
23 * @brief hostlist support. Downloads HELLOs via HTTP. 22 * @brief hostlist support. Downloads HELLOs via HTTP.
24 * @author Christian Grothoff 23 * @author Christian Grothoff
25 */ 24 */
26 25#ifndef GNUNET_DAEMON_HOSTLIST_CLIENT_H
27#ifndef HOSTLIST_CLIENT_H 26#define GNUNET_DAEMON_HOSTLIST_CLIENT_H
28#define HOSTLIST_CLIENT_H
29 27
30#include "gnunet_core_service.h" 28#include "gnunet_core_service.h"
31#include "gnunet_statistics_service.h" 29#include "gnunet_statistics_service.h"
32#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
33#include "gnunet_time_lib.h"
34
35/**
36 * Maximum number of hostlist that are saved
37 */
38#define MAX_NUMBER_HOSTLISTS 30
39
40/**
41 * Time intervall hostlists are saved to disk
42 */
43#define SAVING_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 30)
44
45/**
46 * Time interval between two hostlist tests
47 */
48#define TESTING_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3)
49
50/**
51 * Time interval for download dispatcher before a download is re-scheduled
52 */
53#define WAITING_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
54
55/**
56 * Defines concerning the hostlist quality metric
57 */
58
59/**
60 * Initial quality of a new created hostlist
61 */
62#define HOSTLIST_INITIAL 10000
63
64/**
65 * Value subtracted each time a hostlist download fails
66 */
67#define HOSTLIST_FAILED_DOWNLOAD 100
68
69/**
70 * Value added each time a hostlist download is successful
71 */
72#define HOSTLIST_SUCCESSFUL_DOWNLOAD 100
73
74/**
75 * Value added for each valid HELLO recived during a hostlist download
76 */
77#define HOSTLIST_SUCCESSFUL_HELLO 1
78
79 31
80 32
81/** 33/**
@@ -83,18 +35,19 @@
83 * 35 *
84 * @param c the configuration to use 36 * @param c the configuration to use
85 * @param st hande for publishing statistics 37 * @param st hande for publishing statistics
86 * @param ch set to handler for connect notifications 38 * @param ch[OUT] set to handler for connect notifications
87 * @param dh set to handler for disconnect notifications 39 * @param dh[OUT] set to handler for disconnect notifications
88 * @param msgh set to handler for message handler notifications 40 * @param msgh[OUT] set to handler for message handler notifications
89 * @param learn set if client is learning new hostlists 41 * @param learn set if client is learning new hostlists
90 * @return GNUNET_OK on success 42 * @return #GNUNET_OK on success
91 */ 43 */
92int 44int
93GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, 45GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c,
94 struct GNUNET_STATISTICS_Handle *st, 46 struct GNUNET_STATISTICS_Handle *st,
95 GNUNET_CORE_ConnectEventHandler *ch, 47 GNUNET_CORE_ConnectEventHandler *ch,
96 GNUNET_CORE_DisconnectEventHandler *dh, 48 GNUNET_CORE_DisconnectEventHandler *dh,
97 GNUNET_CORE_MessageCallback *msgh, int learn); 49 GNUNET_CORE_MessageCallback *msgh,
50 int learn);
98 51
99 52
100/** 53/**
@@ -105,4 +58,4 @@ GNUNET_HOSTLIST_client_stop (void);
105 58
106 59
107#endif 60#endif
108/* end of hostlist-client.h */ 61/* end of gnunet-daemon-hostlist_client.h */
diff --git a/src/hostlist/hostlist-server.c b/src/hostlist/gnunet-daemon-hostlist_server.c
index adf9359c6..8a7e747c6 100644
--- a/src/hostlist/hostlist-server.c
+++ b/src/hostlist/gnunet-daemon-hostlist_server.c
@@ -19,14 +19,15 @@
19*/ 19*/
20 20
21/** 21/**
22 * @file hostlist/hostlist-server.c 22 * @file hostlist/gnunet-daemon-hostlist_server.c
23 * @author Christian Grothoff, Matthias Wachs, David Barksdale 23 * @author Christian Grothoff
24 * @author Matthias Wachs
25 * @author David Barksdale
24 * @brief application to provide an integrated hostlist HTTP server 26 * @brief application to provide an integrated hostlist HTTP server
25 */ 27 */
26
27#include "platform.h" 28#include "platform.h"
28#include <microhttpd.h> 29#include <microhttpd.h>
29#include "hostlist-server.h" 30#include "gnunet-daemon-hostlist_server.h"
30#include "gnunet_hello_lib.h" 31#include "gnunet_hello_lib.h"
31#include "gnunet_peerinfo_service.h" 32#include "gnunet_peerinfo_service.h"
32#include "gnunet-daemon-hostlist.h" 33#include "gnunet-daemon-hostlist.h"
@@ -34,6 +35,13 @@
34 35
35 36
36/** 37/**
38 * How long until our hostlist advertisment transmission via CORE should
39 * time out?
40 */
41#define GNUNET_ADV_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
42
43
44/**
37 * Handle to the HTTP server as provided by libmicrohttpd for IPv6. 45 * Handle to the HTTP server as provided by libmicrohttpd for IPv6.
38 */ 46 */
39static struct MHD_Daemon *daemon_handle_v6; 47static struct MHD_Daemon *daemon_handle_v6;
@@ -148,7 +156,8 @@ finish_response ()
148 * @return #GNUNET_SYSERR to stop iterating (unless expiration has occured) 156 * @return #GNUNET_SYSERR to stop iterating (unless expiration has occured)
149 */ 157 */
150static int 158static int
151check_has_addr (void *cls, const struct GNUNET_HELLO_Address *address, 159check_has_addr (void *cls,
160 const struct GNUNET_HELLO_Address *address,
152 struct GNUNET_TIME_Absolute expiration) 161 struct GNUNET_TIME_Absolute expiration)
153{ 162{
154 int *arg = cls; 163 int *arg = cls;
@@ -168,6 +177,11 @@ check_has_addr (void *cls, const struct GNUNET_HELLO_Address *address,
168/** 177/**
169 * Callback that processes each of the known HELLOs for the 178 * Callback that processes each of the known HELLOs for the
170 * hostlist response construction. 179 * hostlist response construction.
180 *
181 * @param cls closure, NULL
182 * @param peer id of the peer, NULL for last call
183 * @param hello hello message for the peer (can be NULL)
184 * @param error message
171 */ 185 */
172static void 186static void
173host_processor (void *cls, 187host_processor (void *cls,
@@ -199,7 +213,10 @@ host_processor (void *cls,
199 if (NULL == hello) 213 if (NULL == hello)
200 return; 214 return;
201 has_addr = GNUNET_NO; 215 has_addr = GNUNET_NO;
202 GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO, &check_has_addr, &has_addr); 216 GNUNET_HELLO_iterate_addresses (hello,
217 GNUNET_NO,
218 &check_has_addr,
219 &has_addr);
203 if (GNUNET_NO == has_addr) 220 if (GNUNET_NO == has_addr)
204 { 221 {
205 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 222 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -215,7 +232,9 @@ host_processor (void *cls,
215 s = GNUNET_HELLO_size (hello); 232 s = GNUNET_HELLO_size (hello);
216 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 233 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
217 "Received %u bytes of `%s' from peer `%s' for hostlist.\n", 234 "Received %u bytes of `%s' from peer `%s' for hostlist.\n",
218 (unsigned int) s, "HELLO", GNUNET_i2s (peer)); 235 (unsigned int) s,
236 "HELLO",
237 GNUNET_i2s (peer));
219 if ((old + s >= GNUNET_MAX_MALLOC_CHECKED) || 238 if ((old + s >= GNUNET_MAX_MALLOC_CHECKED) ||
220 (old + s >= MAX_BYTES_PER_HOSTLISTS)) 239 (old + s >= MAX_BYTES_PER_HOSTLISTS))
221 { 240 {
@@ -226,19 +245,26 @@ host_processor (void *cls,
226 return; /* too large, skip! */ 245 return; /* too large, skip! */
227 } 246 }
228 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 247 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
229 "Adding peer `%s' to hostlist (%u bytes)\n", GNUNET_i2s (peer), 248 "Adding peer `%s' to hostlist (%u bytes)\n",
249 GNUNET_i2s (peer),
230 (unsigned int) s); 250 (unsigned int) s);
231 GNUNET_array_grow (builder->data, builder->size, old + s); 251 GNUNET_array_grow (builder->data, builder->size, old + s);
232 memcpy (&builder->data[old], hello, s); 252 memcpy (&builder->data[old], hello, s);
233} 253}
234 254
235 255
236
237/** 256/**
238 * Hostlist access policy (very permissive, allows everything). 257 * Hostlist access policy (very permissive, allows everything).
258 * Returns #MHD_NO only if we are not yet ready to serve.
259 *
260 * @param cls closure
261 * @param addr address information from the client
262 * @param addrlen length of @a addr
263 * @return #MHD_YES if connection is allowed, #MHD_NO if not (we are not ready)
239 */ 264 */
240static int 265static int
241accept_policy_callback (void *cls, const struct sockaddr *addr, 266accept_policy_callback (void *cls,
267 const struct sockaddr *addr,
242 socklen_t addrlen) 268 socklen_t addrlen)
243{ 269{
244 if (NULL == response) 270 if (NULL == response)
@@ -254,9 +280,11 @@ accept_policy_callback (void *cls, const struct sockaddr *addr,
254/** 280/**
255 * Add headers to a request indicating that we allow Cross-Origin Resource 281 * Add headers to a request indicating that we allow Cross-Origin Resource
256 * Sharing. 282 * Sharing.
283 *
284 * @param response response to add headers to
257 */ 285 */
258static void 286static void
259add_cors_headers(struct MHD_Response *response) 287add_cors_headers (struct MHD_Response *response)
260{ 288{
261 MHD_add_response_header (response, 289 MHD_add_response_header (response,
262 "Access-Control-Allow-Origin", 290 "Access-Control-Allow-Origin",
@@ -272,12 +300,47 @@ add_cors_headers(struct MHD_Response *response)
272 300
273/** 301/**
274 * Main request handler. 302 * Main request handler.
303 *
304 * @param cls argument given together with the function
305 * pointer when the handler was registered with MHD
306 * @param url the requested url
307 * @param method the HTTP method used (#MHD_HTTP_METHOD_GET,
308 * #MHD_HTTP_METHOD_PUT, etc.)
309 * @param version the HTTP version string (i.e.
310 * #MHD_HTTP_VERSION_1_1)
311 * @param upload_data the data being uploaded (excluding HEADERS,
312 * for a POST that fits into memory and that is encoded
313 * with a supported encoding, the POST data will NOT be
314 * given in upload_data and is instead available as
315 * part of #MHD_get_connection_values; very large POST
316 * data *will* be made available incrementally in
317 * @a upload_data)
318 * @param upload_data_size set initially to the size of the
319 * @a upload_data provided; the method must update this
320 * value to the number of bytes NOT processed;
321 * @param con_cls pointer that the callback can set to some
322 * address and that will be preserved by MHD for future
323 * calls for this request; since the access handler may
324 * be called many times (i.e., for a PUT/POST operation
325 * with plenty of upload data) this allows the application
326 * to easily associate some request-specific state.
327 * If necessary, this state can be cleaned up in the
328 * global #MHD_RequestCompletedCallback (which
329 * can be set with the #MHD_OPTION_NOTIFY_COMPLETED).
330 * Initially, `*con_cls` will be NULL.
331 * @return #MHD_YES if the connection was handled successfully,
332 * #MHD_NO if the socket must be closed due to a serios
333 * error while handling the request
275 */ 334 */
276static int 335static int
277access_handler_callback (void *cls, struct MHD_Connection *connection, 336access_handler_callback (void *cls,
278 const char *url, const char *method, 337 struct MHD_Connection *connection,
279 const char *version, const char *upload_data, 338 const char *url,
280 size_t * upload_data_size, void **con_cls) 339 const char *method,
340 const char *version,
341 const char *upload_data,
342 size_t *upload_data_size,
343 void **con_cls)
281{ 344{
282 static int dummy; 345 static int dummy;
283 346
@@ -343,13 +406,17 @@ access_handler_callback (void *cls, struct MHD_Connection *connection,
343 406
344 407
345/** 408/**
346 * Handler called by core when core is ready to transmit message 409 * Handler called by CORE when CORE is ready to transmit message
347 * @param cls closure 410 *
348 * @param size size of buffer to copy message to 411 * @param cls closure
349 * @param buf buffer to copy message to 412 * @param size size of buffer to copy message to
413 * @param buf buffer to copy message to
414 * @return number of bytes copied to @a buf
350 */ 415 */
351static size_t 416static size_t
352adv_transmit_ready (void *cls, size_t size, void *buf) 417adv_transmit_ready (void *cls,
418 size_t size,
419 void *buf)
353{ 420{
354 static uint64_t hostlist_adv_count; 421 static uint64_t hostlist_adv_count;
355 size_t transmission_size; 422 size_t transmission_size;
@@ -391,7 +458,8 @@ adv_transmit_ready (void *cls, size_t size, void *buf)
391 * @param peer peer identity this notification is about 458 * @param peer peer identity this notification is about
392 */ 459 */
393static void 460static void
394connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer) 461connect_handler (void *cls,
462 const struct GNUNET_PeerIdentity *peer)
395{ 463{
396 size_t size; 464 size_t size;
397 465
@@ -413,12 +481,15 @@ connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer)
413 return; 481 return;
414 } 482 }
415 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 483 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
416 "Asked core to transmit advertisement message with a size of %u bytes to peer `%s'\n", 484 "Asked CORE to transmit advertisement message with a size of %u bytes to peer `%s'\n",
417 size, GNUNET_i2s (peer)); 485 size,
486 GNUNET_i2s (peer));
418 if (NULL == 487 if (NULL ==
419 GNUNET_CORE_notify_transmit_ready (core, GNUNET_YES, 488 GNUNET_CORE_notify_transmit_ready (core, GNUNET_YES,
420 GNUNET_CORE_PRIO_BEST_EFFORT, 489 GNUNET_CORE_PRIO_BEST_EFFORT,
421 GNUNET_ADV_TIMEOUT, peer, size, 490 GNUNET_ADV_TIMEOUT,
491 peer,
492 size,
422 &adv_transmit_ready, NULL)) 493 &adv_transmit_ready, NULL))
423 { 494 {
424 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 495 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -434,7 +505,8 @@ connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer)
434 * @param peer peer identity this notification is about 505 * @param peer peer identity this notification is about
435 */ 506 */
436static void 507static void
437disconnect_handler (void *cls, const struct GNUNET_PeerIdentity *peer) 508disconnect_handler (void *cls,
509 const struct GNUNET_PeerIdentity *peer)
438{ 510{
439 /* nothing to do */ 511 /* nothing to do */
440} 512}
@@ -450,8 +522,10 @@ disconnect_handler (void *cls, const struct GNUNET_PeerIdentity *peer)
450 * @param err_msg NULL if successful, otherwise contains error message 522 * @param err_msg NULL if successful, otherwise contains error message
451 */ 523 */
452static void 524static void
453process_notify (void *cls, const struct GNUNET_PeerIdentity *peer, 525process_notify (void *cls,
454 const struct GNUNET_HELLO_Message *hello, const char *err_msg) 526 const struct GNUNET_PeerIdentity *peer,
527 const struct GNUNET_HELLO_Message *hello,
528 const char *err_msg)
455{ 529{
456 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 530 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
457 "Peerinfo is notifying us to rebuild our hostlist\n"); 531 "Peerinfo is notifying us to rebuild our hostlist\n");
@@ -489,9 +563,13 @@ prepare_daemon (struct MHD_Daemon *daemon_handle);
489/** 563/**
490 * Call MHD to process pending requests and then go back 564 * Call MHD to process pending requests and then go back
491 * and schedule the next run. 565 * and schedule the next run.
566 *
567 * @param cls the `struct MHD_Daemon` of the HTTP server to run
568 * @param tc scheduler context
492 */ 569 */
493static void 570static void
494run_daemon (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 571run_daemon (void *cls,
572 const struct GNUNET_SCHEDULER_TaskContext *tc)
495{ 573{
496 struct MHD_Daemon *daemon_handle = cls; 574 struct MHD_Daemon *daemon_handle = cls;
497 575
@@ -513,6 +591,8 @@ run_daemon (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
513/** 591/**
514 * Function that queries MHD's select sets and 592 * Function that queries MHD's select sets and
515 * starts the task waiting for them. 593 * starts the task waiting for them.
594 *
595 * @param daemon_handle HTTP server to prepare to run
516 */ 596 */
517static GNUNET_SCHEDULER_TaskIdentifier 597static GNUNET_SCHEDULER_TaskIdentifier
518prepare_daemon (struct MHD_Daemon *daemon_handle) 598prepare_daemon (struct MHD_Daemon *daemon_handle)
@@ -555,6 +635,12 @@ prepare_daemon (struct MHD_Daemon *daemon_handle)
555/** 635/**
556 * Start server offering our hostlist. 636 * Start server offering our hostlist.
557 * 637 *
638 * @param c configuration to use
639 * @param st statistics handle to use
640 * @param co core handle to use
641 * @param server_ch[OUT] set to handler for CORE connect events
642 * @param server_dh[OUT] set to handler for CORE disconnect events
643 * @param advertise #GNUNET_YES if we should advertise our hostlist
558 * @return #GNUNET_OK on success 644 * @return #GNUNET_OK on success
559 */ 645 */
560int 646int
@@ -799,4 +885,4 @@ GNUNET_HOSTLIST_server_stop ()
799 core = NULL; 885 core = NULL;
800} 886}
801 887
802/* end of hostlist-server.c */ 888/* end of gnunet-daemon-hostlist_server.c */
diff --git a/src/hostlist/hostlist-server.h b/src/hostlist/gnunet-daemon-hostlist_server.h
index e0f8eb4a6..bfceda336 100644
--- a/src/hostlist/hostlist-server.h
+++ b/src/hostlist/gnunet-daemon-hostlist_server.h
@@ -19,24 +19,29 @@
19*/ 19*/
20 20
21/** 21/**
22 * @file hostlist/hostlist-server.h 22 * @file hostlist/gnunet-daemon-hostlist_server.h
23 * @brief hostlist support. Downloads HELLOs via HTTP. 23 * @brief hostlist support. Downloads HELLOs via HTTP.
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26 26
27#ifndef HOSTLIST_SERVER_H 27#ifndef GNUNET_DAEMON_HOSTLIST_SERVER_H
28#define HOSTLIST_SERVER_H 28#define GNUNET_DAEMON_HOSTLIST_SERVER_H
29 29
30#include "gnunet_core_service.h" 30#include "gnunet_core_service.h"
31#include "gnunet_statistics_service.h" 31#include "gnunet_statistics_service.h"
32#include "gnunet_util_lib.h" 32#include "gnunet_util_lib.h"
33 33
34#define GNUNET_ADV_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
35 34
36/** 35/**
37 * Start server offering our hostlist. 36 * Start server offering our hostlist.
38 * 37 *
39 * @return GNUNET_OK on success 38 * @param c configuration to use
39 * @param st statistics handle to use
40 * @param co core handle to use
41 * @param server_ch[OUT] set to handler for CORE connect events
42 * @param server_dh[OUT] set to handler for CORE disconnect events
43 * @param advertise #GNUNET_YES if we should advertise our hostlist
44 * @return #GNUNET_OK on success
40 */ 45 */
41int 46int
42GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c, 47GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c,
@@ -55,4 +60,4 @@ GNUNET_HOSTLIST_server_stop (void);
55 60
56 61
57#endif 62#endif
58/* end of hostlist-server.h */ 63/* end of gnunet-daemon-hostlist_server.h */
diff --git a/src/hostlist/test_gnunet_daemon_hostlist_learning.c b/src/hostlist/test_gnunet_daemon_hostlist_learning.c
index 8a5cdac7a..9f4d8e3d7 100644
--- a/src/hostlist/test_gnunet_daemon_hostlist_learning.c
+++ b/src/hostlist/test_gnunet_daemon_hostlist_learning.c
@@ -37,7 +37,7 @@
37 */ 37 */
38#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 180) 38#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 180)
39 39
40#define CHECK_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) 40#define CHECK_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
41 41
42 42
43struct PeerContext 43struct PeerContext
@@ -304,7 +304,7 @@ check_statistics (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
304 &process_adv_sent, NULL); 304 &process_adv_sent, NULL);
305 } 305 }
306 check_task = 306 check_task =
307 GNUNET_SCHEDULER_add_delayed (CHECK_INTERVALL, &check_statistics, NULL); 307 GNUNET_SCHEDULER_add_delayed (CHECK_INTERVAL, &check_statistics, NULL);
308} 308}
309 309
310 310
@@ -452,7 +452,7 @@ run (void *cls, char *const *args, const char *cfgfile,
452 timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_error, NULL); 452 timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_error, NULL);
453 453
454 check_task = 454 check_task =
455 GNUNET_SCHEDULER_add_delayed (CHECK_INTERVALL, &check_statistics, NULL); 455 GNUNET_SCHEDULER_add_delayed (CHECK_INTERVAL, &check_statistics, NULL);
456} 456}
457 457
458 458