diff options
author | Christian Grothoff <christian@grothoff.org> | 2009-06-13 05:44:21 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2009-06-13 05:44:21 +0000 |
commit | a2355334e0a5116144f2588ddf1e37f596c520bd (patch) | |
tree | ade2f6d60a9aadc53e5731d7cca68c7f67901940 /src/hostlist/gnunet-daemon-hostlist.c | |
parent | 73cd82b1494c8390c41e7b5afda96b250fd448fa (diff) | |
download | gnunet-a2355334e0a5116144f2588ddf1e37f596c520bd.tar.gz gnunet-a2355334e0a5116144f2588ddf1e37f596c520bd.zip |
client part
Diffstat (limited to 'src/hostlist/gnunet-daemon-hostlist.c')
-rw-r--r-- | src/hostlist/gnunet-daemon-hostlist.c | 63 |
1 files changed, 59 insertions, 4 deletions
diff --git a/src/hostlist/gnunet-daemon-hostlist.c b/src/hostlist/gnunet-daemon-hostlist.c index 0fb77ecbd..f11bcd87d 100644 --- a/src/hostlist/gnunet-daemon-hostlist.c +++ b/src/hostlist/gnunet-daemon-hostlist.c | |||
@@ -26,12 +26,15 @@ | |||
26 | 26 | ||
27 | #include <stdlib.h> | 27 | #include <stdlib.h> |
28 | #include "platform.h" | 28 | #include "platform.h" |
29 | #include "hostlist-client.h" | ||
30 | #include "gnunet_core_service.h" | ||
29 | #include "gnunet_getopt_lib.h" | 31 | #include "gnunet_getopt_lib.h" |
30 | #include "gnunet_protocols.h" | 32 | #include "gnunet_protocols.h" |
31 | #include "gnunet_program_lib.h" | 33 | #include "gnunet_program_lib.h" |
32 | #include "gnunet_statistics_service.h" | 34 | #include "gnunet_statistics_service.h" |
33 | #include "gnunet_strings_lib.h" | 35 | #include "gnunet_strings_lib.h" |
34 | #include "gnunet_time_lib.h" | 36 | #include "gnunet_time_lib.h" |
37 | #include "gnunet_util_lib.h" | ||
35 | 38 | ||
36 | 39 | ||
37 | /** | 40 | /** |
@@ -51,6 +54,10 @@ static int learning; | |||
51 | */ | 54 | */ |
52 | static int provide_hostlist; | 55 | static int provide_hostlist; |
53 | 56 | ||
57 | /** | ||
58 | * Statistics handle. | ||
59 | */ | ||
60 | static struct GNUNET_STATISTICS_Handle *stats; | ||
54 | 61 | ||
55 | /** | 62 | /** |
56 | * gnunet-daemon-hostlist command line options. | 63 | * gnunet-daemon-hostlist command line options. |
@@ -66,6 +73,33 @@ static struct GNUNET_GETOPT_CommandLineOption options[] = { | |||
66 | }; | 73 | }; |
67 | 74 | ||
68 | 75 | ||
76 | static void | ||
77 | core_init (void *cls, | ||
78 | struct GNUNET_CORE_Handle * server, | ||
79 | const struct GNUNET_PeerIdentity * | ||
80 | my_identity, | ||
81 | const struct | ||
82 | GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded * | ||
83 | publicKey) | ||
84 | { | ||
85 | /* TODO: provide "server" to 'hostlist' module (if applicable) */ | ||
86 | } | ||
87 | |||
88 | |||
89 | /** | ||
90 | * Last task run during shutdown. Disconnects us from | ||
91 | * the other services. | ||
92 | */ | ||
93 | static void | ||
94 | cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
95 | { | ||
96 | if (stats != NULL) | ||
97 | { | ||
98 | GNUNET_STATISTICS_destroy (stats); | ||
99 | stats = NULL; | ||
100 | } | ||
101 | } | ||
102 | |||
69 | 103 | ||
70 | /** | 104 | /** |
71 | * Main function that will be run. | 105 | * Main function that will be run. |
@@ -83,6 +117,13 @@ run (void *cls, | |||
83 | const char *cfgfile, | 117 | const char *cfgfile, |
84 | struct GNUNET_CONFIGURATION_Handle * cfg) | 118 | struct GNUNET_CONFIGURATION_Handle * cfg) |
85 | { | 119 | { |
120 | GNUNET_CORE_ClientEventHandler ch = NULL; | ||
121 | GNUNET_CORE_ClientEventHandler dh = NULL; | ||
122 | struct GNUNET_CORE_MessageHandler handlers[] = | ||
123 | { | ||
124 | { NULL, 0, 0 } | ||
125 | }; | ||
126 | |||
86 | if ( (! bootstrapping) && | 127 | if ( (! bootstrapping) && |
87 | (! learning) && | 128 | (! learning) && |
88 | (! provide_hostlist) ) | 129 | (! provide_hostlist) ) |
@@ -91,6 +132,7 @@ run (void *cls, | |||
91 | _("None of the functions for the hostlist daemon were enabled. I have no reason to run!\n")); | 132 | _("None of the functions for the hostlist daemon were enabled. I have no reason to run!\n")); |
92 | return; | 133 | return; |
93 | } | 134 | } |
135 | stats = GNUNET_STATISTICS_create (sched, "hostlist", cfg); | ||
94 | if (learning) | 136 | if (learning) |
95 | { | 137 | { |
96 | // FIXME! | 138 | // FIXME! |
@@ -98,10 +140,8 @@ run (void *cls, | |||
98 | } | 140 | } |
99 | if (bootstrapping) | 141 | if (bootstrapping) |
100 | { | 142 | { |
101 | // FIXME! | 143 | GNUNET_HOSTLIST_client_start (cfg, sched, stats, |
102 | // (register handler with core to monitor number of active | 144 | &ch, &dh); |
103 | // connections; trigger hostlist download via CURL if | ||
104 | // number is low) | ||
105 | } | 145 | } |
106 | if (provide_hostlist) | 146 | if (provide_hostlist) |
107 | { | 147 | { |
@@ -109,6 +149,21 @@ run (void *cls, | |||
109 | // (initialize MHD server and run using scheduler; | 149 | // (initialize MHD server and run using scheduler; |
110 | // use peerinfo to gather HELLOs) | 150 | // use peerinfo to gather HELLOs) |
111 | } | 151 | } |
152 | GNUNET_CORE_connect (sched, cfg, | ||
153 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
154 | NULL, | ||
155 | &core_init, | ||
156 | ch, dh, | ||
157 | NULL, | ||
158 | NULL, GNUNET_NO, | ||
159 | NULL, GNUNET_NO, | ||
160 | handlers); | ||
161 | GNUNET_SCHEDULER_add_delayed (sched, | ||
162 | GNUNET_YES, | ||
163 | GNUNET_SCHEDULER_PRIORITY_IDLE, | ||
164 | GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, | ||
165 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
166 | &cleaning_task, NULL); | ||
112 | } | 167 | } |
113 | 168 | ||
114 | 169 | ||