[SNMP4J] Notification filtering

Matthias Wiesmann matthias.wiesmann at gmail.com
Fri Feb 10 02:55:41 CET 2006


hello everybody,

I managed to get the first part of the passesFilter function to work.
I added two methods to create the lexicographic successor and the next
peer to the oid class. I also patched the mask function to correctly
handle empty strings (I put the OID class in attachement), actually,
the mask function should be corrected to handle the case where the
mask is shorter that the OID.  There also seems to be a bogus value
(0) for the idxSnmpNotifyFilterSubtree field, it is defined a 0, but I
suspect it should be 1.

Notification filtering does not work by itself, I get null pointer
exceptions, so there seem to be some bugs in the way filter marches
are calculated. I will try to find out more later.

Cheers

Matthias

-----

public boolean passesFilter(OID paramsIndex, OID notificationID,
                              VariableBinding[] vbs) {
      MOTableRowFilter activeFilter =
      new RowStatus.ActiveRowsFilter(idxSnmpNotifyFilterProfileRowStatus);
      List profiles =
	  snmpNotifyFilterProfileEntryModel.getRows(paramsIndex,
paramsIndex.successor(),
						    activeFilter);
      if (profiles.size() == 0) {
	  final OctetString params = new
OctetString(MOTableIndex.getBytes(paramsIndex)) ;
	  logger.info("found no matching profile for
"+paramsIndex+"("+params+") "+notificationID+" in
"+snmpNotifyFilterProfileEntryModel) ;
      // no profile -> passes filter
	
	  return true;
      }
      OctetString profileName = (OctetString)
((MOTableRow)profiles.get(0)).getValue(idxSnmpNotifyFilterProfileName);
      OID profileNameOID = MOTableIndex.createSubIndex(profileName,
false); // there seems to be a problem
      activeFilter = new
RowStatus.ActiveRowsFilter(idxSnmpNotifyFilterRowStatus);
      List filters =
        snmpNotifyFilterEntryModel.getRows(profileNameOID,
profileNameOID.nextPeer(),
                                           activeFilter);
    if (filters.size() == 0) {
	final OctetString params = new
OctetString(MOTableIndex.getBytes(profileNameOID)) ;
	logger.info("found no matching filter for
"+profileNameOID+"("+params+") "+notificationID+" in
"+snmpNotifyFilterEntryModel) ;
      // no filters -> no trap is sent
      return false;
    }


More information about the SNMP4J mailing list