summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2010-10-18 19:44:45 +0000
committerXin LI <delphij@FreeBSD.org>2010-10-18 19:44:45 +0000
commitb46a1ee8f0756ffa8aff09939ad8c814b10b8931 (patch)
tree8415397977fff001bdafa8de341e9e4bff90a4ed
parenta83f96f1936ee3800ae6434d9099592cbbbbb930 (diff)
Notes
-rw-r--r--nc.112
-rw-r--r--netcat.c39
-rw-r--r--socks.c18
3 files changed, 34 insertions, 35 deletions
diff --git a/nc.1 b/nc.1
index 94a2d43cdbbe..05b46f8f74df 100644
--- a/nc.1
+++ b/nc.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: nc.1,v 1.53 2010/02/23 23:00:52 schwarze Exp $
+.\" $OpenBSD: nc.1,v 1.55 2010/07/25 07:51:39 guenther Exp $
.\"
.\" Copyright (c) 1996 David Sacerdote
.\" All rights reserved.
@@ -25,7 +25,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd $Mdocdate: February 23 2010 $
+.Dd $Mdocdate: July 3 2010 $
.Dt NC 1
.Os
.Sh NAME
@@ -42,7 +42,7 @@
.Op Fl p Ar source_port
.Op Fl s Ar source_ip_address
.Op Fl T Ar ToS
-.Op Fl V Ar rdomain
+.Op Fl V Ar rtable
.Op Fl w Ar timeout
.Op Fl X Ar proxy_protocol
.Oo Xo
@@ -179,8 +179,8 @@ Specifies to use
sockets.
.It Fl u
Use UDP instead of the default option of TCP.
-.It Fl V Ar rdomain
-Set the routing domain.
+.It Fl V Ar rtable
+Set the routing table to be used.
The default is 0.
.It Fl v
Have
@@ -317,7 +317,7 @@ when it might be necessary to verify what data a server is sending
in response to commands issued by the client.
For example, to retrieve the home page of a web site:
.Bd -literal -offset indent
-$ echo -n "GET / HTTP/1.0\er\en\er\en" | nc host.example.com 80
+$ printf "GET / HTTP/1.0\er\en\er\en" | nc host.example.com 80
.Ed
.Pp
Note that this also displays the headers sent by the web server.
diff --git a/netcat.c b/netcat.c
index 508712388dfd..e471182b2ad8 100644
--- a/netcat.c
+++ b/netcat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: netcat.c,v 1.95 2010/02/27 00:58:56 nicm Exp $ */
+/* $OpenBSD: netcat.c,v 1.98 2010/07/03 04:44:51 guenther Exp $ */
/*
* Copyright (c) 2001 Eric Jackson <ericj@monkey.org>
*
@@ -84,7 +84,7 @@ int Iflag; /* TCP receive buffer size */
int Oflag; /* TCP send buffer size */
int Sflag; /* TCP MD5 signature option */
int Tflag = -1; /* IP Type of Service */
-u_int rdomain;
+u_int rtableid;
int timeout = -1;
int family = AF_UNSPEC;
@@ -189,10 +189,10 @@ main(int argc, char *argv[])
uflag = 1;
break;
case 'V':
- rdomain = (unsigned int)strtonum(optarg, 0,
+ rtableid = (unsigned int)strtonum(optarg, 0,
RT_TABLEID_MAX, &errstr);
if (errstr)
- errx(1, "rdomain %s: %s", errstr, optarg);
+ errx(1, "rtable %s: %s", errstr, optarg);
break;
case 'v':
vflag = 1;
@@ -323,11 +323,11 @@ main(int argc, char *argv[])
*/
if (uflag) {
int rv, plen;
- char buf[8192];
+ char buf[16384];
struct sockaddr_storage z;
len = sizeof(z);
- plen = jflag ? 8192 : 1024;
+ plen = jflag ? 16384 : 2048;
rv = recvfrom(s, buf, plen, MSG_PEEK,
(struct sockaddr *)&z, &len);
if (rv < 0)
@@ -507,10 +507,10 @@ remote_connect(const char *host, const char *port, struct addrinfo hints)
res0->ai_protocol)) < 0)
continue;
- if (rdomain) {
- if (setsockopt(s, IPPROTO_IP, SO_RDOMAIN, &rdomain,
- sizeof(rdomain)) == -1)
- err(1, "setsockopt SO_RDOMAIN");
+ if (rtableid) {
+ if (setsockopt(s, IPPROTO_IP, SO_RTABLE, &rtableid,
+ sizeof(rtableid)) == -1)
+ err(1, "setsockopt SO_RTABLE");
}
/* Bind to a local port or source address if specified. */
@@ -581,10 +581,10 @@ local_listen(char *host, char *port, struct addrinfo hints)
res0->ai_protocol)) < 0)
continue;
- if (rdomain) {
- if (setsockopt(s, IPPROTO_IP, SO_RDOMAIN, &rdomain,
- sizeof(rdomain)) == -1)
- err(1, "setsockopt SO_RDOMAIN");
+ if (rtableid) {
+ if (setsockopt(s, IPPROTO_IP, SO_RTABLE, &rtableid,
+ sizeof(rtableid)) == -1)
+ err(1, "setsockopt SO_RTABLE");
}
ret = setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof(x));
@@ -619,12 +619,12 @@ void
readwrite(int nfd)
{
struct pollfd pfd[2];
- unsigned char buf[8192];
+ unsigned char buf[16384];
int n, wfd = fileno(stdin);
int lfd = fileno(stdout);
int plen;
- plen = jflag ? 8192 : 1024;
+ plen = jflag ? 16384 : 2048;
/* Setup Network FD */
pfd[0].fd = nfd;
@@ -766,10 +766,9 @@ build_ports(char *p)
hi = strtonum(p, 1, PORT_MAX, &errstr);
if (errstr)
errx(1, "port number %s: %s", errstr, p);
- portlist[0] = calloc(1, PORT_MAX_LEN);
+ portlist[0] = strdup(p);
if (portlist[0] == NULL)
err(1, NULL);
- portlist[0] = p;
}
}
@@ -872,7 +871,7 @@ help(void)
\t-t Answer TELNET negotiation\n\
\t-U Use UNIX domain socket\n\
\t-u UDP mode\n\
- \t-V rdomain Specify alternate routing domain\n\
+ \t-V rtable Specify alternate routing table\n\
\t-v Verbose\n\
\t-w secs\t Timeout for connects and final net reads\n\
\t-X proto Proxy protocol: \"4\", \"5\" (SOCKS) or \"connect\"\n\
@@ -888,7 +887,7 @@ usage(int ret)
fprintf(stderr,
"usage: nc [-46DdhklnrStUuvz] [-I length] [-i interval] [-O length]\n"
"\t [-P proxy_username] [-p source_port] [-s source_ip_address] [-T ToS]\n"
- "\t [-V rdomain] [-w timeout] [-X proxy_protocol]\n"
+ "\t [-V rtable] [-w timeout] [-X proxy_protocol]\n"
"\t [-x proxy_address[:port]] [hostname] [port]\n");
if (ret)
exit(1);
diff --git a/socks.c b/socks.c
index da7bd0c60e6d..b38dff741e19 100644
--- a/socks.c
+++ b/socks.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: socks.c,v 1.17 2006/09/25 04:51:20 ray Exp $ */
+/* $OpenBSD: socks.c,v 1.18 2010/04/20 07:26:35 nicm Exp $ */
/*
* Copyright (c) 1999 Niklas Hallqvist. All rights reserved.
@@ -167,11 +167,11 @@ socks_connect(const char *host, const char *port,
buf[2] = SOCKS_NOAUTH;
cnt = atomicio(vwrite, proxyfd, buf, 3);
if (cnt != 3)
- err(1, "write failed (%d/3)", cnt);
+ err(1, "write failed (%zu/3)", cnt);
cnt = atomicio(read, proxyfd, buf, 2);
if (cnt != 2)
- err(1, "read failed (%d/3)", cnt);
+ err(1, "read failed (%zu/3)", cnt);
if (buf[1] == SOCKS_NOMETHOD)
errx(1, "authentication method negotiation failed");
@@ -220,11 +220,11 @@ socks_connect(const char *host, const char *port,
cnt = atomicio(vwrite, proxyfd, buf, wlen);
if (cnt != wlen)
- err(1, "write failed (%d/%d)", cnt, wlen);
+ err(1, "write failed (%zu/%zu)", cnt, wlen);
cnt = atomicio(read, proxyfd, buf, 10);
if (cnt != 10)
- err(1, "read failed (%d/10)", cnt);
+ err(1, "read failed (%zu/10)", cnt);
if (buf[1] != 0)
errx(1, "connection failed, SOCKS error %d", buf[1]);
} else if (socksv == 4) {
@@ -242,11 +242,11 @@ socks_connect(const char *host, const char *port,
cnt = atomicio(vwrite, proxyfd, buf, wlen);
if (cnt != wlen)
- err(1, "write failed (%d/%d)", cnt, wlen);
+ err(1, "write failed (%zu/%zu)", cnt, wlen);
cnt = atomicio(read, proxyfd, buf, 8);
if (cnt != 8)
- err(1, "read failed (%d/8)", cnt);
+ err(1, "read failed (%zu/8)", cnt);
if (buf[1] != 90)
errx(1, "connection failed, SOCKS error %d", buf[1]);
} else if (socksv == -1) {
@@ -272,7 +272,7 @@ socks_connect(const char *host, const char *port,
cnt = atomicio(vwrite, proxyfd, buf, r);
if (cnt != r)
- err(1, "write failed (%d/%d)", cnt, r);
+ err(1, "write failed (%zu/%d)", cnt, r);
if (authretry > 1) {
char resp[1024];
@@ -290,7 +290,7 @@ socks_connect(const char *host, const char *port,
errx(1, "Proxy auth response too long");
r = strlen(buf);
if ((cnt = atomicio(vwrite, proxyfd, buf, r)) != r)
- err(1, "write failed (%d/%d)", cnt, r);
+ err(1, "write failed (%zu/%d)", cnt, r);
}
/* Terminate headers */