2015-12-20 22:21:57 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2022-11-24 07:22:40 +00:00
|
|
|
/* make the include files below expose their flags */
|
|
|
|
#define HA_EXPOSE_FLAGS
|
|
|
|
|
2020-06-04 19:07:02 +00:00
|
|
|
#include <haproxy/channel-t.h>
|
2020-06-04 16:02:10 +00:00
|
|
|
#include <haproxy/connection-t.h>
|
2022-09-12 16:53:06 +00:00
|
|
|
#include <haproxy/fd-t.h>
|
2020-06-04 19:21:03 +00:00
|
|
|
#include <haproxy/http_ana-t.h>
|
2022-09-09 14:59:29 +00:00
|
|
|
#include <haproxy/htx-t.h>
|
2022-10-12 15:00:13 +00:00
|
|
|
#include <haproxy/mux_fcgi-t.h>
|
2022-09-12 17:20:23 +00:00
|
|
|
#include <haproxy/mux_h2-t.h>
|
2022-09-15 08:54:36 +00:00
|
|
|
#include <haproxy/mux_h1-t.h>
|
2024-04-25 07:43:16 +00:00
|
|
|
#include <haproxy/peers-t.h>
|
2022-09-12 16:53:06 +00:00
|
|
|
#include <haproxy/stconn-t.h>
|
2020-06-04 21:46:14 +00:00
|
|
|
#include <haproxy/stream-t.h>
|
2020-06-04 15:25:40 +00:00
|
|
|
#include <haproxy/task-t.h>
|
2015-12-20 22:21:57 +00:00
|
|
|
|
2020-02-06 07:33:08 +00:00
|
|
|
// 1 bit per flag, no hole permitted here
|
|
|
|
#define SHOW_AS_ANA 0x00000001
|
|
|
|
#define SHOW_AS_CHN 0x00000002
|
|
|
|
#define SHOW_AS_CONN 0x00000004
|
2022-05-27 07:57:31 +00:00
|
|
|
#define SHOW_AS_SC 0x00000008
|
2022-04-04 09:28:27 +00:00
|
|
|
#define SHOW_AS_SET 0x00000010
|
|
|
|
#define SHOW_AS_STRM 0x00000020
|
|
|
|
#define SHOW_AS_TASK 0x00000040
|
|
|
|
#define SHOW_AS_TXN 0x00000080
|
2022-05-27 14:29:30 +00:00
|
|
|
#define SHOW_AS_SD 0x00000100
|
2022-09-09 14:59:29 +00:00
|
|
|
#define SHOW_AS_HSL 0x00000200
|
|
|
|
#define SHOW_AS_HTX 0x00000400
|
2022-09-09 15:18:57 +00:00
|
|
|
#define SHOW_AS_HMSG 0x00000800
|
2022-09-12 16:53:06 +00:00
|
|
|
#define SHOW_AS_FD 0x00001000
|
2022-09-12 17:20:23 +00:00
|
|
|
#define SHOW_AS_H2C 0x00002000
|
|
|
|
#define SHOW_AS_H2S 0x00004000
|
2022-09-15 08:54:36 +00:00
|
|
|
#define SHOW_AS_H1C 0x00008000
|
|
|
|
#define SHOW_AS_H1S 0x00010000
|
2022-10-12 15:00:13 +00:00
|
|
|
#define SHOW_AS_FCONN 0x00020000
|
|
|
|
#define SHOW_AS_FSTRM 0x00040000
|
2024-04-25 07:43:16 +00:00
|
|
|
#define SHOW_AS_PEERS 0x00080000
|
|
|
|
#define SHOW_AS_PEER 0x00100000
|
2020-02-06 07:33:08 +00:00
|
|
|
|
|
|
|
// command line names, must be in exact same order as the SHOW_AS_* flags above
|
|
|
|
// so that show_as_words[i] matches flag 1U<<i.
|
2024-04-25 07:43:16 +00:00
|
|
|
const char *show_as_words[] = { "ana", "chn", "conn", "sc", "stet", "strm", "task", "txn", "sd", "hsl", "htx", "hmsg", "fd", "h2c", "h2s", "h1c", "h1s", "fconn", "fstrm",
|
|
|
|
"peers", "peer"};
|
2020-02-06 07:33:08 +00:00
|
|
|
|
2022-09-09 12:51:57 +00:00
|
|
|
/* will be sufficient for even largest flag names */
|
2022-09-09 14:47:43 +00:00
|
|
|
static char buf[4096];
|
|
|
|
static size_t bsz = sizeof(buf);
|
2022-09-09 12:51:57 +00:00
|
|
|
|
2020-02-06 07:33:08 +00:00
|
|
|
unsigned int get_show_as(const char *word)
|
|
|
|
{
|
|
|
|
int w = 0;
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
if (w == sizeof(show_as_words) / sizeof(*show_as_words))
|
|
|
|
return 0;
|
|
|
|
if (strcmp(word, show_as_words[w]) == 0)
|
|
|
|
return 1U << w;
|
|
|
|
w++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void usage_exit(const char *name)
|
|
|
|
{
|
2022-09-09 12:16:49 +00:00
|
|
|
int word, nbword;
|
|
|
|
|
|
|
|
fprintf(stderr, "Usage: %s [", name);
|
|
|
|
|
|
|
|
nbword = sizeof(show_as_words) / sizeof(*show_as_words);
|
|
|
|
for (word = 0; word < nbword; word++)
|
|
|
|
fprintf(stderr, "%s%s", word ? "|" : "", show_as_words[word]);
|
|
|
|
fprintf(stderr, "]* { [+-][0x]value* | - }\n");
|
2020-02-06 07:33:08 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2015-12-20 22:21:57 +00:00
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
unsigned int flags;
|
2020-02-06 07:33:08 +00:00
|
|
|
unsigned int show_as = 0;
|
|
|
|
unsigned int f;
|
|
|
|
const char *name = argv[0];
|
2020-02-06 17:17:50 +00:00
|
|
|
char line[20];
|
|
|
|
char *value;
|
2020-02-06 07:48:16 +00:00
|
|
|
int multi = 0;
|
2020-02-06 17:17:50 +00:00
|
|
|
int use_stdin = 0;
|
2020-02-06 07:33:08 +00:00
|
|
|
char *err;
|
|
|
|
|
|
|
|
while (argc > 0) {
|
|
|
|
argv++; argc--;
|
|
|
|
if (argc < 1)
|
|
|
|
usage_exit(name);
|
|
|
|
|
|
|
|
f = get_show_as(argv[0]);
|
2020-02-06 07:48:16 +00:00
|
|
|
if (!f)
|
|
|
|
break;
|
2020-02-06 07:33:08 +00:00
|
|
|
show_as |= f;
|
2015-12-20 22:21:57 +00:00
|
|
|
}
|
|
|
|
|
2020-02-06 07:33:08 +00:00
|
|
|
if (!show_as)
|
|
|
|
show_as = ~0U;
|
|
|
|
|
2020-02-06 07:48:16 +00:00
|
|
|
if (argc > 1)
|
|
|
|
multi = 1;
|
2015-12-20 22:21:57 +00:00
|
|
|
|
2020-02-06 17:17:50 +00:00
|
|
|
if (strcmp(argv[0], "-") == 0)
|
|
|
|
use_stdin = 1;
|
|
|
|
|
2020-02-06 07:48:16 +00:00
|
|
|
while (argc > 0) {
|
2020-02-06 17:17:50 +00:00
|
|
|
if (use_stdin) {
|
|
|
|
value = fgets(line, sizeof(line), stdin);
|
|
|
|
if (!value)
|
|
|
|
break;
|
|
|
|
|
2020-04-02 10:25:26 +00:00
|
|
|
/* skip common leading delimiters that slip from copy-paste */
|
2020-02-06 17:17:50 +00:00
|
|
|
while (*value == ' ' || *value == '\t' || *value == ':' || *value == '=')
|
|
|
|
value++;
|
|
|
|
|
|
|
|
/* stop at the end of the number and trim any C suffix like "UL" */
|
|
|
|
err = value;
|
|
|
|
while (*err == '-' || *err == '+' ||
|
2021-04-02 15:47:21 +00:00
|
|
|
(isalnum((unsigned char)*err) && toupper((unsigned char)*err) != 'U' && toupper((unsigned char)*err) != 'L'))
|
2020-02-06 17:17:50 +00:00
|
|
|
err++;
|
2021-04-03 13:26:56 +00:00
|
|
|
*err = 0;
|
2020-02-06 17:17:50 +00:00
|
|
|
} else {
|
|
|
|
value = argv[0];
|
|
|
|
argv++; argc--;
|
|
|
|
}
|
|
|
|
|
|
|
|
flags = strtoul(value, &err, 0);
|
|
|
|
if (!*value || *err) {
|
|
|
|
fprintf(stderr, "Unparsable value: <%s>\n", value);
|
2020-02-06 07:48:16 +00:00
|
|
|
usage_exit(name);
|
|
|
|
}
|
|
|
|
|
2020-02-06 17:17:50 +00:00
|
|
|
if (multi || use_stdin)
|
2020-02-06 07:48:16 +00:00
|
|
|
printf("### 0x%08x:\n", flags);
|
|
|
|
|
2022-09-09 14:47:43 +00:00
|
|
|
if (show_as & SHOW_AS_ANA) printf("chn->ana = %s\n", (chn_show_analysers(buf, bsz, " | ", flags), buf));
|
|
|
|
if (show_as & SHOW_AS_CHN) printf("chn->flags = %s\n", (chn_show_flags (buf, bsz, " | ", flags), buf));
|
|
|
|
if (show_as & SHOW_AS_CONN) printf("conn->flags = %s\n", (conn_show_flags (buf, bsz, " | ", flags), buf));
|
|
|
|
if (show_as & SHOW_AS_SC) printf("sc->flags = %s\n", (sc_show_flags (buf, bsz, " | ", flags), buf));
|
|
|
|
if (show_as & SHOW_AS_SD) printf("sd->flags = %s\n", (se_show_flags (buf, bsz, " | ", flags), buf));
|
|
|
|
if (show_as & SHOW_AS_SET) printf("strm->et = %s\n", (strm_et_show_flags(buf, bsz, " | ", flags), buf));
|
|
|
|
if (show_as & SHOW_AS_STRM) printf("strm->flags = %s\n", (strm_show_flags (buf, bsz, " | ", flags), buf));
|
|
|
|
if (show_as & SHOW_AS_TASK) printf("task->state = %s\n", (task_show_state (buf, bsz, " | ", flags), buf));
|
|
|
|
if (show_as & SHOW_AS_TXN) printf("txn->flags = %s\n", (txn_show_flags (buf, bsz, " | ", flags), buf));
|
2022-09-09 14:59:29 +00:00
|
|
|
if (show_as & SHOW_AS_HSL) printf("sl->flags = %s\n", (hsl_show_flags (buf, bsz, " | ", flags), buf));
|
|
|
|
if (show_as & SHOW_AS_HTX) printf("htx->flags = %s\n", (htx_show_flags (buf, bsz, " | ", flags), buf));
|
2022-09-09 15:18:57 +00:00
|
|
|
if (show_as & SHOW_AS_HMSG) printf("hmsg->flags = %s\n", (hmsg_show_flags (buf, bsz, " | ", flags), buf));
|
2022-09-12 16:53:06 +00:00
|
|
|
if (show_as & SHOW_AS_FD) printf("fd->flags = %s\n", (fd_show_flags (buf, bsz, " | ", flags), buf));
|
2022-09-12 17:20:23 +00:00
|
|
|
if (show_as & SHOW_AS_H2C) printf("h2c->flags = %s\n", (h2c_show_flags (buf, bsz, " | ", flags), buf));
|
|
|
|
if (show_as & SHOW_AS_H2S) printf("h2s->flags = %s\n", (h2s_show_flags (buf, bsz, " | ", flags), buf));
|
2022-09-15 08:54:36 +00:00
|
|
|
if (show_as & SHOW_AS_H1C) printf("h1c->flags = %s\n", (h1c_show_flags (buf, bsz, " | ", flags), buf));
|
|
|
|
if (show_as & SHOW_AS_H1S) printf("h1s->flags = %s\n", (h1s_show_flags (buf, bsz, " | ", flags), buf));
|
2022-10-12 15:00:13 +00:00
|
|
|
if (show_as & SHOW_AS_FCONN) printf("fconn->flags = %s\n",(fconn_show_flags (buf, bsz, " | ", flags), buf));
|
|
|
|
if (show_as & SHOW_AS_FSTRM) printf("fstrm->flags = %s\n",(fstrm_show_flags (buf, bsz, " | ", flags), buf));
|
2024-04-25 07:43:16 +00:00
|
|
|
if (show_as & SHOW_AS_PEERS) printf("peers->flags = %s\n",(peers_show_flags (buf, bsz, " | ", flags), buf));
|
|
|
|
if (show_as & SHOW_AS_PEER) printf("peer->flags = %s\n", (peer_show_flags (buf, bsz, " | ", flags), buf));
|
2020-02-06 07:48:16 +00:00
|
|
|
}
|
2015-12-20 22:21:57 +00:00
|
|
|
return 0;
|
|
|
|
}
|