Home | History | Annotate | Line # | Download | only in common
uipc_syscalls_43.c revision 1.31
      1  1.31       dsl /*	$NetBSD: uipc_syscalls_43.c,v 1.31 2007/06/24 18:01:48 dsl 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.31       dsl __KERNEL_RCSID(0, "$NetBSD: uipc_syscalls_43.c,v 1.31 2007/06/24 18:01:48 dsl Exp $");
     36   1.1  christos 
     37   1.1  christos #include <sys/param.h>
     38   1.1  christos #include <sys/systm.h>
     39   1.1  christos #include <sys/filedesc.h>
     40   1.1  christos #include <sys/kernel.h>
     41   1.1  christos #include <sys/proc.h>
     42   1.1  christos #include <sys/file.h>
     43   1.1  christos #include <sys/socket.h>
     44   1.1  christos #include <sys/socketvar.h>
     45   1.1  christos #include <sys/stat.h>
     46   1.1  christos #include <sys/ioctl.h>
     47   1.1  christos #include <sys/fcntl.h>
     48   1.1  christos #include <sys/malloc.h>
     49   1.1  christos #include <sys/syslog.h>
     50   1.1  christos #include <sys/unistd.h>
     51   1.1  christos #include <sys/resourcevar.h>
     52  1.15  jdolecek #include <sys/mbuf.h>		/* for MLEN */
     53  1.24  christos #include <sys/protosw.h>
     54   1.1  christos 
     55   1.1  christos #include <sys/mount.h>
     56   1.1  christos #include <sys/syscallargs.h>
     57   1.1  christos 
     58  1.29  christos #include <net/if.h>
     59  1.24  christos #include <compat/sys/socket.h>
     60  1.29  christos #include <compat/sys/sockio.h>
     61  1.24  christos 
     62  1.15  jdolecek #include <compat/common/compat_util.h>
     63  1.15  jdolecek 
     64  1.15  jdolecek #include <uvm/uvm_extern.h>
     65  1.15  jdolecek 
     66  1.15  jdolecek /*
     67  1.15  jdolecek  * Following 4.3 syscalls were not versioned, even through they should
     68  1.15  jdolecek  * have been:
     69  1.15  jdolecek  * connect(2), bind(2), sendto(2)
     70  1.15  jdolecek  */
     71  1.15  jdolecek 
     72  1.28  christos static int compat_43_sa_put(void *);
     73  1.15  jdolecek 
     74   1.1  christos int
     75  1.19   thorpej compat_43_sys_accept(struct lwp *l, void *v, register_t *retval)
     76   1.2   thorpej {
     77  1.15  jdolecek 	struct compat_43_sys_accept_args /* {
     78   1.1  christos 		syscallarg(int) s;
     79  1.28  christos 		syscallarg(void *) name;
     80   1.1  christos 		syscallarg(int *) anamelen;
     81   1.2   thorpej 	} */ *uap = v;
     82   1.1  christos 	int error;
     83   1.1  christos 
     84  1.19   thorpej 	if ((error = sys_accept(l, v, retval)) != 0)
     85   1.1  christos 		return error;
     86   1.1  christos 
     87  1.15  jdolecek 	if (SCARG(uap, name)
     88  1.15  jdolecek 	    && (error = compat_43_sa_put(SCARG(uap, name))))
     89  1.15  jdolecek 		return (error);
     90   1.1  christos 
     91   1.1  christos 	return 0;
     92   1.1  christos }
     93   1.1  christos 
     94   1.1  christos int
     95  1.19   thorpej compat_43_sys_getpeername(struct lwp *l, void *v, register_t *retval)
     96   1.2   thorpej {
     97  1.15  jdolecek 	struct compat_43_sys_getpeername_args /* {
     98   1.1  christos 		syscallarg(int) fdes;
     99  1.28  christos 		syscallarg(void *) asa;
    100   1.1  christos 		syscallarg(int *) alen;
    101   1.2   thorpej 	} */ *uap = v;
    102   1.1  christos 
    103   1.1  christos 	int error;
    104   1.1  christos 
    105  1.19   thorpej 	if ((error = sys_getpeername(l, v, retval)) != 0)
    106   1.1  christos 		return error;
    107   1.1  christos 
    108  1.15  jdolecek 	if ((error = compat_43_sa_put(SCARG(uap, asa))))
    109  1.15  jdolecek 		return (error);
    110   1.1  christos 
    111   1.1  christos 	return 0;
    112   1.1  christos }
    113   1.1  christos 
    114   1.1  christos int
    115  1.19   thorpej compat_43_sys_getsockname(struct lwp *l, void *v, register_t *retval)
    116   1.2   thorpej {
    117  1.15  jdolecek 	struct compat_43_sys_getsockname_args /* {
    118   1.1  christos 		syscallarg(int) fdes;
    119  1.28  christos 		syscallarg(void *) asa;
    120   1.1  christos 		syscallarg(int *) alen;
    121   1.2   thorpej 	} */ *uap = v;
    122   1.1  christos 	int error;
    123   1.1  christos 
    124  1.19   thorpej 	if ((error = sys_getsockname(l, v, retval)) != 0)
    125   1.1  christos 		return error;
    126   1.1  christos 
    127  1.15  jdolecek 	if ((error = compat_43_sa_put(SCARG(uap, asa))))
    128  1.15  jdolecek 		return (error);
    129   1.1  christos 
    130   1.1  christos 	return 0;
    131   1.1  christos }
    132   1.1  christos 
    133   1.1  christos int
    134  1.19   thorpej compat_43_sys_recv(struct lwp *l, void *v, register_t *retval)
    135   1.2   thorpej {
    136  1.11  augustss 	struct compat_43_sys_recv_args /* {
    137   1.1  christos 		syscallarg(int) s;
    138  1.28  christos 		syscallarg(void *) buf;
    139   1.1  christos 		syscallarg(int) len;
    140   1.1  christos 		syscallarg(int) flags;
    141   1.2   thorpej 	} */ *uap = v;
    142  1.14  jdolecek 	struct sys_recvfrom_args bra;
    143  1.14  jdolecek 
    144  1.14  jdolecek 	SCARG(&bra, s) = SCARG(uap, s);
    145  1.14  jdolecek 	SCARG(&bra, buf) = SCARG(uap, buf);
    146  1.14  jdolecek 	SCARG(&bra, len) = (size_t) SCARG(uap, len);
    147  1.14  jdolecek 	SCARG(&bra, flags) = SCARG(uap, flags);
    148  1.14  jdolecek 	SCARG(&bra, from) = NULL;
    149  1.14  jdolecek 	SCARG(&bra, fromlenaddr) = NULL;
    150   1.1  christos 
    151  1.19   thorpej 	return (sys_recvfrom(l, &bra, retval));
    152   1.1  christos }
    153   1.1  christos 
    154   1.1  christos int
    155  1.19   thorpej compat_43_sys_recvfrom(struct lwp *l, void *v, register_t *retval)
    156   1.2   thorpej {
    157  1.15  jdolecek 	struct compat_43_sys_recvfrom_args /* {
    158   1.1  christos 		syscallarg(int) s;
    159  1.28  christos 		syscallarg(void *) buf;
    160   1.1  christos 		syscallarg(size_t) len;
    161   1.1  christos 		syscallarg(int) flags;
    162  1.28  christos 		syscallarg(void *) from;
    163   1.1  christos 		syscallarg(int *) fromlenaddr;
    164   1.2   thorpej 	} */ *uap = v;
    165  1.15  jdolecek 	int error;
    166  1.15  jdolecek 
    167  1.19   thorpej 	if ((error = sys_recvfrom(l, v, retval)))
    168  1.15  jdolecek 		return (error);
    169  1.15  jdolecek 
    170  1.15  jdolecek 	if (SCARG(uap, from) && (error = compat_43_sa_put(SCARG(uap, from))))
    171  1.15  jdolecek 		return (error);
    172   1.1  christos 
    173  1.15  jdolecek 	return (0);
    174   1.1  christos }
    175   1.1  christos 
    176   1.1  christos /*
    177  1.15  jdolecek  * Old recvmsg. Arrange necessary structures, calls generic code and
    178  1.15  jdolecek  * adjusts results accordingly.
    179   1.1  christos  */
    180   1.1  christos int
    181  1.19   thorpej compat_43_sys_recvmsg(struct lwp *l, void *v, register_t *retval)
    182   1.2   thorpej {
    183  1.11  augustss 	struct compat_43_sys_recvmsg_args /* {
    184   1.1  christos 		syscallarg(int) s;
    185   1.1  christos 		syscallarg(struct omsghdr *) msg;
    186   1.1  christos 		syscallarg(int) flags;
    187   1.2   thorpej 	} */ *uap = v;
    188  1.15  jdolecek 	struct omsghdr omsg;
    189   1.1  christos 	struct msghdr msg;
    190  1.31       dsl 	struct mbuf *from, *control;
    191   1.1  christos 	int error;
    192   1.1  christos 
    193  1.31       dsl 	error = copyin(SCARG(uap, msg), &omsg, sizeof (struct omsghdr));
    194   1.5  christos 	if (error)
    195   1.1  christos 		return (error);
    196  1.23     perry 
    197  1.31       dsl 	if (omsg.msg_accrights == NULL)
    198  1.31       dsl 		omsg.msg_accrightslen = 0;
    199  1.31       dsl 	/* it was this way in 4.4BSD */
    200  1.31       dsl 	if (omsg.msg_accrightslen > MLEN)
    201  1.31       dsl 		return EINVAL;
    202  1.15  jdolecek 
    203  1.15  jdolecek 	msg.msg_name	= omsg.msg_name;
    204  1.15  jdolecek 	msg.msg_namelen = omsg.msg_namelen;
    205  1.15  jdolecek 	msg.msg_iovlen	= omsg.msg_iovlen;
    206  1.31       dsl 	msg.msg_iov	= omsg.msg_iov;
    207  1.31       dsl 	msg.msg_flags	= (SCARG(uap, flags) & MSG_USERFLAGS) | MSG_IOVUSRSPACE;
    208  1.15  jdolecek 
    209  1.31       dsl 	error = do_sys_recvmsg(l, SCARG(uap, s), &msg, &from,
    210  1.31       dsl 	    omsg.msg_accrights != NULL ? &control : NULL, retval);
    211  1.31       dsl 	if (error != 0)
    212  1.31       dsl 		return error;
    213   1.1  christos 
    214  1.15  jdolecek 	/*
    215  1.15  jdolecek 	 * If there is any control information and it's SCM_RIGHTS,
    216  1.15  jdolecek 	 * pass it back to the program.
    217  1.31       dsl 	 * XXX: maybe there can be more than one chunk of control data?
    218  1.15  jdolecek 	 */
    219  1.31       dsl 	if (omsg.msg_accrights && control != NULL) {
    220  1.31       dsl 		struct cmsghdr *cmsg = mtod(control, void *);
    221  1.15  jdolecek 
    222  1.31       dsl 		if (cmsg->cmsg_level == SOL_SOCKET
    223  1.31       dsl 		    && cmsg->cmsg_type == SCM_RIGHTS
    224  1.31       dsl 		    && cmsg->cmsg_len < omsg.msg_accrightslen
    225  1.31       dsl 		    && copyout(CMSG_DATA(cmsg), omsg.msg_accrights,
    226  1.31       dsl 			    cmsg->cmsg_len) == 0) {
    227  1.31       dsl 			omsg.msg_accrightslen = cmsg->cmsg_len;
    228  1.31       dsl 			free_control_mbuf(l, control, control->m_next);
    229  1.31       dsl 		} else {
    230  1.15  jdolecek 			omsg.msg_accrightslen = 0;
    231  1.31       dsl 			free_control_mbuf(l, control, control);
    232  1.15  jdolecek 		}
    233  1.31       dsl 	} else
    234  1.31       dsl 		omsg.msg_accrightslen = 0;
    235  1.23     perry 
    236  1.31       dsl 	if (from != NULL)
    237  1.31       dsl 		/* convert from sockaddr sa_family to osockaddr one here */
    238  1.31       dsl 		mtod(from, struct osockaddr *)->sa_family =
    239  1.31       dsl 				    mtod(from, struct sockaddr *)->sa_family;
    240  1.31       dsl 
    241  1.31       dsl 	error = copyout_sockname(omsg.msg_name, &omsg.msg_namelen, 0, from);
    242  1.31       dsl 	if (from != NULL)
    243  1.31       dsl 		m_free(from);
    244  1.15  jdolecek 
    245  1.31       dsl 	if (error != 0)
    246  1.31       dsl 		 error = copyout(&omsg, SCARG(uap, msg), sizeof(omsg));
    247  1.15  jdolecek 
    248  1.31       dsl 	return error;
    249   1.1  christos }
    250   1.1  christos 
    251   1.1  christos int
    252  1.19   thorpej compat_43_sys_send(struct lwp *l, void *v, register_t *retval)
    253   1.2   thorpej {
    254  1.11  augustss 	struct compat_43_sys_send_args /* {
    255   1.1  christos 		syscallarg(int) s;
    256  1.28  christos 		syscallarg(void *) buf;
    257   1.1  christos 		syscallarg(int) len;
    258   1.1  christos 		syscallarg(int) flags;
    259   1.2   thorpej 	} */ *uap = v;
    260  1.14  jdolecek 	struct sys_sendto_args bsa;
    261  1.14  jdolecek 
    262  1.14  jdolecek 	SCARG(&bsa, s)		= SCARG(uap, s);
    263  1.14  jdolecek 	SCARG(&bsa, buf)	= SCARG(uap, buf);
    264  1.14  jdolecek 	SCARG(&bsa, len)	= SCARG(uap, len);
    265  1.14  jdolecek 	SCARG(&bsa, flags)	= SCARG(uap, flags);
    266  1.14  jdolecek 	SCARG(&bsa, to)		= NULL;
    267  1.14  jdolecek 	SCARG(&bsa, tolen)	= 0;
    268   1.1  christos 
    269  1.19   thorpej 	return (sys_sendto(l, &bsa, retval));
    270   1.1  christos }
    271   1.1  christos 
    272  1.15  jdolecek /*
    273  1.15  jdolecek  * Old sendmsg. Arrange necessary structures, call generic code and
    274  1.15  jdolecek  * adjust the results accordingly for old code.
    275  1.15  jdolecek  */
    276   1.1  christos int
    277  1.19   thorpej compat_43_sys_sendmsg(struct lwp *l, void *v, register_t *retval)
    278   1.2   thorpej {
    279  1.11  augustss 	struct compat_43_sys_sendmsg_args /* {
    280   1.1  christos 		syscallarg(int) s;
    281  1.28  christos 		syscallarg(void *) msg;
    282   1.1  christos 		syscallarg(int) flags;
    283   1.2   thorpej 	} */ *uap = v;
    284  1.15  jdolecek 	struct omsghdr omsg;
    285   1.1  christos 	struct msghdr msg;
    286   1.1  christos 	int error;
    287  1.30       dsl 	struct mbuf *nam;
    288  1.30       dsl 	struct mbuf *ctl;
    289  1.30       dsl 	struct osockaddr *osa;
    290  1.30       dsl 	struct sockaddr *sa;
    291   1.1  christos 
    292  1.30       dsl 	error = copyin(SCARG(uap, msg), &omsg, sizeof (struct omsghdr));
    293  1.30       dsl 	if (error != 0)
    294   1.1  christos 		return (error);
    295  1.15  jdolecek 
    296  1.30       dsl 	msg.msg_iovlen = omsg.msg_iovlen;
    297  1.30       dsl 	msg.msg_iov = omsg.msg_iov;
    298  1.15  jdolecek 
    299  1.30       dsl 	error = sockargs(&nam, omsg.msg_name, omsg.msg_namelen, MT_SONAME);
    300  1.30       dsl 	if (error != 0)
    301  1.30       dsl 		return (error);
    302  1.15  jdolecek 
    303  1.30       dsl 	sa = mtod(nam, void *);
    304  1.30       dsl 	osa = mtod(nam, void *);
    305  1.30       dsl 	sa->sa_family = osa->sa_family;
    306  1.30       dsl 	sa->sa_len = omsg.msg_namelen;
    307  1.15  jdolecek 
    308  1.30       dsl 	msg.msg_flags = MSG_IOVUSRSPACE | MSG_NAMEMBUF;
    309  1.15  jdolecek 
    310  1.30       dsl 	msg.msg_name = nam;
    311  1.30       dsl 	msg.msg_namelen = omsg.msg_namelen;
    312  1.15  jdolecek 
    313  1.15  jdolecek 	if (omsg.msg_accrights && omsg.msg_accrightslen != 0) {
    314  1.30       dsl 		struct cmsghdr *cmsg;
    315  1.30       dsl 		u_int clen;
    316  1.15  jdolecek 
    317  1.30       dsl 		clen = CMSG_SPACE(omsg.msg_accrightslen);
    318  1.30       dsl 		/* it was (almost) this way in 4.4BSD */
    319  1.30       dsl 		if (omsg.msg_accrightslen < 0 || clen > MLEN) {
    320  1.30       dsl 			error = EINVAL;
    321  1.30       dsl 			goto bad;
    322  1.30       dsl 		}
    323  1.15  jdolecek 
    324  1.30       dsl 		ctl = m_get(M_WAIT, MT_CONTROL);
    325  1.30       dsl 		ctl->m_len = clen;
    326  1.30       dsl 		cmsg = mtod(ctl, void *);
    327  1.15  jdolecek 		cmsg->cmsg_len		= CMSG_SPACE(omsg.msg_accrightslen);
    328  1.15  jdolecek 		cmsg->cmsg_level	= SOL_SOCKET;
    329  1.15  jdolecek 		cmsg->cmsg_type 	= SCM_RIGHTS;
    330  1.15  jdolecek 
    331  1.15  jdolecek 		error = copyin(omsg.msg_accrights, CMSG_DATA(cmsg),
    332  1.15  jdolecek 		    omsg.msg_accrightslen);
    333  1.30       dsl 		if (error)
    334  1.30       dsl 			goto bad;
    335  1.23     perry 
    336  1.30       dsl 		msg.msg_control = ctl;
    337  1.30       dsl 		msg.msg_controllen = clen;
    338  1.30       dsl 		msg.msg_flags |= MSG_CONTROLMBUF;
    339  1.15  jdolecek 	} else {
    340  1.15  jdolecek 		msg.msg_control = NULL;
    341  1.15  jdolecek 		msg.msg_controllen = 0;
    342  1.15  jdolecek 	}
    343  1.15  jdolecek 
    344  1.30       dsl 	return do_sys_sendmsg(l, SCARG(uap, s), &msg, SCARG(uap, flags), retval);
    345  1.30       dsl 
    346  1.30       dsl     bad:
    347  1.30       dsl 	if (nam != NULL)
    348  1.30       dsl 		m_free(nam);
    349  1.30       dsl 
    350   1.1  christos 	return (error);
    351  1.15  jdolecek }
    352  1.15  jdolecek 
    353  1.15  jdolecek static int
    354  1.15  jdolecek compat_43_sa_put(from)
    355  1.28  christos 	void *from;
    356  1.15  jdolecek {
    357  1.15  jdolecek 	struct osockaddr *osa = (struct osockaddr *) from;
    358  1.15  jdolecek 	struct sockaddr sa;
    359  1.15  jdolecek 	struct osockaddr *kosa;
    360  1.15  jdolecek 	int error, len;
    361  1.15  jdolecek 
    362  1.15  jdolecek 	/*
    363  1.15  jdolecek 	 * Only read/write the sockaddr family and length, the rest is
    364  1.15  jdolecek 	 * not changed.
    365  1.15  jdolecek 	 */
    366  1.15  jdolecek 	len = sizeof(sa.sa_len) + sizeof(sa.sa_family);
    367  1.15  jdolecek 
    368  1.28  christos 	error = copyin((void *) osa, (void *) &sa, len);
    369  1.15  jdolecek 	if (error)
    370  1.15  jdolecek 		return (error);
    371  1.15  jdolecek 
    372  1.15  jdolecek 	/* Note: we convert from sockaddr sa_family to osockaddr one here */
    373  1.15  jdolecek 	kosa = (struct osockaddr *) &sa;
    374  1.15  jdolecek 	kosa->sa_family = sa.sa_family;
    375  1.15  jdolecek 	error = copyout(kosa, osa, len);
    376  1.15  jdolecek 	if (error)
    377  1.15  jdolecek 		return (error);
    378  1.15  jdolecek 
    379  1.15  jdolecek 	return (0);
    380   1.1  christos }
    381  1.24  christos 
    382  1.24  christos int
    383  1.29  christos compat_ifioctl(struct socket *so, u_long ocmd, u_long cmd, void *data,
    384  1.29  christos     struct lwp *l)
    385  1.24  christos {
    386  1.29  christos 	int error;
    387  1.29  christos 	struct ifreq *ifr = data;
    388  1.24  christos 	struct ifnet *ifp = ifunit(ifr->ifr_name);
    389  1.29  christos 	struct sockaddr *sa;
    390  1.24  christos 
    391  1.24  christos 	if (ifp == NULL)
    392  1.24  christos 		return ENXIO;
    393  1.24  christos 
    394  1.29  christos 	switch (ocmd) {
    395  1.29  christos 	case OSIOCSIFADDR:
    396  1.29  christos 	case OSIOCSIFDSTADDR:
    397  1.29  christos 	case OSIOCSIFBRDADDR:
    398  1.29  christos 	case OSIOCSIFNETMASK:
    399  1.29  christos 		sa = &ifr->ifr_addr;
    400  1.24  christos #if BYTE_ORDER != BIG_ENDIAN
    401  1.29  christos 		if (sa->sa_family == 0 && sa->sa_len < 16) {
    402  1.29  christos 			sa->sa_family = sa->sa_len;
    403  1.29  christos 			sa->sa_len = 16;
    404  1.24  christos 		}
    405  1.24  christos #else
    406  1.29  christos 		if (sa->sa_len == 0)
    407  1.29  christos 			sa->sa_len = 16;
    408  1.24  christos #endif
    409  1.24  christos 		break;
    410  1.24  christos 
    411  1.29  christos 	case OOSIOCGIFADDR:
    412  1.24  christos 		cmd = SIOCGIFADDR;
    413  1.24  christos 		break;
    414  1.24  christos 
    415  1.29  christos 	case OOSIOCGIFDSTADDR:
    416  1.24  christos 		cmd = SIOCGIFDSTADDR;
    417  1.24  christos 		break;
    418  1.24  christos 
    419  1.29  christos 	case OOSIOCGIFBRDADDR:
    420  1.24  christos 		cmd = SIOCGIFBRDADDR;
    421  1.24  christos 		break;
    422  1.24  christos 
    423  1.29  christos 	case OOSIOCGIFNETMASK:
    424  1.24  christos 		cmd = SIOCGIFNETMASK;
    425  1.24  christos 	}
    426  1.24  christos 
    427  1.24  christos 	error = (*so->so_proto->pr_usrreq)(so, PRU_CONTROL,
    428  1.29  christos 	    (struct mbuf *)cmd, (struct mbuf *)ifr, (struct mbuf *)ifp, l);
    429  1.24  christos 
    430  1.24  christos 	switch (ocmd) {
    431  1.29  christos 	case OOSIOCGIFADDR:
    432  1.29  christos 	case OOSIOCGIFDSTADDR:
    433  1.29  christos 	case OOSIOCGIFBRDADDR:
    434  1.29  christos 	case OOSIOCGIFNETMASK:
    435  1.29  christos 		*(u_int16_t *)&ifr->ifr_addr =
    436  1.29  christos 		    ((struct sockaddr *)&ifr->ifr_addr)->sa_family;
    437  1.24  christos 	}
    438  1.24  christos 	return error;
    439  1.24  christos }
    440