Skip to content

Commit 4582c64

Browse files
JordanYateskartben
authored andcommitted
net: lib: zperf: warning on bad response flags
Output a warning if the server response does not have the expected header flag set. Signed-off-by: Jordan Yates <jordan@embeint.com>
1 parent 5c8b7cd commit 4582c64

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

subsys/net/lib/zperf/zperf_internal.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ struct zperf_udp_datagram {
6464

6565
BUILD_ASSERT(sizeof(struct zperf_udp_datagram) <= PACKET_SIZE_MAX, "Invalid PACKET_SIZE_MAX");
6666

67+
#define ZPERF_FLAGS_VERSION1 0x80000000
68+
#define ZPERF_FLAGS_EXTEND 0x40000000
69+
#define ZPERF_FLAGS_UDPTESTS 0x20000000
70+
#define ZPERF_FLAGS_SEQNO64B 0x08000000
71+
6772
struct zperf_client_hdr_v1 {
6873
int32_t flags;
6974
int32_t num_of_threads;

subsys/net/lib/zperf/zperf_udp_uploader.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ static inline void zperf_upload_decode_stat(const uint8_t *data,
2525
struct zperf_results *results)
2626
{
2727
struct zperf_server_hdr *stat;
28+
uint32_t flags;
2829

2930
if (datalen < sizeof(struct zperf_udp_datagram) +
3031
sizeof(struct zperf_server_hdr)) {
@@ -33,6 +34,10 @@ static inline void zperf_upload_decode_stat(const uint8_t *data,
3334

3435
stat = (struct zperf_server_hdr *)
3536
(data + sizeof(struct zperf_udp_datagram));
37+
flags = ntohl(UNALIGNED_GET(&stat->flags));
38+
if (!(flags & ZPERF_FLAGS_VERSION1)) {
39+
NET_WARN("Unexpected response flags");
40+
}
3641

3742
results->nb_packets_rcvd = ntohl(UNALIGNED_GET(&stat->datagrams));
3843
results->nb_packets_lost = ntohl(UNALIGNED_GET(&stat->error_cnt));

0 commit comments

Comments
 (0)