Home | History | Annotate | Line # | Download | only in common
uipc_syscalls_43.c revision 1.47.14.7
      1  1.47.14.7  pgoyette /*	$NetBSD: uipc_syscalls_43.c,v 1.47.14.7 2018/09/30 01:45:49 pgoyette Exp $	*/
      2        1.1  christos 
      3        1.1  christos /*
      4        1.1  christos  * Copyright (c) 1982, 1986, 1989, 1990, 1993
      5        1.1  christos  *	The Regents of the University of California.  All rights reserved.
      6        1.1  christos  *
      7        1.1  christos  * Redistribution and use in source and binary forms, with or without
      8        1.1  christos  * modification, are permitted provided that the following conditions
      9        1.1  christos  * are met:
     10        1.1  christos  * 1. Redistributions of source code must retain the above copyright
     11        1.1  christos  *    notice, this list of conditions and the following disclaimer.
     12        1.1  christos  * 2. Redistributions in binary form must reproduce the above copyright
     13        1.1  christos  *    notice, this list of conditions and the following disclaimer in the
     14        1.1  christos  *    documentation and/or other materials provided with the distribution.
     15       1.22       agc  * 3. Neither the name of the University nor the names of its contributors
     16        1.1  christos  *    may be used to endorse or promote products derived from this software
     17        1.1  christos  *    without specific prior written permission.
     18        1.1  christos  *
     19        1.1  christos  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     20        1.1  christos  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     21        1.1  christos  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     22        1.1  christos  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     23        1.1  christos  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     24        1.1  christos  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     25        1.1  christos  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26        1.1  christos  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     27        1.1  christos  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     28        1.1  christos  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     29        1.1  christos  * SUCH DAMAGE.
     30        1.1  christos  *
     31        1.1  christos  *	@(#)uipc_syscalls.c	8.4 (Berkeley) 2/21/94
     32        1.1  christos  */
     33       1.17     lukem 
     34       1.17     lukem #include <sys/cdefs.h>
     35  1.47.14.7  pgoyette __KERNEL_RCSID(0, "$NetBSD: uipc_syscalls_43.c,v 1.47.14.7 2018/09/30 01:45:49 pgoyette Exp $");
     36  1.47.14.6  pgoyette 
     37  1.47.14.6  pgoyette #if defined(_KERNEL_OPT)
     38  1.47.14.6  pgoyette #include "opt_compat_netbsd.h"
     39  1.47.14.6  pgoyette #endif
     40        1.1  christos 
     41        1.1  christos #include <sys/param.h>
     42        1.1  christos #include <sys/systm.h>
     43        1.1  christos #include <sys/filedesc.h>
     44        1.1  christos #include <sys/kernel.h>
     45        1.1  christos #include <sys/proc.h>
     46        1.1  christos #include <sys/file.h>
     47        1.1  christos #include <sys/socket.h>
     48        1.1  christos #include <sys/socketvar.h>
     49        1.1  christos #include <sys/stat.h>
     50        1.1  christos #include <sys/ioctl.h>
     51        1.1  christos #include <sys/fcntl.h>
     52        1.1  christos #include <sys/syslog.h>
     53        1.1  christos #include <sys/unistd.h>
     54        1.1  christos #include <sys/resourcevar.h>
     55       1.15  jdolecek #include <sys/mbuf.h>		/* for MLEN */
     56       1.24  christos #include <sys/protosw.h>
     57        1.1  christos 
     58        1.1  christos #include <sys/mount.h>
     59  1.47.14.2  pgoyette #include <sys/syscall.h>
     60  1.47.14.2  pgoyette #include <sys/syscallvar.h>
     61        1.1  christos #include <sys/syscallargs.h>
     62        1.1  christos 
     63       1.29  christos #include <net/if.h>
     64       1.35    martin #include <net/bpf.h>
     65       1.35    martin #include <net/route.h>
     66       1.35    martin #include <netinet/in.h>
     67       1.35    martin #include <netinet/in_systm.h>
     68       1.35    martin #include <netinet/ip.h>
     69       1.35    martin #include <net/if_gre.h>
     70       1.35    martin #include <net/if_tap.h>
     71       1.40    martin #include <net80211/ieee80211_ioctl.h>
     72       1.35    martin #include <netinet6/in6_var.h>
     73       1.35    martin #include <netinet6/nd6.h>
     74       1.24  christos #include <compat/sys/socket.h>
     75       1.29  christos #include <compat/sys/sockio.h>
     76       1.24  christos 
     77       1.15  jdolecek #include <compat/common/compat_util.h>
     78  1.47.14.2  pgoyette #include <compat/common/compat_mod.h>
     79       1.15  jdolecek 
     80       1.15  jdolecek #include <uvm/uvm_extern.h>
     81       1.15  jdolecek 
     82       1.15  jdolecek /*
     83       1.15  jdolecek  * Following 4.3 syscalls were not versioned, even through they should
     84       1.15  jdolecek  * have been:
     85       1.15  jdolecek  * connect(2), bind(2), sendto(2)
     86       1.15  jdolecek  */
     87       1.15  jdolecek 
     88  1.47.14.2  pgoyette static struct syscall_package uipc_syscalls_43_syscalls[] = {
     89  1.47.14.2  pgoyette 	{ SYS_compat_43_oaccept, 0, (sy_call_t *)compat_43_sys_accept },
     90  1.47.14.2  pgoyette 	{ SYS_compat_43_ogetpeername, 0,
     91  1.47.14.2  pgoyette 	    (sy_call_t *)compat_43_sys_getpeername },
     92  1.47.14.2  pgoyette 	{ SYS_compat_43_ogetsockname, 0,
     93  1.47.14.2  pgoyette 	    (sy_call_t *)compat_43_sys_getsockname },
     94  1.47.14.2  pgoyette 	{ SYS_compat_43_orecv, 0, (sy_call_t *)compat_43_sys_recv },
     95  1.47.14.2  pgoyette 	{ SYS_compat_43_orecvfrom, 0, (sy_call_t *)compat_43_sys_recvfrom },
     96  1.47.14.2  pgoyette 	{ SYS_compat_43_orecvmsg, 0, (sy_call_t *)compat_43_sys_recvmsg },
     97  1.47.14.2  pgoyette 	{ SYS_compat_43_osend, 0, (sy_call_t *)compat_43_sys_send },
     98  1.47.14.2  pgoyette 	{ SYS_compat_43_osendmsg, 0, (sy_call_t *)compat_43_sys_sendmsg },
     99  1.47.14.2  pgoyette 	{ 0, 0, NULL }
    100  1.47.14.2  pgoyette };
    101  1.47.14.2  pgoyette 
    102       1.28  christos static int compat_43_sa_put(void *);
    103       1.15  jdolecek 
    104        1.1  christos int
    105       1.39       dsl compat_43_sys_accept(struct lwp *l, const struct compat_43_sys_accept_args *uap, register_t *retval)
    106        1.2   thorpej {
    107       1.39       dsl 	/* {
    108        1.1  christos 		syscallarg(int) s;
    109       1.28  christos 		syscallarg(void *) name;
    110        1.1  christos 		syscallarg(int *) anamelen;
    111       1.39       dsl 	} */
    112        1.1  christos 	int error;
    113        1.1  christos 
    114       1.45      matt 	if ((error = sys_accept(l, (const struct sys_accept_args *)uap, retval)) != 0)
    115        1.1  christos 		return error;
    116        1.1  christos 
    117       1.15  jdolecek 	if (SCARG(uap, name)
    118       1.15  jdolecek 	    && (error = compat_43_sa_put(SCARG(uap, name))))
    119       1.15  jdolecek 		return (error);
    120        1.1  christos 
    121        1.1  christos 	return 0;
    122        1.1  christos }
    123        1.1  christos 
    124        1.1  christos int
    125       1.39       dsl compat_43_sys_getpeername(struct lwp *l, const struct compat_43_sys_getpeername_args *uap, register_t *retval)
    126        1.2   thorpej {
    127       1.39       dsl 	/* {
    128        1.1  christos 		syscallarg(int) fdes;
    129       1.28  christos 		syscallarg(void *) asa;
    130        1.1  christos 		syscallarg(int *) alen;
    131       1.39       dsl 	} */
    132        1.1  christos 
    133        1.1  christos 	int error;
    134        1.1  christos 
    135       1.45      matt 	if ((error = sys_getpeername(l, (const struct sys_getpeername_args *)uap, retval)) != 0)
    136        1.1  christos 		return error;
    137        1.1  christos 
    138       1.15  jdolecek 	if ((error = compat_43_sa_put(SCARG(uap, asa))))
    139       1.15  jdolecek 		return (error);
    140        1.1  christos 
    141        1.1  christos 	return 0;
    142        1.1  christos }
    143        1.1  christos 
    144        1.1  christos int
    145       1.39       dsl compat_43_sys_getsockname(struct lwp *l, const struct compat_43_sys_getsockname_args *uap, register_t *retval)
    146        1.2   thorpej {
    147       1.39       dsl 	/* {
    148        1.1  christos 		syscallarg(int) fdes;
    149       1.28  christos 		syscallarg(void *) asa;
    150        1.1  christos 		syscallarg(int *) alen;
    151       1.39       dsl 	} */
    152        1.1  christos 	int error;
    153        1.1  christos 
    154       1.45      matt 	if ((error = sys_getsockname(l, (const struct sys_getsockname_args *)uap, retval)) != 0)
    155        1.1  christos 		return error;
    156        1.1  christos 
    157       1.15  jdolecek 	if ((error = compat_43_sa_put(SCARG(uap, asa))))
    158       1.15  jdolecek 		return (error);
    159        1.1  christos 
    160        1.1  christos 	return 0;
    161        1.1  christos }
    162        1.1  christos 
    163        1.1  christos int
    164       1.39       dsl compat_43_sys_recv(struct lwp *l, const struct compat_43_sys_recv_args *uap, register_t *retval)
    165        1.2   thorpej {
    166       1.39       dsl 	/* {
    167        1.1  christos 		syscallarg(int) s;
    168       1.28  christos 		syscallarg(void *) buf;
    169        1.1  christos 		syscallarg(int) len;
    170        1.1  christos 		syscallarg(int) flags;
    171       1.39       dsl 	} */
    172       1.14  jdolecek 	struct sys_recvfrom_args bra;
    173       1.14  jdolecek 
    174       1.14  jdolecek 	SCARG(&bra, s) = SCARG(uap, s);
    175       1.14  jdolecek 	SCARG(&bra, buf) = SCARG(uap, buf);
    176       1.14  jdolecek 	SCARG(&bra, len) = (size_t) SCARG(uap, len);
    177       1.14  jdolecek 	SCARG(&bra, flags) = SCARG(uap, flags);
    178       1.14  jdolecek 	SCARG(&bra, from) = NULL;
    179       1.14  jdolecek 	SCARG(&bra, fromlenaddr) = NULL;
    180        1.1  christos 
    181       1.19   thorpej 	return (sys_recvfrom(l, &bra, retval));
    182        1.1  christos }
    183        1.1  christos 
    184        1.1  christos int
    185       1.39       dsl compat_43_sys_recvfrom(struct lwp *l, const struct compat_43_sys_recvfrom_args *uap, register_t *retval)
    186        1.2   thorpej {
    187       1.39       dsl 	/* {
    188        1.1  christos 		syscallarg(int) s;
    189       1.28  christos 		syscallarg(void *) buf;
    190        1.1  christos 		syscallarg(size_t) len;
    191        1.1  christos 		syscallarg(int) flags;
    192       1.28  christos 		syscallarg(void *) from;
    193        1.1  christos 		syscallarg(int *) fromlenaddr;
    194       1.39       dsl 	} */
    195       1.15  jdolecek 	int error;
    196       1.15  jdolecek 
    197       1.45      matt 	if ((error = sys_recvfrom(l, (const struct sys_recvfrom_args *)uap, retval)))
    198       1.15  jdolecek 		return (error);
    199       1.15  jdolecek 
    200       1.15  jdolecek 	if (SCARG(uap, from) && (error = compat_43_sa_put(SCARG(uap, from))))
    201       1.15  jdolecek 		return (error);
    202        1.1  christos 
    203       1.15  jdolecek 	return (0);
    204        1.1  christos }
    205        1.1  christos 
    206        1.1  christos /*
    207       1.15  jdolecek  * Old recvmsg. Arrange necessary structures, calls generic code and
    208       1.15  jdolecek  * adjusts results accordingly.
    209        1.1  christos  */
    210        1.1  christos int
    211       1.39       dsl compat_43_sys_recvmsg(struct lwp *l, const struct compat_43_sys_recvmsg_args *uap, register_t *retval)
    212        1.2   thorpej {
    213       1.39       dsl 	/* {
    214        1.1  christos 		syscallarg(int) s;
    215        1.1  christos 		syscallarg(struct omsghdr *) msg;
    216        1.1  christos 		syscallarg(int) flags;
    217       1.39       dsl 	} */
    218       1.15  jdolecek 	struct omsghdr omsg;
    219        1.1  christos 	struct msghdr msg;
    220       1.31       dsl 	struct mbuf *from, *control;
    221        1.1  christos 	int error;
    222        1.1  christos 
    223       1.31       dsl 	error = copyin(SCARG(uap, msg), &omsg, sizeof (struct omsghdr));
    224        1.5  christos 	if (error)
    225        1.1  christos 		return (error);
    226       1.23     perry 
    227       1.31       dsl 	if (omsg.msg_accrights == NULL)
    228       1.31       dsl 		omsg.msg_accrightslen = 0;
    229       1.31       dsl 	/* it was this way in 4.4BSD */
    230       1.31       dsl 	if (omsg.msg_accrightslen > MLEN)
    231       1.31       dsl 		return EINVAL;
    232       1.15  jdolecek 
    233       1.15  jdolecek 	msg.msg_name	= omsg.msg_name;
    234       1.15  jdolecek 	msg.msg_namelen = omsg.msg_namelen;
    235       1.15  jdolecek 	msg.msg_iovlen	= omsg.msg_iovlen;
    236       1.31       dsl 	msg.msg_iov	= omsg.msg_iov;
    237       1.31       dsl 	msg.msg_flags	= (SCARG(uap, flags) & MSG_USERFLAGS) | MSG_IOVUSRSPACE;
    238       1.15  jdolecek 
    239  1.47.14.5  pgoyette 	error = do_sys_recvmsg(l, SCARG(uap, s), &msg, &from,
    240       1.31       dsl 	    omsg.msg_accrights != NULL ? &control : NULL, retval);
    241       1.31       dsl 	if (error != 0)
    242       1.31       dsl 		return error;
    243        1.1  christos 
    244       1.15  jdolecek 	/*
    245       1.15  jdolecek 	 * If there is any control information and it's SCM_RIGHTS,
    246       1.15  jdolecek 	 * pass it back to the program.
    247       1.31       dsl 	 * XXX: maybe there can be more than one chunk of control data?
    248       1.15  jdolecek 	 */
    249       1.31       dsl 	if (omsg.msg_accrights && control != NULL) {
    250       1.45      matt 		struct cmsghdr *cmsg = mtod(control, struct cmsghdr *);
    251       1.15  jdolecek 
    252       1.31       dsl 		if (cmsg->cmsg_level == SOL_SOCKET
    253       1.31       dsl 		    && cmsg->cmsg_type == SCM_RIGHTS
    254       1.31       dsl 		    && cmsg->cmsg_len < omsg.msg_accrightslen
    255       1.31       dsl 		    && copyout(CMSG_DATA(cmsg), omsg.msg_accrights,
    256       1.31       dsl 			    cmsg->cmsg_len) == 0) {
    257       1.31       dsl 			omsg.msg_accrightslen = cmsg->cmsg_len;
    258       1.31       dsl 			free_control_mbuf(l, control, control->m_next);
    259       1.31       dsl 		} else {
    260       1.15  jdolecek 			omsg.msg_accrightslen = 0;
    261       1.31       dsl 			free_control_mbuf(l, control, control);
    262       1.15  jdolecek 		}
    263       1.31       dsl 	} else
    264       1.31       dsl 		omsg.msg_accrightslen = 0;
    265       1.23     perry 
    266       1.31       dsl 	if (from != NULL)
    267       1.31       dsl 		/* convert from sockaddr sa_family to osockaddr one here */
    268       1.31       dsl 		mtod(from, struct osockaddr *)->sa_family =
    269       1.31       dsl 				    mtod(from, struct sockaddr *)->sa_family;
    270       1.31       dsl 
    271       1.45      matt 	error = copyout_sockname((struct sockaddr *)omsg.msg_name, &omsg.msg_namelen, 0, from);
    272       1.31       dsl 	if (from != NULL)
    273       1.31       dsl 		m_free(from);
    274       1.15  jdolecek 
    275       1.31       dsl 	if (error != 0)
    276       1.31       dsl 		 error = copyout(&omsg, SCARG(uap, msg), sizeof(omsg));
    277       1.15  jdolecek 
    278       1.31       dsl 	return error;
    279        1.1  christos }
    280        1.1  christos 
    281        1.1  christos int
    282       1.39       dsl compat_43_sys_send(struct lwp *l, const struct compat_43_sys_send_args *uap, register_t *retval)
    283        1.2   thorpej {
    284       1.39       dsl 	/* {
    285        1.1  christos 		syscallarg(int) s;
    286       1.28  christos 		syscallarg(void *) buf;
    287        1.1  christos 		syscallarg(int) len;
    288        1.1  christos 		syscallarg(int) flags;
    289       1.39       dsl 	} */
    290       1.14  jdolecek 	struct sys_sendto_args bsa;
    291       1.14  jdolecek 
    292       1.14  jdolecek 	SCARG(&bsa, s)		= SCARG(uap, s);
    293       1.14  jdolecek 	SCARG(&bsa, buf)	= SCARG(uap, buf);
    294       1.14  jdolecek 	SCARG(&bsa, len)	= SCARG(uap, len);
    295       1.14  jdolecek 	SCARG(&bsa, flags)	= SCARG(uap, flags);
    296       1.14  jdolecek 	SCARG(&bsa, to)		= NULL;
    297       1.14  jdolecek 	SCARG(&bsa, tolen)	= 0;
    298        1.1  christos 
    299       1.19   thorpej 	return (sys_sendto(l, &bsa, retval));
    300        1.1  christos }
    301        1.1  christos 
    302       1.32       dsl int
    303       1.32       dsl compat43_set_accrights(struct msghdr *msg, void *accrights, int accrightslen)
    304       1.32       dsl {
    305       1.32       dsl 	struct cmsghdr *cmsg;
    306       1.32       dsl 	int error;
    307       1.32       dsl 	struct mbuf *ctl;
    308       1.32       dsl 	u_int clen;
    309       1.32       dsl 
    310       1.32       dsl 	if (accrights == NULL || accrightslen == 0) {
    311       1.32       dsl 		msg->msg_control = NULL;
    312       1.32       dsl 		msg->msg_controllen = 0;
    313       1.32       dsl 		return 0;
    314       1.32       dsl 	}
    315       1.32       dsl 
    316       1.32       dsl 	clen = CMSG_SPACE(accrightslen);
    317       1.32       dsl 	/* it was (almost) this way in 4.4BSD */
    318       1.32       dsl 	if (accrightslen < 0 || clen > MLEN)
    319       1.32       dsl 		return EINVAL;
    320       1.32       dsl 
    321       1.32       dsl 	ctl = m_get(M_WAIT, MT_CONTROL);
    322       1.32       dsl 	ctl->m_len = clen;
    323       1.45      matt 	cmsg = mtod(ctl, struct cmsghdr *);
    324       1.32       dsl 	cmsg->cmsg_len		= CMSG_SPACE(accrightslen);
    325       1.32       dsl 	cmsg->cmsg_level	= SOL_SOCKET;
    326       1.32       dsl 	cmsg->cmsg_type 	= SCM_RIGHTS;
    327       1.32       dsl 
    328       1.32       dsl 	error = copyin(accrights, CMSG_DATA(cmsg), accrightslen);
    329       1.32       dsl 	if (error) {
    330       1.32       dsl 		m_free(ctl);
    331       1.32       dsl 		return error;
    332       1.32       dsl 	}
    333       1.32       dsl 
    334       1.32       dsl 	msg->msg_control = ctl;
    335       1.32       dsl 	msg->msg_controllen = clen;
    336       1.32       dsl 	msg->msg_flags |= MSG_CONTROLMBUF;
    337       1.32       dsl 	return 0;
    338       1.32       dsl }
    339       1.32       dsl 
    340       1.15  jdolecek /*
    341       1.15  jdolecek  * Old sendmsg. Arrange necessary structures, call generic code and
    342       1.15  jdolecek  * adjust the results accordingly for old code.
    343       1.15  jdolecek  */
    344        1.1  christos int
    345       1.39       dsl compat_43_sys_sendmsg(struct lwp *l, const struct compat_43_sys_sendmsg_args *uap, register_t *retval)
    346        1.2   thorpej {
    347       1.39       dsl 	/* {
    348        1.1  christos 		syscallarg(int) s;
    349       1.28  christos 		syscallarg(void *) msg;
    350        1.1  christos 		syscallarg(int) flags;
    351       1.39       dsl 	} */
    352       1.15  jdolecek 	struct omsghdr omsg;
    353        1.1  christos 	struct msghdr msg;
    354        1.1  christos 	int error;
    355       1.30       dsl 	struct mbuf *nam;
    356       1.30       dsl 	struct osockaddr *osa;
    357       1.30       dsl 	struct sockaddr *sa;
    358        1.1  christos 
    359       1.30       dsl 	error = copyin(SCARG(uap, msg), &omsg, sizeof (struct omsghdr));
    360       1.30       dsl 	if (error != 0)
    361        1.1  christos 		return (error);
    362       1.15  jdolecek 
    363       1.30       dsl 	msg.msg_iovlen = omsg.msg_iovlen;
    364       1.30       dsl 	msg.msg_iov = omsg.msg_iov;
    365       1.15  jdolecek 
    366  1.47.14.1  pgoyette 	error = sockargs(&nam, omsg.msg_name, omsg.msg_namelen,
    367  1.47.14.1  pgoyette 	    UIO_USERSPACE, MT_SONAME);
    368       1.30       dsl 	if (error != 0)
    369       1.30       dsl 		return (error);
    370       1.15  jdolecek 
    371       1.45      matt 	sa = mtod(nam, struct sockaddr *);
    372       1.45      matt 	osa = mtod(nam, struct osockaddr *);
    373       1.30       dsl 	sa->sa_family = osa->sa_family;
    374       1.30       dsl 	sa->sa_len = omsg.msg_namelen;
    375       1.15  jdolecek 
    376       1.30       dsl 	msg.msg_flags = MSG_IOVUSRSPACE | MSG_NAMEMBUF;
    377       1.15  jdolecek 
    378       1.30       dsl 	msg.msg_name = nam;
    379       1.30       dsl 	msg.msg_namelen = omsg.msg_namelen;
    380       1.32       dsl 	error = compat43_set_accrights(&msg, omsg.msg_accrights,
    381       1.32       dsl 	    omsg.msg_accrightslen);
    382       1.32       dsl 	if (error != 0)
    383       1.32       dsl 		goto bad;
    384       1.15  jdolecek 
    385       1.47    martin 	return do_sys_sendmsg(l, SCARG(uap, s), &msg, SCARG(uap, flags),
    386  1.47.14.5  pgoyette 	    retval);
    387       1.30       dsl 
    388       1.30       dsl     bad:
    389       1.30       dsl 	if (nam != NULL)
    390       1.30       dsl 		m_free(nam);
    391       1.30       dsl 
    392        1.1  christos 	return (error);
    393       1.15  jdolecek }
    394       1.15  jdolecek 
    395       1.15  jdolecek static int
    396       1.38       dsl compat_43_sa_put(void *from)
    397       1.15  jdolecek {
    398       1.15  jdolecek 	struct osockaddr *osa = (struct osockaddr *) from;
    399       1.15  jdolecek 	struct sockaddr sa;
    400       1.15  jdolecek 	struct osockaddr *kosa;
    401       1.15  jdolecek 	int error, len;
    402       1.15  jdolecek 
    403       1.15  jdolecek 	/*
    404       1.15  jdolecek 	 * Only read/write the sockaddr family and length, the rest is
    405       1.15  jdolecek 	 * not changed.
    406       1.15  jdolecek 	 */
    407       1.15  jdolecek 	len = sizeof(sa.sa_len) + sizeof(sa.sa_family);
    408       1.15  jdolecek 
    409       1.28  christos 	error = copyin((void *) osa, (void *) &sa, len);
    410       1.15  jdolecek 	if (error)
    411       1.15  jdolecek 		return (error);
    412       1.15  jdolecek 
    413       1.15  jdolecek 	/* Note: we convert from sockaddr sa_family to osockaddr one here */
    414       1.15  jdolecek 	kosa = (struct osockaddr *) &sa;
    415       1.15  jdolecek 	kosa->sa_family = sa.sa_family;
    416       1.15  jdolecek 	error = copyout(kosa, osa, len);
    417       1.15  jdolecek 	if (error)
    418       1.15  jdolecek 		return (error);
    419       1.15  jdolecek 
    420       1.15  jdolecek 	return (0);
    421        1.1  christos }
    422  1.47.14.2  pgoyette 
    423  1.47.14.2  pgoyette int
    424  1.47.14.2  pgoyette uipc_syscalls_43_init(void)
    425  1.47.14.2  pgoyette {
    426  1.47.14.2  pgoyette 
    427  1.47.14.2  pgoyette 	return syscall_establish(NULL, uipc_syscalls_43_syscalls);
    428  1.47.14.2  pgoyette }
    429  1.47.14.2  pgoyette 
    430  1.47.14.2  pgoyette int
    431  1.47.14.2  pgoyette uipc_syscalls_43_fini(void)
    432  1.47.14.2  pgoyette {
    433  1.47.14.2  pgoyette 
    434  1.47.14.2  pgoyette 	return syscall_disestablish(NULL, uipc_syscalls_43_syscalls);
    435  1.47.14.2  pgoyette }
    436