version 1.1, 2016/10/18 13:28:18
|
version 1.1.1.2, 2021/03/17 00:36:46
|
Line 1
|
Line 1
|
/* |
/* |
* iperf, Copyright (c) 2014, 2015, The Regents of the University of | * iperf, Copyright (c) 2014, 2015, 2017, 2019, The Regents of the University of |
* California, through Lawrence Berkeley National Laboratory (subject |
* California, through Lawrence Berkeley National Laboratory (subject |
* to receipt of any required approvals from the U.S. Dept. of |
* to receipt of any required approvals from the U.S. Dept. of |
* Energy). All rights reserved. |
* Energy). All rights reserved. |
Line 41
|
Line 41
|
#include <netinet/in.h> |
#include <netinet/in.h> |
#include <arpa/inet.h> |
#include <arpa/inet.h> |
#include <netdb.h> |
#include <netdb.h> |
#ifdef HAVE_STDINT_H |
|
#include <stdint.h> |
|
#endif |
|
#include <netinet/tcp.h> |
|
|
|
#include "iperf.h" |
#include "iperf.h" |
#include "iperf_api.h" |
#include "iperf_api.h" |
#include "units.h" | #include "iperf_util.h" |
#include "iperf_locale.h" |
#include "iperf_locale.h" |
#include "net.h" |
#include "net.h" |
|
#include "units.h" |
|
|
|
|
static int run(struct iperf_test *test); |
static int run(struct iperf_test *test); |
Line 104 main(int argc, char **argv)
|
Line 101 main(int argc, char **argv)
|
if (iperf_parse_arguments(test, argc, argv) < 0) { |
if (iperf_parse_arguments(test, argc, argv) < 0) { |
iperf_err(test, "parameter error - %s", iperf_strerror(i_errno)); |
iperf_err(test, "parameter error - %s", iperf_strerror(i_errno)); |
fprintf(stderr, "\n"); |
fprintf(stderr, "\n"); |
usage_long(); | usage_long(stdout); |
exit(1); |
exit(1); |
} |
} |
|
|
Line 119 main(int argc, char **argv)
|
Line 116 main(int argc, char **argv)
|
|
|
static jmp_buf sigend_jmp_buf; |
static jmp_buf sigend_jmp_buf; |
|
|
static void | static void __attribute__ ((noreturn)) |
sigend_handler(int sig) |
sigend_handler(int sig) |
{ |
{ |
longjmp(sigend_jmp_buf, 1); |
longjmp(sigend_jmp_buf, 1); |
Line 134 run(struct iperf_test *test)
|
Line 131 run(struct iperf_test *test)
|
if (setjmp(sigend_jmp_buf)) |
if (setjmp(sigend_jmp_buf)) |
iperf_got_sigend(test); |
iperf_got_sigend(test); |
|
|
|
/* Ignore SIGPIPE to simplify error handling */ |
|
signal(SIGPIPE, SIG_IGN); |
|
|
switch (test->role) { |
switch (test->role) { |
case 's': |
case 's': |
if (test->daemon) { |
if (test->daemon) { |
int rc = daemon(0, 0); | int rc; |
| rc = daemon(0, 0); |
if (rc < 0) { |
if (rc < 0) { |
i_errno = IEDAEMON; |
i_errno = IEDAEMON; |
iperf_errexit(test, "error - %s", iperf_strerror(i_errno)); |
iperf_errexit(test, "error - %s", iperf_strerror(i_errno)); |
Line 154 run(struct iperf_test *test)
|
Line 155 run(struct iperf_test *test)
|
iperf_err(test, "error - %s", iperf_strerror(i_errno)); |
iperf_err(test, "error - %s", iperf_strerror(i_errno)); |
if (rc < -1) { |
if (rc < -1) { |
iperf_errexit(test, "exiting"); |
iperf_errexit(test, "exiting"); |
break; |
|
} |
} |
} |
} |
iperf_reset_test(test); |
iperf_reset_test(test); |
if (iperf_get_test_one_off(test)) | if (iperf_get_test_one_off(test)) { |
break; | /* Authentication failure doesn't count for 1-off test */ |
| if (rc < 0 && i_errno == IEAUTHTEST) { |
| continue; |
| } |
| break; |
| } |
} |
} |
iperf_delete_pidfile(test); |
iperf_delete_pidfile(test); |
break; |
break; |
Line 173 run(struct iperf_test *test)
|
Line 178 run(struct iperf_test *test)
|
} |
} |
|
|
iperf_catch_sigend(SIG_DFL); |
iperf_catch_sigend(SIG_DFL); |
|
signal(SIGPIPE, SIG_DFL); |
|
|
return 0; |
return 0; |
} |
} |