blob: db601aa64ea3685eb2d29cfe62018f5ee38d3915 [file] [log] [blame]
Willy Tarreau074d65b2015-12-20 23:21:57 +01001#include <stdio.h>
2#include <stdlib.h>
3
4#include <types/channel.h>
5#include <types/connection.h>
6#include <types/proto_http.h>
7#include <types/stream.h>
8#include <types/stream_interface.h>
9#include <types/task.h>
10
11#define SHOW_FLAG(f,n) \
12 do { \
13 if (!((f) & (n))) break; \
14 (f) &= ~(n); \
15 printf(#n"%s", (f) ? " | " : ""); \
16 } while (0)
17
18void show_chn_ana(unsigned int f)
19{
20 printf("chn->ana = ");
21
22 if (!f) {
23 printf("0\n");
24 return;
25 }
26
Christopher Fauletf4cfcf92017-11-10 14:10:35 +010027 SHOW_FLAG(f, AN_REQ_FLT_START_FE);
Willy Tarreau074d65b2015-12-20 23:21:57 +010028 SHOW_FLAG(f, AN_REQ_INSPECT_FE);
29 SHOW_FLAG(f, AN_REQ_WAIT_HTTP);
30 SHOW_FLAG(f, AN_REQ_HTTP_BODY);
31 SHOW_FLAG(f, AN_REQ_HTTP_PROCESS_FE);
32 SHOW_FLAG(f, AN_REQ_SWITCHING_RULES);
Christopher Fauletf4cfcf92017-11-10 14:10:35 +010033 SHOW_FLAG(f, AN_REQ_FLT_START_BE);
Willy Tarreau074d65b2015-12-20 23:21:57 +010034 SHOW_FLAG(f, AN_REQ_INSPECT_BE);
35 SHOW_FLAG(f, AN_REQ_HTTP_PROCESS_BE);
Christopher Fauletf4cfcf92017-11-10 14:10:35 +010036 SHOW_FLAG(f, AN_REQ_HTTP_TARPIT);
Willy Tarreau074d65b2015-12-20 23:21:57 +010037 SHOW_FLAG(f, AN_REQ_SRV_RULES);
38 SHOW_FLAG(f, AN_REQ_HTTP_INNER);
Willy Tarreau074d65b2015-12-20 23:21:57 +010039 SHOW_FLAG(f, AN_REQ_PRST_RDP_COOKIE);
Christopher Fauletf4cfcf92017-11-10 14:10:35 +010040 SHOW_FLAG(f, AN_REQ_STICKING_RULES);
41 SHOW_FLAG(f, AN_REQ_FLT_HTTP_HDRS);
Willy Tarreau074d65b2015-12-20 23:21:57 +010042 SHOW_FLAG(f, AN_REQ_HTTP_XFER_BODY);
Christopher Fauletf4cfcf92017-11-10 14:10:35 +010043 SHOW_FLAG(f, AN_REQ_FLT_XFER_DATA);
44 SHOW_FLAG(f, AN_REQ_FLT_END);
45
46 SHOW_FLAG(f, AN_REQ_FLT_START_FE);
47 SHOW_FLAG(f, AN_REQ_FLT_START_BE);
Willy Tarreau074d65b2015-12-20 23:21:57 +010048 SHOW_FLAG(f, AN_RES_INSPECT);
49 SHOW_FLAG(f, AN_RES_WAIT_HTTP);
Willy Tarreau074d65b2015-12-20 23:21:57 +010050 SHOW_FLAG(f, AN_RES_STORE_RULES);
Christopher Fauletf4cfcf92017-11-10 14:10:35 +010051 SHOW_FLAG(f, AN_RES_HTTP_PROCESS_FE);
52 SHOW_FLAG(f, AN_RES_HTTP_PROCESS_BE);
53 SHOW_FLAG(f, AN_RES_FLT_HTTP_HDRS);
Willy Tarreau074d65b2015-12-20 23:21:57 +010054 SHOW_FLAG(f, AN_RES_HTTP_XFER_BODY);
Christopher Fauletf4cfcf92017-11-10 14:10:35 +010055 SHOW_FLAG(f, AN_RES_FLT_XFER_DATA);
56 SHOW_FLAG(f, AN_RES_FLT_END);
Willy Tarreau074d65b2015-12-20 23:21:57 +010057
58 if (f) {
59 printf("EXTRA(0x%08x)", f);
60 }
61 putchar('\n');
62}
63
64void show_chn_flags(unsigned int f)
65{
66 printf("chn->flags = ");
67
68 if (!f) {
69 printf("0\n");
70 return;
71 }
72
73 SHOW_FLAG(f, CF_ISRESP);
Christopher Fauletf4cfcf92017-11-10 14:10:35 +010074 SHOW_FLAG(f, CF_FLT_ANALYZE);
75 SHOW_FLAG(f, CF_WRITE_EVENT);
Willy Tarreau074d65b2015-12-20 23:21:57 +010076 SHOW_FLAG(f, CF_WAKE_ONCE);
77 SHOW_FLAG(f, CF_NEVER_WAIT);
78 SHOW_FLAG(f, CF_SEND_DONTWAIT);
79 SHOW_FLAG(f, CF_EXPECT_MORE);
80 SHOW_FLAG(f, CF_DONT_READ);
81 SHOW_FLAG(f, CF_AUTO_CONNECT);
82 SHOW_FLAG(f, CF_READ_DONTWAIT);
83 SHOW_FLAG(f, CF_KERN_SPLICING);
84 SHOW_FLAG(f, CF_READ_ATTACHED);
85 SHOW_FLAG(f, CF_ANA_TIMEOUT);
86 SHOW_FLAG(f, CF_WROTE_DATA);
87 SHOW_FLAG(f, CF_STREAMER_FAST);
88 SHOW_FLAG(f, CF_STREAMER);
89 SHOW_FLAG(f, CF_AUTO_CLOSE);
90 SHOW_FLAG(f, CF_SHUTW_NOW);
91 SHOW_FLAG(f, CF_SHUTW);
92 SHOW_FLAG(f, CF_WAKE_WRITE);
93 SHOW_FLAG(f, CF_WRITE_ERROR);
94 SHOW_FLAG(f, CF_WRITE_TIMEOUT);
95 SHOW_FLAG(f, CF_WRITE_PARTIAL);
96 SHOW_FLAG(f, CF_WRITE_NULL);
97 SHOW_FLAG(f, CF_READ_NOEXP);
98 SHOW_FLAG(f, CF_SHUTR_NOW);
99 SHOW_FLAG(f, CF_SHUTR);
100 SHOW_FLAG(f, CF_WAKE_CONNECT);
101 SHOW_FLAG(f, CF_READ_ERROR);
102 SHOW_FLAG(f, CF_READ_TIMEOUT);
103 SHOW_FLAG(f, CF_READ_PARTIAL);
104 SHOW_FLAG(f, CF_READ_NULL);
105
106 if (f) {
107 printf("EXTRA(0x%08x)", f);
108 }
109 putchar('\n');
110}
111
112void show_conn_flags(unsigned int f)
113{
114 printf("conn->flags = ");
115 if (!f) {
116 printf("0\n");
117 return;
118 }
119
120 SHOW_FLAG(f, CO_FL_XPRT_TRACKED);
Christopher Fauletf4cfcf92017-11-10 14:10:35 +0100121 SHOW_FLAG(f, CO_FL_RCVD_PROXY);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100122 SHOW_FLAG(f, CO_FL_PRIVATE);
Christopher Fauletf4cfcf92017-11-10 14:10:35 +0100123 SHOW_FLAG(f, CO_FL_ACCEPT_CIP);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100124 SHOW_FLAG(f, CO_FL_ACCEPT_PROXY);
125 SHOW_FLAG(f, CO_FL_SSL_WAIT_HS);
126 SHOW_FLAG(f, CO_FL_SEND_PROXY);
127 SHOW_FLAG(f, CO_FL_WAIT_L6_CONN);
128 SHOW_FLAG(f, CO_FL_WAIT_L4_CONN);
129 SHOW_FLAG(f, CO_FL_CONNECTED);
Christopher Fauletf4cfcf92017-11-10 14:10:35 +0100130 SHOW_FLAG(f, CO_FL_NOTIFY_DATA);
131 SHOW_FLAG(f, CO_FL_NOTIFY_DONE);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100132 SHOW_FLAG(f, CO_FL_ERROR);
133 SHOW_FLAG(f, CO_FL_SOCK_WR_SH);
134 SHOW_FLAG(f, CO_FL_SOCK_RD_SH);
Christopher Fauletf4cfcf92017-11-10 14:10:35 +0100135 SHOW_FLAG(f, CO_FL_EARLY_DATA);
136 SHOW_FLAG(f, CO_FL_EARLY_SSL_HS);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100137 SHOW_FLAG(f, CO_FL_ADDR_TO_SET);
138 SHOW_FLAG(f, CO_FL_ADDR_FROM_SET);
139 SHOW_FLAG(f, CO_FL_WAIT_ROOM);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100140 SHOW_FLAG(f, CO_FL_XPRT_READY);
141 SHOW_FLAG(f, CO_FL_CTRL_READY);
142 SHOW_FLAG(f, CO_FL_CURR_WR_ENA);
Olivier Houchard1a0545f2017-09-13 18:30:23 +0200143 SHOW_FLAG(f, CO_FL_XPRT_WR_ENA);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100144 SHOW_FLAG(f, CO_FL_SOCK_WR_ENA);
145 SHOW_FLAG(f, CO_FL_CURR_RD_ENA);
Olivier Houchard1a0545f2017-09-13 18:30:23 +0200146 SHOW_FLAG(f, CO_FL_XPRT_RD_ENA);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100147 SHOW_FLAG(f, CO_FL_SOCK_RD_ENA);
148
149 if (f) {
150 printf("EXTRA(0x%08x)", f);
151 }
152 putchar('\n');
153}
154
155void show_si_et(unsigned int f)
156{
157 printf("si->et = ");
158 if (!f) {
159 printf("SI_ET_NONE\n");
160 return;
161 }
162
163 SHOW_FLAG(f, SI_ET_QUEUE_TO);
164 SHOW_FLAG(f, SI_ET_QUEUE_ERR);
165 SHOW_FLAG(f, SI_ET_QUEUE_ABRT);
166 SHOW_FLAG(f, SI_ET_CONN_TO);
167 SHOW_FLAG(f, SI_ET_CONN_ERR);
168 SHOW_FLAG(f, SI_ET_CONN_ABRT);
169 SHOW_FLAG(f, SI_ET_CONN_RES);
170 SHOW_FLAG(f, SI_ET_CONN_OTHER);
171 SHOW_FLAG(f, SI_ET_DATA_TO);
172 SHOW_FLAG(f, SI_ET_DATA_ERR);
173 SHOW_FLAG(f, SI_ET_DATA_ABRT);
174
175 if (f) {
176 printf("EXTRA(0x%08x)", f);
177 }
178 putchar('\n');
179}
180
181void show_si_flags(unsigned int f)
182{
183 f &= 0xFFFF;
184
185 printf("si->flags = ");
186 if (!f) {
187 printf("SI_FL_NONE\n");
188 return;
189 }
190
191 SHOW_FLAG(f, SI_FL_EXP);
192 SHOW_FLAG(f, SI_FL_ERR);
193 SHOW_FLAG(f, SI_FL_WAIT_ROOM);
194 SHOW_FLAG(f, SI_FL_WAIT_DATA);
195 SHOW_FLAG(f, SI_FL_ISBACK);
196 SHOW_FLAG(f, SI_FL_DONT_WAKE);
197 SHOW_FLAG(f, SI_FL_INDEP_STR);
198 SHOW_FLAG(f, SI_FL_NOLINGER);
199 SHOW_FLAG(f, SI_FL_NOHALF);
200 SHOW_FLAG(f, SI_FL_SRC_ADDR);
201 SHOW_FLAG(f, SI_FL_WANT_PUT);
202 SHOW_FLAG(f, SI_FL_WANT_GET);
203
204 if (f) {
205 printf("EXTRA(0x%04x)", f);
206 }
207 putchar('\n');
208}
209
210void show_task_state(unsigned int f)
211{
212 printf("task->state = ");
213
214 if (!f) {
215 printf("TASK_SLEEPING\n");
216 return;
217 }
218
219 SHOW_FLAG(f, TASK_WOKEN_OTHER);
220 SHOW_FLAG(f, TASK_WOKEN_RES);
221 SHOW_FLAG(f, TASK_WOKEN_MSG);
222 SHOW_FLAG(f, TASK_WOKEN_SIGNAL);
223 SHOW_FLAG(f, TASK_WOKEN_IO);
224 SHOW_FLAG(f, TASK_WOKEN_TIMER);
225 SHOW_FLAG(f, TASK_WOKEN_INIT);
226 SHOW_FLAG(f, TASK_RUNNING);
227
228 if (f) {
229 printf("EXTRA(0x%08x)", f);
230 }
231 putchar('\n');
232}
233
234void show_txn_flags(unsigned int f)
235{
236 printf("txn->flags = ");
237
238 if (!f) {
239 printf("0\n");
240 return;
241 }
242
243 SHOW_FLAG(f, TX_NOT_FIRST);
244 SHOW_FLAG(f, TX_USE_PX_CONN);
245 SHOW_FLAG(f, TX_HDR_CONN_KAL);
246 SHOW_FLAG(f, TX_HDR_CONN_CLO);
247 SHOW_FLAG(f, TX_HDR_CONN_PRS);
248 SHOW_FLAG(f, TX_WAIT_NEXT_RQ);
249 SHOW_FLAG(f, TX_HDR_CONN_UPG);
250 SHOW_FLAG(f, TX_PREFER_LAST);
251 SHOW_FLAG(f, TX_CON_KAL_SET);
252 SHOW_FLAG(f, TX_CON_CLO_SET);
253
254 //printf("%s", f ? "" : " | ");
255 switch (f & TX_CON_WANT_MSK) {
256 case TX_CON_WANT_KAL: /*f &= ~TX_CON_WANT_MSK ; printf("TX_CON_WANT_KAL%s", f ? " | " : "");*/ break;
257 case TX_CON_WANT_TUN: f &= ~TX_CON_WANT_MSK ; printf("TX_CON_WANT_TUN%s", f ? " | " : ""); break;
258 case TX_CON_WANT_SCL: f &= ~TX_CON_WANT_MSK ; printf("TX_CON_WANT_SCL%s", f ? " | " : ""); break;
259 case TX_CON_WANT_CLO: f &= ~TX_CON_WANT_MSK ; printf("TX_CON_WANT_CLO%s", f ? " | " : ""); break;
260 }
261
262 SHOW_FLAG(f, TX_CACHE_COOK);
263 SHOW_FLAG(f, TX_CACHEABLE);
264 SHOW_FLAG(f, TX_SCK_PRESENT);
265
266 //printf("%s", f ? "" : " | ");
267 switch (f & TX_SCK_MASK) {
268 case TX_SCK_NONE: f &= ~TX_SCK_MASK ; /*printf("TX_SCK_NONE%s", f ? " | " : "");*/ break;
269 case TX_SCK_FOUND: f &= ~TX_SCK_MASK ; printf("TX_SCK_FOUND%s", f ? " | " : ""); break;
270 case TX_SCK_DELETED: f &= ~TX_SCK_MASK ; printf("TX_SCK_DELETED%s", f ? " | " : ""); break;
271 case TX_SCK_INSERTED: f &= ~TX_SCK_MASK ; printf("TX_SCK_INSERTED%s", f ? " | " : ""); break;
272 case TX_SCK_REPLACED: f &= ~TX_SCK_MASK ; printf("TX_SCK_REPLACED%s", f ? " | " : ""); break;
273 case TX_SCK_UPDATED: f &= ~TX_SCK_MASK ; printf("TX_SCK_UPDATED%s", f ? " | " : ""); break;
274 default: printf("TX_SCK_MASK(%02x)", f); f &= ~TX_SCK_MASK ; printf("%s", f ? " | " : ""); break;
275 }
276
277 //printf("%s", f ? "" : " | ");
278 switch (f & TX_CK_MASK) {
279 case TX_CK_NONE: f &= ~TX_CK_MASK ; /*printf("TX_CK_NONE%s", f ? " | " : "");*/ break;
280 case TX_CK_INVALID: f &= ~TX_CK_MASK ; printf("TX_CK_INVALID%s", f ? " | " : ""); break;
281 case TX_CK_DOWN: f &= ~TX_CK_MASK ; printf("TX_CK_DOWN%s", f ? " | " : ""); break;
282 case TX_CK_VALID: f &= ~TX_CK_MASK ; printf("TX_CK_VALID%s", f ? " | " : ""); break;
283 case TX_CK_EXPIRED: f &= ~TX_CK_MASK ; printf("TX_CK_EXPIRED%s", f ? " | " : ""); break;
284 case TX_CK_OLD: f &= ~TX_CK_MASK ; printf("TX_CK_OLD%s", f ? " | " : ""); break;
285 case TX_CK_UNUSED: f &= ~TX_CK_MASK ; printf("TX_CK_UNUSED%s", f ? " | " : ""); break;
286 default: printf("TX_CK_MASK(%02x)", f); f &= ~TX_CK_MASK ; printf("%s", f ? " | " : ""); break;
287 }
288
289 SHOW_FLAG(f, TX_CLTARPIT);
290 SHOW_FLAG(f, TX_SVALLOW);
291 SHOW_FLAG(f, TX_SVDENY);
292 SHOW_FLAG(f, TX_CLALLOW);
293 SHOW_FLAG(f, TX_CLDENY);
294
295 if (f) {
296 printf("EXTRA(0x%08x)", f);
297 }
298 putchar('\n');
299}
300
301void show_strm_flags(unsigned int f)
302{
303 printf("strm->flags = ");
304
305 if (!f) {
306 printf("0\n");
307 return;
308 }
309
310 SHOW_FLAG(f, SF_SRV_REUSED);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100311 SHOW_FLAG(f, SF_IGNORE_PRST);
312
313 //printf("%s", f ? "" : " | ");
314 switch (f & SF_FINST_MASK) {
315 case SF_FINST_R: f &= ~SF_FINST_MASK ; printf("SF_FINST_R%s", f ? " | " : ""); break;
316 case SF_FINST_C: f &= ~SF_FINST_MASK ; printf("SF_FINST_C%s", f ? " | " : ""); break;
317 case SF_FINST_H: f &= ~SF_FINST_MASK ; printf("SF_FINST_H%s", f ? " | " : ""); break;
318 case SF_FINST_D: f &= ~SF_FINST_MASK ; printf("SF_FINST_D%s", f ? " | " : ""); break;
319 case SF_FINST_L: f &= ~SF_FINST_MASK ; printf("SF_FINST_L%s", f ? " | " : ""); break;
320 case SF_FINST_Q: f &= ~SF_FINST_MASK ; printf("SF_FINST_Q%s", f ? " | " : ""); break;
321 case SF_FINST_T: f &= ~SF_FINST_MASK ; printf("SF_FINST_T%s", f ? " | " : ""); break;
322 }
323
324 switch (f & SF_ERR_MASK) {
325 case SF_ERR_LOCAL: f &= ~SF_ERR_MASK ; printf("SF_ERR_LOCAL%s", f ? " | " : ""); break;
326 case SF_ERR_CLITO: f &= ~SF_ERR_MASK ; printf("SF_ERR_CLITO%s", f ? " | " : ""); break;
327 case SF_ERR_CLICL: f &= ~SF_ERR_MASK ; printf("SF_ERR_CLICL%s", f ? " | " : ""); break;
328 case SF_ERR_SRVTO: f &= ~SF_ERR_MASK ; printf("SF_ERR_SRVTO%s", f ? " | " : ""); break;
329 case SF_ERR_SRVCL: f &= ~SF_ERR_MASK ; printf("SF_ERR_SRVCL%s", f ? " | " : ""); break;
330 case SF_ERR_PRXCOND: f &= ~SF_ERR_MASK ; printf("SF_ERR_PRXCOND%s", f ? " | " : ""); break;
331 case SF_ERR_RESOURCE: f &= ~SF_ERR_MASK ; printf("SF_ERR_RESOURCE%s", f ? " | " : ""); break;
332 case SF_ERR_INTERNAL: f &= ~SF_ERR_MASK ; printf("SF_ERR_INTERNAL%s", f ? " | " : ""); break;
333 case SF_ERR_DOWN: f &= ~SF_ERR_MASK ; printf("SF_ERR_DOWN%s", f ? " | " : ""); break;
334 case SF_ERR_KILLED: f &= ~SF_ERR_MASK ; printf("SF_ERR_KILLED%s", f ? " | " : ""); break;
335 case SF_ERR_UP: f &= ~SF_ERR_MASK ; printf("SF_ERR_UP%s", f ? " | " : ""); break;
Willy Tarreaua7da4d22016-11-11 08:05:34 +0100336 case SF_ERR_CHK_PORT: f &= ~SF_ERR_MASK ; printf("SF_ERR_CHK_PORT%s", f ? " | " : ""); break;
Willy Tarreau074d65b2015-12-20 23:21:57 +0100337 }
338
339 SHOW_FLAG(f, SF_TUNNEL);
340 SHOW_FLAG(f, SF_REDIRECTABLE);
341 SHOW_FLAG(f, SF_CONN_TAR);
342 SHOW_FLAG(f, SF_REDISP);
343 SHOW_FLAG(f, SF_INITIALIZED);
344 SHOW_FLAG(f, SF_CURR_SESS);
345 SHOW_FLAG(f, SF_MONITOR);
346 SHOW_FLAG(f, SF_FORCE_PRST);
347 SHOW_FLAG(f, SF_BE_ASSIGNED);
348 SHOW_FLAG(f, SF_ADDR_SET);
349 SHOW_FLAG(f, SF_ASSIGNED);
350 SHOW_FLAG(f, SF_DIRECT);
351
352 if (f) {
353 printf("EXTRA(0x%08x)", f);
354 }
355 putchar('\n');
356}
357
358int main(int argc, char **argv)
359{
360 unsigned int flags;
361
362 if (argc < 2) {
363 fprintf(stderr, "Usage: %s 0x<flags|state>\n", argv[0]);
364 exit(1);
365 }
366
367 flags = strtoul(argv[1], NULL, 0);
368
369 show_task_state(flags);
370 show_txn_flags(flags);
371 show_strm_flags(flags);
372 show_si_et(flags);
373 show_si_flags(flags);
374 show_conn_flags(flags);
375 show_chn_flags(flags);
376 show_chn_ana(flags);
377
378 return 0;
379}