Skip to content

Commit fed314b

Browse files
committed
vllp: Add 'show vllp' CLI command
1 parent cd4240e commit fed314b

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

src/net/vllp.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <mios/timer.h>
1212
#include <mios/service.h>
1313
#include <mios/stream.h>
14+
#include <mios/cli.h>
1415

1516
#include <sys/param.h>
1617

@@ -929,3 +930,49 @@ vllp_server_create(uint32_t txid, uint32_t rxid, uint8_t mtu,
929930
LIST_INSERT_HEAD(&vllps, v, link);
930931
return v;
931932
}
933+
934+
static const char vllp_channel_state_strtbl[] = {
935+
"PENDING\0"
936+
"OPEN_SENT\0"
937+
"ESTABLISHED\0"
938+
"CLOSED_SEND\0"
939+
"\0"
940+
};
941+
942+
static const char vllp_channel_app_closed_strtbl[] = {
943+
"OPEN\0"
944+
"APP_CLOSED\0"
945+
"CLOSED_SENT\0"
946+
"\0"
947+
};
948+
949+
static const char vllp_channel_net_closed_strtbl[] = {
950+
"OPEN\0"
951+
"CLOSED\0"
952+
"\0"
953+
};
954+
955+
static error_t
956+
cmd_tcp(cli_t *cli, int argc, char **argv)
957+
{
958+
vllp_t *v;
959+
vllp_channel_t *vc;
960+
LIST_FOREACH(v, &vllps, link) {
961+
cli_printf(cli, "TX:0x%x RX:0x%x %sonnected", v->txid, v->rxid,
962+
v->connected ? "C" : "Disc");
963+
cli_printf(cli, " Flow status Local:0x%04x Remote:0x%04x\n",
964+
v->local_flow_status, v->remote_flow_status);
965+
cli_printf(cli, " Channels:\n");
966+
LIST_FOREACH(vc, &v->channels, link) {
967+
cli_printf(cli, " %2d : state:%s app:%s net:%s\n", vc->id,
968+
strtbl(vllp_channel_state_strtbl, vc->state),
969+
strtbl(vllp_channel_app_closed_strtbl, vc->app_closed),
970+
strtbl(vllp_channel_net_closed_strtbl, vc->net_closed));
971+
}
972+
973+
cli_printf(cli, "\n");
974+
}
975+
return 0;
976+
}
977+
978+
CLI_CMD_DEF_EXT("show_vllp", cmd_tcp, NULL, "Show VLLP connections");

0 commit comments

Comments
 (0)