Skip to content

Commit

Permalink
Address UDP connect message endian issue
Browse files Browse the repository at this point in the history
Accept big-endian and little-endian format for both legacy and new
messages since the value is sent in host byte order.
  • Loading branch information
mriswyth committed Nov 4, 2022
1 parent 3d1218b commit 087fa8b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/iperf.h
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ extern int gerror; /* error value from getaddrinfo(3), for use in internal error
/* 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_MSG 123456789 // Old servers may still reply with the legacy value
#define LEGACY_UDP_CONNECT_REPLY 987654321 // Old servers may still reply with the legacy value

/* In Reverse mode, maximum number of packets to wait for "accept" response - to handle out of order packets */
Expand Down
4 changes: 2 additions & 2 deletions src/iperf_udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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_MSG && 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_MSG) {
i_errno = IESTREAMREAD;
return -1;
}
Expand Down

0 comments on commit 087fa8b

Please sign in to comment.