1 /* $NetBSD: linux32_socketcall.h,v 1.3 2007/12/20 23:02:58 dsl Exp $ */ 2 3 /*- 4 * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. All advertising materials mentioning features or use of this software 15 * must display the following acknowledgement: 16 * This product includes software developed by Emmanuel Dreyfus 17 * 4. The name of the author may not be used to endorse or promote 18 * products derived from this software without specific prior written 19 * permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE THE AUTHOR AND CONTRIBUTORS ``AS IS'' 22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS 25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 * POSSIBILITY OF SUCH DAMAGE. 32 */ 33 #ifndef _LINUX32_SOCKETCALL_H 34 #define _LINUX32_SOCKETCALL_H 35 36 #define LINUX32_MAX_SOCKETCALL 17 37 38 #ifdef syscallarg 39 #undef syscallarg 40 #endif 41 42 #define syscallarg(x) \ 43 union { \ 44 register32_t pad; \ 45 \ 46 struct { x datum; } le; \ 47 struct { /* LINTED zero array dimension */ \ 48 int8_t pad[ /* CONSTCOND */ \ 49 (sizeof (register32_t) < sizeof (x)) \ 50 ? 0 \ 51 : sizeof (register32_t) - sizeof (x)]; \ 52 x datum; \ 53 } be; \ 54 } 55 56 struct linux32_sys_socket_args { 57 syscallarg(int) domain; 58 syscallarg(int) type; 59 syscallarg(int) protocol; 60 }; 61 62 struct linux32_sys_socketpair_args { 63 syscallarg(int) domain; 64 syscallarg(int) type; 65 syscallarg(int) protocol; 66 syscallarg(netbsd32_intp) rsv; 67 }; 68 69 struct linux32_sys_sendto_args { 70 syscallarg(int) s; 71 syscallarg(netbsd32_voidp) msg; 72 syscallarg(int) len; 73 syscallarg(int) flags; 74 syscallarg(netbsd32_sockaddrp_t) to; 75 syscallarg(int) tolen; 76 }; 77 78 struct linux32_sys_recvfrom_args { 79 syscallarg(int) s; 80 syscallarg(netbsd32_voidp) buf; 81 syscallarg(netbsd32_size_t) len; 82 syscallarg(int) flags; 83 syscallarg(netbsd32_osockaddrp_t) from; 84 syscallarg(netbsd32_intp) fromlenaddr; 85 }; 86 87 struct linux32_sys_setsockopt_args { 88 syscallarg(int) s; 89 syscallarg(int) level; 90 syscallarg(int) optname; 91 syscallarg(netbsd32_voidp) optval; 92 syscallarg(int) optlen; 93 }; 94 95 struct linux32_sys_getsockopt_args { 96 syscallarg(int) s; 97 syscallarg(int) level; 98 syscallarg(int) optname; 99 syscallarg(netbsd32_voidp) optval; 100 syscallarg(netbsd32_intp) optlen; 101 }; 102 103 struct linux32_sys_bind_args { 104 syscallarg(int) s; 105 syscallarg(netbsd32_osockaddrp_t) name; 106 syscallarg(int) namelen; 107 }; 108 109 struct linux32_sys_connect_args { 110 syscallarg(int) s; 111 syscallarg(netbsd32_osockaddrp_t) name; 112 syscallarg(int) namelen; 113 }; 114 115 struct linux32_sys_accept_args { 116 syscallarg(int) s; 117 syscallarg(netbsd32_osockaddrp_t) name; 118 syscallarg(netbsd32_intp) anamelen; 119 }; 120 121 struct linux32_sys_getsockname_args { 122 syscallarg(int) fdec; 123 syscallarg(netbsd32_charp) asa; 124 syscallarg(netbsd32_intp) alen; 125 }; 126 127 struct linux32_sys_getpeername_args { 128 syscallarg(int) fdes; 129 syscallarg(netbsd32_sockaddrp_t) asa; 130 syscallarg(netbsd32_intp) alen; 131 }; 132 133 struct linux32_sys_sendmsg_args { 134 syscallarg(int) s; 135 syscallarg(netbsd32_msghdrp_t) msg; 136 syscallarg(int) flags; 137 }; 138 139 struct linux32_sys_recvmsg_args { 140 syscallarg(int) s; 141 syscallarg(netbsd32_msghdrp_t) msg; 142 syscallarg(int) flags; 143 }; 144 145 struct linux32_sys_send_args { 146 syscallarg(int) s; 147 syscallarg(netbsd32_voidp) buf; 148 syscallarg(int) len; 149 syscallarg(int) flags; 150 }; 151 152 struct linux32_sys_recv_args { 153 syscallarg(int) s; 154 syscallarg(netbsd32_voidp) buf; 155 syscallarg(int) len; 156 syscallarg(int) flags; 157 }; 158 159 union linux32_socketcall_args { 160 struct linux_sys_socket_args socket_args; 161 struct linux32_sys_bind_args bind_args; 162 struct linux32_sys_connect_args connect_args; 163 struct sys_listen_args listen_args; 164 struct linux32_sys_accept_args accept_args; 165 struct linux32_sys_getsockname_args getsockname_args; 166 struct linux32_sys_getpeername_args getpeername_args; 167 struct linux32_sys_socketpair_args socketpair_args; 168 struct linux32_sys_send_args send_args; 169 struct linux32_sys_recv_args recv_args; 170 struct linux32_sys_sendto_args sendto_args; 171 struct linux32_sys_recvfrom_args recvfrom_args; 172 struct sys_shutdown_args shutdown_args; 173 struct linux32_sys_setsockopt_args setsockopt_args; 174 struct linux32_sys_getsockopt_args getsockopt_args; 175 struct linux32_sys_sendmsg_args sendmsg_args; 176 struct linux32_sys_recvmsg_args recvmsg_args; 177 }; 178 179 # ifdef _KERNEL 180 __BEGIN_DECLS 181 #define SYS_DEF(foo) struct foo##_args; \ 182 int foo(struct lwp *, const struct foo##_args *, register_t *) 183 SYS_DEF(linux32_sys_socketpair); 184 SYS_DEF(linux32_sys_sendto); 185 SYS_DEF(linux32_sys_recvfrom); 186 SYS_DEF(linux32_sys_setsockopt); 187 SYS_DEF(linux32_sys_getsockopt); 188 SYS_DEF(linux32_sys_connect); 189 SYS_DEF(linux32_sys_socket); 190 SYS_DEF(linux32_sys_bind); 191 SYS_DEF(linux32_sys_getsockname); 192 SYS_DEF(linux32_sys_getpeername); 193 SYS_DEF(linux32_sys_sendmsg); 194 SYS_DEF(linux32_sys_recvmsg); 195 SYS_DEF(linux32_sys_recv); 196 SYS_DEF(linux32_sys_send); 197 SYS_DEF(linux32_sys_accept); 198 #undef SYS_DEF 199 __END_DECLS 200 # endif /* !_KERNEL */ 201 202 #endif /* !_LINUX32_SOCKETCALL_H */ 203