Add libiperf api for getting iperf version (#767)

Also includes a test program.
This commit is contained in:
RollingSlack 2018-08-09 15:36:54 -04:00 committed by Bruce A. Mah
parent f64da9b9bc
commit beac6881e6
5 changed files with 70 additions and 3 deletions

1
.gitignore vendored
View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 );

53
src/t_api.c Normal file
View File

@ -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;
}