netbsd32_socket.c revision 1.1.2.2 1 1.1.2.2 bouyer /* $NetBSD: netbsd32_socket.c,v 1.1.2.2 2001/02/11 19:14:17 bouyer Exp $ */
2 1.1.2.2 bouyer
3 1.1.2.2 bouyer /*
4 1.1.2.2 bouyer * Copyright (c) 1998, 2001 Matthew R. Green
5 1.1.2.2 bouyer * All rights reserved.
6 1.1.2.2 bouyer *
7 1.1.2.2 bouyer * Redistribution and use in source and binary forms, with or without
8 1.1.2.2 bouyer * modification, are permitted provided that the following conditions
9 1.1.2.2 bouyer * are met:
10 1.1.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
11 1.1.2.2 bouyer * notice, this list of conditions and the following disclaimer.
12 1.1.2.2 bouyer * 2. Redistributions in binary form must reproduce the above copyright
13 1.1.2.2 bouyer * notice, this list of conditions and the following disclaimer in the
14 1.1.2.2 bouyer * documentation and/or other materials provided with the distribution.
15 1.1.2.2 bouyer * 3. The name of the author may not be used to endorse or promote products
16 1.1.2.2 bouyer * derived from this software without specific prior written permission.
17 1.1.2.2 bouyer *
18 1.1.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 1.1.2.2 bouyer * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 1.1.2.2 bouyer * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 1.1.2.2 bouyer * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 1.1.2.2 bouyer * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 1.1.2.2 bouyer * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 1.1.2.2 bouyer * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 1.1.2.2 bouyer * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 1.1.2.2 bouyer * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 1.1.2.2 bouyer * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 1.1.2.2 bouyer * SUCH DAMAGE.
29 1.1.2.2 bouyer */
30 1.1.2.2 bouyer
31 1.1.2.2 bouyer #if defined(_KERNEL) && !defined(_LKM)
32 1.1.2.2 bouyer #include "opt_ktrace.h"
33 1.1.2.2 bouyer #endif
34 1.1.2.2 bouyer
35 1.1.2.2 bouyer /*
36 1.1.2.2 bouyer * Though COMPAT_OLDSOCK is needed only for COMPAT_43, SunOS, Linux,
37 1.1.2.2 bouyer * HP-UX, FreeBSD, Ultrix, OSF1, we define it unconditionally so that
38 1.1.2.2 bouyer * this would be LKM-safe.
39 1.1.2.2 bouyer */
40 1.1.2.2 bouyer #define COMPAT_OLDSOCK /* used by <sys/socket.h> */
41 1.1.2.2 bouyer
42 1.1.2.2 bouyer #include <sys/param.h>
43 1.1.2.2 bouyer #include <sys/systm.h>
44 1.1.2.2 bouyer #define msg __msg /* Don't ask me! */
45 1.1.2.2 bouyer #include <sys/malloc.h>
46 1.1.2.2 bouyer #include <sys/mount.h>
47 1.1.2.2 bouyer #include <sys/socket.h>
48 1.1.2.2 bouyer #include <sys/sockio.h>
49 1.1.2.2 bouyer #include <sys/socketvar.h>
50 1.1.2.2 bouyer #include <sys/mbuf.h>
51 1.1.2.2 bouyer #include <sys/ktrace.h>
52 1.1.2.2 bouyer #include <sys/file.h>
53 1.1.2.2 bouyer #include <sys/filedesc.h>
54 1.1.2.2 bouyer #include <sys/syscallargs.h>
55 1.1.2.2 bouyer #include <sys/proc.h>
56 1.1.2.2 bouyer
57 1.1.2.2 bouyer #include <compat/netbsd32/netbsd32.h>
58 1.1.2.2 bouyer #include <compat/netbsd32/netbsd32_syscallargs.h>
59 1.1.2.2 bouyer #include <compat/netbsd32/netbsd32_conv.h>
60 1.1.2.2 bouyer
61 1.1.2.2 bouyer /* note that the netbsd32_msghdr's iov really points to a struct iovec, not a netbsd32_iovec. */
62 1.1.2.2 bouyer static int recvit32 __P((struct proc *, int, struct netbsd32_msghdr *, struct iovec *, caddr_t,
63 1.1.2.2 bouyer register_t *));
64 1.1.2.2 bouyer
65 1.1.2.2 bouyer int
66 1.1.2.2 bouyer netbsd32_recvmsg(p, v, retval)
67 1.1.2.2 bouyer struct proc *p;
68 1.1.2.2 bouyer void *v;
69 1.1.2.2 bouyer register_t *retval;
70 1.1.2.2 bouyer {
71 1.1.2.2 bouyer struct netbsd32_recvmsg_args /* {
72 1.1.2.2 bouyer syscallarg(int) s;
73 1.1.2.2 bouyer syscallarg(netbsd32_msghdrp_t) msg;
74 1.1.2.2 bouyer syscallarg(int) flags;
75 1.1.2.2 bouyer } */ *uap = v;
76 1.1.2.2 bouyer struct netbsd32_msghdr msg;
77 1.1.2.2 bouyer struct iovec aiov[UIO_SMALLIOV], *uiov, *iov;
78 1.1.2.2 bouyer int error;
79 1.1.2.2 bouyer
80 1.1.2.2 bouyer error = copyin((caddr_t)(u_long)SCARG(uap, msg), (caddr_t)&msg,
81 1.1.2.2 bouyer sizeof(msg));
82 1.1.2.2 bouyer /* netbsd32_msghdr needs the iov pre-allocated */
83 1.1.2.2 bouyer if (error)
84 1.1.2.2 bouyer return (error);
85 1.1.2.2 bouyer if ((u_int)msg.msg_iovlen > UIO_SMALLIOV) {
86 1.1.2.2 bouyer if ((u_int)msg.msg_iovlen > IOV_MAX)
87 1.1.2.2 bouyer return (EMSGSIZE);
88 1.1.2.2 bouyer MALLOC(iov, struct iovec *,
89 1.1.2.2 bouyer sizeof(struct iovec) * (u_int)msg.msg_iovlen, M_IOV,
90 1.1.2.2 bouyer M_WAITOK);
91 1.1.2.2 bouyer } else if ((u_int)msg.msg_iovlen > 0)
92 1.1.2.2 bouyer iov = aiov;
93 1.1.2.2 bouyer else
94 1.1.2.2 bouyer return (EMSGSIZE);
95 1.1.2.2 bouyer #ifdef COMPAT_OLDSOCK
96 1.1.2.2 bouyer msg.msg_flags = SCARG(uap, flags) &~ MSG_COMPAT;
97 1.1.2.2 bouyer #else
98 1.1.2.2 bouyer msg.msg_flags = SCARG(uap, flags);
99 1.1.2.2 bouyer #endif
100 1.1.2.2 bouyer uiov = (struct iovec *)(u_long)msg.msg_iov;
101 1.1.2.2 bouyer error = netbsd32_to_iovecin((struct netbsd32_iovec *)uiov,
102 1.1.2.2 bouyer iov, msg.msg_iovlen);
103 1.1.2.2 bouyer if (error)
104 1.1.2.2 bouyer goto done;
105 1.1.2.2 bouyer if ((error = recvit32(p, SCARG(uap, s), &msg, iov, (caddr_t)0, retval)) == 0) {
106 1.1.2.2 bouyer error = copyout((caddr_t)&msg, (caddr_t)(u_long)SCARG(uap, msg),
107 1.1.2.2 bouyer sizeof(msg));
108 1.1.2.2 bouyer }
109 1.1.2.2 bouyer done:
110 1.1.2.2 bouyer if (iov != aiov)
111 1.1.2.2 bouyer FREE(iov, M_IOV);
112 1.1.2.2 bouyer return (error);
113 1.1.2.2 bouyer }
114 1.1.2.2 bouyer
115 1.1.2.2 bouyer int
116 1.1.2.2 bouyer recvit32(p, s, mp, iov, namelenp, retsize)
117 1.1.2.2 bouyer struct proc *p;
118 1.1.2.2 bouyer int s;
119 1.1.2.2 bouyer struct netbsd32_msghdr *mp;
120 1.1.2.2 bouyer struct iovec *iov;
121 1.1.2.2 bouyer caddr_t namelenp;
122 1.1.2.2 bouyer register_t *retsize;
123 1.1.2.2 bouyer {
124 1.1.2.2 bouyer struct file *fp;
125 1.1.2.2 bouyer struct uio auio;
126 1.1.2.2 bouyer int i;
127 1.1.2.2 bouyer int len, error;
128 1.1.2.2 bouyer struct mbuf *from = 0, *control = 0;
129 1.1.2.2 bouyer struct socket *so;
130 1.1.2.2 bouyer #ifdef KTRACE
131 1.1.2.2 bouyer struct iovec *ktriov = NULL;
132 1.1.2.2 bouyer #endif
133 1.1.2.2 bouyer
134 1.1.2.2 bouyer /* getsock() will use the descriptor for us */
135 1.1.2.2 bouyer if ((error = getsock(p->p_fd, s, &fp)) != 0)
136 1.1.2.2 bouyer return (error);
137 1.1.2.2 bouyer auio.uio_iov = iov;
138 1.1.2.2 bouyer auio.uio_iovcnt = mp->msg_iovlen;
139 1.1.2.2 bouyer auio.uio_segflg = UIO_USERSPACE;
140 1.1.2.2 bouyer auio.uio_rw = UIO_READ;
141 1.1.2.2 bouyer auio.uio_procp = p;
142 1.1.2.2 bouyer auio.uio_offset = 0; /* XXX */
143 1.1.2.2 bouyer auio.uio_resid = 0;
144 1.1.2.2 bouyer for (i = 0; i < mp->msg_iovlen; i++, iov++) {
145 1.1.2.2 bouyer #if 0
146 1.1.2.2 bouyer /* cannot happen iov_len is unsigned */
147 1.1.2.2 bouyer if (iov->iov_len < 0) {
148 1.1.2.2 bouyer error = EINVAL;
149 1.1.2.2 bouyer goto out1;
150 1.1.2.2 bouyer }
151 1.1.2.2 bouyer #endif
152 1.1.2.2 bouyer /*
153 1.1.2.2 bouyer * Reads return ssize_t because -1 is returned on error.
154 1.1.2.2 bouyer * Therefore we must restrict the length to SSIZE_MAX to
155 1.1.2.2 bouyer * avoid garbage return values.
156 1.1.2.2 bouyer */
157 1.1.2.2 bouyer auio.uio_resid += iov->iov_len;
158 1.1.2.2 bouyer if (iov->iov_len > SSIZE_MAX || auio.uio_resid > SSIZE_MAX) {
159 1.1.2.2 bouyer error = EINVAL;
160 1.1.2.2 bouyer goto out1;
161 1.1.2.2 bouyer }
162 1.1.2.2 bouyer }
163 1.1.2.2 bouyer #ifdef KTRACE
164 1.1.2.2 bouyer if (KTRPOINT(p, KTR_GENIO)) {
165 1.1.2.2 bouyer int iovlen = auio.uio_iovcnt * sizeof(struct iovec);
166 1.1.2.2 bouyer
167 1.1.2.2 bouyer MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK);
168 1.1.2.2 bouyer memcpy((caddr_t)ktriov, (caddr_t)auio.uio_iov, iovlen);
169 1.1.2.2 bouyer }
170 1.1.2.2 bouyer #endif
171 1.1.2.2 bouyer len = auio.uio_resid;
172 1.1.2.2 bouyer so = (struct socket *)fp->f_data;
173 1.1.2.2 bouyer error = (*so->so_receive)(so, &from, &auio, NULL,
174 1.1.2.2 bouyer mp->msg_control ? &control : NULL, &mp->msg_flags);
175 1.1.2.2 bouyer if (error) {
176 1.1.2.2 bouyer if (auio.uio_resid != len && (error == ERESTART ||
177 1.1.2.2 bouyer error == EINTR || error == EWOULDBLOCK))
178 1.1.2.2 bouyer error = 0;
179 1.1.2.2 bouyer }
180 1.1.2.2 bouyer #ifdef KTRACE
181 1.1.2.2 bouyer if (ktriov != NULL) {
182 1.1.2.2 bouyer if (error == 0)
183 1.1.2.2 bouyer ktrgenio(p, s, UIO_READ, ktriov,
184 1.1.2.2 bouyer len - auio.uio_resid, error);
185 1.1.2.2 bouyer FREE(ktriov, M_TEMP);
186 1.1.2.2 bouyer }
187 1.1.2.2 bouyer #endif
188 1.1.2.2 bouyer if (error)
189 1.1.2.2 bouyer goto out;
190 1.1.2.2 bouyer *retsize = len - auio.uio_resid;
191 1.1.2.2 bouyer if (mp->msg_name) {
192 1.1.2.2 bouyer len = mp->msg_namelen;
193 1.1.2.2 bouyer if (len <= 0 || from == 0)
194 1.1.2.2 bouyer len = 0;
195 1.1.2.2 bouyer else {
196 1.1.2.2 bouyer #ifdef COMPAT_OLDSOCK
197 1.1.2.2 bouyer if (mp->msg_flags & MSG_COMPAT)
198 1.1.2.2 bouyer mtod(from, struct osockaddr *)->sa_family =
199 1.1.2.2 bouyer mtod(from, struct sockaddr *)->sa_family;
200 1.1.2.2 bouyer #endif
201 1.1.2.2 bouyer if (len > from->m_len)
202 1.1.2.2 bouyer len = from->m_len;
203 1.1.2.2 bouyer /* else if len < from->m_len ??? */
204 1.1.2.2 bouyer error = copyout(mtod(from, caddr_t),
205 1.1.2.2 bouyer (caddr_t)(u_long)mp->msg_name, (unsigned)len);
206 1.1.2.2 bouyer if (error)
207 1.1.2.2 bouyer goto out;
208 1.1.2.2 bouyer }
209 1.1.2.2 bouyer mp->msg_namelen = len;
210 1.1.2.2 bouyer if (namelenp &&
211 1.1.2.2 bouyer (error = copyout((caddr_t)&len, namelenp, sizeof(int)))) {
212 1.1.2.2 bouyer #ifdef COMPAT_OLDSOCK
213 1.1.2.2 bouyer if (mp->msg_flags & MSG_COMPAT)
214 1.1.2.2 bouyer error = 0; /* old recvfrom didn't check */
215 1.1.2.2 bouyer else
216 1.1.2.2 bouyer #endif
217 1.1.2.2 bouyer goto out;
218 1.1.2.2 bouyer }
219 1.1.2.2 bouyer }
220 1.1.2.2 bouyer if (mp->msg_control) {
221 1.1.2.2 bouyer #ifdef COMPAT_OLDSOCK
222 1.1.2.2 bouyer /*
223 1.1.2.2 bouyer * We assume that old recvmsg calls won't receive access
224 1.1.2.2 bouyer * rights and other control info, esp. as control info
225 1.1.2.2 bouyer * is always optional and those options didn't exist in 4.3.
226 1.1.2.2 bouyer * If we receive rights, trim the cmsghdr; anything else
227 1.1.2.2 bouyer * is tossed.
228 1.1.2.2 bouyer */
229 1.1.2.2 bouyer if (control && mp->msg_flags & MSG_COMPAT) {
230 1.1.2.2 bouyer if (mtod(control, struct cmsghdr *)->cmsg_level !=
231 1.1.2.2 bouyer SOL_SOCKET ||
232 1.1.2.2 bouyer mtod(control, struct cmsghdr *)->cmsg_type !=
233 1.1.2.2 bouyer SCM_RIGHTS) {
234 1.1.2.2 bouyer mp->msg_controllen = 0;
235 1.1.2.2 bouyer goto out;
236 1.1.2.2 bouyer }
237 1.1.2.2 bouyer control->m_len -= sizeof(struct cmsghdr);
238 1.1.2.2 bouyer control->m_data += sizeof(struct cmsghdr);
239 1.1.2.2 bouyer }
240 1.1.2.2 bouyer #endif
241 1.1.2.2 bouyer len = mp->msg_controllen;
242 1.1.2.2 bouyer if (len <= 0 || control == 0)
243 1.1.2.2 bouyer len = 0;
244 1.1.2.2 bouyer else {
245 1.1.2.2 bouyer struct mbuf *m = control;
246 1.1.2.2 bouyer caddr_t p = (caddr_t)(u_long)mp->msg_control;
247 1.1.2.2 bouyer
248 1.1.2.2 bouyer do {
249 1.1.2.2 bouyer i = m->m_len;
250 1.1.2.2 bouyer if (len < i) {
251 1.1.2.2 bouyer mp->msg_flags |= MSG_CTRUNC;
252 1.1.2.2 bouyer i = len;
253 1.1.2.2 bouyer }
254 1.1.2.2 bouyer error = copyout(mtod(m, caddr_t), p,
255 1.1.2.2 bouyer (unsigned)i);
256 1.1.2.2 bouyer if (m->m_next)
257 1.1.2.2 bouyer i = ALIGN(i);
258 1.1.2.2 bouyer p += i;
259 1.1.2.2 bouyer len -= i;
260 1.1.2.2 bouyer if (error != 0 || len <= 0)
261 1.1.2.2 bouyer break;
262 1.1.2.2 bouyer } while ((m = m->m_next) != NULL);
263 1.1.2.2 bouyer len = p - (caddr_t)(u_long)mp->msg_control;
264 1.1.2.2 bouyer }
265 1.1.2.2 bouyer mp->msg_controllen = len;
266 1.1.2.2 bouyer }
267 1.1.2.2 bouyer out:
268 1.1.2.2 bouyer if (from)
269 1.1.2.2 bouyer m_freem(from);
270 1.1.2.2 bouyer if (control)
271 1.1.2.2 bouyer m_freem(control);
272 1.1.2.2 bouyer out1:
273 1.1.2.2 bouyer FILE_UNUSE(fp, p);
274 1.1.2.2 bouyer return (error);
275 1.1.2.2 bouyer }
276 1.1.2.2 bouyer
277 1.1.2.2 bouyer int
278 1.1.2.2 bouyer netbsd32_sendmsg(p, v, retval)
279 1.1.2.2 bouyer struct proc *p;
280 1.1.2.2 bouyer void *v;
281 1.1.2.2 bouyer register_t *retval;
282 1.1.2.2 bouyer {
283 1.1.2.2 bouyer struct netbsd32_sendmsg_args /* {
284 1.1.2.2 bouyer syscallarg(int) s;
285 1.1.2.2 bouyer syscallarg(const netbsd32_msghdrp_t) msg;
286 1.1.2.2 bouyer syscallarg(int) flags;
287 1.1.2.2 bouyer } */ *uap = v;
288 1.1.2.2 bouyer struct msghdr msg;
289 1.1.2.2 bouyer struct netbsd32_msghdr msg32;
290 1.1.2.2 bouyer struct iovec aiov[UIO_SMALLIOV], *iov;
291 1.1.2.2 bouyer int error;
292 1.1.2.2 bouyer
293 1.1.2.2 bouyer error = copyin((caddr_t)(u_long)SCARG(uap, msg),
294 1.1.2.2 bouyer (caddr_t)&msg32, sizeof(msg32));
295 1.1.2.2 bouyer if (error)
296 1.1.2.2 bouyer return (error);
297 1.1.2.2 bouyer netbsd32_to_msghdr(&msg32, &msg);
298 1.1.2.2 bouyer if ((u_int)msg.msg_iovlen > UIO_SMALLIOV) {
299 1.1.2.2 bouyer if ((u_int)msg.msg_iovlen > IOV_MAX)
300 1.1.2.2 bouyer return (EMSGSIZE);
301 1.1.2.2 bouyer MALLOC(iov, struct iovec *,
302 1.1.2.2 bouyer sizeof(struct iovec) * (u_int)msg.msg_iovlen, M_IOV,
303 1.1.2.2 bouyer M_WAITOK);
304 1.1.2.2 bouyer } else if ((u_int)msg.msg_iovlen > 0)
305 1.1.2.2 bouyer iov = aiov;
306 1.1.2.2 bouyer else
307 1.1.2.2 bouyer return (EMSGSIZE);
308 1.1.2.2 bouyer error = netbsd32_to_iovecin((struct netbsd32_iovec *)msg.msg_iov,
309 1.1.2.2 bouyer iov, msg.msg_iovlen);
310 1.1.2.2 bouyer if (error)
311 1.1.2.2 bouyer goto done;
312 1.1.2.2 bouyer msg.msg_iov = iov;
313 1.1.2.2 bouyer #ifdef COMPAT_OLDSOCK
314 1.1.2.2 bouyer msg.msg_flags = 0;
315 1.1.2.2 bouyer #endif
316 1.1.2.2 bouyer /* Luckily we can use this directly */
317 1.1.2.2 bouyer error = sendit(p, SCARG(uap, s), &msg, SCARG(uap, flags), retval);
318 1.1.2.2 bouyer done:
319 1.1.2.2 bouyer if (iov != aiov)
320 1.1.2.2 bouyer FREE(iov, M_IOV);
321 1.1.2.2 bouyer return (error);
322 1.1.2.2 bouyer }
323 1.1.2.2 bouyer
324 1.1.2.2 bouyer int
325 1.1.2.2 bouyer netbsd32_recvfrom(p, v, retval)
326 1.1.2.2 bouyer struct proc *p;
327 1.1.2.2 bouyer void *v;
328 1.1.2.2 bouyer register_t *retval;
329 1.1.2.2 bouyer {
330 1.1.2.2 bouyer struct netbsd32_recvfrom_args /* {
331 1.1.2.2 bouyer syscallarg(int) s;
332 1.1.2.2 bouyer syscallarg(netbsd32_voidp) buf;
333 1.1.2.2 bouyer syscallarg(netbsd32_size_t) len;
334 1.1.2.2 bouyer syscallarg(int) flags;
335 1.1.2.2 bouyer syscallarg(netbsd32_sockaddrp_t) from;
336 1.1.2.2 bouyer syscallarg(netbsd32_intp) fromlenaddr;
337 1.1.2.2 bouyer } */ *uap = v;
338 1.1.2.2 bouyer struct netbsd32_msghdr msg;
339 1.1.2.2 bouyer struct iovec aiov;
340 1.1.2.2 bouyer int error;
341 1.1.2.2 bouyer
342 1.1.2.2 bouyer if (SCARG(uap, fromlenaddr)) {
343 1.1.2.2 bouyer error = copyin((caddr_t)(u_long)SCARG(uap, fromlenaddr),
344 1.1.2.2 bouyer (caddr_t)&msg.msg_namelen,
345 1.1.2.2 bouyer sizeof(msg.msg_namelen));
346 1.1.2.2 bouyer if (error)
347 1.1.2.2 bouyer return (error);
348 1.1.2.2 bouyer } else
349 1.1.2.2 bouyer msg.msg_namelen = 0;
350 1.1.2.2 bouyer msg.msg_name = SCARG(uap, from);
351 1.1.2.2 bouyer msg.msg_iov = NULL; /* ignored in recvit32(), uses iov */
352 1.1.2.2 bouyer msg.msg_iovlen = 1;
353 1.1.2.2 bouyer aiov.iov_base = (caddr_t)(u_long)SCARG(uap, buf);
354 1.1.2.2 bouyer aiov.iov_len = (u_long)SCARG(uap, len);
355 1.1.2.2 bouyer msg.msg_control = 0;
356 1.1.2.2 bouyer msg.msg_flags = SCARG(uap, flags);
357 1.1.2.2 bouyer return (recvit32(p, SCARG(uap, s), &msg, &aiov,
358 1.1.2.2 bouyer (caddr_t)(u_long)SCARG(uap, fromlenaddr), retval));
359 1.1.2.2 bouyer }
360 1.1.2.2 bouyer
361 1.1.2.2 bouyer int
362 1.1.2.2 bouyer netbsd32_sendto(p, v, retval)
363 1.1.2.2 bouyer struct proc *p;
364 1.1.2.2 bouyer void *v;
365 1.1.2.2 bouyer register_t *retval;
366 1.1.2.2 bouyer {
367 1.1.2.2 bouyer struct netbsd32_sendto_args /* {
368 1.1.2.2 bouyer syscallarg(int) s;
369 1.1.2.2 bouyer syscallarg(const netbsd32_voidp) buf;
370 1.1.2.2 bouyer syscallarg(netbsd32_size_t) len;
371 1.1.2.2 bouyer syscallarg(int) flags;
372 1.1.2.2 bouyer syscallarg(const netbsd32_sockaddrp_t) to;
373 1.1.2.2 bouyer syscallarg(int) tolen;
374 1.1.2.2 bouyer } */ *uap = v;
375 1.1.2.2 bouyer struct msghdr msg;
376 1.1.2.2 bouyer struct iovec aiov;
377 1.1.2.2 bouyer
378 1.1.2.2 bouyer msg.msg_name = (caddr_t)(u_long)SCARG(uap, to); /* XXX kills const */
379 1.1.2.2 bouyer msg.msg_namelen = SCARG(uap, tolen);
380 1.1.2.2 bouyer msg.msg_iov = &aiov;
381 1.1.2.2 bouyer msg.msg_iovlen = 1;
382 1.1.2.2 bouyer msg.msg_control = 0;
383 1.1.2.2 bouyer #ifdef COMPAT_OLDSOCK
384 1.1.2.2 bouyer msg.msg_flags = 0;
385 1.1.2.2 bouyer #endif
386 1.1.2.2 bouyer aiov.iov_base = (char *)(u_long)SCARG(uap, buf); /* XXX kills const */
387 1.1.2.2 bouyer aiov.iov_len = SCARG(uap, len);
388 1.1.2.2 bouyer return (sendit(p, SCARG(uap, s), &msg, SCARG(uap, flags), retval));
389 1.1.2.2 bouyer }
390