diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2014-01-08 13:55:29 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2014-01-08 13:55:29 +0000 |
commit | b2df9f3d5fc484516a863aebbb72ab5dc3417b77 (patch) | |
tree | 202e50fdf7bcf955b916948f373240d89f53e7c3 /src/testbed/gnunet-daemon-testbed-underlay.c | |
parent | acd7a98dade8dc8b85505162f0aa4fd8e47d3126 (diff) | |
download | gnunet-b2df9f3d5fc484516a863aebbb72ab5dc3417b77.tar.gz gnunet-b2df9f3d5fc484516a863aebbb72ab5dc3417b77.zip |
- fixes
Diffstat (limited to 'src/testbed/gnunet-daemon-testbed-underlay.c')
-rw-r--r-- | src/testbed/gnunet-daemon-testbed-underlay.c | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/src/testbed/gnunet-daemon-testbed-underlay.c b/src/testbed/gnunet-daemon-testbed-underlay.c index aa4c9685a..5c5b5cddf 100644 --- a/src/testbed/gnunet-daemon-testbed-underlay.c +++ b/src/testbed/gnunet-daemon-testbed-underlay.c | |||
@@ -89,7 +89,7 @@ static struct GNUNET_DISK_MapHandle *hostkeys_map; | |||
89 | /** | 89 | /** |
90 | * The hostkeys data | 90 | * The hostkeys data |
91 | */ | 91 | */ |
92 | static char *hostkeys_data; | 92 | static void *hostkeys_data; |
93 | 93 | ||
94 | /** | 94 | /** |
95 | * Handle to the transport service. This is used for setting link metrics | 95 | * Handle to the transport service. This is used for setting link metrics |
@@ -193,19 +193,10 @@ struct WhiteListRow | |||
193 | unsigned int id; | 193 | unsigned int id; |
194 | 194 | ||
195 | /** | 195 | /** |
196 | * Bandwidth to be assigned to the link | ||
197 | */ | ||
198 | int bandwidth; | ||
199 | |||
200 | /** | ||
201 | * Latency to be assigned to the link | 196 | * Latency to be assigned to the link |
202 | */ | 197 | */ |
203 | int latency; | 198 | int latency; |
204 | 199 | ||
205 | /** | ||
206 | * Loss to be assigned to the link | ||
207 | */ | ||
208 | int loss; | ||
209 | }; | 200 | }; |
210 | 201 | ||
211 | 202 | ||
@@ -294,6 +285,11 @@ unload_keys () | |||
294 | static void | 285 | static void |
295 | do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 286 | do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
296 | { | 287 | { |
288 | if (NULL != transport) | ||
289 | { | ||
290 | GNUNET_TRANSPORT_disconnect (transport); | ||
291 | transport = NULL; | ||
292 | } | ||
297 | cleanup_map (); | 293 | cleanup_map (); |
298 | unload_keys (); | 294 | unload_keys (); |
299 | if (NULL != bh) | 295 | if (NULL != bh) |
@@ -310,9 +306,9 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
310 | * @return GNUNET_SYSERR upon error OR the number of rows retrieved | 306 | * @return GNUNET_SYSERR upon error OR the number of rows retrieved |
311 | */ | 307 | */ |
312 | static int | 308 | static int |
313 | db_read_whitelist (struct sqlite3 *db, unsigned int pid, struct WhiteListRow **wl_rows) | 309 | db_read_whitelist (struct sqlite3 *db, int pid, struct WhiteListRow **wl_rows) |
314 | { | 310 | { |
315 | static const char *query_wl = "SELECT (oid, bandwidth, latency, loss) FROM whitelist WHERE (id == ?);"; | 311 | static const char *query_wl = "SELECT oid, latency FROM whitelist WHERE (id == ?);"; |
316 | struct sqlite3_stmt *stmt_wl; | 312 | struct sqlite3_stmt *stmt_wl; |
317 | struct WhiteListRow *lr; | 313 | struct WhiteListRow *lr; |
318 | int nrows; | 314 | int nrows; |
@@ -337,10 +333,8 @@ db_read_whitelist (struct sqlite3 *db, unsigned int pid, struct WhiteListRow **w | |||
337 | break; | 333 | break; |
338 | nrows++; | 334 | nrows++; |
339 | lr = GNUNET_new (struct WhiteListRow); | 335 | lr = GNUNET_new (struct WhiteListRow); |
340 | lr->id = sqlite3_column_int (stmt_wl, 1); | 336 | lr->id = sqlite3_column_int (stmt_wl, 0); |
341 | lr->bandwidth = sqlite3_column_int (stmt_wl, 2); | 337 | lr->latency = sqlite3_column_int (stmt_wl, 1); |
342 | lr->latency = sqlite3_column_int (stmt_wl, 3); | ||
343 | lr->loss = sqlite3_column_int (stmt_wl, 4); | ||
344 | lr->next = *wl_rows; | 338 | lr->next = *wl_rows; |
345 | *wl_rows = lr; | 339 | *wl_rows = lr; |
346 | } while (1); | 340 | } while (1); |
@@ -376,12 +370,6 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
376 | GNUNET_break (0); | 370 | GNUNET_break (0); |
377 | return; | 371 | return; |
378 | } | 372 | } |
379 | transport = GNUNET_TRANSPORT_connect (c, NULL, NULL, NULL, NULL, NULL); | ||
380 | if (NULL == transport) | ||
381 | { | ||
382 | GNUNET_break (0); | ||
383 | return; | ||
384 | } | ||
385 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (c, "TESTBED-UNDERLAY", | 373 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (c, "TESTBED-UNDERLAY", |
386 | "DBFILE", | 374 | "DBFILE", |
387 | &dbfile)) | 375 | &dbfile)) |
@@ -407,13 +395,23 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
407 | wl_head = NULL; | 395 | wl_head = NULL; |
408 | if (GNUNET_OK != load_keys (c)) | 396 | if (GNUNET_OK != load_keys (c)) |
409 | goto close_db; | 397 | goto close_db; |
398 | |||
399 | transport = GNUNET_TRANSPORT_connect (c, NULL, NULL, NULL, NULL, NULL); | ||
400 | if (NULL == transport) | ||
401 | { | ||
402 | GNUNET_break (0); | ||
403 | return; | ||
404 | } | ||
410 | /* read and process whitelist */ | 405 | /* read and process whitelist */ |
411 | nrows = 0; | 406 | nrows = 0; |
412 | wl_head = NULL; | 407 | wl_head = NULL; |
413 | nrows = db_read_whitelist (db, pid, &wl_head); | 408 | nrows = db_read_whitelist (db, pid, &wl_head); |
414 | if ((GNUNET_SYSERR == nrows) || (0 == nrows)) | 409 | if ((GNUNET_SYSERR == nrows) || (0 == nrows)) |
410 | { | ||
411 | GNUNET_TRANSPORT_disconnect (transport); | ||
415 | goto close_db; | 412 | goto close_db; |
416 | map = GNUNET_CONTAINER_multipeermap_create (nrows, GNUNET_YES); | 413 | } |
414 | map = GNUNET_CONTAINER_multipeermap_create (nrows, GNUNET_NO); | ||
417 | params[0].type = GNUNET_ATS_QUALITY_NET_DELAY; | 415 | params[0].type = GNUNET_ATS_QUALITY_NET_DELAY; |
418 | while (NULL != (wl_entry = wl_head)) | 416 | while (NULL != (wl_entry = wl_head)) |
419 | { | 417 | { |
@@ -423,11 +421,14 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
423 | GNUNET_break (GNUNET_OK == | 421 | GNUNET_break (GNUNET_OK == |
424 | GNUNET_CONTAINER_multipeermap_put (map, &identity, &identity, | 422 | GNUNET_CONTAINER_multipeermap_put (map, &identity, &identity, |
425 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)); | 423 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)); |
424 | DEBUG ("Setting %u ms latency to peer `%s'\n", | ||
425 | wl_entry->latency, | ||
426 | GNUNET_i2s (&identity)); | ||
426 | GNUNET_TRANSPORT_set_traffic_metric (transport, | 427 | GNUNET_TRANSPORT_set_traffic_metric (transport, |
427 | &identity, | 428 | &identity, |
428 | GNUNET_YES, | 429 | GNUNET_YES, |
429 | GNUNET_YES, /* FIXME: Separate inbound, outboud metrics */ | 430 | GNUNET_YES, /* FIXME: Separate inbound, outboud metrics */ |
430 | params, 3); | 431 | params, 1); |
431 | GNUNET_free (wl_entry); | 432 | GNUNET_free (wl_entry); |
432 | } | 433 | } |
433 | bh = GNUNET_TRANSPORT_blacklist (c, &check_access, NULL); | 434 | bh = GNUNET_TRANSPORT_blacklist (c, &check_access, NULL); |
@@ -435,7 +436,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
435 | &do_shutdown, NULL); | 436 | &do_shutdown, NULL); |
436 | 437 | ||
437 | close_db: | 438 | close_db: |
438 | GNUNET_break (GNUNET_OK == sqlite3_close (db)); | 439 | GNUNET_break (SQLITE_OK == sqlite3_close (db)); |
439 | return; | 440 | return; |
440 | } | 441 | } |
441 | 442 | ||