Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | |
Willy Tarreau | f1d32c4 | 2020-06-04 21:07:02 +0200 | [diff] [blame] | 4 | #include <haproxy/channel-t.h> |
Willy Tarreau | 7ea393d | 2020-06-04 18:02:10 +0200 | [diff] [blame] | 5 | #include <haproxy/connection-t.h> |
Willy Tarreau | c2b1ff0 | 2020-06-04 21:21:03 +0200 | [diff] [blame] | 6 | #include <haproxy/http_ana-t.h> |
Willy Tarreau | dfd3de8 | 2020-06-04 23:46:14 +0200 | [diff] [blame] | 7 | #include <haproxy/stream-t.h> |
Willy Tarreau | 5e539c9 | 2020-06-04 20:45:39 +0200 | [diff] [blame] | 8 | #include <haproxy/stream_interface-t.h> |
Willy Tarreau | cea0e1b | 2020-06-04 17:25:40 +0200 | [diff] [blame] | 9 | #include <haproxy/task-t.h> |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 10 | |
Willy Tarreau | 354b6f5 | 2020-02-06 08:33:08 +0100 | [diff] [blame] | 11 | // 1 bit per flag, no hole permitted here |
| 12 | #define SHOW_AS_ANA 0x00000001 |
| 13 | #define SHOW_AS_CHN 0x00000002 |
| 14 | #define SHOW_AS_CONN 0x00000004 |
| 15 | #define SHOW_AS_CS 0x00000008 |
| 16 | #define SHOW_AS_SI 0x00000010 |
| 17 | #define SHOW_AS_SIET 0x00000020 |
| 18 | #define SHOW_AS_STRM 0x00000040 |
| 19 | #define SHOW_AS_TASK 0x00000080 |
| 20 | #define SHOW_AS_TXN 0x00000100 |
| 21 | |
| 22 | // command line names, must be in exact same order as the SHOW_AS_* flags above |
| 23 | // so that show_as_words[i] matches flag 1U<<i. |
| 24 | const char *show_as_words[] = { "ana", "chn", "conn", "cs", "si", "siet", "strm", "task", "txn", }; |
| 25 | |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 26 | #define SHOW_FLAG(f,n) \ |
| 27 | do { \ |
| 28 | if (!((f) & (n))) break; \ |
| 29 | (f) &= ~(n); \ |
| 30 | printf(#n"%s", (f) ? " | " : ""); \ |
| 31 | } while (0) |
| 32 | |
Willy Tarreau | 354b6f5 | 2020-02-06 08:33:08 +0100 | [diff] [blame] | 33 | unsigned int get_show_as(const char *word) |
| 34 | { |
| 35 | int w = 0; |
| 36 | |
| 37 | while (1) { |
| 38 | if (w == sizeof(show_as_words) / sizeof(*show_as_words)) |
| 39 | return 0; |
| 40 | if (strcmp(word, show_as_words[w]) == 0) |
| 41 | return 1U << w; |
| 42 | w++; |
| 43 | } |
| 44 | } |
| 45 | |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 46 | void show_chn_ana(unsigned int f) |
| 47 | { |
| 48 | printf("chn->ana = "); |
| 49 | |
| 50 | if (!f) { |
| 51 | printf("0\n"); |
| 52 | return; |
| 53 | } |
| 54 | |
Christopher Faulet | f4cfcf9 | 2017-11-10 14:10:35 +0100 | [diff] [blame] | 55 | SHOW_FLAG(f, AN_REQ_FLT_START_FE); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 56 | SHOW_FLAG(f, AN_REQ_INSPECT_FE); |
| 57 | SHOW_FLAG(f, AN_REQ_WAIT_HTTP); |
| 58 | SHOW_FLAG(f, AN_REQ_HTTP_BODY); |
| 59 | SHOW_FLAG(f, AN_REQ_HTTP_PROCESS_FE); |
| 60 | SHOW_FLAG(f, AN_REQ_SWITCHING_RULES); |
Christopher Faulet | f4cfcf9 | 2017-11-10 14:10:35 +0100 | [diff] [blame] | 61 | SHOW_FLAG(f, AN_REQ_FLT_START_BE); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 62 | SHOW_FLAG(f, AN_REQ_INSPECT_BE); |
| 63 | SHOW_FLAG(f, AN_REQ_HTTP_PROCESS_BE); |
Christopher Faulet | f4cfcf9 | 2017-11-10 14:10:35 +0100 | [diff] [blame] | 64 | SHOW_FLAG(f, AN_REQ_HTTP_TARPIT); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 65 | SHOW_FLAG(f, AN_REQ_SRV_RULES); |
| 66 | SHOW_FLAG(f, AN_REQ_HTTP_INNER); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 67 | SHOW_FLAG(f, AN_REQ_PRST_RDP_COOKIE); |
Christopher Faulet | f4cfcf9 | 2017-11-10 14:10:35 +0100 | [diff] [blame] | 68 | SHOW_FLAG(f, AN_REQ_STICKING_RULES); |
| 69 | SHOW_FLAG(f, AN_REQ_FLT_HTTP_HDRS); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 70 | SHOW_FLAG(f, AN_REQ_HTTP_XFER_BODY); |
Christopher Faulet | f4cfcf9 | 2017-11-10 14:10:35 +0100 | [diff] [blame] | 71 | SHOW_FLAG(f, AN_REQ_FLT_XFER_DATA); |
| 72 | SHOW_FLAG(f, AN_REQ_FLT_END); |
| 73 | |
Willy Tarreau | 260bf5c | 2018-01-15 18:59:16 +0100 | [diff] [blame] | 74 | SHOW_FLAG(f, AN_RES_FLT_START_FE); |
| 75 | SHOW_FLAG(f, AN_RES_FLT_START_BE); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 76 | SHOW_FLAG(f, AN_RES_INSPECT); |
| 77 | SHOW_FLAG(f, AN_RES_WAIT_HTTP); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 78 | SHOW_FLAG(f, AN_RES_STORE_RULES); |
Christopher Faulet | f4cfcf9 | 2017-11-10 14:10:35 +0100 | [diff] [blame] | 79 | SHOW_FLAG(f, AN_RES_HTTP_PROCESS_FE); |
| 80 | SHOW_FLAG(f, AN_RES_HTTP_PROCESS_BE); |
| 81 | SHOW_FLAG(f, AN_RES_FLT_HTTP_HDRS); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 82 | SHOW_FLAG(f, AN_RES_HTTP_XFER_BODY); |
Christopher Faulet | f4cfcf9 | 2017-11-10 14:10:35 +0100 | [diff] [blame] | 83 | SHOW_FLAG(f, AN_RES_FLT_XFER_DATA); |
| 84 | SHOW_FLAG(f, AN_RES_FLT_END); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 85 | |
| 86 | if (f) { |
| 87 | printf("EXTRA(0x%08x)", f); |
| 88 | } |
| 89 | putchar('\n'); |
| 90 | } |
| 91 | |
| 92 | void show_chn_flags(unsigned int f) |
| 93 | { |
| 94 | printf("chn->flags = "); |
| 95 | |
| 96 | if (!f) { |
| 97 | printf("0\n"); |
| 98 | return; |
| 99 | } |
| 100 | |
| 101 | SHOW_FLAG(f, CF_ISRESP); |
Willy Tarreau | f882a85 | 2019-03-25 18:34:28 +0100 | [diff] [blame] | 102 | SHOW_FLAG(f, CF_EOI); |
Christopher Faulet | f4cfcf9 | 2017-11-10 14:10:35 +0100 | [diff] [blame] | 103 | SHOW_FLAG(f, CF_FLT_ANALYZE); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 104 | SHOW_FLAG(f, CF_WAKE_ONCE); |
| 105 | SHOW_FLAG(f, CF_NEVER_WAIT); |
| 106 | SHOW_FLAG(f, CF_SEND_DONTWAIT); |
| 107 | SHOW_FLAG(f, CF_EXPECT_MORE); |
| 108 | SHOW_FLAG(f, CF_DONT_READ); |
| 109 | SHOW_FLAG(f, CF_AUTO_CONNECT); |
| 110 | SHOW_FLAG(f, CF_READ_DONTWAIT); |
| 111 | SHOW_FLAG(f, CF_KERN_SPLICING); |
| 112 | SHOW_FLAG(f, CF_READ_ATTACHED); |
| 113 | SHOW_FLAG(f, CF_ANA_TIMEOUT); |
| 114 | SHOW_FLAG(f, CF_WROTE_DATA); |
| 115 | SHOW_FLAG(f, CF_STREAMER_FAST); |
| 116 | SHOW_FLAG(f, CF_STREAMER); |
| 117 | SHOW_FLAG(f, CF_AUTO_CLOSE); |
| 118 | SHOW_FLAG(f, CF_SHUTW_NOW); |
| 119 | SHOW_FLAG(f, CF_SHUTW); |
| 120 | SHOW_FLAG(f, CF_WAKE_WRITE); |
| 121 | SHOW_FLAG(f, CF_WRITE_ERROR); |
| 122 | SHOW_FLAG(f, CF_WRITE_TIMEOUT); |
| 123 | SHOW_FLAG(f, CF_WRITE_PARTIAL); |
| 124 | SHOW_FLAG(f, CF_WRITE_NULL); |
| 125 | SHOW_FLAG(f, CF_READ_NOEXP); |
| 126 | SHOW_FLAG(f, CF_SHUTR_NOW); |
| 127 | SHOW_FLAG(f, CF_SHUTR); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 128 | SHOW_FLAG(f, CF_READ_ERROR); |
| 129 | SHOW_FLAG(f, CF_READ_TIMEOUT); |
| 130 | SHOW_FLAG(f, CF_READ_PARTIAL); |
| 131 | SHOW_FLAG(f, CF_READ_NULL); |
| 132 | |
| 133 | if (f) { |
| 134 | printf("EXTRA(0x%08x)", f); |
| 135 | } |
| 136 | putchar('\n'); |
| 137 | } |
| 138 | |
| 139 | void show_conn_flags(unsigned int f) |
| 140 | { |
| 141 | printf("conn->flags = "); |
| 142 | if (!f) { |
| 143 | printf("0\n"); |
| 144 | return; |
| 145 | } |
| 146 | |
| 147 | SHOW_FLAG(f, CO_FL_XPRT_TRACKED); |
Christopher Faulet | f4cfcf9 | 2017-11-10 14:10:35 +0100 | [diff] [blame] | 148 | SHOW_FLAG(f, CO_FL_RCVD_PROXY); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 149 | SHOW_FLAG(f, CO_FL_PRIVATE); |
Christopher Faulet | f4cfcf9 | 2017-11-10 14:10:35 +0100 | [diff] [blame] | 150 | SHOW_FLAG(f, CO_FL_ACCEPT_CIP); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 151 | SHOW_FLAG(f, CO_FL_ACCEPT_PROXY); |
| 152 | SHOW_FLAG(f, CO_FL_SSL_WAIT_HS); |
| 153 | SHOW_FLAG(f, CO_FL_SEND_PROXY); |
| 154 | SHOW_FLAG(f, CO_FL_WAIT_L6_CONN); |
| 155 | SHOW_FLAG(f, CO_FL_WAIT_L4_CONN); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 156 | SHOW_FLAG(f, CO_FL_ERROR); |
| 157 | SHOW_FLAG(f, CO_FL_SOCK_WR_SH); |
| 158 | SHOW_FLAG(f, CO_FL_SOCK_RD_SH); |
Willy Tarreau | db20750 | 2019-06-03 14:26:54 +0200 | [diff] [blame] | 159 | SHOW_FLAG(f, CO_FL_SOCKS4_RECV); |
| 160 | SHOW_FLAG(f, CO_FL_SOCKS4_SEND); |
Christopher Faulet | f4cfcf9 | 2017-11-10 14:10:35 +0100 | [diff] [blame] | 161 | SHOW_FLAG(f, CO_FL_EARLY_DATA); |
| 162 | SHOW_FLAG(f, CO_FL_EARLY_SSL_HS); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 163 | SHOW_FLAG(f, CO_FL_ADDR_TO_SET); |
| 164 | SHOW_FLAG(f, CO_FL_ADDR_FROM_SET); |
| 165 | SHOW_FLAG(f, CO_FL_WAIT_ROOM); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 166 | SHOW_FLAG(f, CO_FL_XPRT_READY); |
| 167 | SHOW_FLAG(f, CO_FL_CTRL_READY); |
Willy Tarreau | 54067e9 | 2020-06-19 08:47:30 +0200 | [diff] [blame] | 168 | SHOW_FLAG(f, CO_FL_IDLE_LIST); |
| 169 | SHOW_FLAG(f, CO_FL_SAFE_LIST); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 170 | |
| 171 | if (f) { |
| 172 | printf("EXTRA(0x%08x)", f); |
| 173 | } |
| 174 | putchar('\n'); |
| 175 | } |
Christopher Faulet | 5f8ef13 | 2018-03-01 08:55:21 +0100 | [diff] [blame] | 176 | void show_cs_flags(unsigned int f) |
| 177 | { |
| 178 | printf("cs->flags = "); |
| 179 | if (!f) { |
| 180 | printf("0\n"); |
| 181 | return; |
| 182 | } |
Willy Tarreau | d501646 | 2018-11-16 10:37:20 +0100 | [diff] [blame] | 183 | SHOW_FLAG(f, CS_FL_NOT_FIRST); |
Willy Tarreau | db20750 | 2019-06-03 14:26:54 +0200 | [diff] [blame] | 184 | SHOW_FLAG(f, CS_FL_KILL_CONN); |
Christopher Faulet | 5f8ef13 | 2018-03-01 08:55:21 +0100 | [diff] [blame] | 185 | SHOW_FLAG(f, CS_FL_WAIT_FOR_HS); |
Willy Tarreau | f882a85 | 2019-03-25 18:34:28 +0100 | [diff] [blame] | 186 | SHOW_FLAG(f, CS_FL_EOI); |
Christopher Faulet | 5f8ef13 | 2018-03-01 08:55:21 +0100 | [diff] [blame] | 187 | SHOW_FLAG(f, CS_FL_EOS); |
Willy Tarreau | 121c4e0 | 2018-12-17 21:58:03 +0100 | [diff] [blame] | 188 | SHOW_FLAG(f, CS_FL_ERR_PENDING); |
| 189 | SHOW_FLAG(f, CS_FL_WANT_ROOM); |
Christopher Faulet | 5f8ef13 | 2018-03-01 08:55:21 +0100 | [diff] [blame] | 190 | SHOW_FLAG(f, CS_FL_RCV_MORE); |
| 191 | SHOW_FLAG(f, CS_FL_ERROR); |
| 192 | SHOW_FLAG(f, CS_FL_SHWS); |
| 193 | SHOW_FLAG(f, CS_FL_SHWN); |
| 194 | SHOW_FLAG(f, CS_FL_SHRR); |
| 195 | SHOW_FLAG(f, CS_FL_SHRD); |
Christopher Faulet | 5f8ef13 | 2018-03-01 08:55:21 +0100 | [diff] [blame] | 196 | |
| 197 | if (f) { |
| 198 | printf("EXTRA(0x%08x)", f); |
| 199 | } |
| 200 | putchar('\n'); |
| 201 | } |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 202 | |
| 203 | void show_si_et(unsigned int f) |
| 204 | { |
| 205 | printf("si->et = "); |
| 206 | if (!f) { |
| 207 | printf("SI_ET_NONE\n"); |
| 208 | return; |
| 209 | } |
| 210 | |
| 211 | SHOW_FLAG(f, SI_ET_QUEUE_TO); |
| 212 | SHOW_FLAG(f, SI_ET_QUEUE_ERR); |
| 213 | SHOW_FLAG(f, SI_ET_QUEUE_ABRT); |
| 214 | SHOW_FLAG(f, SI_ET_CONN_TO); |
| 215 | SHOW_FLAG(f, SI_ET_CONN_ERR); |
| 216 | SHOW_FLAG(f, SI_ET_CONN_ABRT); |
| 217 | SHOW_FLAG(f, SI_ET_CONN_RES); |
| 218 | SHOW_FLAG(f, SI_ET_CONN_OTHER); |
| 219 | SHOW_FLAG(f, SI_ET_DATA_TO); |
| 220 | SHOW_FLAG(f, SI_ET_DATA_ERR); |
| 221 | SHOW_FLAG(f, SI_ET_DATA_ABRT); |
| 222 | |
| 223 | if (f) { |
| 224 | printf("EXTRA(0x%08x)", f); |
| 225 | } |
| 226 | putchar('\n'); |
| 227 | } |
| 228 | |
| 229 | void show_si_flags(unsigned int f) |
| 230 | { |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 231 | printf("si->flags = "); |
| 232 | if (!f) { |
| 233 | printf("SI_FL_NONE\n"); |
| 234 | return; |
| 235 | } |
| 236 | |
| 237 | SHOW_FLAG(f, SI_FL_EXP); |
| 238 | SHOW_FLAG(f, SI_FL_ERR); |
Willy Tarreau | d0f5bbc | 2018-11-14 11:10:26 +0100 | [diff] [blame] | 239 | SHOW_FLAG(f, SI_FL_RXBLK_ROOM); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 240 | SHOW_FLAG(f, SI_FL_WAIT_DATA); |
| 241 | SHOW_FLAG(f, SI_FL_ISBACK); |
| 242 | SHOW_FLAG(f, SI_FL_DONT_WAKE); |
| 243 | SHOW_FLAG(f, SI_FL_INDEP_STR); |
| 244 | SHOW_FLAG(f, SI_FL_NOLINGER); |
| 245 | SHOW_FLAG(f, SI_FL_NOHALF); |
| 246 | SHOW_FLAG(f, SI_FL_SRC_ADDR); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 247 | SHOW_FLAG(f, SI_FL_WANT_GET); |
Willy Tarreau | f2ddd87 | 2018-12-18 09:54:22 +0100 | [diff] [blame] | 248 | SHOW_FLAG(f, SI_FL_CLEAN_ABRT); |
Willy Tarreau | 94f7907 | 2018-11-14 11:24:08 +0100 | [diff] [blame] | 249 | SHOW_FLAG(f, SI_FL_RXBLK_CHAN); |
| 250 | SHOW_FLAG(f, SI_FL_RXBLK_BUFF); |
| 251 | SHOW_FLAG(f, SI_FL_RXBLK_ROOM); |
| 252 | SHOW_FLAG(f, SI_FL_RXBLK_SHUT); |
| 253 | SHOW_FLAG(f, SI_FL_RX_WAIT_EP); |
Willy Tarreau | fc402cf | 2020-06-28 16:05:39 +0200 | [diff] [blame] | 254 | SHOW_FLAG(f, SI_FL_L7_RETRY); |
| 255 | SHOW_FLAG(f, SI_FL_D_L7_RETRY); |
Willy Tarreau | 94f7907 | 2018-11-14 11:24:08 +0100 | [diff] [blame] | 256 | |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 257 | if (f) { |
Willy Tarreau | 94f7907 | 2018-11-14 11:24:08 +0100 | [diff] [blame] | 258 | printf("EXTRA(0x%08x)", f); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 259 | } |
| 260 | putchar('\n'); |
| 261 | } |
| 262 | |
| 263 | void show_task_state(unsigned int f) |
| 264 | { |
| 265 | printf("task->state = "); |
| 266 | |
| 267 | if (!f) { |
| 268 | printf("TASK_SLEEPING\n"); |
| 269 | return; |
| 270 | } |
| 271 | |
| 272 | SHOW_FLAG(f, TASK_WOKEN_OTHER); |
| 273 | SHOW_FLAG(f, TASK_WOKEN_RES); |
| 274 | SHOW_FLAG(f, TASK_WOKEN_MSG); |
| 275 | SHOW_FLAG(f, TASK_WOKEN_SIGNAL); |
| 276 | SHOW_FLAG(f, TASK_WOKEN_IO); |
| 277 | SHOW_FLAG(f, TASK_WOKEN_TIMER); |
| 278 | SHOW_FLAG(f, TASK_WOKEN_INIT); |
| 279 | SHOW_FLAG(f, TASK_RUNNING); |
| 280 | |
| 281 | if (f) { |
| 282 | printf("EXTRA(0x%08x)", f); |
| 283 | } |
| 284 | putchar('\n'); |
| 285 | } |
| 286 | |
| 287 | void show_txn_flags(unsigned int f) |
| 288 | { |
| 289 | printf("txn->flags = "); |
| 290 | |
| 291 | if (!f) { |
| 292 | printf("0\n"); |
| 293 | return; |
| 294 | } |
| 295 | |
| 296 | SHOW_FLAG(f, TX_NOT_FIRST); |
| 297 | SHOW_FLAG(f, TX_USE_PX_CONN); |
Christopher Faulet | c41547b | 2019-07-16 14:32:23 +0200 | [diff] [blame] | 298 | SHOW_FLAG(f, TX_CON_WANT_TUN); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 299 | |
| 300 | SHOW_FLAG(f, TX_CACHE_COOK); |
| 301 | SHOW_FLAG(f, TX_CACHEABLE); |
| 302 | SHOW_FLAG(f, TX_SCK_PRESENT); |
| 303 | |
| 304 | //printf("%s", f ? "" : " | "); |
| 305 | switch (f & TX_SCK_MASK) { |
| 306 | case TX_SCK_NONE: f &= ~TX_SCK_MASK ; /*printf("TX_SCK_NONE%s", f ? " | " : "");*/ break; |
| 307 | case TX_SCK_FOUND: f &= ~TX_SCK_MASK ; printf("TX_SCK_FOUND%s", f ? " | " : ""); break; |
| 308 | case TX_SCK_DELETED: f &= ~TX_SCK_MASK ; printf("TX_SCK_DELETED%s", f ? " | " : ""); break; |
| 309 | case TX_SCK_INSERTED: f &= ~TX_SCK_MASK ; printf("TX_SCK_INSERTED%s", f ? " | " : ""); break; |
| 310 | case TX_SCK_REPLACED: f &= ~TX_SCK_MASK ; printf("TX_SCK_REPLACED%s", f ? " | " : ""); break; |
| 311 | case TX_SCK_UPDATED: f &= ~TX_SCK_MASK ; printf("TX_SCK_UPDATED%s", f ? " | " : ""); break; |
| 312 | default: printf("TX_SCK_MASK(%02x)", f); f &= ~TX_SCK_MASK ; printf("%s", f ? " | " : ""); break; |
| 313 | } |
| 314 | |
| 315 | //printf("%s", f ? "" : " | "); |
| 316 | switch (f & TX_CK_MASK) { |
| 317 | case TX_CK_NONE: f &= ~TX_CK_MASK ; /*printf("TX_CK_NONE%s", f ? " | " : "");*/ break; |
| 318 | case TX_CK_INVALID: f &= ~TX_CK_MASK ; printf("TX_CK_INVALID%s", f ? " | " : ""); break; |
| 319 | case TX_CK_DOWN: f &= ~TX_CK_MASK ; printf("TX_CK_DOWN%s", f ? " | " : ""); break; |
| 320 | case TX_CK_VALID: f &= ~TX_CK_MASK ; printf("TX_CK_VALID%s", f ? " | " : ""); break; |
| 321 | case TX_CK_EXPIRED: f &= ~TX_CK_MASK ; printf("TX_CK_EXPIRED%s", f ? " | " : ""); break; |
| 322 | case TX_CK_OLD: f &= ~TX_CK_MASK ; printf("TX_CK_OLD%s", f ? " | " : ""); break; |
| 323 | case TX_CK_UNUSED: f &= ~TX_CK_MASK ; printf("TX_CK_UNUSED%s", f ? " | " : ""); break; |
| 324 | default: printf("TX_CK_MASK(%02x)", f); f &= ~TX_CK_MASK ; printf("%s", f ? " | " : ""); break; |
| 325 | } |
| 326 | |
| 327 | SHOW_FLAG(f, TX_CLTARPIT); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 328 | |
| 329 | if (f) { |
| 330 | printf("EXTRA(0x%08x)", f); |
| 331 | } |
| 332 | putchar('\n'); |
| 333 | } |
| 334 | |
| 335 | void show_strm_flags(unsigned int f) |
| 336 | { |
| 337 | printf("strm->flags = "); |
| 338 | |
| 339 | if (!f) { |
| 340 | printf("0\n"); |
| 341 | return; |
| 342 | } |
| 343 | |
| 344 | SHOW_FLAG(f, SF_SRV_REUSED); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 345 | SHOW_FLAG(f, SF_IGNORE_PRST); |
| 346 | |
| 347 | //printf("%s", f ? "" : " | "); |
| 348 | switch (f & SF_FINST_MASK) { |
| 349 | case SF_FINST_R: f &= ~SF_FINST_MASK ; printf("SF_FINST_R%s", f ? " | " : ""); break; |
| 350 | case SF_FINST_C: f &= ~SF_FINST_MASK ; printf("SF_FINST_C%s", f ? " | " : ""); break; |
| 351 | case SF_FINST_H: f &= ~SF_FINST_MASK ; printf("SF_FINST_H%s", f ? " | " : ""); break; |
| 352 | case SF_FINST_D: f &= ~SF_FINST_MASK ; printf("SF_FINST_D%s", f ? " | " : ""); break; |
| 353 | case SF_FINST_L: f &= ~SF_FINST_MASK ; printf("SF_FINST_L%s", f ? " | " : ""); break; |
| 354 | case SF_FINST_Q: f &= ~SF_FINST_MASK ; printf("SF_FINST_Q%s", f ? " | " : ""); break; |
| 355 | case SF_FINST_T: f &= ~SF_FINST_MASK ; printf("SF_FINST_T%s", f ? " | " : ""); break; |
| 356 | } |
| 357 | |
| 358 | switch (f & SF_ERR_MASK) { |
| 359 | case SF_ERR_LOCAL: f &= ~SF_ERR_MASK ; printf("SF_ERR_LOCAL%s", f ? " | " : ""); break; |
| 360 | case SF_ERR_CLITO: f &= ~SF_ERR_MASK ; printf("SF_ERR_CLITO%s", f ? " | " : ""); break; |
| 361 | case SF_ERR_CLICL: f &= ~SF_ERR_MASK ; printf("SF_ERR_CLICL%s", f ? " | " : ""); break; |
| 362 | case SF_ERR_SRVTO: f &= ~SF_ERR_MASK ; printf("SF_ERR_SRVTO%s", f ? " | " : ""); break; |
| 363 | case SF_ERR_SRVCL: f &= ~SF_ERR_MASK ; printf("SF_ERR_SRVCL%s", f ? " | " : ""); break; |
| 364 | case SF_ERR_PRXCOND: f &= ~SF_ERR_MASK ; printf("SF_ERR_PRXCOND%s", f ? " | " : ""); break; |
| 365 | case SF_ERR_RESOURCE: f &= ~SF_ERR_MASK ; printf("SF_ERR_RESOURCE%s", f ? " | " : ""); break; |
| 366 | case SF_ERR_INTERNAL: f &= ~SF_ERR_MASK ; printf("SF_ERR_INTERNAL%s", f ? " | " : ""); break; |
| 367 | case SF_ERR_DOWN: f &= ~SF_ERR_MASK ; printf("SF_ERR_DOWN%s", f ? " | " : ""); break; |
| 368 | case SF_ERR_KILLED: f &= ~SF_ERR_MASK ; printf("SF_ERR_KILLED%s", f ? " | " : ""); break; |
| 369 | case SF_ERR_UP: f &= ~SF_ERR_MASK ; printf("SF_ERR_UP%s", f ? " | " : ""); break; |
Willy Tarreau | a7da4d2 | 2016-11-11 08:05:34 +0100 | [diff] [blame] | 370 | case SF_ERR_CHK_PORT: f &= ~SF_ERR_MASK ; printf("SF_ERR_CHK_PORT%s", f ? " | " : ""); break; |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 371 | } |
| 372 | |
Willy Tarreau | 8a0eabd | 2020-02-06 07:57:36 +0100 | [diff] [blame] | 373 | SHOW_FLAG(f, SF_HTX); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 374 | SHOW_FLAG(f, SF_REDIRECTABLE); |
Willy Tarreau | 8a0eabd | 2020-02-06 07:57:36 +0100 | [diff] [blame] | 375 | SHOW_FLAG(f, SF_IGNORE); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 376 | SHOW_FLAG(f, SF_REDISP); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 377 | SHOW_FLAG(f, SF_CURR_SESS); |
| 378 | SHOW_FLAG(f, SF_MONITOR); |
| 379 | SHOW_FLAG(f, SF_FORCE_PRST); |
| 380 | SHOW_FLAG(f, SF_BE_ASSIGNED); |
| 381 | SHOW_FLAG(f, SF_ADDR_SET); |
| 382 | SHOW_FLAG(f, SF_ASSIGNED); |
| 383 | SHOW_FLAG(f, SF_DIRECT); |
| 384 | |
| 385 | if (f) { |
| 386 | printf("EXTRA(0x%08x)", f); |
| 387 | } |
| 388 | putchar('\n'); |
| 389 | } |
| 390 | |
Willy Tarreau | 354b6f5 | 2020-02-06 08:33:08 +0100 | [diff] [blame] | 391 | void usage_exit(const char *name) |
| 392 | { |
Willy Tarreau | e4f80a0 | 2020-02-06 18:17:50 +0100 | [diff] [blame] | 393 | fprintf(stderr, "Usage: %s [ana|chn|conn|cs|si|sierr|strm|task|txn]* { [+-][0x]value* | - }\n", name); |
Willy Tarreau | 354b6f5 | 2020-02-06 08:33:08 +0100 | [diff] [blame] | 394 | exit(1); |
| 395 | } |
| 396 | |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 397 | int main(int argc, char **argv) |
| 398 | { |
| 399 | unsigned int flags; |
Willy Tarreau | 354b6f5 | 2020-02-06 08:33:08 +0100 | [diff] [blame] | 400 | unsigned int show_as = 0; |
| 401 | unsigned int f; |
| 402 | const char *name = argv[0]; |
Willy Tarreau | e4f80a0 | 2020-02-06 18:17:50 +0100 | [diff] [blame] | 403 | char line[20]; |
| 404 | char *value; |
Willy Tarreau | bde76f0 | 2020-02-06 08:48:16 +0100 | [diff] [blame] | 405 | int multi = 0; |
Willy Tarreau | e4f80a0 | 2020-02-06 18:17:50 +0100 | [diff] [blame] | 406 | int use_stdin = 0; |
Willy Tarreau | 354b6f5 | 2020-02-06 08:33:08 +0100 | [diff] [blame] | 407 | char *err; |
| 408 | |
| 409 | while (argc > 0) { |
| 410 | argv++; argc--; |
| 411 | if (argc < 1) |
| 412 | usage_exit(name); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 413 | |
Willy Tarreau | 354b6f5 | 2020-02-06 08:33:08 +0100 | [diff] [blame] | 414 | f = get_show_as(argv[0]); |
Willy Tarreau | bde76f0 | 2020-02-06 08:48:16 +0100 | [diff] [blame] | 415 | if (!f) |
| 416 | break; |
Willy Tarreau | 354b6f5 | 2020-02-06 08:33:08 +0100 | [diff] [blame] | 417 | show_as |= f; |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 418 | } |
| 419 | |
Willy Tarreau | 354b6f5 | 2020-02-06 08:33:08 +0100 | [diff] [blame] | 420 | if (!show_as) |
| 421 | show_as = ~0U; |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 422 | |
Willy Tarreau | bde76f0 | 2020-02-06 08:48:16 +0100 | [diff] [blame] | 423 | if (argc > 1) |
| 424 | multi = 1; |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 425 | |
Willy Tarreau | e4f80a0 | 2020-02-06 18:17:50 +0100 | [diff] [blame] | 426 | if (strcmp(argv[0], "-") == 0) |
| 427 | use_stdin = 1; |
| 428 | |
Willy Tarreau | bde76f0 | 2020-02-06 08:48:16 +0100 | [diff] [blame] | 429 | while (argc > 0) { |
Willy Tarreau | e4f80a0 | 2020-02-06 18:17:50 +0100 | [diff] [blame] | 430 | if (use_stdin) { |
| 431 | value = fgets(line, sizeof(line), stdin); |
| 432 | if (!value) |
| 433 | break; |
| 434 | |
Ilya Shipitsin | 6fb0f21 | 2020-04-02 15:25:26 +0500 | [diff] [blame] | 435 | /* skip common leading delimiters that slip from copy-paste */ |
Willy Tarreau | e4f80a0 | 2020-02-06 18:17:50 +0100 | [diff] [blame] | 436 | while (*value == ' ' || *value == '\t' || *value == ':' || *value == '=') |
| 437 | value++; |
| 438 | |
| 439 | /* stop at the end of the number and trim any C suffix like "UL" */ |
| 440 | err = value; |
| 441 | while (*err == '-' || *err == '+' || |
| 442 | (isalnum(*err) && toupper(*err) != 'U' && toupper(*err) != 'L')) |
| 443 | err++; |
| 444 | if (err) |
| 445 | *err = 0; |
| 446 | } else { |
| 447 | value = argv[0]; |
| 448 | argv++; argc--; |
| 449 | } |
| 450 | |
| 451 | flags = strtoul(value, &err, 0); |
| 452 | if (!*value || *err) { |
| 453 | fprintf(stderr, "Unparsable value: <%s>\n", value); |
Willy Tarreau | bde76f0 | 2020-02-06 08:48:16 +0100 | [diff] [blame] | 454 | usage_exit(name); |
| 455 | } |
| 456 | |
Willy Tarreau | e4f80a0 | 2020-02-06 18:17:50 +0100 | [diff] [blame] | 457 | if (multi || use_stdin) |
Willy Tarreau | bde76f0 | 2020-02-06 08:48:16 +0100 | [diff] [blame] | 458 | printf("### 0x%08x:\n", flags); |
| 459 | |
| 460 | if (show_as & SHOW_AS_ANA) show_chn_ana(flags); |
| 461 | if (show_as & SHOW_AS_CHN) show_chn_flags(flags); |
| 462 | if (show_as & SHOW_AS_CONN) show_conn_flags(flags); |
| 463 | if (show_as & SHOW_AS_CS) show_cs_flags(flags); |
| 464 | if (show_as & SHOW_AS_SI) show_si_flags(flags); |
| 465 | if (show_as & SHOW_AS_SIET) show_si_et(flags); |
| 466 | if (show_as & SHOW_AS_STRM) show_strm_flags(flags); |
| 467 | if (show_as & SHOW_AS_TASK) show_task_state(flags); |
| 468 | if (show_as & SHOW_AS_TXN) show_txn_flags(flags); |
Willy Tarreau | bde76f0 | 2020-02-06 08:48:16 +0100 | [diff] [blame] | 469 | } |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 470 | return 0; |
| 471 | } |