diff options
author | 2012-07-07 15:33:02 +0000 | |
---|---|---|
committer | 2012-07-07 15:33:02 +0000 | |
commit | d7038269867a6a7ccafcdd9ff9e08efec23af684 (patch) | |
tree | 0d8aa06b843616c4e7d37c9cc3756fdf94e1f26c | |
parent | restore DIOCKILLSTATE semantics to what they were before the NAT rewrite. (diff) | |
download | wireguard-openbsd-d7038269867a6a7ccafcdd9ff9e08efec23af684.tar.xz wireguard-openbsd-d7038269867a6a7ccafcdd9ff9e08efec23af684.zip |
Allow UDP server to receive datagrams from multiple socket pairs with -k
flag. Prompted by a question from dsp at 2f30 dot org, diff from Lazarom
Koromil with a few tweaks by me, many thanks.
ok mikeb@ nicm@ haesbaert@
-rw-r--r-- | usr.bin/nc/nc.1 | 8 | ||||
-rw-r--r-- | usr.bin/nc/netcat.c | 16 |
2 files changed, 17 insertions, 7 deletions
diff --git a/usr.bin/nc/nc.1 b/usr.bin/nc/nc.1 index 75d1437580a..232b6f5b6e1 100644 --- a/usr.bin/nc/nc.1 +++ b/usr.bin/nc/nc.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: nc.1,v 1.60 2012/02/07 12:11:43 lum Exp $ +.\" $OpenBSD: nc.1,v 1.61 2012/07/07 15:33:02 haesbaert 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 7 2012 $ +.Dd $Mdocdate: July 7 2012 $ .Dt NC 1 .Os .Sh NAME @@ -119,6 +119,10 @@ is completed. It is an error to use this option without the .Fl l option. +When used together with the +.Fl u +option, the server socket is not connected and it can receive UDP datagrams from +multiple hosts. .It Fl l Used to specify that .Nm diff --git a/usr.bin/nc/netcat.c b/usr.bin/nc/netcat.c index 4bef71a7ca4..a034bbab8c0 100644 --- a/usr.bin/nc/netcat.c +++ b/usr.bin/nc/netcat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: netcat.c,v 1.108 2012/07/07 09:36:30 haesbaert Exp $ */ +/* $OpenBSD: netcat.c,v 1.109 2012/07/07 15:33:02 haesbaert Exp $ */ /* * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> * @@ -345,11 +345,17 @@ main(int argc, char *argv[]) if (s < 0) err(1, NULL); /* - * For UDP, we will use recvfrom() initially - * to wait for a caller, then use the regular - * functions to talk to the caller. + * For UDP and -k, don't connect the socket, let it + * receive datagrams from multiple socket pairs. */ - if (uflag) { + if (uflag && kflag) + readwrite(s); + /* + * For UDP and not -k, we will use recvfrom() initially + * to wait for a caller, then use the regular functions + * to talk to the caller. + */ + else if (uflag && !kflag) { int rv, plen; char buf[16384]; struct sockaddr_storage z; |