diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-12-16 19:39:17 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-12-16 19:39:17 +0000 |
commit | 0f3e7c893811e2444a03459b0a0b7c0236ca7910 (patch) | |
tree | 60a100252d2e03cda79a16869c9f81bd8591cd0f /src/transport/plugin_transport_udp.c | |
parent | 220e49fc82002262c7e5c077e878c2a3e12f2a04 (diff) | |
download | gnunet-0f3e7c893811e2444a03459b0a0b7c0236ca7910.tar.gz gnunet-0f3e7c893811e2444a03459b0a0b7c0236ca7910.zip |
-adding debug logic for #3555
Diffstat (limited to 'src/transport/plugin_transport_udp.c')
-rw-r--r-- | src/transport/plugin_transport_udp.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 37de3c06e..900cb1580 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -2635,7 +2635,7 @@ udp_select_read (struct Plugin *plugin, | |||
2635 | fromlen = sizeof(addr); | 2635 | fromlen = sizeof(addr); |
2636 | memset (&addr, 0, sizeof(addr)); | 2636 | memset (&addr, 0, sizeof(addr)); |
2637 | size = GNUNET_NETWORK_socket_recvfrom (rsock, buf, sizeof(buf), | 2637 | size = GNUNET_NETWORK_socket_recvfrom (rsock, buf, sizeof(buf), |
2638 | (struct sockaddr *) &addr, &fromlen); | 2638 | (struct sockaddr *) &addr, &fromlen); |
2639 | #if MINGW | 2639 | #if MINGW |
2640 | /* On SOCK_DGRAM UDP sockets recvfrom might fail with a | 2640 | /* On SOCK_DGRAM UDP sockets recvfrom might fail with a |
2641 | * WSAECONNRESET error to indicate that previous sendto() (yes, sendto!) | 2641 | * WSAECONNRESET error to indicate that previous sendto() (yes, sendto!) |
@@ -2652,16 +2652,18 @@ udp_select_read (struct Plugin *plugin, | |||
2652 | #endif | 2652 | #endif |
2653 | if (-1 == size) | 2653 | if (-1 == size) |
2654 | { | 2654 | { |
2655 | LOG(GNUNET_ERROR_TYPE_DEBUG, "UDP failed to receive data: %s\n", | 2655 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2656 | STRERROR (errno)); | 2656 | "UDP failed to receive data: %s\n", |
2657 | STRERROR (errno)); | ||
2657 | /* Connection failure or something. Not a protocol violation. */ | 2658 | /* Connection failure or something. Not a protocol violation. */ |
2658 | return; | 2659 | return; |
2659 | } | 2660 | } |
2660 | if (size < sizeof(struct GNUNET_MessageHeader)) | 2661 | if (size < sizeof(struct GNUNET_MessageHeader)) |
2661 | { | 2662 | { |
2662 | LOG(GNUNET_ERROR_TYPE_WARNING, | 2663 | LOG (GNUNET_ERROR_TYPE_WARNING, |
2663 | "UDP got %u bytes, which is not enough for a GNUnet message header\n", | 2664 | "UDP got %u bytes from %s, which is not enough for a GNUnet message header\n", |
2664 | (unsigned int ) size); | 2665 | (unsigned int ) size, |
2666 | GNUNET_a2s ((const struct sockaddr *) &addr, fromlen)); | ||
2665 | /* _MAY_ be a connection failure (got partial message) */ | 2667 | /* _MAY_ be a connection failure (got partial message) */ |
2666 | /* But it _MAY_ also be that the other side uses non-GNUnet protocol. */ | 2668 | /* But it _MAY_ also be that the other side uses non-GNUnet protocol. */ |
2667 | GNUNET_break_op(0); | 2669 | GNUNET_break_op(0); |
@@ -2669,13 +2671,18 @@ udp_select_read (struct Plugin *plugin, | |||
2669 | } | 2671 | } |
2670 | msg = (const struct GNUNET_MessageHeader *) buf; | 2672 | msg = (const struct GNUNET_MessageHeader *) buf; |
2671 | 2673 | ||
2672 | LOG(GNUNET_ERROR_TYPE_DEBUG, | 2674 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2673 | "UDP received %u-byte message from `%s' type %u\n", (unsigned int ) size, | 2675 | "UDP received %u-byte message from `%s' type %u\n", |
2674 | GNUNET_a2s ((const struct sockaddr * ) &addr, fromlen), | 2676 | (unsigned int) size, |
2675 | ntohs (msg->type)); | 2677 | GNUNET_a2s ((const struct sockaddr *) &addr, fromlen), |
2678 | ntohs (msg->type)); | ||
2676 | 2679 | ||
2677 | if (size != ntohs (msg->size)) | 2680 | if (size != ntohs (msg->size)) |
2678 | { | 2681 | { |
2682 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
2683 | "UDP malformed message header from %s\n", | ||
2684 | (unsigned int ) size, | ||
2685 | GNUNET_a2s ((const struct sockaddr *) &addr, fromlen)); | ||
2679 | GNUNET_break_op(0); | 2686 | GNUNET_break_op(0); |
2680 | return; | 2687 | return; |
2681 | } | 2688 | } |