147 lines
4.2 KiB
C
147 lines
4.2 KiB
C
/* $NetBSD: svr4_32_net.c,v 1.10 2003/09/13 08:22:51 jdolecek Exp $ */
|
|
|
|
/*-
|
|
* Copyright (c) 1994 The NetBSD Foundation, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
* by Christos Zoulas.
|
|
*
|
|
* 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. Redistributions in binary form must reproduce the above copyright
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
* documentation and/or other materials provided with the distribution.
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
* must display the following acknowledgement:
|
|
* This product includes software developed by the NetBSD
|
|
* Foundation, Inc. and its contributors.
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
* contributors may be used to endorse or promote products derived
|
|
* from this software without specific prior written permission.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
* ``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 FOUNDATION OR CONTRIBUTORS
|
|
* 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.
|
|
*/
|
|
|
|
/*
|
|
* Emulate /dev/{udp,tcp,...}
|
|
*/
|
|
|
|
#include <sys/cdefs.h>
|
|
__KERNEL_RCSID(0, "$NetBSD: svr4_32_net.c,v 1.10 2003/09/13 08:22:51 jdolecek Exp $");
|
|
|
|
#define COMPAT_SVR4 1
|
|
|
|
#include <sys/param.h>
|
|
#include <sys/kernel.h>
|
|
#include <sys/systm.h>
|
|
#include <sys/buf.h>
|
|
#include <sys/malloc.h>
|
|
#include <sys/ioctl.h>
|
|
#include <sys/tty.h>
|
|
#include <sys/file.h>
|
|
#include <sys/filedesc.h>
|
|
#include <sys/fcntl.h>
|
|
#include <sys/select.h>
|
|
#include <sys/socket.h>
|
|
#include <sys/socketvar.h>
|
|
#include <sys/protosw.h>
|
|
#include <sys/domain.h>
|
|
#include <net/if.h>
|
|
#include <netinet/in.h>
|
|
#include <sys/proc.h>
|
|
#include <sys/vnode.h>
|
|
#include <sys/device.h>
|
|
#include <sys/conf.h>
|
|
#include <sys/mount.h>
|
|
|
|
#include <sys/sa.h>
|
|
#include <sys/syscallargs.h>
|
|
|
|
#include <compat/svr4_32/svr4_32_types.h>
|
|
#include <compat/svr4_32/svr4_32_util.h>
|
|
#include <compat/svr4_32/svr4_32_signal.h>
|
|
#include <compat/svr4_32/svr4_32_lwp.h>
|
|
#include <compat/svr4_32/svr4_32_ucontext.h>
|
|
#include <compat/svr4_32/svr4_32_syscallargs.h>
|
|
#include <compat/svr4_32/svr4_32_ioctl.h>
|
|
#include <compat/svr4_32/svr4_32_stropts.h>
|
|
#include <compat/svr4_32/svr4_32_socket.h>
|
|
|
|
/*
|
|
* Device minor numbers
|
|
*/
|
|
enum {
|
|
dev_ptm = 10,
|
|
dev_arp = 26,
|
|
dev_icmp = 27,
|
|
dev_ip = 28,
|
|
dev_tcp = 35,
|
|
dev_udp = 36,
|
|
dev_rawip = 37,
|
|
dev_unix_dgram = 38,
|
|
dev_unix_stream = 39,
|
|
dev_unix_ord_stream = 40
|
|
};
|
|
|
|
int svr4_32_netattach __P((int));
|
|
|
|
int svr4_soo_close __P((struct file *, struct proc *));
|
|
int svr4_ptm_alloc __P((struct proc *));
|
|
|
|
static struct fileops svr4_32_netops = {
|
|
soo_read, soo_write, soo_ioctl, soo_fcntl, soo_poll,
|
|
soo_stat, svr4_soo_close
|
|
};
|
|
|
|
|
|
/*
|
|
* Used by new config, but we don't need it.
|
|
*/
|
|
int
|
|
svr4_32_netattach(n)
|
|
int n;
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
struct svr4_strm *
|
|
svr4_32_stream_get(fp)
|
|
struct file *fp;
|
|
{
|
|
struct socket *so;
|
|
struct svr4_strm *st;
|
|
|
|
if (fp == NULL || fp->f_type != DTYPE_SOCKET)
|
|
return NULL;
|
|
|
|
so = (struct socket *) fp->f_data;
|
|
|
|
if (so->so_internal)
|
|
return so->so_internal;
|
|
|
|
/* Allocate a new one. */
|
|
fp->f_ops = &svr4_32_netops;
|
|
st = malloc(sizeof(struct svr4_strm), M_NETADDR, M_WAITOK);
|
|
st->s_family = so->so_proto->pr_domain->dom_family;
|
|
st->s_cmd = ~0;
|
|
st->s_afd = -1;
|
|
st->s_eventmask = 0;
|
|
so->so_internal = st;
|
|
|
|
return st;
|
|
}
|