ospf6d: add SNMP notifications/traps support
Only implement ospfv3NbrStateChange and ospfv3IfStateChange.
diff --git a/ospf6d/ospf6_snmp.c b/ospf6d/ospf6_snmp.c
index ce49331..a42e57a 100644
--- a/ospf6d/ospf6_snmp.c
+++ b/ospf6d/ospf6_snmp.c
@@ -204,6 +204,7 @@
/* OSPFv3-MIB instances. */
oid ospfv3_oid [] = { OSPFv3MIB };
+oid ospfv3_trap_oid [] = { OSPFv3MIB, 0 };
/* Hook functions. */
static u_char *ospfv3GeneralGroup (struct variable *, oid *, size_t *,
@@ -1110,6 +1111,61 @@
return NULL;
}
+/* OSPF Traps. */
+#define NBRSTATECHANGE 2
+#define IFSTATECHANGE 10
+
+static struct trap_object ospf6NbrTrapList[] =
+{
+ {-3, {1, 1, OSPFv3ROUTERID}},
+ {4, {1, 9, 1, OSPFv3NBRADDRESSTYPE}},
+ {4, {1, 9, 1, OSPFv3NBRADDRESS}},
+ {4, {1, 9, 1, OSPFv3NBRSTATE}}
+};
+
+static struct trap_object ospf6IfTrapList[] =
+{
+ {-3, {1, 1, OSPFv3ROUTERID}},
+ {4, {1, 7, 1, OSPFv3IFSTATE}},
+ {4, {1, 7, 1, OSPFv3IFADMINSTATUS}},
+ {4, {1, 7, 1, OSPFv3IFAREAID}}
+};
+
+void
+ospf6TrapNbrStateChange (struct ospf6_neighbor *on)
+{
+ oid index[3];
+
+ index[0] = on->ospf6_if->interface->ifindex;
+ index[1] = on->ospf6_if->instance_id;
+ index[2] = ntohl (on->router_id);
+
+ smux_trap (ospfv3_variables, sizeof ospfv3_variables / sizeof (struct variable),
+ ospfv3_trap_oid, sizeof ospfv3_trap_oid / sizeof (oid),
+ ospfv3_oid, sizeof ospfv3_oid / sizeof (oid),
+ index, 3,
+ ospf6NbrTrapList,
+ sizeof ospf6NbrTrapList / sizeof (struct trap_object),
+ NBRSTATECHANGE);
+}
+
+void
+ospf6TrapIfStateChange (struct ospf6_interface *oi)
+{
+ oid index[2];
+
+ index[0] = oi->interface->ifindex;
+ index[1] = oi->instance_id;
+
+ smux_trap (ospfv3_variables, sizeof ospfv3_variables / sizeof (struct variable),
+ ospfv3_trap_oid, sizeof ospfv3_trap_oid / sizeof (oid),
+ ospfv3_oid, sizeof ospfv3_oid / sizeof (oid),
+ index, 2,
+ ospf6IfTrapList,
+ sizeof ospf6IfTrapList / sizeof (struct trap_object),
+ IFSTATECHANGE);
+}
+
/* Register OSPFv3-MIB. */
void
ospf6_snmp_init (struct thread_master *master)