]> git.puffer.fish Git - mirror/frr.git/commitdiff
2005-09-29 Alain Ritoux <alain.ritoux@6wind.com>
authorvincent <vincent>
Thu, 29 Sep 2005 16:34:30 +0000 (16:34 +0000)
committervincent <vincent>
Thu, 29 Sep 2005 16:34:30 +0000 (16:34 +0000)
    * lib/smux.[ch]: allow to retreive global OID (identified by <0
      namelen).
    * ospf_ism.c: generate SNMP traps on Interface state change
    * ospf_nsm.c: generate SNMP traps on Neighbour state change
    * ospf_snmp.[ch]: support for SNMP traps for interface and neighbours.

lib/ChangeLog
lib/smux.c
lib/smux.h
ospfd/ChangeLog
ospfd/ospf_ism.c
ospfd/ospf_nsm.c
ospfd/ospf_snmp.c
ospfd/ospf_snmp.h

index 2a8256f8ec3ad25d88dfd8a00bddd9f8379aaa99..fd3feffacb906f1d3eb29dbf284bad236bf6a0f0 100644 (file)
@@ -1,3 +1,8 @@
+2005-09-29 Alain Ritoux <alain.ritoux@6wind.com>
+
+       * smux.[ch]: allow to retreive global OID (identified by <0
+         namelen).
+
 2005-09-29 Paul Jakma <paul.jakma@sun.com>
 
        * zebra.h: Solaris capabilities requires priv.h to be included.
index 28f402d886180cfefefb696189bfa0a8f9c1ad54..c9b7a8809d7a2e152538d40202453854c581b542 100644 (file)
@@ -1065,13 +1065,34 @@ smux_trap (oid *name, size_t namelen,
       u_char val_type;
 
       /* Make OID. */
-      oid_copy (oid, name, namelen);
-      oid_copy (oid + namelen, trapobj[i].name, trapobj[i].namelen);
-      oid_copy (oid + namelen + trapobj[i].namelen, iname, inamelen);
-      oid_len = namelen + trapobj[i].namelen + inamelen;
+      if (trapobj[i].namelen > 0) 
+        {
+          oid_copy (oid, name, namelen);
+          oid_copy (oid + namelen, trapobj[i].name, trapobj[i].namelen);
+          oid_copy (oid + namelen + trapobj[i].namelen, iname, inamelen);
+          oid_len = namelen + trapobj[i].namelen + inamelen;
+        }
+      else 
+        {
+          oid_copy (oid, name, namelen);
+          oid_copy (oid + namelen, trapobj[i].name, trapobj[i].namelen * (-1));
+          oid_len = namelen + trapobj[i].namelen * (-1) ;
+        }
 
-      if (debug_smux)
-       smux_oid_dump ("Trap", oid, oid_len);
+      if (debug_smux) 
+        {
+          smux_oid_dump ("Trap", name, namelen);
+          if (trapobj[i].namelen < 0)
+            smux_oid_dump ("Trap", 
+                           trapobj[i].name, (- 1) * (trapobj[i].namelen));
+          else 
+            {
+              smux_oid_dump ("Trap", trapobj[i].name, (trapobj[i].namelen));
+              smux_oid_dump ("Trap", iname, inamelen);
+            }
+          smux_oid_dump ("Trap", oid, oid_len);
+          zlog_info ("BUFSIZ: %d // oid_len: %d", BUFSIZ, oid_len);
+      }
 
       ret = smux_get (oid, &oid_len, 1, &val_type, &val, &val_len);
 
index a4f1718dfcf1b133ba6ad76ceea282ad9559b485..79d23e7065a25fdb65922aee0b18a8a7b1e379bf 100644 (file)
@@ -94,7 +94,7 @@ struct variable
   FindVarMethod *findVar;
 
   /* Suffix of the MIB. */
-  u_char namelen;
+  int namelen;
   oid name[MAX_OID_LEN];
 };
 
@@ -121,7 +121,7 @@ struct subtree
 struct trap_object
 {
   FindVarMethod *findVar;
-  u_char namelen;
+  int namelen;
   oid name[MAX_OID_LEN];
 };
 
index 2cc9a4fd7b0ee35321f944fd1f52a6b99b6b4914..be1e0f9167149eac36e4c421c1fa14cd83c9c44f 100644 (file)
@@ -1,3 +1,9 @@
+2005-09-29 Alain Ritoux <alain.ritoux@6wind.com>
+
+       * ospf_ism.c: generate SNMP traps on Interface state change
+       * ospf_nsm.c: generate SNMP traps on Neighbour state change
+       * ospf_snmp.[ch]: support for SNMP traps for interface and neighbours.
+
 2005-09-29 Alain Ritoux <alain.ritoux@6wind.com>
 
        * ospf_vty.c: forece default route LSA to be re_issued whenever
index b251e59063a8b7621465201f9089336c28c3ced0..ab91e8d88e0f09f31b6785a4acc7b5f70c110b03 100644 (file)
@@ -43,6 +43,7 @@
 #include "ospfd/ospf_packet.h"
 #include "ospfd/ospf_flood.h"
 #include "ospfd/ospf_abr.h"
+#include "ospfd/ospf_snmp.h"
 \f
 /* elect DR and BDR. Refer to RFC2319 section 9.4 */
 static struct ospf_neighbor *
@@ -552,6 +553,20 @@ ism_change_state (struct ospf_interface *oi, int state)
   oi->state = state;
   oi->state_change++;
 
+#ifdef HAVE_SNMP
+  /* Terminal state or regression */ 
+  if ((state == ISM_DR) || (state == ISM_Backup) || (state == ISM_DROther) ||
+      (state == ISM_PointToPoint) || (state < old_state))
+    {
+      /* ospfVirtIfStateChange */
+      if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
+        ospfTrapVirtIfStateChange (oi);
+      /* ospfIfStateChange */
+      else
+        ospfTrapIfStateChange (oi);
+    }
+#endif
+
   /* Set multicast memberships appropriately for new state. */
   ospf_if_set_multicast(oi);
 
index 2af4fc187c34af49ffe6b1006d083a41fb3d1bd4..1d100848c77252c2206b51f93b680efebea90cfe 100644 (file)
@@ -47,6 +47,7 @@
 #include "ospfd/ospf_dump.h"
 #include "ospfd/ospf_flood.h"
 #include "ospfd/ospf_abr.h"
+#include "ospfd/ospf_snmp.h"
 
 void nsm_reset_nbr (struct ospf_neighbor *);
 
@@ -692,6 +693,22 @@ nsm_change_state (struct ospf_neighbor *nbr, int state)
   if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
     vl_area = ospf_area_lookup_by_area_id (oi->ospf, oi->vl_data->vl_area_id);
   
+#ifdef HAVE_SNMP
+  /* Terminal state or regression */ 
+  if ((state == NSM_Full) || (state == NSM_TwoWay) || (state < old_state))
+    {
+      /* ospfVirtNbrStateChange */
+      if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
+        ospfTrapVirtNbrStateChange(nbr);
+      /* ospfNbrStateChange trap  */
+      else
+        /* To/From FULL, only managed by DR */
+        if (((state != NSM_Full) && (old_state != NSM_Full)) ||
+            (oi->state == ISM_DR))
+          ospfTrapNbrStateChange(nbr);
+    }
+#endif
+
   /* One of the neighboring routers changes to/from the FULL state. */
   if ((old_state != NSM_Full && state == NSM_Full) ||
       (old_state == NSM_Full && state != NSM_Full))
index bceb962e1326a3aa0442c7eae16903029e077680..05e4de8a4c3d524a4981a6c8d907b33f7ab05807 100644 (file)
@@ -2064,7 +2064,9 @@ ospf_snmp_nbr_lookup (struct ospf *ospf, struct in_addr *nbr_addr,
       for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
        if ((nbr = rn->info) != NULL
            && nbr != oi->nbr_self
+/* If EXACT match is needed, provide ALL entry found
            && nbr->state != NSM_Down
+ */
            && nbr->src.s_addr != 0)
          {
            if (IPV4_ADDR_SAME (&nbr->src, nbr_addr))
@@ -2475,6 +2477,112 @@ ospfAreaAggregateEntry (struct variable *v, oid *name, size_t *length,
   return NULL;
 }
 \f
+/* OSPF Traps. */
+#define IFSTATECHANGE      16
+#define VIRTIFSTATECHANGE   1
+#define NBRSTATECHANGE      2
+#define VIRTNBRSTATECHANGE  3
+
+struct trap_object ospfNbrTrapList[] =
+{
+  {ospfGeneralGroup, -2, {1, OSPFROUTERID}},
+  {ospfNbrEntry, 3, {10, 1, OSPFNBRIPADDR}},
+  {ospfNbrEntry, 3, {10, 1, OSPFNBRRTRID}},
+  {ospfNbrEntry, 3, {10, 1, OSPFNBRSTATE}}
+};
+
+
+struct trap_object ospfVirtNbrTrapList[] =
+{
+  {ospfGeneralGroup, -2, {1, 1}},
+  {ospfVirtNbrEntry, 3, {11, 1, OSPFVIRTNBRAREA}},
+  {ospfVirtNbrEntry, 3, {11, 1, OSPFVIRTNBRRTRID}},
+  {ospfVirtNbrEntry, 3, {11, 1, OSPFVIRTNBRSTATE}}
+};
+
+struct trap_object ospfIfTrapList[] =
+{
+  {ospfGeneralGroup, -2, {1, OSPFROUTERID}},
+  {ospfIfEntry, 3, {7, 1, OSPFIFIPADDRESS}},
+  {ospfIfEntry, 3, {7, 1, OSPFADDRESSLESSIF}},
+  {ospfIfEntry, 3, {7, 1, OSPFIFSTATE}}
+};
+
+struct trap_object ospfVirtIfTrapList[] =
+{
+  {ospfGeneralGroup, -2, {1, OSPFROUTERID}},
+  {ospfVirtIfEntry, 3, {9, 1, OSPFVIRTIFAREAID}},
+  {ospfVirtIfEntry, 3, {9, 1, OSPFVIRTIFNEIGHBOR}},
+  {ospfVirtIfEntry, 3, {9, 1, OSPFVIRTIFSTATE}}
+};
+
+void
+ospfTrapNbrStateChange (struct ospf_neighbor *on)
+{
+  oid index[sizeof (oid) * (IN_ADDR_SIZE + 1)];
+  
+  zlog (NULL, LOG_INFO, "ospfTrapNbrStateChange trap sent");
+
+  oid_copy_addr (index, &(on->address.u.prefix4), IN_ADDR_SIZE);
+  index[IN_ADDR_SIZE] = 0;
+
+  smux_trap (ospf_oid, sizeof ospf_oid / sizeof (oid),
+             index,  IN_ADDR_SIZE + 1,
+             ospfNbrTrapList, 
+             sizeof ospfNbrTrapList / sizeof (struct trap_object),
+             time (NULL), NBRSTATECHANGE);
+}
+
+void
+ospfTrapVirtNbrStateChange (struct ospf_neighbor *on)
+{
+  oid index[sizeof (oid) * (IN_ADDR_SIZE + 1)];
+  
+  zlog (NULL, LOG_INFO, "ospfTrapVirtNbrStateChange trap sent");
+
+  oid_copy_addr (index, &(on->address.u.prefix4), IN_ADDR_SIZE);
+  index[IN_ADDR_SIZE] = 0;
+
+  smux_trap (ospf_oid, sizeof ospf_oid / sizeof (oid),
+             index,  IN_ADDR_SIZE + 1,
+             ospfVirtNbrTrapList, 
+             sizeof ospfVirtNbrTrapList / sizeof (struct trap_object),
+             time (NULL), VIRTNBRSTATECHANGE);
+}
+
+void
+ospfTrapIfStateChange (struct ospf_interface *oi)
+{
+  oid index[sizeof (oid) * (IN_ADDR_SIZE + 1)];
+
+  zlog (NULL, LOG_INFO, "ospfTrapIfStateChange trap sent");
+  
+  oid_copy_addr (index, &(oi->address->u.prefix4), IN_ADDR_SIZE);
+  index[IN_ADDR_SIZE] = 0;
+
+  smux_trap (ospf_oid, sizeof ospf_oid / sizeof (oid),
+             index, IN_ADDR_SIZE + 1,
+             ospfIfTrapList, 
+             sizeof ospfIfTrapList / sizeof (struct trap_object),
+             time (NULL), IFSTATECHANGE);
+}
+
+void
+ospfTrapVirtIfStateChange (struct ospf_interface *oi)
+{
+  oid index[sizeof (oid) * (IN_ADDR_SIZE + 1)];
+
+  zlog (NULL, LOG_INFO, "ospfTrapVirtIfStateChange trap sent");
+  
+  oid_copy_addr (index, &(oi->address->u.prefix4), IN_ADDR_SIZE);
+  index[IN_ADDR_SIZE] = 0;
+
+  smux_trap (ospf_oid, sizeof ospf_oid / sizeof (oid),
+             index, IN_ADDR_SIZE + 1,
+             ospfVirtIfTrapList,
+             sizeof ospfVirtIfTrapList / sizeof (struct trap_object),
+             time (NULL), VIRTIFSTATECHANGE);
+}
 /* Register OSPF2-MIB. */
 void
 ospf_snmp_init ()
index 8b561b033e9cdc6da2174cee5bb5969618306edb..413d1d7f794dd59de485a24609ca0b9e26739aa1 100644 (file)
@@ -30,4 +30,9 @@ extern void ospf_snmp_if_delete (struct interface *);
 extern void ospf_snmp_vl_add (struct ospf_vl_data *);
 extern void ospf_snmp_vl_delete (struct ospf_vl_data *);
 
+extern void ospfTrapIfStateChange (struct ospf_interface *);
+extern void ospfTrapVirtIfStateChange (struct ospf_interface *);
+extern void ospfTrapNbrStateChange (struct ospf_neighbor *);
+extern void ospfTrapVirtNbrStateChange (struct ospf_neighbor *);
+
 #endif /* _ZEBRA_OSPF_SNMP_H */