Skip to content

Commit 2dc942a

Browse files
committed
update to support VxWorks
1 parent 4bea03e commit 2dc942a

File tree

5 files changed

+33
-1
lines changed

5 files changed

+33
-1
lines changed

src/iperf.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
#include "queue.h"
6868
#include "cjson.h"
6969
#include "iperf_time.h"
70+
#include "portable_endian.h"
7071

7172
#if defined(HAVE_SSL)
7273
#include <openssl/bio.h>
@@ -93,6 +94,10 @@ typedef uint_fast64_t iperf_size_t;
9394
typedef atomic_uint_fast64_t atomic_iperf_size_t;
9495
#endif // __IPERF_API_H
9596

97+
#if (defined(__vxworks)) || (defined(__VXWORKS__))
98+
typedef unsigned int uint
99+
#endif // __vxworks or __VXWORKS__
100+
96101
struct iperf_interval_results
97102
{
98103
atomic_iperf_size_t bytes_transferred; /* bytes transferred in this interval */
@@ -453,9 +458,15 @@ struct iperf_test
453458
extern int gerror; /* error value from getaddrinfo(3), for use in internal error handling */
454459

455460
/* UDP "connect" message and reply (textual value for Wireshark, etc. readability - legacy was numeric) */
461+
#if BYTE_ORDER == BIG_ENDIAN
462+
#define UDP_CONNECT_MSG 0x39383736
463+
#define UDP_CONNECT_REPLY 0x36373839
464+
#define LEGACY_UDP_CONNECT_REPLY 0xb168de3a
465+
#else
456466
#define UDP_CONNECT_MSG 0x36373839 // "6789" - legacy value was 123456789
457467
#define UDP_CONNECT_REPLY 0x39383736 // "9876" - legacy value was 987654321
458468
#define LEGACY_UDP_CONNECT_REPLY 987654321 // Old servers may still reply with the legacy value
469+
#endif
459470

460471
/* In Reverse mode, maximum number of packets to wait for "accept" response - to handle out of order packets */
461472
#define MAX_REVERSE_OUT_OF_ORDER_PACKETS 2

src/iperf_api.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4710,7 +4710,15 @@ iperf_create_pidfile(struct iperf_test *test)
47104710
if (pid > 0) {
47114711

47124712
/* See if the process exists. */
4713+
#if (defined(__vxworks)) || (defined(__VXWORKS__))
4714+
#if (defined(_WRS_KERNEL)) && (defined(_WRS_CONFIG_LP64))
4715+
if (kill((_Vx_TASK_ID)pid, 0) == 0) {
4716+
#else
4717+
if (kill(pid, 0) == 0) {
4718+
#endif // _WRS_KERNEL and _WRS_CONFIG_LP64
4719+
#else
47134720
if (kill(pid, 0) == 0) {
4721+
#endif // __vxworks or __VXWORKS__
47144722
/*
47154723
* Make sure not to try to delete existing PID file by
47164724
* scribbling over the pathname we'd use to refer to it.

src/iperf_client_api.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,19 @@ iperf_run_client(struct iperf_test * test)
614614
timeout = &used_timeout;
615615
}
616616

617+
#if (defined(__vxworks)) || (defined(__VXWORKS__))
618+
if (timeout != NULL && timeout->tv_sec == 0 && timeout->tv_usec == 0) {
619+
taskDelay (1);
620+
}
621+
622+
result = select(test->max_fd + 1,
623+
&read_set,
624+
(test->state == TEST_RUNNING && !test->reverse) ? &write_set : NULL,
625+
NULL,
626+
timeout);
627+
#else
617628
result = select(test->max_fd + 1, &read_set, &write_set, NULL, timeout);
629+
#endif // __vxworks or __VXWORKS__
618630
if (result < 0 && errno != EINTR) {
619631
i_errno = IESELECT;
620632
goto cleanup_and_fail;

src/iperf_udp.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
#include "timer.h"
4848
#include "net.h"
4949
#include "cjson.h"
50-
#include "portable_endian.h"
5150

5251
#if defined(HAVE_INTTYPES_H)
5352
# include <inttypes.h>

src/portable_endian.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@
131131
// the truth because we use the homebrew htonll, et al. implementations
132132
// that were originally the sole implementation of this functionality
133133
// in iperf 3.0.
134+
#if (!defined(__vxworks)) && (!defined(__VXWORKS__))
134135
# warning platform not supported
136+
#endif
135137
# include <endian.h>
136138
#if BYTE_ORDER == BIG_ENDIAN
137139
#define HTONLL(n) (n)

0 commit comments

Comments
 (0)