From c34548d2d6629269e689a9b2685df7e375a9c7a8 Mon Sep 17 00:00:00 2001 From: "Nathan S. Evans" Date: Wed, 1 Sep 2010 13:18:50 +0000 Subject: [PATCH] transport service hello reduction, klocwork fixes --- src/transport/gnunet-service-transport.c | 24 ++++++++++++++++++++++-- src/transport/plugin_transport_tcp.c | 1 - src/transport/plugin_transport_udp.c | 4 ++-- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index de25666fa..9c873291f 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -2792,6 +2792,11 @@ setup_new_neighbour (const struct GNUNET_PeerIdentity *peer, n->piter = GNUNET_PEERINFO_iterate (peerinfo, peer, GNUNET_TIME_UNIT_FOREVER_REL, &add_hello_for_peer, n); + + GNUNET_STATISTICS_update (stats, + gettext_noop ("# HELLO's sent to new neighbors"), + 1, + GNUNET_NO); transmit_to_peer (NULL, NULL, 0, HELLO_ADDRESS_EXPIRATION, (const char *) our_hello, GNUNET_HELLO_size(our_hello), @@ -3258,8 +3263,14 @@ send_periodic_ping (void *cls, &neighbour->id.hashPubKey, va, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); - hello_size = GNUNET_HELLO_size(our_hello); + + if (peer_address->validated != GNUNET_YES) + hello_size = GNUNET_HELLO_size(our_hello); + else + hello_size = 0; + tsize = sizeof(struct TransportPingMessage) + hello_size; + if (peer_address->addr != NULL) { slen = strlen (tp->short_name) + 1; @@ -3273,7 +3284,9 @@ send_periodic_ping (void *cls, ping.header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_PING); ping.challenge = htonl(va->challenge); memcpy(&ping.target, &neighbour->id, sizeof(struct GNUNET_PeerIdentity)); - memcpy(message_buf, our_hello, hello_size); + if (peer_address->validated != GNUNET_YES) + memcpy(message_buf, our_hello, hello_size); + if (peer_address->addr != NULL) { ping.header.size = htons(sizeof(struct TransportPingMessage) + @@ -3307,6 +3320,13 @@ send_periodic_ping (void *cls, "HELLO", hello_size, "PING"); #endif + if (peer_address->validated != GNUNET_YES) + GNUNET_STATISTICS_update (stats, + gettext_noop ("# PING+HELLO messages sent"), + 1, + GNUNET_NO); + + GNUNET_STATISTICS_update (stats, gettext_noop ("# PING messages sent for re-validation"), 1, diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index d382b5108..ffc738f53 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c @@ -2043,7 +2043,6 @@ tcp_plugin_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc return; } - port = 0; port_start = NULL; for (i = 0; i < sizeof(mybuf); i++) { diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index f8c68244a..02f81a576 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c @@ -978,7 +978,8 @@ process_interfaces (void *cls, &((struct sockaddr_in6 *) addr)->sin6_addr, sizeof (struct in6_addr)); GNUNET_assert(NULL != inet_ntop(AF_INET6, &t6.ipv6_addr, &buf[0], INET6_ADDRSTRLEN)); - if ((plugin->bind_address != NULL) || ((plugin->bind6_address != NULL) && (0 != strcmp(buf, plugin->bind_address)))) + if (((plugin->bind_address != NULL) && (0 != strcmp(buf, plugin->bind_address))) + || ((plugin->bind6_address != NULL) && (0 != strcmp(buf, plugin->bind6_address)))) { GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: Not notifying transport of address %s\n", "UDP", GNUNET_a2s (addr, addrlen)); return GNUNET_OK; @@ -1177,7 +1178,6 @@ udp_plugin_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc return; } - port = 0; port_start = NULL; for (i = 0; i < sizeof(mybuf); i++) { -- 2.25.1