Skip to content

Commit beac688

Browse files
rollingslackbmah888
authored andcommittedAug 9, 2018
Add libiperf api for getting iperf version (esnet#767)
Also includes a test program.
1 parent f64da9b commit beac688

File tree

5 files changed

+70
-3
lines changed

5 files changed

+70
-3
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ src/iperf3_profile
2424
src/t_timer
2525
src/t_units
2626
src/t_uuid
27+
src/t_api
2728
examples/.libs
2829
examples/Makefile
2930
examples/mic

‎src/Makefile.am

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
lib_LTLIBRARIES = libiperf.la # Build and install an iperf library
22
bin_PROGRAMS = iperf3 # Build and install an iperf binary
33
if ENABLE_PROFILING
4-
noinst_PROGRAMS = t_timer t_units t_uuid iperf3_profile # Build, but don't install the test programs and a profiled version of iperf3
4+
noinst_PROGRAMS = t_timer t_units t_uuid t_api iperf3_profile # Build, but don't install the test programs and a profiled version of iperf3
55
else
6-
noinst_PROGRAMS = t_timer t_units t_uuid # Build, but don't install the test programs
6+
noinst_PROGRAMS = t_timer t_units t_uuid t_api # Build, but don't install the test programs
77
endif
88
include_HEADERS = iperf_api.h # Defines the headers that get installed with the program
99

@@ -77,13 +77,18 @@ t_uuid_CFLAGS = -g
7777
t_uuid_LDFLAGS =
7878
t_uuid_LDADD = libiperf.la
7979

80+
t_api_SOURCES = t_api.c
81+
t_api_CFLAGS = -g
82+
t_api_LDFLAGS =
83+
t_api_LDADD = libiperf.la
8084

8185

8286

8387
# Specify which tests to run during a "make check"
8488
TESTS = \
8589
t_timer \
8690
t_units \
87-
t_uuid
91+
t_uuid \
92+
t_api
8893

8994
dist_man_MANS = iperf3.1 libiperf.3

‎src/iperf_api.c

+7
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,13 @@ iperf_get_test_extra_data(struct iperf_test *ipt)
321321
return ipt->extra_data;
322322
}
323323

324+
static const char iperf_version[] = IPERF_VERSION;
325+
char *
326+
iperf_get_iperf_version(void)
327+
{
328+
return (char*)iperf_version;
329+
}
330+
324331
/************** Setter routines for some fields inside iperf_test *************/
325332

326333
void

‎src/iperf_api.h

+1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ int iperf_get_test_udp_counters_64bit( struct iperf_test* ipt );
122122
int iperf_get_test_one_off( struct iperf_test* ipt );
123123
int iperf_get_test_tos( struct iperf_test* ipt );
124124
char* iperf_get_extra_data( struct iperf_test* ipt );
125+
char* iperf_get_iperf_version(void);
125126

126127
/* Setter routines for some fields inside iperf_test. */
127128
void iperf_set_verbose( struct iperf_test* ipt, int verbose );

‎src/t_api.c

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* iperf, Copyright (c) 2017, The Regents of the University of
3+
* California, through Lawrence Berkeley National Laboratory (subject
4+
* to receipt of any required approvals from the U.S. Dept. of
5+
* Energy). All rights reserved.
6+
*
7+
* If you have questions about your rights to use or distribute this
8+
* software, please contact Berkeley Lab's Technology Transfer
9+
* Department at TTD@lbl.gov.
10+
*
11+
* NOTICE. This software is owned by the U.S. Department of Energy.
12+
* As such, the U.S. Government has been granted for itself and others
13+
* acting on its behalf a paid-up, nonexclusive, irrevocable,
14+
* worldwide license in the Software to reproduce, prepare derivative
15+
* works, and perform publicly and display publicly. Beginning five
16+
* (5) years after the date permission to assert copyright is obtained
17+
* from the U.S. Department of Energy, and subject to any subsequent
18+
* five (5) year renewals, the U.S. Government is granted for itself
19+
* and others acting on its behalf a paid-up, nonexclusive,
20+
* irrevocable, worldwide license in the Software to reproduce,
21+
* prepare derivative works, distribute copies to the public, perform
22+
* publicly and display publicly, and to permit others to do so.
23+
*
24+
* This code is distributed under a BSD style license, see the LICENSE
25+
* file for complete information.
26+
*/
27+
28+
29+
#include <assert.h>
30+
#ifdef HAVE_STDINT_H
31+
#include <stdint.h>
32+
#endif
33+
#include <stdio.h>
34+
#include <string.h>
35+
36+
#include "iperf.h"
37+
#include "iperf_api.h"
38+
39+
#include "version.h"
40+
41+
#include "units.h"
42+
43+
44+
int
45+
main(int argc, char **argv)
46+
{
47+
const char *ver;
48+
49+
ver = iperf_get_iperf_version();
50+
assert(strcmp(ver, IPERF_VERSION) == 0);
51+
52+
return 0;
53+
}

0 commit comments

Comments
 (0)
Please sign in to comment.