1 /*	$NetBSD: linux_socketcall.h,v 1.6 2001/07/04 10:09:24 jdolecek 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 osockaddr *) 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 osockaddr *) from;
143 	syscallarg(int *) fromlenaddr;
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 struct linux_sys_bind_args {
163 	syscallarg(int) s;
164 	syscallarg(struct osockaddr *) name;
165 	syscallarg(int) namelen;
166 };
167 
168 struct linux_sys_connect_args {
169 	syscallarg(int) s;
170 	syscallarg(struct osockaddr *) name;
171 	syscallarg(int) namelen;
172 };
173 
174 struct linux_sys_accept_args {
175 	syscallarg(int) s;
176 	syscallarg(struct osockaddr *) name;
177 	syscallarg(int *) anamelen;
178 };
179 
180 struct linux_sys_getsockname_args {
181 	syscallarg(int) fdes;
182 	syscallarg(struct osockaddr *) asa;
183 	syscallarg(int *) alen;
184 };
185 
186 struct linux_sys_getpeername_args {
187 	syscallarg(int) fdes;
188 	syscallarg(struct osockaddr *) asa;
189 	syscallarg(int *) alen;
190 };
191 
192 struct linux_sys_sendmsg_args {
193 	syscallarg(int) s;
194 	syscallarg(struct msghdr *) msg;
195 	syscallarg(u_int) flags;
196 };
197 
198 struct linux_sys_recvmsg_args {
199 	syscallarg(int) s;
200 	syscallarg(struct msghdr *) msg;
201 	syscallarg(u_int) flags;
202 };
203 
204 struct linux_sys_send_args {
205 	syscallarg(int) s;
206 	syscallarg(void *) buf;
207 	syscallarg(int) len;
208 	syscallarg(int) flags;
209 };
210 
211 struct linux_sys_recv_args {
212 	syscallarg(int) s;
213 	syscallarg(void *) buf;
214 	syscallarg(int) len;
215 	syscallarg(int) flags;
216 };
217 
218 /* These are only used for their size: */
219 
220 struct linux_sys_listen_args {
221 	syscallarg(int) s;
222 	syscallarg(int) backlog;
223 };
224 
225 struct linux_sys_shutdown_args {
226 	syscallarg(int) s;
227 	syscallarg(int) how;
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 int linux_sys_connect __P((struct proc *, void *, register_t *));
239 int linux_sys_bind __P((struct proc *, void *, register_t *));
240 int linux_sys_getsockname __P((struct proc *, void *, register_t *));
241 int linux_sys_getpeername __P((struct proc *, void *, register_t *));
242 int linux_sys_sendmsg __P((struct proc *, void *, register_t *));
243 int linux_sys_recvmsg __P((struct proc *, void *, register_t *));
244 int linux_sys_recv __P((struct proc *, void *, register_t *));
245 int linux_sys_send __P((struct proc *, void *, register_t *));
246 int linux_sys_accept __P((struct proc *, void *, register_t *));
247 __END_DECLS
248 # endif /* !_KERNEL */
249 
250 # endif
251 
252 #endif /* !_LINUX_SOCKETCALL_H */
253