From 1bfed6cbc67309bd7002514f6e8d9ccd8500e57f Mon Sep 17 00:00:00 2001 From: bthompson Date: Fri, 4 Nov 2022 10:47:57 -0400 Subject: [PATCH] Address UDP connect message endian issue Accept big-endian and little-endian format for both legacy and new messages since the value is sent in host byte order. --- src/iperf.h | 7 ++++--- src/iperf_udp.c | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/iperf.h b/src/iperf.h index b5405f92d..8a0fc8324 100644 --- a/src/iperf.h +++ b/src/iperf.h @@ -430,9 +430,10 @@ struct iperf_test extern int gerror; /* error value from getaddrinfo(3), for use in internal error handling */ /* UDP "connect" message and reply (textual value for Wireshark, etc. readability - legacy was numeric) */ -#define UDP_CONNECT_MSG 0x36373839 // "6789" - legacy value was 123456789 -#define UDP_CONNECT_REPLY 0x39383736 // "9876" - legacy value was 987654321 -#define LEGACY_UDP_CONNECT_REPLY 987654321 // Old servers may still reply with the legacy value +#define UDP_CONNECT_MSG 0x36373839 // "6789" - legacy value was 123456789 +#define UDP_CONNECT_REPLY 0x39383736 // "9876" - legacy value was 987654321 +#define LEGACY_UDP_CONNECT_REPLY 987654321 // Old servers may still reply with legacy value +#define LEGACY_UDP_CONNECT_REPLY_ENDIAN 2976439866 // Old servers may still reply with legacy value /* In Reverse mode, maximum number of packets to wait for "accept" response - to handle out of order packets */ #define MAX_REVERSE_OUT_OF_ORDER_PACKETS 2 diff --git a/src/iperf_udp.c b/src/iperf_udp.c index b697c9729..bd6a80f8d 100644 --- a/src/iperf_udp.c +++ b/src/iperf_udp.c @@ -592,9 +592,9 @@ iperf_udp_connect(struct iperf_test *test) printf("Connect received for Socket %d, sz=%d, buf=%x, i=%d, max_len_wait_for_reply=%d\n", s, sz, buf, i, max_len_wait_for_reply); } i += sz; - } while (buf != UDP_CONNECT_REPLY && buf != LEGACY_UDP_CONNECT_REPLY && i < max_len_wait_for_reply); + } while (buf != UDP_CONNECT_REPLY && buf != LEGACY_UDP_CONNECT_REPLY && buf != UDP_CONNECT_MSG && buf != LEGACY_UDP_CONNECT_REPLY_ENDIAN && i < max_len_wait_for_reply); - if (buf != UDP_CONNECT_REPLY && buf != LEGACY_UDP_CONNECT_REPLY) { + if (buf != UDP_CONNECT_REPLY && buf != LEGACY_UDP_CONNECT_REPLY && buf != UDP_CONNECT_MSG && buf != LEGACY_UDP_CONNECT_REPLY_ENDIAN) { i_errno = IESTREAMREAD; return -1; }