summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2004-07-15 15:07:53 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2004-07-15 15:07:53 +0000
commit784d42662f31f3db6f6a7259e300a1ec8205ca63 (patch)
treefa89b87b3f9e6f5876e2a33887368f2949eb2b22
parent2e11a1d23a814b47701a5bb499eb0e932e1dbda3 (diff)
add -D for sodebug; ok deraadt, jmc
-rw-r--r--usr.bin/nc/nc.16
-rw-r--r--usr.bin/nc/netcat.c21
2 files changed, 22 insertions, 5 deletions
diff --git a/usr.bin/nc/nc.1 b/usr.bin/nc/nc.1
index 719cdd84664..182950a9524 100644
--- a/usr.bin/nc/nc.1
+++ b/usr.bin/nc/nc.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: nc.1,v 1.31 2004/03/12 10:10:00 jmc Exp $
+.\" $OpenBSD: nc.1,v 1.32 2004/07/15 15:07:52 markus Exp $
.\"
.\" Copyright (c) 1996 David Sacerdote
.\" All rights reserved.
@@ -34,7 +34,7 @@
.Sh SYNOPSIS
.Nm nc
.Bk -words
-.Op Fl 46dhklnrStUuvz
+.Op Fl 46DdhklnrStUuvz
.Op Fl i Ar interval
.Op Fl p Ar source_port
.Op Fl s Ar source_ip_address
@@ -91,6 +91,8 @@ to use IPv4 addresses only.
Forces
.Nm
to use IPv6 addresses only.
+.It Fl D
+Enable debugging on the socket.
.It Fl d
Do not attempt to read from stdin.
.It Fl h
diff --git a/usr.bin/nc/netcat.c b/usr.bin/nc/netcat.c
index ee151972e87..ea907d6b1ad 100644
--- a/usr.bin/nc/netcat.c
+++ b/usr.bin/nc/netcat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: netcat.c,v 1.72 2004/03/12 10:10:00 jmc Exp $ */
+/* $OpenBSD: netcat.c,v 1.73 2004/07/15 15:07:52 markus Exp $ */
/*
* Copyright (c) 2001 Eric Jackson <ericj@monkey.org>
*
@@ -73,6 +73,7 @@ int uflag; /* UDP - Default to TCP */
int vflag; /* Verbosity */
int xflag; /* Socks proxy */
int zflag; /* Port Scan Flag */
+int Dflag; /* sodebug */
int Sflag; /* TCP MD5 signature option */
int timeout = -1;
@@ -114,7 +115,7 @@ main(int argc, char *argv[])
endp = NULL;
sv = NULL;
- while ((ch = getopt(argc, argv, "46UX:dhi:klnp:rs:tuvw:x:zS")) != -1) {
+ while ((ch = getopt(argc, argv, "46Ddhi:klnp:rSs:tUuvw:X:x:z")) != -1) {
switch (ch) {
case '4':
family = AF_INET;
@@ -184,6 +185,9 @@ main(int argc, char *argv[])
case 'z':
zflag = 1;
break;
+ case 'D':
+ Dflag = 1;
+ break;
case 'S':
Sflag = 1;
break;
@@ -486,6 +490,11 @@ remote_connect(char *host, char *port, struct addrinfo hints)
&x, sizeof(x)) == -1)
err(1, NULL);
}
+ if (Dflag) {
+ if (setsockopt(s, SOL_SOCKET, SO_DEBUG,
+ &x, sizeof(x)) == -1)
+ err(1, NULL);
+ }
if (connect(s, res0->ai_addr, res0->ai_addrlen) == 0)
break;
@@ -542,6 +551,11 @@ local_listen(char *host, char *port, struct addrinfo hints)
if (ret == -1)
err(1, NULL);
}
+ if (Dflag) {
+ if (setsockopt(s, SOL_SOCKET, SO_DEBUG,
+ &x, sizeof(x)) == -1)
+ err(1, NULL);
+ }
if (bind(s, (struct sockaddr *)res0->ai_addr,
res0->ai_addrlen) == 0)
@@ -753,6 +767,7 @@ help(void)
fprintf(stderr, "\tCommand Summary:\n\
\t-4 Use IPv4\n\
\t-6 Use IPv6\n\
+ \t-D Enable the debug socket option\n\
\t-d Detach from stdin\n\
\t-h This help text\n\
\t-i secs\t Delay interval for lines sent, ports scanned\n\
@@ -778,7 +793,7 @@ help(void)
void
usage(int ret)
{
- fprintf(stderr, "usage: nc [-46dhklnrStUuvz] [-i interval] [-p source_port]\n");
+ fprintf(stderr, "usage: nc [-46DdhklnrStUuvz] [-i interval] [-p source_port]\n");
fprintf(stderr, "\t [-s source_ip_address] [-w timeout] [-X socks_version]\n");
fprintf(stderr, "\t [-x proxy_address[:port]] [hostname] [port[s]]\n");
if (ret)