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