xref: /netbsd-src/sys/compat/linux/common/linux_socketcall.h (revision dc306354b0b29af51801a7632f1e95265a68cd81)
1 /*	$NetBSD: linux_socketcall.h,v 1.4 1998/10/04 00:02:44 fvdl 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__)
75 /* Used on: arm, i386, m68k, mips, ppc, sparc, sparc64 */
76 /* Not used on: alpha */
77 
78 /*
79  * Values passed to the Linux socketcall() syscall, determining the actual
80  * action to take.
81  */
82 
83 #define LINUX_SYS_socket	1
84 #define LINUX_SYS_bind		2
85 #define LINUX_SYS_connect	3
86 #define LINUX_SYS_listen	4
87 #define LINUX_SYS_accept	5
88 #define LINUX_SYS_getsockname	6
89 #define LINUX_SYS_getpeername	7
90 #define LINUX_SYS_socketpair	8
91 #define LINUX_SYS_send		9
92 #define LINUX_SYS_recv		10
93 #define LINUX_SYS_sendto	11
94 #define LINUX_SYS_recvfrom	12
95 #define LINUX_SYS_shutdown	13
96 #define LINUX_SYS_setsockopt	14
97 #define LINUX_SYS_getsockopt	15
98 #define LINUX_SYS_sendmsg	16
99 #define LINUX_SYS_recvmsg	17
100 
101 #define LINUX_MAX_SOCKETCALL	17
102 
103 
104 /*
105  * Structures for the arguments of the different system calls. This looks
106  * a little better than copyin() of all values one by one.
107  */
108 
109 /* !!!: This should be at least as large as any other struct here. */
110 struct linux_socketcall_dummy_args {
111 	int dummy_ints[4];		/* Max 4 ints */
112 	void * dummy_ptrs[3];		/* Max 3 pointers */
113 };
114 
115 struct linux_sys_socket_args {
116 	syscallarg(int) domain;
117 	syscallarg(int) type;
118 	syscallarg(int) protocol;
119 };
120 
121 struct linux_sys_socketpair_args {
122 	syscallarg(int) domain;
123 	syscallarg(int) type;
124 	syscallarg(int) protocol;
125 	syscallarg(int *) rsv;
126 };
127 
128 struct linux_sys_sendto_args {
129 	syscallarg(int) s;
130 	syscallarg(void *) msg;
131 	syscallarg(int) len;
132 	syscallarg(int) flags;
133 	syscallarg(struct sockaddr *) to;
134 	syscallarg(int) tolen;
135 };
136 
137 struct linux_sys_recvfrom_args {
138 	syscallarg(int) s;
139 	syscallarg(void *) buf;
140 	syscallarg(int) len;
141 	syscallarg(int) flags;
142 	syscallarg(struct sockaddr *) from;
143 	syscallarg(int *) fromlen;
144 };
145 
146 struct linux_sys_setsockopt_args {
147 	syscallarg(int) s;
148 	syscallarg(int) level;
149 	syscallarg(int) optname;
150 	syscallarg(void *) optval;
151 	syscallarg(int) optlen;
152 };
153 
154 struct linux_sys_getsockopt_args {
155 	syscallarg(int) s;
156 	syscallarg(int) level;
157 	syscallarg(int) optname;
158 	syscallarg(void *) optval;
159 	syscallarg(int *) optlen;
160 };
161 
162 /* These are only used for their size: */
163 
164 struct linux_sys_bind_args {
165 	syscallarg(int) s;
166 	syscallarg(struct sockaddr *) name;
167 	syscallarg(int) namelen;
168 };
169 
170 struct linux_sys_connect_args {
171 	syscallarg(int) s;
172 	syscallarg(struct sockaddr *) name;
173 	syscallarg(int) namelen;
174 };
175 
176 struct linux_sys_listen_args {
177 	syscallarg(int) s;
178 	syscallarg(int) backlog;
179 };
180 
181 struct linux_sys_accept_args {
182 	syscallarg(int) s;
183 	syscallarg(struct sockaddr *) addr;
184 	syscallarg(int *) namelen;
185 };
186 
187 struct linux_sys_getsockname_args {
188 	syscallarg(int) s;
189 	syscallarg(struct sockaddr *) addr;
190 	syscallarg(int *) namelen;
191 };
192 
193 struct linux_sys_getpeername_args {
194 	syscallarg(int) s;
195 	syscallarg(struct sockaddr *) addr;
196 	syscallarg(int *) namelen;
197 };
198 
199 struct linux_sys_send_args {
200 	syscallarg(int) s;
201 	syscallarg(void *) msg;
202 	syscallarg(int) len;
203 	syscallarg(int) flags;
204 };
205 
206 struct linux_sys_recv_args {
207 	syscallarg(int) s;
208 	syscallarg(void *) msg;
209 	syscallarg(int) len;
210 	syscallarg(int) flags;
211 };
212 
213 struct linux_sys_shutdown_args {
214 	syscallarg(int) s;
215 	syscallarg(int) how;
216 };
217 
218 struct linux_sys_sendmsg_args {
219 	syscallarg(int) s;
220 	syscallarg(struct msghdr *) msg;
221 	syscallarg(u_int) flags;
222 };
223 
224 struct linux_sys_recvmsg_args {
225 	syscallarg(int) s;
226 	syscallarg(struct msghdr *) msg;
227 	syscallarg(u_int) flags;
228 };
229 
230 # ifdef _KERNEL
231 __BEGIN_DECLS
232 int linux_sys_socket __P((struct proc *, void *, register_t *));
233 int linux_sys_socketpair __P((struct proc *, void *, register_t *));
234 int linux_sys_sendto __P((struct proc *, void *, register_t *));
235 int linux_sys_recvfrom __P((struct proc *, void *, register_t *));
236 int linux_sys_setsockopt __P((struct proc *, void *, register_t *));
237 int linux_sys_getsockopt __P((struct proc *, void *, register_t *));
238 __END_DECLS
239 # endif /* !_KERNEL */
240 
241 # endif
242 
243 #endif /* !_LINUX_SOCKETCALL_H */
244