summaryrefslogtreecommitdiff
path: root/pimd/pim_neighbor.c
diff options
context:
space:
mode:
Diffstat (limited to 'pimd/pim_neighbor.c')
-rw-r--r--pimd/pim_neighbor.c88
1 files changed, 53 insertions, 35 deletions
diff --git a/pimd/pim_neighbor.c b/pimd/pim_neighbor.c
index 181a71210c..00190bd830 100644
--- a/pimd/pim_neighbor.c
+++ b/pimd/pim_neighbor.c
@@ -1,22 +1,21 @@
/*
- PIM for Quagga
- Copyright (C) 2008 Everton da Silva Marques
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING; if not, write to the
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- MA 02110-1301 USA
-*/
+ * PIM for Quagga
+ * Copyright (C) 2008 Everton da Silva Marques
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
#include <zebra.h>
@@ -262,9 +261,8 @@ void pim_neighbor_timer_reset(struct pim_neighbor *neigh, uint16_t holdtime)
neigh->holdtime, src_str, neigh->interface->name);
}
- THREAD_TIMER_ON(master, neigh->t_expire_timer,
- on_neighbor_timer,
- neigh, neigh->holdtime);
+ thread_add_timer(master, on_neighbor_timer, neigh, neigh->holdtime,
+ &neigh->t_expire_timer);
}
static int
@@ -286,9 +284,8 @@ on_neighbor_jp_timer (struct thread *t)
rpf.rpf_addr.u.prefix4 = neigh->source_addr;
pim_joinprune_send(&rpf, neigh->upstream_jp_agg);
- THREAD_TIMER_ON(master, neigh->jp_timer,
- on_neighbor_jp_timer,
- neigh, qpim_t_periodic);
+ thread_add_timer(master, on_neighbor_jp_timer, neigh, qpim_t_periodic,
+ &neigh->jp_timer);
return 0;
}
@@ -297,9 +294,8 @@ static void
pim_neighbor_start_jp_timer (struct pim_neighbor *neigh)
{
THREAD_TIMER_OFF(neigh->jp_timer);
- THREAD_TIMER_ON(master, neigh->jp_timer,
- on_neighbor_jp_timer,
- neigh, qpim_t_periodic);
+ thread_add_timer(master, on_neighbor_jp_timer, neigh, qpim_t_periodic,
+ &neigh->jp_timer);
}
static struct pim_neighbor *pim_neighbor_new(struct interface *ifp,
@@ -423,6 +419,31 @@ void pim_neighbor_free(struct pim_neighbor *neigh)
XFREE(MTYPE_PIM_NEIGHBOR, neigh);
}
+struct pim_neighbor *
+pim_neighbor_find_by_secondary (struct interface *ifp,
+ struct prefix *src)
+{
+ struct pim_interface *pim_ifp;
+ struct listnode *node, *pnode;
+ struct pim_neighbor *neigh;
+ struct prefix *p;
+
+ pim_ifp = ifp->info;
+ if (!pim_ifp)
+ return NULL;
+
+ for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, node, neigh))
+ {
+ for (ALL_LIST_ELEMENTS_RO(neigh->prefix_list, pnode, p))
+ {
+ if (prefix_same (p, src))
+ return neigh;
+ }
+ }
+
+ return NULL;
+}
+
struct pim_neighbor *pim_neighbor_find(struct interface *ifp,
struct in_addr source_addr)
{
@@ -686,7 +707,7 @@ void pim_neighbor_delete_all(struct interface *ifp,
}
struct prefix *pim_neighbor_find_secondary(struct pim_neighbor *neigh,
- struct in_addr addr)
+ struct prefix *addr)
{
struct listnode *node;
struct prefix *p;
@@ -695,14 +716,11 @@ struct prefix *pim_neighbor_find_secondary(struct pim_neighbor *neigh,
return 0;
for (ALL_LIST_ELEMENTS_RO(neigh->prefix_list, node, p)) {
- if (p->family == AF_INET) {
- if (addr.s_addr == p->u.prefix4.s_addr) {
- return p;
- }
- }
+ if (prefix_same (p, addr))
+ return p;
}
- return 0;
+ return NULL;
}
/*
@@ -746,7 +764,7 @@ static void delete_from_neigh_addr(struct interface *ifp,
for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neigh_node,
neigh)) {
{
- struct prefix *p = pim_neighbor_find_secondary(neigh, addr->u.prefix4);
+ struct prefix *p = pim_neighbor_find_secondary(neigh, addr);
if (p) {
char addr_str[INET_ADDRSTRLEN];
char this_neigh_str[INET_ADDRSTRLEN];