blob: 318f3946ec0cbda92a168956b62622f1b4f195ba [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 Fauleta7285182022-03-30 15:43:23 +0200222 SHOW_FLAG(f, CS_FL_INDEP_STR);
Christopher Faulet974da9f2022-03-30 15:30:03 +0200223 SHOW_FLAG(f, CS_FL_DONT_WAKE);
Christopher Faulet8abe7122022-03-30 15:10:18 +0200224 SHOW_FLAG(f, CS_FL_NOLINGER);
225 SHOW_FLAG(f, CS_FL_NOHALF);
Christopher Faulet8da67aa2022-03-29 17:53:09 +0200226 SHOW_FLAG(f, CS_FL_ADDR_FROM_SET);
227 SHOW_FLAG(f, CS_FL_ADDR_TO_SET);
Christopher Faulet30995112022-03-25 15:32:38 +0100228 SHOW_FLAG(f, CS_FL_ISBACK);
Christopher Faulet5f8ef132018-03-01 08:55:21 +0100229
230 if (f) {
231 printf("EXTRA(0x%08x)", f);
232 }
233 putchar('\n');
234}
Willy Tarreau074d65b2015-12-20 23:21:57 +0100235
236void show_si_et(unsigned int f)
237{
238 printf("si->et = ");
239 if (!f) {
240 printf("SI_ET_NONE\n");
241 return;
242 }
243
244 SHOW_FLAG(f, SI_ET_QUEUE_TO);
245 SHOW_FLAG(f, SI_ET_QUEUE_ERR);
246 SHOW_FLAG(f, SI_ET_QUEUE_ABRT);
247 SHOW_FLAG(f, SI_ET_CONN_TO);
248 SHOW_FLAG(f, SI_ET_CONN_ERR);
249 SHOW_FLAG(f, SI_ET_CONN_ABRT);
250 SHOW_FLAG(f, SI_ET_CONN_RES);
251 SHOW_FLAG(f, SI_ET_CONN_OTHER);
252 SHOW_FLAG(f, SI_ET_DATA_TO);
253 SHOW_FLAG(f, SI_ET_DATA_ERR);
254 SHOW_FLAG(f, SI_ET_DATA_ABRT);
255
256 if (f) {
257 printf("EXTRA(0x%08x)", f);
258 }
259 putchar('\n');
260}
261
262void show_si_flags(unsigned int f)
263{
Willy Tarreau074d65b2015-12-20 23:21:57 +0100264 printf("si->flags = ");
265 if (!f) {
266 printf("SI_FL_NONE\n");
267 return;
268 }
269
Willy Tarreau074d65b2015-12-20 23:21:57 +0100270 SHOW_FLAG(f, SI_FL_WAIT_DATA);
271 SHOW_FLAG(f, SI_FL_ISBACK);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100272 SHOW_FLAG(f, SI_FL_SRC_ADDR);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100273 SHOW_FLAG(f, SI_FL_WANT_GET);
Willy Tarreauf2ddd872018-12-18 09:54:22 +0100274 SHOW_FLAG(f, SI_FL_CLEAN_ABRT);
Willy Tarreau94f79072018-11-14 11:24:08 +0100275 SHOW_FLAG(f, SI_FL_RXBLK_CHAN);
276 SHOW_FLAG(f, SI_FL_RXBLK_BUFF);
277 SHOW_FLAG(f, SI_FL_RXBLK_ROOM);
278 SHOW_FLAG(f, SI_FL_RXBLK_SHUT);
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100279 SHOW_FLAG(f, SI_FL_RXBLK_CONN);
Willy Tarreau94f79072018-11-14 11:24:08 +0100280 SHOW_FLAG(f, SI_FL_RX_WAIT_EP);
281
Willy Tarreau074d65b2015-12-20 23:21:57 +0100282 if (f) {
Willy Tarreau94f79072018-11-14 11:24:08 +0100283 printf("EXTRA(0x%08x)", f);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100284 }
285 putchar('\n');
286}
287
288void show_task_state(unsigned int f)
289{
290 printf("task->state = ");
291
292 if (!f) {
293 printf("TASK_SLEEPING\n");
294 return;
295 }
296
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100297 SHOW_FLAG(f, TASK_F_USR1);
298 SHOW_FLAG(f, TASK_F_TASKLET);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100299 SHOW_FLAG(f, TASK_WOKEN_OTHER);
300 SHOW_FLAG(f, TASK_WOKEN_RES);
301 SHOW_FLAG(f, TASK_WOKEN_MSG);
302 SHOW_FLAG(f, TASK_WOKEN_SIGNAL);
303 SHOW_FLAG(f, TASK_WOKEN_IO);
304 SHOW_FLAG(f, TASK_WOKEN_TIMER);
305 SHOW_FLAG(f, TASK_WOKEN_INIT);
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100306 SHOW_FLAG(f, TASK_HEAVY);
307 SHOW_FLAG(f, TASK_IN_LIST);
308 SHOW_FLAG(f, TASK_KILLED);
309 SHOW_FLAG(f, TASK_SELF_WAKING);
310 SHOW_FLAG(f, TASK_SHARED_WQ);
311 SHOW_FLAG(f, TASK_QUEUED);
312 SHOW_FLAG(f, TASK_GLOBAL);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100313 SHOW_FLAG(f, TASK_RUNNING);
314
315 if (f) {
316 printf("EXTRA(0x%08x)", f);
317 }
318 putchar('\n');
319}
320
321void show_txn_flags(unsigned int f)
322{
323 printf("txn->flags = ");
324
325 if (!f) {
326 printf("0\n");
327 return;
328 }
329
Christopher Faulete05bf9e2022-03-29 15:23:40 +0200330 SHOW_FLAG(f, TX_L7_RETRY);
331 SHOW_FLAG(f, TX_D_L7_RETRY);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100332 SHOW_FLAG(f, TX_NOT_FIRST);
333 SHOW_FLAG(f, TX_USE_PX_CONN);
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100334 SHOW_FLAG(f, TX_CACHE_HAS_SEC_KEY);
Christopher Fauletc41547b2019-07-16 14:32:23 +0200335 SHOW_FLAG(f, TX_CON_WANT_TUN);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100336
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100337 SHOW_FLAG(f, TX_CACHE_IGNORE);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100338 SHOW_FLAG(f, TX_CACHE_COOK);
339 SHOW_FLAG(f, TX_CACHEABLE);
340 SHOW_FLAG(f, TX_SCK_PRESENT);
341
342 //printf("%s", f ? "" : " | ");
343 switch (f & TX_SCK_MASK) {
344 case TX_SCK_NONE: f &= ~TX_SCK_MASK ; /*printf("TX_SCK_NONE%s", f ? " | " : "");*/ break;
345 case TX_SCK_FOUND: f &= ~TX_SCK_MASK ; printf("TX_SCK_FOUND%s", f ? " | " : ""); break;
346 case TX_SCK_DELETED: f &= ~TX_SCK_MASK ; printf("TX_SCK_DELETED%s", f ? " | " : ""); break;
347 case TX_SCK_INSERTED: f &= ~TX_SCK_MASK ; printf("TX_SCK_INSERTED%s", f ? " | " : ""); break;
348 case TX_SCK_REPLACED: f &= ~TX_SCK_MASK ; printf("TX_SCK_REPLACED%s", f ? " | " : ""); break;
349 case TX_SCK_UPDATED: f &= ~TX_SCK_MASK ; printf("TX_SCK_UPDATED%s", f ? " | " : ""); break;
350 default: printf("TX_SCK_MASK(%02x)", f); f &= ~TX_SCK_MASK ; printf("%s", f ? " | " : ""); break;
351 }
352
353 //printf("%s", f ? "" : " | ");
354 switch (f & TX_CK_MASK) {
355 case TX_CK_NONE: f &= ~TX_CK_MASK ; /*printf("TX_CK_NONE%s", f ? " | " : "");*/ break;
356 case TX_CK_INVALID: f &= ~TX_CK_MASK ; printf("TX_CK_INVALID%s", f ? " | " : ""); break;
357 case TX_CK_DOWN: f &= ~TX_CK_MASK ; printf("TX_CK_DOWN%s", f ? " | " : ""); break;
358 case TX_CK_VALID: f &= ~TX_CK_MASK ; printf("TX_CK_VALID%s", f ? " | " : ""); break;
359 case TX_CK_EXPIRED: f &= ~TX_CK_MASK ; printf("TX_CK_EXPIRED%s", f ? " | " : ""); break;
360 case TX_CK_OLD: f &= ~TX_CK_MASK ; printf("TX_CK_OLD%s", f ? " | " : ""); break;
361 case TX_CK_UNUSED: f &= ~TX_CK_MASK ; printf("TX_CK_UNUSED%s", f ? " | " : ""); break;
362 default: printf("TX_CK_MASK(%02x)", f); f &= ~TX_CK_MASK ; printf("%s", f ? " | " : ""); break;
363 }
364
365 SHOW_FLAG(f, TX_CLTARPIT);
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100366 SHOW_FLAG(f, TX_CONST_REPLY);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100367
368 if (f) {
369 printf("EXTRA(0x%08x)", f);
370 }
371 putchar('\n');
372}
373
374void show_strm_flags(unsigned int f)
375{
376 printf("strm->flags = ");
377
378 if (!f) {
379 printf("0\n");
380 return;
381 }
382
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100383 SHOW_FLAG(f, SF_WEBSOCKET);
384 SHOW_FLAG(f, SF_SRV_REUSED_ANTICIPATED);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100385 SHOW_FLAG(f, SF_SRV_REUSED);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100386 SHOW_FLAG(f, SF_IGNORE_PRST);
387
388 //printf("%s", f ? "" : " | ");
389 switch (f & SF_FINST_MASK) {
390 case SF_FINST_R: f &= ~SF_FINST_MASK ; printf("SF_FINST_R%s", f ? " | " : ""); break;
391 case SF_FINST_C: f &= ~SF_FINST_MASK ; printf("SF_FINST_C%s", f ? " | " : ""); break;
392 case SF_FINST_H: f &= ~SF_FINST_MASK ; printf("SF_FINST_H%s", f ? " | " : ""); break;
393 case SF_FINST_D: f &= ~SF_FINST_MASK ; printf("SF_FINST_D%s", f ? " | " : ""); break;
394 case SF_FINST_L: f &= ~SF_FINST_MASK ; printf("SF_FINST_L%s", f ? " | " : ""); break;
395 case SF_FINST_Q: f &= ~SF_FINST_MASK ; printf("SF_FINST_Q%s", f ? " | " : ""); break;
396 case SF_FINST_T: f &= ~SF_FINST_MASK ; printf("SF_FINST_T%s", f ? " | " : ""); break;
397 }
398
399 switch (f & SF_ERR_MASK) {
400 case SF_ERR_LOCAL: f &= ~SF_ERR_MASK ; printf("SF_ERR_LOCAL%s", f ? " | " : ""); break;
401 case SF_ERR_CLITO: f &= ~SF_ERR_MASK ; printf("SF_ERR_CLITO%s", f ? " | " : ""); break;
402 case SF_ERR_CLICL: f &= ~SF_ERR_MASK ; printf("SF_ERR_CLICL%s", f ? " | " : ""); break;
403 case SF_ERR_SRVTO: f &= ~SF_ERR_MASK ; printf("SF_ERR_SRVTO%s", f ? " | " : ""); break;
404 case SF_ERR_SRVCL: f &= ~SF_ERR_MASK ; printf("SF_ERR_SRVCL%s", f ? " | " : ""); break;
405 case SF_ERR_PRXCOND: f &= ~SF_ERR_MASK ; printf("SF_ERR_PRXCOND%s", f ? " | " : ""); break;
406 case SF_ERR_RESOURCE: f &= ~SF_ERR_MASK ; printf("SF_ERR_RESOURCE%s", f ? " | " : ""); break;
407 case SF_ERR_INTERNAL: f &= ~SF_ERR_MASK ; printf("SF_ERR_INTERNAL%s", f ? " | " : ""); break;
408 case SF_ERR_DOWN: f &= ~SF_ERR_MASK ; printf("SF_ERR_DOWN%s", f ? " | " : ""); break;
409 case SF_ERR_KILLED: f &= ~SF_ERR_MASK ; printf("SF_ERR_KILLED%s", f ? " | " : ""); break;
410 case SF_ERR_UP: f &= ~SF_ERR_MASK ; printf("SF_ERR_UP%s", f ? " | " : ""); break;
Willy Tarreaua7da4d22016-11-11 08:05:34 +0100411 case SF_ERR_CHK_PORT: f &= ~SF_ERR_MASK ; printf("SF_ERR_CHK_PORT%s", f ? " | " : ""); break;
Willy Tarreau074d65b2015-12-20 23:21:57 +0100412 }
413
Willy Tarreau8a0eabd2020-02-06 07:57:36 +0100414 SHOW_FLAG(f, SF_HTX);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100415 SHOW_FLAG(f, SF_REDIRECTABLE);
Willy Tarreau8a0eabd2020-02-06 07:57:36 +0100416 SHOW_FLAG(f, SF_IGNORE);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100417 SHOW_FLAG(f, SF_REDISP);
Christopher Fauletae024ce2022-03-29 19:02:31 +0200418 SHOW_FLAG(f, SF_CONN_EXP);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100419 SHOW_FLAG(f, SF_CURR_SESS);
420 SHOW_FLAG(f, SF_MONITOR);
421 SHOW_FLAG(f, SF_FORCE_PRST);
422 SHOW_FLAG(f, SF_BE_ASSIGNED);
423 SHOW_FLAG(f, SF_ADDR_SET);
424 SHOW_FLAG(f, SF_ASSIGNED);
425 SHOW_FLAG(f, SF_DIRECT);
426
427 if (f) {
428 printf("EXTRA(0x%08x)", f);
429 }
430 putchar('\n');
431}
432
Willy Tarreau354b6f52020-02-06 08:33:08 +0100433void usage_exit(const char *name)
434{
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100435 fprintf(stderr, "Usage: %s [ana|chn|conn|cs|si|sierr|strm|task|txn]* { [+-][0x]value* | - }\n", name);
Willy Tarreau354b6f52020-02-06 08:33:08 +0100436 exit(1);
437}
438
Willy Tarreau074d65b2015-12-20 23:21:57 +0100439int main(int argc, char **argv)
440{
441 unsigned int flags;
Willy Tarreau354b6f52020-02-06 08:33:08 +0100442 unsigned int show_as = 0;
443 unsigned int f;
444 const char *name = argv[0];
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100445 char line[20];
446 char *value;
Willy Tarreaubde76f02020-02-06 08:48:16 +0100447 int multi = 0;
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100448 int use_stdin = 0;
Willy Tarreau354b6f52020-02-06 08:33:08 +0100449 char *err;
450
451 while (argc > 0) {
452 argv++; argc--;
453 if (argc < 1)
454 usage_exit(name);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100455
Willy Tarreau354b6f52020-02-06 08:33:08 +0100456 f = get_show_as(argv[0]);
Willy Tarreaubde76f02020-02-06 08:48:16 +0100457 if (!f)
458 break;
Willy Tarreau354b6f52020-02-06 08:33:08 +0100459 show_as |= f;
Willy Tarreau074d65b2015-12-20 23:21:57 +0100460 }
461
Willy Tarreau354b6f52020-02-06 08:33:08 +0100462 if (!show_as)
463 show_as = ~0U;
Willy Tarreau074d65b2015-12-20 23:21:57 +0100464
Willy Tarreaubde76f02020-02-06 08:48:16 +0100465 if (argc > 1)
466 multi = 1;
Willy Tarreau074d65b2015-12-20 23:21:57 +0100467
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100468 if (strcmp(argv[0], "-") == 0)
469 use_stdin = 1;
470
Willy Tarreaubde76f02020-02-06 08:48:16 +0100471 while (argc > 0) {
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100472 if (use_stdin) {
473 value = fgets(line, sizeof(line), stdin);
474 if (!value)
475 break;
476
Ilya Shipitsin6fb0f212020-04-02 15:25:26 +0500477 /* skip common leading delimiters that slip from copy-paste */
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100478 while (*value == ' ' || *value == '\t' || *value == ':' || *value == '=')
479 value++;
480
481 /* stop at the end of the number and trim any C suffix like "UL" */
482 err = value;
483 while (*err == '-' || *err == '+' ||
Willy Tarreaub00c00e2021-04-02 17:47:21 +0200484 (isalnum((unsigned char)*err) && toupper((unsigned char)*err) != 'U' && toupper((unsigned char)*err) != 'L'))
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100485 err++;
Willy Tarreaucd430b92021-04-03 15:26:56 +0200486 *err = 0;
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100487 } else {
488 value = argv[0];
489 argv++; argc--;
490 }
491
492 flags = strtoul(value, &err, 0);
493 if (!*value || *err) {
494 fprintf(stderr, "Unparsable value: <%s>\n", value);
Willy Tarreaubde76f02020-02-06 08:48:16 +0100495 usage_exit(name);
496 }
497
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100498 if (multi || use_stdin)
Willy Tarreaubde76f02020-02-06 08:48:16 +0100499 printf("### 0x%08x:\n", flags);
500
501 if (show_as & SHOW_AS_ANA) show_chn_ana(flags);
502 if (show_as & SHOW_AS_CHN) show_chn_flags(flags);
503 if (show_as & SHOW_AS_CONN) show_conn_flags(flags);
504 if (show_as & SHOW_AS_CS) show_cs_flags(flags);
Christopher Fauletdb90f2a2022-03-22 16:06:25 +0100505 if (show_as & SHOW_AS_ENDP) show_endp_flags(flags);
Willy Tarreaubde76f02020-02-06 08:48:16 +0100506 if (show_as & SHOW_AS_SI) show_si_flags(flags);
507 if (show_as & SHOW_AS_SIET) show_si_et(flags);
508 if (show_as & SHOW_AS_STRM) show_strm_flags(flags);
509 if (show_as & SHOW_AS_TASK) show_task_state(flags);
510 if (show_as & SHOW_AS_TXN) show_txn_flags(flags);
Willy Tarreaubde76f02020-02-06 08:48:16 +0100511 }
Willy Tarreau074d65b2015-12-20 23:21:57 +0100512 return 0;
513}