Date: Fri, 24 Jul 2020 14:51:28 +0000 (UTC) From: Mark Johnston <markj@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r363474 - stable/12/contrib/netcat Message-ID: <202007241451.06OEpSot061925@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: markj Date: Fri Jul 24 14:51:28 2020 New Revision: 363474 URL: https://svnweb.freebsd.org/changeset/base/363474 Log: MFC r363084: Add a --sctp flag to nc. Modified: stable/12/contrib/netcat/nc.1 stable/12/contrib/netcat/netcat.c Directory Properties: stable/12/ (props changed) Modified: stable/12/contrib/netcat/nc.1 ============================================================================== --- stable/12/contrib/netcat/nc.1 Fri Jul 24 14:17:37 2020 (r363473) +++ stable/12/contrib/netcat/nc.1 Fri Jul 24 14:51:28 2020 (r363474) @@ -41,6 +41,7 @@ .Op Fl I Ar length .Op Fl i Ar interval .Op Fl -no-tcpopt +.Op Fl -sctp .Op Fl O Ar length .Op Fl P Ar proxy_username .Op Fl p Ar source_port @@ -181,6 +182,8 @@ hostnames or ports. Disables the use of TCP options on the socket, by setting the boolean TCP_NOOPT socket option. +.It Fl -sctp +Use SCTP instead of the default option of TCP. .It Fl O Ar length Specifies the size of the TCP send buffer. .It Fl P Ar proxy_username Modified: stable/12/contrib/netcat/netcat.c ============================================================================== --- stable/12/contrib/netcat/netcat.c Fri Jul 24 14:17:37 2020 (r363473) +++ stable/12/contrib/netcat/netcat.c Fri Jul 24 14:51:28 2020 (r363474) @@ -88,6 +88,7 @@ int lflag; /* Bind to local port */ int Nflag; /* shutdown() network socket */ int nflag; /* Don't do name look up */ int FreeBSD_Oflag; /* Do not use TCP options */ +int FreeBSD_sctp; /* Use SCTP */ char *Pflag; /* Proxy username */ char *pflag; /* Localport flag */ int rflag; /* Random ports flag */ @@ -153,6 +154,7 @@ main(int argc, char *argv[]) char unix_dg_tmp_socket_buf[UNIX_DG_TMP_SOCKET_SIZE]; struct option longopts[] = { { "no-tcpopt", no_argument, &FreeBSD_Oflag, 1 }, + { "sctp", no_argument, &FreeBSD_sctp, 1 }, { NULL, 0, NULL, 0 } }; @@ -310,6 +312,9 @@ main(int argc, char *argv[]) if (Tflag < 0 || Tflag > 255 || errstr || errno) errx(1, "illegal tos value %s", optarg); break; + case 0: + /* Long option. */ + break; default: usage(1); } @@ -340,6 +345,12 @@ main(int argc, char *argv[]) errx(1, "cannot use -z and -l"); if (!lflag && kflag) errx(1, "must use -l with -k"); + if (FreeBSD_sctp) { + if (uflag) + errx(1, "cannot use -u and --sctp"); + if (family == AF_UNIX) + errx(1, "cannot use -U and --sctp"); + } /* Get name of temporary socket for unix datagram client */ if ((family == AF_UNIX) && uflag && !lflag) { @@ -359,7 +370,8 @@ main(int argc, char *argv[]) memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = family; hints.ai_socktype = uflag ? SOCK_DGRAM : SOCK_STREAM; - hints.ai_protocol = uflag ? IPPROTO_UDP : IPPROTO_TCP; + hints.ai_protocol = uflag ? IPPROTO_UDP : + FreeBSD_sctp ? IPPROTO_SCTP : IPPROTO_TCP; if (nflag) hints.ai_flags |= AI_NUMERICHOST; } @@ -368,6 +380,9 @@ main(int argc, char *argv[]) if (uflag) errx(1, "no proxy support for UDP mode"); + if (FreeBSD_sctp) + errx(1, "no proxy support for SCTP mode"); + if (lflag) errx(1, "no proxy support for listen"); @@ -1330,6 +1345,7 @@ help(void) \t-N Shutdown the network socket after EOF on stdin\n\ \t-n Suppress name/port resolutions\n\ \t--no-tcpopt Disable TCP options\n\ + \t--sctp\t SCTP mode\n\ \t-O length TCP send buffer length\n\ \t-P proxyuser\tUsername for proxy authentication\n\ \t-p port\t Specify local port for remote connects\n\ @@ -1348,7 +1364,7 @@ help(void) \t-z Zero-I/O mode [used for scanning]\n\ Port numbers can be individual or ranges: lo-hi [inclusive]\n"); #ifdef IPSEC - fprintf(stderr, "See ipsec_set_policy(3) for -e argument format\n"); + fprintf(stderr, "\tSee ipsec_set_policy(3) for -e argument format\n"); #endif exit(1); } @@ -1388,6 +1404,7 @@ usage(int ret) #else "usage: nc [-46DdFhklNnrStUuvz] [-I length] [-i interval] [-O length]\n" #endif + "\t [--no-tcpopt] [--sctp]\n" "\t [-P proxy_username] [-p source_port] [-s source] [-T ToS]\n" "\t [-V rtable] [-w timeout] [-X proxy_protocol]\n" "\t [-x proxy_address[:port]] [destination] [port]\n");
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202007241451.06OEpSot061925>