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