diff options
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/gnunet-transport.c | 56 |
1 files changed, 22 insertions, 34 deletions
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c index c0442950d..8624b09b4 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 | ||
@@ -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); |
@@ -1451,7 +1439,7 @@ main (int argc, | |||
1451 | GNUNET_GETOPT_OPTION_SET_ONE ('D', | 1439 | GNUNET_GETOPT_OPTION_SET_ONE ('D', |
1452 | "disconnect", | 1440 | "disconnect", |
1453 | gettext_noop ("disconnect from a peer"), | 1441 | gettext_noop ("disconnect from a peer"), |
1454 | &do_disconnect), | 1442 | &do_disconnect), |
1455 | GNUNET_GETOPT_OPTION_SET_ONE ('i', | 1443 | GNUNET_GETOPT_OPTION_SET_ONE ('i', |
1456 | "information", | 1444 | "information", |
1457 | gettext_noop ("provide information about all current connections (once)"), | 1445 | gettext_noop ("provide information about all current connections (once)"), |
@@ -1468,11 +1456,11 @@ main (int argc, | |||
1468 | "numeric", | 1456 | "numeric", |
1469 | gettext_noop ("do not resolve hostnames"), | 1457 | gettext_noop ("do not resolve hostnames"), |
1470 | &numeric), | 1458 | &numeric), |
1471 | GNUNET_GETOPT_OPTION_STRING ('p', | 1459 | GNUNET_GETOPT_OPTION_SET_BASE32_AUTO ('p', |
1472 | "peer", | 1460 | "peer", |
1473 | "PEER", | 1461 | "PEER", |
1474 | gettext_noop ("peer identity"), | 1462 | gettext_noop ("peer identity"), |
1475 | &cpid), | 1463 | &pid), |
1476 | GNUNET_GETOPT_OPTION_SET_ONE ('P', | 1464 | GNUNET_GETOPT_OPTION_SET_ONE ('P', |
1477 | "plugins", | 1465 | "plugins", |
1478 | gettext_noop ("monitor plugin sessions"), | 1466 | gettext_noop ("monitor plugin sessions"), |