blob: 0138f4f08ba929d1640a1f62b737a35ac08b43ab [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_WANT_GET);
Willy Tarreau94f79072018-11-14 11:24:08 +0100273 SHOW_FLAG(f, SI_FL_RXBLK_CHAN);
274 SHOW_FLAG(f, SI_FL_RXBLK_BUFF);
275 SHOW_FLAG(f, SI_FL_RXBLK_ROOM);
276 SHOW_FLAG(f, SI_FL_RXBLK_SHUT);
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100277 SHOW_FLAG(f, SI_FL_RXBLK_CONN);
Willy Tarreau94f79072018-11-14 11:24:08 +0100278 SHOW_FLAG(f, SI_FL_RX_WAIT_EP);
279
Willy Tarreau074d65b2015-12-20 23:21:57 +0100280 if (f) {
Willy Tarreau94f79072018-11-14 11:24:08 +0100281 printf("EXTRA(0x%08x)", f);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100282 }
283 putchar('\n');
284}
285
286void show_task_state(unsigned int f)
287{
288 printf("task->state = ");
289
290 if (!f) {
291 printf("TASK_SLEEPING\n");
292 return;
293 }
294
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100295 SHOW_FLAG(f, TASK_F_USR1);
296 SHOW_FLAG(f, TASK_F_TASKLET);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100297 SHOW_FLAG(f, TASK_WOKEN_OTHER);
298 SHOW_FLAG(f, TASK_WOKEN_RES);
299 SHOW_FLAG(f, TASK_WOKEN_MSG);
300 SHOW_FLAG(f, TASK_WOKEN_SIGNAL);
301 SHOW_FLAG(f, TASK_WOKEN_IO);
302 SHOW_FLAG(f, TASK_WOKEN_TIMER);
303 SHOW_FLAG(f, TASK_WOKEN_INIT);
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100304 SHOW_FLAG(f, TASK_HEAVY);
305 SHOW_FLAG(f, TASK_IN_LIST);
306 SHOW_FLAG(f, TASK_KILLED);
307 SHOW_FLAG(f, TASK_SELF_WAKING);
308 SHOW_FLAG(f, TASK_SHARED_WQ);
309 SHOW_FLAG(f, TASK_QUEUED);
310 SHOW_FLAG(f, TASK_GLOBAL);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100311 SHOW_FLAG(f, TASK_RUNNING);
312
313 if (f) {
314 printf("EXTRA(0x%08x)", f);
315 }
316 putchar('\n');
317}
318
319void show_txn_flags(unsigned int f)
320{
321 printf("txn->flags = ");
322
323 if (!f) {
324 printf("0\n");
325 return;
326 }
327
Christopher Faulete05bf9e2022-03-29 15:23:40 +0200328 SHOW_FLAG(f, TX_L7_RETRY);
329 SHOW_FLAG(f, TX_D_L7_RETRY);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100330 SHOW_FLAG(f, TX_NOT_FIRST);
331 SHOW_FLAG(f, TX_USE_PX_CONN);
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100332 SHOW_FLAG(f, TX_CACHE_HAS_SEC_KEY);
Christopher Fauletc41547b2019-07-16 14:32:23 +0200333 SHOW_FLAG(f, TX_CON_WANT_TUN);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100334
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100335 SHOW_FLAG(f, TX_CACHE_IGNORE);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100336 SHOW_FLAG(f, TX_CACHE_COOK);
337 SHOW_FLAG(f, TX_CACHEABLE);
338 SHOW_FLAG(f, TX_SCK_PRESENT);
339
340 //printf("%s", f ? "" : " | ");
341 switch (f & TX_SCK_MASK) {
342 case TX_SCK_NONE: f &= ~TX_SCK_MASK ; /*printf("TX_SCK_NONE%s", f ? " | " : "");*/ break;
343 case TX_SCK_FOUND: f &= ~TX_SCK_MASK ; printf("TX_SCK_FOUND%s", f ? " | " : ""); break;
344 case TX_SCK_DELETED: f &= ~TX_SCK_MASK ; printf("TX_SCK_DELETED%s", f ? " | " : ""); break;
345 case TX_SCK_INSERTED: f &= ~TX_SCK_MASK ; printf("TX_SCK_INSERTED%s", f ? " | " : ""); break;
346 case TX_SCK_REPLACED: f &= ~TX_SCK_MASK ; printf("TX_SCK_REPLACED%s", f ? " | " : ""); break;
347 case TX_SCK_UPDATED: f &= ~TX_SCK_MASK ; printf("TX_SCK_UPDATED%s", f ? " | " : ""); break;
348 default: printf("TX_SCK_MASK(%02x)", f); f &= ~TX_SCK_MASK ; printf("%s", f ? " | " : ""); break;
349 }
350
351 //printf("%s", f ? "" : " | ");
352 switch (f & TX_CK_MASK) {
353 case TX_CK_NONE: f &= ~TX_CK_MASK ; /*printf("TX_CK_NONE%s", f ? " | " : "");*/ break;
354 case TX_CK_INVALID: f &= ~TX_CK_MASK ; printf("TX_CK_INVALID%s", f ? " | " : ""); break;
355 case TX_CK_DOWN: f &= ~TX_CK_MASK ; printf("TX_CK_DOWN%s", f ? " | " : ""); break;
356 case TX_CK_VALID: f &= ~TX_CK_MASK ; printf("TX_CK_VALID%s", f ? " | " : ""); break;
357 case TX_CK_EXPIRED: f &= ~TX_CK_MASK ; printf("TX_CK_EXPIRED%s", f ? " | " : ""); break;
358 case TX_CK_OLD: f &= ~TX_CK_MASK ; printf("TX_CK_OLD%s", f ? " | " : ""); break;
359 case TX_CK_UNUSED: f &= ~TX_CK_MASK ; printf("TX_CK_UNUSED%s", f ? " | " : ""); break;
360 default: printf("TX_CK_MASK(%02x)", f); f &= ~TX_CK_MASK ; printf("%s", f ? " | " : ""); break;
361 }
362
363 SHOW_FLAG(f, TX_CLTARPIT);
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100364 SHOW_FLAG(f, TX_CONST_REPLY);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100365
366 if (f) {
367 printf("EXTRA(0x%08x)", f);
368 }
369 putchar('\n');
370}
371
372void show_strm_flags(unsigned int f)
373{
374 printf("strm->flags = ");
375
376 if (!f) {
377 printf("0\n");
378 return;
379 }
380
Christopher Fauletd1391382022-03-30 16:26:39 +0200381 SHOW_FLAG(f, SF_SRC_ADDR);
Christopher Fauletc2b7fa82022-01-18 10:46:10 +0100382 SHOW_FLAG(f, SF_WEBSOCKET);
383 SHOW_FLAG(f, SF_SRV_REUSED_ANTICIPATED);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100384 SHOW_FLAG(f, SF_SRV_REUSED);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100385 SHOW_FLAG(f, SF_IGNORE_PRST);
386
387 //printf("%s", f ? "" : " | ");
388 switch (f & SF_FINST_MASK) {
389 case SF_FINST_R: f &= ~SF_FINST_MASK ; printf("SF_FINST_R%s", f ? " | " : ""); break;
390 case SF_FINST_C: f &= ~SF_FINST_MASK ; printf("SF_FINST_C%s", f ? " | " : ""); break;
391 case SF_FINST_H: f &= ~SF_FINST_MASK ; printf("SF_FINST_H%s", f ? " | " : ""); break;
392 case SF_FINST_D: f &= ~SF_FINST_MASK ; printf("SF_FINST_D%s", f ? " | " : ""); break;
393 case SF_FINST_L: f &= ~SF_FINST_MASK ; printf("SF_FINST_L%s", f ? " | " : ""); break;
394 case SF_FINST_Q: f &= ~SF_FINST_MASK ; printf("SF_FINST_Q%s", f ? " | " : ""); break;
395 case SF_FINST_T: f &= ~SF_FINST_MASK ; printf("SF_FINST_T%s", f ? " | " : ""); break;
396 }
397
398 switch (f & SF_ERR_MASK) {
399 case SF_ERR_LOCAL: f &= ~SF_ERR_MASK ; printf("SF_ERR_LOCAL%s", f ? " | " : ""); break;
400 case SF_ERR_CLITO: f &= ~SF_ERR_MASK ; printf("SF_ERR_CLITO%s", f ? " | " : ""); break;
401 case SF_ERR_CLICL: f &= ~SF_ERR_MASK ; printf("SF_ERR_CLICL%s", f ? " | " : ""); break;
402 case SF_ERR_SRVTO: f &= ~SF_ERR_MASK ; printf("SF_ERR_SRVTO%s", f ? " | " : ""); break;
403 case SF_ERR_SRVCL: f &= ~SF_ERR_MASK ; printf("SF_ERR_SRVCL%s", f ? " | " : ""); break;
404 case SF_ERR_PRXCOND: f &= ~SF_ERR_MASK ; printf("SF_ERR_PRXCOND%s", f ? " | " : ""); break;
405 case SF_ERR_RESOURCE: f &= ~SF_ERR_MASK ; printf("SF_ERR_RESOURCE%s", f ? " | " : ""); break;
406 case SF_ERR_INTERNAL: f &= ~SF_ERR_MASK ; printf("SF_ERR_INTERNAL%s", f ? " | " : ""); break;
407 case SF_ERR_DOWN: f &= ~SF_ERR_MASK ; printf("SF_ERR_DOWN%s", f ? " | " : ""); break;
408 case SF_ERR_KILLED: f &= ~SF_ERR_MASK ; printf("SF_ERR_KILLED%s", f ? " | " : ""); break;
409 case SF_ERR_UP: f &= ~SF_ERR_MASK ; printf("SF_ERR_UP%s", f ? " | " : ""); break;
Willy Tarreaua7da4d22016-11-11 08:05:34 +0100410 case SF_ERR_CHK_PORT: f &= ~SF_ERR_MASK ; printf("SF_ERR_CHK_PORT%s", f ? " | " : ""); break;
Willy Tarreau074d65b2015-12-20 23:21:57 +0100411 }
412
Willy Tarreau8a0eabd2020-02-06 07:57:36 +0100413 SHOW_FLAG(f, SF_HTX);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100414 SHOW_FLAG(f, SF_REDIRECTABLE);
Willy Tarreau8a0eabd2020-02-06 07:57:36 +0100415 SHOW_FLAG(f, SF_IGNORE);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100416 SHOW_FLAG(f, SF_REDISP);
Christopher Fauletae024ce2022-03-29 19:02:31 +0200417 SHOW_FLAG(f, SF_CONN_EXP);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100418 SHOW_FLAG(f, SF_CURR_SESS);
419 SHOW_FLAG(f, SF_MONITOR);
420 SHOW_FLAG(f, SF_FORCE_PRST);
421 SHOW_FLAG(f, SF_BE_ASSIGNED);
422 SHOW_FLAG(f, SF_ADDR_SET);
423 SHOW_FLAG(f, SF_ASSIGNED);
424 SHOW_FLAG(f, SF_DIRECT);
425
426 if (f) {
427 printf("EXTRA(0x%08x)", f);
428 }
429 putchar('\n');
430}
431
Willy Tarreau354b6f52020-02-06 08:33:08 +0100432void usage_exit(const char *name)
433{
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100434 fprintf(stderr, "Usage: %s [ana|chn|conn|cs|si|sierr|strm|task|txn]* { [+-][0x]value* | - }\n", name);
Willy Tarreau354b6f52020-02-06 08:33:08 +0100435 exit(1);
436}
437
Willy Tarreau074d65b2015-12-20 23:21:57 +0100438int main(int argc, char **argv)
439{
440 unsigned int flags;
Willy Tarreau354b6f52020-02-06 08:33:08 +0100441 unsigned int show_as = 0;
442 unsigned int f;
443 const char *name = argv[0];
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100444 char line[20];
445 char *value;
Willy Tarreaubde76f02020-02-06 08:48:16 +0100446 int multi = 0;
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100447 int use_stdin = 0;
Willy Tarreau354b6f52020-02-06 08:33:08 +0100448 char *err;
449
450 while (argc > 0) {
451 argv++; argc--;
452 if (argc < 1)
453 usage_exit(name);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100454
Willy Tarreau354b6f52020-02-06 08:33:08 +0100455 f = get_show_as(argv[0]);
Willy Tarreaubde76f02020-02-06 08:48:16 +0100456 if (!f)
457 break;
Willy Tarreau354b6f52020-02-06 08:33:08 +0100458 show_as |= f;
Willy Tarreau074d65b2015-12-20 23:21:57 +0100459 }
460
Willy Tarreau354b6f52020-02-06 08:33:08 +0100461 if (!show_as)
462 show_as = ~0U;
Willy Tarreau074d65b2015-12-20 23:21:57 +0100463
Willy Tarreaubde76f02020-02-06 08:48:16 +0100464 if (argc > 1)
465 multi = 1;
Willy Tarreau074d65b2015-12-20 23:21:57 +0100466
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100467 if (strcmp(argv[0], "-") == 0)
468 use_stdin = 1;
469
Willy Tarreaubde76f02020-02-06 08:48:16 +0100470 while (argc > 0) {
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100471 if (use_stdin) {
472 value = fgets(line, sizeof(line), stdin);
473 if (!value)
474 break;
475
Ilya Shipitsin6fb0f212020-04-02 15:25:26 +0500476 /* skip common leading delimiters that slip from copy-paste */
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100477 while (*value == ' ' || *value == '\t' || *value == ':' || *value == '=')
478 value++;
479
480 /* stop at the end of the number and trim any C suffix like "UL" */
481 err = value;
482 while (*err == '-' || *err == '+' ||
Willy Tarreaub00c00e2021-04-02 17:47:21 +0200483 (isalnum((unsigned char)*err) && toupper((unsigned char)*err) != 'U' && toupper((unsigned char)*err) != 'L'))
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100484 err++;
Willy Tarreaucd430b92021-04-03 15:26:56 +0200485 *err = 0;
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100486 } else {
487 value = argv[0];
488 argv++; argc--;
489 }
490
491 flags = strtoul(value, &err, 0);
492 if (!*value || *err) {
493 fprintf(stderr, "Unparsable value: <%s>\n", value);
Willy Tarreaubde76f02020-02-06 08:48:16 +0100494 usage_exit(name);
495 }
496
Willy Tarreaue4f80a02020-02-06 18:17:50 +0100497 if (multi || use_stdin)
Willy Tarreaubde76f02020-02-06 08:48:16 +0100498 printf("### 0x%08x:\n", flags);
499
500 if (show_as & SHOW_AS_ANA) show_chn_ana(flags);
501 if (show_as & SHOW_AS_CHN) show_chn_flags(flags);
502 if (show_as & SHOW_AS_CONN) show_conn_flags(flags);
503 if (show_as & SHOW_AS_CS) show_cs_flags(flags);
Christopher Fauletdb90f2a2022-03-22 16:06:25 +0100504 if (show_as & SHOW_AS_ENDP) show_endp_flags(flags);
Willy Tarreaubde76f02020-02-06 08:48:16 +0100505 if (show_as & SHOW_AS_SI) show_si_flags(flags);
506 if (show_as & SHOW_AS_SIET) show_si_et(flags);
507 if (show_as & SHOW_AS_STRM) show_strm_flags(flags);
508 if (show_as & SHOW_AS_TASK) show_task_state(flags);
509 if (show_as & SHOW_AS_TXN) show_txn_flags(flags);
Willy Tarreaubde76f02020-02-06 08:48:16 +0100510 }
Willy Tarreau074d65b2015-12-20 23:21:57 +0100511 return 0;
512}