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