Date: Tue, 19 Jul 2011 10:31:06 GMT From: Catalin Nicutar <cnicutar@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 196388 for review Message-ID: <201107191031.p6JAV6u9059391@skunkworks.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@196388?ac=10 Change 196388 by cnicutar@cnicutar_cronos on 2011/07/19 10:30:05 Add TCP UTO support to netcat. Affected files ... .. //depot/projects/soc2011/cnicutar_tcputo_8/src/contrib/netcat/nc.1#2 edit .. //depot/projects/soc2011/cnicutar_tcputo_8/src/contrib/netcat/netcat.c#2 edit Differences ... ==== //depot/projects/soc2011/cnicutar_tcputo_8/src/contrib/netcat/nc.1#2 (text+ko) ==== @@ -27,7 +27,7 @@ .\" .\" $FreeBSD: src/contrib/netcat/nc.1,v 1.14.2.6 2010/11/18 01:14:18 delphij Exp $ .\" -.Dd July 25, 2010 +.Dd July 19, 2011 .Dt NC 1 .Os .Sh NAME @@ -173,6 +173,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_ip_address @@ -224,6 +227,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_8/src/contrib/netcat/netcat.c#2 (text+ko) ==== @@ -82,6 +82,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 */ @@ -136,6 +137,7 @@ struct addrinfo proxyhints; struct option longopts[] = { { "no-tcpopt", no_argument, &FreeBSD_Oflag, 1 }, + { "rcv-uto", no_argument, &utoflag, 1 }, { NULL, 0, NULL, 0 } }; @@ -246,7 +248,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; @@ -279,6 +280,9 @@ case 'T': Tflag = parse_iptos(optarg); break; + case 0: + /* getopt_long returns 0 for --long-options. */ + break; default: usage(1); } @@ -698,7 +702,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"); } @@ -894,6 +898,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 @@ -939,6 +956,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\
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201107191031.p6JAV6u9059391>