blob: cf11a71f1bdfa58a2852fd4cd946a95721feb4ed [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);
125 SHOW_FLAG(f, CO_FL_WAIT_DATA);
126 SHOW_FLAG(f, CO_FL_XPRT_READY);
127 SHOW_FLAG(f, CO_FL_CTRL_READY);
128 SHOW_FLAG(f, CO_FL_CURR_WR_ENA);
129 SHOW_FLAG(f, CO_FL_DATA_WR_ENA);
130 SHOW_FLAG(f, CO_FL_SOCK_WR_ENA);
131 SHOW_FLAG(f, CO_FL_CURR_RD_ENA);
132 SHOW_FLAG(f, CO_FL_DATA_RD_ENA);
133 SHOW_FLAG(f, CO_FL_SOCK_RD_ENA);
134
135 if (f) {
136 printf("EXTRA(0x%08x)", f);
137 }
138 putchar('\n');
139}
140
141void show_si_et(unsigned int f)
142{
143 printf("si->et = ");
144 if (!f) {
145 printf("SI_ET_NONE\n");
146 return;
147 }
148
149 SHOW_FLAG(f, SI_ET_QUEUE_TO);
150 SHOW_FLAG(f, SI_ET_QUEUE_ERR);
151 SHOW_FLAG(f, SI_ET_QUEUE_ABRT);
152 SHOW_FLAG(f, SI_ET_CONN_TO);
153 SHOW_FLAG(f, SI_ET_CONN_ERR);
154 SHOW_FLAG(f, SI_ET_CONN_ABRT);
155 SHOW_FLAG(f, SI_ET_CONN_RES);
156 SHOW_FLAG(f, SI_ET_CONN_OTHER);
157 SHOW_FLAG(f, SI_ET_DATA_TO);
158 SHOW_FLAG(f, SI_ET_DATA_ERR);
159 SHOW_FLAG(f, SI_ET_DATA_ABRT);
160
161 if (f) {
162 printf("EXTRA(0x%08x)", f);
163 }
164 putchar('\n');
165}
166
167void show_si_flags(unsigned int f)
168{
169 f &= 0xFFFF;
170
171 printf("si->flags = ");
172 if (!f) {
173 printf("SI_FL_NONE\n");
174 return;
175 }
176
177 SHOW_FLAG(f, SI_FL_EXP);
178 SHOW_FLAG(f, SI_FL_ERR);
179 SHOW_FLAG(f, SI_FL_WAIT_ROOM);
180 SHOW_FLAG(f, SI_FL_WAIT_DATA);
181 SHOW_FLAG(f, SI_FL_ISBACK);
182 SHOW_FLAG(f, SI_FL_DONT_WAKE);
183 SHOW_FLAG(f, SI_FL_INDEP_STR);
184 SHOW_FLAG(f, SI_FL_NOLINGER);
185 SHOW_FLAG(f, SI_FL_NOHALF);
186 SHOW_FLAG(f, SI_FL_SRC_ADDR);
187 SHOW_FLAG(f, SI_FL_WANT_PUT);
188 SHOW_FLAG(f, SI_FL_WANT_GET);
189
190 if (f) {
191 printf("EXTRA(0x%04x)", f);
192 }
193 putchar('\n');
194}
195
196void show_task_state(unsigned int f)
197{
198 printf("task->state = ");
199
200 if (!f) {
201 printf("TASK_SLEEPING\n");
202 return;
203 }
204
205 SHOW_FLAG(f, TASK_WOKEN_OTHER);
206 SHOW_FLAG(f, TASK_WOKEN_RES);
207 SHOW_FLAG(f, TASK_WOKEN_MSG);
208 SHOW_FLAG(f, TASK_WOKEN_SIGNAL);
209 SHOW_FLAG(f, TASK_WOKEN_IO);
210 SHOW_FLAG(f, TASK_WOKEN_TIMER);
211 SHOW_FLAG(f, TASK_WOKEN_INIT);
212 SHOW_FLAG(f, TASK_RUNNING);
213
214 if (f) {
215 printf("EXTRA(0x%08x)", f);
216 }
217 putchar('\n');
218}
219
220void show_txn_flags(unsigned int f)
221{
222 printf("txn->flags = ");
223
224 if (!f) {
225 printf("0\n");
226 return;
227 }
228
229 SHOW_FLAG(f, TX_NOT_FIRST);
230 SHOW_FLAG(f, TX_USE_PX_CONN);
231 SHOW_FLAG(f, TX_HDR_CONN_KAL);
232 SHOW_FLAG(f, TX_HDR_CONN_CLO);
233 SHOW_FLAG(f, TX_HDR_CONN_PRS);
234 SHOW_FLAG(f, TX_WAIT_NEXT_RQ);
235 SHOW_FLAG(f, TX_HDR_CONN_UPG);
236 SHOW_FLAG(f, TX_PREFER_LAST);
237 SHOW_FLAG(f, TX_CON_KAL_SET);
238 SHOW_FLAG(f, TX_CON_CLO_SET);
239
240 //printf("%s", f ? "" : " | ");
241 switch (f & TX_CON_WANT_MSK) {
242 case TX_CON_WANT_KAL: /*f &= ~TX_CON_WANT_MSK ; printf("TX_CON_WANT_KAL%s", f ? " | " : "");*/ break;
243 case TX_CON_WANT_TUN: f &= ~TX_CON_WANT_MSK ; printf("TX_CON_WANT_TUN%s", f ? " | " : ""); break;
244 case TX_CON_WANT_SCL: f &= ~TX_CON_WANT_MSK ; printf("TX_CON_WANT_SCL%s", f ? " | " : ""); break;
245 case TX_CON_WANT_CLO: f &= ~TX_CON_WANT_MSK ; printf("TX_CON_WANT_CLO%s", f ? " | " : ""); break;
246 }
247
248 SHOW_FLAG(f, TX_CACHE_COOK);
249 SHOW_FLAG(f, TX_CACHEABLE);
250 SHOW_FLAG(f, TX_SCK_PRESENT);
251
252 //printf("%s", f ? "" : " | ");
253 switch (f & TX_SCK_MASK) {
254 case TX_SCK_NONE: f &= ~TX_SCK_MASK ; /*printf("TX_SCK_NONE%s", f ? " | " : "");*/ break;
255 case TX_SCK_FOUND: f &= ~TX_SCK_MASK ; printf("TX_SCK_FOUND%s", f ? " | " : ""); break;
256 case TX_SCK_DELETED: f &= ~TX_SCK_MASK ; printf("TX_SCK_DELETED%s", f ? " | " : ""); break;
257 case TX_SCK_INSERTED: f &= ~TX_SCK_MASK ; printf("TX_SCK_INSERTED%s", f ? " | " : ""); break;
258 case TX_SCK_REPLACED: f &= ~TX_SCK_MASK ; printf("TX_SCK_REPLACED%s", f ? " | " : ""); break;
259 case TX_SCK_UPDATED: f &= ~TX_SCK_MASK ; printf("TX_SCK_UPDATED%s", f ? " | " : ""); break;
260 default: printf("TX_SCK_MASK(%02x)", f); f &= ~TX_SCK_MASK ; printf("%s", f ? " | " : ""); break;
261 }
262
263 //printf("%s", f ? "" : " | ");
264 switch (f & TX_CK_MASK) {
265 case TX_CK_NONE: f &= ~TX_CK_MASK ; /*printf("TX_CK_NONE%s", f ? " | " : "");*/ break;
266 case TX_CK_INVALID: f &= ~TX_CK_MASK ; printf("TX_CK_INVALID%s", f ? " | " : ""); break;
267 case TX_CK_DOWN: f &= ~TX_CK_MASK ; printf("TX_CK_DOWN%s", f ? " | " : ""); break;
268 case TX_CK_VALID: f &= ~TX_CK_MASK ; printf("TX_CK_VALID%s", f ? " | " : ""); break;
269 case TX_CK_EXPIRED: f &= ~TX_CK_MASK ; printf("TX_CK_EXPIRED%s", f ? " | " : ""); break;
270 case TX_CK_OLD: f &= ~TX_CK_MASK ; printf("TX_CK_OLD%s", f ? " | " : ""); break;
271 case TX_CK_UNUSED: f &= ~TX_CK_MASK ; printf("TX_CK_UNUSED%s", f ? " | " : ""); break;
272 default: printf("TX_CK_MASK(%02x)", f); f &= ~TX_CK_MASK ; printf("%s", f ? " | " : ""); break;
273 }
274
275 SHOW_FLAG(f, TX_CLTARPIT);
276 SHOW_FLAG(f, TX_SVALLOW);
277 SHOW_FLAG(f, TX_SVDENY);
278 SHOW_FLAG(f, TX_CLALLOW);
279 SHOW_FLAG(f, TX_CLDENY);
280
281 if (f) {
282 printf("EXTRA(0x%08x)", f);
283 }
284 putchar('\n');
285}
286
287void show_strm_flags(unsigned int f)
288{
289 printf("strm->flags = ");
290
291 if (!f) {
292 printf("0\n");
293 return;
294 }
295
296 SHOW_FLAG(f, SF_SRV_REUSED);
Willy Tarreau074d65b2015-12-20 23:21:57 +0100297 SHOW_FLAG(f, SF_IGNORE_PRST);
298
299 //printf("%s", f ? "" : " | ");
300 switch (f & SF_FINST_MASK) {
301 case SF_FINST_R: f &= ~SF_FINST_MASK ; printf("SF_FINST_R%s", f ? " | " : ""); break;
302 case SF_FINST_C: f &= ~SF_FINST_MASK ; printf("SF_FINST_C%s", f ? " | " : ""); break;
303 case SF_FINST_H: f &= ~SF_FINST_MASK ; printf("SF_FINST_H%s", f ? " | " : ""); break;
304 case SF_FINST_D: f &= ~SF_FINST_MASK ; printf("SF_FINST_D%s", f ? " | " : ""); break;
305 case SF_FINST_L: f &= ~SF_FINST_MASK ; printf("SF_FINST_L%s", f ? " | " : ""); break;
306 case SF_FINST_Q: f &= ~SF_FINST_MASK ; printf("SF_FINST_Q%s", f ? " | " : ""); break;
307 case SF_FINST_T: f &= ~SF_FINST_MASK ; printf("SF_FINST_T%s", f ? " | " : ""); break;
308 }
309
310 switch (f & SF_ERR_MASK) {
311 case SF_ERR_LOCAL: f &= ~SF_ERR_MASK ; printf("SF_ERR_LOCAL%s", f ? " | " : ""); break;
312 case SF_ERR_CLITO: f &= ~SF_ERR_MASK ; printf("SF_ERR_CLITO%s", f ? " | " : ""); break;
313 case SF_ERR_CLICL: f &= ~SF_ERR_MASK ; printf("SF_ERR_CLICL%s", f ? " | " : ""); break;
314 case SF_ERR_SRVTO: f &= ~SF_ERR_MASK ; printf("SF_ERR_SRVTO%s", f ? " | " : ""); break;
315 case SF_ERR_SRVCL: f &= ~SF_ERR_MASK ; printf("SF_ERR_SRVCL%s", f ? " | " : ""); break;
316 case SF_ERR_PRXCOND: f &= ~SF_ERR_MASK ; printf("SF_ERR_PRXCOND%s", f ? " | " : ""); break;
317 case SF_ERR_RESOURCE: f &= ~SF_ERR_MASK ; printf("SF_ERR_RESOURCE%s", f ? " | " : ""); break;
318 case SF_ERR_INTERNAL: f &= ~SF_ERR_MASK ; printf("SF_ERR_INTERNAL%s", f ? " | " : ""); break;
319 case SF_ERR_DOWN: f &= ~SF_ERR_MASK ; printf("SF_ERR_DOWN%s", f ? " | " : ""); break;
320 case SF_ERR_KILLED: f &= ~SF_ERR_MASK ; printf("SF_ERR_KILLED%s", f ? " | " : ""); break;
321 case SF_ERR_UP: f &= ~SF_ERR_MASK ; printf("SF_ERR_UP%s", f ? " | " : ""); break;
Willy Tarreaua7da4d22016-11-11 08:05:34 +0100322 case SF_ERR_CHK_PORT: f &= ~SF_ERR_MASK ; printf("SF_ERR_CHK_PORT%s", f ? " | " : ""); break;
Willy Tarreau074d65b2015-12-20 23:21:57 +0100323 }
324
325 SHOW_FLAG(f, SF_TUNNEL);
326 SHOW_FLAG(f, SF_REDIRECTABLE);
327 SHOW_FLAG(f, SF_CONN_TAR);
328 SHOW_FLAG(f, SF_REDISP);
329 SHOW_FLAG(f, SF_INITIALIZED);
330 SHOW_FLAG(f, SF_CURR_SESS);
331 SHOW_FLAG(f, SF_MONITOR);
332 SHOW_FLAG(f, SF_FORCE_PRST);
333 SHOW_FLAG(f, SF_BE_ASSIGNED);
334 SHOW_FLAG(f, SF_ADDR_SET);
335 SHOW_FLAG(f, SF_ASSIGNED);
336 SHOW_FLAG(f, SF_DIRECT);
337
338 if (f) {
339 printf("EXTRA(0x%08x)", f);
340 }
341 putchar('\n');
342}
343
344int main(int argc, char **argv)
345{
346 unsigned int flags;
347
348 if (argc < 2) {
349 fprintf(stderr, "Usage: %s 0x<flags|state>\n", argv[0]);
350 exit(1);
351 }
352
353 flags = strtoul(argv[1], NULL, 0);
354
355 show_task_state(flags);
356 show_txn_flags(flags);
357 show_strm_flags(flags);
358 show_si_et(flags);
359 show_si_flags(flags);
360 show_conn_flags(flags);
361 show_chn_flags(flags);
362 show_chn_ana(flags);
363
364 return 0;
365}