blob: 998fd8ab4108c8ef5efae9b167ee15f99e8a0d52 [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"
Roland McGrath34e014a2002-12-16 20:40:59 +000032#include <sys/syscall.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000033
Wichert Akkerman42080d82001-04-10 10:32:26 +000034#ifdef HAVE_POLL_H
35#include <poll.h>
36#endif
Pavel Machek245a6ac2000-02-01 16:12:33 +000037#ifdef HAVE_SYS_POLL_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000038#include <sys/poll.h>
Pavel Machek245a6ac2000-02-01 16:12:33 +000039#endif
Wichert Akkerman42080d82001-04-10 10:32:26 +000040#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
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000052
Roland McGrath561c7992003-04-02 01:10:44 +000053#if defined(HAVE_SYS_STREAM_H) || defined(LINUX) || defined(FREEBSD)
Wichert Akkerman42080d82001-04-10 10:32:26 +000054
55#ifndef HAVE_STROPTS_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000056#define RS_HIPRI 1
57struct 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
Wichert Akkerman42080d82001-04-10 10:32:26 +000064#endif /* !HAVE_STROPTS_H */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000065
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
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +000072#ifndef FREEBSD
Roland McGrathd9f816f2004-09-04 03:39:20 +000073static const struct xlat msgflags[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000074 { RS_HIPRI, "RS_HIPRI" },
75 { 0, NULL },
76};
77
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000078
79static void
80printstrbuf(tcp, sbp, getting)
81struct tcb *tcp;
82struct strbuf *sbp;
83int 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);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +000092 printstr(tcp, (unsigned long) sbp->buf, sbp->len);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000093 tprintf("}");
94 }
95}
96
97static void
98printstrbufarg(tcp, arg, getting)
99struct tcb *tcp;
100int arg;
101int 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
114int
115sys_putmsg(tcp)
116struct 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 */
Roland McGrathb2dee132005-06-01 19:02:36 +0000127 printflags(msgflags, tcp->u_arg[3], "RS_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000128 }
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("[");
Roland McGrathb2dee132005-06-01 19:02:36 +0000157 printflags(msgflags, flags, "RS_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000158 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
Roland McGrath34e014a2002-12-16 20:40:59 +0000179#if defined SYS_putpmsg || defined SYS_getpmsg
Roland McGrathd9f816f2004-09-04 03:39:20 +0000180static const 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};
Roland McGrath34e014a2002-12-16 20:40:59 +0000192#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000193
Roland McGrath34e014a2002-12-16 20:40:59 +0000194#ifdef SYS_putpmsg
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000195int
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 */
Roland McGrathb2dee132005-06-01 19:02:36 +0000210 printflags(pmsgflags, tcp->u_arg[4], "MSG_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000211 }
212 return 0;
213}
Roland McGrath34e014a2002-12-16 20:40:59 +0000214#endif /* SYS_putpmsg */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000215
Roland McGrath34e014a2002-12-16 20:40:59 +0000216#ifdef SYS_getpmsg
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000217int
218sys_getpmsg(tcp)
219struct 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");
Wichert Akkerman906dade1999-11-26 09:18:37 +0000237 tprintf(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000238 /* 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("[");
Roland McGrathb2dee132005-06-01 19:02:36 +0000245 printflags(pmsgflags, flags, "MSG_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000246 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}
Roland McGrath34e014a2002-12-16 20:40:59 +0000266#endif /* SYS_getpmsg */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000267
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
Roland McGrathd9f816f2004-09-04 03:39:20 +0000273static const 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);
Roland McGrathb2dee132005-06-01 19:02:36 +0000333 printflags(pollflags, pollp[i].events,
334 "POLL???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000335 if (!syserror(tcp) && pollp[i].revents) {
336 tprintf(", revents=");
Roland McGrathb2dee132005-06-01 19:02:36 +0000337 printflags(pollflags, pollp[i].revents,
338 "POLL???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000339 }
340 tprintf("}");
341 }
342 tprintf("]");
343 }
344 tprintf(", %d, ", nfds);
345#ifdef INFTIM
346 if (tcp->u_arg[2] == INFTIM)
347 tprintf("INFTIM");
348 else
349#endif
350 tprintf("%ld", tcp->u_arg[2]);
351 free(pollp);
352 }
353 return 0;
354}
355
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000356#else /* !HAVE_SYS_POLL_H */
357int
358sys_poll(tcp)
359struct tcb *tcp;
360{
361 return 0;
362}
363#endif
364
Roland McGrath561c7992003-04-02 01:10:44 +0000365#if !defined(LINUX) && !defined(FREEBSD)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000366
Roland McGrathd9f816f2004-09-04 03:39:20 +0000367static const struct xlat stream_flush_options[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000368 { FLUSHR, "FLUSHR" },
369 { FLUSHW, "FLUSHW" },
370 { FLUSHRW, "FLUSHRW" },
371#ifdef FLUSHBAND
372 { FLUSHBAND, "FLUSHBAND" },
373#endif
374 { 0, NULL },
375};
376
Roland McGrathd9f816f2004-09-04 03:39:20 +0000377static const struct xlat stream_setsig_flags[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000378 { S_INPUT, "S_INPUT" },
379 { S_HIPRI, "S_HIPRI" },
380 { S_OUTPUT, "S_OUTPUT" },
381 { S_MSG, "S_MSG" },
382#ifdef S_ERROR
383 { S_ERROR, "S_ERROR" },
384#endif
385#ifdef S_HANGUP
386 { S_HANGUP, "S_HANGUP" },
387#endif
388#ifdef S_RDNORM
389 { S_RDNORM, "S_RDNORM" },
390#endif
391#ifdef S_WRNORM
392 { S_WRNORM, "S_WRNORM" },
393#endif
394#ifdef S_RDBAND
395 { S_RDBAND, "S_RDBAND" },
396#endif
397#ifdef S_WRBAND
398 { S_WRBAND, "S_WRBAND" },
399#endif
400#ifdef S_BANDURG
401 { S_BANDURG, "S_BANDURG" },
402#endif
403 { 0, NULL },
404};
405
Roland McGrathd9f816f2004-09-04 03:39:20 +0000406static const struct xlat stream_read_options[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000407 { RNORM, "RNORM" },
408 { RMSGD, "RMSGD" },
409 { RMSGN, "RMSGN" },
410 { 0, NULL },
411};
412
Roland McGrathd9f816f2004-09-04 03:39:20 +0000413static const struct xlat stream_read_flags[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000414#ifdef RPROTDAT
415 { RPROTDAT, "RPROTDAT" },
416#endif
417#ifdef RPROTDIS
418 { RPROTDIS, "RPROTDIS" },
419#endif
420#ifdef RPROTNORM
421 { RPROTNORM, "RPROTNORM" },
422#endif
423 { 0, NULL },
424};
425
426#ifndef RMODEMASK
427#define RMODEMASK (~0)
428#endif
429
430#ifdef I_SWROPT
Roland McGrathd9f816f2004-09-04 03:39:20 +0000431static const struct xlat stream_write_flags[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000432 { SNDZERO, "SNDZERO" },
433 { SNDPIPE, "SNDPIPE" },
434 { 0, NULL },
435};
436#endif /* I_SWROPT */
437
438#ifdef I_ATMARK
Roland McGrathd9f816f2004-09-04 03:39:20 +0000439static const struct xlat stream_atmark_options[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000440 { ANYMARK, "ANYMARK" },
441 { LASTMARK, "LASTMARK" },
442 { 0, NULL },
443};
444#endif /* I_ATMARK */
445
446#ifdef TI_BIND
Roland McGrathd9f816f2004-09-04 03:39:20 +0000447static const struct xlat transport_user_options[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000448 { T_CONN_REQ, "T_CONN_REQ" },
449 { T_CONN_RES, "T_CONN_RES" },
450 { T_DISCON_REQ, "T_DISCON_REQ" },
451 { T_DATA_REQ, "T_DATA_REQ" },
452 { T_EXDATA_REQ, "T_EXDATA_REQ" },
453 { T_INFO_REQ, "T_INFO_REQ" },
454 { T_BIND_REQ, "T_BIND_REQ" },
455 { T_UNBIND_REQ, "T_UNBIND_REQ" },
456 { T_UNITDATA_REQ,"T_UNITDATA_REQ"},
457 { T_OPTMGMT_REQ,"T_OPTMGMT_REQ" },
458 { T_ORDREL_REQ, "T_ORDREL_REQ" },
459 { 0, NULL },
460};
461
Roland McGrathd9f816f2004-09-04 03:39:20 +0000462static const struct xlat transport_user_flags [] = {
John Hughes38ae88d2002-05-23 11:48:58 +0000463 { 0, "0" },
464 { T_MORE, "T_MORE" },
465 { T_EXPEDITED, "T_EXPEDITED" },
466 { T_NEGOTIATE, "T_NEGOTIATE" },
467 { T_CHECK, "T_CHECK" },
468 { T_DEFAULT, "T_DEFAULT" },
469 { T_SUCCESS, "T_SUCCESS" },
470 { T_FAILURE, "T_FAILURE" },
471 { T_CURRENT, "T_CURRENT" },
472 { T_PARTSUCCESS,"T_PARTSUCCESS" },
473 { T_READONLY, "T_READONLY" },
474 { T_NOTSUPPORT, "T_NOTSUPPORT" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000475 { 0, NULL },
476};
John Hughes38ae88d2002-05-23 11:48:58 +0000477
478
Roland McGrath6d2b3492002-12-30 00:51:30 +0000479#ifdef HAVE_STRUCT_T_OPTHDR
John Hughes38ae88d2002-05-23 11:48:58 +0000480
Roland McGrathd9f816f2004-09-04 03:39:20 +0000481static const struct xlat xti_level [] = {
John Hughes38ae88d2002-05-23 11:48:58 +0000482 { XTI_GENERIC, "XTI_GENERIC" },
483 { 0, NULL },
484};
485
Roland McGrathd9f816f2004-09-04 03:39:20 +0000486static const struct xlat xti_generic [] = {
John Hughes38ae88d2002-05-23 11:48:58 +0000487 { XTI_DEBUG, "XTI_DEBUG" },
488 { XTI_LINGER, "XTI_LINGER" },
489 { XTI_RCVBUF, "XTI_RCVBUF" },
490 { XTI_RCVLOWAT, "XTI_RCVLOWAT" },
491 { XTI_SNDBUF, "XTI_SNDBUF" },
492 { XTI_SNDLOWAT, "XTI_SNDLOWAT" },
493 { 0, NULL },
494};
495
496
497
498void
499print_xti_optmgmt (tcp, addr, len)
500struct tcb *tcp;
501long addr;
502int len;
503{
504 int c = 0;
505 struct t_opthdr hdr;
506
John Hughes2c4e3a82002-05-24 10:19:44 +0000507 while (len >= (int) sizeof hdr) {
John Hughes38ae88d2002-05-23 11:48:58 +0000508 if (umove(tcp, addr, &hdr) < 0) break;
509 if (c++) {
510 tprintf (", ");
511 }
512 else if (len > hdr.len + sizeof hdr) {
513 tprintf ("[");
514 }
515 tprintf ("{level=");
516 printxval (xti_level, hdr.level, "???");
517 tprintf (", name=");
518 switch (hdr.level) {
519 case XTI_GENERIC:
520 printxval (xti_generic, hdr.name, "XTI_???");
521 break;
522 default:
523 tprintf ("%ld", hdr.name);
524 break;
525 }
526 tprintf (", status=");
527 printxval (transport_user_flags, hdr.status, "T_???");
528 addr += sizeof hdr;
529 len -= sizeof hdr;
530 if ((hdr.len -= sizeof hdr) > 0) {
531 if (hdr.len > len) break;
532 tprintf (", val=");
533 if (len == sizeof (int))
534 printnum (tcp, addr, "%d");
535 else
536 printstr (tcp, addr, hdr.len);
537 addr += hdr.len;
538 len -= hdr.len;
539 }
540 tprintf ("}");
541 }
542 if (len > 0) {
543 if (c++) tprintf (", ");
544 printstr (tcp, addr, len);
545 }
546 if (c > 1) tprintf ("]");
547}
548
549#endif
550
551
552static void
553print_optmgmt (tcp, addr, len)
554struct tcb *tcp;
555long addr;
556int len;
557{
Roland McGrath34e014a2002-12-16 20:40:59 +0000558 /* We don't know how to tell if TLI (socket) or XTI
John Hughes38ae88d2002-05-23 11:48:58 +0000559 optmgmt is being used yet, assume TLI. */
Roland McGrath6d2b3492002-12-30 00:51:30 +0000560#if defined (HAVE_STRUCT_OPTHDR)
John Hughes38ae88d2002-05-23 11:48:58 +0000561 print_sock_optmgmt (tcp, addr, len);
Roland McGrath6d2b3492002-12-30 00:51:30 +0000562#elif defined (HAVE_STRUCT_T_OPTHDR)
John Hughes38ae88d2002-05-23 11:48:58 +0000563 print_xti_optmgmt (tcp, addr, len);
564#else
565 printstr (tcp, addr, len);
566#endif
567}
568
569
570
571
Roland McGrathd9f816f2004-09-04 03:39:20 +0000572static const struct xlat service_type [] = {
John Hughes38ae88d2002-05-23 11:48:58 +0000573 { T_COTS, "T_COTS" },
574 { T_COTS_ORD, "T_COTS_ORD" },
575 { T_CLTS, "T_CLTS" },
576 { 0, NULL },
577};
578
Roland McGrathd9f816f2004-09-04 03:39:20 +0000579static const struct xlat ts_state [] = {
John Hughes38ae88d2002-05-23 11:48:58 +0000580 { TS_UNBND, "TS_UNBND" },
581 { TS_WACK_BREQ, "TS_WACK_BREQ" },
582 { TS_WACK_UREQ, "TS_WACK_UREQ" },
583 { TS_IDLE, "TS_IDLE" },
584 { TS_WACK_OPTREQ,"TS_WACK_OPTREQ"},
585 { TS_WACK_CREQ, "TS_WACK_CREQ" },
586 { TS_WCON_CREQ, "TS_WCON_CREQ" },
587 { TS_WRES_CIND, "TS_WRES_CIND" },
588 { TS_WACK_CRES, "TS_WACK_CRES" },
589 { TS_DATA_XFER, "TS_DATA_XFER" },
590 { TS_WIND_ORDREL,"TS_WIND_ORDREL"},
591 { TS_WREQ_ORDREL,"TS_WREQ_ORDREL"},
592 { TS_WACK_DREQ6,"TS_WACK_DREQ6" },
593 { TS_WACK_DREQ7,"TS_WACK_DREQ7" },
594 { TS_WACK_DREQ9,"TS_WACK_DREQ9" },
595 { TS_WACK_DREQ10,"TS_WACK_DREQ10"},
596 { TS_WACK_DREQ11,"TS_WACK_DREQ11"},
597 { 0, NULL },
598};
599
Roland McGrathd9f816f2004-09-04 03:39:20 +0000600static const struct xlat provider_flags [] = {
John Hughes38ae88d2002-05-23 11:48:58 +0000601 { 0, "0" },
602 { SENDZERO, "SENDZERO" },
603 { EXPINLINE, "EXPINLINE" },
604 { XPG4_1, "XPG4_1" },
605 { 0, NULL },
606};
607
608
Roland McGrathd9f816f2004-09-04 03:39:20 +0000609static const struct xlat tli_errors [] = {
John Hughes38ae88d2002-05-23 11:48:58 +0000610 { TBADADDR, "TBADADDR" },
611 { TBADOPT, "TBADOPT" },
612 { TACCES, "TACCES" },
613 { TBADF, "TBADF" },
614 { TNOADDR, "TNOADDR" },
615 { TOUTSTATE, "TOUTSTATE" },
616 { TBADSEQ, "TBADSEQ" },
617 { TSYSERR, "TSYSERR" },
618 { TLOOK, "TLOOK" },
619 { TBADDATA, "TBADDATA" },
620 { TBUFOVFLW, "TBUFOVFLW" },
621 { TFLOW, "TFLOW" },
622 { TNODATA, "TNODATA" },
623 { TNODIS, "TNODIS" },
624 { TNOUDERR, "TNOUDERR" },
625 { TBADFLAG, "TBADFLAG" },
626 { TNOREL, "TNOREL" },
627 { TNOTSUPPORT, "TNOTSUPPORT" },
628 { TSTATECHNG, "TSTATECHNG" },
629 { TNOSTRUCTYPE, "TNOSTRUCTYPE" },
630 { TBADNAME, "TBADNAME" },
631 { TBADQLEN, "TBADQLEN" },
632 { TADDRBUSY, "TADDRBUSY" },
633 { TINDOUT, "TINDOUT" },
634 { TPROVMISMATCH,"TPROVMISMATCH" },
635 { TRESQLEN, "TRESQLEN" },
636 { TRESADDR, "TRESADDR" },
637 { TQFULL, "TQFULL" },
638 { TPROTO, "TPROTO" },
639 { 0, NULL },
640};
641
642
643static int
644print_transport_message (tcp, expect, addr, len)
645struct tcb *tcp;
646int expect;
647long addr;
648int len;
649{
650 union T_primitives m;
651 int c = 0;
652
653 if (len < sizeof m.type) goto dump;
654
655 if (umove (tcp, addr, &m.type) < 0) goto dump;
656
657#define GET(type, struct) \
658 do { \
659 if (len < sizeof m.struct) goto dump; \
660 if (umove (tcp, addr, &m.struct) < 0) goto dump;\
661 tprintf ("{"); \
662 if (expect != type) { \
663 ++c; \
664 tprintf (#type); \
665 } \
666 } \
667 while (0)
668
669#define COMMA() \
Roland McGrath34e014a2002-12-16 20:40:59 +0000670 do { if (c++) tprintf (", "); } while (0)
671
John Hughes38ae88d2002-05-23 11:48:58 +0000672
673#define STRUCT(struct, elem, print) \
674 do { \
675 COMMA (); \
676 if (m.struct.elem##_length < 0 || \
677 m.struct.elem##_offset < sizeof m.struct || \
678 m.struct.elem##_offset + m.struct.elem##_length > len) \
679 { \
680 tprintf (#elem "_length=%ld, " #elem "_offset=%ld",\
681 m.struct.elem##_length, \
682 m.struct.elem##_offset); \
683 } \
684 else { \
685 tprintf (#elem "="); \
686 print (tcp, \
687 addr + m.struct.elem##_offset, \
688 m.struct.elem##_length); \
689 } \
690 } \
691 while (0)
692
693#define ADDR(struct, elem) STRUCT (struct, elem, printstr)
Roland McGrath34e014a2002-12-16 20:40:59 +0000694
John Hughes38ae88d2002-05-23 11:48:58 +0000695 switch (m.type) {
696#ifdef T_CONN_REQ
697 case T_CONN_REQ: /* connect request */
698 GET (T_CONN_REQ, conn_req);
699 ADDR (conn_req, DEST);
700 ADDR (conn_req, OPT);
701 break;
702#endif
703#ifdef T_CONN_RES
704 case T_CONN_RES: /* connect response */
705 GET (T_CONN_RES, conn_res);
Roland McGrath38dc6bb2003-01-10 20:05:54 +0000706#ifdef HAVE_STRUCT_T_CONN_RES_QUEUE_PTR
John Hughes38ae88d2002-05-23 11:48:58 +0000707 COMMA ();
708 tprintf ("QUEUE=%p", m.conn_res.QUEUE_ptr);
Roland McGrath38dc6bb2003-01-10 20:05:54 +0000709#elif defined HAVE_STRUCT_T_CONN_RES_ACCEPTOR_ID
710 COMMA ();
Roland McGrath7686eee2003-01-10 20:09:43 +0000711 tprintf ("ACCEPTOR=%#lx", m.conn_res.ACCEPTOR_id);
Roland McGrath38dc6bb2003-01-10 20:05:54 +0000712#endif
John Hughes38ae88d2002-05-23 11:48:58 +0000713 ADDR (conn_res, OPT);
714 COMMA ();
715 tprintf ("SEQ=%ld", m.conn_res.SEQ_number);
716 break;
717#endif
718#ifdef T_DISCON_REQ
719 case T_DISCON_REQ: /* disconnect request */
720 GET (T_DISCON_REQ, discon_req);
721 COMMA ();
722 tprintf ("SEQ=%ld", m.discon_req.SEQ_number);
723 break;
724#endif
725#ifdef T_DATA_REQ
726 case T_DATA_REQ: /* data request */
727 GET (T_DATA_REQ, data_req);
728 COMMA ();
729 tprintf ("MORE=%ld", m.data_req.MORE_flag);
730 break;
731#endif
732#ifdef T_EXDATA_REQ
733 case T_EXDATA_REQ: /* expedited data req */
734 GET (T_EXDATA_REQ, exdata_req);
735 COMMA ();
736 tprintf ("MORE=%ld", m.exdata_req.MORE_flag);
737 break;
738#endif
739#ifdef T_INFO_REQ
740 case T_INFO_REQ: /* information req */
741 GET (T_INFO_REQ, info_req);
742 break;
743#endif
744#ifdef T_BIND_REQ
745 case T_BIND_REQ: /* bind request */
746#ifdef O_T_BIND_REQ
747 case O_T_BIND_REQ: /* Ugly xti/tli hack */
748#endif
749 GET (T_BIND_REQ, bind_req);
750 ADDR (bind_req, ADDR);
751 COMMA ();
752 tprintf ("CONIND=%ld", m.bind_req.CONIND_number);
753 break;
754#endif
755#ifdef T_UNBIND_REQ
756 case T_UNBIND_REQ: /* unbind request */
757 GET (T_UNBIND_REQ, unbind_req);
758 break;
759#endif
760#ifdef T_UNITDATA_REQ
761 case T_UNITDATA_REQ: /* unitdata requset */
762 GET (T_UNITDATA_REQ, unitdata_req);
763 ADDR (unitdata_req, DEST);
764 ADDR (unitdata_req, OPT);
765 break;
766#endif
767#ifdef T_OPTMGMT_REQ
768 case T_OPTMGMT_REQ: /* manage opt req */
769 GET (T_OPTMGMT_REQ, optmgmt_req);
770 COMMA ();
771 tprintf ("MGMT=");
Roland McGrathb2dee132005-06-01 19:02:36 +0000772 printflags (transport_user_flags, m.optmgmt_req.MGMT_flags,
773 "T_???");
John Hughes38ae88d2002-05-23 11:48:58 +0000774 STRUCT (optmgmt_req, OPT, print_optmgmt);
775 break;
776#endif
777#ifdef T_ORDREL_REQ
778 case T_ORDREL_REQ: /* orderly rel req */
779 GET (T_ORDREL_REQ, ordrel_req);
780 break;
781#endif
782#ifdef T_CONN_IND
783 case T_CONN_IND: /* connect indication */
784 GET (T_CONN_IND, conn_ind);
785 ADDR (conn_ind, SRC);
786 ADDR (conn_ind, OPT);
787 tprintf (", SEQ=%ld", m.conn_ind.SEQ_number);
788 break;
789#endif
790#ifdef T_CONN_CON
791 case T_CONN_CON: /* connect corfirm */
792 GET (T_CONN_CON, conn_con);
793 ADDR (conn_con, RES);
794 ADDR (conn_con, OPT);
795 break;
796#endif
797#ifdef T_DISCON_IND
798 case T_DISCON_IND: /* discon indication */
799 GET (T_DISCON_IND, discon_ind);
800 COMMA ();
801 tprintf ("DISCON=%ld, SEQ=%ld",
802 m.discon_ind.DISCON_reason, m.discon_ind.SEQ_number);
803 break;
804#endif
805#ifdef T_DATA_IND
806 case T_DATA_IND: /* data indication */
807 GET (T_DATA_IND, data_ind);
808 COMMA ();
809 tprintf ("MORE=%ld", m.data_ind.MORE_flag);
810 break;
811#endif
812#ifdef T_EXDATA_IND
813 case T_EXDATA_IND: /* expedited data ind */
814 GET (T_EXDATA_IND, exdata_ind);
815 COMMA ();
816 tprintf ("MORE=%ld", m.exdata_ind.MORE_flag);
817 break;
818#endif
819#ifdef T_INFO_ACK
820 case T_INFO_ACK: /* info ack */
821 GET (T_INFO_ACK, info_ack);
822 COMMA ();
823 tprintf ("TSDU=%ld, ETSDU=%ld, CDATA=%ld, DDATA=%ld, "
824 "ADDR=%ld, OPT=%ld, TIDU=%ld, SERV=",
825 m.info_ack.TSDU_size, m.info_ack.ETSDU_size,
826 m.info_ack.CDATA_size, m.info_ack.DDATA_size,
827 m.info_ack.ADDR_size, m.info_ack.OPT_size,
828 m.info_ack.TIDU_size);
829 printxval (service_type, m.info_ack.SERV_type, "T_???");
830 tprintf (", CURRENT=");
831 printxval (ts_state, m.info_ack.CURRENT_state, "TS_???");
832 tprintf (", PROVIDER=");
Roland McGrathb2dee132005-06-01 19:02:36 +0000833 printflags (provider_flags, m.info_ack.PROVIDER_flag, "???");
John Hughes38ae88d2002-05-23 11:48:58 +0000834 break;
835#endif
836#ifdef T_BIND_ACK
837 case T_BIND_ACK: /* bind ack */
838 GET (T_BIND_ACK, bind_ack);
839 ADDR (bind_ack, ADDR);
840 tprintf (", CONIND=%ld", m.bind_ack.CONIND_number);
841 break;
842#endif
843#ifdef T_ERROR_ACK
844 case T_ERROR_ACK: /* error ack */
845 GET (T_ERROR_ACK, error_ack);
846 COMMA ();
847 tprintf ("ERROR=");
848 printxval (transport_user_options,
849 m.error_ack.ERROR_prim, "TI_???");
850 tprintf (", TLI=");
851 printxval (tli_errors, m.error_ack.TLI_error, "T???");
852 tprintf ("UNIX=%s", strerror (m.error_ack.UNIX_error));
853 break;
854#endif
855#ifdef T_OK_ACK
856 case T_OK_ACK: /* ok ack */
857 GET (T_OK_ACK, ok_ack);
858 COMMA ();
859 tprintf ("CORRECT=");
860 printxval (transport_user_options,
861 m.ok_ack.CORRECT_prim, "TI_???");
862 break;
863#endif
864#ifdef T_UNITDATA_IND
865 case T_UNITDATA_IND: /* unitdata ind */
866 GET (T_UNITDATA_IND, unitdata_ind);
867 ADDR (unitdata_ind, SRC);
868 ADDR (unitdata_ind, OPT);
869 break;
870#endif
871#ifdef T_UDERROR_IND
872 case T_UDERROR_IND: /* unitdata error ind */
873 GET (T_UDERROR_IND, uderror_ind);
874 ADDR (uderror_ind, DEST);
875 ADDR (uderror_ind, OPT);
876 tprintf (", ERROR=%ld", m.uderror_ind.ERROR_type);
877 break;
878#endif
879#ifdef T_OPTMGMT_ACK
880 case T_OPTMGMT_ACK: /* manage opt ack */
881 GET (T_OPTMGMT_ACK, optmgmt_ack);
882 COMMA ();
883 tprintf ("MGMT=");
Roland McGrathb2dee132005-06-01 19:02:36 +0000884 printflags (transport_user_flags, m.optmgmt_ack.MGMT_flags,
885 "T_???");
John Hughes38ae88d2002-05-23 11:48:58 +0000886 STRUCT (optmgmt_ack, OPT, print_optmgmt);
887 break;
888#endif
889#ifdef T_ORDREL_IND
890 case T_ORDREL_IND: /* orderly rel ind */
891 GET (T_ORDREL_IND, ordrel_ind);
892 break;
893#endif
894#ifdef T_ADDR_REQ
895 case T_ADDR_REQ: /* address req */
896 GET (T_ADDR_REQ, addr_req);
897 break;
898#endif
899#ifdef T_ADDR_ACK
900 case T_ADDR_ACK: /* address response */
901 GET (T_ADDR_ACK, addr_ack);
902 ADDR (addr_ack, LOCADDR);
903 ADDR (addr_ack, REMADDR);
904 break;
905#endif
906 default:
907 dump:
908 c = -1;
909 printstr(tcp, addr, len);
910 break;
911 }
912
913 if (c >= 0) tprintf ("}");
914
915#undef ADDR
916#undef COMMA
917#undef STRUCT
Roland McGrath34e014a2002-12-16 20:40:59 +0000918
John Hughes38ae88d2002-05-23 11:48:58 +0000919 return 0;
920}
921
922
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000923#endif /* TI_BIND */
924
John Hughes38ae88d2002-05-23 11:48:58 +0000925
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000926static int
927internal_stream_ioctl(tcp, arg)
928struct tcb *tcp;
929int arg;
930{
931 struct strioctl si;
Roland McGrath1c04b0b2004-01-13 10:18:46 +0000932 struct ioctlent *iop;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000933 int in_and_out;
John Hughes38ae88d2002-05-23 11:48:58 +0000934 int timod = 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000935#ifdef SI_GETUDATA
936 struct si_udata udata;
937#endif /* SI_GETUDATA */
938
939 if (!arg)
940 return 0;
941 if (umove(tcp, arg, &si) < 0) {
942 if (entering(tcp))
943 tprintf(", {...}");
944 return 1;
945 }
946 if (entering(tcp)) {
Roland McGrath2843a4e2003-11-14 02:54:03 +0000947 iop = ioctl_lookup(si.ic_cmd);
948 if (iop) {
949 tprintf(", {ic_cmd=%s", iop->symbol);
950 while ((iop = ioctl_next_match(iop)))
951 tprintf(" or %s", iop->symbol);
952 } else
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000953 tprintf(", {ic_cmd=%#x", si.ic_cmd);
954 if (si.ic_timout == INFTIM)
955 tprintf(", ic_timout=INFTIM, ");
956 else
957 tprintf(" ic_timout=%d, ", si.ic_timout);
958 }
959 in_and_out = 1;
960 switch (si.ic_cmd) {
961#ifdef SI_GETUDATA
962 case SI_GETUDATA:
963 in_and_out = 0;
964 break;
965#endif /* SI_GETUDATA */
966 }
967 if (in_and_out) {
968 if (entering(tcp))
969 tprintf("/* in */ ");
970 else
971 tprintf(", /* out */ ");
972 }
973 if (in_and_out || entering(tcp))
974 tprintf("ic_len=%d, ic_dp=", si.ic_len);
975 switch (si.ic_cmd) {
976#ifdef TI_BIND
977 case TI_BIND:
978 /* in T_BIND_REQ, out T_BIND_ACK */
John Hughes38ae88d2002-05-23 11:48:58 +0000979 ++timod;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000980 if (entering(tcp)) {
John Hughes38ae88d2002-05-23 11:48:58 +0000981 print_transport_message (tcp,
982 T_BIND_REQ,
983 si.ic_dp, si.ic_len);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000984 }
985 else {
John Hughes38ae88d2002-05-23 11:48:58 +0000986 print_transport_message (tcp,
987 T_BIND_ACK,
988 si.ic_dp, si.ic_len);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000989 }
990 break;
991#endif /* TI_BIND */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000992#ifdef TI_UNBIND
993 case TI_UNBIND:
994 /* in T_UNBIND_REQ, out T_OK_ACK */
John Hughes38ae88d2002-05-23 11:48:58 +0000995 ++timod;
996 if (entering(tcp)) {
997 print_transport_message (tcp,
998 T_UNBIND_REQ,
999 si.ic_dp, si.ic_len);
1000 }
1001 else {
1002 print_transport_message (tcp,
1003 T_OK_ACK,
1004 si.ic_dp, si.ic_len);
1005 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001006 break;
1007#endif /* TI_UNBIND */
1008#ifdef TI_GETINFO
1009 case TI_GETINFO:
1010 /* in T_INFO_REQ, out T_INFO_ACK */
John Hughes38ae88d2002-05-23 11:48:58 +00001011 ++timod;
1012 if (entering(tcp)) {
1013 print_transport_message (tcp,
1014 T_INFO_REQ,
1015 si.ic_dp, si.ic_len);
1016 }
1017 else {
1018 print_transport_message (tcp,
1019 T_INFO_ACK,
1020 si.ic_dp, si.ic_len);
1021 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001022 break;
1023#endif /* TI_GETINFO */
1024#ifdef TI_OPTMGMT
1025 case TI_OPTMGMT:
1026 /* in T_OPTMGMT_REQ, out T_OPTMGMT_ACK */
John Hughes38ae88d2002-05-23 11:48:58 +00001027 ++timod;
1028 if (entering(tcp)) {
1029 print_transport_message (tcp,
1030 T_OPTMGMT_REQ,
1031 si.ic_dp, si.ic_len);
1032 }
1033 else {
1034 print_transport_message (tcp,
1035 T_OPTMGMT_ACK,
1036 si.ic_dp, si.ic_len);
1037 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001038 break;
1039#endif /* TI_OPTMGMT */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001040#ifdef SI_GETUDATA
1041 case SI_GETUDATA:
1042 if (entering(tcp))
1043 break;
1044#if 0
1045 tprintf("struct si_udata ");
1046#endif
1047 if (umove(tcp, (int) si.ic_dp, &udata) < 0)
1048 tprintf("{...}");
1049 else {
1050 tprintf("{tidusize=%d, addrsize=%d, ",
1051 udata.tidusize, udata.addrsize);
1052 tprintf("optsize=%d, etsdusize=%d, ",
1053 udata.optsize, udata.etsdusize);
1054 tprintf("servtype=%d, so_state=%d, ",
1055 udata.servtype, udata.so_state);
1056 tprintf("so_options=%d", udata.so_options);
1057#if 0
1058 tprintf(", tsdusize=%d", udata.tsdusize);
1059#endif
1060 tprintf("}");
1061 }
1062 break;
1063#endif /* SI_GETUDATA */
1064 default:
Michal Ludvig10a88d02002-10-07 14:31:00 +00001065 printstr(tcp, (long) si.ic_dp, si.ic_len);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001066 break;
1067 }
John Hughes38ae88d2002-05-23 11:48:58 +00001068 if (exiting(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001069 tprintf("}");
John Hughes38ae88d2002-05-23 11:48:58 +00001070 if (timod && tcp->u_rval) {
1071 tcp->auxstr = xlookup (tli_errors, tcp->u_rval);
1072 return RVAL_STR + 1;
1073 }
1074 }
Roland McGrath34e014a2002-12-16 20:40:59 +00001075
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001076 return 1;
1077}
1078
1079int
1080stream_ioctl(tcp, code, arg)
1081struct tcb *tcp;
1082int code, arg;
1083{
1084#ifdef I_LIST
1085 int i;
1086#endif
1087 int val;
1088#ifdef I_FLUSHBAND
1089 struct bandinfo bi;
1090#endif
1091 struct strpeek sp;
1092 struct strfdinsert sfi;
1093 struct strrecvfd srf;
1094#ifdef I_LIST
1095 struct str_list sl;
1096#endif
1097
1098 /* I_STR is a special case because the data is read & written. */
1099 if (code == I_STR)
1100 return internal_stream_ioctl(tcp, arg);
1101 if (entering(tcp))
1102 return 0;
1103
1104 switch (code) {
1105 case I_PUSH:
1106 case I_LOOK:
1107 case I_FIND:
1108 /* arg is a string */
1109 tprintf(", ");
1110 printpath(tcp, arg);
1111 return 1;
1112 case I_POP:
1113 /* doesn't take an argument */
1114 return 1;
1115 case I_FLUSH:
1116 /* argument is an option */
1117 tprintf(", ");
1118 printxval(stream_flush_options, arg, "FLUSH???");
1119 return 1;
1120#ifdef I_FLUSHBAND
1121 case I_FLUSHBAND:
1122 /* argument is a pointer to a bandinfo struct */
1123 if (umove(tcp, arg, &bi) < 0)
1124 tprintf(", {...}");
1125 else {
1126 tprintf(", {bi_pri=%d, bi_flag=", bi.bi_pri);
Roland McGrathb2dee132005-06-01 19:02:36 +00001127 printflags(stream_flush_options, bi.bi_flag, "FLUSH???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001128 tprintf("}");
1129 }
1130 return 1;
1131#endif /* I_FLUSHBAND */
1132 case I_SETSIG:
1133 /* argument is a set of flags */
1134 tprintf(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00001135 printflags(stream_setsig_flags, arg, "S_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001136 return 1;
1137 case I_GETSIG:
1138 /* argument is a pointer to a set of flags */
1139 if (syserror(tcp))
1140 return 0;
1141 tprintf(", [");
1142 if (umove(tcp, arg, &val) < 0)
1143 tprintf("?");
Roland McGrathb2dee132005-06-01 19:02:36 +00001144 else
1145 printflags(stream_setsig_flags, val, "S_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001146 tprintf("]");
1147 return 1;
1148 case I_PEEK:
1149 /* argument is a pointer to a strpeek structure */
1150 if (syserror(tcp) || !arg)
1151 return 0;
1152 if (umove(tcp, arg, &sp) < 0) {
1153 tprintf(", {...}");
1154 return 1;
1155 }
1156 tprintf(", {ctlbuf=");
1157 printstrbuf(tcp, &sp.ctlbuf, 1);
1158 tprintf(", databuf=");
1159 printstrbuf(tcp, &sp.databuf, 1);
John Hughesfd15cb32002-05-17 11:41:35 +00001160 tprintf(", flags=");
Roland McGrathb2dee132005-06-01 19:02:36 +00001161 printflags(msgflags, sp.flags, "RS_???");
John Hughesfd15cb32002-05-17 11:41:35 +00001162 tprintf("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001163 return 1;
1164 case I_SRDOPT:
1165 /* argument is an option with flags */
1166 tprintf(", ");
1167 printxval(stream_read_options, arg & RMODEMASK, "R???");
1168 addflags(stream_read_flags, arg & ~RMODEMASK);
1169 return 1;
1170 case I_GRDOPT:
1171 /* argument is an pointer to an option with flags */
1172 if (syserror(tcp))
1173 return 0;
1174 tprintf(", [");
1175 if (umove(tcp, arg, &val) < 0)
1176 tprintf("?");
1177 else {
1178 printxval(stream_read_options,
1179 arg & RMODEMASK, "R???");
1180 addflags(stream_read_flags, arg & ~RMODEMASK);
1181 }
1182 tprintf("]");
1183 return 1;
1184 case I_NREAD:
1185#ifdef I_GETBAND
1186 case I_GETBAND:
1187#endif
1188#ifdef I_SETCLTIME
1189 case I_SETCLTIME:
1190#endif
1191#ifdef I_GETCLTIME
1192 case I_GETCLTIME:
1193#endif
1194 /* argument is a pointer to a decimal integer */
1195 if (syserror(tcp))
1196 return 0;
1197 tprintf(", ");
1198 printnum(tcp, arg, "%d");
1199 return 1;
1200 case I_FDINSERT:
1201 /* argument is a pointer to a strfdinsert structure */
1202 if (syserror(tcp) || !arg)
1203 return 0;
1204 if (umove(tcp, arg, &sfi) < 0) {
1205 tprintf(", {...}");
1206 return 1;
1207 }
1208 tprintf(", {ctlbuf=");
1209 printstrbuf(tcp, &sfi.ctlbuf, 1);
1210 tprintf(", databuf=");
1211 printstrbuf(tcp, &sfi.databuf, 1);
John Hughesfd15cb32002-05-17 11:41:35 +00001212 tprintf(", flags=");
Roland McGrathb2dee132005-06-01 19:02:36 +00001213 printflags(msgflags, sfi.flags, "RS_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001214 tprintf(", filedes=%d, offset=%d}", sfi.fildes, sfi.offset);
1215 return 1;
1216#ifdef I_SWROPT
1217 case I_SWROPT:
1218 /* argument is a set of flags */
1219 tprintf(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00001220 printflags(stream_write_flags, arg, "SND???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001221 return 1;
1222#endif /* I_SWROPT */
1223#ifdef I_GWROPT
1224 case I_GWROPT:
1225 /* argument is an pointer to an option with flags */
1226 if (syserror(tcp))
1227 return 0;
1228 tprintf(", [");
1229 if (umove(tcp, arg, &val) < 0)
1230 tprintf("?");
Roland McGrathb2dee132005-06-01 19:02:36 +00001231 else
1232 printflags(stream_write_flags, arg, "SND???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001233 tprintf("]");
1234 return 1;
1235#endif /* I_GWROPT */
1236 case I_SENDFD:
1237#ifdef I_CKBAND
1238 case I_CKBAND:
1239#endif
1240#ifdef I_CANPUT
1241 case I_CANPUT:
1242#endif
1243 case I_LINK:
1244 case I_UNLINK:
1245 case I_PLINK:
1246 case I_PUNLINK:
1247 /* argument is a decimal integer */
1248 tprintf(", %d", arg);
1249 return 1;
1250 case I_RECVFD:
1251 /* argument is a pointer to a strrecvfd structure */
1252 if (syserror(tcp) || !arg)
1253 return 0;
1254 if (umove(tcp, arg, &srf) < 0) {
1255 tprintf(", {...}");
1256 return 1;
1257 }
1258 tprintf(", {fd=%d, uid=%lu, gid=%lu}", srf.fd,
1259 (unsigned long) srf.uid, (unsigned long) srf.gid);
1260 return 1;
1261#ifdef I_LIST
1262 case I_LIST:
1263 if (syserror(tcp))
1264 return 0;
1265 if (arg == 0) {
1266 tprintf(", NULL");
1267 return 1;
1268 }
1269 if (umove(tcp, arg, &sl) < 0) {
1270 tprintf(", {...}");
1271 return 1;
1272 }
1273 tprintf(", {sl_nmods=%d, sl_modlist=[", sl.sl_nmods);
1274 for (i = 0; i < tcp->u_rval; i++) {
1275 if (i)
1276 tprintf(", ");
1277 printpath(tcp, (int) sl.sl_modlist[i].l_name);
1278 }
1279 tprintf("]}");
1280 return 1;
1281#endif /* I_LIST */
1282#ifdef I_ATMARK
1283 case I_ATMARK:
1284 tprintf(", ");
1285 printxval(stream_atmark_options, arg, "???MARK");
1286 return 1;
1287#endif /* I_ATMARK */
1288 default:
1289 return 0;
1290 }
1291}
1292
Roland McGrath561c7992003-04-02 01:10:44 +00001293#endif /* !LINUX && !FREEBSD */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001294
Roland McGrath561c7992003-04-02 01:10:44 +00001295#endif /* HAVE_SYS_STREAM_H || LINUX || FREEBSD */