diff options
author | David Lamparter <equinox@opensourcerouting.org> | 2016-06-12 17:32:23 +0200 |
---|---|---|
committer | David Lamparter <equinox@opensourcerouting.org> | 2017-03-25 08:52:36 +0100 |
commit | 3012671ffadbd839626b5c0b0b1fd36b3698f582 (patch) | |
tree | 847bacd0156e5e8dc2e64cbfbbf10c2f6e3ac9ac /ripd | |
parent | build: split off libfrrsnmp (diff) | |
download | frr-3012671ffadbd839626b5c0b0b1fd36b3698f582.tar.xz frr-3012671ffadbd839626b5c0b0b1fd36b3698f582.zip |
*: use hooks for sending SNMP traps
This means there are no ties into the SNMP code anymore other than the
init call at startup.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'ripd')
-rw-r--r-- | ripd/rip_interface.c | 11 | ||||
-rw-r--r-- | ripd/rip_snmp.c | 20 | ||||
-rw-r--r-- | ripd/ripd.h | 7 |
3 files changed, 23 insertions, 15 deletions
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c index 4c750faf4..a4ee2ba57 100644 --- a/ripd/rip_interface.c +++ b/ripd/rip_interface.c @@ -42,6 +42,9 @@ #include "ripd/rip_debug.h" #include "ripd/rip_interface.h" +DEFINE_HOOK(rip_ifaddr_add, (struct connected *ifc), (ifc)) +DEFINE_HOOK(rip_ifaddr_del, (struct connected *ifc), (ifc)) + /* static prototypes */ static void rip_enable_apply (struct interface *); static void rip_passive_interface_apply (struct interface *); @@ -673,9 +676,7 @@ rip_interface_address_add (int command, struct zclient *zclient, /* Check if this prefix needs to be redistributed */ rip_apply_address_add(ifc); -#ifdef HAVE_SNMP - rip_ifaddr_add (ifc->ifp, ifc); -#endif /* HAVE_SNMP */ + hook_call(rip_ifaddr_add, ifc); } return 0; @@ -723,9 +724,7 @@ rip_interface_address_delete (int command, struct zclient *zclient, zlog_debug ("connected address %s/%d is deleted", inet_ntoa (p->u.prefix4), p->prefixlen); -#ifdef HAVE_SNMP - rip_ifaddr_delete (ifc->ifp, ifc); -#endif /* HAVE_SNMP */ + hook_call(rip_ifaddr_del, ifc); /* Chech wether this prefix needs to be removed */ rip_apply_address_del(ifc); diff --git a/ripd/rip_snmp.c b/ripd/rip_snmp.c index 36fd9c26e..bdae0409d 100644 --- a/ripd/rip_snmp.c +++ b/ripd/rip_snmp.c @@ -175,24 +175,27 @@ rip2Globals (struct variable *v, oid name[], size_t *length, return NULL; } -void -rip_ifaddr_add (struct interface *ifp, struct connected *ifc) +static int +rip_snmp_ifaddr_add (struct connected *ifc) { + struct interface *ifp = ifc->ifp; struct prefix *p; struct route_node *rn; p = ifc->address; if (p->family != AF_INET) - return; + return 0; rn = route_node_get (rip_ifaddr_table, p); rn->info = ifp; + return 0; } -void -rip_ifaddr_delete (struct interface *ifp, struct connected *ifc) +static int +rip_snmp_ifaddr_del (struct connected *ifc) { + struct interface *ifp = ifc->ifp; struct prefix *p; struct route_node *rn; struct interface *i; @@ -200,11 +203,11 @@ rip_ifaddr_delete (struct interface *ifp, struct connected *ifc) p = ifc->address; if (p->family != AF_INET) - return; + return 0; rn = route_node_lookup (rip_ifaddr_table, p); if (! rn) - return; + return 0; i = rn->info; if (rn && !strncmp(i->name,ifp->name,INTERFACE_NAMSIZ)) { @@ -212,6 +215,7 @@ rip_ifaddr_delete (struct interface *ifp, struct connected *ifc) route_unlock_node (rn); route_unlock_node (rn); } + return 0; } static struct interface * @@ -587,6 +591,8 @@ void rip_snmp_init () { rip_ifaddr_table = route_table_init (); + hook_register(rip_ifaddr_add, rip_snmp_ifaddr_add); + hook_register(rip_ifaddr_del, rip_snmp_ifaddr_del); smux_init (master); REGISTER_MIB("mibII/rip", rip_variables, variable, rip_oid); diff --git a/ripd/ripd.h b/ripd/ripd.h index 68b3d1fc6..66113cdc9 100644 --- a/ripd/ripd.h +++ b/ripd/ripd.h @@ -23,6 +23,7 @@ #define _ZEBRA_RIP_H #include "qobj.h" +#include "hook.h" #include "rip_memory.h" /* RIP version number. */ @@ -432,8 +433,6 @@ extern void rip_offset_clean (void); extern void rip_info_free (struct rip_info *); extern u_char rip_distance_apply (struct rip_info *); extern void rip_redistribute_clean (void); -extern void rip_ifaddr_add (struct interface *, struct connected *); -extern void rip_ifaddr_delete (struct interface *, struct connected *); extern struct rip_info *rip_ecmp_add (struct rip_info *); extern struct rip_info *rip_ecmp_replace (struct rip_info *); @@ -448,4 +447,8 @@ extern struct thread_master *master; /* RIP statistics for SNMP. */ extern long rip_global_route_changes; extern long rip_global_queries; + +DECLARE_HOOK(rip_ifaddr_add, (struct connected *ifc), (ifc)) +DECLARE_HOOK(rip_ifaddr_del, (struct connected *ifc), (ifc)) + #endif /* _ZEBRA_RIP_H */ |