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_spf.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_spf.c')
| -rw-r--r-- | ospfd/ospf_spf.c | 27 | 
1 files changed, 27 insertions, 0 deletions
diff --git a/ospfd/ospf_spf.c b/ospfd/ospf_spf.c index dfeb80bd17..e9e1882956 100644 --- a/ospfd/ospf_spf.c +++ b/ospfd/ospf_spf.c @@ -994,6 +994,33 @@ static void ospf_spf_dump(struct vertex *v, int i)  		ospf_spf_dump(v, i);  } +void ospf_spf_print(struct vty *vty, struct vertex *v, int i) +{ +	struct listnode *cnode; +	struct listnode *nnode; +	struct vertex_parent *parent; + +	if (v->type == OSPF_VERTEX_ROUTER) { +		vty_out(vty, "SPF Result: depth %d [R] %s\n", i, +			inet_ntoa(v->lsa->id)); +	} else { +		struct network_lsa *lsa = (struct network_lsa *)v->lsa; +		vty_out(vty, "SPF Result: depth %d [N] %s/%d\n", i, +			inet_ntoa(v->lsa->id), ip_masklen(lsa->mask)); +	} + +	for (ALL_LIST_ELEMENTS_RO(v->parents, nnode, parent)) { +		vty_out(vty, " nexthop %s lsa pos %d\n", +			inet_ntoa(parent->nexthop->router), +			parent->nexthop->lsa_pos); +	} + +	i++; + +	for (ALL_LIST_ELEMENTS_RO(v->children, cnode, v)) +		ospf_spf_print(vty, v, i); +} +  /* Second stage of SPF calculation. */  static void ospf_spf_process_stubs(struct ospf_area *area, struct vertex *v,  				   struct route_table *rt, int parent_is_root)  | 
