Rework detection / enabling of SCTP support.
Rather than doing checks for platforms that we believe support SCTP, instead look for an indication (notably the presence of <netinet/sctp.h>) that it's supported. This makes the conditionals for SCTP more obvious. In addition, it opens up the possibility that SCTP might work on some new OS that's not FreeBSD or Linux. This change may force some additional build-time requirements on Linux, such as lksctp-tools-devel on CentOS / Fedora or libsctp-dev on Ubuntu. Committing this first cut for review and to enable testing on multiple platforms. So far this works correctly on Linux (SCTP support) and MacOS (no SCTP support).
Этот коммит содержится в:
родитель
e3990c3cc0
Коммит
cd81de3c0a
@ -46,4 +46,8 @@ exit 1
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_CONST
|
||||
|
||||
# Check for SCTP support
|
||||
AC_CHECK_HEADERS([netinet/sctp.h],
|
||||
AC_DEFINE([HAVE_SCTP], [1], [Have SCTP support.]))
|
||||
|
||||
AC_OUTPUT([Makefile src/Makefile examples/Makefile])
|
||||
|
@ -9,6 +9,12 @@
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the <netinet/sctp.h> header file. */
|
||||
#undef HAVE_NETINET_SCTP_H
|
||||
|
||||
/* Have SCTP support. */
|
||||
#undef HAVE_SCTP
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
|
@ -40,12 +40,15 @@
|
||||
#include <sys/cpuset.h>
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
#include "net.h"
|
||||
#include "iperf.h"
|
||||
#include "iperf_api.h"
|
||||
#include "iperf_udp.h"
|
||||
#include "iperf_tcp.h"
|
||||
#if defined(HAVE_SCTP)
|
||||
#include "iperf_sctp.h"
|
||||
#endif /* HAVE_SCTP */
|
||||
#include "timer.h"
|
||||
|
||||
#include "cjson.h"
|
||||
@ -570,7 +573,7 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
|
||||
#if defined(linux) && defined(TCP_CONGESTION)
|
||||
{"linux-congestion", required_argument, NULL, 'C'},
|
||||
#endif
|
||||
#if defined(linux) || defined(__FreeBSD__)
|
||||
#if defined(HAVE_SCTP)
|
||||
{"sctp", no_argument, NULL, OPT_SCTP},
|
||||
#endif
|
||||
{"pidfile", required_argument, NULL, 'I'},
|
||||
@ -639,13 +642,13 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
|
||||
client_flag = 1;
|
||||
break;
|
||||
case OPT_SCTP:
|
||||
#if defined(linux) || defined(__FreeBSD__)
|
||||
#if defined(HAVE_SCTP)
|
||||
set_protocol(test, Psctp);
|
||||
client_flag = 1;
|
||||
#else /* linux */
|
||||
#else /* HAVE_SCTP */
|
||||
i_errno = IEUNIMP;
|
||||
return -1;
|
||||
#endif /* linux */
|
||||
#endif /* HAVE_SCTP */
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
@ -1555,7 +1558,10 @@ protocol_free(struct protocol *proto)
|
||||
int
|
||||
iperf_defaults(struct iperf_test *testp)
|
||||
{
|
||||
struct protocol *tcp, *udp, *sctp;
|
||||
struct protocol *tcp, *udp;
|
||||
#if defined(HAVE_SCTP)
|
||||
struct protocol *sctp;
|
||||
#endif /* HAVE_SCTP */
|
||||
|
||||
testp->omit = OMIT;
|
||||
testp->duration = DURATION;
|
||||
@ -1627,6 +1633,7 @@ iperf_defaults(struct iperf_test *testp)
|
||||
|
||||
set_protocol(testp, Ptcp);
|
||||
|
||||
#if defined(HAVE_SCTP)
|
||||
sctp = protocol_new();
|
||||
if (!sctp) {
|
||||
protocol_free(tcp);
|
||||
@ -1644,6 +1651,7 @@ iperf_defaults(struct iperf_test *testp)
|
||||
sctp->init = iperf_sctp_init;
|
||||
|
||||
SLIST_INSERT_AFTER(udp, sctp, protocols);
|
||||
#endif /* HAVE_SCTP */
|
||||
|
||||
testp->on_new_stream = iperf_on_new_stream;
|
||||
testp->on_test_start = iperf_on_test_start;
|
||||
|
@ -255,6 +255,7 @@ enum {
|
||||
IEBURST = 15, // Invalid burst count. Maximum value = %dMAX_BURST
|
||||
IEENDCONDITIONS = 16, // Only one test end condition (-t, -n, -k) may be specified
|
||||
IELOGFILE = 17, // Can't open log file
|
||||
IENOSCTP = 18, // No SCTP support available
|
||||
/* Test errors */
|
||||
IENEWTEST = 100, // Unable to create a new test (check perror)
|
||||
IEINITTEST = 101, // Test initialization failed (check perror)
|
||||
|
@ -130,6 +130,9 @@ iperf_strerror(int i_errno)
|
||||
snprintf(errstr, len, "unable to open log file");
|
||||
perr = 1;
|
||||
break;
|
||||
case IENOSCTP:
|
||||
snprintf(errstr, len, "no SCTP support available");
|
||||
break;
|
||||
case IENEWTEST:
|
||||
snprintf(errstr, len, "unable to create a new test");
|
||||
perr = 1;
|
||||
|
@ -20,6 +20,12 @@
|
||||
#include <sys/time.h>
|
||||
#include <sys/select.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HAVE_NETINET_SCTP_H
|
||||
#include <netinet/sctp.h>
|
||||
#endif /* HAVE_NETINET_SCTP_H */
|
||||
|
||||
#include "iperf.h"
|
||||
#include "iperf_api.h"
|
||||
#include "iperf_sctp.h"
|
||||
@ -34,6 +40,7 @@
|
||||
int
|
||||
iperf_sctp_recv(struct iperf_stream *sp)
|
||||
{
|
||||
#if defined(HAVE_SCTP)
|
||||
int r;
|
||||
|
||||
r = Nread(sp->socket, sp->buffer, sp->settings->blksize, Psctp);
|
||||
@ -44,6 +51,10 @@ iperf_sctp_recv(struct iperf_stream *sp)
|
||||
sp->result->bytes_received_this_interval += r;
|
||||
|
||||
return r;
|
||||
#else
|
||||
i_errno = IENOSCTP;
|
||||
return -1;
|
||||
#endif /* HAVE_SCTP */
|
||||
}
|
||||
|
||||
|
||||
@ -54,6 +65,7 @@ iperf_sctp_recv(struct iperf_stream *sp)
|
||||
int
|
||||
iperf_sctp_send(struct iperf_stream *sp)
|
||||
{
|
||||
#if defined(HAVE_SCTP)
|
||||
int r;
|
||||
|
||||
r = Nwrite(sp->socket, sp->buffer, sp->settings->blksize, Psctp);
|
||||
@ -64,6 +76,10 @@ iperf_sctp_send(struct iperf_stream *sp)
|
||||
sp->result->bytes_sent_this_interval += r;
|
||||
|
||||
return r;
|
||||
#else
|
||||
i_errno = IENOSCTP;
|
||||
return -1;
|
||||
#endif /* HAVE_SCTP */
|
||||
}
|
||||
|
||||
|
||||
@ -75,6 +91,7 @@ iperf_sctp_send(struct iperf_stream *sp)
|
||||
int
|
||||
iperf_sctp_accept(struct iperf_test * test)
|
||||
{
|
||||
#if defined(HAVE_SCTP)
|
||||
int s;
|
||||
signed char rbuf = ACCESS_DENIED;
|
||||
char cookie[COOKIE_SIZE];
|
||||
@ -102,6 +119,10 @@ iperf_sctp_accept(struct iperf_test * test)
|
||||
}
|
||||
|
||||
return s;
|
||||
#else
|
||||
i_errno = IENOSCTP;
|
||||
return -1;
|
||||
#endif /* HAVE_SCTP */
|
||||
}
|
||||
|
||||
|
||||
@ -112,6 +133,7 @@ iperf_sctp_accept(struct iperf_test * test)
|
||||
int
|
||||
iperf_sctp_listen(struct iperf_test *test)
|
||||
{
|
||||
#if defined(HAVE_SCTP)
|
||||
struct addrinfo hints, *res;
|
||||
char portstr[6];
|
||||
int s, opt;
|
||||
@ -173,6 +195,10 @@ iperf_sctp_listen(struct iperf_test *test)
|
||||
test->listener = s;
|
||||
|
||||
return s;
|
||||
#else
|
||||
i_errno = IENOSCTP;
|
||||
return -1;
|
||||
#endif /* HAVE_SCTP */
|
||||
}
|
||||
|
||||
|
||||
@ -183,6 +209,7 @@ iperf_sctp_listen(struct iperf_test *test)
|
||||
int
|
||||
iperf_sctp_connect(struct iperf_test *test)
|
||||
{
|
||||
#if defined(HAVE_SCTP)
|
||||
int s, opt;
|
||||
char portstr[6];
|
||||
struct addrinfo hints, *local_res, *server_res;
|
||||
@ -242,6 +269,10 @@ iperf_sctp_connect(struct iperf_test *test)
|
||||
}
|
||||
|
||||
return s;
|
||||
#else
|
||||
i_errno = IENOSCTP;
|
||||
return -1;
|
||||
#endif /* HAVE_SCTP */
|
||||
}
|
||||
|
||||
|
||||
@ -249,6 +280,11 @@ iperf_sctp_connect(struct iperf_test *test)
|
||||
int
|
||||
iperf_sctp_init(struct iperf_test *test)
|
||||
{
|
||||
#if defined(HAVE_SCTP)
|
||||
return 0;
|
||||
#else
|
||||
i_errno = IENOSCTP;
|
||||
return -1;
|
||||
#endif /* HAVE_SCTP */
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009-2011, The Regents of the University of California,
|
||||
* Copyright (c) 2009-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.
|
||||
*
|
||||
@ -10,11 +10,6 @@
|
||||
#ifndef IPERF_SCTP_H
|
||||
#define IPERF_SCTP_H
|
||||
|
||||
|
||||
#ifndef SCTP_DISABLE_FRAGMENTS
|
||||
#define SCTP_DISABLE_FRAGMENTS 8
|
||||
#endif
|
||||
|
||||
/**
|
||||
* iperf_sctp_accept -- accepts a new SCTP connection
|
||||
* on sctp_listener_socket for SCTP data and param/result
|
||||
|
@ -53,6 +53,8 @@
|
||||
|
||||
#include "version.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
@ -88,9 +90,9 @@ const char usage_longstr[] = "Usage: iperf [-s|-c host] [options]\n"
|
||||
" -I, --pidfile file write PID file\n"
|
||||
"Client specific:\n"
|
||||
" -c, --client <host> run in client mode, connecting to <host>\n"
|
||||
#if defined(linux) || defined(__FreeBSD__)
|
||||
#if defined(HAVE_SCTP)
|
||||
" --sctp use SCTP rather than TCP\n"
|
||||
#endif
|
||||
#endif /* HAVE_SCTP */
|
||||
" -u, --udp use UDP rather than TCP\n"
|
||||
" -b, --bandwidth #[KMG][/#] target bandwidth in bits/sec\n"
|
||||
" (default %d Mbit/sec for UDP, unlimited for TCP)\n"
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user