1998-10-04 04:02:23 +04:00
|
|
|
/* $NetBSD: linux_socket.c,v 1.18 1998/10/04 00:02:43 fvdl Exp $ */
|
1998-10-01 07:33:17 +04:00
|
|
|
|
|
|
|
/*-
|
1998-10-04 04:02:23 +04:00
|
|
|
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
|
1998-10-01 07:33:17 +04:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
1998-10-04 04:02:23 +04:00
|
|
|
* by Frank van der Linden and Eric Haszlakiewicz.
|
1998-10-01 07:33:17 +04:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
1995-03-01 02:24:35 +03:00
|
|
|
|
1998-10-01 07:33:17 +04:00
|
|
|
/*
|
|
|
|
* Functions in multiarch:
|
|
|
|
* linux_sys_socketcall : linux_socketcall.c
|
|
|
|
*/
|
|
|
|
|
1995-03-01 02:24:35 +03:00
|
|
|
#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/select.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/socketvar.h>
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <netinet/in.h>
|
1995-05-28 14:20:46 +04:00
|
|
|
#include <netinet/tcp.h>
|
1995-03-01 02:24:35 +03:00
|
|
|
#include <sys/mount.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
|
|
|
|
#include <sys/syscallargs.h>
|
|
|
|
|
1998-10-04 00:17:36 +04:00
|
|
|
#include <compat/linux/common/linux_types.h>
|
|
|
|
#include <compat/linux/common/linux_util.h>
|
|
|
|
#include <compat/linux/common/linux_signal.h>
|
|
|
|
#include <compat/linux/common/linux_ioctl.h>
|
|
|
|
#include <compat/linux/common/linux_socket.h>
|
|
|
|
#include <compat/linux/common/linux_socketcall.h>
|
|
|
|
#include <compat/linux/common/linux_sockio.h>
|
|
|
|
|
1995-03-01 02:24:35 +03:00
|
|
|
#include <compat/linux/linux_syscallargs.h>
|
|
|
|
|
|
|
|
/*
|
1998-10-01 07:33:17 +04:00
|
|
|
* The calls in this file are entered either via the linux_socketcall()
|
|
|
|
* interface or, on the Alpha, as individual syscalls. The
|
|
|
|
* linux_socketcall function does any massaging of arguments so that all
|
|
|
|
* the calls in here need not think that they are anything other
|
|
|
|
* than a normal syscall.
|
1995-03-01 02:24:35 +03:00
|
|
|
*/
|
|
|
|
|
1996-04-05 04:01:10 +04:00
|
|
|
int linux_to_bsd_domain __P((int));
|
|
|
|
int linux_to_bsd_sopt_level __P((int));
|
|
|
|
int linux_to_bsd_so_sockopt __P((int));
|
|
|
|
int linux_to_bsd_ip_sockopt __P((int));
|
|
|
|
int linux_to_bsd_tcp_sockopt __P((int));
|
|
|
|
int linux_to_bsd_udp_sockopt __P((int));
|
|
|
|
|
1995-03-01 02:24:35 +03:00
|
|
|
/*
|
|
|
|
* Convert between Linux and BSD socket domain values
|
|
|
|
*/
|
1995-05-28 12:09:51 +04:00
|
|
|
int
|
1995-03-01 02:24:35 +03:00
|
|
|
linux_to_bsd_domain(ldom)
|
|
|
|
int ldom;
|
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
|
1995-03-01 02:24:35 +03:00
|
|
|
switch (ldom) {
|
|
|
|
case LINUX_AF_UNSPEC:
|
|
|
|
return AF_UNSPEC;
|
|
|
|
case LINUX_AF_UNIX:
|
|
|
|
return AF_LOCAL;
|
|
|
|
case LINUX_AF_INET:
|
|
|
|
return AF_INET;
|
|
|
|
case LINUX_AF_AX25:
|
|
|
|
return AF_CCITT;
|
|
|
|
case LINUX_AF_IPX:
|
|
|
|
return AF_IPX;
|
|
|
|
case LINUX_AF_APPLETALK:
|
|
|
|
return AF_APPLETALK;
|
1998-10-01 07:33:17 +04:00
|
|
|
case LINUX_AF_X25:
|
|
|
|
return AF_CCITT;
|
|
|
|
case LINUX_AF_INET6:
|
|
|
|
return AF_INET6;
|
|
|
|
case LINUX_AF_DECnet:
|
|
|
|
return AF_DECnet;
|
|
|
|
case LINUX_AF_NETLINK:
|
|
|
|
return AF_ROUTE;
|
|
|
|
/* NETROM, BRIDGE, ATMPVC, ROSE, NETBEUI, SECURITY, */
|
|
|
|
/* pseudo_AF_KEY, PACKET, ASH, ECONET, ATMSVC, SNA */
|
1995-03-01 02:24:35 +03:00
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-05-28 12:09:51 +04:00
|
|
|
int
|
1998-10-01 07:33:17 +04:00
|
|
|
linux_sys_socket(p, v, retval)
|
1995-03-01 02:24:35 +03:00
|
|
|
struct proc *p;
|
1998-10-01 07:33:17 +04:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct linux_sys_socket_args /* {
|
1995-03-01 02:24:35 +03:00
|
|
|
syscallarg(int) domain;
|
|
|
|
syscallarg(int) type;
|
|
|
|
syscallarg(int) protocol;
|
1998-10-01 07:33:17 +04:00
|
|
|
} */ *uap = v;
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sys_socket_args bsa;
|
1995-03-01 02:24:35 +03:00
|
|
|
|
1998-10-01 07:33:17 +04:00
|
|
|
SCARG(&bsa, protocol) = SCARG(uap, protocol);
|
|
|
|
SCARG(&bsa, type) = SCARG(uap, type);
|
|
|
|
SCARG(&bsa, domain) = linux_to_bsd_domain(SCARG(uap, domain));
|
1995-03-01 02:24:35 +03:00
|
|
|
if (SCARG(&bsa, domain) == -1)
|
|
|
|
return EINVAL;
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_socket(p, &bsa, retval);
|
1995-03-01 02:24:35 +03:00
|
|
|
}
|
|
|
|
|
1995-05-28 12:09:51 +04:00
|
|
|
int
|
1998-10-01 07:33:17 +04:00
|
|
|
linux_sys_socketpair(p, v, retval)
|
1995-03-01 02:24:35 +03:00
|
|
|
struct proc *p;
|
1998-10-01 07:33:17 +04:00
|
|
|
void *v;
|
1995-03-01 02:24:35 +03:00
|
|
|
register_t *retval;
|
|
|
|
{
|
1998-10-01 07:33:17 +04:00
|
|
|
struct linux_sys_socketpair_args /* {
|
1995-03-01 02:24:35 +03:00
|
|
|
syscallarg(int) domain;
|
|
|
|
syscallarg(int) type;
|
|
|
|
syscallarg(int) protocol;
|
|
|
|
syscallarg(int *) rsv;
|
1998-10-01 07:33:17 +04:00
|
|
|
} */ *uap = v;
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sys_socketpair_args bsa;
|
1995-03-01 02:24:35 +03:00
|
|
|
|
1998-10-01 07:33:17 +04:00
|
|
|
SCARG(&bsa, domain) = linux_to_bsd_domain(SCARG(uap, domain));
|
1995-03-01 02:24:35 +03:00
|
|
|
if (SCARG(&bsa, domain) == -1)
|
|
|
|
return EINVAL;
|
1998-10-01 07:33:17 +04:00
|
|
|
SCARG(&bsa, type) = SCARG(uap, type);
|
|
|
|
SCARG(&bsa, protocol) = SCARG(uap, protocol);
|
|
|
|
SCARG(&bsa, rsv) = SCARG(uap, rsv);
|
1995-03-01 02:24:35 +03:00
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_socketpair(p, &bsa, retval);
|
1995-03-01 02:24:35 +03:00
|
|
|
}
|
|
|
|
|
1995-05-28 12:09:51 +04:00
|
|
|
int
|
1998-10-01 07:33:17 +04:00
|
|
|
linux_sys_sendto(p, v, retval)
|
1995-03-01 02:24:35 +03:00
|
|
|
struct proc *p;
|
1998-10-01 07:33:17 +04:00
|
|
|
void *v;
|
1995-03-01 02:24:35 +03:00
|
|
|
register_t *retval;
|
|
|
|
{
|
1998-10-01 07:33:17 +04:00
|
|
|
struct linux_sys_sendto_args /* {
|
1995-03-01 02:24:35 +03:00
|
|
|
syscallarg(int) s;
|
|
|
|
syscallarg(void *) msg;
|
|
|
|
syscallarg(int) len;
|
|
|
|
syscallarg(int) flags;
|
|
|
|
syscallarg(sockaddr *) to;
|
|
|
|
syscallarg(int) tolen;
|
1998-10-01 07:33:17 +04:00
|
|
|
} */ *uap = v;
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sys_sendto_args bsa;
|
1995-03-01 02:24:35 +03:00
|
|
|
|
1998-10-01 07:33:17 +04:00
|
|
|
SCARG(&bsa, s) = SCARG(uap, s);
|
|
|
|
SCARG(&bsa, buf) = SCARG(uap, msg);
|
|
|
|
SCARG(&bsa, len) = SCARG(uap, len);
|
|
|
|
SCARG(&bsa, flags) = SCARG(uap, flags);
|
|
|
|
SCARG(&bsa, to) = (void *) SCARG(uap, to);
|
|
|
|
SCARG(&bsa, tolen) = SCARG(uap, tolen);
|
1995-03-01 02:24:35 +03:00
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_sendto(p, &bsa, retval);
|
1995-03-01 02:24:35 +03:00
|
|
|
}
|
|
|
|
|
1995-05-28 12:09:51 +04:00
|
|
|
int
|
1998-10-01 07:33:17 +04:00
|
|
|
linux_sys_recvfrom(p, v, retval)
|
1995-03-01 02:24:35 +03:00
|
|
|
struct proc *p;
|
1998-10-01 07:33:17 +04:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct linux_sys_recvfrom_args /* {
|
1995-03-01 02:24:35 +03:00
|
|
|
syscallarg(int) s;
|
|
|
|
syscallarg(void *) buf;
|
|
|
|
syscallarg(int) len;
|
|
|
|
syscallarg(int) flags;
|
|
|
|
syscallarg(struct sockaddr *) from;
|
|
|
|
syscallarg(int *) fromlen;
|
1998-10-01 07:33:17 +04:00
|
|
|
} */ *uap = v;
|
1995-10-07 09:25:19 +03:00
|
|
|
struct compat_43_sys_recvfrom_args bra;
|
1995-03-01 02:24:35 +03:00
|
|
|
|
1998-10-01 07:33:17 +04:00
|
|
|
SCARG(&bra, s) = SCARG(uap, s);
|
|
|
|
SCARG(&bra, buf) = SCARG(uap, buf);
|
|
|
|
SCARG(&bra, len) = SCARG(uap, len);
|
|
|
|
SCARG(&bra, flags) = SCARG(uap, flags);
|
|
|
|
SCARG(&bra, from) = (caddr_t) SCARG(uap, from);
|
|
|
|
SCARG(&bra, fromlenaddr) = SCARG(uap, fromlen);
|
1995-03-01 02:24:35 +03:00
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
return compat_43_sys_recvfrom(p, &bra, retval);
|
1995-03-01 02:24:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert socket option level from Linux to NetBSD value. Only SOL_SOCKET
|
|
|
|
* is different, the rest matches IPPROTO_* on both systems.
|
|
|
|
*/
|
1995-05-28 12:09:51 +04:00
|
|
|
int
|
1995-03-01 02:24:35 +03:00
|
|
|
linux_to_bsd_sopt_level(llevel)
|
|
|
|
int llevel;
|
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
|
1995-03-01 02:24:35 +03:00
|
|
|
switch (llevel) {
|
|
|
|
case LINUX_SOL_SOCKET:
|
|
|
|
return SOL_SOCKET;
|
1995-05-28 12:50:17 +04:00
|
|
|
case LINUX_SOL_IP:
|
|
|
|
return IPPROTO_IP;
|
|
|
|
case LINUX_SOL_TCP:
|
|
|
|
return IPPROTO_TCP;
|
|
|
|
case LINUX_SOL_UDP:
|
|
|
|
return IPPROTO_UDP;
|
1995-03-01 02:24:35 +03:00
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert Linux socket level socket option numbers to NetBSD values.
|
|
|
|
*/
|
1995-05-28 12:09:51 +04:00
|
|
|
int
|
1995-03-01 02:24:35 +03:00
|
|
|
linux_to_bsd_so_sockopt(lopt)
|
|
|
|
int lopt;
|
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
|
1995-03-01 02:24:35 +03:00
|
|
|
switch (lopt) {
|
|
|
|
case LINUX_SO_DEBUG:
|
|
|
|
return SO_DEBUG;
|
|
|
|
case LINUX_SO_REUSEADDR:
|
|
|
|
return SO_REUSEADDR;
|
|
|
|
case LINUX_SO_TYPE:
|
|
|
|
return SO_TYPE;
|
|
|
|
case LINUX_SO_ERROR:
|
|
|
|
return SO_ERROR;
|
|
|
|
case LINUX_SO_DONTROUTE:
|
|
|
|
return SO_DONTROUTE;
|
|
|
|
case LINUX_SO_BROADCAST:
|
|
|
|
return SO_BROADCAST;
|
|
|
|
case LINUX_SO_SNDBUF:
|
|
|
|
return SO_SNDBUF;
|
|
|
|
case LINUX_SO_RCVBUF:
|
|
|
|
return SO_RCVBUF;
|
|
|
|
case LINUX_SO_KEEPALIVE:
|
|
|
|
return SO_KEEPALIVE;
|
|
|
|
case LINUX_SO_OOBINLINE:
|
|
|
|
return SO_OOBINLINE;
|
|
|
|
case LINUX_SO_LINGER:
|
|
|
|
return SO_LINGER;
|
|
|
|
case LINUX_SO_PRIORITY:
|
|
|
|
case LINUX_SO_NO_CHECK:
|
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-05-28 12:50:17 +04:00
|
|
|
/*
|
|
|
|
* Convert Linux IP level socket option number to NetBSD values.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
linux_to_bsd_ip_sockopt(lopt)
|
|
|
|
int lopt;
|
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
|
1995-05-28 12:50:17 +04:00
|
|
|
switch (lopt) {
|
|
|
|
case LINUX_IP_TOS:
|
|
|
|
return IP_TOS;
|
|
|
|
case LINUX_IP_TTL:
|
|
|
|
return IP_TTL;
|
|
|
|
case LINUX_IP_MULTICAST_TTL:
|
|
|
|
return IP_MULTICAST_TTL;
|
|
|
|
case LINUX_IP_MULTICAST_LOOP:
|
|
|
|
return IP_MULTICAST_LOOP;
|
|
|
|
case LINUX_IP_MULTICAST_IF:
|
|
|
|
return IP_MULTICAST_IF;
|
|
|
|
case LINUX_IP_ADD_MEMBERSHIP:
|
|
|
|
return IP_ADD_MEMBERSHIP;
|
|
|
|
case LINUX_IP_DROP_MEMBERSHIP:
|
|
|
|
return IP_DROP_MEMBERSHIP;
|
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert Linux TCP level socket option number to NetBSD values.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
linux_to_bsd_tcp_sockopt(lopt)
|
|
|
|
int lopt;
|
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
|
1995-05-28 12:50:17 +04:00
|
|
|
switch (lopt) {
|
1995-05-28 14:16:32 +04:00
|
|
|
case LINUX_TCP_NODELAY:
|
|
|
|
return TCP_NODELAY;
|
|
|
|
case LINUX_TCP_MAXSEG:
|
|
|
|
return TCP_MAXSEG;
|
1995-05-28 12:50:17 +04:00
|
|
|
default:
|
1995-05-28 14:16:32 +04:00
|
|
|
return -1;
|
1995-05-28 12:50:17 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert Linux UDP level socket option number to NetBSD values.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
linux_to_bsd_udp_sockopt(lopt)
|
|
|
|
int lopt;
|
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
|
1995-05-28 12:50:17 +04:00
|
|
|
switch (lopt) {
|
|
|
|
default:
|
1995-05-28 14:16:32 +04:00
|
|
|
return -1;
|
1995-05-28 12:50:17 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-03-01 02:24:35 +03:00
|
|
|
/*
|
1995-05-28 13:39:45 +04:00
|
|
|
* Another reasonably straightforward function: setsockopt(2).
|
1995-03-01 02:24:35 +03:00
|
|
|
* The level and option numbers are converted; the values passed
|
|
|
|
* are not (yet) converted, the ones currently implemented don't
|
|
|
|
* need conversion, as they are the same on both systems.
|
|
|
|
*/
|
1995-05-28 12:09:51 +04:00
|
|
|
int
|
1998-10-01 07:33:17 +04:00
|
|
|
linux_sys_setsockopt(p, v, retval)
|
1995-03-01 02:24:35 +03:00
|
|
|
struct proc *p;
|
1998-10-01 07:33:17 +04:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct linux_sys_setsockopt_args /* {
|
1995-03-01 02:24:35 +03:00
|
|
|
syscallarg(int) s;
|
|
|
|
syscallarg(int) level;
|
|
|
|
syscallarg(int) optname;
|
|
|
|
syscallarg(void *) optval;
|
|
|
|
syscallarg(int) optlen;
|
1998-10-01 07:33:17 +04:00
|
|
|
} */ *uap = v;
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sys_setsockopt_args bsa;
|
1998-10-01 07:33:17 +04:00
|
|
|
int name;
|
1995-03-01 02:24:35 +03:00
|
|
|
|
1998-10-01 07:33:17 +04:00
|
|
|
SCARG(&bsa, s) = SCARG(uap, s);
|
|
|
|
SCARG(&bsa, level) = linux_to_bsd_sopt_level(SCARG(uap, level));
|
|
|
|
SCARG(&bsa, val) = SCARG(uap, optval);
|
|
|
|
SCARG(&bsa, valsize) = SCARG(uap, optlen);
|
1995-03-01 02:24:35 +03:00
|
|
|
|
|
|
|
switch (SCARG(&bsa, level)) {
|
|
|
|
case SOL_SOCKET:
|
1998-10-01 07:33:17 +04:00
|
|
|
name = linux_to_bsd_so_sockopt(SCARG(uap, optname));
|
1995-03-01 02:24:35 +03:00
|
|
|
break;
|
|
|
|
case IPPROTO_IP:
|
1998-10-01 07:33:17 +04:00
|
|
|
name = linux_to_bsd_ip_sockopt(SCARG(uap, optname));
|
1995-03-01 02:24:35 +03:00
|
|
|
break;
|
1995-05-28 12:50:17 +04:00
|
|
|
case IPPROTO_TCP:
|
1998-10-01 07:33:17 +04:00
|
|
|
name = linux_to_bsd_tcp_sockopt(SCARG(uap, optname));
|
1995-05-28 12:50:17 +04:00
|
|
|
break;
|
|
|
|
case IPPROTO_UDP:
|
1998-10-01 07:33:17 +04:00
|
|
|
name = linux_to_bsd_udp_sockopt(SCARG(uap, optname));
|
1995-05-28 12:50:17 +04:00
|
|
|
break;
|
1995-03-01 02:24:35 +03:00
|
|
|
default:
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (name == -1)
|
|
|
|
return EINVAL;
|
|
|
|
SCARG(&bsa, name) = name;
|
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_setsockopt(p, &bsa, retval);
|
1995-03-01 02:24:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* getsockopt(2) is very much the same as setsockopt(2) (see above)
|
|
|
|
*/
|
1995-05-28 12:09:51 +04:00
|
|
|
int
|
1998-10-01 07:33:17 +04:00
|
|
|
linux_sys_getsockopt(p, v, retval)
|
1995-03-01 02:24:35 +03:00
|
|
|
struct proc *p;
|
1998-10-01 07:33:17 +04:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct linux_sys_getsockopt_args /* {
|
1995-03-01 02:24:35 +03:00
|
|
|
syscallarg(int) s;
|
|
|
|
syscallarg(int) level;
|
|
|
|
syscallarg(int) optname;
|
|
|
|
syscallarg(void *) optval;
|
1998-10-01 07:33:17 +04:00
|
|
|
syscallarg(int *) optlen;
|
|
|
|
} */ *uap = v;
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sys_getsockopt_args bga;
|
1998-10-01 07:33:17 +04:00
|
|
|
int name;
|
1995-03-01 02:24:35 +03:00
|
|
|
|
1998-10-01 07:33:17 +04:00
|
|
|
SCARG(&bga, s) = SCARG(uap, s);
|
|
|
|
SCARG(&bga, level) = linux_to_bsd_sopt_level(SCARG(uap, level));
|
|
|
|
SCARG(&bga, val) = SCARG(uap, optval);
|
|
|
|
SCARG(&bga, avalsize) = SCARG(uap, optlen);
|
1995-03-01 02:24:35 +03:00
|
|
|
|
|
|
|
switch (SCARG(&bga, level)) {
|
|
|
|
case SOL_SOCKET:
|
1998-10-01 07:33:17 +04:00
|
|
|
name = linux_to_bsd_so_sockopt(SCARG(uap, optname));
|
1995-03-01 02:24:35 +03:00
|
|
|
break;
|
|
|
|
case IPPROTO_IP:
|
1998-10-01 07:33:17 +04:00
|
|
|
name = linux_to_bsd_ip_sockopt(SCARG(uap, optname));
|
1995-03-01 02:24:35 +03:00
|
|
|
break;
|
1995-05-28 12:50:17 +04:00
|
|
|
case IPPROTO_TCP:
|
1998-10-01 07:33:17 +04:00
|
|
|
name = linux_to_bsd_tcp_sockopt(SCARG(uap, optname));
|
1995-05-28 12:50:17 +04:00
|
|
|
break;
|
|
|
|
case IPPROTO_UDP:
|
1998-10-01 07:33:17 +04:00
|
|
|
name = linux_to_bsd_udp_sockopt(SCARG(uap, optname));
|
1995-05-28 12:50:17 +04:00
|
|
|
break;
|
1995-03-01 02:24:35 +03:00
|
|
|
default:
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (name == -1)
|
|
|
|
return EINVAL;
|
1995-05-28 13:39:45 +04:00
|
|
|
SCARG(&bga, name) = name;
|
1995-03-01 02:24:35 +03:00
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_getsockopt(p, &bga, retval);
|
1995-03-01 02:24:35 +03:00
|
|
|
}
|
1996-03-08 07:55:59 +03:00
|
|
|
|
|
|
|
int
|
|
|
|
linux_ioctl_socket(p, uap, retval)
|
|
|
|
register struct proc *p;
|
|
|
|
register struct linux_sys_ioctl_args /* {
|
|
|
|
syscallarg(int) fd;
|
|
|
|
syscallarg(u_long) com;
|
|
|
|
syscallarg(caddr_t) data;
|
|
|
|
} */ *uap;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
u_long com;
|
|
|
|
struct sys_ioctl_args ia;
|
|
|
|
|
|
|
|
com = SCARG(uap, com);
|
|
|
|
retval[0] = 0;
|
|
|
|
|
|
|
|
switch (com) {
|
|
|
|
case LINUX_SIOCGIFCONF:
|
|
|
|
SCARG(&ia, com) = OSIOCGIFCONF;
|
|
|
|
break;
|
|
|
|
case LINUX_SIOCGIFFLAGS:
|
|
|
|
SCARG(&ia, com) = SIOCGIFFLAGS;
|
|
|
|
break;
|
|
|
|
case LINUX_SIOCGIFADDR:
|
|
|
|
SCARG(&ia, com) = OSIOCGIFADDR;
|
|
|
|
break;
|
|
|
|
case LINUX_SIOCGIFDSTADDR:
|
|
|
|
SCARG(&ia, com) = OSIOCGIFDSTADDR;
|
|
|
|
break;
|
|
|
|
case LINUX_SIOCGIFBRDADDR:
|
|
|
|
SCARG(&ia, com) = OSIOCGIFBRDADDR;
|
|
|
|
break;
|
|
|
|
case LINUX_SIOCGIFNETMASK:
|
|
|
|
SCARG(&ia, com) = OSIOCGIFNETMASK;
|
|
|
|
break;
|
|
|
|
case LINUX_SIOCADDMULTI:
|
|
|
|
SCARG(&ia, com) = SIOCADDMULTI;
|
|
|
|
break;
|
|
|
|
case LINUX_SIOCDELMULTI:
|
|
|
|
SCARG(&ia, com) = SIOCDELMULTI;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
SCARG(&ia, fd) = SCARG(uap, fd);
|
|
|
|
SCARG(&ia, data) = SCARG(uap, data);
|
|
|
|
return sys_ioctl(p, &ia, retval);
|
|
|
|
}
|