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