PERFORCE change 197243 for review
Catalin Nicutar
cnicutar at FreeBSD.org
Fri Aug 5 23:02:02 UTC 2011
http://p4web.freebsd.org/@@197243?ac=10
Change 197243 by cnicutar at cnicutar_cronos on 2011/08/05 23:01:13
Forward-port netcat UTO support to HEAD.
Affected files ...
.. //depot/projects/soc2011/cnicutar_tcputo_9/src/contrib/netcat/nc.1#2 edit
.. //depot/projects/soc2011/cnicutar_tcputo_9/src/contrib/netcat/netcat.c#2 edit
Differences ...
==== //depot/projects/soc2011/cnicutar_tcputo_9/src/contrib/netcat/nc.1#2 (text+ko) ====
@@ -27,7 +27,7 @@
.\"
.\" $FreeBSD: src/contrib/netcat/nc.1,v 1.21 2011/05/11 21:52:26 delphij Exp $
.\"
-.Dd January 8, 2011
+.Dd July 19, 2011
.Dt NC 1
.Os
.Sh NAME
@@ -175,6 +175,9 @@
Specifies that source and/or destination ports should be chosen randomly
instead of sequentially within a range or in the order that the system
assigns them.
+.It Fl -rcv-uto
+Specifies that the UTO value sent by the peer should be accepted when TCP
+computes the local User Timeout.
.It Fl S
Enables the RFC 2385 TCP MD5 signature option.
.It Fl s Ar source
@@ -240,6 +243,9 @@
.Fl w
flag.
The default is no timeout.
+.Tf
+This timeout also controls the User Timeout advertised to the peer by
+TCP.
.It Fl X Ar proxy_protocol
Requests that
.Nm
==== //depot/projects/soc2011/cnicutar_tcputo_9/src/contrib/netcat/netcat.c#2 (text+ko) ====
@@ -83,6 +83,7 @@
char *Pflag; /* Proxy username */
char *pflag; /* Localport flag */
int rflag; /* Random ports flag */
+int utoflag; /* Accept peer UTO. */
char *sflag; /* Source Address */
int tflag; /* Telnet Emulation */
int uflag; /* UDP - Default to TCP */
@@ -140,6 +141,7 @@
char unix_dg_tmp_socket_buf[UNIX_DG_TMP_SOCKET_SIZE];
struct option longopts[] = {
{ "no-tcpopt", no_argument, &FreeBSD_Oflag, 1 },
+ { "rcv-uto", no_argument, &utoflag, 1 },
{ NULL, 0, NULL, 0 }
};
@@ -250,7 +252,6 @@
timeout = strtonum(optarg, 0, INT_MAX / 1000, &errstr);
if (errstr)
errx(1, "timeout %s: %s", errstr, optarg);
- timeout *= 1000;
break;
case 'x':
xflag = 1;
@@ -283,6 +284,9 @@
case 'T':
Tflag = parse_iptos(optarg);
break;
+ case 0:
+ /* getopt_long returns 0 for --long-options. */
+ break;
default:
usage(1);
}
@@ -742,7 +746,7 @@
if (iflag)
sleep(iflag);
- if ((n = poll(pfd, 2 - dflag, timeout)) < 0) {
+ if ((n = poll(pfd, 2 - dflag, timeout * 1000)) < 0) {
close(nfd);
err(1, "Polling Error");
}
@@ -938,6 +942,19 @@
&FreeBSD_Oflag, sizeof(FreeBSD_Oflag)) == -1)
err(1, "disable TCP options");
}
+ /*
+ * Try to set the sent timeout but don't die on error. The timeout
+ * option was here before UTO so this would break existing
+ * applications on systems where UTO is disabled.
+ */
+ if (timeout > 0 && setsockopt(s, IPPROTO_TCP, TCP_SNDUTO_TIMEOUT,
+ &timeout, sizeof(timeout)))
+ perror("setsokopt send TCP UTO");
+
+ /* Set the disposition to accept the timeout of the peer. */
+ if (utoflag && setsockopt(s, IPPROTO_TCP, TCP_RCVUTO_TIMEOUT,
+ &utoflag, sizeof(utoflag)))
+ err(1, "setsokopt receive TCP UTO");
}
int
@@ -983,6 +1000,7 @@
\t-P proxyuser\tUsername for proxy authentication\n\
\t-p port\t Specify local port for remote connects\n\
\t-r Randomize remote ports\n\
+ \t--rcv-uto Accept peer User Timeout\n\
\t-S Enable the TCP MD5 signature option\n\
\t-s addr\t Local source address\n\
\t-T ToS\t Set IP Type of Service\n\
More information about the p4-projects
mailing list