|
11 | 11 | #include <mios/timer.h> |
12 | 12 | #include <mios/service.h> |
13 | 13 | #include <mios/stream.h> |
| 14 | +#include <mios/cli.h> |
14 | 15 |
|
15 | 16 | #include <sys/param.h> |
16 | 17 |
|
@@ -929,3 +930,49 @@ vllp_server_create(uint32_t txid, uint32_t rxid, uint8_t mtu, |
929 | 930 | LIST_INSERT_HEAD(&vllps, v, link); |
930 | 931 | return v; |
931 | 932 | } |
| 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