From 1a638f333ab86cf1908109b696bda4e4a549da9b Mon Sep 17 00:00:00 2001 From: Alex Kozlov Date: Wed, 30 Dec 2015 14:07:42 +0000 Subject: - Rename nonstandard src directory to files - Modernize ports --- benchmarks/tcpblast/Makefile | 13 ++-- benchmarks/tcpblast/files/tcpblast.c | 128 +++++++++++++++++++++++++++++++++++ benchmarks/tcpblast/src/Makefile | 6 -- benchmarks/tcpblast/src/tcpblast.c | 127 ---------------------------------- 4 files changed, 135 insertions(+), 139 deletions(-) create mode 100644 benchmarks/tcpblast/files/tcpblast.c delete mode 100644 benchmarks/tcpblast/src/Makefile delete mode 100644 benchmarks/tcpblast/src/tcpblast.c (limited to 'benchmarks') diff --git a/benchmarks/tcpblast/Makefile b/benchmarks/tcpblast/Makefile index 1a696c7e326d..cd4917f60b3b 100644 --- a/benchmarks/tcpblast/Makefile +++ b/benchmarks/tcpblast/Makefile @@ -5,19 +5,20 @@ PORTNAME= tcpblast PORTVERSION= 1.1 PORTREVISION= 1 CATEGORIES= benchmarks net ipv6 +MASTER_SITES= # none DISTFILES= # none MAINTAINER= ports@FreeBSD.org COMMENT= Measures the throughput of a TCP connection +NO_WRKSUBDIR= yes + PLIST_FILES= bin/tcpblast -USES= uidfix -WRKSRC= ${WRKDIR}/src +do-build: + ${CC} ${CFLAGS} ${FILESDIR}/${PORTNAME}.c -o ${WRKDIR}/${PORTNAME} -do-extract: - @${RM} -rf ${WRKDIR} - @${MKDIR} ${WRKDIR} - ${CP} -RP ${.CURDIR}/src ${WRKDIR} +do-install: + ${INSTALL_PROGRAM} ${WRKDIR}/${PORTNAME} ${STAGEDIR}${PREFIX}/bin .include diff --git a/benchmarks/tcpblast/files/tcpblast.c b/benchmarks/tcpblast/files/tcpblast.c new file mode 100644 index 000000000000..47bac345b52b --- /dev/null +++ b/benchmarks/tcpblast/files/tcpblast.c @@ -0,0 +1,128 @@ +/* + * tcpblast - test and estimate TCP thruput + * + * Daniel Karrenberg + */ + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#define BLKSIZE 1024 + +struct sockaddr_in sock_in; +struct servent *sp; +struct hostent *host; + +long starts, startms, stops, stopms, expms; +struct timeval ti; +struct timezone tiz; + +char greet[BLKSIZE] = "Hi!"; +int nblocks; +int f; + +int main(argc, argv) +int argc; char **argv; +{ + struct addrinfo hints, *res, *res0; + char *cause = NULL; + int ch, proto, error; + register int i; + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = PF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + + while ((ch = getopt(argc, argv, "46")) != -1) { + switch (ch) { + case '4': + hints.ai_family = PF_INET; + break; + case '6': + hints.ai_family = PF_INET6; + break; + } + } + argc -= optind; + argv += optind; + if (argc != 2) { + fprintf(stderr, + "usage: tcpblast [-4] [-6] destination nblkocks\n" + "blocksize: %d bytes %d\n", BLKSIZE, argc); + exit(1); + } + + nblocks = atoi(argv[1]); + if (nblocks<=1 || nblocks>10000) { + fprintf(stderr, "tcpblast: 1 < nblocks <= 10000 \n"); + exit(1); + } + + error = getaddrinfo(argv[0], "discard", &hints, &res0); + if (error) + errx(1, "%s", gai_strerror(error)); + f = -1; + cause = "no addresses"; + errno = EADDRNOTAVAIL; + for (res = res0; res; res = res->ai_next) { + f = socket(res->ai_family, res->ai_socktype, res->ai_protocol); + if (f < 0) { + cause = "socket"; + continue; + } + if (connect(f, res->ai_addr, res->ai_addrlen) < 0) { + cause = "connect"; + close(f); + f = -1; + continue; + } + break; + } + if (f < 0) + err(1, cause); + freeaddrinfo(res); + + if (gettimeofday(&ti, &tiz) < 0) + { + perror("tcpblast time:"); + exit(1); + } + starts = ti.tv_sec; + startms = ti.tv_usec / 1000L; + + + for (i=0; i diff --git a/benchmarks/tcpblast/src/tcpblast.c b/benchmarks/tcpblast/src/tcpblast.c deleted file mode 100644 index 5a191701dc89..000000000000 --- a/benchmarks/tcpblast/src/tcpblast.c +++ /dev/null @@ -1,127 +0,0 @@ -/* - * tcpblast - test and estimate TCP thruput - * - * Daniel Karrenberg - */ - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - -#define BLKSIZE 1024 - -struct sockaddr_in sock_in; -struct servent *sp; -struct hostent *host; - -long starts, startms, stops, stopms, expms; -struct timeval ti; -struct timezone tiz; - -char greet[BLKSIZE] = "Hi!"; -int nblocks; -int f; - -int main(argc, argv) -int argc; char **argv; -{ - struct addrinfo hints, *res, *res0; - char *cause = NULL; - int ch, proto, error; - register int i; - - memset(&hints, 0, sizeof(hints)); - hints.ai_family = PF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - - while ((ch = getopt(argc, argv, "46")) != -1) { - switch (ch) { - case '4': - hints.ai_family = PF_INET; - break; - case '6': - hints.ai_family = PF_INET6; - break; - } - } - argc -= optind; - argv += optind; - if (argc != 2) { - fprintf(stderr, - "usage: tcpblast [-4] [-6] destination nblkocks\n" - "blocksize: %d bytes %d\n", BLKSIZE, argc); - exit(1); - } - - nblocks = atoi(argv[1]); - if (nblocks<=1 || nblocks>10000) { - fprintf(stderr, "tcpblast: 1 < nblocks <= 10000 \n"); - exit(1); - } - - error = getaddrinfo(argv[0], "discard", &hints, &res0); - if (error) - errx(1, "%s", gai_strerror(error)); - f = -1; - cause = "no addresses"; - errno = EADDRNOTAVAIL; - for (res = res0; res; res = res->ai_next) { - f = socket(res->ai_family, res->ai_socktype, res->ai_protocol); - if (f < 0) { - cause = "socket"; - continue; - } - if (connect(f, res->ai_addr, res->ai_addrlen) < 0) { - cause = "connect"; - close(f); - f = -1; - continue; - } - break; - } - if (f < 0) - err(1, cause); - freeaddrinfo(res); - - if (gettimeofday(&ti, &tiz) < 0) - { - perror("tcpblast time:"); - exit(1); - } - starts = ti.tv_sec; - startms = ti.tv_usec / 1000L; - - - for (i=0; i