From 99deb321fcbd6b0519d21ccc1498e88341bd6bd7 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 7 Sep 2016 15:34:29 -0400 Subject: [PATCH] pimd: Add the ability to lookup neighbor on a interface On a specified interface return the single neighbor on that interface. Signed-off-by: Donald Sharp --- pimd/pim_neighbor.c | 16 ++++++++++++++++ pimd/pim_neighbor.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/pimd/pim_neighbor.c b/pimd/pim_neighbor.c index 61e19d8005..ba2fc753b3 100644 --- a/pimd/pim_neighbor.c +++ b/pimd/pim_neighbor.c @@ -403,6 +403,22 @@ struct pim_neighbor *pim_neighbor_find(struct interface *ifp, return 0; } +/* + * Find the *one* interface out + * this interface. If more than + * one return NULL + */ +struct pim_neighbor * +pim_neighbor_find_if (struct interface *ifp) +{ + struct pim_interface *pim_ifp = ifp->info; + + if (pim_ifp->pim_neighbor_list->count != 1) + return NULL; + + return listnode_head (pim_ifp->pim_neighbor_list); +} + struct pim_neighbor *pim_neighbor_add(struct interface *ifp, struct in_addr source_addr, pim_hello_options hello_options, diff --git a/pimd/pim_neighbor.h b/pimd/pim_neighbor.h index 4bf78d063e..3f5a121d4c 100644 --- a/pimd/pim_neighbor.h +++ b/pimd/pim_neighbor.h @@ -48,6 +48,8 @@ void pim_neighbor_free(struct pim_neighbor *neigh); struct pim_neighbor *pim_neighbor_find(struct interface *ifp, struct in_addr source_addr); +struct pim_neighbor *pim_neighbor_find_if (struct interface *ifp); + #define PIM_NEIGHBOR_SEND_DELAY 0 #define PIM_NEIGHBOR_SEND_NOW 1 -- 2.39.5