freebsd-nq/sys/i386/ibcs2/ibcs2_socksys.c
Steven Wallace 9e03db613c Remove old files no longer needed.
Add new files created for emulator.
Modify NetBSD import to work with FreeBSD and add new features and
code.  The complete emulator is essentially a combination of work/code
implemented by Sean Eric Fagan, Soren Schmidt, Scott Bartram, and myself,
Steven Wallace.

Features of this new emulator system include:

 o  "clean" code, including strict prototyping.
 o  Auto-generation of ibcs2 system calls, xenix system calls, isc system
calls.  Generation includes system tables, structure definitions,
and prototyping of function calls.
 o  ibcs2 emulator does not rely on any COMPAT_43 system calls.
 o  embedded socksys support
 o  ibcs2 msgsys, semsys, shmsys calls supported if supported in kernel
 o  alternate /emul/ibcs2 namespace searched first for files in ibcs2
system.  Usefull to keep sysv libraries, binaries in /emul/ibcs2.
 o  many other finer details and functions fixed or implemented.
1995-10-10 07:59:30 +00:00

131 lines
4.2 KiB
C

/*
* 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>
#include <sys/systm.h>
#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>
#include <sys/sysproto.h>
#include <net/if.h>
#include <i386/ibcs2/ibcs2_socksys.h>
#include <i386/ibcs2/ibcs2_util.h>
/*
* iBCS2 socksys calls.
*/
int
ibcs2_socksys(p, uap, retval)
register struct proc *p;
register struct ibcs2_socksys_args *uap;
int *retval;
{
register struct filedesc *fdp = p->p_fd;
register struct file *fp;
int error;
int realargs[7]; /* 1 for command, 6 for recvfrom */
void *passargs;
/*
* 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.
*/
if (error = copyin(uap->argsp, (caddr_t)realargs, sizeof(realargs)))
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]));
passargs = (void *)(realargs + 1);
switch (realargs[0]) {
case SOCKSYS_ACCEPT:
return accept(p, passargs, retval);
case SOCKSYS_BIND:
return bind(p, passargs, retval);
case SOCKSYS_CONNECT:
return connect(p, passargs, retval);
case SOCKSYS_GETPEERNAME:
return getpeername(p, passargs, retval);
case SOCKSYS_GETSOCKNAME:
return getsockname(p, passargs, retval);
case SOCKSYS_GETSOCKOPT:
return getsockopt(p, passargs, retval);
case SOCKSYS_LISTEN:
return listen(p, passargs, retval);
case SOCKSYS_RECV:
realargs[5] = realargs[6] = 0;
/* FALLTHROUGH */
case SOCKSYS_RECVFROM:
return recvfrom(p, passargs, retval);
case SOCKSYS_SEND:
realargs[5] = realargs[6] = 0;
/* FALLTHROUGH */
case SOCKSYS_SENDTO:
return sendto(p, passargs, retval);
case SOCKSYS_SETSOCKOPT:
return setsockopt(p, passargs, retval);
case SOCKSYS_SHUTDOWN:
return shutdown(p, passargs, retval);
case SOCKSYS_SOCKET:
return socket(p, passargs, retval);
case SOCKSYS_SELECT:
return select(p, passargs, retval);
case SOCKSYS_GETIPDOMAIN:
return getdomainname(p, passargs, retval);
case SOCKSYS_SETIPDOMAIN:
return setdomainname(p, passargs, retval);
case SOCKSYS_ADJTIME:
return adjtime(p, passargs, retval);
case SOCKSYS_SETREUID:
return setreuid(p, passargs, retval);
case SOCKSYS_SETREGID:
return setregid(p, passargs, retval);
case SOCKSYS_GETTIME:
return gettimeofday(p, passargs, retval);
case SOCKSYS_SETTIME:
return settimeofday(p, passargs, retval);
case SOCKSYS_GETITIMER:
return getitimer(p, passargs, retval);
case SOCKSYS_SETITIMER:
return setitimer(p, passargs, retval);
default:
printf("socksys unknown %08x %08x %08x %08x %08x %08x %08x\n",
realargs[0], realargs[1], realargs[2], realargs[3],
realargs[4], realargs[5], realargs[6]);
return EINVAL;
}
/* NOTREACHED */
}