diff options
-rw-r--r-- | usr.bin/nc/nc.1 | 7 | ||||
-rw-r--r-- | usr.bin/nc/netcat.c | 28 |
2 files changed, 29 insertions, 6 deletions
diff --git a/usr.bin/nc/nc.1 b/usr.bin/nc/nc.1 index e8dfeea0771..c8bb9b071d0 100644 --- a/usr.bin/nc/nc.1 +++ b/usr.bin/nc/nc.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: nc.1,v 1.48 2008/09/19 13:24:41 sobrado Exp $ +.\" $OpenBSD: nc.1,v 1.49 2009/06/05 00:18:10 claudio 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: September 19 2008 $ +.Dd $Mdocdate: June 5 2009 $ .Dt NC 1 .Os .Sh NAME @@ -42,6 +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 w Ar timeout .Op Fl X Ar proxy_protocol .Oo Xo @@ -176,6 +177,8 @@ to script telnet sessions. Specifies to use Unix Domain Sockets. .It Fl u Use UDP instead of the default option of TCP. +.It Fl V Ar rdomain +Set the routing domain, the default is 0. .It Fl v Have .Nm diff --git a/usr.bin/nc/netcat.c b/usr.bin/nc/netcat.c index e4650735061..6700f89cfe5 100644 --- a/usr.bin/nc/netcat.c +++ b/usr.bin/nc/netcat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: netcat.c,v 1.92 2008/09/19 13:24:41 sobrado Exp $ */ +/* $OpenBSD: netcat.c,v 1.93 2009/06/05 00:18:10 claudio Exp $ */ /* * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> * @@ -84,6 +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; int timeout = -1; int family = AF_UNSPEC; @@ -125,7 +126,7 @@ main(int argc, char *argv[]) sv = NULL; while ((ch = getopt(argc, argv, - "46DdhI:i:jklnO:P:p:rSs:tT:Uuvw:X:x:z")) != -1) { + "46DdhI:i:jklnO:P:p:rSs:tT:UuV:vw:X:x:z")) != -1) { switch (ch) { case '4': family = AF_INET; @@ -187,6 +188,12 @@ main(int argc, char *argv[]) case 'u': uflag = 1; break; + case 'V': + rdomain = (unsigned int)strtonum(optarg, 0, + RT_TABLEID_MAX, &errstr); + if (errstr) + errx(1, "rdomain %s: %s", errstr, optarg); + break; case 'v': vflag = 1; break; @@ -498,6 +505,12 @@ 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"); + } + /* Bind to a local port or source address if specified. */ if (sflag || pflag) { struct addrinfo ahints, *ares; @@ -566,6 +579,12 @@ 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"); + } + ret = setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof(x)); if (ret == -1) err(1, NULL); @@ -851,6 +870,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 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\ @@ -866,8 +886,8 @@ 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 [-w timeout] [-X proxy_protocol] [-x proxy_address[:port]] [hostname]\n" - "\t [port]\n"); + "\t [-V rdomain] [-w timeout] [-X proxy_protocol]\n" + "\t [-x proxy_address[:port]] [hostname] [port]\n"); if (ret) exit(1); } |