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