diff options
Diffstat (limited to 'src/testbed/gnunet-daemon-testbed-underlay.c')
-rw-r--r-- | src/testbed/gnunet-daemon-testbed-underlay.c | 360 |
1 files changed, 184 insertions, 176 deletions
diff --git a/src/testbed/gnunet-daemon-testbed-underlay.c b/src/testbed/gnunet-daemon-testbed-underlay.c index 0c6a3c3df..2cc25b0ed 100644 --- a/src/testbed/gnunet-daemon-testbed-underlay.c +++ b/src/testbed/gnunet-daemon-testbed-underlay.c | |||
@@ -38,13 +38,13 @@ | |||
38 | * Logging shorthand | 38 | * Logging shorthand |
39 | */ | 39 | */ |
40 | #define LOG(type, ...) \ | 40 | #define LOG(type, ...) \ |
41 | GNUNET_log(type, __VA_ARGS__) | 41 | GNUNET_log (type, __VA_ARGS__) |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * Debug logging shorthand | 44 | * Debug logging shorthand |
45 | */ | 45 | */ |
46 | #define DEBUG(...) \ | 46 | #define DEBUG(...) \ |
47 | LOG(GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) | 47 | LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) |
48 | 48 | ||
49 | /** | 49 | /** |
50 | * Log an error message at log-level 'level' that indicates | 50 | * Log an error message at log-level 'level' that indicates |
@@ -53,12 +53,13 @@ | |||
53 | */ | 53 | */ |
54 | #define LOG_SQLITE(db, msg, level, cmd) \ | 54 | #define LOG_SQLITE(db, msg, level, cmd) \ |
55 | do { \ | 55 | do { \ |
56 | GNUNET_log_from(level, "sqlite", _("`%s' failed at %s:%d with error: %s\n"), \ | 56 | GNUNET_log_from (level, "sqlite", _ ( \ |
57 | cmd, __FILE__, __LINE__, sqlite3_errmsg(db)); \ | 57 | "`%s' failed at %s:%d with error: %s\n"), \ |
58 | if (msg != NULL) \ | 58 | cmd, __FILE__, __LINE__, sqlite3_errmsg (db)); \ |
59 | GNUNET_asprintf (msg, _("`%s' failed at %s:%u with error: %s"), cmd, \ | 59 | if (msg != NULL) \ |
60 | __FILE__, __LINE__, sqlite3_errmsg(db)); \ | 60 | GNUNET_asprintf (msg, _ ("`%s' failed at %s:%u with error: %s"), cmd, \ |
61 | } while (0) | 61 | __FILE__, __LINE__, sqlite3_errmsg (db)); \ |
62 | } while (0) | ||
62 | 63 | ||
63 | 64 | ||
64 | /** | 65 | /** |
@@ -115,10 +116,10 @@ static unsigned int num_hostkeys; | |||
115 | * #GNUNET_NO if not. | 116 | * #GNUNET_NO if not. |
116 | */ | 117 | */ |
117 | static int | 118 | static int |
118 | iterator(void *cls, const struct GNUNET_PeerIdentity *key, void *value) | 119 | iterator (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
119 | { | 120 | { |
120 | GNUNET_assert(GNUNET_YES == GNUNET_CONTAINER_multipeermap_remove(map, key, | 121 | GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multipeermap_remove (map, key, |
121 | value)); | 122 | value)); |
122 | return GNUNET_YES; | 123 | return GNUNET_YES; |
123 | } | 124 | } |
124 | 125 | ||
@@ -127,16 +128,17 @@ iterator(void *cls, const struct GNUNET_PeerIdentity *key, void *value) | |||
127 | * Cleaup and destroy the map | 128 | * Cleaup and destroy the map |
128 | */ | 129 | */ |
129 | static void | 130 | static void |
130 | cleanup_map() | 131 | cleanup_map () |
131 | { | 132 | { |
132 | if (NULL != map) | 133 | if (NULL != map) |
133 | { | 134 | { |
134 | GNUNET_assert(GNUNET_SYSERR != GNUNET_CONTAINER_multipeermap_iterate(map, | 135 | GNUNET_assert (GNUNET_SYSERR != GNUNET_CONTAINER_multipeermap_iterate (map, |
135 | &iterator, | 136 | & |
137 | iterator, | ||
136 | NULL)); | 138 | NULL)); |
137 | GNUNET_CONTAINER_multipeermap_destroy(map); | 139 | GNUNET_CONTAINER_multipeermap_destroy (map); |
138 | map = NULL; | 140 | map = NULL; |
139 | } | 141 | } |
140 | } | 142 | } |
141 | 143 | ||
142 | 144 | ||
@@ -148,35 +150,35 @@ cleanup_map() | |||
148 | * @return GNUNET_OK if the connection is allowed, GNUNET_SYSERR if not | 150 | * @return GNUNET_OK if the connection is allowed, GNUNET_SYSERR if not |
149 | */ | 151 | */ |
150 | static int | 152 | static int |
151 | check_access(void *cls, const struct GNUNET_PeerIdentity * pid) | 153 | check_access (void *cls, const struct GNUNET_PeerIdentity *pid) |
152 | { | 154 | { |
153 | int contains; | 155 | int contains; |
154 | 156 | ||
155 | GNUNET_assert(NULL != map); | 157 | GNUNET_assert (NULL != map); |
156 | contains = GNUNET_CONTAINER_multipeermap_contains(map, pid); | 158 | contains = GNUNET_CONTAINER_multipeermap_contains (map, pid); |
157 | if (GNUNET_YES == contains) | 159 | if (GNUNET_YES == contains) |
158 | { | 160 | { |
159 | DEBUG("Permitting `%s'\n", GNUNET_i2s(pid)); | 161 | DEBUG ("Permitting `%s'\n", GNUNET_i2s (pid)); |
160 | return GNUNET_OK; | 162 | return GNUNET_OK; |
161 | } | 163 | } |
162 | DEBUG("Not permitting `%s'\n", GNUNET_i2s(pid)); | 164 | DEBUG ("Not permitting `%s'\n", GNUNET_i2s (pid)); |
163 | return GNUNET_SYSERR; | 165 | return GNUNET_SYSERR; |
164 | } | 166 | } |
165 | 167 | ||
166 | 168 | ||
167 | static int | 169 | static int |
168 | get_identity(unsigned int offset, | 170 | get_identity (unsigned int offset, |
169 | struct GNUNET_PeerIdentity *id) | 171 | struct GNUNET_PeerIdentity *id) |
170 | { | 172 | { |
171 | struct GNUNET_CRYPTO_EddsaPrivateKey private_key; | 173 | struct GNUNET_CRYPTO_EddsaPrivateKey private_key; |
172 | 174 | ||
173 | if (offset >= num_hostkeys) | 175 | if (offset >= num_hostkeys) |
174 | return GNUNET_SYSERR; | 176 | return GNUNET_SYSERR; |
175 | GNUNET_memcpy(&private_key, | 177 | GNUNET_memcpy (&private_key, |
176 | hostkeys_data + (offset * GNUNET_TESTING_HOSTKEYFILESIZE), | 178 | hostkeys_data + (offset * GNUNET_TESTING_HOSTKEYFILESIZE), |
177 | GNUNET_TESTING_HOSTKEYFILESIZE); | 179 | GNUNET_TESTING_HOSTKEYFILESIZE); |
178 | GNUNET_CRYPTO_eddsa_key_get_public(&private_key, | 180 | GNUNET_CRYPTO_eddsa_key_get_public (&private_key, |
179 | &id->public_key); | 181 | &id->public_key); |
180 | return GNUNET_OK; | 182 | return GNUNET_OK; |
181 | } | 183 | } |
182 | 184 | ||
@@ -184,7 +186,8 @@ get_identity(unsigned int offset, | |||
184 | /** | 186 | /** |
185 | * Whilelist entry | 187 | * Whilelist entry |
186 | */ | 188 | */ |
187 | struct WhiteListRow { | 189 | struct WhiteListRow |
190 | { | ||
188 | /** | 191 | /** |
189 | * Next ptr | 192 | * Next ptr |
190 | */ | 193 | */ |
@@ -206,7 +209,7 @@ struct WhiteListRow { | |||
206 | * Function to load keys | 209 | * Function to load keys |
207 | */ | 210 | */ |
208 | static int | 211 | static int |
209 | load_keys(const struct GNUNET_CONFIGURATION_Handle *c) | 212 | load_keys (const struct GNUNET_CONFIGURATION_Handle *c) |
210 | { | 213 | { |
211 | char *data_dir; | 214 | char *data_dir; |
212 | char *idfile; | 215 | char *idfile; |
@@ -215,42 +218,42 @@ load_keys(const struct GNUNET_CONFIGURATION_Handle *c) | |||
215 | data_dir = NULL; | 218 | data_dir = NULL; |
216 | idfile = NULL; | 219 | idfile = NULL; |
217 | fsize = 0; | 220 | fsize = 0; |
218 | data_dir = GNUNET_OS_installation_get_path(GNUNET_OS_IPK_DATADIR); | 221 | data_dir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR); |
219 | GNUNET_asprintf(&idfile, "%s/testing_hostkeys.ecc", data_dir); | 222 | GNUNET_asprintf (&idfile, "%s/testing_hostkeys.ecc", data_dir); |
220 | GNUNET_free(data_dir); | 223 | GNUNET_free (data_dir); |
221 | data_dir = NULL; | 224 | data_dir = NULL; |
222 | if (GNUNET_OK != | 225 | if (GNUNET_OK != |
223 | GNUNET_DISK_file_size(idfile, &fsize, GNUNET_YES, GNUNET_YES)) | 226 | GNUNET_DISK_file_size (idfile, &fsize, GNUNET_YES, GNUNET_YES)) |
224 | { | 227 | { |
225 | GNUNET_free(idfile); | 228 | GNUNET_free (idfile); |
226 | return GNUNET_SYSERR; | 229 | return GNUNET_SYSERR; |
227 | } | 230 | } |
228 | if (0 != (fsize % GNUNET_TESTING_HOSTKEYFILESIZE)) | 231 | if (0 != (fsize % GNUNET_TESTING_HOSTKEYFILESIZE)) |
229 | { | 232 | { |
230 | LOG(GNUNET_ERROR_TYPE_ERROR, | 233 | LOG (GNUNET_ERROR_TYPE_ERROR, |
231 | _("Incorrect hostkey file format: %s\n"), idfile); | 234 | _ ("Incorrect hostkey file format: %s\n"), idfile); |
232 | GNUNET_free(idfile); | 235 | GNUNET_free (idfile); |
233 | return GNUNET_SYSERR; | 236 | return GNUNET_SYSERR; |
234 | } | 237 | } |
235 | hostkeys_fd = GNUNET_DISK_file_open(idfile, GNUNET_DISK_OPEN_READ, | 238 | hostkeys_fd = GNUNET_DISK_file_open (idfile, GNUNET_DISK_OPEN_READ, |
236 | GNUNET_DISK_PERM_NONE); | 239 | GNUNET_DISK_PERM_NONE); |
237 | if (NULL == hostkeys_fd) | 240 | if (NULL == hostkeys_fd) |
238 | { | 241 | { |
239 | GNUNET_log_strerror_file(GNUNET_ERROR_TYPE_ERROR, "open", idfile); | 242 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", idfile); |
240 | GNUNET_free(idfile); | 243 | GNUNET_free (idfile); |
241 | return GNUNET_SYSERR; | 244 | return GNUNET_SYSERR; |
242 | } | 245 | } |
243 | GNUNET_free(idfile); | 246 | GNUNET_free (idfile); |
244 | idfile = NULL; | 247 | idfile = NULL; |
245 | hostkeys_data = GNUNET_DISK_file_map(hostkeys_fd, | 248 | hostkeys_data = GNUNET_DISK_file_map (hostkeys_fd, |
246 | &hostkeys_map, | 249 | &hostkeys_map, |
247 | GNUNET_DISK_MAP_TYPE_READ, | 250 | GNUNET_DISK_MAP_TYPE_READ, |
248 | fsize); | 251 | fsize); |
249 | if (NULL == hostkeys_data) | 252 | if (NULL == hostkeys_data) |
250 | { | 253 | { |
251 | GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR, "mmap"); | 254 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "mmap"); |
252 | return GNUNET_SYSERR; | 255 | return GNUNET_SYSERR; |
253 | } | 256 | } |
254 | num_hostkeys = fsize / GNUNET_TESTING_HOSTKEYFILESIZE; | 257 | num_hostkeys = fsize / GNUNET_TESTING_HOSTKEYFILESIZE; |
255 | return GNUNET_OK; | 258 | return GNUNET_OK; |
256 | } | 259 | } |
@@ -260,20 +263,20 @@ load_keys(const struct GNUNET_CONFIGURATION_Handle *c) | |||
260 | * Function to unload keys | 263 | * Function to unload keys |
261 | */ | 264 | */ |
262 | static void | 265 | static void |
263 | unload_keys() | 266 | unload_keys () |
264 | { | 267 | { |
265 | if (NULL != hostkeys_map) | 268 | if (NULL != hostkeys_map) |
266 | { | 269 | { |
267 | GNUNET_assert(NULL != hostkeys_data); | 270 | GNUNET_assert (NULL != hostkeys_data); |
268 | GNUNET_DISK_file_unmap(hostkeys_map); | 271 | GNUNET_DISK_file_unmap (hostkeys_map); |
269 | hostkeys_map = NULL; | 272 | hostkeys_map = NULL; |
270 | hostkeys_data = NULL; | 273 | hostkeys_data = NULL; |
271 | } | 274 | } |
272 | if (NULL != hostkeys_fd) | 275 | if (NULL != hostkeys_fd) |
273 | { | 276 | { |
274 | GNUNET_DISK_file_close(hostkeys_fd); | 277 | GNUNET_DISK_file_close (hostkeys_fd); |
275 | hostkeys_fd = NULL; | 278 | hostkeys_fd = NULL; |
276 | } | 279 | } |
277 | } | 280 | } |
278 | 281 | ||
279 | 282 | ||
@@ -283,17 +286,17 @@ unload_keys() | |||
283 | * @param cls NULL | 286 | * @param cls NULL |
284 | */ | 287 | */ |
285 | static void | 288 | static void |
286 | do_shutdown(void *cls) | 289 | do_shutdown (void *cls) |
287 | { | 290 | { |
288 | if (NULL != transport) | 291 | if (NULL != transport) |
289 | { | 292 | { |
290 | GNUNET_TRANSPORT_manipulation_disconnect(transport); | 293 | GNUNET_TRANSPORT_manipulation_disconnect (transport); |
291 | transport = NULL; | 294 | transport = NULL; |
292 | } | 295 | } |
293 | cleanup_map(); | 296 | cleanup_map (); |
294 | unload_keys(); | 297 | unload_keys (); |
295 | if (NULL != bh) | 298 | if (NULL != bh) |
296 | GNUNET_TRANSPORT_blacklist_cancel(bh); | 299 | GNUNET_TRANSPORT_blacklist_cancel (bh); |
297 | } | 300 | } |
298 | 301 | ||
299 | 302 | ||
@@ -306,40 +309,42 @@ do_shutdown(void *cls) | |||
306 | * @return GNUNET_SYSERR upon error OR the number of rows retrieved | 309 | * @return GNUNET_SYSERR upon error OR the number of rows retrieved |
307 | */ | 310 | */ |
308 | static int | 311 | static int |
309 | db_read_whitelist(struct sqlite3 *db, int pid, struct WhiteListRow **wl_rows) | 312 | db_read_whitelist (struct sqlite3 *db, int pid, struct WhiteListRow **wl_rows) |
310 | { | 313 | { |
311 | static const char *query_wl = "SELECT oid, latency FROM whitelist WHERE (id == ?);"; | 314 | static const char *query_wl = |
315 | "SELECT oid, latency FROM whitelist WHERE (id == ?);"; | ||
312 | struct sqlite3_stmt *stmt_wl; | 316 | struct sqlite3_stmt *stmt_wl; |
313 | struct WhiteListRow *lr; | 317 | struct WhiteListRow *lr; |
314 | int nrows; | 318 | int nrows; |
315 | int ret; | 319 | int ret; |
316 | 320 | ||
317 | if (SQLITE_OK != (ret = sqlite3_prepare_v2(db, query_wl, -1, &stmt_wl, NULL))) | 321 | if (SQLITE_OK != (ret = sqlite3_prepare_v2 (db, query_wl, -1, &stmt_wl, |
318 | { | 322 | NULL))) |
319 | LOG_SQLITE(db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_prepare_v2"); | 323 | { |
320 | return GNUNET_SYSERR; | 324 | LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_prepare_v2"); |
321 | } | 325 | return GNUNET_SYSERR; |
322 | if (SQLITE_OK != (ret = sqlite3_bind_int(stmt_wl, 1, pid))) | 326 | } |
323 | { | 327 | if (SQLITE_OK != (ret = sqlite3_bind_int (stmt_wl, 1, pid))) |
324 | LOG_SQLITE(db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_bind_int"); | 328 | { |
325 | sqlite3_finalize(stmt_wl); | 329 | LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_bind_int"); |
326 | return GNUNET_SYSERR; | 330 | sqlite3_finalize (stmt_wl); |
327 | } | 331 | return GNUNET_SYSERR; |
332 | } | ||
328 | nrows = 0; | 333 | nrows = 0; |
329 | do | 334 | do |
330 | { | 335 | { |
331 | ret = sqlite3_step(stmt_wl); | 336 | ret = sqlite3_step (stmt_wl); |
332 | if (SQLITE_ROW != ret) | 337 | if (SQLITE_ROW != ret) |
333 | break; | 338 | break; |
334 | nrows++; | 339 | nrows++; |
335 | lr = GNUNET_new(struct WhiteListRow); | 340 | lr = GNUNET_new (struct WhiteListRow); |
336 | lr->id = sqlite3_column_int(stmt_wl, 0); | 341 | lr->id = sqlite3_column_int (stmt_wl, 0); |
337 | lr->latency = sqlite3_column_int(stmt_wl, 1); | 342 | lr->latency = sqlite3_column_int (stmt_wl, 1); |
338 | lr->next = *wl_rows; | 343 | lr->next = *wl_rows; |
339 | *wl_rows = lr; | 344 | *wl_rows = lr; |
340 | } | 345 | } |
341 | while (1); | 346 | while (1); |
342 | sqlite3_finalize(stmt_wl); | 347 | sqlite3_finalize (stmt_wl); |
343 | return nrows; | 348 | return nrows; |
344 | } | 349 | } |
345 | 350 | ||
@@ -353,8 +358,8 @@ db_read_whitelist(struct sqlite3 *db, int pid, struct WhiteListRow **wl_rows) | |||
353 | * @param c configuration | 358 | * @param c configuration |
354 | */ | 359 | */ |
355 | static void | 360 | static void |
356 | run(void *cls, char *const *args, const char *cfgfile, | 361 | run (void *cls, char *const *args, const char *cfgfile, |
357 | const struct GNUNET_CONFIGURATION_Handle *c) | 362 | const struct GNUNET_CONFIGURATION_Handle *c) |
358 | { | 363 | { |
359 | char *dbfile; | 364 | char *dbfile; |
360 | struct WhiteListRow *wl_head; | 365 | struct WhiteListRow *wl_head; |
@@ -367,78 +372,80 @@ run(void *cls, char *const *args, const char *cfgfile, | |||
367 | int ret; | 372 | int ret; |
368 | 373 | ||
369 | if (GNUNET_OK != | 374 | if (GNUNET_OK != |
370 | GNUNET_CONFIGURATION_get_value_number(c, "TESTBED", | 375 | GNUNET_CONFIGURATION_get_value_number (c, "TESTBED", |
371 | "PEERID", &pid)) | 376 | "PEERID", &pid)) |
377 | { | ||
378 | GNUNET_break (0); | ||
379 | return; | ||
380 | } | ||
381 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (c, | ||
382 | "TESTBED-UNDERLAY", | ||
383 | "DBFILE", | ||
384 | &dbfile)) | ||
385 | { | ||
386 | GNUNET_break (0); | ||
387 | return; | ||
388 | } | ||
389 | if (SQLITE_OK != (ret = sqlite3_open_v2 (dbfile, &db, SQLITE_OPEN_READONLY, | ||
390 | NULL))) | ||
391 | { | ||
392 | if (NULL != db) | ||
372 | { | 393 | { |
373 | GNUNET_break(0); | 394 | LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite_open_v2"); |
374 | return; | 395 | GNUNET_break (SQLITE_OK == sqlite3_close (db)); |
375 | } | 396 | } |
376 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename(c, "TESTBED-UNDERLAY", | 397 | else |
377 | "DBFILE", | 398 | LOG (GNUNET_ERROR_TYPE_ERROR, "Cannot open sqlite file %s\n", dbfile); |
378 | &dbfile)) | 399 | GNUNET_free (dbfile); |
379 | { | 400 | return; |
380 | GNUNET_break(0); | 401 | } |
381 | return; | 402 | DEBUG ("Opened database %s\n", dbfile); |
382 | } | 403 | GNUNET_free (dbfile); |
383 | if (SQLITE_OK != (ret = sqlite3_open_v2(dbfile, &db, SQLITE_OPEN_READONLY, NULL))) | ||
384 | { | ||
385 | if (NULL != db) | ||
386 | { | ||
387 | LOG_SQLITE(db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite_open_v2"); | ||
388 | GNUNET_break(SQLITE_OK == sqlite3_close(db)); | ||
389 | } | ||
390 | else | ||
391 | LOG(GNUNET_ERROR_TYPE_ERROR, "Cannot open sqlite file %s\n", dbfile); | ||
392 | GNUNET_free(dbfile); | ||
393 | return; | ||
394 | } | ||
395 | DEBUG("Opened database %s\n", dbfile); | ||
396 | GNUNET_free(dbfile); | ||
397 | dbfile = NULL; | 404 | dbfile = NULL; |
398 | wl_head = NULL; | 405 | wl_head = NULL; |
399 | if (GNUNET_OK != load_keys(c)) | 406 | if (GNUNET_OK != load_keys (c)) |
400 | goto close_db; | 407 | goto close_db; |
401 | 408 | ||
402 | transport = GNUNET_TRANSPORT_manipulation_connect(c); | 409 | transport = GNUNET_TRANSPORT_manipulation_connect (c); |
403 | if (NULL == transport) | 410 | if (NULL == transport) |
404 | { | 411 | { |
405 | GNUNET_break(0); | 412 | GNUNET_break (0); |
406 | return; | 413 | return; |
407 | } | 414 | } |
408 | /* read and process whitelist */ | 415 | /* read and process whitelist */ |
409 | nrows = 0; | 416 | nrows = 0; |
410 | wl_head = NULL; | 417 | wl_head = NULL; |
411 | nrows = db_read_whitelist(db, pid, &wl_head); | 418 | nrows = db_read_whitelist (db, pid, &wl_head); |
412 | if ((GNUNET_SYSERR == nrows) || (0 == nrows)) | 419 | if ((GNUNET_SYSERR == nrows) || (0 == nrows)) |
413 | { | 420 | { |
414 | GNUNET_TRANSPORT_manipulation_disconnect(transport); | 421 | GNUNET_TRANSPORT_manipulation_disconnect (transport); |
415 | goto close_db; | 422 | goto close_db; |
416 | } | 423 | } |
417 | map = GNUNET_CONTAINER_multipeermap_create(nrows, GNUNET_NO); | 424 | map = GNUNET_CONTAINER_multipeermap_create (nrows, GNUNET_NO); |
418 | while (NULL != (wl_entry = wl_head)) | 425 | while (NULL != (wl_entry = wl_head)) |
419 | { | 426 | { |
420 | wl_head = wl_entry->next; | 427 | wl_head = wl_entry->next; |
421 | delay.rel_value_us = wl_entry->latency; | 428 | delay.rel_value_us = wl_entry->latency; |
422 | memset(&prop, 0, sizeof(prop)); | 429 | memset (&prop, 0, sizeof(prop)); |
423 | GNUNET_assert(GNUNET_OK == get_identity(wl_entry->id, &identity)); | 430 | GNUNET_assert (GNUNET_OK == get_identity (wl_entry->id, &identity)); |
424 | GNUNET_break(GNUNET_OK == | 431 | GNUNET_break (GNUNET_OK == |
425 | GNUNET_CONTAINER_multipeermap_put(map, &identity, &identity, | 432 | GNUNET_CONTAINER_multipeermap_put (map, &identity, &identity, |
426 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)); | 433 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)); |
427 | DEBUG("Setting %u ms latency to peer `%s'\n", | 434 | DEBUG ("Setting %u ms latency to peer `%s'\n", |
428 | wl_entry->latency, | 435 | wl_entry->latency, |
429 | GNUNET_i2s(&identity)); | 436 | GNUNET_i2s (&identity)); |
430 | GNUNET_TRANSPORT_manipulation_set(transport, | 437 | GNUNET_TRANSPORT_manipulation_set (transport, |
431 | &identity, | 438 | &identity, |
432 | &prop, | 439 | &prop, |
433 | delay, | 440 | delay, |
434 | delay); | 441 | delay); |
435 | GNUNET_free(wl_entry); | 442 | GNUNET_free (wl_entry); |
436 | } | 443 | } |
437 | bh = GNUNET_TRANSPORT_blacklist(c, &check_access, NULL); | 444 | bh = GNUNET_TRANSPORT_blacklist (c, &check_access, NULL); |
438 | GNUNET_SCHEDULER_add_shutdown(&do_shutdown, NULL); | 445 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); |
439 | 446 | ||
440 | close_db: | 447 | close_db: |
441 | GNUNET_break(SQLITE_OK == sqlite3_close(db)); | 448 | GNUNET_break (SQLITE_OK == sqlite3_close (db)); |
442 | } | 449 | } |
443 | 450 | ||
444 | 451 | ||
@@ -450,24 +457,25 @@ close_db: | |||
450 | * @return 0 ok, 1 on error | 457 | * @return 0 ok, 1 on error |
451 | */ | 458 | */ |
452 | int | 459 | int |
453 | main(int argc, char *const *argv) | 460 | main (int argc, char *const *argv) |
454 | { | 461 | { |
455 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 462 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { |
456 | GNUNET_GETOPT_OPTION_END | 463 | GNUNET_GETOPT_OPTION_END |
457 | }; | 464 | }; |
458 | int ret; | 465 | int ret; |
459 | 466 | ||
460 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args(argc, argv, &argc, &argv)) | 467 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |
461 | return 2; | 468 | return 2; |
462 | #ifdef SQLITE_CONFIG_MMAP_SIZE | 469 | #ifdef SQLITE_CONFIG_MMAP_SIZE |
463 | (void)sqlite3_config(SQLITE_CONFIG_MMAP_SIZE, 512000, 256000000); | 470 | (void) sqlite3_config (SQLITE_CONFIG_MMAP_SIZE, 512000, 256000000); |
464 | #endif | 471 | #endif |
465 | ret = | 472 | ret = |
466 | (GNUNET_OK == | 473 | (GNUNET_OK == |
467 | GNUNET_PROGRAM_run(argc, argv, "testbed-underlay", | 474 | GNUNET_PROGRAM_run (argc, argv, "testbed-underlay", |
468 | _ | 475 | _ |
469 | ("Daemon to restrict underlay network in testbed deployments"), | 476 | ( |
470 | options, &run, NULL)) ? 0 : 1; | 477 | "Daemon to restrict underlay network in testbed deployments"), |
471 | GNUNET_free((void*)argv); | 478 | options, &run, NULL)) ? 0 : 1; |
479 | GNUNET_free ((void*) argv); | ||
472 | return ret; | 480 | return ret; |
473 | } | 481 | } |