Home | History | Annotate | Line # | Download | only in common
linux32_socket.c revision 1.7
      1  1.7     njoly /*	$NetBSD: linux32_socket.c,v 1.7 2008/06/24 09:00:04 njoly 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.7     njoly __KERNEL_RCSID(0, "$NetBSD: linux32_socket.c,v 1.7 2008/06/24 09:00:04 njoly 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.7     njoly #include <net/route.h>
     57  1.7     njoly 
     58  1.7     njoly #include <netinet/in.h>
     59  1.7     njoly #include <netinet/ip_mroute.h>
     60  1.6  christos 
     61  1.1      manu #include <sys/syscallargs.h>
     62  1.1      manu 
     63  1.1      manu #include <compat/netbsd32/netbsd32.h>
     64  1.7     njoly #include <compat/netbsd32/netbsd32_ioctl.h>
     65  1.1      manu #include <compat/netbsd32/netbsd32_conv.h>
     66  1.1      manu #include <compat/netbsd32/netbsd32_syscallargs.h>
     67  1.6  christos #include <compat/sys/sockio.h>
     68  1.1      manu 
     69  1.1      manu #include <compat/linux/common/linux_types.h>
     70  1.6  christos #include <compat/linux/common/linux_types.h>
     71  1.1      manu #include <compat/linux/common/linux_signal.h>
     72  1.1      manu #include <compat/linux/common/linux_machdep.h>
     73  1.1      manu #include <compat/linux/common/linux_misc.h>
     74  1.1      manu #include <compat/linux/common/linux_oldolduname.h>
     75  1.6  christos #include <compat/linux/common/linux_ioctl.h>
     76  1.6  christos #include <compat/linux/common/linux_sockio.h>
     77  1.1      manu #include <compat/linux/linux_syscallargs.h>
     78  1.1      manu 
     79  1.1      manu #include <compat/linux32/common/linux32_types.h>
     80  1.1      manu #include <compat/linux32/common/linux32_signal.h>
     81  1.1      manu #include <compat/linux32/common/linux32_machdep.h>
     82  1.1      manu #include <compat/linux32/common/linux32_sysctl.h>
     83  1.1      manu #include <compat/linux32/common/linux32_socketcall.h>
     84  1.6  christos #include <compat/linux32/common/linux32_ioctl.h>
     85  1.1      manu #include <compat/linux32/linux32_syscallargs.h>
     86  1.1      manu 
     87  1.1      manu int
     88  1.5       dsl linux32_sys_socketpair(struct lwp *l, const struct linux32_sys_socketpair_args *uap, register_t *retval)
     89  1.1      manu {
     90  1.5       dsl 	/* {
     91  1.1      manu 		syscallarg(int) domain;
     92  1.1      manu 		syscallarg(int) type;
     93  1.1      manu 		syscallarg(int) protocol;
     94  1.1      manu 		syscallarg(netbsd32_intp) rsv;
     95  1.5       dsl 	} */
     96  1.1      manu 	struct linux_sys_socketpair_args ua;
     97  1.1      manu 
     98  1.1      manu 	NETBSD32TO64_UAP(domain);
     99  1.1      manu 	NETBSD32TO64_UAP(type);
    100  1.1      manu 	NETBSD32TO64_UAP(protocol);
    101  1.1      manu 	NETBSD32TOP_UAP(rsv, int)
    102  1.1      manu 
    103  1.1      manu 	return linux_sys_socketpair(l, &ua, retval);
    104  1.1      manu }
    105  1.1      manu 
    106  1.1      manu int
    107  1.5       dsl linux32_sys_sendto(struct lwp *l, const struct linux32_sys_sendto_args *uap, register_t *retval)
    108  1.1      manu {
    109  1.5       dsl 	/* {
    110  1.1      manu 		syscallarg(int) s;
    111  1.5       dsl 		syscallarg(netbsd32_voidp) msg;
    112  1.1      manu 		syscallarg(int) len;
    113  1.1      manu 		syscallarg(int) flags;
    114  1.1      manu 		syscallarg(netbsd32_osockaddrp_t) to;
    115  1.1      manu 		syscallarg(int) tolen;
    116  1.5       dsl 	} */
    117  1.1      manu 	struct linux_sys_sendto_args ua;
    118  1.1      manu 
    119  1.1      manu 	NETBSD32TO64_UAP(s);
    120  1.1      manu 	NETBSD32TOP_UAP(msg, void);
    121  1.1      manu 	NETBSD32TO64_UAP(len);
    122  1.1      manu 	NETBSD32TO64_UAP(flags);
    123  1.1      manu 	NETBSD32TOP_UAP(to, struct osockaddr);
    124  1.1      manu 	NETBSD32TO64_UAP(tolen);
    125  1.1      manu 
    126  1.1      manu 	return linux_sys_sendto(l, &ua, retval);
    127  1.1      manu }
    128  1.1      manu 
    129  1.1      manu 
    130  1.1      manu int
    131  1.5       dsl linux32_sys_recvfrom(struct lwp *l, const struct linux32_sys_recvfrom_args *uap, register_t *retval)
    132  1.1      manu {
    133  1.5       dsl 	/* {
    134  1.1      manu 		syscallarg(int) s;
    135  1.5       dsl 		syscallarg(netbsd32_voidp) buf;
    136  1.1      manu 		syscallarg(netbsd32_size_t) len;
    137  1.1      manu 		syscallarg(int) flags;
    138  1.1      manu 		syscallarg(netbsd32_osockaddrp_t) from;
    139  1.1      manu 		syscallarg(netbsd32_intp) fromlenaddr;
    140  1.5       dsl 	} */
    141  1.1      manu 	struct linux_sys_recvfrom_args ua;
    142  1.1      manu 
    143  1.1      manu 	NETBSD32TO64_UAP(s);
    144  1.1      manu 	NETBSD32TOP_UAP(buf, void);
    145  1.1      manu 	NETBSD32TO64_UAP(len);
    146  1.1      manu 	NETBSD32TO64_UAP(flags);
    147  1.1      manu 	NETBSD32TOP_UAP(from, struct osockaddr);
    148  1.1      manu 	NETBSD32TOP_UAP(fromlenaddr, unsigned int);
    149  1.1      manu 
    150  1.1      manu 	return linux_sys_recvfrom(l, &ua, retval);
    151  1.1      manu }
    152  1.1      manu 
    153  1.1      manu int
    154  1.5       dsl linux32_sys_setsockopt(struct lwp *l, const struct linux32_sys_setsockopt_args *uap, register_t *retval)
    155  1.1      manu {
    156  1.5       dsl 	/* {
    157  1.1      manu 		syscallarg(int) s;
    158  1.1      manu 		syscallarg(int) level;
    159  1.1      manu 		syscallarg(int) optname;
    160  1.1      manu 		syscallarg(netbsd32_voidp) optval;
    161  1.1      manu 		syscallarg(int) optlen;
    162  1.5       dsl 	} */
    163  1.1      manu 	struct linux_sys_setsockopt_args ua;
    164  1.1      manu 
    165  1.1      manu 	NETBSD32TO64_UAP(s);
    166  1.1      manu 	NETBSD32TO64_UAP(level);
    167  1.1      manu 	NETBSD32TO64_UAP(optname);
    168  1.1      manu 	NETBSD32TOP_UAP(optval, void);
    169  1.1      manu 	NETBSD32TO64_UAP(optlen);
    170  1.1      manu 
    171  1.1      manu 	return linux_sys_setsockopt(l, &ua, retval);
    172  1.1      manu }
    173  1.1      manu 
    174  1.1      manu 
    175  1.1      manu int
    176  1.5       dsl linux32_sys_getsockopt(struct lwp *l, const struct linux32_sys_getsockopt_args *uap, register_t *retval)
    177  1.1      manu {
    178  1.5       dsl 	/* {
    179  1.1      manu 		syscallarg(int) s;
    180  1.1      manu 		syscallarg(int) level;
    181  1.1      manu 		syscallarg(int) optname;
    182  1.1      manu 		syscallarg(netbsd32_voidp) optval;
    183  1.1      manu 		syscallarg(netbsd32_intp) optlen;
    184  1.5       dsl 	} */
    185  1.1      manu 	struct linux_sys_getsockopt_args ua;
    186  1.1      manu 
    187  1.1      manu 	NETBSD32TO64_UAP(s);
    188  1.1      manu 	NETBSD32TO64_UAP(level);
    189  1.1      manu 	NETBSD32TO64_UAP(optname);
    190  1.1      manu 	NETBSD32TOP_UAP(optval, void);
    191  1.1      manu 	NETBSD32TOP_UAP(optlen, int);
    192  1.1      manu 
    193  1.1      manu 	return linux_sys_getsockopt(l, &ua, retval);
    194  1.1      manu }
    195  1.1      manu 
    196  1.1      manu int
    197  1.5       dsl linux32_sys_socket(struct lwp *l, const struct linux32_sys_socket_args *uap, register_t *retval)
    198  1.1      manu {
    199  1.5       dsl 	/* {
    200  1.1      manu 		syscallarg(int) domain;
    201  1.1      manu 		syscallarg(int) type;
    202  1.1      manu 		syscallarg(int) protocol;
    203  1.5       dsl 	} */
    204  1.1      manu 	struct linux_sys_socket_args ua;
    205  1.1      manu 
    206  1.1      manu 	NETBSD32TO64_UAP(domain);
    207  1.1      manu 	NETBSD32TO64_UAP(type);
    208  1.1      manu 	NETBSD32TO64_UAP(protocol);
    209  1.1      manu 
    210  1.1      manu 	return linux_sys_socket(l, &ua, retval);
    211  1.1      manu }
    212  1.1      manu 
    213  1.1      manu int
    214  1.5       dsl linux32_sys_bind(struct lwp *l, const struct linux32_sys_bind_args *uap, register_t *retval)
    215  1.1      manu {
    216  1.5       dsl 	/* {
    217  1.1      manu 		syscallarg(int) s;
    218  1.1      manu 		syscallarg(netbsd32_osockaddrp_t) name;
    219  1.1      manu 		syscallarg(int) namelen;
    220  1.5       dsl 	} */
    221  1.1      manu 	struct linux_sys_bind_args ua;
    222  1.1      manu 
    223  1.1      manu 	NETBSD32TO64_UAP(s);
    224  1.1      manu 	NETBSD32TOP_UAP(name, struct osockaddr)
    225  1.1      manu 	NETBSD32TO64_UAP(namelen);
    226  1.1      manu 
    227  1.1      manu 	return linux_sys_bind(l, &ua, retval);
    228  1.1      manu }
    229  1.1      manu 
    230  1.1      manu int
    231  1.5       dsl linux32_sys_connect(struct lwp *l, const struct linux32_sys_connect_args *uap, register_t *retval)
    232  1.1      manu {
    233  1.5       dsl 	/* {
    234  1.1      manu 		syscallarg(int) s;
    235  1.1      manu 		syscallarg(netbsd32_osockaddrp_t) name;
    236  1.1      manu 		syscallarg(int) namelen;
    237  1.5       dsl 	} */
    238  1.1      manu 	struct linux_sys_connect_args ua;
    239  1.1      manu 
    240  1.1      manu 	NETBSD32TO64_UAP(s);
    241  1.1      manu 	NETBSD32TOP_UAP(name, struct osockaddr)
    242  1.1      manu 	NETBSD32TO64_UAP(namelen);
    243  1.1      manu 
    244  1.2      manu #ifdef DEBUG_LINUX
    245  1.1      manu 	printf("linux32_sys_connect: s = %d, name = %p, namelen = %d\n",
    246  1.1      manu 		SCARG(&ua, s), SCARG(&ua, name), SCARG(&ua, namelen));
    247  1.2      manu #endif
    248  1.1      manu 
    249  1.1      manu 	return linux_sys_connect(l, &ua, retval);
    250  1.1      manu }
    251  1.1      manu 
    252  1.1      manu int
    253  1.5       dsl linux32_sys_accept(struct lwp *l, const struct linux32_sys_accept_args *uap, register_t *retval)
    254  1.1      manu {
    255  1.5       dsl 	/* {
    256  1.1      manu 		syscallarg(int) s;
    257  1.1      manu 		syscallarg(netbsd32_osockaddrp_t) name;
    258  1.1      manu 		syscallarg(netbsd32_intp) anamelen;
    259  1.5       dsl 	} */
    260  1.1      manu 	struct linux_sys_accept_args ua;
    261  1.1      manu 
    262  1.1      manu 	NETBSD32TO64_UAP(s);
    263  1.1      manu 	NETBSD32TOP_UAP(name, struct osockaddr)
    264  1.1      manu 	NETBSD32TOP_UAP(anamelen, int);
    265  1.1      manu 
    266  1.1      manu 	return linux_sys_accept(l, &ua, retval);
    267  1.1      manu }
    268  1.1      manu 
    269  1.1      manu int
    270  1.5       dsl linux32_sys_getpeername(struct lwp *l, const struct linux32_sys_getpeername_args *uap, register_t *retval)
    271  1.1      manu {
    272  1.5       dsl 	/* {
    273  1.1      manu 		syscallarg(int) fdes;
    274  1.1      manu 		syscallarg(netbsd32_sockaddrp_t) asa;
    275  1.1      manu 		syscallarg(netbsd32_intp) alen;
    276  1.5       dsl 	} */
    277  1.1      manu 	struct linux_sys_getpeername_args ua;
    278  1.1      manu 
    279  1.1      manu 	NETBSD32TO64_UAP(fdes);
    280  1.1      manu 	NETBSD32TOP_UAP(asa, struct sockaddr)
    281  1.1      manu 	NETBSD32TOP_UAP(alen, int);
    282  1.1      manu 
    283  1.1      manu 	return linux_sys_getpeername(l, &ua, retval);
    284  1.1      manu }
    285  1.1      manu 
    286  1.1      manu int
    287  1.5       dsl linux32_sys_getsockname(struct lwp *l, const struct linux32_sys_getsockname_args *uap, register_t *retval)
    288  1.1      manu {
    289  1.5       dsl 	/* {
    290  1.1      manu 		syscallarg(int) fdec;
    291  1.1      manu 		syscallarg(netbsd32_charp) asa;
    292  1.1      manu 		syscallarg(netbsd32_intp) alen;
    293  1.5       dsl 	} */
    294  1.1      manu 	struct linux_sys_getsockname_args ua;
    295  1.1      manu 
    296  1.1      manu 	NETBSD32TO64_UAP(fdec);
    297  1.1      manu 	NETBSD32TOP_UAP(asa, char)
    298  1.1      manu 	NETBSD32TOP_UAP(alen, int);
    299  1.1      manu 
    300  1.1      manu 	return linux_sys_getsockname(l, &ua, retval);
    301  1.1      manu }
    302  1.1      manu 
    303  1.1      manu int
    304  1.5       dsl linux32_sys_sendmsg(struct lwp *l, const struct linux32_sys_sendmsg_args *uap, register_t *retval)
    305  1.1      manu {
    306  1.5       dsl 	/* {
    307  1.1      manu 		syscallarg(int) s;
    308  1.1      manu 		syscallarg(netbsd32_msghdrp_t) msg;
    309  1.1      manu 		syscallarg(int) flags;
    310  1.5       dsl 	} */
    311  1.1      manu 	struct linux_sys_sendmsg_args ua;
    312  1.1      manu 
    313  1.1      manu 	NETBSD32TO64_UAP(s);
    314  1.1      manu 	NETBSD32TOP_UAP(msg, struct msghdr);
    315  1.1      manu 	NETBSD32TO64_UAP(flags);
    316  1.1      manu 
    317  1.1      manu 	return linux_sys_sendmsg(l, &ua, retval);
    318  1.1      manu }
    319  1.1      manu 
    320  1.1      manu int
    321  1.5       dsl linux32_sys_recvmsg(struct lwp *l, const struct linux32_sys_recvmsg_args *uap, register_t *retval)
    322  1.1      manu {
    323  1.5       dsl 	/* {
    324  1.1      manu 		syscallarg(int) s;
    325  1.1      manu 		syscallarg(netbsd32_msghdrp_t) msg;
    326  1.1      manu 		syscallarg(int) flags;
    327  1.5       dsl 	} */
    328  1.1      manu 	struct linux_sys_recvmsg_args ua;
    329  1.1      manu 
    330  1.1      manu 	NETBSD32TO64_UAP(s);
    331  1.1      manu 	NETBSD32TOP_UAP(msg, struct msghdr);
    332  1.1      manu 	NETBSD32TO64_UAP(flags);
    333  1.1      manu 
    334  1.1      manu 	return linux_sys_recvmsg(l, &ua, retval);
    335  1.1      manu }
    336  1.1      manu 
    337  1.1      manu int
    338  1.5       dsl linux32_sys_send(struct lwp *l, const struct linux32_sys_send_args *uap, register_t *retval)
    339  1.1      manu {
    340  1.5       dsl 	/* {
    341  1.1      manu 		syscallarg(int) s;
    342  1.1      manu 		syscallarg(netbsd32_voidp) buf;
    343  1.1      manu 		syscallarg(int) len;
    344  1.1      manu 		syscallarg(int) flags;
    345  1.5       dsl 	} */
    346  1.1      manu 	struct sys_sendto_args ua;
    347  1.1      manu 
    348  1.1      manu 	NETBSD32TO64_UAP(s);
    349  1.1      manu 	NETBSD32TOP_UAP(buf, void);
    350  1.1      manu 	NETBSD32TO64_UAP(len);
    351  1.1      manu 	NETBSD32TO64_UAP(flags);
    352  1.1      manu 	SCARG(&ua, to) = NULL;
    353  1.1      manu 	SCARG(&ua, tolen) = 0;
    354  1.1      manu 
    355  1.1      manu 	return sys_sendto(l, &ua, retval);
    356  1.1      manu }
    357  1.1      manu 
    358  1.1      manu int
    359  1.5       dsl linux32_sys_recv(struct lwp *l, const struct linux32_sys_recv_args *uap, register_t *retval)
    360  1.1      manu {
    361  1.5       dsl 	/* {
    362  1.1      manu 		syscallarg(int) s;
    363  1.1      manu 		syscallarg(netbsd32_voidp) buf;
    364  1.1      manu 		syscallarg(int) len;
    365  1.1      manu 		syscallarg(int) flags;
    366  1.5       dsl 	} */
    367  1.1      manu 	struct sys_recvfrom_args ua;
    368  1.1      manu 
    369  1.1      manu 	NETBSD32TO64_UAP(s);
    370  1.1      manu 	NETBSD32TOP_UAP(buf, void);
    371  1.1      manu 	NETBSD32TO64_UAP(len);
    372  1.1      manu 	NETBSD32TO64_UAP(flags);
    373  1.1      manu 	SCARG(&ua, from) = NULL;
    374  1.1      manu 	SCARG(&ua, fromlenaddr) = NULL;
    375  1.1      manu 
    376  1.1      manu 	return sys_recvfrom(l, &ua, retval);
    377  1.1      manu }
    378  1.6  christos 
    379  1.6  christos int
    380  1.6  christos linux32_ioctl_socket(struct lwp *l, const struct linux32_sys_ioctl_args *uap, register_t *retval)
    381  1.6  christos {
    382  1.6  christos 	/* {
    383  1.6  christos 		syscallarg(int) fd;
    384  1.6  christos 		syscallarg(u_long) com;
    385  1.6  christos 		syscallarg(void *) data;
    386  1.6  christos 	} */
    387  1.6  christos 	u_long com;
    388  1.6  christos 	int error = 0, isdev = 0, dosys = 1;
    389  1.6  christos 	struct netbsd32_ioctl_args ia;
    390  1.6  christos 	file_t *fp;
    391  1.6  christos 	struct vnode *vp;
    392  1.6  christos 	int (*ioctlf)(file_t *, u_long, void *);
    393  1.6  christos 	struct ioctl_pt pt;
    394  1.6  christos 
    395  1.6  christos 	if ((fp = fd_getfile(SCARG(uap, fd))) == NULL)
    396  1.6  christos 		return (EBADF);
    397  1.6  christos 
    398  1.6  christos 	if (fp->f_type == DTYPE_VNODE) {
    399  1.6  christos 		vp = (struct vnode *)fp->f_data;
    400  1.6  christos 		isdev = vp->v_type == VCHR;
    401  1.6  christos 	}
    402  1.6  christos 
    403  1.6  christos 	/*
    404  1.6  christos 	 * Don't try to interpret socket ioctl calls that are done
    405  1.6  christos 	 * on a device filedescriptor, just pass them through, to
    406  1.6  christos 	 * emulate Linux behaviour. Use PTIOCLINUX so that the
    407  1.6  christos 	 * device will only handle these if it's prepared to do
    408  1.6  christos 	 * so, to avoid unexpected things from happening.
    409  1.6  christos 	 */
    410  1.6  christos 	if (isdev) {
    411  1.6  christos 		dosys = 0;
    412  1.6  christos 		ioctlf = fp->f_ops->fo_ioctl;
    413  1.6  christos 		pt.com = SCARG(uap, com);
    414  1.6  christos 		pt.data = (void *)NETBSD32PTR64(SCARG(uap, data));
    415  1.6  christos 		error = ioctlf(fp, PTIOCLINUX, &pt);
    416  1.6  christos 		/*
    417  1.6  christos 		 * XXX hack: if the function returns EJUSTRETURN,
    418  1.6  christos 		 * it has stuffed a sysctl return value in pt.data.
    419  1.6  christos 		 */
    420  1.6  christos 		if (error == EJUSTRETURN) {
    421  1.6  christos 			retval[0] = (register_t)pt.data;
    422  1.6  christos 			error = 0;
    423  1.6  christos 		}
    424  1.6  christos 		goto out;
    425  1.6  christos 	}
    426  1.6  christos 
    427  1.6  christos 	com = SCARG(uap, com);
    428  1.6  christos 	retval[0] = 0;
    429  1.6  christos 
    430  1.6  christos 	switch (com) {
    431  1.6  christos 	case LINUX_SIOCGIFCONF:
    432  1.7     njoly 		SCARG(&ia, com) = OOSIOCGIFCONF32;
    433  1.6  christos 		break;
    434  1.6  christos 	case LINUX_SIOCGIFFLAGS:
    435  1.6  christos 		SCARG(&ia, com) = OSIOCGIFFLAGS;
    436  1.6  christos 		break;
    437  1.6  christos 	case LINUX_SIOCSIFFLAGS:
    438  1.6  christos 		SCARG(&ia, com) = OSIOCSIFFLAGS;
    439  1.6  christos 		break;
    440  1.6  christos 	case LINUX_SIOCGIFADDR:
    441  1.6  christos 		SCARG(&ia, com) = OOSIOCGIFADDR;
    442  1.6  christos 		break;
    443  1.6  christos 	case LINUX_SIOCGIFDSTADDR:
    444  1.6  christos 		SCARG(&ia, com) = OOSIOCGIFDSTADDR;
    445  1.6  christos 		break;
    446  1.6  christos 	case LINUX_SIOCGIFBRDADDR:
    447  1.6  christos 		SCARG(&ia, com) = OOSIOCGIFBRDADDR;
    448  1.6  christos 		break;
    449  1.6  christos 	case LINUX_SIOCGIFNETMASK:
    450  1.6  christos 		SCARG(&ia, com) = OOSIOCGIFNETMASK;
    451  1.6  christos 		break;
    452  1.6  christos 	case LINUX_SIOCADDMULTI:
    453  1.6  christos 		SCARG(&ia, com) = OSIOCADDMULTI;
    454  1.6  christos 		break;
    455  1.6  christos 	case LINUX_SIOCDELMULTI:
    456  1.6  christos 		SCARG(&ia, com) = OSIOCDELMULTI;
    457  1.6  christos 		break;
    458  1.6  christos #ifdef notyet
    459  1.6  christos 	case LINUX_SIOCGIFHWADDR:
    460  1.6  christos 		error = linux_getifhwaddr(l, retval, SCARG(uap, fd),
    461  1.6  christos 		    SCARG(uap, data));
    462  1.6  christos 		dosys = 0;
    463  1.6  christos 		break;
    464  1.6  christos #endif
    465  1.6  christos 	default:
    466  1.6  christos 		error = EINVAL;
    467  1.6  christos 	}
    468  1.6  christos 
    469  1.6  christos  out:
    470  1.6  christos  	fd_putfile(SCARG(uap, fd));
    471  1.6  christos 
    472  1.6  christos 	if (error == 0 && dosys) {
    473  1.6  christos 		SCARG(&ia, fd) = SCARG(uap, fd);
    474  1.6  christos 		SCARG(&ia, data) = SCARG(uap, data);
    475  1.6  christos 		error = netbsd32_ioctl(curlwp, &ia, retval);
    476  1.6  christos 	}
    477  1.6  christos 
    478  1.6  christos 	return error;
    479  1.6  christos }
    480