diff options
Diffstat (limited to 'src/transport/gnunet-transport.c')
-rw-r--r-- | src/transport/gnunet-transport.c | 122 |
1 files changed, 61 insertions, 61 deletions
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c index fcfc94ac8..96d0a6a3a 100644 --- a/src/transport/gnunet-transport.c +++ b/src/transport/gnunet-transport.c | |||
@@ -167,11 +167,6 @@ struct PeerResolutionContext | |||
167 | #define BLOCKSIZE 4 | 167 | #define BLOCKSIZE 4 |
168 | 168 | ||
169 | /** | 169 | /** |
170 | * Which peer should we connect to? | ||
171 | */ | ||
172 | static char *cpid; | ||
173 | |||
174 | /** | ||
175 | * Handle to transport service. | 170 | * Handle to transport service. |
176 | */ | 171 | */ |
177 | static struct GNUNET_TRANSPORT_CoreHandle *handle; | 172 | static struct GNUNET_TRANSPORT_CoreHandle *handle; |
@@ -283,7 +278,7 @@ static struct GNUNET_TRANSPORT_PluginMonitor *pm; | |||
283 | 278 | ||
284 | /** | 279 | /** |
285 | * Identity of the peer we transmit to / connect to. | 280 | * Identity of the peer we transmit to / connect to. |
286 | * (equivalent to 'cpid' string). | 281 | * ('-p' command-line option). |
287 | */ | 282 | */ |
288 | static struct GNUNET_PeerIdentity pid; | 283 | static struct GNUNET_PeerIdentity pid; |
289 | 284 | ||
@@ -295,7 +290,7 @@ static struct GNUNET_SCHEDULER_Task *op_timeout; | |||
295 | /** | 290 | /** |
296 | * Selected level of verbosity. | 291 | * Selected level of verbosity. |
297 | */ | 292 | */ |
298 | static int verbosity; | 293 | static unsigned int verbosity; |
299 | 294 | ||
300 | /** | 295 | /** |
301 | * Resolver process handle. | 296 | * Resolver process handle. |
@@ -485,7 +480,7 @@ operation_timeout (void *cls) | |||
485 | _("Failed to resolve address for peer `%s'\n"), | 480 | _("Failed to resolve address for peer `%s'\n"), |
486 | GNUNET_i2s (&cur->addrcp->peer)); | 481 | GNUNET_i2s (&cur->addrcp->peer)); |
487 | 482 | ||
488 | GNUNET_CONTAINER_DLL_remove(rc_head, | 483 | GNUNET_CONTAINER_DLL_remove(rc_head, |
489 | rc_tail, | 484 | rc_tail, |
490 | cur); | 485 | cur); |
491 | GNUNET_TRANSPORT_address_to_string_cancel (cur->asc); | 486 | GNUNET_TRANSPORT_address_to_string_cancel (cur->asc); |
@@ -729,7 +724,7 @@ print_info (const struct GNUNET_PeerIdentity *id, | |||
729 | GNUNET_STRINGS_absolute_time_to_string (state_timeout)); | 724 | GNUNET_STRINGS_absolute_time_to_string (state_timeout)); |
730 | } | 725 | } |
731 | else if ( (GNUNET_YES == iterate_connections) && | 726 | else if ( (GNUNET_YES == iterate_connections) && |
732 | (GNUNET_TRANSPORT_is_connected(state)) ) | 727 | (GNUNET_TRANSPORT_is_connected(state)) ) |
733 | { | 728 | { |
734 | /* Only connected peers, skip state */ | 729 | /* Only connected peers, skip state */ |
735 | FPRINTF (stdout, | 730 | FPRINTF (stdout, |
@@ -1089,10 +1084,9 @@ plugin_monitoring_cb (void *cls, | |||
1089 | } | 1084 | } |
1090 | return; /* shutdown */ | 1085 | return; /* shutdown */ |
1091 | } | 1086 | } |
1092 | if ( (NULL != cpid) && | 1087 | if (0 != memcmp (&info->address->peer, |
1093 | (0 != memcmp (&info->address->peer, | 1088 | &pid, |
1094 | cpid, | 1089 | sizeof (struct GNUNET_PeerIdentity))) |
1095 | sizeof (struct GNUNET_PeerIdentity))) ) | ||
1096 | return; /* filtered */ | 1090 | return; /* filtered */ |
1097 | if (NULL == addr) | 1091 | if (NULL == addr) |
1098 | { | 1092 | { |
@@ -1241,21 +1235,11 @@ run (void *cls, | |||
1241 | const char *cfgfile, | 1235 | const char *cfgfile, |
1242 | const struct GNUNET_CONFIGURATION_Handle *mycfg) | 1236 | const struct GNUNET_CONFIGURATION_Handle *mycfg) |
1243 | { | 1237 | { |
1238 | static struct GNUNET_PeerIdentity zero_pid; | ||
1244 | int counter = 0; | 1239 | int counter = 0; |
1245 | ret = 1; | 1240 | ret = 1; |
1246 | 1241 | ||
1247 | cfg = (struct GNUNET_CONFIGURATION_Handle *) mycfg; | 1242 | cfg = (struct GNUNET_CONFIGURATION_Handle *) mycfg; |
1248 | if ( (NULL != cpid) && | ||
1249 | (GNUNET_OK != | ||
1250 | GNUNET_CRYPTO_eddsa_public_key_from_string (cpid, | ||
1251 | strlen (cpid), | ||
1252 | &pid.public_key))) | ||
1253 | { | ||
1254 | FPRINTF (stderr, | ||
1255 | _("Failed to parse peer identity `%s'\n"), | ||
1256 | cpid); | ||
1257 | return; | ||
1258 | } | ||
1259 | 1243 | ||
1260 | counter = benchmark_send + benchmark_receive + iterate_connections | 1244 | counter = benchmark_send + benchmark_receive + iterate_connections |
1261 | + monitor_connections + monitor_connects + do_disconnect + | 1245 | + monitor_connections + monitor_connects + do_disconnect + |
@@ -1290,7 +1274,9 @@ run (void *cls, | |||
1290 | 1274 | ||
1291 | if (do_disconnect) /* -D: Disconnect from peer */ | 1275 | if (do_disconnect) /* -D: Disconnect from peer */ |
1292 | { | 1276 | { |
1293 | if (NULL == cpid) | 1277 | if (0 == memcmp (&zero_pid, |
1278 | &pid, | ||
1279 | sizeof (pid))) | ||
1294 | { | 1280 | { |
1295 | FPRINTF (stderr, | 1281 | FPRINTF (stderr, |
1296 | _("Option `%s' makes no sense without option `%s'.\n"), | 1282 | _("Option `%s' makes no sense without option `%s'.\n"), |
@@ -1315,7 +1301,9 @@ run (void *cls, | |||
1315 | } | 1301 | } |
1316 | else if (benchmark_send) /* -s: Benchmark sending */ | 1302 | else if (benchmark_send) /* -s: Benchmark sending */ |
1317 | { | 1303 | { |
1318 | if (NULL == cpid) | 1304 | if (0 == memcmp (&zero_pid, |
1305 | &pid, | ||
1306 | sizeof (pid))) | ||
1319 | { | 1307 | { |
1320 | FPRINTF (stderr, | 1308 | FPRINTF (stderr, |
1321 | _("Option `%s' makes no sense without option `%s'.\n"), | 1309 | _("Option `%s' makes no sense without option `%s'.\n"), |
@@ -1352,7 +1340,7 @@ run (void *cls, | |||
1352 | NULL), | 1340 | NULL), |
1353 | GNUNET_MQ_handler_end () | 1341 | GNUNET_MQ_handler_end () |
1354 | }; | 1342 | }; |
1355 | 1343 | ||
1356 | handle = GNUNET_TRANSPORT_core_connect (cfg, | 1344 | handle = GNUNET_TRANSPORT_core_connect (cfg, |
1357 | NULL, | 1345 | NULL, |
1358 | handlers, | 1346 | handlers, |
@@ -1378,7 +1366,7 @@ run (void *cls, | |||
1378 | else if (iterate_connections) /* -i: List information about peers once */ | 1366 | else if (iterate_connections) /* -i: List information about peers once */ |
1379 | { | 1367 | { |
1380 | pic = GNUNET_TRANSPORT_monitor_peers (cfg, | 1368 | pic = GNUNET_TRANSPORT_monitor_peers (cfg, |
1381 | (NULL == cpid) ? NULL : &pid, | 1369 | &pid, |
1382 | GNUNET_YES, | 1370 | GNUNET_YES, |
1383 | &process_peer_iteration_cb, | 1371 | &process_peer_iteration_cb, |
1384 | (void *) cfg); | 1372 | (void *) cfg); |
@@ -1391,7 +1379,7 @@ run (void *cls, | |||
1391 | monitored_peers = GNUNET_CONTAINER_multipeermap_create (10, | 1379 | monitored_peers = GNUNET_CONTAINER_multipeermap_create (10, |
1392 | GNUNET_NO); | 1380 | GNUNET_NO); |
1393 | pic = GNUNET_TRANSPORT_monitor_peers (cfg, | 1381 | pic = GNUNET_TRANSPORT_monitor_peers (cfg, |
1394 | (NULL == cpid) ? NULL : &pid, | 1382 | &pid, |
1395 | GNUNET_NO, | 1383 | GNUNET_NO, |
1396 | &process_peer_monitoring_cb, | 1384 | &process_peer_monitoring_cb, |
1397 | NULL); | 1385 | NULL); |
@@ -1439,38 +1427,50 @@ main (int argc, | |||
1439 | char * const *argv) | 1427 | char * const *argv) |
1440 | { | 1428 | { |
1441 | int res; | 1429 | int res; |
1442 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 1430 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
1443 | { 'a', "all", NULL, | 1431 | GNUNET_GETOPT_option_flag ('a', |
1444 | gettext_noop ("print information for all peers (instead of only connected peers)"), | 1432 | "all", |
1445 | 0, &GNUNET_GETOPT_set_one, &iterate_all }, | 1433 | gettext_noop ("print information for all peers (instead of only connected peers)"), |
1446 | { 'b', "benchmark", NULL, | 1434 | &iterate_all), |
1447 | gettext_noop ("measure how fast we are receiving data from all peers (until CTRL-C)"), | 1435 | GNUNET_GETOPT_option_flag ('b', |
1448 | 0, &GNUNET_GETOPT_set_one, &benchmark_receive }, | 1436 | "benchmark", |
1449 | { 'D', "disconnect", | 1437 | gettext_noop ("measure how fast we are receiving data from all peers (until CTRL-C)"), |
1450 | NULL, gettext_noop ("disconnect from a peer"), 0, | 1438 | &benchmark_receive), |
1451 | &GNUNET_GETOPT_set_one, &do_disconnect }, | 1439 | GNUNET_GETOPT_option_flag ('D', |
1452 | { 'i', "information", NULL, | 1440 | "disconnect", |
1453 | gettext_noop ("provide information about all current connections (once)"), | 1441 | gettext_noop ("disconnect from a peer"), |
1454 | 0, &GNUNET_GETOPT_set_one, &iterate_connections }, | 1442 | &do_disconnect), |
1455 | { 'm', "monitor", NULL, | 1443 | GNUNET_GETOPT_option_flag ('i', |
1456 | gettext_noop ("provide information about all current connections (continuously)"), | 1444 | "information", |
1457 | 0, &GNUNET_GETOPT_set_one, &monitor_connections }, | 1445 | gettext_noop ("provide information about all current connections (once)"), |
1458 | { 'e', "events", NULL, | 1446 | &iterate_connections), |
1459 | gettext_noop ("provide information about all connects and disconnect events (continuously)"), | 1447 | GNUNET_GETOPT_option_flag ('m', |
1460 | 0, &GNUNET_GETOPT_set_one, &monitor_connects }, | 1448 | "monitor", |
1461 | { 'n', "numeric", | 1449 | gettext_noop ("provide information about all current connections (continuously)"), |
1462 | NULL, gettext_noop ("do not resolve hostnames"), 0, | 1450 | &monitor_connections), |
1463 | &GNUNET_GETOPT_set_one, &numeric }, | 1451 | GNUNET_GETOPT_option_flag ('e', |
1464 | { 'p', "peer", "PEER", | 1452 | "events", |
1465 | gettext_noop ("peer identity"), 1, &GNUNET_GETOPT_set_string, | 1453 | gettext_noop ("provide information about all connects and disconnect events (continuously)"), |
1466 | &cpid }, | 1454 | &monitor_connects), |
1467 | { 'P', "plugins", NULL, | 1455 | GNUNET_GETOPT_option_flag ('n', |
1468 | gettext_noop ("monitor plugin sessions"), 0, &GNUNET_GETOPT_set_one, | 1456 | "numeric", |
1469 | &monitor_plugins }, | 1457 | gettext_noop ("do not resolve hostnames"), |
1470 | { 's', "send", NULL, gettext_noop | 1458 | &numeric), |
1471 | ("send data for benchmarking to the other peer (until CTRL-C)"), 0, | 1459 | GNUNET_GETOPT_option_base32_auto ('p', |
1472 | &GNUNET_GETOPT_set_one, &benchmark_send }, | 1460 | "peer", |
1473 | GNUNET_GETOPT_OPTION_VERBOSE (&verbosity), | 1461 | "PEER", |
1462 | gettext_noop ("peer identity"), | ||
1463 | &pid), | ||
1464 | GNUNET_GETOPT_option_flag ('P', | ||
1465 | "plugins", | ||
1466 | gettext_noop ("monitor plugin sessions"), | ||
1467 | &monitor_plugins), | ||
1468 | GNUNET_GETOPT_option_flag ('s', | ||
1469 | "send", | ||
1470 | gettext_noop | ||
1471 | ("send data for benchmarking to the other peer (until CTRL-C)"), | ||
1472 | &benchmark_send), | ||
1473 | GNUNET_GETOPT_option_verbose (&verbosity), | ||
1474 | GNUNET_GETOPT_OPTION_END | 1474 | GNUNET_GETOPT_OPTION_END |
1475 | }; | 1475 | }; |
1476 | 1476 | ||