summaryrefslogtreecommitdiff
path: root/ospfd/ospf_interface.c
diff options
context:
space:
mode:
authorChirag Shah <chirag@cumulusnetworks.com>2018-01-19 18:17:53 -0800
committerChirag Shah <chirag@cumulusnetworks.com>2018-01-20 19:30:59 -0800
commit2bc7673f110a92c7a20f170daf9b34d8c8190f8a (patch)
tree7464fddff1091feaece4468d6507536b60a5ade6 /ospfd/ospf_interface.c
parent4ff9eb721d5b089a86070f03282c3d0843194504 (diff)
ospfd: show ip ospf neighbor json output format
Current json output does not differentiate start of neighbor ip object. Adding "neighbors" keyword at the beginning of neighbor list. This is useful when displaying vrf level output along with neighbors list. Ticket:CM-19097 Testing Done: show ip ospf neighbor json show ip ospf vrf all neighbor json Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
Diffstat (limited to 'ospfd/ospf_interface.c')
-rw-r--r--ospfd/ospf_interface.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c
index e8700e7eb0..c8f758525e 100644
--- a/ospfd/ospf_interface.c
+++ b/ospfd/ospf_interface.c
@@ -51,6 +51,28 @@ DEFINE_QOBJ_TYPE(ospf_interface)
DEFINE_HOOK(ospf_vl_add, (struct ospf_vl_data * vd), (vd))
DEFINE_HOOK(ospf_vl_delete, (struct ospf_vl_data * vd), (vd))
+int ospf_interface_neighbor_count(struct ospf_interface *oi)
+{
+ int count = 0;
+ struct route_node *rn;
+ struct ospf_neighbor *nbr = NULL;
+
+ for (rn = route_top(oi->nbrs); rn; rn = route_next(rn)) {
+ nbr = rn->info;
+ if (nbr) {
+ /* Do not show myself. */
+ if (nbr == oi->nbr_self)
+ continue;
+ /* Down state is not shown. */
+ if (nbr->state == NSM_Down)
+ continue;
+ count++;
+ }
+ }
+
+ return count;
+}
+
int ospf_if_get_output_cost(struct ospf_interface *oi)
{
/* If all else fails, use default OSPF cost */