]> granicus.if.org Git - strace/blob - stream.c
Add argument to tprint_iov() specifying whether to decode each iovec
[strace] / stream.c
1 /*
2  * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
3  * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
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.
16  *
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.
27  *
28  *      $Id$
29  */
30
31 #include "defs.h"
32 #include <sys/syscall.h>
33
34 #ifdef HAVE_POLL_H
35 #include <poll.h>
36 #endif
37 #ifdef HAVE_SYS_POLL_H
38 #include <sys/poll.h>
39 #endif
40 #ifdef HAVE_STROPTS_H
41 #include <stropts.h>
42 #endif
43 #ifdef HAVE_SYS_CONF_H
44 #include <sys/conf.h>
45 #endif
46 #ifdef HAVE_SYS_STREAM_H
47 #include <sys/stream.h>
48 #endif
49 #ifdef HAVE_SYS_TIHDR_H
50 #include <sys/tihdr.h>
51 #endif
52
53 #if defined(HAVE_SYS_STREAM_H) || defined(LINUX) || defined(FREEBSD)
54
55 #ifndef HAVE_STROPTS_H
56 #define RS_HIPRI 1
57 struct strbuf {
58         int     maxlen;                 /* no. of bytes in buffer */
59         int     len;                    /* no. of bytes returned */
60         const char *buf;                /* pointer to data */
61 };
62 #define MORECTL 1
63 #define MOREDATA 2
64 #endif /* !HAVE_STROPTS_H */
65
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 */
71
72 #ifndef FREEBSD
73 static const struct xlat msgflags[] = {
74         { RS_HIPRI,     "RS_HIPRI"      },
75         { 0,            NULL            },
76 };
77
78
79 static void
80 printstrbuf(struct tcb *tcp, struct strbuf *sbp, int getting)
81 {
82         if (sbp->maxlen == -1 && getting)
83                 tprintf("{maxlen=-1}");
84         else {
85                 tprintf("{");
86                 if (getting)
87                         tprintf("maxlen=%d, ", sbp->maxlen);
88                 tprintf("len=%d, buf=", sbp->len);
89                 printstr(tcp, (unsigned long) sbp->buf, sbp->len);
90                 tprintf("}");
91         }
92 }
93
94 static void
95 printstrbufarg(struct tcb *tcp, int arg, int getting)
96 {
97         struct strbuf buf;
98
99         if (arg == 0)
100                 tprintf("NULL");
101         else if (umove(tcp, arg, &buf) < 0)
102                 tprintf("{...}");
103         else
104                 printstrbuf(tcp, &buf, getting);
105         tprintf(", ");
106 }
107
108 int
109 sys_putmsg(struct tcb *tcp)
110 {
111         int i;
112
113         if (entering(tcp)) {
114                 /* fd */
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);
119                 /* flags */
120                 printflags(msgflags, tcp->u_arg[3], "RS_???");
121         }
122         return 0;
123 }
124
125 #if defined(SPARC) || defined(SPARC64) || defined(SUNOS4) || defined(SVR4)
126 int
127 sys_getmsg(struct tcb *tcp)
128 {
129         int i, flags;
130
131         if (entering(tcp)) {
132                 /* fd */
133                 tprintf("%lu, ", tcp->u_arg[0]);
134         } else {
135                 if (syserror(tcp)) {
136                         tprintf("%#lx, %#lx, %#lx",
137                                 tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
138                         return 0;
139                 }
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)
145                         tprintf("NULL");
146                 else if (umove(tcp, tcp->u_arg[3], &flags) < 0)
147                         tprintf("[?]");
148                 else {
149                         tprintf("[");
150                         printflags(msgflags, flags, "RS_???");
151                         tprintf("]");
152                 }
153                 /* decode return value */
154                 switch (tcp->u_rval) {
155                 case MORECTL:
156                         tcp->auxstr = "MORECTL";
157                         break;
158                 case MORECTL|MOREDATA:
159                         tcp->auxstr = "MORECTL|MOREDATA";
160                         break;
161                 case MOREDATA:
162                         tcp->auxstr = "MORECTL";
163                         break;
164                 default:
165                         tcp->auxstr = NULL;
166                         break;
167                 }
168         }
169         return RVAL_HEX | RVAL_STR;
170 }
171 #endif /* SPARC || SPARC64 || SUNOS4 || SVR4 */
172
173 #if defined SYS_putpmsg || defined SYS_getpmsg
174 static const struct xlat pmsgflags[] = {
175 #ifdef MSG_HIPRI
176         { MSG_HIPRI,    "MSG_HIPRI"     },
177 #endif
178 #ifdef MSG_AND
179         { MSG_ANY,      "MSG_ANY"       },
180 #endif
181 #ifdef MSG_BAND
182         { MSG_BAND,     "MSG_BAND"      },
183 #endif
184         { 0,            NULL            },
185 };
186 #endif
187
188 #ifdef SYS_putpmsg
189 int
190 sys_putpmsg(struct tcb *tcp)
191 {
192         int i;
193
194         if (entering(tcp)) {
195                 /* fd */
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);
200                 /* band */
201                 tprintf("%ld, ", tcp->u_arg[3]);
202                 /* flags */
203                 printflags(pmsgflags, tcp->u_arg[4], "MSG_???");
204         }
205         return 0;
206 }
207 #endif /* SYS_putpmsg */
208
209 #ifdef SYS_getpmsg
210 int
211 sys_getpmsg(struct tcb *tcp)
212 {
213         int i, flags;
214
215         if (entering(tcp)) {
216                 /* fd */
217                 tprintf("%lu, ", tcp->u_arg[0]);
218         } else {
219                 if (syserror(tcp)) {
220                         tprintf("%#lx, %#lx, %#lx, %#lx", tcp->u_arg[1],
221                                 tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[4]);
222                         return 0;
223                 }
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");
229                 tprintf(", ");
230                 /* pointer to flags */
231                 if (tcp->u_arg[4] == 0)
232                         tprintf("NULL");
233                 else if (umove(tcp, tcp->u_arg[4], &flags) < 0)
234                         tprintf("[?]");
235                 else {
236                         tprintf("[");
237                         printflags(pmsgflags, flags, "MSG_???");
238                         tprintf("]");
239                 }
240                 /* decode return value */
241                 switch (tcp->u_rval) {
242                 case MORECTL:
243                         tcp->auxstr = "MORECTL";
244                         break;
245                 case MORECTL|MOREDATA:
246                         tcp->auxstr = "MORECTL|MOREDATA";
247                         break;
248                 case MOREDATA:
249                         tcp->auxstr = "MORECTL";
250                         break;
251                 default:
252                         tcp->auxstr = NULL;
253                         break;
254                 }
255         }
256         return RVAL_HEX | RVAL_STR;
257 }
258 #endif /* SYS_getpmsg */
259
260 #endif /* !FREEBSD */
261
262
263 #ifdef HAVE_SYS_POLL_H
264
265 static const struct xlat pollflags[] = {
266 #ifdef POLLIN
267         { POLLIN,       "POLLIN"        },
268         { POLLPRI,      "POLLPRI"       },
269         { POLLOUT,      "POLLOUT"       },
270 #ifdef POLLRDNORM
271         { POLLRDNORM,   "POLLRDNORM"    },
272 #endif
273 #ifdef POLLWRNORM
274         { POLLWRNORM,   "POLLWRNORM"    },
275 #endif
276 #ifdef POLLRDBAND
277         { POLLRDBAND,   "POLLRDBAND"    },
278 #endif
279 #ifdef POLLWRBAND
280         { POLLWRBAND,   "POLLWRBAND"    },
281 #endif
282         { POLLERR,      "POLLERR"       },
283         { POLLHUP,      "POLLHUP"       },
284         { POLLNVAL,     "POLLNVAL"      },
285 #endif
286         { 0,            NULL            },
287 };
288
289 static int
290 decode_poll(struct tcb *tcp, long pts)
291 {
292         struct pollfd fds;
293         unsigned nfds;
294         unsigned long size, start, cur, end, abbrev_end;
295         int failed = 0;
296
297         if (entering(tcp)) {
298                 nfds = tcp->u_arg[1];
299                 size = sizeof(fds) * nfds;
300                 start = tcp->u_arg[0];
301                 end = start + size;
302                 if (nfds == 0 || size / sizeof(fds) != nfds || end < start) {
303                         tprintf("%#lx, %d, ",
304                                 tcp->u_arg[0], nfds);
305                         return 0;
306                 }
307                 if (abbrev(tcp)) {
308                         abbrev_end = start + max_strlen * sizeof(fds);
309                         if (abbrev_end < start)
310                                 abbrev_end = end;
311                 } else {
312                         abbrev_end = end;
313                 }
314                 tprintf("[");
315                 for (cur = start; cur < end; cur += sizeof(fds)) {
316                         if (cur > start)
317                                 tprintf(", ");
318                         if (cur >= abbrev_end) {
319                                 tprintf("...");
320                                 break;
321                         }
322                         if (umoven(tcp, cur, sizeof fds, (char *) &fds) < 0) {
323                                 tprintf("?");
324                                 failed = 1;
325                                 break;
326                         }
327                         if (fds.fd < 0) {
328                                 tprintf("{fd=%d}", fds.fd);
329                                 continue;
330                         }
331                         tprintf("{fd=");
332                         printfd(tcp, fds.fd);
333                         tprintf(", events=");
334                         printflags(pollflags, fds.events, "POLL???");
335                         tprintf("}");
336                 }
337                 tprintf("]");
338                 if (failed)
339                         tprintf(" %#lx", start);
340                 tprintf(", %d, ", nfds);
341                 return 0;
342         } else {
343                 static char outstr[1024];
344                 char str[64];
345                 const char *flagstr;
346                 unsigned int cumlen;
347
348                 if (syserror(tcp))
349                         return 0;
350                 if (tcp->u_rval == 0) {
351                         tcp->auxstr = "Timeout";
352                         return RVAL_STR;
353                 }
354
355                 nfds = tcp->u_arg[1];
356                 size = sizeof(fds) * nfds;
357                 start = tcp->u_arg[0];
358                 end = start + size;
359                 if (nfds == 0 || size / sizeof(fds) != nfds || end < start)
360                         return 0;
361                 if (abbrev(tcp)) {
362                         abbrev_end = start + max_strlen * sizeof(fds);
363                         if (abbrev_end < start)
364                                 abbrev_end = end;
365                 } else {
366                         abbrev_end = end;
367                 }
368
369                 outstr[0] = '\0';
370                 cumlen = 0;
371
372                 for (cur = start; cur < end; cur += sizeof(fds)) {
373                         if (umoven(tcp, cur, sizeof fds, (char *) &fds) < 0) {
374                                 ++cumlen;
375                                 if (cumlen < sizeof(outstr))
376                                         strcat(outstr, "?");
377                                 failed = 1;
378                                 break;
379                         }
380                         if (!fds.revents)
381                                 continue;
382                         if (!cumlen) {
383                                 ++cumlen;
384                                 strcat(outstr, "[");
385                         } else {
386                                 cumlen += 2;
387                                 if (cumlen < sizeof(outstr))
388                                         strcat(outstr, ", ");
389                         }
390                         if (cur >= abbrev_end) {
391                                 cumlen += 3;
392                                 if (cumlen < sizeof(outstr))
393                                         strcat(outstr, "...");
394                                 break;
395                         }
396                         sprintf(str, "{fd=%d, revents=", fds.fd);
397                         flagstr = sprintflags("", pollflags, fds.revents);
398                         cumlen += strlen(str) + strlen(flagstr) + 1;
399                         if (cumlen < sizeof(outstr)) {
400                                 strcat(outstr, str);
401                                 strcat(outstr, flagstr);
402                                 strcat(outstr, "}");
403                         }
404                 }
405                 if (failed)
406                         return 0;
407
408                 if (cumlen && ++cumlen < sizeof(outstr))
409                         strcat(outstr, "]");
410
411                 if (pts) {
412                         char str[128];
413
414                         sprintf(str, "%sleft ", cumlen ? ", " : "");
415                         sprint_timespec(str + strlen(str), tcp, pts);
416                         if ((cumlen += strlen(str)) < sizeof(outstr))
417                                 strcat(outstr, str);
418                 }
419
420                 if (!outstr[0])
421                         return 0;
422
423                 tcp->auxstr = outstr;
424                 return RVAL_STR;
425         }
426 }
427
428 int
429 sys_poll(struct tcb *tcp)
430 {
431         int rc = decode_poll(tcp, 0);
432         if (entering(tcp)) {
433 #ifdef INFTIM
434                 if (tcp->u_arg[2] == INFTIM)
435                         tprintf("INFTIM");
436                 else
437 #endif
438                         tprintf("%ld", tcp->u_arg[2]);
439         }
440         return rc;
441 }
442
443 #ifdef LINUX
444 int
445 sys_ppoll(struct tcb *tcp)
446 {
447         int rc = decode_poll(tcp, tcp->u_arg[2]);
448         if (entering(tcp)) {
449                 print_timespec(tcp, tcp->u_arg[2]);
450                 tprintf(", ");
451                 print_sigset(tcp, tcp->u_arg[3], 0);
452                 tprintf(", %lu", tcp->u_arg[4]);
453         }
454         return rc;
455 }
456 #endif
457
458 #else /* !HAVE_SYS_POLL_H */
459 int
460 sys_poll(struct tcb *tcp)
461 {
462         return 0;
463 }
464 #endif
465
466 #if !defined(LINUX) && !defined(FREEBSD)
467
468 static const struct xlat stream_flush_options[] = {
469         { FLUSHR,       "FLUSHR"        },
470         { FLUSHW,       "FLUSHW"        },
471         { FLUSHRW,      "FLUSHRW"       },
472 #ifdef FLUSHBAND
473         { FLUSHBAND,    "FLUSHBAND"     },
474 #endif
475         { 0,            NULL            },
476 };
477
478 static const struct xlat stream_setsig_flags[] = {
479         { S_INPUT,      "S_INPUT"       },
480         { S_HIPRI,      "S_HIPRI"       },
481         { S_OUTPUT,     "S_OUTPUT"      },
482         { S_MSG,        "S_MSG"         },
483 #ifdef S_ERROR
484         { S_ERROR,      "S_ERROR"       },
485 #endif
486 #ifdef S_HANGUP
487         { S_HANGUP,     "S_HANGUP"      },
488 #endif
489 #ifdef S_RDNORM
490         { S_RDNORM,     "S_RDNORM"      },
491 #endif
492 #ifdef S_WRNORM
493         { S_WRNORM,     "S_WRNORM"      },
494 #endif
495 #ifdef S_RDBAND
496         { S_RDBAND,     "S_RDBAND"      },
497 #endif
498 #ifdef S_WRBAND
499         { S_WRBAND,     "S_WRBAND"      },
500 #endif
501 #ifdef S_BANDURG
502         { S_BANDURG,    "S_BANDURG"     },
503 #endif
504         { 0,            NULL            },
505 };
506
507 static const struct xlat stream_read_options[] = {
508         { RNORM,        "RNORM"         },
509         { RMSGD,        "RMSGD"         },
510         { RMSGN,        "RMSGN"         },
511         { 0,            NULL            },
512 };
513
514 static const struct xlat stream_read_flags[] = {
515 #ifdef RPROTDAT
516         { RPROTDAT,     "RPROTDAT"      },
517 #endif
518 #ifdef RPROTDIS
519         { RPROTDIS,     "RPROTDIS"      },
520 #endif
521 #ifdef RPROTNORM
522         { RPROTNORM,    "RPROTNORM"     },
523 #endif
524         { 0,            NULL            },
525 };
526
527 #ifndef RMODEMASK
528 #define RMODEMASK (~0)
529 #endif
530
531 #ifdef I_SWROPT
532 static const struct xlat stream_write_flags[] = {
533         { SNDZERO,      "SNDZERO"       },
534         { SNDPIPE,      "SNDPIPE"       },
535         { 0,            NULL            },
536 };
537 #endif /* I_SWROPT */
538
539 #ifdef I_ATMARK
540 static const struct xlat stream_atmark_options[] = {
541         { ANYMARK,      "ANYMARK"       },
542         { LASTMARK,     "LASTMARK"      },
543         { 0,            NULL            },
544 };
545 #endif /* I_ATMARK */
546
547 #ifdef TI_BIND
548 static const struct xlat transport_user_options[] = {
549         { T_CONN_REQ,   "T_CONN_REQ"    },
550         { T_CONN_RES,   "T_CONN_RES"    },
551         { T_DISCON_REQ, "T_DISCON_REQ"  },
552         { T_DATA_REQ,   "T_DATA_REQ"    },
553         { T_EXDATA_REQ, "T_EXDATA_REQ"  },
554         { T_INFO_REQ,   "T_INFO_REQ"    },
555         { T_BIND_REQ,   "T_BIND_REQ"    },
556         { T_UNBIND_REQ, "T_UNBIND_REQ"  },
557         { T_UNITDATA_REQ,"T_UNITDATA_REQ"},
558         { T_OPTMGMT_REQ,"T_OPTMGMT_REQ" },
559         { T_ORDREL_REQ, "T_ORDREL_REQ"  },
560         { 0,            NULL            },
561 };
562
563 static const struct xlat transport_user_flags[] = {
564         { 0,            "0"             },
565         { T_MORE,       "T_MORE"        },
566         { T_EXPEDITED,  "T_EXPEDITED"   },
567         { T_NEGOTIATE,  "T_NEGOTIATE"   },
568         { T_CHECK,      "T_CHECK"       },
569         { T_DEFAULT,    "T_DEFAULT"     },
570         { T_SUCCESS,    "T_SUCCESS"     },
571         { T_FAILURE,    "T_FAILURE"     },
572         { T_CURRENT,    "T_CURRENT"     },
573         { T_PARTSUCCESS,"T_PARTSUCCESS" },
574         { T_READONLY,   "T_READONLY"    },
575         { T_NOTSUPPORT, "T_NOTSUPPORT"  },
576         { 0,            NULL            },
577 };
578
579
580 #ifdef HAVE_STRUCT_T_OPTHDR
581
582 static const struct xlat xti_level[] = {
583         { XTI_GENERIC,  "XTI_GENERIC"   },
584         { 0,            NULL            },
585 };
586
587 static const struct xlat xti_generic[] = {
588         { XTI_DEBUG,    "XTI_DEBUG"     },
589         { XTI_LINGER,   "XTI_LINGER"    },
590         { XTI_RCVBUF,   "XTI_RCVBUF"    },
591         { XTI_RCVLOWAT, "XTI_RCVLOWAT"  },
592         { XTI_SNDBUF,   "XTI_SNDBUF"    },
593         { XTI_SNDLOWAT, "XTI_SNDLOWAT"  },
594         { 0,            NULL            },
595 };
596
597
598
599 void
600 print_xti_optmgmt(struct tcb *tcp, long addr, int len)
601 {
602         int c = 0;
603         struct t_opthdr hdr;
604
605         while (len >= (int) sizeof hdr) {
606                 if (umove(tcp, addr, &hdr) < 0) break;
607                 if (c++) {
608                         tprintf(", ");
609                 }
610                 else if (len > hdr.len + sizeof hdr) {
611                         tprintf("[");
612                 }
613                 tprintf("{level=");
614                 printxval(xti_level, hdr.level, "???");
615                 tprintf(", name=");
616                 switch (hdr.level) {
617                     case XTI_GENERIC:
618                         printxval(xti_generic, hdr.name, "XTI_???");
619                         break;
620                     default:
621                         tprintf("%ld", hdr.name);
622                         break;
623                 }
624                 tprintf(", status=");
625                 printxval(transport_user_flags, hdr.status, "T_???");
626                 addr += sizeof hdr;
627                 len -= sizeof hdr;
628                 if ((hdr.len -= sizeof hdr) > 0) {
629                         if (hdr.len > len) break;
630                         tprintf(", val=");
631                         if (len == sizeof(int))
632                                 printnum(tcp, addr, "%d");
633                         else
634                                 printstr(tcp, addr, hdr.len);
635                         addr += hdr.len;
636                         len -= hdr.len;
637                 }
638                 tprintf("}");
639         }
640         if (len > 0) {
641                 if (c++) tprintf(", ");
642                 printstr(tcp, addr, len);
643         }
644         if (c > 1) tprintf("]");
645 }
646
647 #endif
648
649
650 static void
651 print_optmgmt(struct tcb *tcp, long addr, int len)
652 {
653         /* We don't know how to tell if TLI (socket) or XTI
654            optmgmt is being used yet, assume TLI. */
655 #if defined (HAVE_STRUCT_OPTHDR)
656         print_sock_optmgmt(tcp, addr, len);
657 #elif defined (HAVE_STRUCT_T_OPTHDR)
658         print_xti_optmgmt(tcp, addr, len);
659 #else
660         printstr(tcp, addr, len);
661 #endif
662 }
663
664
665
666
667 static const struct xlat service_type[] = {
668         { T_COTS,       "T_COTS"        },
669         { T_COTS_ORD,   "T_COTS_ORD"    },
670         { T_CLTS,       "T_CLTS"        },
671         { 0,            NULL            },
672 };
673
674 static const struct xlat ts_state[] = {
675         { TS_UNBND,     "TS_UNBND"      },
676         { TS_WACK_BREQ, "TS_WACK_BREQ"  },
677         { TS_WACK_UREQ, "TS_WACK_UREQ"  },
678         { TS_IDLE,      "TS_IDLE"       },
679         { TS_WACK_OPTREQ,"TS_WACK_OPTREQ"},
680         { TS_WACK_CREQ, "TS_WACK_CREQ"  },
681         { TS_WCON_CREQ, "TS_WCON_CREQ"  },
682         { TS_WRES_CIND, "TS_WRES_CIND"  },
683         { TS_WACK_CRES, "TS_WACK_CRES"  },
684         { TS_DATA_XFER, "TS_DATA_XFER"  },
685         { TS_WIND_ORDREL,"TS_WIND_ORDREL"},
686         { TS_WREQ_ORDREL,"TS_WREQ_ORDREL"},
687         { TS_WACK_DREQ6,"TS_WACK_DREQ6" },
688         { TS_WACK_DREQ7,"TS_WACK_DREQ7" },
689         { TS_WACK_DREQ9,"TS_WACK_DREQ9" },
690         { TS_WACK_DREQ10,"TS_WACK_DREQ10"},
691         { TS_WACK_DREQ11,"TS_WACK_DREQ11"},
692         { 0,            NULL            },
693 };
694
695 static const struct xlat provider_flags[] = {
696         { 0,            "0"             },
697         { SENDZERO,     "SENDZERO"      },
698         { EXPINLINE,    "EXPINLINE"     },
699         { XPG4_1,       "XPG4_1"        },
700         { 0,            NULL            },
701 };
702
703
704 static const struct xlat tli_errors[] = {
705         { TBADADDR,     "TBADADDR"      },
706         { TBADOPT,      "TBADOPT"       },
707         { TACCES,       "TACCES"        },
708         { TBADF,        "TBADF"         },
709         { TNOADDR,      "TNOADDR"       },
710         { TOUTSTATE,    "TOUTSTATE"     },
711         { TBADSEQ,      "TBADSEQ"       },
712         { TSYSERR,      "TSYSERR"       },
713         { TLOOK,        "TLOOK"         },
714         { TBADDATA,     "TBADDATA"      },
715         { TBUFOVFLW,    "TBUFOVFLW"     },
716         { TFLOW,        "TFLOW"         },
717         { TNODATA,      "TNODATA"       },
718         { TNODIS,       "TNODIS"        },
719         { TNOUDERR,     "TNOUDERR"      },
720         { TBADFLAG,     "TBADFLAG"      },
721         { TNOREL,       "TNOREL"        },
722         { TNOTSUPPORT,  "TNOTSUPPORT"   },
723         { TSTATECHNG,   "TSTATECHNG"    },
724         { TNOSTRUCTYPE, "TNOSTRUCTYPE"  },
725         { TBADNAME,     "TBADNAME"      },
726         { TBADQLEN,     "TBADQLEN"      },
727         { TADDRBUSY,    "TADDRBUSY"     },
728         { TINDOUT,      "TINDOUT"       },
729         { TPROVMISMATCH,"TPROVMISMATCH" },
730         { TRESQLEN,     "TRESQLEN"      },
731         { TRESADDR,     "TRESADDR"      },
732         { TQFULL,       "TQFULL"        },
733         { TPROTO,       "TPROTO"        },
734         { 0,            NULL            },
735 };
736
737
738 static int
739 print_transport_message(struct tcb *tcp, int expect, long addr, int len)
740 {
741         union T_primitives m;
742         int c = 0;
743
744         if (len < sizeof m.type) goto dump;
745
746         if (umove(tcp, addr, &m.type) < 0) goto dump;
747
748 #define GET(type, struct)       \
749         do {                                                    \
750                 if (len < sizeof m.struct) goto dump;           \
751                 if (umove(tcp, addr, &m.struct) < 0) goto dump;\
752                 tprintf("{");                                   \
753                 if (expect != type) {                           \
754                         ++c;                                    \
755                         tprintf(#type);                 \
756                 }                                               \
757         }                                                       \
758         while (0)
759
760 #define COMMA() \
761         do { if (c++) tprintf(", "); } while (0)
762
763
764 #define STRUCT(struct, elem, print)                                     \
765         do {                                                            \
766                 COMMA();                                                \
767                 if (m.struct.elem##_length < 0 ||                       \
768                     m.struct.elem##_offset < sizeof m.struct ||         \
769                     m.struct.elem##_offset + m.struct.elem##_length > len) \
770                 {                                                       \
771                         tprintf(#elem "_length=%ld, " #elem "_offset=%ld",\
772                                 m.struct.elem##_length,                 \
773                                 m.struct.elem##_offset);                \
774                 }                                                       \
775                 else {                                                  \
776                         tprintf(#elem "=");                             \
777                         print(tcp,                                      \
778                                  addr + m.struct.elem##_offset,         \
779                                  m.struct.elem##_length);               \
780                 }                                                       \
781         }                                                               \
782         while (0)
783
784 #define ADDR(struct, elem) STRUCT(struct, elem, printstr)
785
786         switch (m.type) {
787 #ifdef T_CONN_REQ
788             case T_CONN_REQ:    /* connect request   */
789                 GET(T_CONN_REQ, conn_req);
790                 ADDR(conn_req, DEST);
791                 ADDR(conn_req, OPT);
792                 break;
793 #endif
794 #ifdef T_CONN_RES
795             case T_CONN_RES:    /* connect response   */
796                 GET(T_CONN_RES, conn_res);
797 #ifdef HAVE_STRUCT_T_CONN_RES_QUEUE_PTR
798                 COMMA();
799                 tprintf("QUEUE=%p", m.conn_res.QUEUE_ptr);
800 #elif defined HAVE_STRUCT_T_CONN_RES_ACCEPTOR_ID
801                 COMMA();
802                 tprintf("ACCEPTOR=%#lx", m.conn_res.ACCEPTOR_id);
803 #endif
804                 ADDR(conn_res, OPT);
805                 COMMA();
806                 tprintf("SEQ=%ld", m.conn_res.SEQ_number);
807                 break;
808 #endif
809 #ifdef T_DISCON_REQ
810             case T_DISCON_REQ:  /* disconnect request */
811                 GET(T_DISCON_REQ, discon_req);
812                 COMMA();
813                 tprintf("SEQ=%ld", m.discon_req.SEQ_number);
814                 break;
815 #endif
816 #ifdef T_DATA_REQ
817             case T_DATA_REQ:    /* data request       */
818                 GET(T_DATA_REQ, data_req);
819                 COMMA();
820                 tprintf("MORE=%ld", m.data_req.MORE_flag);
821                 break;
822 #endif
823 #ifdef T_EXDATA_REQ
824             case T_EXDATA_REQ:  /* expedited data req */
825                 GET(T_EXDATA_REQ, exdata_req);
826                 COMMA();
827                 tprintf("MORE=%ld", m.exdata_req.MORE_flag);
828                 break;
829 #endif
830 #ifdef T_INFO_REQ
831             case T_INFO_REQ:    /* information req    */
832                 GET(T_INFO_REQ, info_req);
833                 break;
834 #endif
835 #ifdef T_BIND_REQ
836             case T_BIND_REQ:    /* bind request       */
837 #ifdef O_T_BIND_REQ
838             case O_T_BIND_REQ:  /* Ugly xti/tli hack */
839 #endif
840                 GET(T_BIND_REQ, bind_req);
841                 ADDR(bind_req, ADDR);
842                 COMMA();
843                 tprintf("CONIND=%ld", m.bind_req.CONIND_number);
844                 break;
845 #endif
846 #ifdef T_UNBIND_REQ
847             case T_UNBIND_REQ:  /* unbind request     */
848                 GET(T_UNBIND_REQ, unbind_req);
849                 break;
850 #endif
851 #ifdef T_UNITDATA_REQ
852             case T_UNITDATA_REQ:        /* unitdata requset   */
853                 GET(T_UNITDATA_REQ, unitdata_req);
854                 ADDR(unitdata_req, DEST);
855                 ADDR(unitdata_req, OPT);
856                 break;
857 #endif
858 #ifdef T_OPTMGMT_REQ
859             case T_OPTMGMT_REQ: /* manage opt req     */
860                 GET(T_OPTMGMT_REQ, optmgmt_req);
861                 COMMA();
862                 tprintf("MGMT=");
863                 printflags(transport_user_flags, m.optmgmt_req.MGMT_flags,
864                             "T_???");
865                 STRUCT(optmgmt_req, OPT, print_optmgmt);
866                 break;
867 #endif
868 #ifdef T_ORDREL_REQ
869             case T_ORDREL_REQ:  /* orderly rel req    */
870                 GET(T_ORDREL_REQ, ordrel_req);
871                 break;
872 #endif
873 #ifdef T_CONN_IND
874             case T_CONN_IND:    /* connect indication */
875                 GET(T_CONN_IND, conn_ind);
876                 ADDR(conn_ind, SRC);
877                 ADDR(conn_ind, OPT);
878                 tprintf(", SEQ=%ld", m.conn_ind.SEQ_number);
879                 break;
880 #endif
881 #ifdef T_CONN_CON
882             case T_CONN_CON:    /* connect corfirm    */
883                 GET(T_CONN_CON, conn_con);
884                 ADDR(conn_con, RES);
885                 ADDR(conn_con, OPT);
886                 break;
887 #endif
888 #ifdef T_DISCON_IND
889             case T_DISCON_IND:  /* discon indication  */
890                 GET(T_DISCON_IND, discon_ind);
891                 COMMA();
892                 tprintf("DISCON=%ld, SEQ=%ld",
893                          m.discon_ind.DISCON_reason, m.discon_ind.SEQ_number);
894                 break;
895 #endif
896 #ifdef T_DATA_IND
897             case T_DATA_IND:    /* data indication    */
898                 GET(T_DATA_IND, data_ind);
899                 COMMA();
900                 tprintf("MORE=%ld", m.data_ind.MORE_flag);
901                 break;
902 #endif
903 #ifdef T_EXDATA_IND
904             case T_EXDATA_IND:  /* expedited data ind */
905                 GET(T_EXDATA_IND, exdata_ind);
906                 COMMA();
907                 tprintf("MORE=%ld", m.exdata_ind.MORE_flag);
908                 break;
909 #endif
910 #ifdef T_INFO_ACK
911             case T_INFO_ACK:    /* info ack           */
912                 GET(T_INFO_ACK, info_ack);
913                 COMMA();
914                 tprintf("TSDU=%ld, ETSDU=%ld, CDATA=%ld, DDATA=%ld, "
915                          "ADDR=%ld, OPT=%ld, TIDU=%ld, SERV=",
916                          m.info_ack.TSDU_size, m.info_ack.ETSDU_size,
917                          m.info_ack.CDATA_size, m.info_ack.DDATA_size,
918                          m.info_ack.ADDR_size, m.info_ack.OPT_size,
919                          m.info_ack.TIDU_size);
920                 printxval(service_type, m.info_ack.SERV_type, "T_???");
921                 tprintf(", CURRENT=");
922                 printxval(ts_state, m.info_ack.CURRENT_state, "TS_???");
923                 tprintf(", PROVIDER=");
924                 printflags(provider_flags, m.info_ack.PROVIDER_flag, "???");
925                 break;
926 #endif
927 #ifdef T_BIND_ACK
928             case T_BIND_ACK:    /* bind ack           */
929                 GET(T_BIND_ACK, bind_ack);
930                 ADDR(bind_ack, ADDR);
931                 tprintf(", CONIND=%ld", m.bind_ack.CONIND_number);
932                 break;
933 #endif
934 #ifdef T_ERROR_ACK
935             case T_ERROR_ACK:   /* error ack          */
936                 GET(T_ERROR_ACK, error_ack);
937                 COMMA();
938                 tprintf("ERROR=");
939                 printxval(transport_user_options,
940                            m.error_ack.ERROR_prim, "TI_???");
941                 tprintf(", TLI=");
942                 printxval(tli_errors, m.error_ack.TLI_error, "T???");
943                 tprintf("UNIX=%s", strerror(m.error_ack.UNIX_error));
944                 break;
945 #endif
946 #ifdef T_OK_ACK
947             case T_OK_ACK:      /* ok ack             */
948                 GET(T_OK_ACK, ok_ack);
949                 COMMA();
950                 tprintf("CORRECT=");
951                 printxval(transport_user_options,
952                            m.ok_ack.CORRECT_prim, "TI_???");
953                 break;
954 #endif
955 #ifdef T_UNITDATA_IND
956             case T_UNITDATA_IND:        /* unitdata ind       */
957                 GET(T_UNITDATA_IND, unitdata_ind);
958                 ADDR(unitdata_ind, SRC);
959                 ADDR(unitdata_ind, OPT);
960                 break;
961 #endif
962 #ifdef T_UDERROR_IND
963             case T_UDERROR_IND: /* unitdata error ind */
964                 GET(T_UDERROR_IND, uderror_ind);
965                 ADDR(uderror_ind, DEST);
966                 ADDR(uderror_ind, OPT);
967                 tprintf(", ERROR=%ld", m.uderror_ind.ERROR_type);
968                 break;
969 #endif
970 #ifdef T_OPTMGMT_ACK
971             case T_OPTMGMT_ACK: /* manage opt ack     */
972                 GET(T_OPTMGMT_ACK, optmgmt_ack);
973                 COMMA();
974                 tprintf("MGMT=");
975                 printflags(transport_user_flags, m.optmgmt_ack.MGMT_flags,
976                             "T_???");
977                 STRUCT(optmgmt_ack, OPT, print_optmgmt);
978                 break;
979 #endif
980 #ifdef T_ORDREL_IND
981         case T_ORDREL_IND:      /* orderly rel ind    */
982                 GET(T_ORDREL_IND, ordrel_ind);
983                 break;
984 #endif
985 #ifdef T_ADDR_REQ
986             case T_ADDR_REQ:    /* address req        */
987                 GET(T_ADDR_REQ, addr_req);
988                 break;
989 #endif
990 #ifdef T_ADDR_ACK
991             case T_ADDR_ACK:    /* address response   */
992                 GET(T_ADDR_ACK, addr_ack);
993                 ADDR(addr_ack, LOCADDR);
994                 ADDR(addr_ack, REMADDR);
995                 break;
996 #endif
997             default:
998             dump:
999                 c = -1;
1000                 printstr(tcp, addr, len);
1001                 break;
1002         }
1003
1004         if (c >= 0) tprintf("}");
1005
1006 #undef ADDR
1007 #undef COMMA
1008 #undef STRUCT
1009
1010         return 0;
1011 }
1012
1013
1014 #endif /* TI_BIND */
1015
1016
1017 static int internal_stream_ioctl(struct tcb *tcp, int arg)
1018 {
1019         struct strioctl si;
1020         struct ioctlent *iop;
1021         int in_and_out;
1022         int timod = 0;
1023 #ifdef SI_GETUDATA
1024         struct si_udata udata;
1025 #endif /* SI_GETUDATA */
1026
1027         if (!arg)
1028                 return 0;
1029         if (umove(tcp, arg, &si) < 0) {
1030                 if (entering(tcp))
1031                         tprintf(", {...}");
1032                 return 1;
1033         }
1034         if (entering(tcp)) {
1035                 iop = ioctl_lookup(si.ic_cmd);
1036                 if (iop) {
1037                         tprintf(", {ic_cmd=%s", iop->symbol);
1038                         while ((iop = ioctl_next_match(iop)))
1039                                 tprintf(" or %s", iop->symbol);
1040                 } else
1041                         tprintf(", {ic_cmd=%#x", si.ic_cmd);
1042                 if (si.ic_timout == INFTIM)
1043                         tprintf(", ic_timout=INFTIM, ");
1044                 else
1045                         tprintf(" ic_timout=%d, ", si.ic_timout);
1046         }
1047         in_and_out = 1;
1048         switch (si.ic_cmd) {
1049 #ifdef SI_GETUDATA
1050         case SI_GETUDATA:
1051                 in_and_out = 0;
1052                 break;
1053 #endif /* SI_GETUDATA */
1054         }
1055         if (in_and_out) {
1056                 if (entering(tcp))
1057                         tprintf("/* in */ ");
1058                 else
1059                         tprintf(", /* out */ ");
1060         }
1061         if (in_and_out || entering(tcp))
1062                 tprintf("ic_len=%d, ic_dp=", si.ic_len);
1063         switch (si.ic_cmd) {
1064 #ifdef TI_BIND
1065         case TI_BIND:
1066                 /* in T_BIND_REQ, out T_BIND_ACK */
1067                 ++timod;
1068                 if (entering(tcp)) {
1069                         print_transport_message(tcp,
1070                                                  T_BIND_REQ,
1071                                                  si.ic_dp, si.ic_len);
1072                 }
1073                 else {
1074                         print_transport_message(tcp,
1075                                                  T_BIND_ACK,
1076                                                  si.ic_dp, si.ic_len);
1077                 }
1078                 break;
1079 #endif /* TI_BIND */
1080 #ifdef TI_UNBIND
1081         case TI_UNBIND:
1082                 /* in T_UNBIND_REQ, out T_OK_ACK */
1083                 ++timod;
1084                 if (entering(tcp)) {
1085                         print_transport_message(tcp,
1086                                                  T_UNBIND_REQ,
1087                                                  si.ic_dp, si.ic_len);
1088                 }
1089                 else {
1090                         print_transport_message(tcp,
1091                                                  T_OK_ACK,
1092                                                  si.ic_dp, si.ic_len);
1093                 }
1094                 break;
1095 #endif /* TI_UNBIND */
1096 #ifdef TI_GETINFO
1097         case TI_GETINFO:
1098                 /* in T_INFO_REQ, out T_INFO_ACK */
1099                 ++timod;
1100                 if (entering(tcp)) {
1101                         print_transport_message(tcp,
1102                                                  T_INFO_REQ,
1103                                                  si.ic_dp, si.ic_len);
1104                 }
1105                 else {
1106                         print_transport_message(tcp,
1107                                                  T_INFO_ACK,
1108                                                  si.ic_dp, si.ic_len);
1109                 }
1110                 break;
1111 #endif /* TI_GETINFO */
1112 #ifdef TI_OPTMGMT
1113         case TI_OPTMGMT:
1114                 /* in T_OPTMGMT_REQ, out T_OPTMGMT_ACK */
1115                 ++timod;
1116                 if (entering(tcp)) {
1117                         print_transport_message(tcp,
1118                                                  T_OPTMGMT_REQ,
1119                                                  si.ic_dp, si.ic_len);
1120                 }
1121                 else {
1122                         print_transport_message(tcp,
1123                                                  T_OPTMGMT_ACK,
1124                                                  si.ic_dp, si.ic_len);
1125                 }
1126                 break;
1127 #endif /* TI_OPTMGMT */
1128 #ifdef SI_GETUDATA
1129         case SI_GETUDATA:
1130                 if (entering(tcp))
1131                         break;
1132                 if (umove(tcp, (int) si.ic_dp, &udata) < 0)
1133                         tprintf("{...}");
1134                 else {
1135                         tprintf("{tidusize=%d, addrsize=%d, ",
1136                                 udata.tidusize, udata.addrsize);
1137                         tprintf("optsize=%d, etsdusize=%d, ",
1138                                 udata.optsize, udata.etsdusize);
1139                         tprintf("servtype=%d, so_state=%d, ",
1140                                 udata.servtype, udata.so_state);
1141                         tprintf("so_options=%d", udata.so_options);
1142                         tprintf("}");
1143                 }
1144                 break;
1145 #endif /* SI_GETUDATA */
1146         default:
1147                 printstr(tcp, (long) si.ic_dp, si.ic_len);
1148                 break;
1149         }
1150         if (exiting(tcp)) {
1151                 tprintf("}");
1152                 if (timod && tcp->u_rval && !syserror(tcp)) {
1153                         tcp->auxstr = xlookup(tli_errors, tcp->u_rval);
1154                         return RVAL_STR + 1;
1155                 }
1156         }
1157
1158         return 1;
1159 }
1160
1161 int
1162 stream_ioctl(struct tcb *tcp, int code, int arg)
1163 {
1164 #ifdef I_LIST
1165         int i;
1166 #endif
1167         int val;
1168 #ifdef I_FLUSHBAND
1169         struct bandinfo bi;
1170 #endif
1171         struct strpeek sp;
1172         struct strfdinsert sfi;
1173         struct strrecvfd srf;
1174 #ifdef I_LIST
1175         struct str_list sl;
1176 #endif
1177
1178         /* I_STR is a special case because the data is read & written. */
1179         if (code == I_STR)
1180                 return internal_stream_ioctl(tcp, arg);
1181         if (entering(tcp))
1182                 return 0;
1183
1184         switch (code) {
1185         case I_PUSH:
1186         case I_LOOK:
1187         case I_FIND:
1188                 /* arg is a string */
1189                 tprintf(", ");
1190                 printpath(tcp, arg);
1191                 return 1;
1192         case I_POP:
1193                 /* doesn't take an argument */
1194                 return 1;
1195         case I_FLUSH:
1196                 /* argument is an option */
1197                 tprintf(", ");
1198                 printxval(stream_flush_options, arg, "FLUSH???");
1199                 return 1;
1200 #ifdef I_FLUSHBAND
1201         case I_FLUSHBAND:
1202                 /* argument is a pointer to a bandinfo struct */
1203                 if (umove(tcp, arg, &bi) < 0)
1204                         tprintf(", {...}");
1205                 else {
1206                         tprintf(", {bi_pri=%d, bi_flag=", bi.bi_pri);
1207                         printflags(stream_flush_options, bi.bi_flag, "FLUSH???");
1208                         tprintf("}");
1209                 }
1210                 return 1;
1211 #endif /* I_FLUSHBAND */
1212         case I_SETSIG:
1213                 /* argument is a set of flags */
1214                 tprintf(", ");
1215                 printflags(stream_setsig_flags, arg, "S_???");
1216                 return 1;
1217         case I_GETSIG:
1218                 /* argument is a pointer to a set of flags */
1219                 if (syserror(tcp))
1220                         return 0;
1221                 tprintf(", [");
1222                 if (umove(tcp, arg, &val) < 0)
1223                         tprintf("?");
1224                 else
1225                         printflags(stream_setsig_flags, val, "S_???");
1226                 tprintf("]");
1227                 return 1;
1228         case I_PEEK:
1229                 /* argument is a pointer to a strpeek structure */
1230                 if (syserror(tcp) || !arg)
1231                         return 0;
1232                 if (umove(tcp, arg, &sp) < 0) {
1233                         tprintf(", {...}");
1234                         return 1;
1235                 }
1236                 tprintf(", {ctlbuf=");
1237                 printstrbuf(tcp, &sp.ctlbuf, 1);
1238                 tprintf(", databuf=");
1239                 printstrbuf(tcp, &sp.databuf, 1);
1240                 tprintf(", flags=");
1241                 printflags(msgflags, sp.flags, "RS_???");
1242                 tprintf("}");
1243                 return 1;
1244         case I_SRDOPT:
1245                 /* argument is an option with flags */
1246                 tprintf(", ");
1247                 printxval(stream_read_options, arg & RMODEMASK, "R???");
1248                 addflags(stream_read_flags, arg & ~RMODEMASK);
1249                 return 1;
1250         case I_GRDOPT:
1251                 /* argument is an pointer to an option with flags */
1252                 if (syserror(tcp))
1253                         return 0;
1254                 tprintf(", [");
1255                 if (umove(tcp, arg, &val) < 0)
1256                         tprintf("?");
1257                 else {
1258                         printxval(stream_read_options,
1259                                   arg & RMODEMASK, "R???");
1260                         addflags(stream_read_flags, arg & ~RMODEMASK);
1261                 }
1262                 tprintf("]");
1263                 return 1;
1264         case I_NREAD:
1265 #ifdef I_GETBAND
1266         case I_GETBAND:
1267 #endif
1268 #ifdef I_SETCLTIME
1269         case I_SETCLTIME:
1270 #endif
1271 #ifdef I_GETCLTIME
1272         case I_GETCLTIME:
1273 #endif
1274                 /* argument is a pointer to a decimal integer */
1275                 if (syserror(tcp))
1276                         return 0;
1277                 tprintf(", ");
1278                 printnum(tcp, arg, "%d");
1279                 return 1;
1280         case I_FDINSERT:
1281                 /* argument is a pointer to a strfdinsert structure */
1282                 if (syserror(tcp) || !arg)
1283                         return 0;
1284                 if (umove(tcp, arg, &sfi) < 0) {
1285                         tprintf(", {...}");
1286                         return 1;
1287                 }
1288                 tprintf(", {ctlbuf=");
1289                 printstrbuf(tcp, &sfi.ctlbuf, 1);
1290                 tprintf(", databuf=");
1291                 printstrbuf(tcp, &sfi.databuf, 1);
1292                 tprintf(", flags=");
1293                 printflags(msgflags, sfi.flags, "RS_???");
1294                 tprintf(", filedes=%d, offset=%d}", sfi.fildes, sfi.offset);
1295                 return 1;
1296 #ifdef I_SWROPT
1297         case I_SWROPT:
1298                 /* argument is a set of flags */
1299                 tprintf(", ");
1300                 printflags(stream_write_flags, arg, "SND???");
1301                 return 1;
1302 #endif /* I_SWROPT */
1303 #ifdef I_GWROPT
1304         case I_GWROPT:
1305                 /* argument is an pointer to an option with flags */
1306                 if (syserror(tcp))
1307                         return 0;
1308                 tprintf(", [");
1309                 if (umove(tcp, arg, &val) < 0)
1310                         tprintf("?");
1311                 else
1312                         printflags(stream_write_flags, arg, "SND???");
1313                 tprintf("]");
1314                 return 1;
1315 #endif /* I_GWROPT */
1316         case I_SENDFD:
1317 #ifdef I_CKBAND
1318         case I_CKBAND:
1319 #endif
1320 #ifdef I_CANPUT
1321         case I_CANPUT:
1322 #endif
1323         case I_LINK:
1324         case I_UNLINK:
1325         case I_PLINK:
1326         case I_PUNLINK:
1327                 /* argument is a decimal integer */
1328                 tprintf(", %d", arg);
1329                 return 1;
1330         case I_RECVFD:
1331                 /* argument is a pointer to a strrecvfd structure */
1332                 if (syserror(tcp) || !arg)
1333                         return 0;
1334                 if (umove(tcp, arg, &srf) < 0) {
1335                         tprintf(", {...}");
1336                         return 1;
1337                 }
1338                 tprintf(", {fd=%d, uid=%lu, gid=%lu}", srf.fd,
1339                         (unsigned long) srf.uid, (unsigned long) srf.gid);
1340                 return 1;
1341 #ifdef I_LIST
1342         case I_LIST:
1343                 if (syserror(tcp))
1344                         return 0;
1345                 if (arg == 0) {
1346                         tprintf(", NULL");
1347                         return 1;
1348                 }
1349                 if (umove(tcp, arg, &sl) < 0) {
1350                         tprintf(", {...}");
1351                         return 1;
1352                 }
1353                 tprintf(", {sl_nmods=%d, sl_modlist=[", sl.sl_nmods);
1354                 for (i = 0; i < tcp->u_rval; i++) {
1355                         if (i)
1356                                 tprintf(", ");
1357                         printpath(tcp, (int) sl.sl_modlist[i].l_name);
1358                 }
1359                 tprintf("]}");
1360                 return 1;
1361 #endif /* I_LIST */
1362 #ifdef I_ATMARK
1363         case I_ATMARK:
1364                 tprintf(", ");
1365                 printxval(stream_atmark_options, arg, "???MARK");
1366                 return 1;
1367 #endif /* I_ATMARK */
1368         default:
1369                 return 0;
1370         }
1371 }
1372
1373 #endif /* !LINUX && !FREEBSD */
1374
1375 #endif /* HAVE_SYS_STREAM_H || LINUX || FREEBSD */