blob: 2f7c76b638c8cee0957b9debcd37054f61ed4cf0 [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>
Willy Tarreaucb086c62022-05-27 09:47:12 +02006#include <haproxy/stconn-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 Tarreaucea0e1b2020-06-04 17:25:40 +02009#include <haproxy/task-t.h>
Willy Tarreau074d65b2015-12-20 23:21:57 +010010
Willy Tarreau354b6f52020-02-06 08:33:08 +010011// 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
Willy Tarreau79775fa2022-05-27 09:57:31 +020015#define SHOW_AS_SC 0x00000008
Christopher Faulet09b3c552022-04-04 11:28:27 +020016#define SHOW_AS_SET 0x00000010
17#define SHOW_AS_STRM 0x00000020
18#define SHOW_AS_TASK 0x00000040
19#define SHOW_AS_TXN 0x00000080
Willy Tarreau2bacf4e2022-05-27 16:29:30 +020020#define SHOW_AS_SD 0x00000100
Willy Tarreau354b6f52020-02-06 08:33:08 +010021
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.
Willy Tarreau2bacf4e2022-05-27 16:29:30 +020024const char *show_as_words[] = { "ana", "chn", "conn", "sc", "stet", "strm", "task", "txn", "sd", };
Willy Tarreau354b6f52020-02-06 08:33:08 +010025
Willy Tarreau074d65b2015-12-20 23:21:57 +010026#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 Tarreau354b6f52020-02-06 08:33:08 +010033unsigned 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 Tarreau074d65b2015-12-20 23:21:57 +010046void show_chn_ana(unsigned int f)
47{
48 printf("chn->ana = ");
49
50 if (!f) {
51 printf("0\n");
52 return;
53 }
54
Christopher Fauletf4cfcf92017-11-10 14:10:35 +010055 SHOW_FLAG(f, AN_REQ_FLT_START_FE);
Willy Tarreau074d65b2015-12-20 23:21:57 +010056 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 Fauletf4cfcf92017-11-10 14:10:35 +010061 SHOW_FLAG(f, AN_REQ_FLT_START_BE);
Willy Tarreau074d65b2015-12-20 23:21:57 +010062 SHOW_FLAG(f, AN_REQ_INSPECT_BE);
63 SHOW_FLAG(f, AN_REQ_HTTP_PROCESS_BE);
Christopher Fauletf4cfcf92017-11-10 14:10:35 +010064 SHOW_FLAG(f, AN_REQ_HTTP_TARPIT);
Willy Tarreau074d65b2015-12-20 23:21:57 +010065 SHOW_FLAG(f, AN_REQ_SRV_RULES);
66 SHOW_FLAG(f, AN_REQ_HTTP_INNER);
Willy Tarreau074d65b2015-12-20 23:21:57 +010067 SHOW_FLAG(f, AN_REQ_PRST_RDP_COOKIE);
Christopher Fauletf4cfcf92017-11-10 14:10:35 +010068 SHOW_FLAG(f, AN_REQ_STICKING_RULES);
69 SHOW_FLAG(f, AN_REQ_FLT_HTTP_HDRS);
Willy Tarreau074d65b2015-12-20 23:21:57 +010070 SHOW_FLAG(f, AN_REQ_HTTP_XFER_BODY);
Christopher Fauletc2b7fa82022-01-18 10:46:10 +010071 SHOW_FLAG(f, AN_REQ_WAIT_CLI);
Christopher Fauletf4cfcf92017-11-10 14:10:35 +010072 SHOW_FLAG(f, AN_REQ_FLT_XFER_DATA);
73 SHOW_FLAG(f, AN_REQ_FLT_END);
74
Willy Tarreau260bf5c2018-01-15 18:59:16 +010075 SHOW_FLAG(f, AN_RES_FLT_START_FE);
76 SHOW_FLAG(f, AN_RES_FLT_START_BE);
Willy Tarreau074d65b2015-12-20 23:21:57 +010077 SHOW_FLAG(f, AN_RES_INSPECT);
78 SHOW_FLAG(f, AN_RES_WAIT_HTTP);
Willy Tarreau074d65b2015-12-20 23:21:57 +010079 SHOW_FLAG(f, AN_RES_STORE_RULES);
Christopher Fauletf4cfcf92017-11-10 14:10:35 +010080 SHOW_FLAG(f, AN_RES_HTTP_PROCESS_FE);
81 SHOW_FLAG(f, AN_RES_HTTP_PROCESS_BE);
82 SHOW_FLAG(f, AN_RES_FLT_HTTP_HDRS);
Willy Tarreau074d65b2015-12-20 23:21:57 +010083 SHOW_FLAG(f, AN_RES_HTTP_XFER_BODY);
Christopher Fauletc2b7fa82022-01-18 10:46:10 +010084 SHOW_FLAG(f, AN_RES_WAIT_CLI);
Christopher Fauletf4cfcf92017-11-10 14:10:35 +010085 SHOW_FLAG(f, AN_RES_FLT_XFER_DATA);
86 SHOW_FLAG(f, AN_RES_FLT_END);
Willy Tarreau074d65b2015-12-20 23:21:57 +010087
88 if (f) {
89 printf("EXTRA(0x%08x)", f);
90 }
91 putchar('\n');
92}
93
94void show_chn_flags(unsigned int f)
95{
96 printf("chn->flags = ");
97
98 if (!f) {
99 printf("0\n");
100 return;
101 }
102
103 SHOW_FLAG(f, CF_ISRESP);
Willy Tarreauf882a852019-03-25 18:34:28 +0100104 SHOW_FLAG(f, CF_EOI);
Christopher Fauletf4cfcf92017-11-10 14:10:35 +0100105 SHOW_FLAG(f, CF_FLT_ANALYZE);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100106 SHOW_FLAG(f, CF_WAKE_ONCE);
107 SHOW_FLAG(f, CF_NEVER_WAIT);
108 SHOW_FLAG(f, CF_SEND_DONTWAIT);
109 SHOW_FLAG(f, CF_EXPECT_MORE);
110 SHOW_FLAG(f, CF_DONT_READ);
111 SHOW_FLAG(f, CF_AUTO_CONNECT);
112 SHOW_FLAG(f, CF_READ_DONTWAIT);
113 SHOW_FLAG(f, CF_KERN_SPLICING);
114 SHOW_FLAG(f, CF_READ_ATTACHED);
115 SHOW_FLAG(f, CF_ANA_TIMEOUT);
116 SHOW_FLAG(f, CF_WROTE_DATA);
117 SHOW_FLAG(f, CF_STREAMER_FAST);
118 SHOW_FLAG(f, CF_STREAMER);
119 SHOW_FLAG(f, CF_AUTO_CLOSE);
120 SHOW_FLAG(f, CF_SHUTW_NOW);
121 SHOW_FLAG(f, CF_SHUTW);
122 SHOW_FLAG(f, CF_WAKE_WRITE);
123 SHOW_FLAG(f, CF_WRITE_ERROR);
124 SHOW_FLAG(f, CF_WRITE_TIMEOUT);
125 SHOW_FLAG(f, CF_WRITE_PARTIAL);
126 SHOW_FLAG(f, CF_WRITE_NULL);
127 SHOW_FLAG(f, CF_READ_NOEXP);
128 SHOW_FLAG(f, CF_SHUTR_NOW);
129 SHOW_FLAG(f, CF_SHUTR);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100130 SHOW_FLAG(f, CF_READ_ERROR);
131 SHOW_FLAG(f, CF_READ_TIMEOUT);
132 SHOW_FLAG(f, CF_READ_PARTIAL);
133 SHOW_FLAG(f, CF_READ_NULL);
134
135 if (f) {
136 printf("EXTRA(0x%08x)", f);
137 }
138 putchar('\n');
139}
140
141void show_conn_flags(unsigned int f)
142{
143 printf("conn->flags = ");
144 if (!f) {
145 printf("0\n");
146 return;
147 }
148
149 SHOW_FLAG(f, CO_FL_XPRT_TRACKED);
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100150 SHOW_FLAG(f, CO_FL_SESS_IDLE);
Christopher Fauletf4cfcf92017-11-10 14:10:35 +0100151 SHOW_FLAG(f, CO_FL_RCVD_PROXY);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100152 SHOW_FLAG(f, CO_FL_PRIVATE);
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100153 SHOW_FLAG(f, CO_FL_SSL_WAIT_HS);
Christopher Fauletf4cfcf92017-11-10 14:10:35 +0100154 SHOW_FLAG(f, CO_FL_ACCEPT_CIP);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100155 SHOW_FLAG(f, CO_FL_ACCEPT_PROXY);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100156 SHOW_FLAG(f, CO_FL_SEND_PROXY);
157 SHOW_FLAG(f, CO_FL_WAIT_L6_CONN);
158 SHOW_FLAG(f, CO_FL_WAIT_L4_CONN);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100159 SHOW_FLAG(f, CO_FL_ERROR);
160 SHOW_FLAG(f, CO_FL_SOCK_WR_SH);
161 SHOW_FLAG(f, CO_FL_SOCK_RD_SH);
Willy Tarreaudb207502019-06-03 14:26:54 +0200162 SHOW_FLAG(f, CO_FL_SOCKS4_RECV);
163 SHOW_FLAG(f, CO_FL_SOCKS4_SEND);
Christopher Fauletf4cfcf92017-11-10 14:10:35 +0100164 SHOW_FLAG(f, CO_FL_EARLY_DATA);
165 SHOW_FLAG(f, CO_FL_EARLY_SSL_HS);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100166 SHOW_FLAG(f, CO_FL_WAIT_ROOM);
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100167 SHOW_FLAG(f, CO_FL_WANT_DRAIN);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100168 SHOW_FLAG(f, CO_FL_XPRT_READY);
169 SHOW_FLAG(f, CO_FL_CTRL_READY);
Willy Tarreau54067e92020-06-19 08:47:30 +0200170 SHOW_FLAG(f, CO_FL_IDLE_LIST);
171 SHOW_FLAG(f, CO_FL_SAFE_LIST);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100172
173 if (f) {
174 printf("EXTRA(0x%08x)", f);
175 }
176 putchar('\n');
177}
Christopher Fauletdb90f2a2022-03-22 16:06:25 +0100178
Willy Tarreau2bacf4e2022-05-27 16:29:30 +0200179void show_sd_flags(unsigned int f)
Christopher Fauletdb90f2a2022-03-22 16:06:25 +0100180{
Willy Tarreau2bacf4e2022-05-27 16:29:30 +0200181 printf("sd->flags = ");
Christopher Fauletdb90f2a2022-03-22 16:06:25 +0100182 if (!f) {
183 printf("0\n");
184 return;
185 }
Christopher Fauleta0bdec32022-04-04 07:51:21 +0200186
Willy Tarreaub23edc82022-05-24 16:49:03 +0200187 SHOW_FLAG(f, SE_FL_APPLET_NEED_CONN);
Willy Tarreau8c02f8d2022-05-25 16:01:38 +0200188 SHOW_FLAG(f, SE_FL_HAVE_NO_DATA);
Willy Tarreaue4ebe262022-05-27 16:43:52 +0200189 SHOW_FLAG(f, SE_FL_WONT_CONSUME);
Willy Tarreaub605c422022-05-17 17:04:55 +0200190 SHOW_FLAG(f, SE_FL_WAIT_DATA);
191 SHOW_FLAG(f, SE_FL_KILL_CONN);
192 SHOW_FLAG(f, SE_FL_WAIT_FOR_HS);
193 SHOW_FLAG(f, SE_FL_WANT_ROOM);
Willy Tarreaua577bc22022-05-27 16:35:20 +0200194 SHOW_FLAG(f, SE_FL_RCV_MORE);
195 SHOW_FLAG(f, SE_FL_MAY_SPLICE);
Willy Tarreaub605c422022-05-17 17:04:55 +0200196 SHOW_FLAG(f, SE_FL_ERR_PENDING);
Willy Tarreaua577bc22022-05-27 16:35:20 +0200197 SHOW_FLAG(f, SE_FL_ERROR);
Willy Tarreaub605c422022-05-17 17:04:55 +0200198 SHOW_FLAG(f, SE_FL_EOS);
199 SHOW_FLAG(f, SE_FL_EOI);
Willy Tarreaub605c422022-05-17 17:04:55 +0200200 SHOW_FLAG(f, SE_FL_WEBSOCKET);
201 SHOW_FLAG(f, SE_FL_NOT_FIRST);
202 SHOW_FLAG(f, SE_FL_SHWS);
203 SHOW_FLAG(f, SE_FL_SHWN);
204 SHOW_FLAG(f, SE_FL_SHRR);
205 SHOW_FLAG(f, SE_FL_SHRD);
206 SHOW_FLAG(f, SE_FL_ORPHAN);
207 SHOW_FLAG(f, SE_FL_DETACHED);
208 SHOW_FLAG(f, SE_FL_T_APPLET);
209 SHOW_FLAG(f, SE_FL_T_MUX);
Christopher Fauletdb90f2a2022-03-22 16:06:25 +0100210
211 if (f) {
212 printf("EXTRA(0x%08x)", f);
213 }
214 putchar('\n');
215}
Willy Tarreau79775fa2022-05-27 09:57:31 +0200216void show_sc_flags(unsigned int f)
Christopher Faulet5f8ef132018-03-01 08:55:21 +0100217{
Willy Tarreau79775fa2022-05-27 09:57:31 +0200218 printf("sc->flags = ");
Christopher Faulet5f8ef132018-03-01 08:55:21 +0100219 if (!f) {
220 printf("0\n");
221 return;
222 }
Willy Tarreau15252cd2022-05-25 16:36:21 +0200223 SHOW_FLAG(f, SC_FL_NEED_ROOM);
224 SHOW_FLAG(f, SC_FL_NEED_BUFF);
225 SHOW_FLAG(f, SC_FL_WONT_READ);
Willy Tarreaucb041662022-05-17 19:44:42 +0200226 SHOW_FLAG(f, SC_FL_INDEP_STR);
227 SHOW_FLAG(f, SC_FL_DONT_WAKE);
Willy Tarreaucb041662022-05-17 19:44:42 +0200228 SHOW_FLAG(f, SC_FL_NOHALF);
Willy Tarreaua577bc22022-05-27 16:35:20 +0200229 SHOW_FLAG(f, SC_FL_NOLINGER);
Willy Tarreaucb041662022-05-17 19:44:42 +0200230 SHOW_FLAG(f, SC_FL_ISBACK);
Christopher Faulet5f8ef132018-03-01 08:55:21 +0100231
232 if (f) {
233 printf("EXTRA(0x%08x)", f);
234 }
235 putchar('\n');
236}
Willy Tarreau074d65b2015-12-20 23:21:57 +0100237
Christopher Faulet50264b42022-03-30 19:39:30 +0200238void show_strm_et(unsigned int f)
Willy Tarreau074d65b2015-12-20 23:21:57 +0100239{
Christopher Faulet50264b42022-03-30 19:39:30 +0200240 printf("strm->et = ");
Willy Tarreau074d65b2015-12-20 23:21:57 +0100241 if (!f) {
Christopher Faulet50264b42022-03-30 19:39:30 +0200242 printf("STRM_ET_NONE\n");
Willy Tarreau074d65b2015-12-20 23:21:57 +0100243 return;
244 }
245
Christopher Faulet50264b42022-03-30 19:39:30 +0200246 SHOW_FLAG(f, STRM_ET_QUEUE_TO);
247 SHOW_FLAG(f, STRM_ET_QUEUE_ERR);
248 SHOW_FLAG(f, STRM_ET_QUEUE_ABRT);
249 SHOW_FLAG(f, STRM_ET_CONN_TO);
250 SHOW_FLAG(f, STRM_ET_CONN_ERR);
251 SHOW_FLAG(f, STRM_ET_CONN_ABRT);
252 SHOW_FLAG(f, STRM_ET_CONN_RES);
253 SHOW_FLAG(f, STRM_ET_CONN_OTHER);
254 SHOW_FLAG(f, STRM_ET_DATA_TO);
255 SHOW_FLAG(f, STRM_ET_DATA_ERR);
256 SHOW_FLAG(f, STRM_ET_DATA_ABRT);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100257
258 if (f) {
259 printf("EXTRA(0x%08x)", f);
260 }
261 putchar('\n');
262}
263
Willy Tarreau074d65b2015-12-20 23:21:57 +0100264void show_task_state(unsigned int f)
265{
266 printf("task->state = ");
267
268 if (!f) {
269 printf("TASK_SLEEPING\n");
270 return;
271 }
272
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100273 SHOW_FLAG(f, TASK_F_USR1);
274 SHOW_FLAG(f, TASK_F_TASKLET);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100275 SHOW_FLAG(f, TASK_WOKEN_OTHER);
276 SHOW_FLAG(f, TASK_WOKEN_RES);
277 SHOW_FLAG(f, TASK_WOKEN_MSG);
278 SHOW_FLAG(f, TASK_WOKEN_SIGNAL);
279 SHOW_FLAG(f, TASK_WOKEN_IO);
280 SHOW_FLAG(f, TASK_WOKEN_TIMER);
281 SHOW_FLAG(f, TASK_WOKEN_INIT);
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100282 SHOW_FLAG(f, TASK_HEAVY);
283 SHOW_FLAG(f, TASK_IN_LIST);
284 SHOW_FLAG(f, TASK_KILLED);
285 SHOW_FLAG(f, TASK_SELF_WAKING);
286 SHOW_FLAG(f, TASK_SHARED_WQ);
287 SHOW_FLAG(f, TASK_QUEUED);
288 SHOW_FLAG(f, TASK_GLOBAL);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100289 SHOW_FLAG(f, TASK_RUNNING);
290
291 if (f) {
292 printf("EXTRA(0x%08x)", f);
293 }
294 putchar('\n');
295}
296
297void show_txn_flags(unsigned int f)
298{
299 printf("txn->flags = ");
300
301 if (!f) {
302 printf("0\n");
303 return;
304 }
305
Christopher Faulete05bf9e2022-03-29 15:23:40 +0200306 SHOW_FLAG(f, TX_L7_RETRY);
307 SHOW_FLAG(f, TX_D_L7_RETRY);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100308 SHOW_FLAG(f, TX_NOT_FIRST);
309 SHOW_FLAG(f, TX_USE_PX_CONN);
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100310 SHOW_FLAG(f, TX_CACHE_HAS_SEC_KEY);
Christopher Fauletc41547b2019-07-16 14:32:23 +0200311 SHOW_FLAG(f, TX_CON_WANT_TUN);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100312
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100313 SHOW_FLAG(f, TX_CACHE_IGNORE);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100314 SHOW_FLAG(f, TX_CACHE_COOK);
315 SHOW_FLAG(f, TX_CACHEABLE);
316 SHOW_FLAG(f, TX_SCK_PRESENT);
317
318 //printf("%s", f ? "" : " | ");
319 switch (f & TX_SCK_MASK) {
320 case TX_SCK_NONE: f &= ~TX_SCK_MASK ; /*printf("TX_SCK_NONE%s", f ? " | " : "");*/ break;
321 case TX_SCK_FOUND: f &= ~TX_SCK_MASK ; printf("TX_SCK_FOUND%s", f ? " | " : ""); break;
322 case TX_SCK_DELETED: f &= ~TX_SCK_MASK ; printf("TX_SCK_DELETED%s", f ? " | " : ""); break;
323 case TX_SCK_INSERTED: f &= ~TX_SCK_MASK ; printf("TX_SCK_INSERTED%s", f ? " | " : ""); break;
324 case TX_SCK_REPLACED: f &= ~TX_SCK_MASK ; printf("TX_SCK_REPLACED%s", f ? " | " : ""); break;
325 case TX_SCK_UPDATED: f &= ~TX_SCK_MASK ; printf("TX_SCK_UPDATED%s", f ? " | " : ""); break;
326 default: printf("TX_SCK_MASK(%02x)", f); f &= ~TX_SCK_MASK ; printf("%s", f ? " | " : ""); break;
327 }
328
329 //printf("%s", f ? "" : " | ");
330 switch (f & TX_CK_MASK) {
331 case TX_CK_NONE: f &= ~TX_CK_MASK ; /*printf("TX_CK_NONE%s", f ? " | " : "");*/ break;
332 case TX_CK_INVALID: f &= ~TX_CK_MASK ; printf("TX_CK_INVALID%s", f ? " | " : ""); break;
333 case TX_CK_DOWN: f &= ~TX_CK_MASK ; printf("TX_CK_DOWN%s", f ? " | " : ""); break;
334 case TX_CK_VALID: f &= ~TX_CK_MASK ; printf("TX_CK_VALID%s", f ? " | " : ""); break;
335 case TX_CK_EXPIRED: f &= ~TX_CK_MASK ; printf("TX_CK_EXPIRED%s", f ? " | " : ""); break;
336 case TX_CK_OLD: f &= ~TX_CK_MASK ; printf("TX_CK_OLD%s", f ? " | " : ""); break;
337 case TX_CK_UNUSED: f &= ~TX_CK_MASK ; printf("TX_CK_UNUSED%s", f ? " | " : ""); break;
338 default: printf("TX_CK_MASK(%02x)", f); f &= ~TX_CK_MASK ; printf("%s", f ? " | " : ""); break;
339 }
340
341 SHOW_FLAG(f, TX_CLTARPIT);
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100342 SHOW_FLAG(f, TX_CONST_REPLY);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100343
344 if (f) {
345 printf("EXTRA(0x%08x)", f);
346 }
347 putchar('\n');
348}
349
350void show_strm_flags(unsigned int f)
351{
352 printf("strm->flags = ");
353
354 if (!f) {
355 printf("0\n");
356 return;
357 }
358
Christopher Fauletd1391382022-03-30 16:26:39 +0200359 SHOW_FLAG(f, SF_SRC_ADDR);
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100360 SHOW_FLAG(f, SF_WEBSOCKET);
361 SHOW_FLAG(f, SF_SRV_REUSED_ANTICIPATED);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100362 SHOW_FLAG(f, SF_SRV_REUSED);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100363 SHOW_FLAG(f, SF_IGNORE_PRST);
364
365 //printf("%s", f ? "" : " | ");
366 switch (f & SF_FINST_MASK) {
367 case SF_FINST_R: f &= ~SF_FINST_MASK ; printf("SF_FINST_R%s", f ? " | " : ""); break;
368 case SF_FINST_C: f &= ~SF_FINST_MASK ; printf("SF_FINST_C%s", f ? " | " : ""); break;
369 case SF_FINST_H: f &= ~SF_FINST_MASK ; printf("SF_FINST_H%s", f ? " | " : ""); break;
370 case SF_FINST_D: f &= ~SF_FINST_MASK ; printf("SF_FINST_D%s", f ? " | " : ""); break;
371 case SF_FINST_L: f &= ~SF_FINST_MASK ; printf("SF_FINST_L%s", f ? " | " : ""); break;
372 case SF_FINST_Q: f &= ~SF_FINST_MASK ; printf("SF_FINST_Q%s", f ? " | " : ""); break;
373 case SF_FINST_T: f &= ~SF_FINST_MASK ; printf("SF_FINST_T%s", f ? " | " : ""); break;
374 }
375
376 switch (f & SF_ERR_MASK) {
377 case SF_ERR_LOCAL: f &= ~SF_ERR_MASK ; printf("SF_ERR_LOCAL%s", f ? " | " : ""); break;
378 case SF_ERR_CLITO: f &= ~SF_ERR_MASK ; printf("SF_ERR_CLITO%s", f ? " | " : ""); break;
379 case SF_ERR_CLICL: f &= ~SF_ERR_MASK ; printf("SF_ERR_CLICL%s", f ? " | " : ""); break;
380 case SF_ERR_SRVTO: f &= ~SF_ERR_MASK ; printf("SF_ERR_SRVTO%s", f ? " | " : ""); break;
381 case SF_ERR_SRVCL: f &= ~SF_ERR_MASK ; printf("SF_ERR_SRVCL%s", f ? " | " : ""); break;
382 case SF_ERR_PRXCOND: f &= ~SF_ERR_MASK ; printf("SF_ERR_PRXCOND%s", f ? " | " : ""); break;
383 case SF_ERR_RESOURCE: f &= ~SF_ERR_MASK ; printf("SF_ERR_RESOURCE%s", f ? " | " : ""); break;
384 case SF_ERR_INTERNAL: f &= ~SF_ERR_MASK ; printf("SF_ERR_INTERNAL%s", f ? " | " : ""); break;
385 case SF_ERR_DOWN: f &= ~SF_ERR_MASK ; printf("SF_ERR_DOWN%s", f ? " | " : ""); break;
386 case SF_ERR_KILLED: f &= ~SF_ERR_MASK ; printf("SF_ERR_KILLED%s", f ? " | " : ""); break;
387 case SF_ERR_UP: f &= ~SF_ERR_MASK ; printf("SF_ERR_UP%s", f ? " | " : ""); break;
Willy Tarreaua7da4d22016-11-11 08:05:34 +0100388 case SF_ERR_CHK_PORT: f &= ~SF_ERR_MASK ; printf("SF_ERR_CHK_PORT%s", f ? " | " : ""); break;
Willy Tarreau074d65b2015-12-20 23:21:57 +0100389 }
390
Willy Tarreau8a0eabd2020-02-06 07:57:36 +0100391 SHOW_FLAG(f, SF_HTX);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100392 SHOW_FLAG(f, SF_REDIRECTABLE);
Willy Tarreau8a0eabd2020-02-06 07:57:36 +0100393 SHOW_FLAG(f, SF_IGNORE);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100394 SHOW_FLAG(f, SF_REDISP);
Christopher Fauletae024ce2022-03-29 19:02:31 +0200395 SHOW_FLAG(f, SF_CONN_EXP);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100396 SHOW_FLAG(f, SF_CURR_SESS);
397 SHOW_FLAG(f, SF_MONITOR);
398 SHOW_FLAG(f, SF_FORCE_PRST);
399 SHOW_FLAG(f, SF_BE_ASSIGNED);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100400 SHOW_FLAG(f, SF_ASSIGNED);
401 SHOW_FLAG(f, SF_DIRECT);
402
403 if (f) {
404 printf("EXTRA(0x%08x)", f);
405 }
406 putchar('\n');
407}
408
Willy Tarreau354b6f52020-02-06 08:33:08 +0100409void usage_exit(const char *name)
410{
Willy Tarreau79775fa2022-05-27 09:57:31 +0200411 fprintf(stderr, "Usage: %s [ana|chn|conn|sc|si|sierr|strm|task|txn]* { [+-][0x]value* | - }\n", name);
Willy Tarreau354b6f52020-02-06 08:33:08 +0100412 exit(1);
413}
414
Willy Tarreau074d65b2015-12-20 23:21:57 +0100415int main(int argc, char **argv)
416{
417 unsigned int flags;
Willy Tarreau354b6f52020-02-06 08:33:08 +0100418 unsigned int show_as = 0;
419 unsigned int f;
420 const char *name = argv[0];
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100421 char line[20];
422 char *value;
Willy Tarreaubde76f02020-02-06 08:48:16 +0100423 int multi = 0;
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100424 int use_stdin = 0;
Willy Tarreau354b6f52020-02-06 08:33:08 +0100425 char *err;
426
427 while (argc > 0) {
428 argv++; argc--;
429 if (argc < 1)
430 usage_exit(name);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100431
Willy Tarreau354b6f52020-02-06 08:33:08 +0100432 f = get_show_as(argv[0]);
Willy Tarreaubde76f02020-02-06 08:48:16 +0100433 if (!f)
434 break;
Willy Tarreau354b6f52020-02-06 08:33:08 +0100435 show_as |= f;
Willy Tarreau074d65b2015-12-20 23:21:57 +0100436 }
437
Willy Tarreau354b6f52020-02-06 08:33:08 +0100438 if (!show_as)
439 show_as = ~0U;
Willy Tarreau074d65b2015-12-20 23:21:57 +0100440
Willy Tarreaubde76f02020-02-06 08:48:16 +0100441 if (argc > 1)
442 multi = 1;
Willy Tarreau074d65b2015-12-20 23:21:57 +0100443
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100444 if (strcmp(argv[0], "-") == 0)
445 use_stdin = 1;
446
Willy Tarreaubde76f02020-02-06 08:48:16 +0100447 while (argc > 0) {
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100448 if (use_stdin) {
449 value = fgets(line, sizeof(line), stdin);
450 if (!value)
451 break;
452
Ilya Shipitsin6fb0f212020-04-02 15:25:26 +0500453 /* skip common leading delimiters that slip from copy-paste */
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100454 while (*value == ' ' || *value == '\t' || *value == ':' || *value == '=')
455 value++;
456
457 /* stop at the end of the number and trim any C suffix like "UL" */
458 err = value;
459 while (*err == '-' || *err == '+' ||
Willy Tarreaub00c00e2021-04-02 17:47:21 +0200460 (isalnum((unsigned char)*err) && toupper((unsigned char)*err) != 'U' && toupper((unsigned char)*err) != 'L'))
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100461 err++;
Willy Tarreaucd430b92021-04-03 15:26:56 +0200462 *err = 0;
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100463 } else {
464 value = argv[0];
465 argv++; argc--;
466 }
467
468 flags = strtoul(value, &err, 0);
469 if (!*value || *err) {
470 fprintf(stderr, "Unparsable value: <%s>\n", value);
Willy Tarreaubde76f02020-02-06 08:48:16 +0100471 usage_exit(name);
472 }
473
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100474 if (multi || use_stdin)
Willy Tarreaubde76f02020-02-06 08:48:16 +0100475 printf("### 0x%08x:\n", flags);
476
477 if (show_as & SHOW_AS_ANA) show_chn_ana(flags);
478 if (show_as & SHOW_AS_CHN) show_chn_flags(flags);
479 if (show_as & SHOW_AS_CONN) show_conn_flags(flags);
Willy Tarreau79775fa2022-05-27 09:57:31 +0200480 if (show_as & SHOW_AS_SC) show_sc_flags(flags);
Willy Tarreau2bacf4e2022-05-27 16:29:30 +0200481 if (show_as & SHOW_AS_SD) show_sd_flags(flags);
Christopher Faulet50264b42022-03-30 19:39:30 +0200482 if (show_as & SHOW_AS_SET) show_strm_et(flags);
Willy Tarreaubde76f02020-02-06 08:48:16 +0100483 if (show_as & SHOW_AS_STRM) show_strm_flags(flags);
484 if (show_as & SHOW_AS_TASK) show_task_state(flags);
485 if (show_as & SHOW_AS_TXN) show_txn_flags(flags);
Willy Tarreaubde76f02020-02-06 08:48:16 +0100486 }
Willy Tarreau074d65b2015-12-20 23:21:57 +0100487 return 0;
488}