From 40050b7beed952be8f1f71e0e2610946b6f09d54 Mon Sep 17 00:00:00 2001 From: "Bruce A. Mah" Date: Mon, 14 Apr 2014 13:33:33 -0700 Subject: [PATCH] Fix breakage due to iperf.h depending on the autoconf config.h file but not including it. To fix this required us to change config.h to iperf_config.h (to avoid potential filename collisions with this generic name). Then iperf.h could include this. Adjust the existing header file inclusions to track this, and also canonicalize their inclusion to be at the top of *.c files. --- .gitignore | 2 +- configure.ac | 2 +- src/iperf.h | 2 + src/iperf_api.c | 10 ++++- src/{config.h.in => iperf_config.h.in} | 5 ++- src/iperf_sctp.c | 3 +- src/iperf_tcp.c | 2 +- src/iperf_util.c | 60 +++++++++++++++++++++++++- src/iperf_util.h | 6 ++- src/locale.c | 3 +- src/main.c | 1 + 11 files changed, 82 insertions(+), 14 deletions(-) rename src/{config.h.in => iperf_config.h.in} (93%) diff --git a/.gitignore b/.gitignore index ea663f6..1b2a87b 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,7 @@ docs/_static src/.deps src/.libs src/Makefile -src/config.h +src/iperf_config.h src/stamp-h1 src/iperf3 src/iperf3_profile diff --git a/configure.ac b/configure.ac index 5695c30..6b6ccdd 100644 --- a/configure.ac +++ b/configure.ac @@ -9,7 +9,7 @@ AC_CONFIG_AUX_DIR(config) # Initialize the automake system AM_INIT_AUTOMAKE -AM_CONFIG_HEADER(src/config.h) +AM_CONFIG_HEADER(src/iperf_config.h) AC_CANONICAL_HOST diff --git a/src/iperf.h b/src/iperf.h index 74ff86d..0b4bb4d 100644 --- a/src/iperf.h +++ b/src/iperf.h @@ -10,6 +10,8 @@ #ifndef __IPERF_H #define __IPERF_H +#include "iperf_config.h" + #include #include #include diff --git a/src/iperf_api.c b/src/iperf_api.c index b06f74d..dc62ff7 100644 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -10,6 +10,8 @@ #define _GNU_SOURCE #define __USE_GNU +#include "iperf_config.h" + #include #include #include @@ -40,7 +42,6 @@ #include #endif /* HAVE_CPUSET_SETAFFINITY */ -#include "config.h" #include "net.h" #include "iperf.h" #include "iperf_api.h" @@ -622,7 +623,8 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv) test->json_output = 1; break; case 'v': - printf("%s\n%s\n", version, get_system_info()); + printf("%s\n%s\n%s\n", version, get_system_info(), + get_optional_features()); exit(0); case 's': if (test->role == 'c') { @@ -819,6 +821,10 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv) } } + if (test->debug) { + printf("fubar\n"); + } + /* Set logging to a file if specified, otherwise use the default (stdout) */ if (test->logfile) { test->outfile = fopen(test->logfile, "a+"); diff --git a/src/config.h.in b/src/iperf_config.h.in similarity index 93% rename from src/config.h.in rename to src/iperf_config.h.in index cad0a10..5d9c1a6 100644 --- a/src/config.h.in +++ b/src/iperf_config.h.in @@ -1,4 +1,4 @@ -/* src/config.h.in. Generated from configure.ac by autoheader. */ +/* src/iperf_config.h.in. Generated from configure.ac by autoheader. */ /* Define to 1 if you have the `cpuset_setaffinity' function. */ #undef HAVE_CPUSET_SETAFFINITY @@ -70,6 +70,9 @@ /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME +/* Define to the home page for this package. */ +#undef PACKAGE_URL + /* Define to the version of this package. */ #undef PACKAGE_VERSION diff --git a/src/iperf_sctp.c b/src/iperf_sctp.c index d14a7ab..d62803b 100644 --- a/src/iperf_sctp.c +++ b/src/iperf_sctp.c @@ -6,6 +6,7 @@ * This code is distributed under a BSD style license, see the LICENSE file * for complete information. */ +#include "iperf_config.h" #include #include @@ -20,8 +21,6 @@ #include #include -#include "config.h" - #ifdef HAVE_NETINET_SCTP_H #include #endif /* HAVE_NETINET_SCTP_H */ diff --git a/src/iperf_tcp.c b/src/iperf_tcp.c index 2ff1d16..6a16397 100644 --- a/src/iperf_tcp.c +++ b/src/iperf_tcp.c @@ -6,6 +6,7 @@ * This code is distributed under a BSD style license, see the LICENSE file * for complete information. */ +#include "iperf_config.h" #include #include @@ -20,7 +21,6 @@ #include #include -#include "config.h" #include "iperf.h" #include "iperf_api.h" #include "iperf_tcp.h" diff --git a/src/iperf_util.c b/src/iperf_util.c index 5a04cda..99ccc35 100644 --- a/src/iperf_util.c +++ b/src/iperf_util.c @@ -12,6 +12,7 @@ * Iperf utility functions * */ +#include "iperf_config.h" #include #include @@ -26,7 +27,6 @@ #include #include -#include "config.h" #include "cjson.h" /* make_cookie @@ -194,7 +194,7 @@ cpu_util(double pcpu[3]) pcpu[2] = (systemdiff / timediff) * 100; } -char * +const char * get_system_info(void) { static char buf[1024]; @@ -210,6 +210,62 @@ get_system_info(void) } +const char * +get_optional_features(void) +{ + static char features[1024]; + unsigned int numfeatures = 0; + + snprintf(features, sizeof(features), "Optional features available: "); + +#if defined(HAVE_CPU_AFFINITY) + if (numfeatures > 0) { + strncat(features, ", ", + sizeof(features) - strlen(features) - 1); + } + strncat(features, "CPU affinity setting", + sizeof(features) - strlen(features) - 1); + numfeatures++; +#endif /* HAVE_CPU_AFFINITY */ + +#if defined(HAVE_FLOWLABEL) + if (numfeatures > 0) { + strncat(features, ", ", + sizeof(features) - strlen(features) - 1); + } + strncat(features, "IPv6 flow label", + sizeof(features) - strlen(features) - 1); + numfeatures++; +#endif /* HAVE_FLOWLABEL */ + +#if defined(HAVE_SCTP) + if (numfeatures > 0) { + strncat(features, ", ", + sizeof(features) - strlen(features) - 1); + } + strncat(features, "SCTP", + sizeof(features) - strlen(features) - 1); + numfeatures++; +#endif /* HAVE_SCTP */ + +#if defined(HAVE_TCP_CONGESTION) + if (numfeatures > 0) { + strncat(features, ", ", + sizeof(features) - strlen(features) - 1); + } + strncat(features, "TCP congestion algorithm setting", + sizeof(features) - strlen(features) - 1); + numfeatures++; +#endif /* HAVE_TCP_CONGESTION */ + + if (numfeatures == 0) { + strncat(features, "None", + sizeof(features) - strlen(features) - 1); + } + + return features; +} + /* Helper routine for building cJSON objects in a printf-like manner. ** ** Sample call: diff --git a/src/iperf_util.h b/src/iperf_util.h index f4a65fa..bf8efd9 100644 --- a/src/iperf_util.h +++ b/src/iperf_util.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2011, The Regents of the University of California, + * Copyright (c) 2009-2011, 2014, 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. * @@ -26,7 +26,9 @@ int delay(int64_t ns); void cpu_util(double pcpu[3]); -char* get_system_info(void); +const char* get_system_info(void); + +const char* get_optional_features(void); cJSON* iperf_json_printf(const char *format, ...); diff --git a/src/locale.c b/src/locale.c index b08aa96..adc0d16 100644 --- a/src/locale.c +++ b/src/locale.c @@ -50,11 +50,10 @@ * ------------------------------------------------------------------- * Strings and other stuff that is locale specific. * ------------------------------------------------------------------- */ +#include "iperf_config.h" #include "version.h" -#include "config.h" - #ifdef __cplusplus extern "C" { diff --git a/src/main.c b/src/main.c index 03ef7b5..e0e2a39 100644 --- a/src/main.c +++ b/src/main.c @@ -6,6 +6,7 @@ * This code is distributed under a BSD style license, see the LICENSE file * for complete information. */ +#include "iperf_config.h" #include #include