summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Bernat <bernat@luffy.cx>2012-06-04 14:36:12 +0200
committerVincent Bernat <bernat@luffy.cx>2012-06-25 19:05:17 +0200
commitbf836661ef8ef880350bc41f0a82566ed5075066 (patch)
tree09fe0cfd070a3984860b1ffc89020caba892eff4
parentc349bb86927d1f5fc8aa8ebc6f553786f8e70634 (diff)
ospf6d: add SNMP notifications/traps support
Only implement ospfv3NbrStateChange and ospfv3IfStateChange.
-rw-r--r--ospf6d/ospf6_interface.c11
-rw-r--r--ospf6d/ospf6_neighbor.c9
-rw-r--r--ospf6d/ospf6_snmp.c56
-rw-r--r--ospf6d/ospf6_snmp.h2
4 files changed, 78 insertions, 0 deletions
diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c
index 6f7aaa8a..40cda246 100644
--- a/ospf6d/ospf6_interface.c
+++ b/ospf6d/ospf6_interface.c
@@ -421,6 +421,17 @@ ospf6_interface_state_change (u_char next_state, struct ospf6_interface *oi)
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 ab157ca8..806767dd 100644
--- a/ospf6d/ospf6_neighbor.c
+++ b/ospf6d/ospf6_neighbor.c
@@ -182,6 +182,15 @@ ospf6_neighbor_state_change (u_char next_state, struct ospf6_neighbor *on)
(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 ce49331c..a42e57ac 100644
--- a/ospf6d/ospf6_snmp.c
+++ b/ospf6d/ospf6_snmp.c
@@ -204,6 +204,7 @@ SNMP_LOCAL_VARIABLES
/* 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 @@ ospfv3NbrEntry (struct variable *v, oid *name, size_t *length,
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 5c67893c..fa1b0c37 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*/