Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/librumphijack Support paccept for nc



details:   https://anonhg.NetBSD.org/src/rev/507575cb4b2f
branches:  trunk
changeset: 351492:507575cb4b2f
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Thu Feb 16 08:08:01 2017 +0000

description:
Support paccept for nc

diffstat:

 lib/librumphijack/hijack.c |  37 ++++++++++++++++++++++++++++++++++---
 1 files changed, 34 insertions(+), 3 deletions(-)

diffs (72 lines):

diff -r 9472525c3700 -r 507575cb4b2f lib/librumphijack/hijack.c
--- a/lib/librumphijack/hijack.c        Thu Feb 16 08:01:11 2017 +0000
+++ b/lib/librumphijack/hijack.c        Thu Feb 16 08:08:01 2017 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: hijack.c,v 1.121 2016/12/02 20:53:36 christos Exp $   */
+/*      $NetBSD: hijack.c,v 1.122 2017/02/16 08:08:01 ozaki-r Exp $    */
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include <rump/rumpuser_port.h>
 
 #if !defined(lint)
-__RCSID("$NetBSD: hijack.c,v 1.121 2016/12/02 20:53:36 christos Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.122 2017/02/16 08:08:01 ozaki-r Exp $");
 #endif
 
 #include <sys/param.h>
@@ -89,7 +89,8 @@
 enum dualcall {
        DUALCALL_WRITE, DUALCALL_WRITEV, DUALCALL_PWRITE, DUALCALL_PWRITEV,
        DUALCALL_IOCTL, DUALCALL_FCNTL,
-       DUALCALL_SOCKET, DUALCALL_ACCEPT, DUALCALL_BIND, DUALCALL_CONNECT,
+       DUALCALL_SOCKET, DUALCALL_ACCEPT, DUALCALL_PACCEPT,
+       DUALCALL_BIND, DUALCALL_CONNECT,
        DUALCALL_GETPEERNAME, DUALCALL_GETSOCKNAME, DUALCALL_LISTEN,
        DUALCALL_RECVFROM, DUALCALL_RECVMSG,
        DUALCALL_SENDTO, DUALCALL_SENDMSG,
@@ -267,6 +268,7 @@
 } syscnames[] = {
        { DUALCALL_SOCKET,      S(REALSOCKET),  RSYS_NAME(SOCKET)       },
        { DUALCALL_ACCEPT,      "accept",       RSYS_NAME(ACCEPT)       },
+       { DUALCALL_PACCEPT,     "paccept",      RSYS_NAME(PACCEPT)      },
        { DUALCALL_BIND,        "bind",         RSYS_NAME(BIND)         },
        { DUALCALL_CONNECT,     "connect",      RSYS_NAME(CONNECT)      },
        { DUALCALL_GETPEERNAME, "getpeername",  RSYS_NAME(GETPEERNAME)  },
@@ -1334,6 +1336,35 @@
        return fd;
 }
 
+int
+paccept(int s, struct sockaddr *addr, socklen_t *addrlen,
+    const sigset_t * restrict sigmask, int flags)
+{
+       int (*op_paccept)(int, struct sockaddr *, socklen_t *,
+           const sigset_t * restrict, int);
+       int fd;
+       bool isrump;
+
+       isrump = fd_isrump(s);
+
+       DPRINTF(("paccept -> %d", s));
+       if (isrump) {
+               op_paccept = GETSYSCALL(rump, PACCEPT);
+               s = fd_host2rump(s);
+       } else {
+               op_paccept = GETSYSCALL(host, PACCEPT);
+       }
+       fd = op_paccept(s, addr, addrlen, sigmask, flags);
+       if (fd != -1 && isrump)
+               fd = fd_rump2host(fd);
+       else
+               fd = fd_host2host(fd);
+
+       DPRINTF((" <- %d\n", fd));
+
+       return fd;
+}
+
 /*
  * ioctl() and fcntl() are varargs calls and need special treatment.
  */



Home | Main Index | Thread Index | Old Index