xref: /netbsd-src/sys/compat/linux/common/linux_socketcall.h (revision bfb6cb13d599546df69c7e4d20d70e22e15a549d)
1 /*	$NetBSD: linux_socketcall.h,v 1.12 2007/03/04 06:01:24 christos Exp $	*/
2 
3 /*-
4  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Frank van der Linden and Eric Haszlakiewicz.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *	This product includes software developed by the NetBSD
21  *	Foundation, Inc. and its contributors.
22  * 4. Neither the name of The NetBSD Foundation nor the names of its
23  *    contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 /*
40  * Copyright (c) 1995 Frank van der Linden
41  * All rights reserved.
42  *
43  * Redistribution and use in source and binary forms, with or without
44  * modification, are permitted provided that the following conditions
45  * are met:
46  * 1. Redistributions of source code must retain the above copyright
47  *    notice, this list of conditions and the following disclaimer.
48  * 2. Redistributions in binary form must reproduce the above copyright
49  *    notice, this list of conditions and the following disclaimer in the
50  *    documentation and/or other materials provided with the distribution.
51  * 3. All advertising materials mentioning features or use of this software
52  *    must display the following acknowledgement:
53  *      This product includes software developed for the NetBSD Project
54  *      by Frank van der Linden
55  * 4. The name of the author may not be used to endorse or promote products
56  *    derived from this software without specific prior written permission
57  *
58  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
59  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
60  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
61  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
62  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
64  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
65  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
66  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
67  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
68  */
69 
70 #ifndef _LINUX_SOCKETCALL_H
71 #define _LINUX_SOCKETCALL_H
72 
73 /* Alpha does not use the socketcall multiplexer */
74 #if !defined(__alpha__) && !defined(__amd64__) && !defined(COMPAT_LINUX32)
75 /* Used on: arm, i386, m68k, mips, ppc, sparc, sparc64 */
76 /* Used for COMPAT_LINUX32 on amd64 */
77 /* Not used on: alpha */
78 
79 /*
80  * Values passed to the Linux socketcall() syscall, determining the actual
81  * action to take.
82  */
83 
84 #define LINUX_SYS_socket	1
85 #define LINUX_SYS_bind		2
86 #define LINUX_SYS_connect	3
87 #define LINUX_SYS_listen	4
88 #define LINUX_SYS_accept	5
89 #define LINUX_SYS_getsockname	6
90 #define LINUX_SYS_getpeername	7
91 #define LINUX_SYS_socketpair	8
92 #define LINUX_SYS_send		9
93 #define LINUX_SYS_recv		10
94 #define LINUX_SYS_sendto	11
95 #define LINUX_SYS_recvfrom	12
96 #define LINUX_SYS_shutdown	13
97 #define LINUX_SYS_setsockopt	14
98 #define LINUX_SYS_getsockopt	15
99 #define LINUX_SYS_sendmsg	16
100 #define LINUX_SYS_recvmsg	17
101 
102 #define LINUX_MAX_SOCKETCALL	17
103 
104 
105 /*
106  * Structures for the arguments of the different system calls. This looks
107  * a little better than copyin() of all values one by one.
108  */
109 
110 /* !!!: This should be at least as large as any other struct here. */
111 struct linux_socketcall_dummy_args {
112 	int dummy_ints[4];		/* Max 4 ints */
113 	void *dummy_ptrs[3];		/* Max 3 pointers */
114 };
115 
116 struct linux_sys_socket_args {
117 	syscallarg(int) domain;
118 	syscallarg(int) type;
119 	syscallarg(int) protocol;
120 };
121 
122 struct linux_sys_socketpair_args {
123 	syscallarg(int) domain;
124 	syscallarg(int) type;
125 	syscallarg(int) protocol;
126 	syscallarg(int *) rsv;
127 };
128 
129 struct linux_sys_sendto_args {
130 	syscallarg(int) s;
131 	syscallarg(void *) msg;
132 	syscallarg(int) len;
133 	syscallarg(int) flags;
134 	syscallarg(struct osockaddr *) to;
135 	syscallarg(int) tolen;
136 };
137 
138 struct linux_sys_recvfrom_args {
139 	syscallarg(int) s;
140 	syscallarg(void *) buf;
141 	syscallarg(int) len;
142 	syscallarg(int) flags;
143 	syscallarg(struct osockaddr *) from;
144 	syscallarg(int *) fromlenaddr;
145 };
146 
147 struct linux_sys_setsockopt_args {
148 	syscallarg(int) s;
149 	syscallarg(int) level;
150 	syscallarg(int) optname;
151 	syscallarg(void *) optval;
152 	syscallarg(int) optlen;
153 };
154 
155 struct linux_sys_getsockopt_args {
156 	syscallarg(int) s;
157 	syscallarg(int) level;
158 	syscallarg(int) optname;
159 	syscallarg(void *) optval;
160 	syscallarg(int *) optlen;
161 };
162 
163 struct linux_sys_bind_args {
164 	syscallarg(int) s;
165 	syscallarg(struct osockaddr *) name;
166 	syscallarg(int) namelen;
167 };
168 
169 struct linux_sys_connect_args {
170 	syscallarg(int) s;
171 	syscallarg(struct osockaddr *) name;
172 	syscallarg(int) namelen;
173 };
174 
175 struct linux_sys_accept_args {
176 	syscallarg(int) s;
177 	syscallarg(struct osockaddr *) name;
178 	syscallarg(int *) anamelen;
179 };
180 
181 struct linux_sys_getsockname_args {
182 	syscallarg(int) fdes;
183 	syscallarg(struct osockaddr *) asa;
184 	syscallarg(int *) alen;
185 };
186 
187 struct linux_sys_getpeername_args {
188 	syscallarg(int) fdes;
189 	syscallarg(struct osockaddr *) asa;
190 	syscallarg(int *) alen;
191 };
192 
193 struct linux_sys_sendmsg_args {
194 	syscallarg(int) s;
195 	syscallarg(struct msghdr *) msg;
196 	syscallarg(u_int) flags;
197 };
198 
199 struct linux_sys_recvmsg_args {
200 	syscallarg(int) s;
201 	syscallarg(struct msghdr *) msg;
202 	syscallarg(u_int) flags;
203 };
204 
205 struct linux_sys_send_args {
206 	syscallarg(int) s;
207 	syscallarg(void *) buf;
208 	syscallarg(int) len;
209 	syscallarg(int) flags;
210 };
211 
212 struct linux_sys_recv_args {
213 	syscallarg(int) s;
214 	syscallarg(void *) buf;
215 	syscallarg(int) len;
216 	syscallarg(int) flags;
217 };
218 
219 /* These are only used for their size: */
220 
221 struct linux_sys_listen_args {
222 	syscallarg(int) s;
223 	syscallarg(int) backlog;
224 };
225 
226 struct linux_sys_shutdown_args {
227 	syscallarg(int) s;
228 	syscallarg(int) how;
229 };
230 
231 # ifdef _KERNEL
232 __BEGIN_DECLS
233 int linux_sys_socket __P((struct lwp *, void *, register_t *));
234 int linux_sys_socketpair __P((struct lwp *, void *, register_t *));
235 int linux_sys_sendto __P((struct lwp *, void *, register_t *));
236 int linux_sys_recvfrom __P((struct lwp *, void *, register_t *));
237 int linux_sys_setsockopt __P((struct lwp *, void *, register_t *));
238 int linux_sys_getsockopt __P((struct lwp *, void *, register_t *));
239 int linux_sys_connect __P((struct lwp *, void *, register_t *));
240 int linux_sys_bind __P((struct lwp *, void *, register_t *));
241 int linux_sys_getsockname __P((struct lwp *, void *, register_t *));
242 int linux_sys_getpeername __P((struct lwp *, void *, register_t *));
243 int linux_sys_sendmsg __P((struct lwp *, void *, register_t *));
244 int linux_sys_recvmsg __P((struct lwp *, void *, register_t *));
245 int linux_sys_recv __P((struct lwp *, void *, register_t *));
246 int linux_sys_send __P((struct lwp *, void *, register_t *));
247 int linux_sys_accept __P((struct lwp *, void *, register_t *));
248 __END_DECLS
249 # endif /* !_KERNEL */
250 
251 # endif
252 
253 #endif /* !_LINUX_SOCKETCALL_H */
254