summaryrefslogtreecommitdiff
path: root/ospf6d/ospf6_snmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'ospf6d/ospf6_snmp.c')
-rw-r--r--ospf6d/ospf6_snmp.c49
1 files changed, 40 insertions, 9 deletions
diff --git a/ospf6d/ospf6_snmp.c b/ospf6d/ospf6_snmp.c
index 86cfd17c83..96f1e3dd21 100644
--- a/ospf6d/ospf6_snmp.c
+++ b/ospf6d/ospf6_snmp.c
@@ -21,8 +21,6 @@
#include <zebra.h>
-#ifdef HAVE_SNMP
-
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
@@ -32,6 +30,8 @@
#include "vector.h"
#include "vrf.h"
#include "smux.h"
+#include "libfrr.h"
+#include "version.h"
#include "ospf6_proto.h"
#include "ospf6_lsa.h"
@@ -45,7 +45,6 @@
#include "ospf6_abr.h"
#include "ospf6_asbr.h"
#include "ospf6d.h"
-#include "ospf6_snmp.h"
/* OSPFv3-MIB */
#define OSPFv3MIB 1,3,6,1,2,1,191
@@ -1139,11 +1138,18 @@ static struct trap_object ospf6IfTrapList[] =
{4, {1, 7, 1, OSPFv3IFAREAID}}
};
-void
-ospf6TrapNbrStateChange (struct ospf6_neighbor *on)
+static int
+ospf6TrapNbrStateChange (struct ospf6_neighbor *on,
+ int next_state, int prev_state)
{
oid index[3];
+ /* Terminal state or regression */
+ if ((next_state != OSPF6_NEIGHBOR_FULL) &&
+ (next_state != OSPF6_NEIGHBOR_TWOWAY) &&
+ (next_state >= prev_state))
+ return 0;
+
index[0] = on->ospf6_if->interface->ifindex;
index[1] = on->ospf6_if->instance_id;
index[2] = ntohl (on->router_id);
@@ -1155,13 +1161,23 @@ ospf6TrapNbrStateChange (struct ospf6_neighbor *on)
ospf6NbrTrapList,
sizeof ospf6NbrTrapList / sizeof (struct trap_object),
NBRSTATECHANGE);
+ return 0;
}
-void
-ospf6TrapIfStateChange (struct ospf6_interface *oi)
+static int
+ospf6TrapIfStateChange (struct ospf6_interface *oi,
+ int next_state, int prev_state)
{
oid index[2];
+ /* Terminal state or regression */
+ if ((next_state != OSPF6_INTERFACE_POINTTOPOINT) &&
+ (next_state != OSPF6_INTERFACE_DROTHER) &&
+ (next_state != OSPF6_INTERFACE_BDR) &&
+ (next_state != OSPF6_INTERFACE_DR) &&
+ (next_state >= prev_state))
+ return 0;
+
index[0] = oi->interface->ifindex;
index[1] = oi->instance_id;
@@ -1172,15 +1188,30 @@ ospf6TrapIfStateChange (struct ospf6_interface *oi)
ospf6IfTrapList,
sizeof ospf6IfTrapList / sizeof (struct trap_object),
IFSTATECHANGE);
+ return 0;
}
/* Register OSPFv3-MIB. */
-void
+static int
ospf6_snmp_init (struct thread_master *master)
{
smux_init (master);
REGISTER_MIB ("OSPFv3MIB", ospfv3_variables, variable, ospfv3_oid);
+ return 0;
}
-#endif /* HAVE_SNMP */
+static int
+ospf6_snmp_module_init (void)
+{
+ hook_register(ospf6_interface_change, ospf6TrapIfStateChange);
+ hook_register(ospf6_neighbor_change, ospf6TrapNbrStateChange);
+ hook_register(frr_late_init, ospf6_snmp_init);
+ return 0;
+}
+FRR_MODULE_SETUP(
+ .name = "ospf6d_snmp",
+ .version = FRR_VERSION,
+ .description = "ospf6d AgentX SNMP module",
+ .init = ospf6_snmp_module_init,
+)