summaryrefslogtreecommitdiffstats
path: root/pimd/pim_cmd_common.c
diff options
context:
space:
mode:
authorDonald Sharp <donaldsharp72@gmail.com>2022-08-11 14:32:32 +0200
committerGitHub <noreply@github.com>2022-08-11 14:32:32 +0200
commit23f85c8dadf55ba90038262a74266f8eecbf41b6 (patch)
treee4f8124d50c6c68fce9707d757d9cf931c697ac8 /pimd/pim_cmd_common.c
parentMerge pull request #11782 from AbhishekNR/ttable_mroute_count (diff)
parentpimd, pim6d: Using ttable for displaying "show ip/ipv6 mroute" command output. (diff)
downloadfrr-23f85c8dadf55ba90038262a74266f8eecbf41b6.tar.xz
frr-23f85c8dadf55ba90038262a74266f8eecbf41b6.zip
Merge pull request #11778 from AbhishekNR/ttable_mroute
pimd, pim6d: Using ttable for displaying output of show mroute commands
Diffstat (limited to 'pimd/pim_cmd_common.c')
-rw-r--r--pimd/pim_cmd_common.c48
1 files changed, 30 insertions, 18 deletions
diff --git a/pimd/pim_cmd_common.c b/pimd/pim_cmd_common.c
index 63751ac9d..1d3f5f430 100644
--- a/pimd/pim_cmd_common.c
+++ b/pimd/pim_cmd_common.c
@@ -3427,6 +3427,8 @@ void show_mroute(struct pim_instance *pim, struct vty *vty, pim_sgaddr *sg,
struct listnode *node;
struct channel_oil *c_oil;
struct static_route *s_route;
+ struct ttable *tt = NULL;
+ char *table = NULL;
time_t now;
json_object *json_group = NULL;
json_object *json_source = NULL;
@@ -3449,8 +3451,14 @@ void show_mroute(struct pim_instance *pim, struct vty *vty, pim_sgaddr *sg,
vty_out(vty, "Flags: S - Sparse, C - Connected, P - Pruned\n");
vty_out(vty,
" R - SGRpt Pruned, F - Register flag, T - SPT-bit set\n");
- vty_out(vty,
- "\nSource Group Flags Proto Input Output TTL Uptime\n");
+
+ /* Prepare table. */
+ tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]);
+ ttable_add_row(
+ tt, "Source|Group|Flags|Proto|Input|Output|TTL|Uptime");
+ tt->style.cell.rpad = 2;
+ tt->style.corner = '+';
+ ttable_restyle(tt);
}
now = pim_time_monotonic_sec();
@@ -3654,11 +3662,10 @@ void show_mroute(struct pim_instance *pim, struct vty *vty, pim_sgaddr *sg,
strlcpy(proto, "STAR", sizeof(proto));
}
- vty_out(vty,
- "%-15s %-15s %-8s %-6s %-16s %-16s %-3d %8s\n",
- src_str, grp_str, state_str, proto,
- in_ifname, out_ifname, ttl,
- mroute_uptime);
+ ttable_add_row(tt, "%s|%s|%s|%s|%s|%s|%d|%s",
+ src_str, grp_str, state_str,
+ proto, in_ifname, out_ifname,
+ ttl, mroute_uptime);
if (first) {
src_str[0] = '\0';
@@ -3672,11 +3679,10 @@ void show_mroute(struct pim_instance *pim, struct vty *vty, pim_sgaddr *sg,
}
if (!json && !found_oif) {
- vty_out(vty,
- "%-15pPAs %-15pPAs %-8s %-6s %-16s %-16s %-3d %8s\n",
- oil_origin(c_oil), oil_mcastgrp(c_oil),
- state_str, "none", in_ifname, "none", 0,
- "--:--:--");
+ ttable_add_row(tt, "%pPAs|%pPAs|%s|%s|%s|%s|%d|%s",
+ oil_origin(c_oil), oil_mcastgrp(c_oil),
+ state_str, "none", in_ifname, "none", 0,
+ "--:--:--");
}
}
@@ -3780,8 +3786,8 @@ void show_mroute(struct pim_instance *pim, struct vty *vty, pim_sgaddr *sg,
json_object_object_add(json_oil, out_ifname,
json_ifp_out);
} else {
- vty_out(vty,
- "%-15pPAs %-15pPAs %-8s %-6s %-16s %-16s %-3d %8s\n",
+ ttable_add_row(
+ tt, "%pPAs|%pPAs|%s|%s|%s|%s|%d|%s",
&s_route->source, &s_route->group, "-",
proto, in_ifname, out_ifname, ttl,
oif_uptime);
@@ -3795,12 +3801,18 @@ void show_mroute(struct pim_instance *pim, struct vty *vty, pim_sgaddr *sg,
}
if (!json && !found_oif) {
- vty_out(vty,
- "%-15pPAs %-15pPAs %-8s %-6s %-16s %-16s %-3d %8s\n",
- &s_route->source, &s_route->group, "-", proto,
- in_ifname, "none", 0, "--:--:--");
+ ttable_add_row(tt, "%pPAs|%pPAs|%s|%s|%s|%s|%d|%s",
+ &s_route->source, &s_route->group, "-",
+ proto, in_ifname, "none", 0, "--:--:--");
}
}
+ /* Dump the generated table. */
+ if (!json) {
+ table = ttable_dump(tt, "\n");
+ vty_out(vty, "%s\n", table);
+ XFREE(MTYPE_TMP, table);
+ ttable_del(tt);
+ }
}
static void show_mroute_count_per_channel_oil(struct channel_oil *c_oil,