2 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
3 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/syscall.h>
37 #ifdef HAVE_SYS_POLL_H
43 #ifdef HAVE_SYS_CONF_H
46 #ifdef HAVE_SYS_STREAM_H
47 #include <sys/stream.h>
49 #ifdef HAVE_SYS_TIHDR_H
50 #include <sys/tihdr.h>
53 #if defined(HAVE_SYS_STREAM_H) || defined(LINUX) || defined(FREEBSD)
55 #ifndef HAVE_STROPTS_H
58 int maxlen; /* no. of bytes in buffer */
59 int len; /* no. of bytes returned */
60 const char *buf; /* pointer to data */
64 #endif /* !HAVE_STROPTS_H */
66 #ifdef HAVE_SYS_TIUSER_H
67 #include <sys/tiuser.h>
68 #include <sys/sockmod.h>
69 #include <sys/timod.h>
70 #endif /* HAVE_SYS_TIUSER_H */
73 static const struct xlat msgflags[] = {
74 { RS_HIPRI, "RS_HIPRI" },
80 printstrbuf(struct tcb *tcp, struct strbuf *sbp, int getting)
82 if (sbp->maxlen == -1 && getting)
83 tprintf("{maxlen=-1}");
87 tprintf("maxlen=%d, ", sbp->maxlen);
88 tprintf("len=%d, buf=", sbp->len);
89 printstr(tcp, (unsigned long) sbp->buf, sbp->len);
95 printstrbufarg(struct tcb *tcp, int arg, int getting)
101 else if (umove(tcp, arg, &buf) < 0)
104 printstrbuf(tcp, &buf, getting);
109 sys_putmsg(struct tcb *tcp)
115 tprintf("%ld, ", tcp->u_arg[0]);
116 /* control and data */
117 for (i = 1; i < 3; i++)
118 printstrbufarg(tcp, tcp->u_arg[i], 0);
120 printflags(msgflags, tcp->u_arg[3], "RS_???");
125 #if defined(SPARC) || defined(SPARC64) || defined(SUNOS4) || defined(SVR4)
127 sys_getmsg(struct tcb *tcp)
133 tprintf("%lu, ", tcp->u_arg[0]);
136 tprintf("%#lx, %#lx, %#lx",
137 tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
140 /* control and data */
141 for (i = 1; i < 3; i++)
142 printstrbufarg(tcp, tcp->u_arg[i], 1);
143 /* pointer to flags */
144 if (tcp->u_arg[3] == 0)
146 else if (umove(tcp, tcp->u_arg[3], &flags) < 0)
150 printflags(msgflags, flags, "RS_???");
153 /* decode return value */
154 switch (tcp->u_rval) {
156 tcp->auxstr = "MORECTL";
158 case MORECTL|MOREDATA:
159 tcp->auxstr = "MORECTL|MOREDATA";
162 tcp->auxstr = "MORECTL";
169 return RVAL_HEX | RVAL_STR;
171 #endif /* SPARC || SPARC64 || SUNOS4 || SVR4 */
173 #if defined SYS_putpmsg || defined SYS_getpmsg
174 static const struct xlat pmsgflags[] = {
176 { MSG_HIPRI, "MSG_HIPRI" },
179 { MSG_ANY, "MSG_ANY" },
182 { MSG_BAND, "MSG_BAND" },
190 sys_putpmsg(struct tcb *tcp)
196 tprintf("%ld, ", tcp->u_arg[0]);
197 /* control and data */
198 for (i = 1; i < 3; i++)
199 printstrbufarg(tcp, tcp->u_arg[i], 0);
201 tprintf("%ld, ", tcp->u_arg[3]);
203 printflags(pmsgflags, tcp->u_arg[4], "MSG_???");
207 #endif /* SYS_putpmsg */
211 sys_getpmsg(struct tcb *tcp)
217 tprintf("%lu, ", tcp->u_arg[0]);
220 tprintf("%#lx, %#lx, %#lx, %#lx", tcp->u_arg[1],
221 tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[4]);
224 /* control and data */
225 for (i = 1; i < 3; i++)
226 printstrbufarg(tcp, tcp->u_arg[i], 1);
227 /* pointer to band */
228 printnum(tcp, tcp->u_arg[3], "%d");
230 /* pointer to flags */
231 if (tcp->u_arg[4] == 0)
233 else if (umove(tcp, tcp->u_arg[4], &flags) < 0)
237 printflags(pmsgflags, flags, "MSG_???");
240 /* decode return value */
241 switch (tcp->u_rval) {
243 tcp->auxstr = "MORECTL";
245 case MORECTL|MOREDATA:
246 tcp->auxstr = "MORECTL|MOREDATA";
249 tcp->auxstr = "MORECTL";
256 return RVAL_HEX | RVAL_STR;
258 #endif /* SYS_getpmsg */
260 #endif /* !FREEBSD */
263 #ifdef HAVE_SYS_POLL_H
265 static const struct xlat pollflags[] = {
267 { POLLIN, "POLLIN" },
268 { POLLPRI, "POLLPRI" },
269 { POLLOUT, "POLLOUT" },
271 { POLLRDNORM, "POLLRDNORM" },
274 { POLLWRNORM, "POLLWRNORM" },
277 { POLLRDBAND, "POLLRDBAND" },
280 { POLLWRBAND, "POLLWRBAND" },
282 { POLLERR, "POLLERR" },
283 { POLLHUP, "POLLHUP" },
284 { POLLNVAL, "POLLNVAL" },
290 decode_poll(struct tcb *tcp, long pts)
294 unsigned long size, start, cur, end, abbrev_end;
298 nfds = tcp->u_arg[1];
299 size = sizeof(fds) * nfds;
300 start = tcp->u_arg[0];
302 if (nfds == 0 || size / sizeof(fds) != nfds || end < start) {
303 tprintf("%#lx, %d, ",
304 tcp->u_arg[0], nfds);
308 abbrev_end = start + max_strlen * sizeof(fds);
309 if (abbrev_end < start)
315 for (cur = start; cur < end; cur += sizeof(fds)) {
318 if (cur >= abbrev_end) {
322 if (umoven(tcp, cur, sizeof fds, (char *) &fds) < 0) {
328 tprintf("{fd=%d}", fds.fd);
332 printfd(tcp, fds.fd);
333 tprintf(", events=");
334 printflags(pollflags, fds.events, "POLL???");
339 tprintf(" %#lx", start);
340 tprintf(", %d, ", nfds);
343 static char outstr[1024];
345 #define end_outstr (outstr + sizeof(outstr))
350 if (tcp->u_rval == 0) {
351 tcp->auxstr = "Timeout";
355 nfds = tcp->u_arg[1];
356 size = sizeof(fds) * nfds;
357 start = tcp->u_arg[0];
359 if (nfds == 0 || size / sizeof(fds) != nfds || end < start)
362 abbrev_end = start + max_strlen * sizeof(fds);
363 if (abbrev_end < start)
371 for (cur = start; cur < end; cur += sizeof(fds)) {
372 if (umoven(tcp, cur, sizeof fds, (char *) &fds) < 0) {
373 if (outptr < end_outstr - 2)
380 if (outptr == outstr) {
383 if (outptr < end_outstr - 3)
384 outptr = stpcpy(outptr, ", ");
386 if (cur >= abbrev_end) {
387 if (outptr < end_outstr - 4)
388 outptr = stpcpy(outptr, "...");
391 if (outptr < end_outstr - (sizeof("{fd=%d, revents=") + sizeof(int)*3) + 1)
392 outptr += sprintf(outptr, "{fd=%d, revents=", fds.fd);
393 flagstr = sprintflags("", pollflags, fds.revents);
394 if (outptr < end_outstr - (strlen(flagstr) + 2)) {
395 outptr = stpcpy(outptr, flagstr);
402 if (outptr != outstr /* && outptr < end_outstr - 1 (always true)*/)
407 if (outptr < end_outstr - 128) {
408 outptr = stpcpy(outptr, outptr == outstr ? "left " : ", left ");
409 sprint_timespec(outptr, tcp, pts);
413 if (outptr == outstr)
416 tcp->auxstr = outstr;
423 sys_poll(struct tcb *tcp)
425 int rc = decode_poll(tcp, 0);
428 if (tcp->u_arg[2] == INFTIM)
432 tprintf("%ld", tcp->u_arg[2]);
439 sys_ppoll(struct tcb *tcp)
441 int rc = decode_poll(tcp, tcp->u_arg[2]);
443 print_timespec(tcp, tcp->u_arg[2]);
445 print_sigset(tcp, tcp->u_arg[3], 0);
446 tprintf(", %lu", tcp->u_arg[4]);
452 #else /* !HAVE_SYS_POLL_H */
454 sys_poll(struct tcb *tcp)
460 #if !defined(LINUX) && !defined(FREEBSD)
462 static const struct xlat stream_flush_options[] = {
463 { FLUSHR, "FLUSHR" },
464 { FLUSHW, "FLUSHW" },
465 { FLUSHRW, "FLUSHRW" },
467 { FLUSHBAND, "FLUSHBAND" },
472 static const struct xlat stream_setsig_flags[] = {
473 { S_INPUT, "S_INPUT" },
474 { S_HIPRI, "S_HIPRI" },
475 { S_OUTPUT, "S_OUTPUT" },
478 { S_ERROR, "S_ERROR" },
481 { S_HANGUP, "S_HANGUP" },
484 { S_RDNORM, "S_RDNORM" },
487 { S_WRNORM, "S_WRNORM" },
490 { S_RDBAND, "S_RDBAND" },
493 { S_WRBAND, "S_WRBAND" },
496 { S_BANDURG, "S_BANDURG" },
501 static const struct xlat stream_read_options[] = {
508 static const struct xlat stream_read_flags[] = {
510 { RPROTDAT, "RPROTDAT" },
513 { RPROTDIS, "RPROTDIS" },
516 { RPROTNORM, "RPROTNORM" },
522 #define RMODEMASK (~0)
526 static const struct xlat stream_write_flags[] = {
527 { SNDZERO, "SNDZERO" },
528 { SNDPIPE, "SNDPIPE" },
531 #endif /* I_SWROPT */
534 static const struct xlat stream_atmark_options[] = {
535 { ANYMARK, "ANYMARK" },
536 { LASTMARK, "LASTMARK" },
539 #endif /* I_ATMARK */
542 static const struct xlat transport_user_options[] = {
543 { T_CONN_REQ, "T_CONN_REQ" },
544 { T_CONN_RES, "T_CONN_RES" },
545 { T_DISCON_REQ, "T_DISCON_REQ" },
546 { T_DATA_REQ, "T_DATA_REQ" },
547 { T_EXDATA_REQ, "T_EXDATA_REQ" },
548 { T_INFO_REQ, "T_INFO_REQ" },
549 { T_BIND_REQ, "T_BIND_REQ" },
550 { T_UNBIND_REQ, "T_UNBIND_REQ" },
551 { T_UNITDATA_REQ,"T_UNITDATA_REQ"},
552 { T_OPTMGMT_REQ,"T_OPTMGMT_REQ" },
553 { T_ORDREL_REQ, "T_ORDREL_REQ" },
557 static const struct xlat transport_user_flags[] = {
559 { T_MORE, "T_MORE" },
560 { T_EXPEDITED, "T_EXPEDITED" },
561 { T_NEGOTIATE, "T_NEGOTIATE" },
562 { T_CHECK, "T_CHECK" },
563 { T_DEFAULT, "T_DEFAULT" },
564 { T_SUCCESS, "T_SUCCESS" },
565 { T_FAILURE, "T_FAILURE" },
566 { T_CURRENT, "T_CURRENT" },
567 { T_PARTSUCCESS,"T_PARTSUCCESS" },
568 { T_READONLY, "T_READONLY" },
569 { T_NOTSUPPORT, "T_NOTSUPPORT" },
574 #ifdef HAVE_STRUCT_T_OPTHDR
576 static const struct xlat xti_level[] = {
577 { XTI_GENERIC, "XTI_GENERIC" },
581 static const struct xlat xti_generic[] = {
582 { XTI_DEBUG, "XTI_DEBUG" },
583 { XTI_LINGER, "XTI_LINGER" },
584 { XTI_RCVBUF, "XTI_RCVBUF" },
585 { XTI_RCVLOWAT, "XTI_RCVLOWAT" },
586 { XTI_SNDBUF, "XTI_SNDBUF" },
587 { XTI_SNDLOWAT, "XTI_SNDLOWAT" },
594 print_xti_optmgmt(struct tcb *tcp, long addr, int len)
599 while (len >= (int) sizeof hdr) {
600 if (umove(tcp, addr, &hdr) < 0) break;
604 else if (len > hdr.len + sizeof hdr) {
608 printxval(xti_level, hdr.level, "???");
612 printxval(xti_generic, hdr.name, "XTI_???");
615 tprintf("%ld", hdr.name);
618 tprintf(", status=");
619 printxval(transport_user_flags, hdr.status, "T_???");
622 if ((hdr.len -= sizeof hdr) > 0) {
623 if (hdr.len > len) break;
625 if (len == sizeof(int))
626 printnum(tcp, addr, "%d");
628 printstr(tcp, addr, hdr.len);
635 if (c++) tprintf(", ");
636 printstr(tcp, addr, len);
638 if (c > 1) tprintf("]");
645 print_optmgmt(struct tcb *tcp, long addr, int len)
647 /* We don't know how to tell if TLI (socket) or XTI
648 optmgmt is being used yet, assume TLI. */
649 #if defined (HAVE_STRUCT_OPTHDR)
650 print_sock_optmgmt(tcp, addr, len);
651 #elif defined (HAVE_STRUCT_T_OPTHDR)
652 print_xti_optmgmt(tcp, addr, len);
654 printstr(tcp, addr, len);
661 static const struct xlat service_type[] = {
662 { T_COTS, "T_COTS" },
663 { T_COTS_ORD, "T_COTS_ORD" },
664 { T_CLTS, "T_CLTS" },
668 static const struct xlat ts_state[] = {
669 { TS_UNBND, "TS_UNBND" },
670 { TS_WACK_BREQ, "TS_WACK_BREQ" },
671 { TS_WACK_UREQ, "TS_WACK_UREQ" },
672 { TS_IDLE, "TS_IDLE" },
673 { TS_WACK_OPTREQ,"TS_WACK_OPTREQ"},
674 { TS_WACK_CREQ, "TS_WACK_CREQ" },
675 { TS_WCON_CREQ, "TS_WCON_CREQ" },
676 { TS_WRES_CIND, "TS_WRES_CIND" },
677 { TS_WACK_CRES, "TS_WACK_CRES" },
678 { TS_DATA_XFER, "TS_DATA_XFER" },
679 { TS_WIND_ORDREL,"TS_WIND_ORDREL"},
680 { TS_WREQ_ORDREL,"TS_WREQ_ORDREL"},
681 { TS_WACK_DREQ6,"TS_WACK_DREQ6" },
682 { TS_WACK_DREQ7,"TS_WACK_DREQ7" },
683 { TS_WACK_DREQ9,"TS_WACK_DREQ9" },
684 { TS_WACK_DREQ10,"TS_WACK_DREQ10"},
685 { TS_WACK_DREQ11,"TS_WACK_DREQ11"},
689 static const struct xlat provider_flags[] = {
691 { SENDZERO, "SENDZERO" },
692 { EXPINLINE, "EXPINLINE" },
693 { XPG4_1, "XPG4_1" },
698 static const struct xlat tli_errors[] = {
699 { TBADADDR, "TBADADDR" },
700 { TBADOPT, "TBADOPT" },
701 { TACCES, "TACCES" },
703 { TNOADDR, "TNOADDR" },
704 { TOUTSTATE, "TOUTSTATE" },
705 { TBADSEQ, "TBADSEQ" },
706 { TSYSERR, "TSYSERR" },
708 { TBADDATA, "TBADDATA" },
709 { TBUFOVFLW, "TBUFOVFLW" },
711 { TNODATA, "TNODATA" },
712 { TNODIS, "TNODIS" },
713 { TNOUDERR, "TNOUDERR" },
714 { TBADFLAG, "TBADFLAG" },
715 { TNOREL, "TNOREL" },
716 { TNOTSUPPORT, "TNOTSUPPORT" },
717 { TSTATECHNG, "TSTATECHNG" },
718 { TNOSTRUCTYPE, "TNOSTRUCTYPE" },
719 { TBADNAME, "TBADNAME" },
720 { TBADQLEN, "TBADQLEN" },
721 { TADDRBUSY, "TADDRBUSY" },
722 { TINDOUT, "TINDOUT" },
723 { TPROVMISMATCH,"TPROVMISMATCH" },
724 { TRESQLEN, "TRESQLEN" },
725 { TRESADDR, "TRESADDR" },
726 { TQFULL, "TQFULL" },
727 { TPROTO, "TPROTO" },
733 print_transport_message(struct tcb *tcp, int expect, long addr, int len)
735 union T_primitives m;
738 if (len < sizeof m.type) goto dump;
740 if (umove(tcp, addr, &m.type) < 0) goto dump;
742 #define GET(type, struct) \
744 if (len < sizeof m.struct) goto dump; \
745 if (umove(tcp, addr, &m.struct) < 0) goto dump;\
747 if (expect != type) { \
755 do { if (c++) tprintf(", "); } while (0)
758 #define STRUCT(struct, elem, print) \
761 if (m.struct.elem##_length < 0 || \
762 m.struct.elem##_offset < sizeof m.struct || \
763 m.struct.elem##_offset + m.struct.elem##_length > len) \
765 tprintf(#elem "_length=%ld, " #elem "_offset=%ld",\
766 m.struct.elem##_length, \
767 m.struct.elem##_offset); \
770 tprintf(#elem "="); \
772 addr + m.struct.elem##_offset, \
773 m.struct.elem##_length); \
778 #define ADDR(struct, elem) STRUCT(struct, elem, printstr)
782 case T_CONN_REQ: /* connect request */
783 GET(T_CONN_REQ, conn_req);
784 ADDR(conn_req, DEST);
789 case T_CONN_RES: /* connect response */
790 GET(T_CONN_RES, conn_res);
791 #ifdef HAVE_STRUCT_T_CONN_RES_QUEUE_PTR
793 tprintf("QUEUE=%p", m.conn_res.QUEUE_ptr);
794 #elif defined HAVE_STRUCT_T_CONN_RES_ACCEPTOR_ID
796 tprintf("ACCEPTOR=%#lx", m.conn_res.ACCEPTOR_id);
800 tprintf("SEQ=%ld", m.conn_res.SEQ_number);
804 case T_DISCON_REQ: /* disconnect request */
805 GET(T_DISCON_REQ, discon_req);
807 tprintf("SEQ=%ld", m.discon_req.SEQ_number);
811 case T_DATA_REQ: /* data request */
812 GET(T_DATA_REQ, data_req);
814 tprintf("MORE=%ld", m.data_req.MORE_flag);
818 case T_EXDATA_REQ: /* expedited data req */
819 GET(T_EXDATA_REQ, exdata_req);
821 tprintf("MORE=%ld", m.exdata_req.MORE_flag);
825 case T_INFO_REQ: /* information req */
826 GET(T_INFO_REQ, info_req);
830 case T_BIND_REQ: /* bind request */
832 case O_T_BIND_REQ: /* Ugly xti/tli hack */
834 GET(T_BIND_REQ, bind_req);
835 ADDR(bind_req, ADDR);
837 tprintf("CONIND=%ld", m.bind_req.CONIND_number);
841 case T_UNBIND_REQ: /* unbind request */
842 GET(T_UNBIND_REQ, unbind_req);
845 #ifdef T_UNITDATA_REQ
846 case T_UNITDATA_REQ: /* unitdata requset */
847 GET(T_UNITDATA_REQ, unitdata_req);
848 ADDR(unitdata_req, DEST);
849 ADDR(unitdata_req, OPT);
853 case T_OPTMGMT_REQ: /* manage opt req */
854 GET(T_OPTMGMT_REQ, optmgmt_req);
857 printflags(transport_user_flags, m.optmgmt_req.MGMT_flags,
859 STRUCT(optmgmt_req, OPT, print_optmgmt);
863 case T_ORDREL_REQ: /* orderly rel req */
864 GET(T_ORDREL_REQ, ordrel_req);
868 case T_CONN_IND: /* connect indication */
869 GET(T_CONN_IND, conn_ind);
872 tprintf(", SEQ=%ld", m.conn_ind.SEQ_number);
876 case T_CONN_CON: /* connect corfirm */
877 GET(T_CONN_CON, conn_con);
883 case T_DISCON_IND: /* discon indication */
884 GET(T_DISCON_IND, discon_ind);
886 tprintf("DISCON=%ld, SEQ=%ld",
887 m.discon_ind.DISCON_reason, m.discon_ind.SEQ_number);
891 case T_DATA_IND: /* data indication */
892 GET(T_DATA_IND, data_ind);
894 tprintf("MORE=%ld", m.data_ind.MORE_flag);
898 case T_EXDATA_IND: /* expedited data ind */
899 GET(T_EXDATA_IND, exdata_ind);
901 tprintf("MORE=%ld", m.exdata_ind.MORE_flag);
905 case T_INFO_ACK: /* info ack */
906 GET(T_INFO_ACK, info_ack);
908 tprintf("TSDU=%ld, ETSDU=%ld, CDATA=%ld, DDATA=%ld, "
909 "ADDR=%ld, OPT=%ld, TIDU=%ld, SERV=",
910 m.info_ack.TSDU_size, m.info_ack.ETSDU_size,
911 m.info_ack.CDATA_size, m.info_ack.DDATA_size,
912 m.info_ack.ADDR_size, m.info_ack.OPT_size,
913 m.info_ack.TIDU_size);
914 printxval(service_type, m.info_ack.SERV_type, "T_???");
915 tprintf(", CURRENT=");
916 printxval(ts_state, m.info_ack.CURRENT_state, "TS_???");
917 tprintf(", PROVIDER=");
918 printflags(provider_flags, m.info_ack.PROVIDER_flag, "???");
922 case T_BIND_ACK: /* bind ack */
923 GET(T_BIND_ACK, bind_ack);
924 ADDR(bind_ack, ADDR);
925 tprintf(", CONIND=%ld", m.bind_ack.CONIND_number);
929 case T_ERROR_ACK: /* error ack */
930 GET(T_ERROR_ACK, error_ack);
933 printxval(transport_user_options,
934 m.error_ack.ERROR_prim, "TI_???");
936 printxval(tli_errors, m.error_ack.TLI_error, "T???");
937 tprintf("UNIX=%s", strerror(m.error_ack.UNIX_error));
941 case T_OK_ACK: /* ok ack */
942 GET(T_OK_ACK, ok_ack);
945 printxval(transport_user_options,
946 m.ok_ack.CORRECT_prim, "TI_???");
949 #ifdef T_UNITDATA_IND
950 case T_UNITDATA_IND: /* unitdata ind */
951 GET(T_UNITDATA_IND, unitdata_ind);
952 ADDR(unitdata_ind, SRC);
953 ADDR(unitdata_ind, OPT);
957 case T_UDERROR_IND: /* unitdata error ind */
958 GET(T_UDERROR_IND, uderror_ind);
959 ADDR(uderror_ind, DEST);
960 ADDR(uderror_ind, OPT);
961 tprintf(", ERROR=%ld", m.uderror_ind.ERROR_type);
965 case T_OPTMGMT_ACK: /* manage opt ack */
966 GET(T_OPTMGMT_ACK, optmgmt_ack);
969 printflags(transport_user_flags, m.optmgmt_ack.MGMT_flags,
971 STRUCT(optmgmt_ack, OPT, print_optmgmt);
975 case T_ORDREL_IND: /* orderly rel ind */
976 GET(T_ORDREL_IND, ordrel_ind);
980 case T_ADDR_REQ: /* address req */
981 GET(T_ADDR_REQ, addr_req);
985 case T_ADDR_ACK: /* address response */
986 GET(T_ADDR_ACK, addr_ack);
987 ADDR(addr_ack, LOCADDR);
988 ADDR(addr_ack, REMADDR);
994 printstr(tcp, addr, len);
998 if (c >= 0) tprintf("}");
1008 #endif /* TI_BIND */
1011 static int internal_stream_ioctl(struct tcb *tcp, int arg)
1014 struct ioctlent *iop;
1018 struct si_udata udata;
1019 #endif /* SI_GETUDATA */
1023 if (umove(tcp, arg, &si) < 0) {
1028 if (entering(tcp)) {
1029 iop = ioctl_lookup(si.ic_cmd);
1031 tprintf(", {ic_cmd=%s", iop->symbol);
1032 while ((iop = ioctl_next_match(iop)))
1033 tprintf(" or %s", iop->symbol);
1035 tprintf(", {ic_cmd=%#x", si.ic_cmd);
1036 if (si.ic_timout == INFTIM)
1037 tprintf(", ic_timout=INFTIM, ");
1039 tprintf(" ic_timout=%d, ", si.ic_timout);
1042 switch (si.ic_cmd) {
1047 #endif /* SI_GETUDATA */
1051 tprintf("/* in */ ");
1053 tprintf(", /* out */ ");
1055 if (in_and_out || entering(tcp))
1056 tprintf("ic_len=%d, ic_dp=", si.ic_len);
1057 switch (si.ic_cmd) {
1060 /* in T_BIND_REQ, out T_BIND_ACK */
1062 if (entering(tcp)) {
1063 print_transport_message(tcp,
1065 si.ic_dp, si.ic_len);
1068 print_transport_message(tcp,
1070 si.ic_dp, si.ic_len);
1073 #endif /* TI_BIND */
1076 /* in T_UNBIND_REQ, out T_OK_ACK */
1078 if (entering(tcp)) {
1079 print_transport_message(tcp,
1081 si.ic_dp, si.ic_len);
1084 print_transport_message(tcp,
1086 si.ic_dp, si.ic_len);
1089 #endif /* TI_UNBIND */
1092 /* in T_INFO_REQ, out T_INFO_ACK */
1094 if (entering(tcp)) {
1095 print_transport_message(tcp,
1097 si.ic_dp, si.ic_len);
1100 print_transport_message(tcp,
1102 si.ic_dp, si.ic_len);
1105 #endif /* TI_GETINFO */
1108 /* in T_OPTMGMT_REQ, out T_OPTMGMT_ACK */
1110 if (entering(tcp)) {
1111 print_transport_message(tcp,
1113 si.ic_dp, si.ic_len);
1116 print_transport_message(tcp,
1118 si.ic_dp, si.ic_len);
1121 #endif /* TI_OPTMGMT */
1126 if (umove(tcp, (int) si.ic_dp, &udata) < 0)
1129 tprintf("{tidusize=%d, addrsize=%d, ",
1130 udata.tidusize, udata.addrsize);
1131 tprintf("optsize=%d, etsdusize=%d, ",
1132 udata.optsize, udata.etsdusize);
1133 tprintf("servtype=%d, so_state=%d, ",
1134 udata.servtype, udata.so_state);
1135 tprintf("so_options=%d", udata.so_options);
1139 #endif /* SI_GETUDATA */
1141 printstr(tcp, (long) si.ic_dp, si.ic_len);
1146 if (timod && tcp->u_rval && !syserror(tcp)) {
1147 tcp->auxstr = xlookup(tli_errors, tcp->u_rval);
1148 return RVAL_STR + 1;
1156 stream_ioctl(struct tcb *tcp, int code, int arg)
1166 struct strfdinsert sfi;
1167 struct strrecvfd srf;
1172 /* I_STR is a special case because the data is read & written. */
1174 return internal_stream_ioctl(tcp, arg);
1182 /* arg is a string */
1184 printpath(tcp, arg);
1187 /* doesn't take an argument */
1190 /* argument is an option */
1192 printxval(stream_flush_options, arg, "FLUSH???");
1196 /* argument is a pointer to a bandinfo struct */
1197 if (umove(tcp, arg, &bi) < 0)
1200 tprintf(", {bi_pri=%d, bi_flag=", bi.bi_pri);
1201 printflags(stream_flush_options, bi.bi_flag, "FLUSH???");
1205 #endif /* I_FLUSHBAND */
1207 /* argument is a set of flags */
1209 printflags(stream_setsig_flags, arg, "S_???");
1212 /* argument is a pointer to a set of flags */
1216 if (umove(tcp, arg, &val) < 0)
1219 printflags(stream_setsig_flags, val, "S_???");
1223 /* argument is a pointer to a strpeek structure */
1224 if (syserror(tcp) || !arg)
1226 if (umove(tcp, arg, &sp) < 0) {
1230 tprintf(", {ctlbuf=");
1231 printstrbuf(tcp, &sp.ctlbuf, 1);
1232 tprintf(", databuf=");
1233 printstrbuf(tcp, &sp.databuf, 1);
1234 tprintf(", flags=");
1235 printflags(msgflags, sp.flags, "RS_???");
1239 /* argument is an option with flags */
1241 printxval(stream_read_options, arg & RMODEMASK, "R???");
1242 addflags(stream_read_flags, arg & ~RMODEMASK);
1245 /* argument is an pointer to an option with flags */
1249 if (umove(tcp, arg, &val) < 0)
1252 printxval(stream_read_options,
1253 arg & RMODEMASK, "R???");
1254 addflags(stream_read_flags, arg & ~RMODEMASK);
1268 /* argument is a pointer to a decimal integer */
1272 printnum(tcp, arg, "%d");
1275 /* argument is a pointer to a strfdinsert structure */
1276 if (syserror(tcp) || !arg)
1278 if (umove(tcp, arg, &sfi) < 0) {
1282 tprintf(", {ctlbuf=");
1283 printstrbuf(tcp, &sfi.ctlbuf, 1);
1284 tprintf(", databuf=");
1285 printstrbuf(tcp, &sfi.databuf, 1);
1286 tprintf(", flags=");
1287 printflags(msgflags, sfi.flags, "RS_???");
1288 tprintf(", filedes=%d, offset=%d}", sfi.fildes, sfi.offset);
1292 /* argument is a set of flags */
1294 printflags(stream_write_flags, arg, "SND???");
1296 #endif /* I_SWROPT */
1299 /* argument is an pointer to an option with flags */
1303 if (umove(tcp, arg, &val) < 0)
1306 printflags(stream_write_flags, arg, "SND???");
1309 #endif /* I_GWROPT */
1321 /* argument is a decimal integer */
1322 tprintf(", %d", arg);
1325 /* argument is a pointer to a strrecvfd structure */
1326 if (syserror(tcp) || !arg)
1328 if (umove(tcp, arg, &srf) < 0) {
1332 tprintf(", {fd=%d, uid=%lu, gid=%lu}", srf.fd,
1333 (unsigned long) srf.uid, (unsigned long) srf.gid);
1343 if (umove(tcp, arg, &sl) < 0) {
1347 tprintf(", {sl_nmods=%d, sl_modlist=[", sl.sl_nmods);
1348 for (i = 0; i < tcp->u_rval; i++) {
1351 printpath(tcp, (int) sl.sl_modlist[i].l_name);
1359 printxval(stream_atmark_options, arg, "???MARK");
1361 #endif /* I_ATMARK */
1367 #endif /* !LINUX && !FREEBSD */
1369 #endif /* HAVE_SYS_STREAM_H || LINUX || FREEBSD */