diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2014-08-19 03:28:54 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2014-08-19 03:28:54 +0000 |
commit | fe181d1c39c4f9250c7b869322c301e9dde7ec0b (patch) | |
tree | e5f5f962093cdc70871e6bffab84e5e9e5e5d7b7 /usr.bin/tcpbench/tcpbench.c | |
parent | 20b523120f1619bc3d40bfb71665aa6e8e8ec7ec (diff) |
add -4 and -6 flags for saying if you want to force ipv4 or ipv6
respectively.
tweaks from jmc@
ok djm@
Diffstat (limited to 'usr.bin/tcpbench/tcpbench.c')
-rw-r--r-- | usr.bin/tcpbench/tcpbench.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/usr.bin/tcpbench/tcpbench.c b/usr.bin/tcpbench/tcpbench.c index 43f59012ad1..24c42d69050 100644 --- a/usr.bin/tcpbench/tcpbench.c +++ b/usr.bin/tcpbench/tcpbench.c @@ -180,10 +180,10 @@ usage(void) { fprintf(stderr, "usage: tcpbench -l\n" - " tcpbench [-uv] [-B buf] [-b addr] [-k kvars] [-n connections]\n" + " tcpbench [-46uv] [-B buf] [-b addr] [-k kvars] [-n connections]\n" " [-p port] [-r interval] [-S space] [-T toskeyword]\n" " [-t secs] [-V rtable] hostname\n" - " tcpbench -s [-uv] [-B buf] [-k kvars] [-p port]\n" + " tcpbench -s [-46uv] [-B buf] [-k kvars] [-p port]\n" " [-r interval] [-S space] [-T toskeyword] [-V rtable]\n"); exit(1); } @@ -997,6 +997,7 @@ main(int argc, char **argv) const char *errstr; struct rlimit rl; int ch, herr, nconn; + int family = PF_UNSPEC; struct nlist nl[] = { { "_tcbtable" }, { "" } }; const char *host = NULL, *port = DEFAULT_PORT, *srcbind = NULL; struct event ev_sigint, ev_sigterm, ev_sighup, ev_progtimer; @@ -1015,8 +1016,14 @@ main(int argc, char **argv) aib = NULL; secs = 0; - while ((ch = getopt(argc, argv, "b:B:hlk:n:p:r:sS:t:T:uvV:")) != -1) { + while ((ch = getopt(argc, argv, "46b:B:hlk:n:p:r:sS:t:T:uvV:")) != -1) { switch (ch) { + case '4': + family = PF_INET; + break; + case '6': + family = PF_INET6; + break; case 'b': srcbind = optarg; break; @@ -1124,6 +1131,7 @@ main(int argc, char **argv) } bzero(&hints, sizeof(hints)); + hints.ai_family = family; if (UDP_MODE) { hints.ai_socktype = SOCK_DGRAM; hints.ai_protocol = IPPROTO_UDP; |