Annotation of sys/compat/osf1/osf1_socket.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: osf1_socket.c,v 1.1 2000/08/04 15:47:55 ericj Exp $ */
2: /* $NetBSD: osf1_socket.c,v 1.4 1999/05/10 01:58:37 cgd Exp $ */
3:
4: /*
5: * Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
6: *
7: * Redistribution and use in source and binary forms, with or without
8: * modification, are permitted provided that the following conditions
9: * are met:
10: * 1. Redistributions of source code must retain the above copyright
11: * notice, this list of conditions and the following disclaimer.
12: * 2. Redistributions in binary form must reproduce the above copyright
13: * notice, this list of conditions and the following disclaimer in the
14: * documentation and/or other materials provided with the distribution.
15: * 3. All advertising materials mentioning features or use of this software
16: * must display the following acknowledgement:
17: * This product includes software developed by Christopher G. Demetriou
18: * for the NetBSD Project.
19: * 4. The name of the author may not be used to endorse or promote products
20: * derived from this software without specific prior written permission
21: *
22: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32: */
33:
34: /*
35: * Copyright (c) 1994, 1995 Carnegie-Mellon University.
36: * All rights reserved.
37: *
38: * Author: Chris G. Demetriou
39: *
40: * Permission to use, copy, modify and distribute this software and
41: * its documentation is hereby granted, provided that both the copyright
42: * notice and this permission notice appear in all copies of the
43: * software, derivative works or modified versions, and any portions
44: * thereof, and that both notices appear in supporting documentation.
45: *
46: * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
47: * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
48: * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
49: *
50: * Carnegie Mellon requests users of this software to return to
51: *
52: * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
53: * School of Computer Science
54: * Carnegie Mellon University
55: * Pittsburgh PA 15213-3890
56: *
57: * any improvements or extensions that they make and grant Carnegie the
58: * rights to redistribute these changes.
59: */
60:
61: #include <sys/param.h>
62: #include <sys/systm.h>
63: #include <sys/namei.h>
64: #include <sys/proc.h>
65: #include <sys/file.h>
66: #include <sys/mount.h>
67: #include <sys/syscallargs.h>
68: #include <sys/socketvar.h>
69: #include <sys/exec.h>
70:
71: #include <compat/osf1/osf1.h>
72: #include <compat/osf1/osf1_syscallargs.h>
73: #include <compat/osf1/osf1_util.h>
74: #include <compat/osf1/osf1_cvt.h>
75:
76: int
77: osf1_sys_recvmsg_xopen(p, v, retval)
78: struct proc *p;
79: void *v;
80: register_t *retval;
81: {
82:
83: /* XXX */
84: return (EINVAL);
85: }
86:
87: int
88: osf1_sys_sendmsg_xopen(p, v, retval)
89: struct proc *p;
90: void *v;
91: register_t *retval;
92: {
93: struct osf1_sys_sendmsg_xopen_args *uap = v;
94: struct sys_sendmsg_args a;
95: struct osf1_msghdr_xopen osf_msghdr;
96: struct osf1_iovec_xopen osf_iovec, *osf_iovec_ptr;
97: struct msghdr bsd_msghdr;
98: struct iovec bsd_iovec, *bsd_iovec_ptr;
99: unsigned long leftovers;
100: caddr_t sg;
101: unsigned int i;
102: int error;
103:
104: sg = stackgap_init(p->p_emul);
105:
106: SCARG(&a, s) = SCARG(uap, s);
107:
108: /*
109: * translate msghdr structure
110: */
111: if ((error = copyin(SCARG(uap, msg), &osf_msghdr,
112: sizeof osf_msghdr)) != 0)
113: return (error);
114:
115: error = osf1_cvt_msghdr_xopen_to_native(&osf_msghdr, &bsd_msghdr);
116: if (error != 0)
117: return (error);
118:
119: if (STACKGAPLEN < (bsd_msghdr.msg_iovlen * sizeof (struct iovec) +
120: sizeof (struct msghdr)))
121: {
122: printf("sendmsg space\n");
123: return (EINVAL);
124: }
125:
126: SCARG(&a, msg) = stackgap_alloc(&sg, sizeof bsd_msghdr);
127: bsd_msghdr.msg_iov = stackgap_alloc(&sg,
128: bsd_msghdr.msg_iovlen * sizeof (struct iovec));
129:
130: if ((error = copyout(&bsd_msghdr, (caddr_t)SCARG(&a, msg),
131: sizeof bsd_msghdr)) != 0)
132: return (error);
133:
134: osf_iovec_ptr = osf_msghdr.msg_iov;
135: bsd_iovec_ptr = bsd_msghdr.msg_iov;
136: for (i = 0; i < bsd_msghdr.msg_iovlen; i++) {
137: if ((error = copyin(&osf_iovec_ptr[i], &osf_iovec,
138: sizeof osf_iovec)) != 0)
139: return (error);
140:
141: bsd_iovec.iov_base = osf_iovec.iov_base;
142: bsd_iovec.iov_len = osf_iovec.iov_len;
143:
144: if ((error = copyout(&bsd_iovec, &bsd_iovec_ptr[i],
145: sizeof bsd_iovec)) != 0)
146: return (error);
147: }
148:
149: /*
150: * translate flags
151: */
152: SCARG(&a, flags) = emul_flags_translate(osf1_sendrecv_msg_flags_xtab,
153: SCARG(uap, flags), &leftovers);
154: if (leftovers != 0)
155: {
156: printf("sendmsg flags leftover: 0x%lx\n", leftovers);
157: return (EINVAL);
158: }
159:
160: return sys_sendmsg(p, &a, retval);
161: }
162:
163: int
164: osf1_sys_sendto(p, v, retval)
165: struct proc *p;
166: void *v;
167: register_t *retval;
168: {
169: struct osf1_sys_sendto_args *uap = v;
170: struct sys_sendto_args a;
171: unsigned long leftovers;
172:
173: SCARG(&a, s) = SCARG(uap, s);
174: SCARG(&a, buf) = SCARG(uap, buf);
175: SCARG(&a, len) = SCARG(uap, len);
176: SCARG(&a, to) = SCARG(uap, to);
177: SCARG(&a, tolen) = SCARG(uap, tolen);
178:
179: /* translate flags */
180: SCARG(&a, flags) = emul_flags_translate(osf1_sendrecv_msg_flags_xtab,
181: SCARG(uap, flags), &leftovers);
182: if (leftovers != 0)
183: return (EINVAL);
184:
185: return sys_sendto(p, &a, retval);
186: }
187:
188: int
189: osf1_sys_socket(p, v, retval)
190: struct proc *p;
191: void *v;
192: register_t *retval;
193: {
194: struct osf1_sys_socket_args *uap = v;
195: struct sys_socket_args a;
196:
197: /* XXX TRANSLATE */
198:
199: if (SCARG(uap, domain) > AF_LINK)
200: return (EINVAL); /* XXX After AF_LINK, divergence. */
201:
202: SCARG(&a, domain) = SCARG(uap, domain);
203: SCARG(&a, type) = SCARG(uap, type);
204: SCARG(&a, protocol) = SCARG(uap, protocol);
205:
206: return sys_socket(p, &a, retval);
207: }
208:
209: int
210: osf1_sys_socketpair(p, v, retval)
211: struct proc *p;
212: void *v;
213: register_t *retval;
214: {
215: struct osf1_sys_socketpair_args *uap = v;
216: struct sys_socketpair_args a;
217:
218: /* XXX TRANSLATE */
219:
220: if (SCARG(uap, domain) > AF_LINK)
221: return (EINVAL); /* XXX After AF_LINK, divergence. */
222:
223: SCARG(&a, domain) = SCARG(uap, domain);
224: SCARG(&a, type) = SCARG(uap, type);
225: SCARG(&a, protocol) = SCARG(uap, protocol);
226: SCARG(&a, rsv) = SCARG(uap, rsv);
227:
228: return sys_socketpair(p, &a, retval);
229: }
CVSweb