aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRollingSlack <8922964+rollingslack@users.noreply.github.com>2018-08-09 15:36:54 -0400
committerBruce A. Mah <bmah@kitchenlab.org>2018-08-09 12:36:54 -0700
commitbeac6881e6ee053ef7847793d67ec155156fa63f (patch)
treee3250a0b376479c4493421279b1081c72ee6dcbb
parentf64da9b9bc8c4aeab9a031b75c992ad2a13d6b5b (diff)
downloadiperf3-beac6881e6ee053ef7847793d67ec155156fa63f.tar.gz
Add libiperf api for getting iperf version (#767)
Also includes a test program.
-rw-r--r--.gitignore1
-rw-r--r--src/Makefile.am11
-rwxr-xr-xsrc/iperf_api.c7
-rwxr-xr-xsrc/iperf_api.h1
-rw-r--r--src/t_api.c53
5 files changed, 70 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index 713df75..424b143 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,6 +24,7 @@ src/iperf3_profile
src/t_timer
src/t_units
src/t_uuid
+src/t_api
examples/.libs
examples/Makefile
examples/mic
diff --git a/src/Makefile.am b/src/Makefile.am
index ef7b66a..e95722d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,9 +1,9 @@
lib_LTLIBRARIES = libiperf.la # Build and install an iperf library
bin_PROGRAMS = iperf3 # Build and install an iperf binary
if ENABLE_PROFILING
-noinst_PROGRAMS = t_timer t_units t_uuid iperf3_profile # Build, but don't install the test programs and a profiled version of iperf3
+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
else
-noinst_PROGRAMS = t_timer t_units t_uuid # Build, but don't install the test programs
+noinst_PROGRAMS = t_timer t_units t_uuid t_api # Build, but don't install the test programs
endif
include_HEADERS = iperf_api.h # Defines the headers that get installed with the program
@@ -77,6 +77,10 @@ t_uuid_CFLAGS = -g
t_uuid_LDFLAGS =
t_uuid_LDADD = libiperf.la
+t_api_SOURCES = t_api.c
+t_api_CFLAGS = -g
+t_api_LDFLAGS =
+t_api_LDADD = libiperf.la
@@ -84,6 +88,7 @@ t_uuid_LDADD = libiperf.la
TESTS = \
t_timer \
t_units \
- t_uuid
+ t_uuid \
+ t_api
dist_man_MANS = iperf3.1 libiperf.3
diff --git a/src/iperf_api.c b/src/iperf_api.c
index f73feab..2fa392d 100755
--- a/src/iperf_api.c
+++ b/src/iperf_api.c
@@ -321,6 +321,13 @@ iperf_get_test_extra_data(struct iperf_test *ipt)
return ipt->extra_data;
}
+static const char iperf_version[] = IPERF_VERSION;
+char *
+iperf_get_iperf_version(void)
+{
+ return (char*)iperf_version;
+}
+
/************** Setter routines for some fields inside iperf_test *************/
void
diff --git a/src/iperf_api.h b/src/iperf_api.h
index 81f3bb4..82322ef 100755
--- a/src/iperf_api.h
+++ b/src/iperf_api.h
@@ -122,6 +122,7 @@ int iperf_get_test_udp_counters_64bit( struct iperf_test* ipt );
int iperf_get_test_one_off( struct iperf_test* ipt );
int iperf_get_test_tos( struct iperf_test* ipt );
char* iperf_get_extra_data( struct iperf_test* ipt );
+char* iperf_get_iperf_version(void);
/* Setter routines for some fields inside iperf_test. */
void iperf_set_verbose( struct iperf_test* ipt, int verbose );
diff --git a/src/t_api.c b/src/t_api.c
new file mode 100644
index 0000000..0669917
--- /dev/null
+++ b/src/t_api.c
@@ -0,0 +1,53 @@
+/*
+ * iperf, Copyright (c) 2017, The Regents of the University of
+ * California, through Lawrence Berkeley National Laboratory (subject
+ * to receipt of any required approvals from the U.S. Dept. of
+ * Energy). All rights reserved.
+ *
+ * If you have questions about your rights to use or distribute this
+ * software, please contact Berkeley Lab's Technology Transfer
+ * Department at TTD@lbl.gov.
+ *
+ * NOTICE. This software is owned by the U.S. Department of Energy.
+ * As such, the U.S. Government has been granted for itself and others
+ * acting on its behalf a paid-up, nonexclusive, irrevocable,
+ * worldwide license in the Software to reproduce, prepare derivative
+ * works, and perform publicly and display publicly. Beginning five
+ * (5) years after the date permission to assert copyright is obtained
+ * from the U.S. Department of Energy, and subject to any subsequent
+ * five (5) year renewals, the U.S. Government is granted for itself
+ * and others acting on its behalf a paid-up, nonexclusive,
+ * irrevocable, worldwide license in the Software to reproduce,
+ * prepare derivative works, distribute copies to the public, perform
+ * publicly and display publicly, and to permit others to do so.
+ *
+ * This code is distributed under a BSD style license, see the LICENSE
+ * file for complete information.
+ */
+
+
+#include <assert.h>
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+#include <stdio.h>
+#include <string.h>
+
+#include "iperf.h"
+#include "iperf_api.h"
+
+#include "version.h"
+
+#include "units.h"
+
+
+int
+main(int argc, char **argv)
+{
+ const char *ver;
+
+ ver = iperf_get_iperf_version();
+ assert(strcmp(ver, IPERF_VERSION) == 0);
+
+ return 0;
+}