ospf6d: add SNMP notifications/traps support

Only implement ospfv3NbrStateChange and ospfv3IfStateChange.
diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c
index 6f7aaa8..40cda24 100644
--- a/ospf6d/ospf6_interface.c
+++ b/ospf6d/ospf6_interface.c
@@ -421,6 +421,17 @@
       OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
       OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
     }
+
+#ifdef HAVE_SNMP
+  /* 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))
+    ospf6TrapIfStateChange (oi);
+#endif
+
 }
 
 
diff --git a/ospf6d/ospf6_neighbor.c b/ospf6d/ospf6_neighbor.c
index ab157ca..806767d 100644
--- a/ospf6d/ospf6_neighbor.c
+++ b/ospf6d/ospf6_neighbor.c
@@ -182,6 +182,15 @@
       (next_state != OSPF6_NEIGHBOR_EXCHANGE &&
        next_state != OSPF6_NEIGHBOR_LOADING))
     ospf6_maxage_remove (on->ospf6_if->area->ospf6);
+
+#ifdef HAVE_SNMP
+  /* Terminal state or regression */ 
+  if ((next_state == OSPF6_NEIGHBOR_FULL)  ||
+      (next_state == OSPF6_NEIGHBOR_TWOWAY) ||
+      (next_state < prev_state))
+    ospf6TrapNbrStateChange (on);
+#endif
+
 }
 
 /* RFC2328 section 10.4 */
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)
diff --git a/ospf6d/ospf6_snmp.h b/ospf6d/ospf6_snmp.h
index 5c67893..fa1b0c3 100644
--- a/ospf6d/ospf6_snmp.h
+++ b/ospf6d/ospf6_snmp.h
@@ -22,6 +22,8 @@
 #ifndef OSPF6_SNMP_H
 #define OSPF6_SNMP_H
 
+extern void ospf6TrapNbrStateChange (struct ospf6_neighbor *);
+extern void ospf6TrapIfStateChange (struct ospf6_interface *);
 extern void ospf6_snmp_init (struct thread_master *);
 
 #endif /*OSPF6_SNMP_H*/