blob: 02064b39eaf6bdd8092255c047d12e4744ab2edc [file] [log] [blame]
Willy Tarreau074d65b2015-12-20 23:21:57 +01001#include <stdio.h>
2#include <stdlib.h>
3
Willy Tarreauf1d32c42020-06-04 21:07:02 +02004#include <haproxy/channel-t.h>
Willy Tarreau7ea393d2020-06-04 18:02:10 +02005#include <haproxy/connection-t.h>
Christopher Fauletdb90f2a2022-03-22 16:06:25 +01006#include <haproxy/conn_stream-t.h>
Willy Tarreauc2b1ff02020-06-04 21:21:03 +02007#include <haproxy/http_ana-t.h>
Willy Tarreaudfd3de82020-06-04 23:46:14 +02008#include <haproxy/stream-t.h>
Willy Tarreau5e539c92020-06-04 20:45:39 +02009#include <haproxy/stream_interface-t.h>
Willy Tarreaucea0e1b2020-06-04 17:25:40 +020010#include <haproxy/task-t.h>
Willy Tarreau074d65b2015-12-20 23:21:57 +010011
Willy Tarreau354b6f52020-02-06 08:33:08 +010012// 1 bit per flag, no hole permitted here
13#define SHOW_AS_ANA 0x00000001
14#define SHOW_AS_CHN 0x00000002
15#define SHOW_AS_CONN 0x00000004
16#define SHOW_AS_CS 0x00000008
17#define SHOW_AS_SI 0x00000010
18#define SHOW_AS_SIET 0x00000020
19#define SHOW_AS_STRM 0x00000040
20#define SHOW_AS_TASK 0x00000080
21#define SHOW_AS_TXN 0x00000100
Christopher Fauletdb90f2a2022-03-22 16:06:25 +010022#define SHOW_AS_ENDP 0x00000200
Willy Tarreau354b6f52020-02-06 08:33:08 +010023
24// command line names, must be in exact same order as the SHOW_AS_* flags above
25// so that show_as_words[i] matches flag 1U<<i.
Christopher Fauletdb90f2a2022-03-22 16:06:25 +010026const char *show_as_words[] = { "ana", "chn", "conn", "cs", "si", "siet", "strm", "task", "txn", "endp", };
Willy Tarreau354b6f52020-02-06 08:33:08 +010027
Willy Tarreau074d65b2015-12-20 23:21:57 +010028#define SHOW_FLAG(f,n) \
29 do { \
30 if (!((f) & (n))) break; \
31 (f) &= ~(n); \
32 printf(#n"%s", (f) ? " | " : ""); \
33 } while (0)
34
Willy Tarreau354b6f52020-02-06 08:33:08 +010035unsigned int get_show_as(const char *word)
36{
37 int w = 0;
38
39 while (1) {
40 if (w == sizeof(show_as_words) / sizeof(*show_as_words))
41 return 0;
42 if (strcmp(word, show_as_words[w]) == 0)
43 return 1U << w;
44 w++;
45 }
46}
47
Willy Tarreau074d65b2015-12-20 23:21:57 +010048void show_chn_ana(unsigned int f)
49{
50 printf("chn->ana = ");
51
52 if (!f) {
53 printf("0\n");
54 return;
55 }
56
Christopher Fauletf4cfcf92017-11-10 14:10:35 +010057 SHOW_FLAG(f, AN_REQ_FLT_START_FE);
Willy Tarreau074d65b2015-12-20 23:21:57 +010058 SHOW_FLAG(f, AN_REQ_INSPECT_FE);
59 SHOW_FLAG(f, AN_REQ_WAIT_HTTP);
60 SHOW_FLAG(f, AN_REQ_HTTP_BODY);
61 SHOW_FLAG(f, AN_REQ_HTTP_PROCESS_FE);
62 SHOW_FLAG(f, AN_REQ_SWITCHING_RULES);
Christopher Fauletf4cfcf92017-11-10 14:10:35 +010063 SHOW_FLAG(f, AN_REQ_FLT_START_BE);
Willy Tarreau074d65b2015-12-20 23:21:57 +010064 SHOW_FLAG(f, AN_REQ_INSPECT_BE);
65 SHOW_FLAG(f, AN_REQ_HTTP_PROCESS_BE);
Christopher Fauletf4cfcf92017-11-10 14:10:35 +010066 SHOW_FLAG(f, AN_REQ_HTTP_TARPIT);
Willy Tarreau074d65b2015-12-20 23:21:57 +010067 SHOW_FLAG(f, AN_REQ_SRV_RULES);
68 SHOW_FLAG(f, AN_REQ_HTTP_INNER);
Willy Tarreau074d65b2015-12-20 23:21:57 +010069 SHOW_FLAG(f, AN_REQ_PRST_RDP_COOKIE);
Christopher Fauletf4cfcf92017-11-10 14:10:35 +010070 SHOW_FLAG(f, AN_REQ_STICKING_RULES);
71 SHOW_FLAG(f, AN_REQ_FLT_HTTP_HDRS);
Willy Tarreau074d65b2015-12-20 23:21:57 +010072 SHOW_FLAG(f, AN_REQ_HTTP_XFER_BODY);
Christopher Fauletc2b7fa82022-01-18 10:46:10 +010073 SHOW_FLAG(f, AN_REQ_WAIT_CLI);
Christopher Fauletf4cfcf92017-11-10 14:10:35 +010074 SHOW_FLAG(f, AN_REQ_FLT_XFER_DATA);
75 SHOW_FLAG(f, AN_REQ_FLT_END);
76
Willy Tarreau260bf5c2018-01-15 18:59:16 +010077 SHOW_FLAG(f, AN_RES_FLT_START_FE);
78 SHOW_FLAG(f, AN_RES_FLT_START_BE);
Willy Tarreau074d65b2015-12-20 23:21:57 +010079 SHOW_FLAG(f, AN_RES_INSPECT);
80 SHOW_FLAG(f, AN_RES_WAIT_HTTP);
Willy Tarreau074d65b2015-12-20 23:21:57 +010081 SHOW_FLAG(f, AN_RES_STORE_RULES);
Christopher Fauletf4cfcf92017-11-10 14:10:35 +010082 SHOW_FLAG(f, AN_RES_HTTP_PROCESS_FE);
83 SHOW_FLAG(f, AN_RES_HTTP_PROCESS_BE);
84 SHOW_FLAG(f, AN_RES_FLT_HTTP_HDRS);
Willy Tarreau074d65b2015-12-20 23:21:57 +010085 SHOW_FLAG(f, AN_RES_HTTP_XFER_BODY);
Christopher Fauletc2b7fa82022-01-18 10:46:10 +010086 SHOW_FLAG(f, AN_RES_WAIT_CLI);
Christopher Fauletf4cfcf92017-11-10 14:10:35 +010087 SHOW_FLAG(f, AN_RES_FLT_XFER_DATA);
88 SHOW_FLAG(f, AN_RES_FLT_END);
Willy Tarreau074d65b2015-12-20 23:21:57 +010089
90 if (f) {
91 printf("EXTRA(0x%08x)", f);
92 }
93 putchar('\n');
94}
95
96void show_chn_flags(unsigned int f)
97{
98 printf("chn->flags = ");
99
100 if (!f) {
101 printf("0\n");
102 return;
103 }
104
105 SHOW_FLAG(f, CF_ISRESP);
Willy Tarreauf882a852019-03-25 18:34:28 +0100106 SHOW_FLAG(f, CF_EOI);
Christopher Fauletf4cfcf92017-11-10 14:10:35 +0100107 SHOW_FLAG(f, CF_FLT_ANALYZE);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100108 SHOW_FLAG(f, CF_WAKE_ONCE);
109 SHOW_FLAG(f, CF_NEVER_WAIT);
110 SHOW_FLAG(f, CF_SEND_DONTWAIT);
111 SHOW_FLAG(f, CF_EXPECT_MORE);
112 SHOW_FLAG(f, CF_DONT_READ);
113 SHOW_FLAG(f, CF_AUTO_CONNECT);
114 SHOW_FLAG(f, CF_READ_DONTWAIT);
115 SHOW_FLAG(f, CF_KERN_SPLICING);
116 SHOW_FLAG(f, CF_READ_ATTACHED);
117 SHOW_FLAG(f, CF_ANA_TIMEOUT);
118 SHOW_FLAG(f, CF_WROTE_DATA);
119 SHOW_FLAG(f, CF_STREAMER_FAST);
120 SHOW_FLAG(f, CF_STREAMER);
121 SHOW_FLAG(f, CF_AUTO_CLOSE);
122 SHOW_FLAG(f, CF_SHUTW_NOW);
123 SHOW_FLAG(f, CF_SHUTW);
124 SHOW_FLAG(f, CF_WAKE_WRITE);
125 SHOW_FLAG(f, CF_WRITE_ERROR);
126 SHOW_FLAG(f, CF_WRITE_TIMEOUT);
127 SHOW_FLAG(f, CF_WRITE_PARTIAL);
128 SHOW_FLAG(f, CF_WRITE_NULL);
129 SHOW_FLAG(f, CF_READ_NOEXP);
130 SHOW_FLAG(f, CF_SHUTR_NOW);
131 SHOW_FLAG(f, CF_SHUTR);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100132 SHOW_FLAG(f, CF_READ_ERROR);
133 SHOW_FLAG(f, CF_READ_TIMEOUT);
134 SHOW_FLAG(f, CF_READ_PARTIAL);
135 SHOW_FLAG(f, CF_READ_NULL);
136
137 if (f) {
138 printf("EXTRA(0x%08x)", f);
139 }
140 putchar('\n');
141}
142
143void show_conn_flags(unsigned int f)
144{
145 printf("conn->flags = ");
146 if (!f) {
147 printf("0\n");
148 return;
149 }
150
151 SHOW_FLAG(f, CO_FL_XPRT_TRACKED);
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100152 SHOW_FLAG(f, CO_FL_SESS_IDLE);
Christopher Fauletf4cfcf92017-11-10 14:10:35 +0100153 SHOW_FLAG(f, CO_FL_RCVD_PROXY);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100154 SHOW_FLAG(f, CO_FL_PRIVATE);
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100155 SHOW_FLAG(f, CO_FL_SSL_WAIT_HS);
Christopher Fauletf4cfcf92017-11-10 14:10:35 +0100156 SHOW_FLAG(f, CO_FL_ACCEPT_CIP);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100157 SHOW_FLAG(f, CO_FL_ACCEPT_PROXY);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100158 SHOW_FLAG(f, CO_FL_SEND_PROXY);
159 SHOW_FLAG(f, CO_FL_WAIT_L6_CONN);
160 SHOW_FLAG(f, CO_FL_WAIT_L4_CONN);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100161 SHOW_FLAG(f, CO_FL_ERROR);
162 SHOW_FLAG(f, CO_FL_SOCK_WR_SH);
163 SHOW_FLAG(f, CO_FL_SOCK_RD_SH);
Willy Tarreaudb207502019-06-03 14:26:54 +0200164 SHOW_FLAG(f, CO_FL_SOCKS4_RECV);
165 SHOW_FLAG(f, CO_FL_SOCKS4_SEND);
Christopher Fauletf4cfcf92017-11-10 14:10:35 +0100166 SHOW_FLAG(f, CO_FL_EARLY_DATA);
167 SHOW_FLAG(f, CO_FL_EARLY_SSL_HS);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100168 SHOW_FLAG(f, CO_FL_ADDR_TO_SET);
169 SHOW_FLAG(f, CO_FL_ADDR_FROM_SET);
170 SHOW_FLAG(f, CO_FL_WAIT_ROOM);
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100171 SHOW_FLAG(f, CO_FL_WANT_DRAIN);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100172 SHOW_FLAG(f, CO_FL_XPRT_READY);
173 SHOW_FLAG(f, CO_FL_CTRL_READY);
Willy Tarreau54067e92020-06-19 08:47:30 +0200174 SHOW_FLAG(f, CO_FL_IDLE_LIST);
175 SHOW_FLAG(f, CO_FL_SAFE_LIST);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100176
177 if (f) {
178 printf("EXTRA(0x%08x)", f);
179 }
180 putchar('\n');
181}
Christopher Fauletdb90f2a2022-03-22 16:06:25 +0100182
183void show_endp_flags(unsigned int f)
184{
185 printf("endp->flags = ");
186 if (!f) {
187 printf("0\n");
188 return;
189 }
Christopher Faulete9e48202022-03-22 18:13:29 +0100190 SHOW_FLAG(f, CS_EP_KILL_CONN);
191 SHOW_FLAG(f, CS_EP_WAIT_FOR_HS);
Christopher Fauletb041b232022-03-24 10:27:02 +0100192 SHOW_FLAG(f, CS_EP_WANT_ROOM);
193 SHOW_FLAG(f, CS_EP_ERROR);
194 SHOW_FLAG(f, CS_EP_ERR_PENDING);
195 SHOW_FLAG(f, CS_EP_EOS);
196 SHOW_FLAG(f, CS_EP_EOI);
197 SHOW_FLAG(f, CS_EP_RCV_MORE);
Christopher Faulete9e48202022-03-22 18:13:29 +0100198 SHOW_FLAG(f, CS_EP_MAY_SPLICE);
199 SHOW_FLAG(f, CS_EP_WEBSOCKET);
200 SHOW_FLAG(f, CS_EP_NOT_FIRST);
201 SHOW_FLAG(f, CS_EP_SHWS);
202 SHOW_FLAG(f, CS_EP_SHWN);
203 SHOW_FLAG(f, CS_EP_SHRR);
204 SHOW_FLAG(f, CS_EP_SHRD);
Christopher Faulet9ec2f4d2022-03-23 15:15:29 +0100205 SHOW_FLAG(f, CS_EP_ORPHAN);
206 SHOW_FLAG(f, CS_EP_DETACHED);
Christopher Fauletdb90f2a2022-03-22 16:06:25 +0100207 SHOW_FLAG(f, CS_EP_T_APPLET);
208 SHOW_FLAG(f, CS_EP_T_MUX);
209
210 if (f) {
211 printf("EXTRA(0x%08x)", f);
212 }
213 putchar('\n');
214}
Christopher Faulet5f8ef132018-03-01 08:55:21 +0100215void show_cs_flags(unsigned int f)
216{
217 printf("cs->flags = ");
218 if (!f) {
219 printf("0\n");
220 return;
221 }
Christopher Faulet30995112022-03-25 15:32:38 +0100222 SHOW_FLAG(f, CS_FL_ISBACK);
Christopher Faulet5f8ef132018-03-01 08:55:21 +0100223
224 if (f) {
225 printf("EXTRA(0x%08x)", f);
226 }
227 putchar('\n');
228}
Willy Tarreau074d65b2015-12-20 23:21:57 +0100229
230void show_si_et(unsigned int f)
231{
232 printf("si->et = ");
233 if (!f) {
234 printf("SI_ET_NONE\n");
235 return;
236 }
237
238 SHOW_FLAG(f, SI_ET_QUEUE_TO);
239 SHOW_FLAG(f, SI_ET_QUEUE_ERR);
240 SHOW_FLAG(f, SI_ET_QUEUE_ABRT);
241 SHOW_FLAG(f, SI_ET_CONN_TO);
242 SHOW_FLAG(f, SI_ET_CONN_ERR);
243 SHOW_FLAG(f, SI_ET_CONN_ABRT);
244 SHOW_FLAG(f, SI_ET_CONN_RES);
245 SHOW_FLAG(f, SI_ET_CONN_OTHER);
246 SHOW_FLAG(f, SI_ET_DATA_TO);
247 SHOW_FLAG(f, SI_ET_DATA_ERR);
248 SHOW_FLAG(f, SI_ET_DATA_ABRT);
249
250 if (f) {
251 printf("EXTRA(0x%08x)", f);
252 }
253 putchar('\n');
254}
255
256void show_si_flags(unsigned int f)
257{
Willy Tarreau074d65b2015-12-20 23:21:57 +0100258 printf("si->flags = ");
259 if (!f) {
260 printf("SI_FL_NONE\n");
261 return;
262 }
263
264 SHOW_FLAG(f, SI_FL_EXP);
265 SHOW_FLAG(f, SI_FL_ERR);
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100266 SHOW_FLAG(f, SI_FL_KILL_CONN);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100267 SHOW_FLAG(f, SI_FL_WAIT_DATA);
268 SHOW_FLAG(f, SI_FL_ISBACK);
269 SHOW_FLAG(f, SI_FL_DONT_WAKE);
270 SHOW_FLAG(f, SI_FL_INDEP_STR);
271 SHOW_FLAG(f, SI_FL_NOLINGER);
272 SHOW_FLAG(f, SI_FL_NOHALF);
273 SHOW_FLAG(f, SI_FL_SRC_ADDR);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100274 SHOW_FLAG(f, SI_FL_WANT_GET);
Willy Tarreauf2ddd872018-12-18 09:54:22 +0100275 SHOW_FLAG(f, SI_FL_CLEAN_ABRT);
Willy Tarreau94f79072018-11-14 11:24:08 +0100276 SHOW_FLAG(f, SI_FL_RXBLK_CHAN);
277 SHOW_FLAG(f, SI_FL_RXBLK_BUFF);
278 SHOW_FLAG(f, SI_FL_RXBLK_ROOM);
279 SHOW_FLAG(f, SI_FL_RXBLK_SHUT);
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100280 SHOW_FLAG(f, SI_FL_RXBLK_CONN);
Willy Tarreau94f79072018-11-14 11:24:08 +0100281 SHOW_FLAG(f, SI_FL_RX_WAIT_EP);
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100282 SHOW_FLAG(f, SI_FL_ADDR_FROM_SET);
283 SHOW_FLAG(f, SI_FL_ADDR_TO_SET);
Willy Tarreau94f79072018-11-14 11:24:08 +0100284
Willy Tarreau074d65b2015-12-20 23:21:57 +0100285 if (f) {
Willy Tarreau94f79072018-11-14 11:24:08 +0100286 printf("EXTRA(0x%08x)", f);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100287 }
288 putchar('\n');
289}
290
291void show_task_state(unsigned int f)
292{
293 printf("task->state = ");
294
295 if (!f) {
296 printf("TASK_SLEEPING\n");
297 return;
298 }
299
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100300 SHOW_FLAG(f, TASK_F_USR1);
301 SHOW_FLAG(f, TASK_F_TASKLET);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100302 SHOW_FLAG(f, TASK_WOKEN_OTHER);
303 SHOW_FLAG(f, TASK_WOKEN_RES);
304 SHOW_FLAG(f, TASK_WOKEN_MSG);
305 SHOW_FLAG(f, TASK_WOKEN_SIGNAL);
306 SHOW_FLAG(f, TASK_WOKEN_IO);
307 SHOW_FLAG(f, TASK_WOKEN_TIMER);
308 SHOW_FLAG(f, TASK_WOKEN_INIT);
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100309 SHOW_FLAG(f, TASK_HEAVY);
310 SHOW_FLAG(f, TASK_IN_LIST);
311 SHOW_FLAG(f, TASK_KILLED);
312 SHOW_FLAG(f, TASK_SELF_WAKING);
313 SHOW_FLAG(f, TASK_SHARED_WQ);
314 SHOW_FLAG(f, TASK_QUEUED);
315 SHOW_FLAG(f, TASK_GLOBAL);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100316 SHOW_FLAG(f, TASK_RUNNING);
317
318 if (f) {
319 printf("EXTRA(0x%08x)", f);
320 }
321 putchar('\n');
322}
323
324void show_txn_flags(unsigned int f)
325{
326 printf("txn->flags = ");
327
328 if (!f) {
329 printf("0\n");
330 return;
331 }
332
Christopher Faulete05bf9e2022-03-29 15:23:40 +0200333 SHOW_FLAG(f, TX_L7_RETRY);
334 SHOW_FLAG(f, TX_D_L7_RETRY);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100335 SHOW_FLAG(f, TX_NOT_FIRST);
336 SHOW_FLAG(f, TX_USE_PX_CONN);
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100337 SHOW_FLAG(f, TX_CACHE_HAS_SEC_KEY);
Christopher Fauletc41547b2019-07-16 14:32:23 +0200338 SHOW_FLAG(f, TX_CON_WANT_TUN);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100339
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100340 SHOW_FLAG(f, TX_CACHE_IGNORE);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100341 SHOW_FLAG(f, TX_CACHE_COOK);
342 SHOW_FLAG(f, TX_CACHEABLE);
343 SHOW_FLAG(f, TX_SCK_PRESENT);
344
345 //printf("%s", f ? "" : " | ");
346 switch (f & TX_SCK_MASK) {
347 case TX_SCK_NONE: f &= ~TX_SCK_MASK ; /*printf("TX_SCK_NONE%s", f ? " | " : "");*/ break;
348 case TX_SCK_FOUND: f &= ~TX_SCK_MASK ; printf("TX_SCK_FOUND%s", f ? " | " : ""); break;
349 case TX_SCK_DELETED: f &= ~TX_SCK_MASK ; printf("TX_SCK_DELETED%s", f ? " | " : ""); break;
350 case TX_SCK_INSERTED: f &= ~TX_SCK_MASK ; printf("TX_SCK_INSERTED%s", f ? " | " : ""); break;
351 case TX_SCK_REPLACED: f &= ~TX_SCK_MASK ; printf("TX_SCK_REPLACED%s", f ? " | " : ""); break;
352 case TX_SCK_UPDATED: f &= ~TX_SCK_MASK ; printf("TX_SCK_UPDATED%s", f ? " | " : ""); break;
353 default: printf("TX_SCK_MASK(%02x)", f); f &= ~TX_SCK_MASK ; printf("%s", f ? " | " : ""); break;
354 }
355
356 //printf("%s", f ? "" : " | ");
357 switch (f & TX_CK_MASK) {
358 case TX_CK_NONE: f &= ~TX_CK_MASK ; /*printf("TX_CK_NONE%s", f ? " | " : "");*/ break;
359 case TX_CK_INVALID: f &= ~TX_CK_MASK ; printf("TX_CK_INVALID%s", f ? " | " : ""); break;
360 case TX_CK_DOWN: f &= ~TX_CK_MASK ; printf("TX_CK_DOWN%s", f ? " | " : ""); break;
361 case TX_CK_VALID: f &= ~TX_CK_MASK ; printf("TX_CK_VALID%s", f ? " | " : ""); break;
362 case TX_CK_EXPIRED: f &= ~TX_CK_MASK ; printf("TX_CK_EXPIRED%s", f ? " | " : ""); break;
363 case TX_CK_OLD: f &= ~TX_CK_MASK ; printf("TX_CK_OLD%s", f ? " | " : ""); break;
364 case TX_CK_UNUSED: f &= ~TX_CK_MASK ; printf("TX_CK_UNUSED%s", f ? " | " : ""); break;
365 default: printf("TX_CK_MASK(%02x)", f); f &= ~TX_CK_MASK ; printf("%s", f ? " | " : ""); break;
366 }
367
368 SHOW_FLAG(f, TX_CLTARPIT);
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100369 SHOW_FLAG(f, TX_CONST_REPLY);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100370
371 if (f) {
372 printf("EXTRA(0x%08x)", f);
373 }
374 putchar('\n');
375}
376
377void show_strm_flags(unsigned int f)
378{
379 printf("strm->flags = ");
380
381 if (!f) {
382 printf("0\n");
383 return;
384 }
385
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100386 SHOW_FLAG(f, SF_WEBSOCKET);
387 SHOW_FLAG(f, SF_SRV_REUSED_ANTICIPATED);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100388 SHOW_FLAG(f, SF_SRV_REUSED);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100389 SHOW_FLAG(f, SF_IGNORE_PRST);
390
391 //printf("%s", f ? "" : " | ");
392 switch (f & SF_FINST_MASK) {
393 case SF_FINST_R: f &= ~SF_FINST_MASK ; printf("SF_FINST_R%s", f ? " | " : ""); break;
394 case SF_FINST_C: f &= ~SF_FINST_MASK ; printf("SF_FINST_C%s", f ? " | " : ""); break;
395 case SF_FINST_H: f &= ~SF_FINST_MASK ; printf("SF_FINST_H%s", f ? " | " : ""); break;
396 case SF_FINST_D: f &= ~SF_FINST_MASK ; printf("SF_FINST_D%s", f ? " | " : ""); break;
397 case SF_FINST_L: f &= ~SF_FINST_MASK ; printf("SF_FINST_L%s", f ? " | " : ""); break;
398 case SF_FINST_Q: f &= ~SF_FINST_MASK ; printf("SF_FINST_Q%s", f ? " | " : ""); break;
399 case SF_FINST_T: f &= ~SF_FINST_MASK ; printf("SF_FINST_T%s", f ? " | " : ""); break;
400 }
401
402 switch (f & SF_ERR_MASK) {
403 case SF_ERR_LOCAL: f &= ~SF_ERR_MASK ; printf("SF_ERR_LOCAL%s", f ? " | " : ""); break;
404 case SF_ERR_CLITO: f &= ~SF_ERR_MASK ; printf("SF_ERR_CLITO%s", f ? " | " : ""); break;
405 case SF_ERR_CLICL: f &= ~SF_ERR_MASK ; printf("SF_ERR_CLICL%s", f ? " | " : ""); break;
406 case SF_ERR_SRVTO: f &= ~SF_ERR_MASK ; printf("SF_ERR_SRVTO%s", f ? " | " : ""); break;
407 case SF_ERR_SRVCL: f &= ~SF_ERR_MASK ; printf("SF_ERR_SRVCL%s", f ? " | " : ""); break;
408 case SF_ERR_PRXCOND: f &= ~SF_ERR_MASK ; printf("SF_ERR_PRXCOND%s", f ? " | " : ""); break;
409 case SF_ERR_RESOURCE: f &= ~SF_ERR_MASK ; printf("SF_ERR_RESOURCE%s", f ? " | " : ""); break;
410 case SF_ERR_INTERNAL: f &= ~SF_ERR_MASK ; printf("SF_ERR_INTERNAL%s", f ? " | " : ""); break;
411 case SF_ERR_DOWN: f &= ~SF_ERR_MASK ; printf("SF_ERR_DOWN%s", f ? " | " : ""); break;
412 case SF_ERR_KILLED: f &= ~SF_ERR_MASK ; printf("SF_ERR_KILLED%s", f ? " | " : ""); break;
413 case SF_ERR_UP: f &= ~SF_ERR_MASK ; printf("SF_ERR_UP%s", f ? " | " : ""); break;
Willy Tarreaua7da4d22016-11-11 08:05:34 +0100414 case SF_ERR_CHK_PORT: f &= ~SF_ERR_MASK ; printf("SF_ERR_CHK_PORT%s", f ? " | " : ""); break;
Willy Tarreau074d65b2015-12-20 23:21:57 +0100415 }
416
Willy Tarreau8a0eabd2020-02-06 07:57:36 +0100417 SHOW_FLAG(f, SF_HTX);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100418 SHOW_FLAG(f, SF_REDIRECTABLE);
Willy Tarreau8a0eabd2020-02-06 07:57:36 +0100419 SHOW_FLAG(f, SF_IGNORE);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100420 SHOW_FLAG(f, SF_REDISP);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100421 SHOW_FLAG(f, SF_CURR_SESS);
422 SHOW_FLAG(f, SF_MONITOR);
423 SHOW_FLAG(f, SF_FORCE_PRST);
424 SHOW_FLAG(f, SF_BE_ASSIGNED);
425 SHOW_FLAG(f, SF_ADDR_SET);
426 SHOW_FLAG(f, SF_ASSIGNED);
427 SHOW_FLAG(f, SF_DIRECT);
428
429 if (f) {
430 printf("EXTRA(0x%08x)", f);
431 }
432 putchar('\n');
433}
434
Willy Tarreau354b6f52020-02-06 08:33:08 +0100435void usage_exit(const char *name)
436{
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100437 fprintf(stderr, "Usage: %s [ana|chn|conn|cs|si|sierr|strm|task|txn]* { [+-][0x]value* | - }\n", name);
Willy Tarreau354b6f52020-02-06 08:33:08 +0100438 exit(1);
439}
440
Willy Tarreau074d65b2015-12-20 23:21:57 +0100441int main(int argc, char **argv)
442{
443 unsigned int flags;
Willy Tarreau354b6f52020-02-06 08:33:08 +0100444 unsigned int show_as = 0;
445 unsigned int f;
446 const char *name = argv[0];
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100447 char line[20];
448 char *value;
Willy Tarreaubde76f02020-02-06 08:48:16 +0100449 int multi = 0;
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100450 int use_stdin = 0;
Willy Tarreau354b6f52020-02-06 08:33:08 +0100451 char *err;
452
453 while (argc > 0) {
454 argv++; argc--;
455 if (argc < 1)
456 usage_exit(name);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100457
Willy Tarreau354b6f52020-02-06 08:33:08 +0100458 f = get_show_as(argv[0]);
Willy Tarreaubde76f02020-02-06 08:48:16 +0100459 if (!f)
460 break;
Willy Tarreau354b6f52020-02-06 08:33:08 +0100461 show_as |= f;
Willy Tarreau074d65b2015-12-20 23:21:57 +0100462 }
463
Willy Tarreau354b6f52020-02-06 08:33:08 +0100464 if (!show_as)
465 show_as = ~0U;
Willy Tarreau074d65b2015-12-20 23:21:57 +0100466
Willy Tarreaubde76f02020-02-06 08:48:16 +0100467 if (argc > 1)
468 multi = 1;
Willy Tarreau074d65b2015-12-20 23:21:57 +0100469
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100470 if (strcmp(argv[0], "-") == 0)
471 use_stdin = 1;
472
Willy Tarreaubde76f02020-02-06 08:48:16 +0100473 while (argc > 0) {
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100474 if (use_stdin) {
475 value = fgets(line, sizeof(line), stdin);
476 if (!value)
477 break;
478
Ilya Shipitsin6fb0f212020-04-02 15:25:26 +0500479 /* skip common leading delimiters that slip from copy-paste */
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100480 while (*value == ' ' || *value == '\t' || *value == ':' || *value == '=')
481 value++;
482
483 /* stop at the end of the number and trim any C suffix like "UL" */
484 err = value;
485 while (*err == '-' || *err == '+' ||
Willy Tarreaub00c00e2021-04-02 17:47:21 +0200486 (isalnum((unsigned char)*err) && toupper((unsigned char)*err) != 'U' && toupper((unsigned char)*err) != 'L'))
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100487 err++;
Willy Tarreaucd430b92021-04-03 15:26:56 +0200488 *err = 0;
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100489 } else {
490 value = argv[0];
491 argv++; argc--;
492 }
493
494 flags = strtoul(value, &err, 0);
495 if (!*value || *err) {
496 fprintf(stderr, "Unparsable value: <%s>\n", value);
Willy Tarreaubde76f02020-02-06 08:48:16 +0100497 usage_exit(name);
498 }
499
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100500 if (multi || use_stdin)
Willy Tarreaubde76f02020-02-06 08:48:16 +0100501 printf("### 0x%08x:\n", flags);
502
503 if (show_as & SHOW_AS_ANA) show_chn_ana(flags);
504 if (show_as & SHOW_AS_CHN) show_chn_flags(flags);
505 if (show_as & SHOW_AS_CONN) show_conn_flags(flags);
506 if (show_as & SHOW_AS_CS) show_cs_flags(flags);
Christopher Fauletdb90f2a2022-03-22 16:06:25 +0100507 if (show_as & SHOW_AS_ENDP) show_endp_flags(flags);
Willy Tarreaubde76f02020-02-06 08:48:16 +0100508 if (show_as & SHOW_AS_SI) show_si_flags(flags);
509 if (show_as & SHOW_AS_SIET) show_si_et(flags);
510 if (show_as & SHOW_AS_STRM) show_strm_flags(flags);
511 if (show_as & SHOW_AS_TASK) show_task_state(flags);
512 if (show_as & SHOW_AS_TXN) show_txn_flags(flags);
Willy Tarreaubde76f02020-02-06 08:48:16 +0100513 }
Willy Tarreau074d65b2015-12-20 23:21:57 +0100514 return 0;
515}