Skip to content

Commit

Permalink
Add libiperf api for getting iperf version (esnet#767)
Browse files Browse the repository at this point in the history
Also includes a test program.
  • Loading branch information
rollingslack authored and bmah888 committed Aug 9, 2018
1 parent f64da9b commit beac688
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions src/Makefile.am
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -77,13 +77,18 @@ 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



# Specify which tests to run during a "make check"
TESTS = \
t_timer \
t_units \
t_uuid
t_uuid \
t_api

dist_man_MANS = iperf3.1 libiperf.3
7 changes: 7 additions & 0 deletions src/iperf_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/iperf_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
53 changes: 53 additions & 0 deletions src/t_api.c
Original file line number Diff line number Diff line change
@@ -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 [email protected].
*
* 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;
}

0 comments on commit beac688

Please sign in to comment.