aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/gnunet-service-transport.c')
-rw-r--r--src/transport/gnunet-service-transport.c77
1 files changed, 51 insertions, 26 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index bb6686a42..e927a11f5 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -45,9 +45,9 @@
45#include "plugin_transport.h" 45#include "plugin_transport.h"
46#include "transport.h" 46#include "transport.h"
47 47
48#define DEBUG_BLACKLIST GNUNET_NO 48#define DEBUG_BLACKLIST GNUNET_YES
49 49
50#define DEBUG_PING_PONG GNUNET_NO 50#define DEBUG_PING_PONG GNUNET_YES
51 51
52/** 52/**
53 * Should we do some additional checks (to validate behavior 53 * Should we do some additional checks (to validate behavior
@@ -1393,6 +1393,32 @@ transmit_send_continuation (void *cls,
1393 1393
1394 1394
1395/** 1395/**
1396 * Convert an address to a string.
1397 *
1398 * @param plugin name of the plugin responsible for the address
1399 * @param addr binary address
1400 * @param addr_len number of bytes in addr
1401 * @return NULL on error, otherwise address string
1402 */
1403static const char*
1404a2s (const char *plugin,
1405 const void *addr,
1406 size_t addr_len)
1407{
1408 struct TransportPlugin *p;
1409
1410 if (plugin == NULL)
1411 return NULL;
1412 p = find_transport (plugin);
1413 if (p == NULL)
1414 return NULL;
1415 return p->api->address_to_string (p->api->cls,
1416 addr,
1417 addr_len);
1418}
1419
1420
1421/**
1396 * Find an address in any of the available transports for 1422 * Find an address in any of the available transports for
1397 * the given neighbour that would be good for message 1423 * the given neighbour that would be good for message
1398 * transmission. This is essentially the transport selection 1424 * transmission. This is essentially the transport selection
@@ -1439,8 +1465,9 @@ find_ready_address(struct NeighbourList *neighbour)
1439 if (addresses->addr != NULL) 1465 if (addresses->addr != NULL)
1440 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1466 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1441 "Have address `%s' for peer `%4s' (status: %d, %d, %d, %u, %llums, %u)\n", 1467 "Have address `%s' for peer `%4s' (status: %d, %d, %d, %u, %llums, %u)\n",
1442 GNUNET_a2s (addresses->addr, 1468 a2s (head->plugin->short_name,
1443 addresses->addrlen), 1469 addresses->addr,
1470 addresses->addrlen),
1444 GNUNET_i2s (&neighbour->id), 1471 GNUNET_i2s (&neighbour->id),
1445 addresses->connected, 1472 addresses->connected,
1446 addresses->in_transmit, 1473 addresses->in_transmit,
@@ -1601,8 +1628,9 @@ try_transmission_to_peer (struct NeighbourList *neighbour)
1601 mq->message_buf_size, 1628 mq->message_buf_size,
1602 GNUNET_i2s (&neighbour->id), 1629 GNUNET_i2s (&neighbour->id),
1603 (mq->specific_address->addr != NULL) 1630 (mq->specific_address->addr != NULL)
1604 ? GNUNET_a2s (mq->specific_address->addr, 1631 ? a2s (mq->specific_address->plugin->short_name,
1605 mq->specific_address->addrlen) 1632 mq->specific_address->addr,
1633 mq->specific_address->addrlen)
1606 : "<inbound>", 1634 : "<inbound>",
1607 rl->plugin->short_name); 1635 rl->plugin->short_name);
1608#endif 1636#endif
@@ -2426,7 +2454,7 @@ add_to_foreign_address_list (void *cls,
2426#if DEBUG_TRANSPORT 2454#if DEBUG_TRANSPORT
2427 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2455 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2428 "Adding address `%s' (%s) for peer `%4s' due to peerinfo data for %llums.\n", 2456 "Adding address `%s' (%s) for peer `%4s' due to peerinfo data for %llums.\n",
2429 GNUNET_a2s (addr, addrlen), 2457 a2s (tname, addr, addrlen),
2430 tname, 2458 tname,
2431 GNUNET_i2s (&n->id), 2459 GNUNET_i2s (&n->id),
2432 expiration.value); 2460 expiration.value);
@@ -3001,8 +3029,9 @@ send_periodic_ping (void *cls,
3001 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3029 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3002 "Some validation of address `%s' via `%s' for peer `%4s' already in progress.\n", 3030 "Some validation of address `%s' via `%s' for peer `%4s' already in progress.\n",
3003 (peer_address->addr != NULL) 3031 (peer_address->addr != NULL)
3004 ? GNUNET_a2s (peer_address->addr, 3032 ? a2s (peer_address->plugin->short_name,
3005 peer_address->addrlen) 3033 peer_address->addr,
3034 peer_address->addrlen)
3006 : "<inbound>", 3035 : "<inbound>",
3007 tp->short_name, 3036 tp->short_name,
3008 GNUNET_i2s (&neighbour->id)); 3037 GNUNET_i2s (&neighbour->id));
@@ -3049,8 +3078,9 @@ send_periodic_ping (void *cls,
3049 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3078 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3050 "Performing re-validation of address `%s' via `%s' for peer `%4s' sending `%s' (%u bytes) and `%s' (%u bytes)\n", 3079 "Performing re-validation of address `%s' via `%s' for peer `%4s' sending `%s' (%u bytes) and `%s' (%u bytes)\n",
3051 (peer_address->addr != NULL) 3080 (peer_address->addr != NULL)
3052 ? GNUNET_a2s (peer_address->addr, 3081 ? a2s (peer_address->plugin->short_name,
3053 peer_address->addrlen) 3082 peer_address->addr,
3083 peer_address->addrlen)
3054 : "<inbound>", 3084 : "<inbound>",
3055 tp->short_name, 3085 tp->short_name,
3056 GNUNET_i2s (&neighbour->id), 3086 GNUNET_i2s (&neighbour->id),
@@ -3231,8 +3261,9 @@ check_pending_validation (void *cls,
3231 "Confirmed validity of address, peer `%4s' has address `%s' (%s).\n", 3261 "Confirmed validity of address, peer `%4s' has address `%s' (%s).\n",
3232 GNUNET_h2s (key), 3262 GNUNET_h2s (key),
3233 (ve->addr != NULL) 3263 (ve->addr != NULL)
3234 ? GNUNET_a2s ((const struct sockaddr *) ve->addr, 3264 ? a2s (ve->transport_name,
3235 ve->addrlen) 3265 (const struct sockaddr *) ve->addr,
3266 ve->addrlen)
3236 : "<inbound>", 3267 : "<inbound>",
3237 ve->transport_name); 3268 ve->transport_name);
3238#endif 3269#endif
@@ -3368,15 +3399,6 @@ handle_pong (void *cls, const struct GNUNET_MessageHeader *message,
3368 return; 3399 return;
3369 } 3400 }
3370 3401
3371#if 0
3372 /* FIXME: add given address to potential pool of our addresses
3373 (for voting) */
3374 GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK,
3375 _("Another peer saw us using the address `%s' via `%s'.\n"),
3376 GNUNET_a2s ((const struct sockaddr *) &pong[1],
3377 ntohs(pong->addrlen)),
3378 va->transport_name);
3379#endif
3380} 3402}
3381 3403
3382 3404
@@ -3434,7 +3456,8 @@ transmit_hello_and_ping (void *cls,
3434#if DEBUG_TRANSPORT 3456#if DEBUG_TRANSPORT
3435 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3457 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3436 "Performing validation of address `%s' via `%s' for peer `%4s' sending `%s' (%u bytes) and `%s' (%u bytes)\n", 3458 "Performing validation of address `%s' via `%s' for peer `%4s' sending `%s' (%u bytes) and `%s' (%u bytes)\n",
3437 GNUNET_a2s ((const void*) &va[1], va->addrlen), 3459 a2s (va->transport_name,
3460 (const void*) &va[1], va->addrlen),
3438 va->transport_name, 3461 va->transport_name,
3439 GNUNET_i2s (&neighbour->id), 3462 GNUNET_i2s (&neighbour->id),
3440 "HELLO", hello_size, 3463 "HELLO", hello_size,
@@ -3548,7 +3571,7 @@ run_validation (void *cls,
3548#if DEBUG_TRANSPORT > 1 3571#if DEBUG_TRANSPORT > 1
3549 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3572 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3550 "Validation of address `%s' via `%s' for peer `%4s' already in progress.\n", 3573 "Validation of address `%s' via `%s' for peer `%4s' already in progress.\n",
3551 GNUNET_a2s (addr, addrlen), 3574 a2s (tname, addr, addrlen),
3552 tname, 3575 tname,
3553 GNUNET_i2s (&id)); 3576 GNUNET_i2s (&id));
3554#endif 3577#endif
@@ -3939,8 +3962,9 @@ handle_ping(void *cls, const struct GNUNET_MessageHeader *message,
3939 "Processing `%s' from `%s'\n", 3962 "Processing `%s' from `%s'\n",
3940 "PING", 3963 "PING",
3941 (sender_address != NULL) 3964 (sender_address != NULL)
3942 ? GNUNET_a2s ((const struct sockaddr *)sender_address, 3965 ? a2s (plugin->short_name,
3943 sender_address_len) 3966 (const struct sockaddr *)sender_address,
3967 sender_address_len)
3944 : "<inbound>"); 3968 : "<inbound>");
3945#endif 3969#endif
3946 GNUNET_STATISTICS_update (stats, 3970 GNUNET_STATISTICS_update (stats,
@@ -4895,6 +4919,7 @@ run (void *cls,
4895int 4919int
4896main (int argc, char *const *argv) 4920main (int argc, char *const *argv)
4897{ 4921{
4922 a2s (NULL, NULL, 0); /* make compiler happy */
4898 return (GNUNET_OK == 4923 return (GNUNET_OK ==
4899 GNUNET_SERVICE_run (argc, 4924 GNUNET_SERVICE_run (argc,
4900 argv, 4925 argv,