blob: 872ba5947c90c3a55420c15782eac28fbca0ef03 [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
2 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00003 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00004 * 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
Wichert Akkerman42080d82001-04-10 10:32:26 +000033#ifdef HAVE_POLL_H
34#include <poll.h>
35#endif
Pavel Machek245a6ac2000-02-01 16:12:33 +000036#ifdef HAVE_SYS_POLL_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000037#include <sys/poll.h>
Pavel Machek245a6ac2000-02-01 16:12:33 +000038#endif
Wichert Akkerman42080d82001-04-10 10:32:26 +000039#ifdef HAVE_STROPTS_H
40#include <stropts.h>
41#endif
42#ifdef HAVE_SYS_CONF_H
43#include <sys/conf.h>
44#endif
45#ifdef HAVE_SYS_STREAM_H
46#include <sys/stream.h>
47#endif
48#ifdef HAVE_SYS_TIHDR_H
49#include <sys/tihdr.h>
50#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000051
Wichert Akkerman42080d82001-04-10 10:32:26 +000052#if defined(HAVE_SYS_STREAM_H) || defined(linux) || defined(FREEBSD)
53
54#ifndef HAVE_STROPTS_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000055#define RS_HIPRI 1
56struct strbuf {
57 int maxlen; /* no. of bytes in buffer */
58 int len; /* no. of bytes returned */
59 char *buf; /* pointer to data */
60};
61#define MORECTL 1
62#define MOREDATA 2
Wichert Akkerman42080d82001-04-10 10:32:26 +000063#endif /* !HAVE_STROPTS_H */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000064
65#ifdef HAVE_SYS_TIUSER_H
66#include <sys/tiuser.h>
67#include <sys/sockmod.h>
68#include <sys/timod.h>
69#endif /* HAVE_SYS_TIUSER_H */
70
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +000071#ifndef FREEBSD
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000072static struct xlat msgflags[] = {
73 { RS_HIPRI, "RS_HIPRI" },
74 { 0, NULL },
75};
76
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000077
78static void
79printstrbuf(tcp, sbp, getting)
80struct tcb *tcp;
81struct strbuf *sbp;
82int getting;
83{
84 if (sbp->maxlen == -1 && getting)
85 tprintf("{maxlen=-1}");
86 else {
87 tprintf("{");
88 if (getting)
89 tprintf("maxlen=%d, ", sbp->maxlen);
90 tprintf("len=%d, buf=", sbp->len);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +000091 printstr(tcp, (unsigned long) sbp->buf, sbp->len);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000092 tprintf("}");
93 }
94}
95
96static void
97printstrbufarg(tcp, arg, getting)
98struct tcb *tcp;
99int arg;
100int getting;
101{
102 struct strbuf buf;
103
104 if (arg == 0)
105 tprintf("NULL");
106 else if (umove(tcp, arg, &buf) < 0)
107 tprintf("{...}");
108 else
109 printstrbuf(tcp, &buf, getting);
110 tprintf(", ");
111}
112
113int
114sys_putmsg(tcp)
115struct tcb *tcp;
116{
117 int i;
118
119 if (entering(tcp)) {
120 /* fd */
121 tprintf("%ld, ", tcp->u_arg[0]);
122 /* control and data */
123 for (i = 1; i < 3; i++)
124 printstrbufarg(tcp, tcp->u_arg[i], 0);
125 /* flags */
126 if (!printflags(msgflags, tcp->u_arg[3]))
127 tprintf("0");
128 }
129 return 0;
130}
131
132int
133sys_getmsg(tcp)
134struct 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 if (!printflags(msgflags, flags))
158 tprintf("0");
159 tprintf("]");
160 }
161 /* decode return value */
162 switch (tcp->u_rval) {
163 case MORECTL:
164 tcp->auxstr = "MORECTL";
165 break;
166 case MORECTL|MOREDATA:
167 tcp->auxstr = "MORECTL|MOREDATA";
168 break;
169 case MOREDATA:
170 tcp->auxstr = "MORECTL";
171 break;
172 default:
173 tcp->auxstr = NULL;
174 break;
175 }
176 }
177 return RVAL_HEX | RVAL_STR;
178}
179
180#ifdef HAVE_PUTPMSG
181
182static struct xlat pmsgflags[] = {
Wichert Akkermand856b992000-10-13 12:47:12 +0000183#ifdef MSG_HIPRI
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000184 { MSG_HIPRI, "MSG_HIPRI" },
Wichert Akkermand856b992000-10-13 12:47:12 +0000185#endif
186#ifdef MSG_AND
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000187 { MSG_ANY, "MSG_ANY" },
Wichert Akkermand856b992000-10-13 12:47:12 +0000188#endif
189#ifdef MSG_BAND
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000190 { MSG_BAND, "MSG_BAND" },
Wichert Akkermand856b992000-10-13 12:47:12 +0000191#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000192 { 0, NULL },
193};
194
195int
196sys_putpmsg(tcp)
197struct 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 if (!printflags(pmsgflags, tcp->u_arg[4]))
211 tprintf("0");
212 }
213 return 0;
214}
215
216int
217sys_getpmsg(tcp)
218struct tcb *tcp;
219{
220 int i, flags;
221
222 if (entering(tcp)) {
223 /* fd */
224 tprintf("%lu, ", tcp->u_arg[0]);
225 } else {
226 if (syserror(tcp)) {
227 tprintf("%#lx, %#lx, %#lx, %#lx", tcp->u_arg[1],
228 tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[4]);
229 return 0;
230 }
231 /* control and data */
232 for (i = 1; i < 3; i++)
233 printstrbufarg(tcp, tcp->u_arg[i], 1);
234 /* pointer to band */
235 printnum(tcp, tcp->u_arg[3], "%d");
Wichert Akkerman906dade1999-11-26 09:18:37 +0000236 tprintf(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000237 /* pointer to flags */
238 if (tcp->u_arg[4] == 0)
239 tprintf("NULL");
240 else if (umove(tcp, tcp->u_arg[4], &flags) < 0)
241 tprintf("[?]");
242 else {
243 tprintf("[");
244 if (!printflags(pmsgflags, flags))
245 tprintf("0");
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
267#endif /* HAVE_PUTPMSG */
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000268#endif /* !FREEBSD */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000269
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000270
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000271#ifdef HAVE_SYS_POLL_H
272
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000273static struct xlat pollflags[] = {
Pavel Machek245a6ac2000-02-01 16:12:33 +0000274#ifdef POLLIN
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000275 { 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" },
Pavel Machek245a6ac2000-02-01 16:12:33 +0000293#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000294 { 0, NULL },
295};
296
297int
298sys_poll(tcp)
299struct tcb *tcp;
300{
301 struct pollfd *pollp;
302
303 if (exiting(tcp)) {
304 int i;
305 int nfds = tcp->u_arg[1];
306
307 if (nfds <= 0) {
308 tprintf("%#lx, %d, %ld\n",
309 tcp->u_arg[0], nfds, tcp->u_arg[2]);
310 return 0;
311 }
312 pollp = (struct pollfd *) malloc(nfds * sizeof(*pollp));
313 if (pollp == NULL) {
314 fprintf(stderr, "sys_poll: no memory\n");
315 tprintf("%#lx, %d, %ld",
316 tcp->u_arg[0], nfds, tcp->u_arg[2]);
317 return 0;
318 }
319 if (umoven(tcp, tcp->u_arg[0],
320 (nfds * sizeof(*pollp)), (char *) pollp) < 0) {
321 tprintf("%#lx", tcp->u_arg[0]);
322 }
323 else {
324 tprintf("[");
325 for (i = 0; i < nfds; i++) {
326 if (i)
327 tprintf(", ");
328 if (pollp[i].fd < 0) {
329 tprintf("{fd=%d}", pollp[i].fd);
330 continue;
331 }
332 tprintf("{fd=%d, events=", pollp[i].fd);
333 if (!printflags(pollflags, pollp[i].events))
334 tprintf("0");
335 if (!syserror(tcp) && pollp[i].revents) {
336 tprintf(", revents=");
337 if (!printflags(pollflags,
338 pollp[i].revents))
339 tprintf("0");
340 }
341 tprintf("}");
342 }
343 tprintf("]");
344 }
345 tprintf(", %d, ", nfds);
346#ifdef INFTIM
347 if (tcp->u_arg[2] == INFTIM)
348 tprintf("INFTIM");
349 else
350#endif
351 tprintf("%ld", tcp->u_arg[2]);
352 free(pollp);
353 }
354 return 0;
355}
356
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000357#else /* !HAVE_SYS_POLL_H */
358int
359sys_poll(tcp)
360struct tcb *tcp;
361{
362 return 0;
363}
364#endif
365
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000366#if !defined(linux) && !defined(FREEBSD)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000367
368static struct xlat stream_flush_options[] = {
369 { FLUSHR, "FLUSHR" },
370 { FLUSHW, "FLUSHW" },
371 { FLUSHRW, "FLUSHRW" },
372#ifdef FLUSHBAND
373 { FLUSHBAND, "FLUSHBAND" },
374#endif
375 { 0, NULL },
376};
377
378static struct xlat stream_setsig_flags[] = {
379 { S_INPUT, "S_INPUT" },
380 { S_HIPRI, "S_HIPRI" },
381 { S_OUTPUT, "S_OUTPUT" },
382 { S_MSG, "S_MSG" },
383#ifdef S_ERROR
384 { S_ERROR, "S_ERROR" },
385#endif
386#ifdef S_HANGUP
387 { S_HANGUP, "S_HANGUP" },
388#endif
389#ifdef S_RDNORM
390 { S_RDNORM, "S_RDNORM" },
391#endif
392#ifdef S_WRNORM
393 { S_WRNORM, "S_WRNORM" },
394#endif
395#ifdef S_RDBAND
396 { S_RDBAND, "S_RDBAND" },
397#endif
398#ifdef S_WRBAND
399 { S_WRBAND, "S_WRBAND" },
400#endif
401#ifdef S_BANDURG
402 { S_BANDURG, "S_BANDURG" },
403#endif
404 { 0, NULL },
405};
406
407static struct xlat stream_read_options[] = {
408 { RNORM, "RNORM" },
409 { RMSGD, "RMSGD" },
410 { RMSGN, "RMSGN" },
411 { 0, NULL },
412};
413
414static struct xlat stream_read_flags[] = {
415#ifdef RPROTDAT
416 { RPROTDAT, "RPROTDAT" },
417#endif
418#ifdef RPROTDIS
419 { RPROTDIS, "RPROTDIS" },
420#endif
421#ifdef RPROTNORM
422 { RPROTNORM, "RPROTNORM" },
423#endif
424 { 0, NULL },
425};
426
427#ifndef RMODEMASK
428#define RMODEMASK (~0)
429#endif
430
431#ifdef I_SWROPT
432static struct xlat stream_write_flags[] = {
433 { SNDZERO, "SNDZERO" },
434 { SNDPIPE, "SNDPIPE" },
435 { 0, NULL },
436};
437#endif /* I_SWROPT */
438
439#ifdef I_ATMARK
440static struct xlat stream_atmark_options[] = {
441 { ANYMARK, "ANYMARK" },
442 { LASTMARK, "LASTMARK" },
443 { 0, NULL },
444};
445#endif /* I_ATMARK */
446
447#ifdef TI_BIND
448static struct xlat transport_user_options[] = {
449 { T_CONN_REQ, "T_CONN_REQ" },
450 { T_CONN_RES, "T_CONN_RES" },
451 { T_DISCON_REQ, "T_DISCON_REQ" },
452 { T_DATA_REQ, "T_DATA_REQ" },
453 { T_EXDATA_REQ, "T_EXDATA_REQ" },
454 { T_INFO_REQ, "T_INFO_REQ" },
455 { T_BIND_REQ, "T_BIND_REQ" },
456 { T_UNBIND_REQ, "T_UNBIND_REQ" },
457 { T_UNITDATA_REQ,"T_UNITDATA_REQ"},
458 { T_OPTMGMT_REQ,"T_OPTMGMT_REQ" },
459 { T_ORDREL_REQ, "T_ORDREL_REQ" },
460 { 0, NULL },
461};
462
463static struct xlat transport_provider_options[] = {
464 { T_CONN_IND, "T_CONN_IND" },
465 { T_CONN_CON, "T_CONN_CON" },
466 { T_DISCON_IND, "T_DISCON_IND" },
467 { T_DATA_IND, "T_DATA_IND" },
468 { T_EXDATA_IND, "T_EXDATA_IND" },
469 { T_INFO_ACK, "T_INFO_ACK" },
470 { T_BIND_ACK, "T_BIND_ACK" },
471 { T_ERROR_ACK, "T_ERROR_ACK" },
472 { T_OK_ACK, "T_OK_ACK" },
473 { T_UNITDATA_IND,"T_UNITDATA_IND"},
474 { T_UDERROR_IND,"T_UDERROR_IND" },
475 { T_OPTMGMT_ACK,"T_OPTMGMT_ACK" },
476 { T_ORDREL_IND, "T_ORDREL_IND" },
477 { 0, NULL },
478};
479#endif /* TI_BIND */
480
481static int
482internal_stream_ioctl(tcp, arg)
483struct tcb *tcp;
484int arg;
485{
486 struct strioctl si;
487 char *name;
488 int in_and_out;
489#ifdef SI_GETUDATA
490 struct si_udata udata;
491#endif /* SI_GETUDATA */
492
493 if (!arg)
494 return 0;
495 if (umove(tcp, arg, &si) < 0) {
496 if (entering(tcp))
497 tprintf(", {...}");
498 return 1;
499 }
500 if (entering(tcp)) {
501 name = ioctl_lookup(si.ic_cmd);
502 if (name)
503 tprintf(", {ic_cmd=%s", name);
504 else
505 tprintf(", {ic_cmd=%#x", si.ic_cmd);
506 if (si.ic_timout == INFTIM)
507 tprintf(", ic_timout=INFTIM, ");
508 else
509 tprintf(" ic_timout=%d, ", si.ic_timout);
510 }
511 in_and_out = 1;
512 switch (si.ic_cmd) {
513#ifdef SI_GETUDATA
514 case SI_GETUDATA:
515 in_and_out = 0;
516 break;
517#endif /* SI_GETUDATA */
518 }
519 if (in_and_out) {
520 if (entering(tcp))
521 tprintf("/* in */ ");
522 else
523 tprintf(", /* out */ ");
524 }
525 if (in_and_out || entering(tcp))
526 tprintf("ic_len=%d, ic_dp=", si.ic_len);
527 switch (si.ic_cmd) {
528#ifdef TI_BIND
529 case TI_BIND:
530 /* in T_BIND_REQ, out T_BIND_ACK */
531 if (entering(tcp)) {
532 struct T_bind_req data;
533
534#if 0
535 tprintf("struct T_bind_req ");
536#endif
537 if (umove(tcp, (int) si.ic_dp, &data) < 0)
538 tprintf("{...}");
539 else {
540 tprintf("{PRIM_type=");
541 printxval(transport_user_options,
542 data.PRIM_type, "T_???");
543 tprintf(", ADDR_length=%ld, ADDR_offset=%ld",
544 data.ADDR_length, data.ADDR_offset);
545 tprintf(", CONIND_number=%ld}",
546 data.CONIND_number);
547 }
548 }
549 else {
550 struct T_bind_ack data;
551
552#if 0
553 tprintf("struct T_bind_ack ");
554#endif
555 if (umove(tcp, (int) si.ic_dp, &data) < 0)
556 tprintf("{...}");
557 else {
558 tprintf("[");
559 tprintf("{PRIM_type=");
560 printxval(transport_provider_options,
561 data.PRIM_type, "T_???");
562 tprintf(", ADDR_length=%ld, ADDR_offset=%ld",
563 data.ADDR_length, data.ADDR_offset);
564 tprintf(", CONIND_number=%ld}",
565 data.CONIND_number);
566 tprintf(", ");
567 printstr(tcp,
568 (int) si.ic_dp + data.ADDR_offset,
569 data.ADDR_length);
570 tprintf("]");
571 }
572 }
573 break;
574#endif /* TI_BIND */
575#if 0
576#ifdef TI_UNBIND
577 case TI_UNBIND:
578 /* in T_UNBIND_REQ, out T_OK_ACK */
579 break;
580#endif /* TI_UNBIND */
581#ifdef TI_GETINFO
582 case TI_GETINFO:
583 /* in T_INFO_REQ, out T_INFO_ACK */
584 break;
585#endif /* TI_GETINFO */
586#ifdef TI_OPTMGMT
587 case TI_OPTMGMT:
588 /* in T_OPTMGMT_REQ, out T_OPTMGMT_ACK */
589 break;
590#endif /* TI_OPTMGMT */
591#endif
592#ifdef SI_GETUDATA
593 case SI_GETUDATA:
594 if (entering(tcp))
595 break;
596#if 0
597 tprintf("struct si_udata ");
598#endif
599 if (umove(tcp, (int) si.ic_dp, &udata) < 0)
600 tprintf("{...}");
601 else {
602 tprintf("{tidusize=%d, addrsize=%d, ",
603 udata.tidusize, udata.addrsize);
604 tprintf("optsize=%d, etsdusize=%d, ",
605 udata.optsize, udata.etsdusize);
606 tprintf("servtype=%d, so_state=%d, ",
607 udata.servtype, udata.so_state);
608 tprintf("so_options=%d", udata.so_options);
609#if 0
610 tprintf(", tsdusize=%d", udata.tsdusize);
611#endif
612 tprintf("}");
613 }
614 break;
615#endif /* SI_GETUDATA */
616 default:
617 printstr(tcp, (int) si.ic_dp, si.ic_len);
618 break;
619 }
620 if (exiting(tcp))
621 tprintf("}");
622 return 1;
623}
624
625int
626stream_ioctl(tcp, code, arg)
627struct tcb *tcp;
628int code, arg;
629{
630#ifdef I_LIST
631 int i;
632#endif
633 int val;
634#ifdef I_FLUSHBAND
635 struct bandinfo bi;
636#endif
637 struct strpeek sp;
638 struct strfdinsert sfi;
639 struct strrecvfd srf;
640#ifdef I_LIST
641 struct str_list sl;
642#endif
643
644 /* I_STR is a special case because the data is read & written. */
645 if (code == I_STR)
646 return internal_stream_ioctl(tcp, arg);
647 if (entering(tcp))
648 return 0;
649
650 switch (code) {
651 case I_PUSH:
652 case I_LOOK:
653 case I_FIND:
654 /* arg is a string */
655 tprintf(", ");
656 printpath(tcp, arg);
657 return 1;
658 case I_POP:
659 /* doesn't take an argument */
660 return 1;
661 case I_FLUSH:
662 /* argument is an option */
663 tprintf(", ");
664 printxval(stream_flush_options, arg, "FLUSH???");
665 return 1;
666#ifdef I_FLUSHBAND
667 case I_FLUSHBAND:
668 /* argument is a pointer to a bandinfo struct */
669 if (umove(tcp, arg, &bi) < 0)
670 tprintf(", {...}");
671 else {
672 tprintf(", {bi_pri=%d, bi_flag=", bi.bi_pri);
673 if (!printflags(stream_flush_options, bi.bi_flag))
674 tprintf("0");
675 tprintf("}");
676 }
677 return 1;
678#endif /* I_FLUSHBAND */
679 case I_SETSIG:
680 /* argument is a set of flags */
681 tprintf(", ");
682 if (!printflags(stream_setsig_flags, arg))
683 tprintf("0");
684 return 1;
685 case I_GETSIG:
686 /* argument is a pointer to a set of flags */
687 if (syserror(tcp))
688 return 0;
689 tprintf(", [");
690 if (umove(tcp, arg, &val) < 0)
691 tprintf("?");
692 else if (!printflags(stream_setsig_flags, val))
693 tprintf("0");
694 tprintf("]");
695 return 1;
696 case I_PEEK:
697 /* argument is a pointer to a strpeek structure */
698 if (syserror(tcp) || !arg)
699 return 0;
700 if (umove(tcp, arg, &sp) < 0) {
701 tprintf(", {...}");
702 return 1;
703 }
704 tprintf(", {ctlbuf=");
705 printstrbuf(tcp, &sp.ctlbuf, 1);
706 tprintf(", databuf=");
707 printstrbuf(tcp, &sp.databuf, 1);
708 if (!printflags(msgflags, sp.flags))
709 tprintf("0");
710 return 1;
711 case I_SRDOPT:
712 /* argument is an option with flags */
713 tprintf(", ");
714 printxval(stream_read_options, arg & RMODEMASK, "R???");
715 addflags(stream_read_flags, arg & ~RMODEMASK);
716 return 1;
717 case I_GRDOPT:
718 /* argument is an pointer to an option with flags */
719 if (syserror(tcp))
720 return 0;
721 tprintf(", [");
722 if (umove(tcp, arg, &val) < 0)
723 tprintf("?");
724 else {
725 printxval(stream_read_options,
726 arg & RMODEMASK, "R???");
727 addflags(stream_read_flags, arg & ~RMODEMASK);
728 }
729 tprintf("]");
730 return 1;
731 case I_NREAD:
732#ifdef I_GETBAND
733 case I_GETBAND:
734#endif
735#ifdef I_SETCLTIME
736 case I_SETCLTIME:
737#endif
738#ifdef I_GETCLTIME
739 case I_GETCLTIME:
740#endif
741 /* argument is a pointer to a decimal integer */
742 if (syserror(tcp))
743 return 0;
744 tprintf(", ");
745 printnum(tcp, arg, "%d");
746 return 1;
747 case I_FDINSERT:
748 /* argument is a pointer to a strfdinsert structure */
749 if (syserror(tcp) || !arg)
750 return 0;
751 if (umove(tcp, arg, &sfi) < 0) {
752 tprintf(", {...}");
753 return 1;
754 }
755 tprintf(", {ctlbuf=");
756 printstrbuf(tcp, &sfi.ctlbuf, 1);
757 tprintf(", databuf=");
758 printstrbuf(tcp, &sfi.databuf, 1);
759 if (!printflags(msgflags, sfi.flags))
760 tprintf("0");
761 tprintf(", filedes=%d, offset=%d}", sfi.fildes, sfi.offset);
762 return 1;
763#ifdef I_SWROPT
764 case I_SWROPT:
765 /* argument is a set of flags */
766 tprintf(", ");
767 if (!printflags(stream_write_flags, arg))
768 tprintf("0");
769 return 1;
770#endif /* I_SWROPT */
771#ifdef I_GWROPT
772 case I_GWROPT:
773 /* argument is an pointer to an option with flags */
774 if (syserror(tcp))
775 return 0;
776 tprintf(", [");
777 if (umove(tcp, arg, &val) < 0)
778 tprintf("?");
779 else if (!printflags(stream_write_flags, arg))
780 tprintf("0");
781 tprintf("]");
782 return 1;
783#endif /* I_GWROPT */
784 case I_SENDFD:
785#ifdef I_CKBAND
786 case I_CKBAND:
787#endif
788#ifdef I_CANPUT
789 case I_CANPUT:
790#endif
791 case I_LINK:
792 case I_UNLINK:
793 case I_PLINK:
794 case I_PUNLINK:
795 /* argument is a decimal integer */
796 tprintf(", %d", arg);
797 return 1;
798 case I_RECVFD:
799 /* argument is a pointer to a strrecvfd structure */
800 if (syserror(tcp) || !arg)
801 return 0;
802 if (umove(tcp, arg, &srf) < 0) {
803 tprintf(", {...}");
804 return 1;
805 }
806 tprintf(", {fd=%d, uid=%lu, gid=%lu}", srf.fd,
807 (unsigned long) srf.uid, (unsigned long) srf.gid);
808 return 1;
809#ifdef I_LIST
810 case I_LIST:
811 if (syserror(tcp))
812 return 0;
813 if (arg == 0) {
814 tprintf(", NULL");
815 return 1;
816 }
817 if (umove(tcp, arg, &sl) < 0) {
818 tprintf(", {...}");
819 return 1;
820 }
821 tprintf(", {sl_nmods=%d, sl_modlist=[", sl.sl_nmods);
822 for (i = 0; i < tcp->u_rval; i++) {
823 if (i)
824 tprintf(", ");
825 printpath(tcp, (int) sl.sl_modlist[i].l_name);
826 }
827 tprintf("]}");
828 return 1;
829#endif /* I_LIST */
830#ifdef I_ATMARK
831 case I_ATMARK:
832 tprintf(", ");
833 printxval(stream_atmark_options, arg, "???MARK");
834 return 1;
835#endif /* I_ATMARK */
836 default:
837 return 0;
838 }
839}
840
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000841#endif /* !linux && !FREEBSD */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000842
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000843#endif /* HAVE_SYS_STREAM_H || linux || FREEBSD */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000844