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