blob: 2638dd3430ad332c81a2a1f2923d25bbb96d1fab [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
27 SHOW_FLAG(f, AN_REQ_INSPECT_FE);
28 SHOW_FLAG(f, AN_REQ_WAIT_HTTP);
29 SHOW_FLAG(f, AN_REQ_HTTP_BODY);
30 SHOW_FLAG(f, AN_REQ_HTTP_PROCESS_FE);
31 SHOW_FLAG(f, AN_REQ_SWITCHING_RULES);
32 SHOW_FLAG(f, AN_REQ_INSPECT_BE);
33 SHOW_FLAG(f, AN_REQ_HTTP_PROCESS_BE);
34 SHOW_FLAG(f, AN_REQ_SRV_RULES);
35 SHOW_FLAG(f, AN_REQ_HTTP_INNER);
36 SHOW_FLAG(f, AN_REQ_HTTP_TARPIT);
37 SHOW_FLAG(f, AN_REQ_STICKING_RULES);
38 SHOW_FLAG(f, AN_REQ_PRST_RDP_COOKIE);
39 SHOW_FLAG(f, AN_REQ_HTTP_XFER_BODY);
40 SHOW_FLAG(f, AN_REQ_ALL);
41 SHOW_FLAG(f, AN_RES_INSPECT);
42 SHOW_FLAG(f, AN_RES_WAIT_HTTP);
43 SHOW_FLAG(f, AN_RES_HTTP_PROCESS_BE);
44 SHOW_FLAG(f, AN_RES_HTTP_PROCESS_FE);
45 SHOW_FLAG(f, AN_RES_STORE_RULES);
46 SHOW_FLAG(f, AN_RES_HTTP_XFER_BODY);
47
48 if (f) {
49 printf("EXTRA(0x%08x)", f);
50 }
51 putchar('\n');
52}
53
54void show_chn_flags(unsigned int f)
55{
56 printf("chn->flags = ");
57
58 if (!f) {
59 printf("0\n");
60 return;
61 }
62
63 SHOW_FLAG(f, CF_ISRESP);
64 SHOW_FLAG(f, CF_WAKE_ONCE);
65 SHOW_FLAG(f, CF_NEVER_WAIT);
66 SHOW_FLAG(f, CF_SEND_DONTWAIT);
67 SHOW_FLAG(f, CF_EXPECT_MORE);
68 SHOW_FLAG(f, CF_DONT_READ);
69 SHOW_FLAG(f, CF_AUTO_CONNECT);
70 SHOW_FLAG(f, CF_READ_DONTWAIT);
71 SHOW_FLAG(f, CF_KERN_SPLICING);
72 SHOW_FLAG(f, CF_READ_ATTACHED);
73 SHOW_FLAG(f, CF_ANA_TIMEOUT);
74 SHOW_FLAG(f, CF_WROTE_DATA);
75 SHOW_FLAG(f, CF_STREAMER_FAST);
76 SHOW_FLAG(f, CF_STREAMER);
77 SHOW_FLAG(f, CF_AUTO_CLOSE);
78 SHOW_FLAG(f, CF_SHUTW_NOW);
79 SHOW_FLAG(f, CF_SHUTW);
80 SHOW_FLAG(f, CF_WAKE_WRITE);
81 SHOW_FLAG(f, CF_WRITE_ERROR);
82 SHOW_FLAG(f, CF_WRITE_TIMEOUT);
83 SHOW_FLAG(f, CF_WRITE_PARTIAL);
84 SHOW_FLAG(f, CF_WRITE_NULL);
85 SHOW_FLAG(f, CF_READ_NOEXP);
86 SHOW_FLAG(f, CF_SHUTR_NOW);
87 SHOW_FLAG(f, CF_SHUTR);
88 SHOW_FLAG(f, CF_WAKE_CONNECT);
89 SHOW_FLAG(f, CF_READ_ERROR);
90 SHOW_FLAG(f, CF_READ_TIMEOUT);
91 SHOW_FLAG(f, CF_READ_PARTIAL);
92 SHOW_FLAG(f, CF_READ_NULL);
93
94 if (f) {
95 printf("EXTRA(0x%08x)", f);
96 }
97 putchar('\n');
98}
99
100void show_conn_flags(unsigned int f)
101{
102 printf("conn->flags = ");
103 if (!f) {
104 printf("0\n");
105 return;
106 }
107
108 SHOW_FLAG(f, CO_FL_XPRT_TRACKED);
109 SHOW_FLAG(f, CO_FL_PRIVATE);
110 SHOW_FLAG(f, CO_FL_ACCEPT_PROXY);
111 SHOW_FLAG(f, CO_FL_SSL_WAIT_HS);
112 SHOW_FLAG(f, CO_FL_SEND_PROXY);
113 SHOW_FLAG(f, CO_FL_WAIT_L6_CONN);
114 SHOW_FLAG(f, CO_FL_WAIT_L4_CONN);
115 SHOW_FLAG(f, CO_FL_CONNECTED);
116 SHOW_FLAG(f, CO_FL_ERROR);
117 SHOW_FLAG(f, CO_FL_SOCK_WR_SH);
118 SHOW_FLAG(f, CO_FL_SOCK_RD_SH);
119 SHOW_FLAG(f, CO_FL_DATA_WR_SH);
120 SHOW_FLAG(f, CO_FL_DATA_RD_SH);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100121 SHOW_FLAG(f, CO_FL_INIT_DATA);
122 SHOW_FLAG(f, CO_FL_ADDR_TO_SET);
123 SHOW_FLAG(f, CO_FL_ADDR_FROM_SET);
124 SHOW_FLAG(f, CO_FL_WAIT_ROOM);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100125 SHOW_FLAG(f, CO_FL_XPRT_READY);
126 SHOW_FLAG(f, CO_FL_CTRL_READY);
127 SHOW_FLAG(f, CO_FL_CURR_WR_ENA);
128 SHOW_FLAG(f, CO_FL_DATA_WR_ENA);
129 SHOW_FLAG(f, CO_FL_SOCK_WR_ENA);
130 SHOW_FLAG(f, CO_FL_CURR_RD_ENA);
131 SHOW_FLAG(f, CO_FL_DATA_RD_ENA);
132 SHOW_FLAG(f, CO_FL_SOCK_RD_ENA);
133
134 if (f) {
135 printf("EXTRA(0x%08x)", f);
136 }
137 putchar('\n');
138}
139
140void show_si_et(unsigned int f)
141{
142 printf("si->et = ");
143 if (!f) {
144 printf("SI_ET_NONE\n");
145 return;
146 }
147
148 SHOW_FLAG(f, SI_ET_QUEUE_TO);
149 SHOW_FLAG(f, SI_ET_QUEUE_ERR);
150 SHOW_FLAG(f, SI_ET_QUEUE_ABRT);
151 SHOW_FLAG(f, SI_ET_CONN_TO);
152 SHOW_FLAG(f, SI_ET_CONN_ERR);
153 SHOW_FLAG(f, SI_ET_CONN_ABRT);
154 SHOW_FLAG(f, SI_ET_CONN_RES);
155 SHOW_FLAG(f, SI_ET_CONN_OTHER);
156 SHOW_FLAG(f, SI_ET_DATA_TO);
157 SHOW_FLAG(f, SI_ET_DATA_ERR);
158 SHOW_FLAG(f, SI_ET_DATA_ABRT);
159
160 if (f) {
161 printf("EXTRA(0x%08x)", f);
162 }
163 putchar('\n');
164}
165
166void show_si_flags(unsigned int f)
167{
168 f &= 0xFFFF;
169
170 printf("si->flags = ");
171 if (!f) {
172 printf("SI_FL_NONE\n");
173 return;
174 }
175
176 SHOW_FLAG(f, SI_FL_EXP);
177 SHOW_FLAG(f, SI_FL_ERR);
178 SHOW_FLAG(f, SI_FL_WAIT_ROOM);
179 SHOW_FLAG(f, SI_FL_WAIT_DATA);
180 SHOW_FLAG(f, SI_FL_ISBACK);
181 SHOW_FLAG(f, SI_FL_DONT_WAKE);
182 SHOW_FLAG(f, SI_FL_INDEP_STR);
183 SHOW_FLAG(f, SI_FL_NOLINGER);
184 SHOW_FLAG(f, SI_FL_NOHALF);
185 SHOW_FLAG(f, SI_FL_SRC_ADDR);
186 SHOW_FLAG(f, SI_FL_WANT_PUT);
187 SHOW_FLAG(f, SI_FL_WANT_GET);
188
189 if (f) {
190 printf("EXTRA(0x%04x)", f);
191 }
192 putchar('\n');
193}
194
195void show_task_state(unsigned int f)
196{
197 printf("task->state = ");
198
199 if (!f) {
200 printf("TASK_SLEEPING\n");
201 return;
202 }
203
204 SHOW_FLAG(f, TASK_WOKEN_OTHER);
205 SHOW_FLAG(f, TASK_WOKEN_RES);
206 SHOW_FLAG(f, TASK_WOKEN_MSG);
207 SHOW_FLAG(f, TASK_WOKEN_SIGNAL);
208 SHOW_FLAG(f, TASK_WOKEN_IO);
209 SHOW_FLAG(f, TASK_WOKEN_TIMER);
210 SHOW_FLAG(f, TASK_WOKEN_INIT);
211 SHOW_FLAG(f, TASK_RUNNING);
212
213 if (f) {
214 printf("EXTRA(0x%08x)", f);
215 }
216 putchar('\n');
217}
218
219void show_txn_flags(unsigned int f)
220{
221 printf("txn->flags = ");
222
223 if (!f) {
224 printf("0\n");
225 return;
226 }
227
228 SHOW_FLAG(f, TX_NOT_FIRST);
229 SHOW_FLAG(f, TX_USE_PX_CONN);
230 SHOW_FLAG(f, TX_HDR_CONN_KAL);
231 SHOW_FLAG(f, TX_HDR_CONN_CLO);
232 SHOW_FLAG(f, TX_HDR_CONN_PRS);
233 SHOW_FLAG(f, TX_WAIT_NEXT_RQ);
234 SHOW_FLAG(f, TX_HDR_CONN_UPG);
235 SHOW_FLAG(f, TX_PREFER_LAST);
236 SHOW_FLAG(f, TX_CON_KAL_SET);
237 SHOW_FLAG(f, TX_CON_CLO_SET);
238
239 //printf("%s", f ? "" : " | ");
240 switch (f & TX_CON_WANT_MSK) {
241 case TX_CON_WANT_KAL: /*f &= ~TX_CON_WANT_MSK ; printf("TX_CON_WANT_KAL%s", f ? " | " : "");*/ break;
242 case TX_CON_WANT_TUN: f &= ~TX_CON_WANT_MSK ; printf("TX_CON_WANT_TUN%s", f ? " | " : ""); break;
243 case TX_CON_WANT_SCL: f &= ~TX_CON_WANT_MSK ; printf("TX_CON_WANT_SCL%s", f ? " | " : ""); break;
244 case TX_CON_WANT_CLO: f &= ~TX_CON_WANT_MSK ; printf("TX_CON_WANT_CLO%s", f ? " | " : ""); break;
245 }
246
247 SHOW_FLAG(f, TX_CACHE_COOK);
248 SHOW_FLAG(f, TX_CACHEABLE);
249 SHOW_FLAG(f, TX_SCK_PRESENT);
250
251 //printf("%s", f ? "" : " | ");
252 switch (f & TX_SCK_MASK) {
253 case TX_SCK_NONE: f &= ~TX_SCK_MASK ; /*printf("TX_SCK_NONE%s", f ? " | " : "");*/ break;
254 case TX_SCK_FOUND: f &= ~TX_SCK_MASK ; printf("TX_SCK_FOUND%s", f ? " | " : ""); break;
255 case TX_SCK_DELETED: f &= ~TX_SCK_MASK ; printf("TX_SCK_DELETED%s", f ? " | " : ""); break;
256 case TX_SCK_INSERTED: f &= ~TX_SCK_MASK ; printf("TX_SCK_INSERTED%s", f ? " | " : ""); break;
257 case TX_SCK_REPLACED: f &= ~TX_SCK_MASK ; printf("TX_SCK_REPLACED%s", f ? " | " : ""); break;
258 case TX_SCK_UPDATED: f &= ~TX_SCK_MASK ; printf("TX_SCK_UPDATED%s", f ? " | " : ""); break;
259 default: printf("TX_SCK_MASK(%02x)", f); f &= ~TX_SCK_MASK ; printf("%s", f ? " | " : ""); break;
260 }
261
262 //printf("%s", f ? "" : " | ");
263 switch (f & TX_CK_MASK) {
264 case TX_CK_NONE: f &= ~TX_CK_MASK ; /*printf("TX_CK_NONE%s", f ? " | " : "");*/ break;
265 case TX_CK_INVALID: f &= ~TX_CK_MASK ; printf("TX_CK_INVALID%s", f ? " | " : ""); break;
266 case TX_CK_DOWN: f &= ~TX_CK_MASK ; printf("TX_CK_DOWN%s", f ? " | " : ""); break;
267 case TX_CK_VALID: f &= ~TX_CK_MASK ; printf("TX_CK_VALID%s", f ? " | " : ""); break;
268 case TX_CK_EXPIRED: f &= ~TX_CK_MASK ; printf("TX_CK_EXPIRED%s", f ? " | " : ""); break;
269 case TX_CK_OLD: f &= ~TX_CK_MASK ; printf("TX_CK_OLD%s", f ? " | " : ""); break;
270 case TX_CK_UNUSED: f &= ~TX_CK_MASK ; printf("TX_CK_UNUSED%s", f ? " | " : ""); break;
271 default: printf("TX_CK_MASK(%02x)", f); f &= ~TX_CK_MASK ; printf("%s", f ? " | " : ""); break;
272 }
273
274 SHOW_FLAG(f, TX_CLTARPIT);
275 SHOW_FLAG(f, TX_SVALLOW);
276 SHOW_FLAG(f, TX_SVDENY);
277 SHOW_FLAG(f, TX_CLALLOW);
278 SHOW_FLAG(f, TX_CLDENY);
279
280 if (f) {
281 printf("EXTRA(0x%08x)", f);
282 }
283 putchar('\n');
284}
285
286void show_strm_flags(unsigned int f)
287{
288 printf("strm->flags = ");
289
290 if (!f) {
291 printf("0\n");
292 return;
293 }
294
295 SHOW_FLAG(f, SF_SRV_REUSED);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100296 SHOW_FLAG(f, SF_IGNORE_PRST);
297
298 //printf("%s", f ? "" : " | ");
299 switch (f & SF_FINST_MASK) {
300 case SF_FINST_R: f &= ~SF_FINST_MASK ; printf("SF_FINST_R%s", f ? " | " : ""); break;
301 case SF_FINST_C: f &= ~SF_FINST_MASK ; printf("SF_FINST_C%s", f ? " | " : ""); break;
302 case SF_FINST_H: f &= ~SF_FINST_MASK ; printf("SF_FINST_H%s", f ? " | " : ""); break;
303 case SF_FINST_D: f &= ~SF_FINST_MASK ; printf("SF_FINST_D%s", f ? " | " : ""); break;
304 case SF_FINST_L: f &= ~SF_FINST_MASK ; printf("SF_FINST_L%s", f ? " | " : ""); break;
305 case SF_FINST_Q: f &= ~SF_FINST_MASK ; printf("SF_FINST_Q%s", f ? " | " : ""); break;
306 case SF_FINST_T: f &= ~SF_FINST_MASK ; printf("SF_FINST_T%s", f ? " | " : ""); break;
307 }
308
309 switch (f & SF_ERR_MASK) {
310 case SF_ERR_LOCAL: f &= ~SF_ERR_MASK ; printf("SF_ERR_LOCAL%s", f ? " | " : ""); break;
311 case SF_ERR_CLITO: f &= ~SF_ERR_MASK ; printf("SF_ERR_CLITO%s", f ? " | " : ""); break;
312 case SF_ERR_CLICL: f &= ~SF_ERR_MASK ; printf("SF_ERR_CLICL%s", f ? " | " : ""); break;
313 case SF_ERR_SRVTO: f &= ~SF_ERR_MASK ; printf("SF_ERR_SRVTO%s", f ? " | " : ""); break;
314 case SF_ERR_SRVCL: f &= ~SF_ERR_MASK ; printf("SF_ERR_SRVCL%s", f ? " | " : ""); break;
315 case SF_ERR_PRXCOND: f &= ~SF_ERR_MASK ; printf("SF_ERR_PRXCOND%s", f ? " | " : ""); break;
316 case SF_ERR_RESOURCE: f &= ~SF_ERR_MASK ; printf("SF_ERR_RESOURCE%s", f ? " | " : ""); break;
317 case SF_ERR_INTERNAL: f &= ~SF_ERR_MASK ; printf("SF_ERR_INTERNAL%s", f ? " | " : ""); break;
318 case SF_ERR_DOWN: f &= ~SF_ERR_MASK ; printf("SF_ERR_DOWN%s", f ? " | " : ""); break;
319 case SF_ERR_KILLED: f &= ~SF_ERR_MASK ; printf("SF_ERR_KILLED%s", f ? " | " : ""); break;
320 case SF_ERR_UP: f &= ~SF_ERR_MASK ; printf("SF_ERR_UP%s", f ? " | " : ""); break;
Willy Tarreaua7da4d22016-11-11 08:05:34 +0100321 case SF_ERR_CHK_PORT: f &= ~SF_ERR_MASK ; printf("SF_ERR_CHK_PORT%s", f ? " | " : ""); break;
Willy Tarreau074d65b2015-12-20 23:21:57 +0100322 }
323
324 SHOW_FLAG(f, SF_TUNNEL);
325 SHOW_FLAG(f, SF_REDIRECTABLE);
326 SHOW_FLAG(f, SF_CONN_TAR);
327 SHOW_FLAG(f, SF_REDISP);
328 SHOW_FLAG(f, SF_INITIALIZED);
329 SHOW_FLAG(f, SF_CURR_SESS);
330 SHOW_FLAG(f, SF_MONITOR);
331 SHOW_FLAG(f, SF_FORCE_PRST);
332 SHOW_FLAG(f, SF_BE_ASSIGNED);
333 SHOW_FLAG(f, SF_ADDR_SET);
334 SHOW_FLAG(f, SF_ASSIGNED);
335 SHOW_FLAG(f, SF_DIRECT);
336
337 if (f) {
338 printf("EXTRA(0x%08x)", f);
339 }
340 putchar('\n');
341}
342
343int main(int argc, char **argv)
344{
345 unsigned int flags;
346
347 if (argc < 2) {
348 fprintf(stderr, "Usage: %s 0x<flags|state>\n", argv[0]);
349 exit(1);
350 }
351
352 flags = strtoul(argv[1], NULL, 0);
353
354 show_task_state(flags);
355 show_txn_flags(flags);
356 show_strm_flags(flags);
357 show_si_et(flags);
358 show_si_flags(flags);
359 show_conn_flags(flags);
360 show_chn_flags(flags);
361 show_chn_ana(flags);
362
363 return 0;
364}