Home | History | Annotate | Line # | Download | only in common
linux32_socket.c revision 1.6
      1  1.6  christos /*	$NetBSD: linux32_socket.c,v 1.6 2008/06/19 16:09:25 christos Exp $ */
      2  1.1      manu 
      3  1.1      manu /*-
      4  1.1      manu  * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
      5  1.1      manu  *
      6  1.1      manu  * Redistribution and use in source and binary forms, with or without
      7  1.1      manu  * modification, are permitted provided that the following conditions
      8  1.1      manu  * are met:
      9  1.1      manu  * 1. Redistributions of source code must retain the above copyright
     10  1.1      manu  *    notice, this list of conditions and the following disclaimer.
     11  1.1      manu  * 2. Redistributions in binary form must reproduce the above copyright
     12  1.1      manu  *    notice, this list of conditions and the following disclaimer in the
     13  1.1      manu  *    documentation and/or other materials provided with the distribution.
     14  1.1      manu  * 3. All advertising materials mentioning features or use of this software
     15  1.1      manu  *    must display the following acknowledgement:
     16  1.1      manu  *	This product includes software developed by Emmanuel Dreyfus
     17  1.1      manu  * 4. The name of the author may not be used to endorse or promote
     18  1.1      manu  *    products derived from this software without specific prior written
     19  1.1      manu  *    permission.
     20  1.1      manu  *
     21  1.1      manu  * THIS SOFTWARE IS PROVIDED BY THE THE AUTHOR AND CONTRIBUTORS ``AS IS''
     22  1.1      manu  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     23  1.1      manu  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     24  1.1      manu  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
     25  1.1      manu  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     26  1.1      manu  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     27  1.1      manu  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     28  1.1      manu  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     29  1.1      manu  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     30  1.1      manu  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     31  1.1      manu  * POSSIBILITY OF SUCH DAMAGE.
     32  1.1      manu  */
     33  1.1      manu 
     34  1.1      manu #include <sys/cdefs.h>
     35  1.1      manu 
     36  1.6  christos __KERNEL_RCSID(0, "$NetBSD: linux32_socket.c,v 1.6 2008/06/19 16:09:25 christos Exp $");
     37  1.1      manu 
     38  1.1      manu #include <sys/types.h>
     39  1.1      manu #include <sys/param.h>
     40  1.1      manu #include <sys/fstypes.h>
     41  1.1      manu #include <sys/signal.h>
     42  1.1      manu #include <sys/dirent.h>
     43  1.1      manu #include <sys/kernel.h>
     44  1.1      manu #include <sys/fcntl.h>
     45  1.1      manu #include <sys/select.h>
     46  1.1      manu #include <sys/proc.h>
     47  1.1      manu #include <sys/ucred.h>
     48  1.1      manu #include <sys/swap.h>
     49  1.6  christos #include <sys/file.h>
     50  1.6  christos #include <sys/vnode.h>
     51  1.6  christos #include <sys/filedesc.h>
     52  1.1      manu 
     53  1.1      manu #include <machine/types.h>
     54  1.1      manu 
     55  1.6  christos #include <net/if.h>
     56  1.6  christos 
     57  1.1      manu #include <sys/syscallargs.h>
     58  1.1      manu 
     59  1.1      manu #include <compat/netbsd32/netbsd32.h>
     60  1.1      manu #include <compat/netbsd32/netbsd32_conv.h>
     61  1.1      manu #include <compat/netbsd32/netbsd32_syscallargs.h>
     62  1.6  christos #include <compat/sys/sockio.h>
     63  1.1      manu 
     64  1.1      manu #include <compat/linux/common/linux_types.h>
     65  1.6  christos #include <compat/linux/common/linux_types.h>
     66  1.1      manu #include <compat/linux/common/linux_signal.h>
     67  1.1      manu #include <compat/linux/common/linux_machdep.h>
     68  1.1      manu #include <compat/linux/common/linux_misc.h>
     69  1.1      manu #include <compat/linux/common/linux_oldolduname.h>
     70  1.6  christos #include <compat/linux/common/linux_ioctl.h>
     71  1.6  christos #include <compat/linux/common/linux_sockio.h>
     72  1.1      manu #include <compat/linux/linux_syscallargs.h>
     73  1.1      manu 
     74  1.1      manu #include <compat/linux32/common/linux32_types.h>
     75  1.1      manu #include <compat/linux32/common/linux32_signal.h>
     76  1.1      manu #include <compat/linux32/common/linux32_machdep.h>
     77  1.1      manu #include <compat/linux32/common/linux32_sysctl.h>
     78  1.1      manu #include <compat/linux32/common/linux32_socketcall.h>
     79  1.6  christos #include <compat/linux32/common/linux32_ioctl.h>
     80  1.1      manu #include <compat/linux32/linux32_syscallargs.h>
     81  1.1      manu 
     82  1.1      manu int
     83  1.5       dsl linux32_sys_socketpair(struct lwp *l, const struct linux32_sys_socketpair_args *uap, register_t *retval)
     84  1.1      manu {
     85  1.5       dsl 	/* {
     86  1.1      manu 		syscallarg(int) domain;
     87  1.1      manu 		syscallarg(int) type;
     88  1.1      manu 		syscallarg(int) protocol;
     89  1.1      manu 		syscallarg(netbsd32_intp) rsv;
     90  1.5       dsl 	} */
     91  1.1      manu 	struct linux_sys_socketpair_args ua;
     92  1.1      manu 
     93  1.1      manu 	NETBSD32TO64_UAP(domain);
     94  1.1      manu 	NETBSD32TO64_UAP(type);
     95  1.1      manu 	NETBSD32TO64_UAP(protocol);
     96  1.1      manu 	NETBSD32TOP_UAP(rsv, int)
     97  1.1      manu 
     98  1.1      manu 	return linux_sys_socketpair(l, &ua, retval);
     99  1.1      manu }
    100  1.1      manu 
    101  1.1      manu int
    102  1.5       dsl linux32_sys_sendto(struct lwp *l, const struct linux32_sys_sendto_args *uap, register_t *retval)
    103  1.1      manu {
    104  1.5       dsl 	/* {
    105  1.1      manu 		syscallarg(int) s;
    106  1.5       dsl 		syscallarg(netbsd32_voidp) msg;
    107  1.1      manu 		syscallarg(int) len;
    108  1.1      manu 		syscallarg(int) flags;
    109  1.1      manu 		syscallarg(netbsd32_osockaddrp_t) to;
    110  1.1      manu 		syscallarg(int) tolen;
    111  1.5       dsl 	} */
    112  1.1      manu 	struct linux_sys_sendto_args ua;
    113  1.1      manu 
    114  1.1      manu 	NETBSD32TO64_UAP(s);
    115  1.1      manu 	NETBSD32TOP_UAP(msg, void);
    116  1.1      manu 	NETBSD32TO64_UAP(len);
    117  1.1      manu 	NETBSD32TO64_UAP(flags);
    118  1.1      manu 	NETBSD32TOP_UAP(to, struct osockaddr);
    119  1.1      manu 	NETBSD32TO64_UAP(tolen);
    120  1.1      manu 
    121  1.1      manu 	return linux_sys_sendto(l, &ua, retval);
    122  1.1      manu }
    123  1.1      manu 
    124  1.1      manu 
    125  1.1      manu int
    126  1.5       dsl linux32_sys_recvfrom(struct lwp *l, const struct linux32_sys_recvfrom_args *uap, register_t *retval)
    127  1.1      manu {
    128  1.5       dsl 	/* {
    129  1.1      manu 		syscallarg(int) s;
    130  1.5       dsl 		syscallarg(netbsd32_voidp) buf;
    131  1.1      manu 		syscallarg(netbsd32_size_t) len;
    132  1.1      manu 		syscallarg(int) flags;
    133  1.1      manu 		syscallarg(netbsd32_osockaddrp_t) from;
    134  1.1      manu 		syscallarg(netbsd32_intp) fromlenaddr;
    135  1.5       dsl 	} */
    136  1.1      manu 	struct linux_sys_recvfrom_args ua;
    137  1.1      manu 
    138  1.1      manu 	NETBSD32TO64_UAP(s);
    139  1.1      manu 	NETBSD32TOP_UAP(buf, void);
    140  1.1      manu 	NETBSD32TO64_UAP(len);
    141  1.1      manu 	NETBSD32TO64_UAP(flags);
    142  1.1      manu 	NETBSD32TOP_UAP(from, struct osockaddr);
    143  1.1      manu 	NETBSD32TOP_UAP(fromlenaddr, unsigned int);
    144  1.1      manu 
    145  1.1      manu 	return linux_sys_recvfrom(l, &ua, retval);
    146  1.1      manu }
    147  1.1      manu 
    148  1.1      manu int
    149  1.5       dsl linux32_sys_setsockopt(struct lwp *l, const struct linux32_sys_setsockopt_args *uap, register_t *retval)
    150  1.1      manu {
    151  1.5       dsl 	/* {
    152  1.1      manu 		syscallarg(int) s;
    153  1.1      manu 		syscallarg(int) level;
    154  1.1      manu 		syscallarg(int) optname;
    155  1.1      manu 		syscallarg(netbsd32_voidp) optval;
    156  1.1      manu 		syscallarg(int) optlen;
    157  1.5       dsl 	} */
    158  1.1      manu 	struct linux_sys_setsockopt_args ua;
    159  1.1      manu 
    160  1.1      manu 	NETBSD32TO64_UAP(s);
    161  1.1      manu 	NETBSD32TO64_UAP(level);
    162  1.1      manu 	NETBSD32TO64_UAP(optname);
    163  1.1      manu 	NETBSD32TOP_UAP(optval, void);
    164  1.1      manu 	NETBSD32TO64_UAP(optlen);
    165  1.1      manu 
    166  1.1      manu 	return linux_sys_setsockopt(l, &ua, retval);
    167  1.1      manu }
    168  1.1      manu 
    169  1.1      manu 
    170  1.1      manu int
    171  1.5       dsl linux32_sys_getsockopt(struct lwp *l, const struct linux32_sys_getsockopt_args *uap, register_t *retval)
    172  1.1      manu {
    173  1.5       dsl 	/* {
    174  1.1      manu 		syscallarg(int) s;
    175  1.1      manu 		syscallarg(int) level;
    176  1.1      manu 		syscallarg(int) optname;
    177  1.1      manu 		syscallarg(netbsd32_voidp) optval;
    178  1.1      manu 		syscallarg(netbsd32_intp) optlen;
    179  1.5       dsl 	} */
    180  1.1      manu 	struct linux_sys_getsockopt_args ua;
    181  1.1      manu 
    182  1.1      manu 	NETBSD32TO64_UAP(s);
    183  1.1      manu 	NETBSD32TO64_UAP(level);
    184  1.1      manu 	NETBSD32TO64_UAP(optname);
    185  1.1      manu 	NETBSD32TOP_UAP(optval, void);
    186  1.1      manu 	NETBSD32TOP_UAP(optlen, int);
    187  1.1      manu 
    188  1.1      manu 	return linux_sys_getsockopt(l, &ua, retval);
    189  1.1      manu }
    190  1.1      manu 
    191  1.1      manu int
    192  1.5       dsl linux32_sys_socket(struct lwp *l, const struct linux32_sys_socket_args *uap, register_t *retval)
    193  1.1      manu {
    194  1.5       dsl 	/* {
    195  1.1      manu 		syscallarg(int) domain;
    196  1.1      manu 		syscallarg(int) type;
    197  1.1      manu 		syscallarg(int) protocol;
    198  1.5       dsl 	} */
    199  1.1      manu 	struct linux_sys_socket_args ua;
    200  1.1      manu 
    201  1.1      manu 	NETBSD32TO64_UAP(domain);
    202  1.1      manu 	NETBSD32TO64_UAP(type);
    203  1.1      manu 	NETBSD32TO64_UAP(protocol);
    204  1.1      manu 
    205  1.1      manu 	return linux_sys_socket(l, &ua, retval);
    206  1.1      manu }
    207  1.1      manu 
    208  1.1      manu int
    209  1.5       dsl linux32_sys_bind(struct lwp *l, const struct linux32_sys_bind_args *uap, register_t *retval)
    210  1.1      manu {
    211  1.5       dsl 	/* {
    212  1.1      manu 		syscallarg(int) s;
    213  1.1      manu 		syscallarg(netbsd32_osockaddrp_t) name;
    214  1.1      manu 		syscallarg(int) namelen;
    215  1.5       dsl 	} */
    216  1.1      manu 	struct linux_sys_bind_args ua;
    217  1.1      manu 
    218  1.1      manu 	NETBSD32TO64_UAP(s);
    219  1.1      manu 	NETBSD32TOP_UAP(name, struct osockaddr)
    220  1.1      manu 	NETBSD32TO64_UAP(namelen);
    221  1.1      manu 
    222  1.1      manu 	return linux_sys_bind(l, &ua, retval);
    223  1.1      manu }
    224  1.1      manu 
    225  1.1      manu int
    226  1.5       dsl linux32_sys_connect(struct lwp *l, const struct linux32_sys_connect_args *uap, register_t *retval)
    227  1.1      manu {
    228  1.5       dsl 	/* {
    229  1.1      manu 		syscallarg(int) s;
    230  1.1      manu 		syscallarg(netbsd32_osockaddrp_t) name;
    231  1.1      manu 		syscallarg(int) namelen;
    232  1.5       dsl 	} */
    233  1.1      manu 	struct linux_sys_connect_args ua;
    234  1.1      manu 
    235  1.1      manu 	NETBSD32TO64_UAP(s);
    236  1.1      manu 	NETBSD32TOP_UAP(name, struct osockaddr)
    237  1.1      manu 	NETBSD32TO64_UAP(namelen);
    238  1.1      manu 
    239  1.2      manu #ifdef DEBUG_LINUX
    240  1.1      manu 	printf("linux32_sys_connect: s = %d, name = %p, namelen = %d\n",
    241  1.1      manu 		SCARG(&ua, s), SCARG(&ua, name), SCARG(&ua, namelen));
    242  1.2      manu #endif
    243  1.1      manu 
    244  1.1      manu 	return linux_sys_connect(l, &ua, retval);
    245  1.1      manu }
    246  1.1      manu 
    247  1.1      manu int
    248  1.5       dsl linux32_sys_accept(struct lwp *l, const struct linux32_sys_accept_args *uap, register_t *retval)
    249  1.1      manu {
    250  1.5       dsl 	/* {
    251  1.1      manu 		syscallarg(int) s;
    252  1.1      manu 		syscallarg(netbsd32_osockaddrp_t) name;
    253  1.1      manu 		syscallarg(netbsd32_intp) anamelen;
    254  1.5       dsl 	} */
    255  1.1      manu 	struct linux_sys_accept_args ua;
    256  1.1      manu 
    257  1.1      manu 	NETBSD32TO64_UAP(s);
    258  1.1      manu 	NETBSD32TOP_UAP(name, struct osockaddr)
    259  1.1      manu 	NETBSD32TOP_UAP(anamelen, int);
    260  1.1      manu 
    261  1.1      manu 	return linux_sys_accept(l, &ua, retval);
    262  1.1      manu }
    263  1.1      manu 
    264  1.1      manu int
    265  1.5       dsl linux32_sys_getpeername(struct lwp *l, const struct linux32_sys_getpeername_args *uap, register_t *retval)
    266  1.1      manu {
    267  1.5       dsl 	/* {
    268  1.1      manu 		syscallarg(int) fdes;
    269  1.1      manu 		syscallarg(netbsd32_sockaddrp_t) asa;
    270  1.1      manu 		syscallarg(netbsd32_intp) alen;
    271  1.5       dsl 	} */
    272  1.1      manu 	struct linux_sys_getpeername_args ua;
    273  1.1      manu 
    274  1.1      manu 	NETBSD32TO64_UAP(fdes);
    275  1.1      manu 	NETBSD32TOP_UAP(asa, struct sockaddr)
    276  1.1      manu 	NETBSD32TOP_UAP(alen, int);
    277  1.1      manu 
    278  1.1      manu 	return linux_sys_getpeername(l, &ua, retval);
    279  1.1      manu }
    280  1.1      manu 
    281  1.1      manu int
    282  1.5       dsl linux32_sys_getsockname(struct lwp *l, const struct linux32_sys_getsockname_args *uap, register_t *retval)
    283  1.1      manu {
    284  1.5       dsl 	/* {
    285  1.1      manu 		syscallarg(int) fdec;
    286  1.1      manu 		syscallarg(netbsd32_charp) asa;
    287  1.1      manu 		syscallarg(netbsd32_intp) alen;
    288  1.5       dsl 	} */
    289  1.1      manu 	struct linux_sys_getsockname_args ua;
    290  1.1      manu 
    291  1.1      manu 	NETBSD32TO64_UAP(fdec);
    292  1.1      manu 	NETBSD32TOP_UAP(asa, char)
    293  1.1      manu 	NETBSD32TOP_UAP(alen, int);
    294  1.1      manu 
    295  1.1      manu 	return linux_sys_getsockname(l, &ua, retval);
    296  1.1      manu }
    297  1.1      manu 
    298  1.1      manu int
    299  1.5       dsl linux32_sys_sendmsg(struct lwp *l, const struct linux32_sys_sendmsg_args *uap, register_t *retval)
    300  1.1      manu {
    301  1.5       dsl 	/* {
    302  1.1      manu 		syscallarg(int) s;
    303  1.1      manu 		syscallarg(netbsd32_msghdrp_t) msg;
    304  1.1      manu 		syscallarg(int) flags;
    305  1.5       dsl 	} */
    306  1.1      manu 	struct linux_sys_sendmsg_args ua;
    307  1.1      manu 
    308  1.1      manu 	NETBSD32TO64_UAP(s);
    309  1.1      manu 	NETBSD32TOP_UAP(msg, struct msghdr);
    310  1.1      manu 	NETBSD32TO64_UAP(flags);
    311  1.1      manu 
    312  1.1      manu 	return linux_sys_sendmsg(l, &ua, retval);
    313  1.1      manu }
    314  1.1      manu 
    315  1.1      manu int
    316  1.5       dsl linux32_sys_recvmsg(struct lwp *l, const struct linux32_sys_recvmsg_args *uap, register_t *retval)
    317  1.1      manu {
    318  1.5       dsl 	/* {
    319  1.1      manu 		syscallarg(int) s;
    320  1.1      manu 		syscallarg(netbsd32_msghdrp_t) msg;
    321  1.1      manu 		syscallarg(int) flags;
    322  1.5       dsl 	} */
    323  1.1      manu 	struct linux_sys_recvmsg_args ua;
    324  1.1      manu 
    325  1.1      manu 	NETBSD32TO64_UAP(s);
    326  1.1      manu 	NETBSD32TOP_UAP(msg, struct msghdr);
    327  1.1      manu 	NETBSD32TO64_UAP(flags);
    328  1.1      manu 
    329  1.1      manu 	return linux_sys_recvmsg(l, &ua, retval);
    330  1.1      manu }
    331  1.1      manu 
    332  1.1      manu int
    333  1.5       dsl linux32_sys_send(struct lwp *l, const struct linux32_sys_send_args *uap, register_t *retval)
    334  1.1      manu {
    335  1.5       dsl 	/* {
    336  1.1      manu 		syscallarg(int) s;
    337  1.1      manu 		syscallarg(netbsd32_voidp) buf;
    338  1.1      manu 		syscallarg(int) len;
    339  1.1      manu 		syscallarg(int) flags;
    340  1.5       dsl 	} */
    341  1.1      manu 	struct sys_sendto_args ua;
    342  1.1      manu 
    343  1.1      manu 	NETBSD32TO64_UAP(s);
    344  1.1      manu 	NETBSD32TOP_UAP(buf, void);
    345  1.1      manu 	NETBSD32TO64_UAP(len);
    346  1.1      manu 	NETBSD32TO64_UAP(flags);
    347  1.1      manu 	SCARG(&ua, to) = NULL;
    348  1.1      manu 	SCARG(&ua, tolen) = 0;
    349  1.1      manu 
    350  1.1      manu 	return sys_sendto(l, &ua, retval);
    351  1.1      manu }
    352  1.1      manu 
    353  1.1      manu int
    354  1.5       dsl linux32_sys_recv(struct lwp *l, const struct linux32_sys_recv_args *uap, register_t *retval)
    355  1.1      manu {
    356  1.5       dsl 	/* {
    357  1.1      manu 		syscallarg(int) s;
    358  1.1      manu 		syscallarg(netbsd32_voidp) buf;
    359  1.1      manu 		syscallarg(int) len;
    360  1.1      manu 		syscallarg(int) flags;
    361  1.5       dsl 	} */
    362  1.1      manu 	struct sys_recvfrom_args ua;
    363  1.1      manu 
    364  1.1      manu 	NETBSD32TO64_UAP(s);
    365  1.1      manu 	NETBSD32TOP_UAP(buf, void);
    366  1.1      manu 	NETBSD32TO64_UAP(len);
    367  1.1      manu 	NETBSD32TO64_UAP(flags);
    368  1.1      manu 	SCARG(&ua, from) = NULL;
    369  1.1      manu 	SCARG(&ua, fromlenaddr) = NULL;
    370  1.1      manu 
    371  1.1      manu 	return sys_recvfrom(l, &ua, retval);
    372  1.1      manu }
    373  1.6  christos 
    374  1.6  christos int
    375  1.6  christos linux32_ioctl_socket(struct lwp *l, const struct linux32_sys_ioctl_args *uap, register_t *retval)
    376  1.6  christos {
    377  1.6  christos 	/* {
    378  1.6  christos 		syscallarg(int) fd;
    379  1.6  christos 		syscallarg(u_long) com;
    380  1.6  christos 		syscallarg(void *) data;
    381  1.6  christos 	} */
    382  1.6  christos 	u_long com;
    383  1.6  christos 	int error = 0, isdev = 0, dosys = 1;
    384  1.6  christos 	struct netbsd32_ioctl_args ia;
    385  1.6  christos 	file_t *fp;
    386  1.6  christos 	struct vnode *vp;
    387  1.6  christos 	int (*ioctlf)(file_t *, u_long, void *);
    388  1.6  christos 	struct ioctl_pt pt;
    389  1.6  christos 
    390  1.6  christos 	if ((fp = fd_getfile(SCARG(uap, fd))) == NULL)
    391  1.6  christos 		return (EBADF);
    392  1.6  christos 
    393  1.6  christos 	if (fp->f_type == DTYPE_VNODE) {
    394  1.6  christos 		vp = (struct vnode *)fp->f_data;
    395  1.6  christos 		isdev = vp->v_type == VCHR;
    396  1.6  christos 	}
    397  1.6  christos 
    398  1.6  christos 	/*
    399  1.6  christos 	 * Don't try to interpret socket ioctl calls that are done
    400  1.6  christos 	 * on a device filedescriptor, just pass them through, to
    401  1.6  christos 	 * emulate Linux behaviour. Use PTIOCLINUX so that the
    402  1.6  christos 	 * device will only handle these if it's prepared to do
    403  1.6  christos 	 * so, to avoid unexpected things from happening.
    404  1.6  christos 	 */
    405  1.6  christos 	if (isdev) {
    406  1.6  christos 		dosys = 0;
    407  1.6  christos 		ioctlf = fp->f_ops->fo_ioctl;
    408  1.6  christos 		pt.com = SCARG(uap, com);
    409  1.6  christos 		pt.data = (void *)NETBSD32PTR64(SCARG(uap, data));
    410  1.6  christos 		error = ioctlf(fp, PTIOCLINUX, &pt);
    411  1.6  christos 		/*
    412  1.6  christos 		 * XXX hack: if the function returns EJUSTRETURN,
    413  1.6  christos 		 * it has stuffed a sysctl return value in pt.data.
    414  1.6  christos 		 */
    415  1.6  christos 		if (error == EJUSTRETURN) {
    416  1.6  christos 			retval[0] = (register_t)pt.data;
    417  1.6  christos 			error = 0;
    418  1.6  christos 		}
    419  1.6  christos 		goto out;
    420  1.6  christos 	}
    421  1.6  christos 
    422  1.6  christos 	com = SCARG(uap, com);
    423  1.6  christos 	retval[0] = 0;
    424  1.6  christos 
    425  1.6  christos 	switch (com) {
    426  1.6  christos 	case LINUX_SIOCGIFCONF:
    427  1.6  christos 		SCARG(&ia, com) = OOSIOCGIFCONF;
    428  1.6  christos 		break;
    429  1.6  christos 	case LINUX_SIOCGIFFLAGS:
    430  1.6  christos 		SCARG(&ia, com) = OSIOCGIFFLAGS;
    431  1.6  christos 		break;
    432  1.6  christos 	case LINUX_SIOCSIFFLAGS:
    433  1.6  christos 		SCARG(&ia, com) = OSIOCSIFFLAGS;
    434  1.6  christos 		break;
    435  1.6  christos 	case LINUX_SIOCGIFADDR:
    436  1.6  christos 		SCARG(&ia, com) = OOSIOCGIFADDR;
    437  1.6  christos 		break;
    438  1.6  christos 	case LINUX_SIOCGIFDSTADDR:
    439  1.6  christos 		SCARG(&ia, com) = OOSIOCGIFDSTADDR;
    440  1.6  christos 		break;
    441  1.6  christos 	case LINUX_SIOCGIFBRDADDR:
    442  1.6  christos 		SCARG(&ia, com) = OOSIOCGIFBRDADDR;
    443  1.6  christos 		break;
    444  1.6  christos 	case LINUX_SIOCGIFNETMASK:
    445  1.6  christos 		SCARG(&ia, com) = OOSIOCGIFNETMASK;
    446  1.6  christos 		break;
    447  1.6  christos 	case LINUX_SIOCADDMULTI:
    448  1.6  christos 		SCARG(&ia, com) = OSIOCADDMULTI;
    449  1.6  christos 		break;
    450  1.6  christos 	case LINUX_SIOCDELMULTI:
    451  1.6  christos 		SCARG(&ia, com) = OSIOCDELMULTI;
    452  1.6  christos 		break;
    453  1.6  christos #ifdef notyet
    454  1.6  christos 	case LINUX_SIOCGIFHWADDR:
    455  1.6  christos 		error = linux_getifhwaddr(l, retval, SCARG(uap, fd),
    456  1.6  christos 		    SCARG(uap, data));
    457  1.6  christos 		dosys = 0;
    458  1.6  christos 		break;
    459  1.6  christos #endif
    460  1.6  christos 	default:
    461  1.6  christos 		error = EINVAL;
    462  1.6  christos 	}
    463  1.6  christos 
    464  1.6  christos  out:
    465  1.6  christos  	fd_putfile(SCARG(uap, fd));
    466  1.6  christos 
    467  1.6  christos 	if (error == 0 && dosys) {
    468  1.6  christos 		SCARG(&ia, fd) = SCARG(uap, fd);
    469  1.6  christos 		SCARG(&ia, data) = SCARG(uap, data);
    470  1.6  christos 		error = netbsd32_ioctl(curlwp, &ia, retval);
    471  1.6  christos 	}
    472  1.6  christos 
    473  1.6  christos 	return error;
    474  1.6  christos }
    475