diff options
| author | GalaxyGorilla <sascha@netdef.org> | 2020-08-12 11:58:54 +0000 |
|---|---|---|
| committer | GalaxyGorilla <sascha@netdef.org> | 2020-08-18 10:58:50 +0000 |
| commit | 3a76b1be886ba84a55eaf25bb0866b292c1ab428 (patch) | |
| tree | d788d9ba5791eb5d41f18a42d082edcec0be3579 /ospfd/ospf_route.c | |
| parent | 1d376ff539508f336cb5872c5592b780e3db180b (diff) | |
ospfd: add print helper for SPF trees and route tables
Signed-off-by: GalaxyGorilla <sascha@netdef.org>
Diffstat (limited to 'ospfd/ospf_route.c')
| -rw-r--r-- | ospfd/ospf_route.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/ospfd/ospf_route.c b/ospfd/ospf_route.c index 487275beec..3b049555ba 100644 --- a/ospfd/ospf_route.c +++ b/ospfd/ospf_route.c @@ -665,6 +665,37 @@ void ospf_route_table_dump(struct route_table *rt) zlog_debug("========================================"); } +void ospf_route_table_print(struct vty *vty, struct route_table *rt) +{ + struct route_node *rn; + struct ospf_route * or ; + struct listnode *pnode; + struct ospf_path *path; + + vty_out(vty, "========== OSPF routing table ==========\n"); + for (rn = route_top(rt); rn; rn = route_next(rn)) + if ((or = rn->info) != NULL) { + if (or->type == OSPF_DESTINATION_NETWORK) { + vty_out(vty, "N %-18pFX %-15pI4 %s %d\n", + &rn->p, & or->u.std.area_id, + ospf_path_type_str[or->path_type], + or->cost); + for (ALL_LIST_ELEMENTS_RO(or->paths, pnode, + path)) + vty_out(vty, " -> %s\n", + path->nexthop.s_addr != 0 + ? inet_ntoa( + path->nexthop) + : "directly connected"); + } else + vty_out(vty, "R %-18pI4 %-15pI4 %s %d\n", + &rn->p.u.prefix4, & or->u.std.area_id, + ospf_path_type_str[or->path_type], + or->cost); + } + vty_out(vty, "========================================\n"); +} + /* This is 16.4.1 implementation. o Intra-area paths using non-backbone areas are always the most preferred. o The other paths, intra-area backbone paths and inter-area paths, |
