factor out some of the osockaddr, omsghdr code.
This commit is contained in:
parent
33359b3121
commit
ca3a193432
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: uipc_syscalls_43.c,v 1.23 2005/02/26 23:10:18 perry Exp $ */
|
||||
/* $NetBSD: uipc_syscalls_43.c,v 1.24 2005/09/24 15:51:03 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1990, 1993
|
||||
|
@ -32,7 +32,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls_43.c,v 1.23 2005/02/26 23:10:18 perry Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls_43.c,v 1.24 2005/09/24 15:51:03 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -50,12 +50,17 @@ __KERNEL_RCSID(0, "$NetBSD: uipc_syscalls_43.c,v 1.23 2005/02/26 23:10:18 perry
|
|||
#include <sys/unistd.h>
|
||||
#include <sys/resourcevar.h>
|
||||
#include <sys/mbuf.h> /* for MLEN */
|
||||
#include <sys/protosw.h>
|
||||
|
||||
#include <sys/mount.h>
|
||||
#include <sys/sa.h>
|
||||
#include <sys/syscallargs.h>
|
||||
|
||||
#include <compat/sys/socket.h>
|
||||
#include <net/if.h>
|
||||
|
||||
#include <compat/common/compat_util.h>
|
||||
#include <compat/sys/socket.h>
|
||||
|
||||
#include <uvm/uvm_extern.h>
|
||||
|
||||
|
@ -446,3 +451,59 @@ compat_43_sa_put(from)
|
|||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
compat_ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p)
|
||||
{
|
||||
int error, ocmd = cmd;
|
||||
struct ifreq *ifr = (struct ifreq *)data;
|
||||
struct ifnet *ifp = ifunit(ifr->ifr_name);
|
||||
|
||||
if (ifp == NULL)
|
||||
return ENXIO;
|
||||
|
||||
switch (cmd) {
|
||||
case SIOCSIFADDR:
|
||||
case SIOCSIFDSTADDR:
|
||||
case SIOCSIFBRDADDR:
|
||||
case SIOCSIFNETMASK:
|
||||
#if BYTE_ORDER != BIG_ENDIAN
|
||||
if (ifr->ifr_addr.sa_family == 0 &&
|
||||
ifr->ifr_addr.sa_len < 16) {
|
||||
ifr->ifr_addr.sa_family = ifr->ifr_addr.sa_len;
|
||||
ifr->ifr_addr.sa_len = 16;
|
||||
}
|
||||
#else
|
||||
if (ifr->ifr_addr.sa_len == 0)
|
||||
ifr->ifr_addr.sa_len = 16;
|
||||
#endif
|
||||
break;
|
||||
|
||||
case OSIOCGIFADDR:
|
||||
cmd = SIOCGIFADDR;
|
||||
break;
|
||||
|
||||
case OSIOCGIFDSTADDR:
|
||||
cmd = SIOCGIFDSTADDR;
|
||||
break;
|
||||
|
||||
case OSIOCGIFBRDADDR:
|
||||
cmd = SIOCGIFBRDADDR;
|
||||
break;
|
||||
|
||||
case OSIOCGIFNETMASK:
|
||||
cmd = SIOCGIFNETMASK;
|
||||
}
|
||||
|
||||
error = (*so->so_proto->pr_usrreq)(so, PRU_CONTROL,
|
||||
(struct mbuf *)cmd, (struct mbuf *)data, (struct mbuf *)ifp, p);
|
||||
|
||||
switch (ocmd) {
|
||||
case OSIOCGIFADDR:
|
||||
case OSIOCGIFDSTADDR:
|
||||
case OSIOCGIFBRDADDR:
|
||||
case OSIOCGIFNETMASK:
|
||||
*(u_int16_t *)&ifr->ifr_addr = ifr->ifr_addr.sa_family;
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: linux_socket.c,v 1.56 2005/05/03 16:26:29 manu Exp $ */
|
||||
/* $NetBSD: linux_socket.c,v 1.57 2005/09/24 15:51:03 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
|
||||
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.56 2005/05/03 16:26:29 manu Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.57 2005/09/24 15:51:03 christos Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_inet.h"
|
||||
|
@ -83,6 +83,8 @@ __KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.56 2005/05/03 16:26:29 manu Exp $
|
|||
#include <netinet6/ip6_var.h>
|
||||
#endif
|
||||
|
||||
#include <compat/sys/socket.h>
|
||||
|
||||
#include <compat/linux/common/linux_types.h>
|
||||
#include <compat/linux/common/linux_util.h>
|
||||
#include <compat/linux/common/linux_signal.h>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: svr4_ioctl.c,v 1.25 2004/06/01 10:38:39 pk Exp $ */
|
||||
/* $NetBSD: svr4_ioctl.c,v 1.26 2005/09/24 15:51:03 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1994 The NetBSD Foundation, Inc.
|
||||
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: svr4_ioctl.c,v 1.25 2004/06/01 10:38:39 pk Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: svr4_ioctl.c,v 1.26 2005/09/24 15:51:03 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/proc.h>
|
||||
|
@ -56,6 +56,8 @@ __KERNEL_RCSID(0, "$NetBSD: svr4_ioctl.c,v 1.25 2004/06/01 10:38:39 pk Exp $");
|
|||
#include <sys/sa.h>
|
||||
#include <sys/syscallargs.h>
|
||||
|
||||
#include <compat/sys/socket.h>
|
||||
|
||||
#include <compat/svr4/svr4_types.h>
|
||||
#include <compat/svr4/svr4_util.h>
|
||||
#include <compat/svr4/svr4_signal.h>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: svr4_sockio.c,v 1.19 2005/02/26 23:10:21 perry Exp $ */
|
||||
/* $NetBSD: svr4_sockio.c,v 1.20 2005/09/24 15:51:03 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1995 The NetBSD Foundation, Inc.
|
||||
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: svr4_sockio.c,v 1.19 2005/02/26 23:10:21 perry Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: svr4_sockio.c,v 1.20 2005/09/24 15:51:03 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/proc.h>
|
||||
|
@ -56,6 +56,8 @@ __KERNEL_RCSID(0, "$NetBSD: svr4_sockio.c,v 1.19 2005/02/26 23:10:21 perry Exp $
|
|||
#include <sys/sa.h>
|
||||
#include <sys/syscallargs.h>
|
||||
|
||||
#include <compat/sys/socket.h>
|
||||
|
||||
#include <compat/svr4/svr4_types.h>
|
||||
#include <compat/svr4/svr4_util.h>
|
||||
#include <compat/svr4/svr4_signal.h>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: svr4_32_ioctl.c,v 1.9 2005/02/26 23:10:21 perry Exp $ */
|
||||
/* $NetBSD: svr4_32_ioctl.c,v 1.10 2005/09/24 15:51:03 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1994 The NetBSD Foundation, Inc.
|
||||
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: svr4_32_ioctl.c,v 1.9 2005/02/26 23:10:21 perry Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: svr4_32_ioctl.c,v 1.10 2005/09/24 15:51:03 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/proc.h>
|
||||
|
@ -56,6 +56,8 @@ __KERNEL_RCSID(0, "$NetBSD: svr4_32_ioctl.c,v 1.9 2005/02/26 23:10:21 perry Exp
|
|||
#include <sys/sa.h>
|
||||
#include <sys/syscallargs.h>
|
||||
|
||||
#include <compat/sys/socket.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>
|
||||
|
@ -69,6 +71,7 @@ __KERNEL_RCSID(0, "$NetBSD: svr4_32_ioctl.c,v 1.9 2005/02/26 23:10:21 perry Exp
|
|||
#include <compat/svr4/svr4_filio.h>
|
||||
#include <compat/svr4_32/svr4_32_sockio.h>
|
||||
|
||||
|
||||
#ifdef DEBUG_SVR4
|
||||
static void svr4_32_decode_cmd __P((netbsd32_u_long, char *, char *, int *, int *));
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: svr4_32_sockio.c,v 1.9 2005/02/26 23:10:21 perry Exp $ */
|
||||
/* $NetBSD: svr4_32_sockio.c,v 1.10 2005/09/24 15:51:03 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1995 The NetBSD Foundation, Inc.
|
||||
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: svr4_32_sockio.c,v 1.9 2005/02/26 23:10:21 perry Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: svr4_32_sockio.c,v 1.10 2005/09/24 15:51:03 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/proc.h>
|
||||
|
@ -56,6 +56,8 @@ __KERNEL_RCSID(0, "$NetBSD: svr4_32_sockio.c,v 1.9 2005/02/26 23:10:21 perry Exp
|
|||
#include <sys/sa.h>
|
||||
#include <sys/syscallargs.h>
|
||||
|
||||
#include <compat/sys/socket.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>
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
/* $NetBSD: socket.h,v 1.1 2005/09/24 15:51:03 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994
|
||||
* The Regents of the University of California. 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. 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. Neither the name of the University 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 REGENTS 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 REGENTS 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.
|
||||
*
|
||||
* @(#)socket.h 8.6 (Berkeley) 5/3/95
|
||||
*/
|
||||
|
||||
#ifndef _COMPAT_SYS_SOCKET_H_
|
||||
#define _COMPAT_SYS_SOCKET_H_
|
||||
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
/*
|
||||
* 4.3 compat sockaddr
|
||||
*/
|
||||
struct osockaddr {
|
||||
uint16_t sa_family; /* address family */
|
||||
char sa_data[14]; /* up to 14 bytes of direct address */
|
||||
};
|
||||
|
||||
/*
|
||||
* 4.3-compat message header
|
||||
*/
|
||||
struct omsghdr {
|
||||
caddr_t msg_name; /* optional address */
|
||||
int msg_namelen; /* size of address */
|
||||
struct iovec *msg_iov; /* scatter/gather array */
|
||||
int msg_iovlen; /* # elements in msg_iov */
|
||||
caddr_t msg_accrights; /* access rights sent/received */
|
||||
int msg_accrightslen;
|
||||
};
|
||||
|
||||
#ifdef _KERNEL
|
||||
__BEGIN_DECLS
|
||||
int compat_ifioctl(struct socket *, u_long, caddr_t, struct proc *);
|
||||
__END_DECLS
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* !_COMPAT_SYS_SOCKET_H_ */
|
Loading…
Reference in New Issue