diff options
Diffstat (limited to 'src/dht/gnunet-service-dht.c')
-rw-r--r-- | src/dht/gnunet-service-dht.c | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c index 9de76ab7a..332d48a86 100644 --- a/src/dht/gnunet-service-dht.c +++ b/src/dht/gnunet-service-dht.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
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, 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 |
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 |
@@ -28,6 +28,7 @@ | |||
28 | #include "gnunet_block_lib.h" | 28 | #include "gnunet_block_lib.h" |
29 | #include "gnunet_util_lib.h" | 29 | #include "gnunet_util_lib.h" |
30 | #include "gnunet_transport_service.h" | 30 | #include "gnunet_transport_service.h" |
31 | #include "gnunet_transport_hello_service.h" | ||
31 | #include "gnunet_hello_lib.h" | 32 | #include "gnunet_hello_lib.h" |
32 | #include "gnunet_dht_service.h" | 33 | #include "gnunet_dht_service.h" |
33 | #include "gnunet_statistics_service.h" | 34 | #include "gnunet_statistics_service.h" |
@@ -40,7 +41,6 @@ | |||
40 | #include "gnunet-service-dht_routing.h" | 41 | #include "gnunet-service-dht_routing.h" |
41 | 42 | ||
42 | 43 | ||
43 | |||
44 | /** | 44 | /** |
45 | * Handle for the statistics service. | 45 | * Handle for the statistics service. |
46 | */ | 46 | */ |
@@ -69,7 +69,7 @@ struct GNUNET_MessageHeader *GDS_my_hello; | |||
69 | /** | 69 | /** |
70 | * Handle to get our current HELLO. | 70 | * Handle to get our current HELLO. |
71 | */ | 71 | */ |
72 | static struct GNUNET_TRANSPORT_GetHelloHandle *ghh; | 72 | static struct GNUNET_TRANSPORT_HelloGetHandle *ghh; |
73 | 73 | ||
74 | /** | 74 | /** |
75 | * Hello address expiration | 75 | * Hello address expiration |
@@ -85,9 +85,9 @@ struct GNUNET_TIME_Relative hello_expiration; | |||
85 | * @param message HELLO message of peer | 85 | * @param message HELLO message of peer |
86 | */ | 86 | */ |
87 | static void | 87 | static void |
88 | process_hello (void *cls, const struct GNUNET_MessageHeader *message) | 88 | process_hello (void *cls, |
89 | const struct GNUNET_MessageHeader *message) | ||
89 | { | 90 | { |
90 | GNUNET_assert (message != NULL); | ||
91 | GNUNET_free_non_null (GDS_my_hello); | 91 | GNUNET_free_non_null (GDS_my_hello); |
92 | GDS_my_hello = GNUNET_malloc (ntohs (message->size)); | 92 | GDS_my_hello = GNUNET_malloc (ntohs (message->size)); |
93 | GNUNET_memcpy (GDS_my_hello, message, ntohs (message->size)); | 93 | GNUNET_memcpy (GDS_my_hello, message, ntohs (message->size)); |
@@ -104,7 +104,7 @@ shutdown_task (void *cls) | |||
104 | { | 104 | { |
105 | if (NULL != ghh) | 105 | if (NULL != ghh) |
106 | { | 106 | { |
107 | GNUNET_TRANSPORT_get_hello_cancel (ghh); | 107 | GNUNET_TRANSPORT_hello_get_cancel (ghh); |
108 | ghh = NULL; | 108 | ghh = NULL; |
109 | } | 109 | } |
110 | GDS_NEIGHBOURS_done (); | 110 | GDS_NEIGHBOURS_done (); |
@@ -112,14 +112,15 @@ shutdown_task (void *cls) | |||
112 | GDS_ROUTING_done (); | 112 | GDS_ROUTING_done (); |
113 | GDS_HELLO_done (); | 113 | GDS_HELLO_done (); |
114 | GDS_NSE_done (); | 114 | GDS_NSE_done (); |
115 | if (GDS_block_context != NULL) | 115 | if (NULL != GDS_block_context) |
116 | { | 116 | { |
117 | GNUNET_BLOCK_context_destroy (GDS_block_context); | 117 | GNUNET_BLOCK_context_destroy (GDS_block_context); |
118 | GDS_block_context = NULL; | 118 | GDS_block_context = NULL; |
119 | } | 119 | } |
120 | if (GDS_stats != NULL) | 120 | if (NULL != GDS_stats) |
121 | { | 121 | { |
122 | GNUNET_STATISTICS_destroy (GDS_stats, GNUNET_YES); | 122 | GNUNET_STATISTICS_destroy (GDS_stats, |
123 | GNUNET_YES); | ||
123 | GDS_stats = NULL; | 124 | GDS_stats = NULL; |
124 | } | 125 | } |
125 | GNUNET_free_non_null (GDS_my_hello); | 126 | GNUNET_free_non_null (GDS_my_hello); |
@@ -143,7 +144,10 @@ run (void *cls, | |||
143 | GDS_server = server; | 144 | GDS_server = server; |
144 | GNUNET_SERVER_suspend (server); | 145 | GNUNET_SERVER_suspend (server); |
145 | if (GNUNET_OK != | 146 | if (GNUNET_OK != |
146 | GNUNET_CONFIGURATION_get_value_time (c, "transport", "HELLO_EXPIRATION", &hello_expiration)) | 147 | GNUNET_CONFIGURATION_get_value_time (c, |
148 | "transport", | ||
149 | "HELLO_EXPIRATION", | ||
150 | &hello_expiration)) | ||
147 | { | 151 | { |
148 | hello_expiration = GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION; | 152 | hello_expiration = GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION; |
149 | } | 153 | } |
@@ -160,7 +164,8 @@ run (void *cls, | |||
160 | } | 164 | } |
161 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, | 165 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
162 | NULL); | 166 | NULL); |
163 | ghh = GNUNET_TRANSPORT_get_hello (GDS_cfg, | 167 | ghh = GNUNET_TRANSPORT_hello_get (GDS_cfg, |
168 | GNUNET_TRANSPORT_AC_GLOBAL, | ||
164 | &process_hello, | 169 | &process_hello, |
165 | NULL); | 170 | NULL); |
166 | } | 171 | } |
@@ -174,14 +179,18 @@ run (void *cls, | |||
174 | * @return 0 ok, 1 on error | 179 | * @return 0 ok, 1 on error |
175 | */ | 180 | */ |
176 | int | 181 | int |
177 | main (int argc, char *const *argv) | 182 | main (int argc, |
183 | char *const *argv) | ||
178 | { | 184 | { |
179 | int ret; | 185 | int ret; |
180 | 186 | ||
181 | ret = | 187 | ret = (GNUNET_OK == |
182 | (GNUNET_OK == | 188 | GNUNET_SERVICE_run (argc, |
183 | GNUNET_SERVICE_run (argc, argv, "dht", GNUNET_SERVICE_OPTION_NONE, &run, | 189 | argv, |
184 | NULL)) ? 0 : 1; | 190 | "dht", |
191 | GNUNET_SERVICE_OPTION_NONE, | ||
192 | &run, | ||
193 | NULL)) ? 0 : 1; | ||
185 | GDS_CLIENTS_done (); | 194 | GDS_CLIENTS_done (); |
186 | return ret; | 195 | return ret; |
187 | } | 196 | } |