2 * Copyright (c) 1998 Mark Newton. All rights reserved.
3 * Copyright (c) 1994, 1996 Christos Zoulas. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Christos Zoulas.
16 * 4. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 * $FreeBSD: src/sys/svr4/svr4_stream.c,v 1.12.2.2 2000/11/26 04:42:27 dillon Exp $
31 * $DragonFly: src/sys/emulation/svr4/Attic/svr4_stream.c,v 1.3 2003/06/23 17:55:49 dillon Exp $
35 * Pretend that we have streams...
38 * ToDo: The state machine for getmsg needs re-thinking
43 #include <sys/param.h>
44 #include <sys/systm.h>
46 #include <sys/malloc.h>
48 #include <sys/filedesc.h>
49 #include <sys/fcntl.h>
50 #include <sys/filio.h>
51 #include <sys/select.h>
52 #include <sys/socket.h>
53 #include <sys/socketvar.h>
55 #include <netinet/in.h>
57 #include <sys/protosw.h>
58 #include <sys/signal.h>
59 #include <sys/signalvar.h>
61 #include <sys/ktrace.h>
65 #include <sys/sysproto.h>
67 #include <svr4/svr4.h>
68 #include <svr4/svr4_types.h>
69 #include <svr4/svr4_util.h>
70 #include <svr4/svr4_signal.h>
71 #include <svr4/svr4_proto.h>
72 #include <svr4/svr4_stropts.h>
73 #include <svr4/svr4_timod.h>
74 #include <svr4/svr4_sockmod.h>
75 #include <svr4/svr4_ioctl.h>
76 #include <svr4/svr4_socket.h>
79 static int clean_pipe __P((const char *));
80 static void getparm __P((struct file *, struct svr4_si_sockparms *));
82 /* Address Conversions */
83 static void sockaddr_to_netaddr_in __P((struct svr4_strmcmd *,
84 const struct sockaddr_in *));
85 static void sockaddr_to_netaddr_un __P((struct svr4_strmcmd *,
86 const struct sockaddr_un *));
87 static void netaddr_to_sockaddr_in __P((struct sockaddr_in *,
88 const struct svr4_strmcmd *));
89 static void netaddr_to_sockaddr_un __P((struct sockaddr_un *,
90 const struct svr4_strmcmd *));
93 static int i_nread __P((struct file *, struct proc *, register_t *, int,
95 static int i_fdinsert __P((struct file *, struct proc *, register_t *, int,
97 static int i_str __P((struct file *, struct proc *, register_t *, int,
99 static int i_setsig __P((struct file *, struct proc *, register_t *, int,
101 static int i_getsig __P((struct file *, struct proc *, register_t *, int,
103 static int _i_bind_rsvd __P((struct file *, struct proc *, register_t *, int,
105 static int _i_rele_rsvd __P((struct file *, struct proc *, register_t *, int,
108 /* i_str sockmod calls */
109 static int sockmod __P((struct file *, int, struct svr4_strioctl *,
111 static int si_listen __P((struct file *, int, struct svr4_strioctl *,
113 static int si_ogetudata __P((struct file *, int, struct svr4_strioctl *,
115 static int si_sockparams __P((struct file *, int, struct svr4_strioctl *,
117 static int si_shutdown __P((struct file *, int, struct svr4_strioctl *,
119 static int si_getudata __P((struct file *, int, struct svr4_strioctl *,
122 /* i_str timod calls */
123 static int timod __P((struct file *, int, struct svr4_strioctl *,
125 static int ti_getinfo __P((struct file *, int, struct svr4_strioctl *,
127 static int ti_bind __P((struct file *, int, struct svr4_strioctl *,
131 static int svr4_sendit __P((struct proc *p, int s, struct msghdr *mp,
134 static int svr4_recvit __P((struct proc *p, int s, struct msghdr *mp,
137 /* <sigh> Ok, so we shouldn't use sendit() in uipc_syscalls.c because
138 * it isn't part of a "public" interface; We're supposed to use
139 * pru_sosend instead. Same goes for recvit()/pru_soreceive() for
140 * that matter. Solution: Suck sendit()/recvit() into here where we
141 * can do what we like.
143 * I hate code duplication.
145 * I will take out all the #ifdef COMPAT_OLDSOCK gumph, though.
148 svr4_sendit(p, s, mp, flags)
158 struct mbuf *control;
163 struct iovec *ktriov = NULL;
167 error = holdsock(p->p_fd, s, &fp);
170 auio.uio_iov = mp->msg_iov;
171 auio.uio_iovcnt = mp->msg_iovlen;
172 auio.uio_segflg = UIO_USERSPACE;
173 auio.uio_rw = UIO_WRITE;
175 auio.uio_offset = 0; /* XXX */
178 for (i = 0; i < mp->msg_iovlen; i++, iov++) {
179 if ((auio.uio_resid += iov->iov_len) < 0) {
185 error = getsockaddr(&to, mp->msg_name, mp->msg_namelen);
193 if (mp->msg_control) {
194 if (mp->msg_controllen < sizeof(struct cmsghdr)) {
198 error = sockargs(&control, mp->msg_control,
199 mp->msg_controllen, MT_CONTROL);
206 if (KTRPOINT(p, KTR_GENIO)) {
207 int iovlen = auio.uio_iovcnt * sizeof (struct iovec);
209 MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK);
210 bcopy((caddr_t)auio.uio_iov, (caddr_t)ktriov, iovlen);
214 len = auio.uio_resid;
215 so = (struct socket *)fp->f_data;
216 error = so->so_proto->pr_usrreqs->pru_sosend(so, to, &auio, 0, control,
219 if (auio.uio_resid != len && (error == ERESTART ||
220 error == EINTR || error == EWOULDBLOCK))
226 p->p_retval[0] = len - auio.uio_resid;
228 if (ktriov != NULL) {
230 ktruio.uio_iov = ktriov;
231 ktruio.uio_resid = p->p_retval[0];
232 ktrgenio(p->p_tracep, s, UIO_WRITE, &ktruio, error);
234 FREE(ktriov, M_TEMP);
245 svr4_recvit(p, s, mp, namelenp)
256 struct mbuf *m, *control = 0;
259 struct sockaddr *fromsa = 0;
261 struct iovec *ktriov = NULL;
265 error = holdsock(p->p_fd, s, &fp);
268 auio.uio_iov = mp->msg_iov;
269 auio.uio_iovcnt = mp->msg_iovlen;
270 auio.uio_segflg = UIO_USERSPACE;
271 auio.uio_rw = UIO_READ;
273 auio.uio_offset = 0; /* XXX */
276 for (i = 0; i < mp->msg_iovlen; i++, iov++) {
277 if ((auio.uio_resid += iov->iov_len) < 0) {
283 if (KTRPOINT(p, KTR_GENIO)) {
284 int iovlen = auio.uio_iovcnt * sizeof (struct iovec);
286 MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK);
287 bcopy((caddr_t)auio.uio_iov, (caddr_t)ktriov, iovlen);
291 len = auio.uio_resid;
292 so = (struct socket *)fp->f_data;
293 error = so->so_proto->pr_usrreqs->pru_soreceive(so, &fromsa, &auio,
294 (struct mbuf **)0, mp->msg_control ? &control : (struct mbuf **)0,
297 if (auio.uio_resid != len && (error == ERESTART ||
298 error == EINTR || error == EWOULDBLOCK))
302 if (ktriov != NULL) {
304 ktruio.uio_iov = ktriov;
305 ktruio.uio_resid = len - auio.uio_resid;
306 ktrgenio(p->p_tracep, s, UIO_READ, &ktruio, error);
308 FREE(ktriov, M_TEMP);
313 p->p_retval[0] = len - auio.uio_resid;
315 len = mp->msg_namelen;
316 if (len <= 0 || fromsa == 0)
320 #define MIN(a,b) ((a)>(b)?(b):(a))
322 /* save sa_len before it is destroyed by MSG_COMPAT */
323 len = MIN(len, fromsa->sa_len);
324 error = copyout(fromsa,
325 (caddr_t)mp->msg_name, (unsigned)len);
329 mp->msg_namelen = len;
331 (error = copyout((caddr_t)&len, namelenp, sizeof (int)))) {
335 if (mp->msg_control) {
336 len = mp->msg_controllen;
338 mp->msg_controllen = 0;
339 ctlbuf = (caddr_t) mp->msg_control;
341 while (m && len > 0) {
347 mp->msg_flags |= MSG_CTRUNC;
351 if ((error = copyout((caddr_t)mtod(m, caddr_t),
352 ctlbuf, tocopy)) != 0)
359 mp->msg_controllen = ctlbuf - (caddr_t)mp->msg_control;
363 FREE(fromsa, M_SONAME);
371 static void bufprint __P((u_char *, size_t));
372 static int show_ioc __P((const char *, struct svr4_strioctl *));
373 static int show_strbuf __P((struct svr4_strbuf *));
374 static void show_msg __P((const char *, int, struct svr4_strbuf *,
375 struct svr4_strbuf *, int));
385 for (i = 0; i < len; i++) {
386 uprintf("%x ", buf[i]);
387 if (i && (i % 16) == 0)
395 struct svr4_strioctl *ioc;
397 u_char *ptr = (u_char *) malloc(ioc->len, M_TEMP, M_WAITOK);
400 uprintf("%s cmd = %ld, timeout = %d, len = %d, buf = %p { ",
401 str, ioc->cmd, ioc->timeout, ioc->len, ioc->buf);
403 if ((error = copyin(ioc->buf, ptr, ioc->len)) != 0) {
404 free((char *) ptr, M_TEMP);
408 bufprint(ptr, ioc->len);
412 free((char *) ptr, M_TEMP);
419 struct svr4_strbuf *str;
423 int maxlen = str->maxlen;
433 ptr = (u_char *) malloc(len, M_TEMP, M_WAITOK);
435 if ((error = copyin(str->buf, ptr, len)) != 0) {
436 free((char *) ptr, M_TEMP);
441 uprintf(", { %d, %d, %p=[ ", str->maxlen, str->len, str->buf);
449 free((char *) ptr, M_TEMP);
456 show_msg(str, fd, ctl, dat, flags)
459 struct svr4_strbuf *ctl;
460 struct svr4_strbuf *dat;
463 struct svr4_strbuf buf;
466 uprintf("%s(%d", str, fd);
468 if ((error = copyin(ctl, &buf, sizeof(buf))) != 0)
476 if ((error = copyin(dat, &buf, sizeof(buf))) != 0)
483 uprintf(", %x);\n", flags);
486 #endif /* DEBUG_SVR4 */
489 * We are faced with an interesting situation. On svr4 unix sockets
490 * are really pipes. But we really have sockets, and we might as
491 * well use them. At the point where svr4 calls TI_BIND, it has
492 * already created a named pipe for the socket using mknod(2).
493 * We need to create a socket with the same name when we bind,
494 * so we need to remove the pipe before, otherwise we'll get address
495 * already in use. So we *carefully* remove the pipe, to avoid
496 * using this as a random file removal tool. We use system calls
497 * to avoid code duplication.
500 clean_pipe(const char *path)
502 struct lstat_args la;
503 struct unlink_args ua;
506 caddr_t sg = stackgap_init();
507 size_t l = strlen(path) + 1;
510 tpath = stackgap_alloc(&sg, l);
511 SCARG(&la, ub) = stackgap_alloc(&sg, sizeof(struct stat));
513 if ((error = copyout(path, tpath, l)) != 0)
516 SCARG(&la, path) = tpath;
518 if ((error = lstat(&la)) != 0)
521 if ((error = copyin(SCARG(&la, ub), &st, sizeof(st))) != 0)
525 * Make sure we are dealing with a mode 0 named pipe.
527 if ((st.st_mode & S_IFMT) != S_IFIFO)
530 if ((st.st_mode & ALLPERMS) != 0)
533 SCARG(&ua, path) = SCARG(&la, path);
535 if ((error = unlink(&ua)) != 0) {
536 DPRINTF(("clean_pipe: unlink failed %d\n", error));
545 sockaddr_to_netaddr_in(sc, sain)
546 struct svr4_strmcmd *sc;
547 const struct sockaddr_in *sain;
549 struct svr4_netaddr_in *na;
550 na = SVR4_ADDROF(sc);
552 na->family = sain->sin_family;
553 na->port = sain->sin_port;
554 na->addr = sain->sin_addr.s_addr;
555 DPRINTF(("sockaddr_in -> netaddr %d %d %lx\n", na->family, na->port,
561 sockaddr_to_netaddr_un(sc, saun)
562 struct svr4_strmcmd *sc;
563 const struct sockaddr_un *saun;
565 struct svr4_netaddr_un *na;
566 char *dst, *edst = ((char *) sc) + sc->offs + sizeof(na->family) + 1 -
570 na = SVR4_ADDROF(sc);
571 na->family = saun->sun_family;
572 for (src = saun->sun_path, dst = na->path; (*dst++ = *src++) != '\0'; )
575 DPRINTF(("sockaddr_un -> netaddr %d %s\n", na->family, na->path));
580 netaddr_to_sockaddr_in(sain, sc)
581 struct sockaddr_in *sain;
582 const struct svr4_strmcmd *sc;
584 const struct svr4_netaddr_in *na;
587 na = SVR4_C_ADDROF(sc);
588 memset(sain, 0, sizeof(*sain));
589 sain->sin_len = sizeof(*sain);
590 sain->sin_family = na->family;
591 sain->sin_port = na->port;
592 sain->sin_addr.s_addr = na->addr;
593 DPRINTF(("netaddr -> sockaddr_in %d %d %x\n", sain->sin_family,
594 sain->sin_port, sain->sin_addr.s_addr));
599 netaddr_to_sockaddr_un(saun, sc)
600 struct sockaddr_un *saun;
601 const struct svr4_strmcmd *sc;
603 const struct svr4_netaddr_un *na;
604 char *dst, *edst = &saun->sun_path[sizeof(saun->sun_path) - 1];
607 na = SVR4_C_ADDROF(sc);
608 memset(saun, 0, sizeof(*saun));
609 saun->sun_family = na->family;
610 for (src = na->path, dst = saun->sun_path; (*dst++ = *src++) != '\0'; )
613 saun->sun_len = dst - saun->sun_path;
614 DPRINTF(("netaddr -> sockaddr_un %d %s\n", saun->sun_family,
622 struct svr4_si_sockparms *pa;
624 struct svr4_strm *st = svr4_stream_get(fp);
625 struct socket *so = (struct socket *) fp->f_data;
630 pa->family = st->s_family;
632 switch (so->so_type) {
634 pa->type = SVR4_T_CLTS;
635 pa->protocol = IPPROTO_UDP;
636 DPRINTF(("getparm(dgram)\n"));
640 pa->type = SVR4_T_COTS; /* What about T_COTS_ORD? XXX */
641 pa->protocol = IPPROTO_IP;
642 DPRINTF(("getparm(stream)\n"));
646 pa->type = SVR4_T_CLTS;
647 pa->protocol = IPPROTO_RAW;
648 DPRINTF(("getparm(raw)\n"));
654 DPRINTF(("getparm(type %d?)\n", so->so_type));
661 si_ogetudata(fp, fd, ioc, p)
664 struct svr4_strioctl *ioc;
668 struct svr4_si_oudata ud;
669 struct svr4_si_sockparms pa;
671 if (ioc->len != sizeof(ud) && ioc->len != sizeof(ud) - sizeof(int)) {
672 DPRINTF(("SI_OGETUDATA: Wrong size %d != %d\n",
673 sizeof(ud), ioc->len));
677 if ((error = copyin(ioc->buf, &ud, sizeof(ud))) != 0)
685 ud.addrsize = sizeof(struct svr4_sockaddr_in);
686 if (pa.type == SVR4_SOCK_STREAM)
699 DPRINTF(("SI_OGETUDATA: Unsupported address family %d\n",
704 /* I have no idea what these should be! */
708 ud.servtype = pa.type;
713 return copyout(&ud, ioc->buf, ioc->len);
718 si_sockparams(fp, fd, ioc, p)
721 struct svr4_strioctl *ioc;
724 struct svr4_si_sockparms pa;
727 return copyout(&pa, ioc->buf, sizeof(pa));
732 si_listen(fp, fd, ioc, p)
735 struct svr4_strioctl *ioc;
739 struct svr4_strm *st = svr4_stream_get(fp);
740 struct svr4_strmcmd lst;
741 struct listen_args la;
746 if ((error = copyin(ioc->buf, &lst, ioc->len)) != 0)
749 if (lst.cmd != SVR4_TI_OLD_BIND_REQUEST) {
750 DPRINTF(("si_listen: bad request %ld\n", lst.cmd));
755 * We are making assumptions again...
758 DPRINTF(("SI_LISTEN: fileno %d backlog = %d\n", fd, 5));
759 SCARG(&la, backlog) = 5;
761 if ((error = listen(&la)) != 0) {
762 DPRINTF(("SI_LISTEN: listen failed %d\n", error));
766 st->s_cmd = SVR4_TI__ACCEPT_WAIT;
767 lst.cmd = SVR4_TI_BIND_REPLY;
769 switch (st->s_family) {
771 /* XXX: Fill the length here */
776 lst.pad[28] = 0x00000000; /* magic again */
777 lst.pad[29] = 0x00000800; /* magic again */
778 lst.pad[30] = 0x80001400; /* magic again */
782 DPRINTF(("SI_LISTEN: Unsupported address family %d\n",
788 if ((error = copyout(&lst, ioc->buf, ioc->len)) != 0)
796 si_getudata(fp, fd, ioc, p)
799 struct svr4_strioctl *ioc;
803 struct svr4_si_udata ud;
805 if (sizeof(ud) != ioc->len) {
806 DPRINTF(("SI_GETUDATA: Wrong size %d != %d\n",
807 sizeof(ud), ioc->len));
811 if ((error = copyin(ioc->buf, &ud, sizeof(ud))) != 0)
814 getparm(fp, &ud.sockparms);
816 switch (ud.sockparms.family) {
818 DPRINTF(("getudata_inet\n"));
821 ud.addrsize = sizeof(struct svr4_sockaddr_in);
822 if (ud.sockparms.type == SVR4_SOCK_STREAM)
830 DPRINTF(("getudata_local\n"));
839 DPRINTF(("SI_GETUDATA: Unsupported address family %d\n",
840 ud.sockparms.family));
845 ud.servtype = ud.sockparms.type;
846 DPRINTF(("ud.servtype = %d\n", ud.servtype));
850 return copyout(&ud, ioc->buf, sizeof(ud));
855 si_shutdown(fp, fd, ioc, p)
858 struct svr4_strioctl *ioc;
862 struct shutdown_args ap;
864 if (ioc->len != sizeof(SCARG(&ap, how))) {
865 DPRINTF(("SI_SHUTDOWN: Wrong size %d != %d\n",
866 sizeof(SCARG(&ap, how)), ioc->len));
870 if ((error = copyin(ioc->buf, &SCARG(&ap, how), ioc->len)) != 0)
875 return shutdown(&ap);
880 sockmod(fp, fd, ioc, p)
883 struct svr4_strioctl *ioc;
887 case SVR4_SI_OGETUDATA:
888 DPRINTF(("SI_OGETUDATA\n"));
889 return si_ogetudata(fp, fd, ioc, p);
891 case SVR4_SI_SHUTDOWN:
892 DPRINTF(("SI_SHUTDOWN\n"));
893 return si_shutdown(fp, fd, ioc, p);
896 DPRINTF(("SI_LISTEN\n"));
897 return si_listen(fp, fd, ioc, p);
899 case SVR4_SI_SETMYNAME:
900 DPRINTF(("SI_SETMYNAME\n"));
903 case SVR4_SI_SETPEERNAME:
904 DPRINTF(("SI_SETPEERNAME\n"));
907 case SVR4_SI_GETINTRANSIT:
908 DPRINTF(("SI_GETINTRANSIT\n"));
911 case SVR4_SI_TCL_LINK:
912 DPRINTF(("SI_TCL_LINK\n"));
915 case SVR4_SI_TCL_UNLINK:
916 DPRINTF(("SI_TCL_UNLINK\n"));
919 case SVR4_SI_SOCKPARAMS:
920 DPRINTF(("SI_SOCKPARAMS\n"));
921 return si_sockparams(fp, fd, ioc, p);
923 case SVR4_SI_GETUDATA:
924 DPRINTF(("SI_GETUDATA\n"));
925 return si_getudata(fp, fd, ioc, p);
928 DPRINTF(("Unknown sockmod ioctl %lx\n", ioc->cmd));
936 ti_getinfo(fp, fd, ioc, p)
939 struct svr4_strioctl *ioc;
943 struct svr4_infocmd info;
945 memset(&info, 0, sizeof(info));
947 if ((error = copyin(ioc->buf, &info, ioc->len)) != 0)
950 if (info.cmd != SVR4_TI_INFO_REQUEST)
953 info.cmd = SVR4_TI_INFO_REPLY;
965 ioc->len = sizeof(info);
966 if ((error = copyout(&info, ioc->buf, ioc->len)) != 0)
974 ti_bind(fp, fd, ioc, p)
977 struct svr4_strioctl *ioc;
981 struct svr4_strm *st = svr4_stream_get(fp);
982 struct sockaddr_in sain;
983 struct sockaddr_un saun;
985 void *skp, *sup = NULL;
987 struct svr4_strmcmd bnd;
991 DPRINTF(("ti_bind: bad file descriptor\n"));
995 if ((error = copyin(ioc->buf, &bnd, ioc->len)) != 0)
998 if (bnd.cmd != SVR4_TI_OLD_BIND_REQUEST) {
999 DPRINTF(("ti_bind: bad request %ld\n", bnd.cmd));
1003 switch (st->s_family) {
1006 sasize = sizeof(sain);
1011 netaddr_to_sockaddr_in(&sain, &bnd);
1013 DPRINTF(("TI_BIND: fam %d, port %d, addr %x\n",
1014 sain.sin_family, sain.sin_port,
1015 sain.sin_addr.s_addr));
1020 sasize = sizeof(saun);
1024 netaddr_to_sockaddr_un(&saun, &bnd);
1026 if (saun.sun_path[0] == '\0')
1029 DPRINTF(("TI_BIND: fam %d, path %s\n",
1030 saun.sun_family, saun.sun_path));
1032 if ((error = clean_pipe(saun.sun_path)) != 0)
1035 bnd.pad[28] = 0x00001000; /* magic again */
1039 DPRINTF(("TI_BIND: Unsupported address family %d\n",
1044 sg = stackgap_init();
1045 sup = stackgap_alloc(&sg, sasize);
1047 if ((error = copyout(skp, sup, sasize)) != 0)
1051 DPRINTF(("TI_BIND: fileno %d\n", fd));
1052 SCARG(&ba, name) = (void *) sup;
1053 SCARG(&ba, namelen) = sasize;
1055 if ((error = bind(&ba)) != 0) {
1056 DPRINTF(("TI_BIND: bind failed %d\n", error));
1062 memset(&bnd, 0, sizeof(bnd));
1063 bnd.len = sasize + 4;
1064 bnd.offs = 0x10; /* XXX */
1067 bnd.cmd = SVR4_TI_BIND_REPLY;
1069 if ((error = copyout(&bnd, ioc->buf, ioc->len)) != 0)
1077 timod(fp, fd, ioc, p)
1080 struct svr4_strioctl *ioc;
1084 case SVR4_TI_GETINFO:
1085 DPRINTF(("TI_GETINFO\n"));
1086 return ti_getinfo(fp, fd, ioc, p);
1088 case SVR4_TI_OPTMGMT:
1089 DPRINTF(("TI_OPTMGMT\n"));
1093 DPRINTF(("TI_BIND\n"));
1094 return ti_bind(fp, fd, ioc, p);
1096 case SVR4_TI_UNBIND:
1097 DPRINTF(("TI_UNBIND\n"));
1101 DPRINTF(("Unknown timod ioctl %lx\n", ioc->cmd));
1108 svr4_stream_ti_ioctl(fp, p, retval, fd, cmd, dat)
1116 struct svr4_strbuf skb, *sub = (struct svr4_strbuf *) dat;
1117 struct svr4_strm *st = svr4_stream_get(fp);
1120 struct sockaddr_in sain;
1121 struct sockaddr_un saun;
1122 struct svr4_strmcmd sc;
1127 DPRINTF(("svr4_stream_ti_ioctl\n"));
1134 if ((error = copyin(sub, &skb, sizeof(skb))) != 0) {
1135 DPRINTF(("ti_ioctl: error copying in strbuf\n"));
1139 switch (st->s_family) {
1142 sasize = sizeof(sain);
1147 sasize = sizeof(saun);
1151 DPRINTF(("ti_ioctl: Unsupported address family %d\n",
1156 sg = stackgap_init();
1157 sup = stackgap_alloc(&sg, sasize);
1158 lenp = stackgap_alloc(&sg, sizeof(*lenp));
1160 if ((error = copyout(&sasize, lenp, sizeof(*lenp))) != 0) {
1161 DPRINTF(("ti_ioctl: error copying out lenp\n"));
1166 case SVR4_TI_GETMYNAME:
1167 DPRINTF(("TI_GETMYNAME\n"));
1169 struct getsockname_args ap;
1170 SCARG(&ap, fdes) = fd;
1171 SCARG(&ap, asa) = sup;
1172 SCARG(&ap, alen) = lenp;
1173 if ((error = getsockname(&ap)) != 0) {
1174 DPRINTF(("ti_ioctl: getsockname error\n"));
1180 case SVR4_TI_GETPEERNAME:
1181 DPRINTF(("TI_GETPEERNAME\n"));
1183 struct getpeername_args ap;
1184 SCARG(&ap, fdes) = fd;
1185 SCARG(&ap, asa) = sup;
1186 SCARG(&ap, alen) = lenp;
1187 if ((error = getpeername(&ap)) != 0) {
1188 DPRINTF(("ti_ioctl: getpeername error\n"));
1194 case SVR4_TI_SETMYNAME:
1195 DPRINTF(("TI_SETMYNAME\n"));
1198 case SVR4_TI_SETPEERNAME:
1199 DPRINTF(("TI_SETPEERNAME\n"));
1202 DPRINTF(("ti_ioctl: Unknown ioctl %lx\n", cmd));
1206 if ((error = copyin(sup, skp, sasize)) != 0) {
1207 DPRINTF(("ti_ioctl: error copying in socket data\n"));
1211 if ((error = copyin(lenp, &sasize, sizeof(*lenp))) != 0) {
1212 DPRINTF(("ti_ioctl: error copying in socket size\n"));
1216 switch (st->s_family) {
1218 sockaddr_to_netaddr_in(&sc, &sain);
1223 sockaddr_to_netaddr_un(&sc, &saun);
1224 skb.len = sasize + 4;
1232 if ((error = copyout(SVR4_ADDROF(&sc), skb.buf, sasize)) != 0) {
1233 DPRINTF(("ti_ioctl: error copying out socket data\n"));
1238 if ((error = copyout(&skb, sub, sizeof(skb))) != 0) {
1239 DPRINTF(("ti_ioctl: error copying out strbuf\n"));
1250 i_nread(fp, p, retval, fd, cmd, dat)
1262 * We are supposed to return the message length in nread, and the
1263 * number of messages in retval. We don't have the notion of number
1264 * of stream messages, so we just find out if we have any bytes waiting
1265 * for us, and if we do, then we assume that we have at least one
1266 * message waiting for us.
1268 if ((error = fo_ioctl(fp, FIONREAD, (caddr_t) &nread, p)) != 0)
1276 return copyout(&nread, dat, sizeof(nread));
1280 i_fdinsert(fp, p, retval, fd, cmd, dat)
1289 * Major hack again here. We assume that we are using this to
1290 * implement accept(2). If that is the case, we have already
1291 * called accept, and we have stored the file descriptor in
1292 * afd. We find the file descriptor that the code wants to use
1293 * in fd insert, and then we dup2() our accepted file descriptor
1297 struct svr4_strm *st = svr4_stream_get(fp);
1298 struct svr4_strfdinsert fdi;
1299 struct dup2_args d2p;
1300 struct close_args clp;
1303 DPRINTF(("fdinsert: bad file type\n"));
1307 if (st->s_afd == -1) {
1308 DPRINTF(("fdinsert: accept fd not found\n"));
1312 if ((error = copyin(dat, &fdi, sizeof(fdi))) != 0) {
1313 DPRINTF(("fdinsert: copyin failed %d\n", error));
1317 SCARG(&d2p, from) = st->s_afd;
1318 SCARG(&d2p, to) = fdi.fd;
1320 if ((error = dup2(&d2p)) != 0) {
1321 DPRINTF(("fdinsert: dup2(%d, %d) failed %d\n",
1322 st->s_afd, fdi.fd, error));
1326 SCARG(&clp, fd) = st->s_afd;
1328 if ((error = close(&clp)) != 0) {
1329 DPRINTF(("fdinsert: close(%d) failed %d\n",
1342 _i_bind_rsvd(fp, p, retval, fd, cmd, dat)
1350 struct mkfifo_args ap;
1353 * This is a supposed to be a kernel and library only ioctl.
1354 * It gets called before ti_bind, when we have a unix
1355 * socket, to physically create the socket transport and
1356 * ``reserve'' it. I don't know how this get reserved inside
1357 * the kernel, but we are going to create it nevertheless.
1359 SCARG(&ap, path) = dat;
1360 SCARG(&ap, mode) = S_IFIFO;
1366 _i_rele_rsvd(fp, p, retval, fd, cmd, dat)
1374 struct unlink_args ap;
1377 * This is a supposed to be a kernel and library only ioctl.
1378 * I guess it is supposed to release the socket.
1380 SCARG(&ap, path) = dat;
1386 i_str(fp, p, retval, fd, cmd, dat)
1395 struct svr4_strioctl ioc;
1397 if ((error = copyin(dat, &ioc, sizeof(ioc))) != 0)
1401 if ((error = show_ioc(">", &ioc)) != 0)
1403 #endif /* DEBUG_SVR4 */
1405 switch (ioc.cmd & 0xff00) {
1407 if ((error = sockmod(fp, fd, &ioc, p)) != 0)
1412 if ((error = timod(fp, fd, &ioc, p)) != 0)
1417 DPRINTF(("Unimplemented module %c %ld\n",
1418 (char) (cmd >> 8), cmd & 0xff));
1423 if ((error = show_ioc("<", &ioc)) != 0)
1425 #endif /* DEBUG_SVR4 */
1426 return copyout(&ioc, dat, sizeof(ioc));
1430 i_setsig(fp, p, retval, fd, cmd, dat)
1439 * This is the best we can do for now; we cannot generate
1440 * signals only for specific events so the signal mask gets
1441 * ignored; we save it just to pass it to a possible I_GETSIG...
1443 * We alse have to fix the O_ASYNC fcntl bit, so the
1444 * process will get SIGPOLLs.
1446 struct fcntl_args fa;
1448 register_t oflags, flags;
1449 struct svr4_strm *st = svr4_stream_get(fp);
1452 DPRINTF(("i_setsig: bad file descriptor\n"));
1455 /* get old status flags */
1456 SCARG(&fa, fd) = fd;
1457 SCARG(&fa, cmd) = F_GETFL;
1458 if ((error = fcntl(&fa)) != 0)
1461 oflags = p->p_retval[0];
1463 /* update the flags */
1467 flags = oflags | O_ASYNC;
1468 if ((error = copyin(dat, &mask, sizeof(mask))) != 0) {
1469 DPRINTF(("i_setsig: bad eventmask pointer\n"));
1472 if (mask & SVR4_S_ALLMASK) {
1473 DPRINTF(("i_setsig: bad eventmask data %x\n", mask));
1476 st->s_eventmask = mask;
1479 flags = oflags & ~O_ASYNC;
1480 st->s_eventmask = 0;
1483 /* set the new flags, if changed */
1484 if (flags != oflags) {
1485 SCARG(&fa, cmd) = F_SETFL;
1486 SCARG(&fa, arg) = (long) flags;
1487 if ((error = fcntl(&fa)) != 0)
1489 flags = p->p_retval[0];
1492 /* set up SIGIO receiver if needed */
1494 SCARG(&fa, cmd) = F_SETOWN;
1495 SCARG(&fa, arg) = (long) p->p_pid;
1502 i_getsig(fp, p, retval, fd, cmd, dat)
1513 struct svr4_strm *st = svr4_stream_get(fp);
1516 DPRINTF(("i_getsig: bad file descriptor\n"));
1519 if ((error = copyout(&st->s_eventmask, dat,
1520 sizeof(st->s_eventmask))) != 0) {
1521 DPRINTF(("i_getsig: bad eventmask pointer\n"));
1529 svr4_stream_ioctl(fp, p, retval, fd, cmd, dat)
1540 * All the following stuff assumes "sockmod" is pushed...
1544 DPRINTF(("I_NREAD\n"));
1545 return i_nread(fp, p, retval, fd, cmd, dat);
1548 DPRINTF(("I_PUSH %x\n", dat));
1549 #if defined(DEBUG_SVR4)
1555 DPRINTF(("I_POP\n"));
1559 DPRINTF(("I_LOOK\n"));
1563 DPRINTF(("I_FLUSH\n"));
1567 DPRINTF(("I_SRDOPT\n"));
1571 DPRINTF(("I_GRDOPT\n"));
1575 DPRINTF(("I_STR\n"));
1576 return i_str(fp, p, retval, fd, cmd, dat);
1579 DPRINTF(("I_SETSIG\n"));
1580 return i_setsig(fp, p, retval, fd, cmd, dat);
1583 DPRINTF(("I_GETSIG\n"));
1584 return i_getsig(fp, p, retval, fd, cmd, dat);
1587 DPRINTF(("I_FIND\n"));
1589 * Here we are not pushing modules really, we just
1590 * pretend all are present
1596 DPRINTF(("I_LINK\n"));
1600 DPRINTF(("I_UNLINK\n"));
1603 case SVR4_I_ERECVFD:
1604 DPRINTF(("I_ERECVFD\n"));
1608 DPRINTF(("I_PEEK\n"));
1611 case SVR4_I_FDINSERT:
1612 DPRINTF(("I_FDINSERT\n"));
1613 return i_fdinsert(fp, p, retval, fd, cmd, dat);
1616 DPRINTF(("I_SENDFD\n"));
1620 DPRINTF(("I_RECVFD\n"));
1624 DPRINTF(("I_SWROPT\n"));
1628 DPRINTF(("I_GWROPT\n"));
1632 DPRINTF(("I_LIST\n"));
1636 DPRINTF(("I_PLINK\n"));
1639 case SVR4_I_PUNLINK:
1640 DPRINTF(("I_PUNLINK\n"));
1644 DPRINTF(("I_SETEV\n"));
1648 DPRINTF(("I_GETEV\n"));
1652 DPRINTF(("I_STREV\n"));
1655 case SVR4_I_UNSTREV:
1656 DPRINTF(("I_UNSTREV\n"));
1659 case SVR4_I_FLUSHBAND:
1660 DPRINTF(("I_FLUSHBAND\n"));
1664 DPRINTF(("I_CKBAND\n"));
1667 case SVR4_I_GETBAND:
1668 DPRINTF(("I_GETBANK\n"));
1672 DPRINTF(("I_ATMARK\n"));
1675 case SVR4_I_SETCLTIME:
1676 DPRINTF(("I_SETCLTIME\n"));
1679 case SVR4_I_GETCLTIME:
1680 DPRINTF(("I_GETCLTIME\n"));
1684 DPRINTF(("I_CANPUT\n"));
1687 case SVR4__I_BIND_RSVD:
1688 DPRINTF(("_I_BIND_RSVD\n"));
1689 return _i_bind_rsvd(fp, p, retval, fd, cmd, dat);
1691 case SVR4__I_RELE_RSVD:
1692 DPRINTF(("_I_RELE_RSVD\n"));
1693 return _i_rele_rsvd(fp, p, retval, fd, cmd, dat);
1696 DPRINTF(("unimpl cmd = %lx\n", cmd));
1706 svr4_sys_putmsg(struct svr4_sys_putmsg_args *uap)
1708 struct proc *p = curproc;
1709 struct filedesc *fdp = p->p_fd;
1711 struct svr4_strbuf dat, ctl;
1712 struct svr4_strmcmd sc;
1713 struct sockaddr_in sain;
1714 struct sockaddr_un saun;
1716 int sasize, *retval;
1717 struct svr4_strm *st;
1721 retval = p->p_retval;
1722 fp = fdp->fd_ofiles[SCARG(uap, fd)];
1724 if (((u_int)SCARG(uap, fd) >= fdp->fd_nfiles) || (fp == NULL)) {
1726 uprintf("putmsg: bad fp\n");
1732 show_msg(">putmsg", SCARG(uap, fd), SCARG(uap, ctl),
1733 SCARG(uap, dat), SCARG(uap, flags));
1734 #endif /* DEBUG_SVR4 */
1736 if (((u_int)SCARG(uap, fd) >= fdp->fd_nfiles) || (fp == NULL)) {
1738 uprintf("putmsg: bad fp(2)\n");
1743 if (SCARG(uap, ctl) != NULL) {
1744 if ((error = copyin(SCARG(uap, ctl), &ctl, sizeof(ctl))) != 0) {
1746 uprintf("putmsg: copyin(): %d\n", error);
1754 if (SCARG(uap, dat) != NULL) {
1755 if ((error = copyin(SCARG(uap, dat), &dat, sizeof(dat))) != 0) {
1757 uprintf("putmsg: copyin(): %d (2)\n", error);
1766 * Only for sockets for now.
1768 if ((st = svr4_stream_get(fp)) == NULL) {
1769 DPRINTF(("putmsg: bad file type\n"));
1773 if (ctl.len > sizeof(sc)) {
1774 DPRINTF(("putmsg: Bad control size %d != %d\n", ctl.len,
1775 sizeof(struct svr4_strmcmd)));
1779 if ((error = copyin(ctl.buf, &sc, ctl.len)) != 0)
1782 switch (st->s_family) {
1784 if (sc.len != sizeof(sain)) {
1785 if (sc.cmd == SVR4_TI_DATA_REQUEST) {
1786 struct write_args wa;
1788 /* Solaris seems to use sc.cmd = 3 to
1789 * send "expedited" data. telnet uses
1790 * this for options processing, sending EOF,
1791 * etc. I'm sure other things use it too.
1792 * I don't have any documentation
1793 * on it, so I'm making a guess that this
1794 * is how it works. newton@atdot.dotat.org XXX
1796 DPRINTF(("sending expedited data ??\n"));
1797 SCARG(&wa, fd) = SCARG(uap, fd);
1798 SCARG(&wa, buf) = dat.buf;
1799 SCARG(&wa, nbyte) = dat.len;
1802 DPRINTF(("putmsg: Invalid inet length %ld\n", sc.len));
1805 netaddr_to_sockaddr_in(&sain, &sc);
1807 sasize = sizeof(sain);
1808 error = sain.sin_family != st->s_family;
1813 /* We are doing an accept; succeed */
1814 DPRINTF(("putmsg: Do nothing\n"));
1819 /* Maybe we've been given a device/inode pair */
1820 udev_t *dev = SVR4_ADDROF(&sc);
1821 ino_t *ino = (ino_t *) &dev[1];
1822 skp = svr4_find_socket(p, fp, *dev, *ino);
1825 /* I guess we have it by name */
1826 netaddr_to_sockaddr_un(skp, &sc);
1828 sasize = sizeof(saun);
1833 DPRINTF(("putmsg: Unsupported address family %d\n",
1838 sg = stackgap_init();
1839 sup = stackgap_alloc(&sg, sasize);
1841 if ((error = copyout(skp, sup, sasize)) != 0)
1844 switch (st->s_cmd = sc.cmd) {
1845 case SVR4_TI_CONNECT_REQUEST: /* connect */
1847 struct connect_args co;
1849 SCARG(&co, s) = SCARG(uap, fd);
1850 SCARG(&co, name) = (void *) sup;
1851 SCARG(&co, namelen) = (int) sasize;
1853 return connect(&co);
1856 case SVR4_TI_SENDTO_REQUEST: /* sendto */
1861 msg.msg_name = (caddr_t) sup;
1862 msg.msg_namelen = sasize;
1863 msg.msg_iov = &aiov;
1865 msg.msg_control = 0;
1867 aiov.iov_base = dat.buf;
1868 aiov.iov_len = dat.len;
1870 error = so->so_proto->pr_usrreqs->pru_sosend(so, 0,
1871 uio, 0, 0, 0, uio->uio_procp);
1873 error = svr4_sendit(p, SCARG(uap, fd), &msg,
1875 DPRINTF(("sendto_request error: %d\n", error));
1881 DPRINTF(("putmsg: Unimplemented command %lx\n", sc.cmd));
1887 svr4_sys_getmsg(struct svr4_sys_getmsg_args *uap)
1889 struct proc *p = curproc;
1890 struct filedesc *fdp = p->p_fd;
1892 struct getpeername_args ga;
1893 struct accept_args aa;
1894 struct svr4_strbuf dat, ctl;
1895 struct svr4_strmcmd sc;
1899 struct sockaddr_in sain;
1900 struct sockaddr_un saun;
1903 struct svr4_strm *st;
1908 retval = p->p_retval;
1909 fp = fdp->fd_ofiles[SCARG(uap, fd)];
1911 if (((u_int)SCARG(uap, fd) >= fdp->fd_nfiles) || (fp == NULL))
1914 memset(&sc, 0, sizeof(sc));
1917 show_msg(">getmsg", SCARG(uap, fd), SCARG(uap, ctl),
1918 SCARG(uap, dat), 0);
1919 #endif /* DEBUG_SVR4 */
1921 if (((u_int)SCARG(uap, fd) >= fdp->fd_nfiles) || (fp == NULL))
1924 if (SCARG(uap, ctl) != NULL) {
1925 if ((error = copyin(SCARG(uap, ctl), &ctl, sizeof(ctl))) != 0)
1933 if (SCARG(uap, dat) != NULL) {
1934 if ((error = copyin(SCARG(uap, dat), &dat, sizeof(dat))) != 0)
1943 * Only for sockets for now.
1945 if ((st = svr4_stream_get(fp)) == NULL) {
1946 DPRINTF(("getmsg: bad file type\n"));
1950 if (ctl.maxlen == -1 || dat.maxlen == -1) {
1951 DPRINTF(("getmsg: Cannot handle -1 maxlen (yet)\n"));
1955 switch (st->s_family) {
1958 sasize = sizeof(sain);
1963 sasize = sizeof(saun);
1967 DPRINTF(("getmsg: Unsupported address family %d\n",
1972 sg = stackgap_init();
1973 sup = stackgap_alloc(&sg, sasize);
1974 flen = (int *) stackgap_alloc(&sg, sizeof(*flen));
1977 if ((error = copyout(&fl, flen, sizeof(fl))) != 0)
1980 switch (st->s_cmd) {
1981 case SVR4_TI_CONNECT_REQUEST:
1982 DPRINTF(("getmsg: TI_CONNECT_REQUEST\n"));
1984 * We do the connect in one step, so the putmsg should
1985 * have gotten the error.
1987 sc.cmd = SVR4_TI_OK_REPLY;
1996 case SVR4_TI_OK_REPLY:
1997 DPRINTF(("getmsg: TI_OK_REPLY\n"));
1999 * We are immediately after a connect reply, so we send
2000 * a connect verification.
2003 SCARG(&ga, fdes) = SCARG(uap, fd);
2004 SCARG(&ga, asa) = (void *) sup;
2005 SCARG(&ga, alen) = flen;
2007 if ((error = getpeername(&ga)) != 0) {
2008 DPRINTF(("getmsg: getpeername failed %d\n", error));
2012 if ((error = copyin(sup, skp, sasize)) != 0)
2015 sc.cmd = SVR4_TI_CONNECT_REPLY;
2019 sc.pad[2] = 0x04000402;
2021 switch (st->s_family) {
2024 sockaddr_to_netaddr_in(&sc, &sain);
2028 sc.len = sasize + 4;
2029 sockaddr_to_netaddr_un(&sc, &saun);
2042 case SVR4_TI__ACCEPT_OK:
2043 DPRINTF(("getmsg: TI__ACCEPT_OK\n"));
2045 * We do the connect in one step, so the putmsg should
2046 * have gotten the error.
2048 sc.cmd = SVR4_TI_OK_REPLY;
2054 st->s_cmd = SVR4_TI__ACCEPT_WAIT;
2057 case SVR4_TI__ACCEPT_WAIT:
2058 DPRINTF(("getmsg: TI__ACCEPT_WAIT\n"));
2060 * We are after a listen, so we try to accept...
2062 SCARG(&aa, s) = SCARG(uap, fd);
2063 SCARG(&aa, name) = (void *) sup;
2064 SCARG(&aa, anamelen) = flen;
2066 if ((error = accept(&aa)) != 0) {
2067 DPRINTF(("getmsg: accept failed %d\n", error));
2071 st->s_afd = *retval;
2073 DPRINTF(("getmsg: Accept fd = %d\n", st->s_afd));
2075 if ((error = copyin(sup, skp, sasize)) != 0)
2078 sc.cmd = SVR4_TI_ACCEPT_REPLY;
2082 switch (st->s_family) {
2085 sockaddr_to_netaddr_in(&sc, &sain);
2091 sc.pad[1] = 0x00010000;
2092 sc.pad[2] = 0xf6bcdaa0; /* I don't know what that is */
2093 sc.pad[3] = 0x00010000;
2095 sc.len = sasize + 4;
2104 st->s_cmd = SVR4_TI__ACCEPT_OK;
2107 case SVR4_TI_SENDTO_REQUEST:
2108 DPRINTF(("getmsg: TI_SENDTO_REQUEST\n"));
2109 if (ctl.maxlen > 36 && ctl.len < 36)
2112 if ((error = copyin(ctl.buf, &sc, ctl.len)) != 0)
2115 switch (st->s_family) {
2117 sockaddr_to_netaddr_in(&sc, &sain);
2121 sockaddr_to_netaddr_un(&sc, &saun);
2128 msg.msg_name = (caddr_t) sup;
2129 msg.msg_namelen = sasize;
2130 msg.msg_iov = &aiov;
2132 msg.msg_control = 0;
2133 aiov.iov_base = dat.buf;
2134 aiov.iov_len = dat.maxlen;
2137 error = svr4_recvit(p, SCARG(uap, fd), &msg, (caddr_t) flen);
2140 DPRINTF(("getmsg: recvit failed %d\n", error));
2144 if ((error = copyin(msg.msg_name, skp, sasize)) != 0)
2147 sc.cmd = SVR4_TI_RECVFROM_IND;
2149 switch (st->s_family) {
2152 sockaddr_to_netaddr_in(&sc, &sain);
2156 sc.len = sasize + 4;
2157 sockaddr_to_netaddr_un(&sc, &saun);
2171 if (st->s_cmd == SVR4_TI_CONNECT_REQUEST) {
2172 struct read_args ra;
2174 /* More wierdness: Again, I can't find documentation
2175 * to back this up, but when a process does a generic
2176 * "getmsg()" call it seems that the command field is
2177 * zero and the length of the data area is zero. I
2178 * think processes expect getmsg() to fill in dat.len
2179 * after reading at most dat.maxlen octets from the
2180 * stream. Since we're using sockets I can let
2181 * read() look after it and frob return values
2182 * appropriately (or inappropriately :-)
2183 * -- newton@atdot.dotat.org XXX
2185 SCARG(&ra, fd) = SCARG(uap, fd);
2186 SCARG(&ra, buf) = dat.buf;
2187 SCARG(&ra, nbyte) = dat.maxlen;
2188 if ((error = read(&ra)) != 0) {
2193 st->s_cmd = SVR4_TI_SENDTO_REQUEST;
2196 DPRINTF(("getmsg: Unknown state %x\n", st->s_cmd));
2200 if (SCARG(uap, ctl)) {
2202 if ((error = copyout(&sc, ctl.buf, ctl.len)) != 0)
2205 if ((error = copyout(&ctl, SCARG(uap, ctl), sizeof(ctl))) != 0)
2209 if (SCARG(uap, dat)) {
2210 if ((error = copyout(&dat, SCARG(uap, dat), sizeof(dat))) != 0)
2214 if (SCARG(uap, flags)) { /* XXX: Need translation */
2215 if ((error = copyout(&fl, SCARG(uap, flags), sizeof(fl))) != 0)
2222 show_msg("<getmsg", SCARG(uap, fd), SCARG(uap, ctl),
2223 SCARG(uap, dat), fl);
2224 #endif /* DEBUG_SVR4 */
2228 int svr4_sys_send(struct svr4_sys_send_args *uap)
2230 struct osend_args osa;
2231 SCARG(&osa, s) = SCARG(uap, s);
2232 SCARG(&osa, buf) = SCARG(uap, buf);
2233 SCARG(&osa, len) = SCARG(uap, len);
2234 SCARG(&osa, flags) = SCARG(uap, flags);
2238 int svr4_sys_recv(struct svr4_sys_recv_args *uap)
2240 struct orecv_args ora;
2241 SCARG(&ora, s) = SCARG(uap, s);
2242 SCARG(&ora, buf) = SCARG(uap, buf);
2243 SCARG(&ora, len) = SCARG(uap, len);
2244 SCARG(&ora, flags) = SCARG(uap, flags);
2249 * XXX This isn't necessary, but it's handy for inserting debug code into
2250 * sendto(). Let's leave it here for now...
2253 svr4_sys_sendto(struct svr4_sys_sendto_args *uap)
2255 struct sendto_args sa;
2257 SCARG(&sa, s) = SCARG(uap, s);
2258 SCARG(&sa, buf) = SCARG(uap, buf);
2259 SCARG(&sa, len) = SCARG(uap, len);
2260 SCARG(&sa, flags) = SCARG(uap, flags);
2261 SCARG(&sa, to) = SCARG(uap, to);
2262 SCARG(&sa, tolen) = SCARG(uap, tolen);
2264 DPRINTF(("calling sendto()\n"));