1996-10-13 04:46:49 +04:00
|
|
|
/* $NetBSD: ibcs2_socksys.c,v 1.7 1996/10/13 00:46:51 christos Exp $ */
|
1996-05-03 21:05:16 +04:00
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1994, 1995 Scott Bartram
|
|
|
|
* Copyright (c) 1994 Arne H Juul
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
1996-05-03 21:05:16 +04:00
|
|
|
#include <sys/systm.h>
|
1995-03-14 18:12:17 +03:00
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/filedesc.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/termios.h>
|
|
|
|
#include <sys/tty.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/ioctl.h>
|
1996-05-03 21:05:16 +04:00
|
|
|
#include <sys/mount.h>
|
1995-03-14 18:12:17 +03:00
|
|
|
#include <net/if.h>
|
|
|
|
|
1996-05-03 21:05:16 +04:00
|
|
|
|
|
|
|
#include <sys/syscallargs.h>
|
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
#include <compat/ibcs2/ibcs2_socksys.h>
|
|
|
|
#include <compat/ibcs2/ibcs2_util.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* iBCS2 socksys calls.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct ibcs2_socksys_args {
|
|
|
|
int fd;
|
|
|
|
int magic;
|
|
|
|
caddr_t argsp;
|
|
|
|
};
|
|
|
|
|
|
|
|
int
|
1996-05-03 21:05:16 +04:00
|
|
|
ibcs2_socksys(p, v, retval)
|
1995-03-14 18:12:17 +03:00
|
|
|
register struct proc *p;
|
1996-05-03 21:05:16 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1996-05-03 21:05:16 +04:00
|
|
|
register struct ibcs2_socksys_args *uap = v;
|
1995-03-14 18:12:17 +03:00
|
|
|
int error;
|
|
|
|
int realargs[7]; /* 1 for command, 6 for recvfrom */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SOCKET should only be legal on /dev/socksys.
|
|
|
|
* GETIPDOMAINNAME should only be legal on /dev/socksys ?
|
|
|
|
* The others are (and should be) only legal on sockets.
|
|
|
|
*/
|
|
|
|
|
1996-05-03 21:05:16 +04:00
|
|
|
error = copyin(uap->argsp, (caddr_t)realargs, sizeof(realargs));
|
|
|
|
if (error)
|
1995-03-14 18:12:17 +03:00
|
|
|
return error;
|
|
|
|
DPRINTF(("ibcs2_socksys: %08x %08x %08x %08x %08x %08x %08x\n",
|
|
|
|
realargs[0], realargs[1], realargs[2], realargs[3],
|
|
|
|
realargs[4], realargs[5], realargs[6]));
|
|
|
|
switch (realargs[0]) {
|
|
|
|
case SOCKSYS_ACCEPT:
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_accept(p, realargs + 1, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
case SOCKSYS_BIND:
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_bind(p, realargs + 1, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
case SOCKSYS_CONNECT:
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_connect(p, realargs + 1, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
case SOCKSYS_GETPEERNAME:
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_getpeername(p, realargs + 1, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
case SOCKSYS_GETSOCKNAME:
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_getsockname(p, realargs + 1, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
case SOCKSYS_GETSOCKOPT:
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_getsockopt(p, realargs + 1, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
case SOCKSYS_LISTEN:
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_listen(p, realargs + 1, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
case SOCKSYS_RECV:
|
|
|
|
realargs[5] = realargs[6] = 0;
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
case SOCKSYS_RECVFROM:
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_recvfrom(p, realargs + 1, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
case SOCKSYS_SEND:
|
|
|
|
realargs[5] = realargs[6] = 0;
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
case SOCKSYS_SENDTO:
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_sendto(p, realargs + 1, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
case SOCKSYS_SETSOCKOPT:
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_setsockopt(p, realargs + 1, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
case SOCKSYS_SHUTDOWN:
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_shutdown(p, realargs + 1, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
case SOCKSYS_SOCKET:
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_socket(p, realargs + 1, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
case SOCKSYS_SELECT:
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_select(p, realargs + 1, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
case SOCKSYS_GETIPDOMAIN:
|
1995-10-07 09:25:19 +03:00
|
|
|
return compat_09_sys_getdomainname(p, realargs + 1, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
case SOCKSYS_SETIPDOMAIN:
|
1995-10-07 09:25:19 +03:00
|
|
|
return compat_09_sys_setdomainname(p, realargs + 1, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
case SOCKSYS_ADJTIME:
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_adjtime(p, realargs + 1, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
case SOCKSYS_SETREUID:
|
1996-06-23 15:17:50 +04:00
|
|
|
return sys_setreuid(p, realargs + 1, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
case SOCKSYS_SETREGID:
|
1996-06-23 15:17:50 +04:00
|
|
|
return sys_setregid(p, realargs + 1, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
case SOCKSYS_GETTIME:
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_gettimeofday(p, realargs + 1, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
case SOCKSYS_SETTIME:
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_settimeofday(p, realargs + 1, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
case SOCKSYS_GETITIMER:
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_getitimer(p, realargs + 1, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
case SOCKSYS_SETITIMER:
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_setitimer(p, realargs + 1, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
default:
|
1996-10-13 04:46:49 +04:00
|
|
|
printf("socksys unknown %08x %08x %08x %08x %08x %08x %08x\n",
|
1996-10-10 21:47:29 +04:00
|
|
|
realargs[0], realargs[1], realargs[2], realargs[3],
|
|
|
|
realargs[4], realargs[5], realargs[6]);
|
1995-03-14 18:12:17 +03:00
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
/* NOTREACHED */
|
|
|
|
}
|