-.\" $OpenBSD: tcpdrop.8,v 1.13 2014/08/28 08:22:42 jmc Exp $
+.\" $OpenBSD: tcpdrop.8,v 1.14 2023/02/06 18:14:10 millert Exp $
.\"
.\" Copyright (c) 2004 Markus Friedl <markus@openbsd.org>
.\"
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: August 28 2014 $
+.Dd $Mdocdate: February 6 2023 $
.Dt TCPDROP 8
.Os
.Sh NAME
.Ar local-port
.Ar remote-addr
.Ar remote-port
-.Nm tcpdrop
-.Ar local-addr : Ns Ar local-port
-.Ar remote-addr : Ns Ar remote-port
.Sh DESCRIPTION
The
.Nm
port
.Ar remote-port .
Addresses and ports can be specified by name or numeric value.
+.Pp
+To simplify dropping TCP connections using the output of
+.Xr fstat 1
+and
+.Xr netstat 1 ,
+.Nm
+also supports a two-argument form where the address and port are
+separated by a colon
+.Pq Sq \&:
+or dot
+.Pq Sq \&.
+character.
.Sh EXAMPLES
If a connection to
.Xr httpd 8
# tcpdrop 192.168.5.41 80 192.168.5.1 26747
# tcpdrop 192.168.5.41:80 192.168.5.1:26747
+
+# tcpdrop 192.168.5.41.80 192.168.5.1.26747
.Ed
.Sh SEE ALSO
.Xr fstat 1 ,
-/* $OpenBSD: tcpdrop.c,v 1.20 2021/07/12 15:09:21 beck Exp $ */
+/* $OpenBSD: tcpdrop.c,v 1.21 2023/02/06 18:14:10 millert Exp $ */
/*
* Copyright (c) 2004 Markus Friedl <markus@openbsd.org>
fprintf(stderr,
"usage: %s local-addr local-port remote-addr remote-port\n",
__progname);
- fprintf(stderr,
- " %s local-addr:local-port remote-addr:remote-port\n",
- __progname);
exit(1);
}
hints.ai_socktype = SOCK_STREAM;
if (argc == 3) {
+ char *dot;
+
laddr1 = addr1 = strdup(argv[1]);
if (!addr1)
err(1, "strdup");
port1 = strrchr(addr1, ':');
+ dot = strrchr(addr1, '.');
+ if (dot > port1)
+ port1 = dot;
if (port1)
*port1++ = '\0';
else
if (!addr2)
err(1, "strdup");
port2 = strrchr(addr2, ':');
+ dot = strrchr(addr2, '.');
+ if (dot > port2)
+ port2 = dot;
if (port2)
*port2++ = '\0';
else