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