org.snmp4j.smi.Null Java Examples

The following examples show how to use org.snmp4j.smi.Null. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SNMPHelper.java    From SuitAgent with Apache License 2.0 6 votes vote down vote up
private static boolean checkWalkFinished(OID targetOID, PDU pdu, VariableBinding vb) {
    boolean finished = false;
    if (pdu.getErrorStatus() != 0) {
        finished = true;
    } else if (vb.getOid() == null) {
        finished = true;
    } else if (vb.getOid().size() < targetOID.size()) {
        finished = true;
    } else if (targetOID.leftMostCompare(targetOID.size(), vb.getOid()) != 0) {
        finished = true;
    } else if (Null.isExceptionSyntax(vb.getVariable().getSyntax())) {
        finished = true;
    } else if (vb.getOid().compareTo(targetOID) <= 0) {
        finished = true;
    }
    return finished;

}
 
Example #2
Source File: SNMPHelper.java    From OpenFalcon-SuitAgent with Apache License 2.0 6 votes vote down vote up
private static boolean checkWalkFinished(OID targetOID, PDU pdu, VariableBinding vb) {
    boolean finished = false;
    if (pdu.getErrorStatus() != 0) {
        finished = true;
    } else if (vb.getOid() == null) {
        finished = true;
    } else if (vb.getOid().size() < targetOID.size()) {
        finished = true;
    } else if (targetOID.leftMostCompare(targetOID.size(), vb.getOid()) != 0) {
        finished = true;
    } else if (Null.isExceptionSyntax(vb.getVariable().getSyntax())) {
        finished = true;
    } else if (vb.getOid().compareTo(targetOID) <= 0) {
        finished = true;
    }
    return finished;

}
 
Example #3
Source File: MOGroup.java    From snmpman with Apache License 2.0 5 votes vote down vote up
@Override
public void get(final SubRequest request) {
    final OID oid = request.getVariableBinding().getOid();
    final Variable variable = variableBindings.get(oid);
    if (variable == null) {
        request.getVariableBinding().setVariable(Null.noSuchInstance);
    } else {
        request.getVariableBinding().setVariable((Variable) variable.clone());
    }
    request.completed();
}
 
Example #4
Source File: MOGroup.java    From snmpman with Apache License 2.0 5 votes vote down vote up
@Override
public boolean next(final SubRequest request) {
    final MOScope scope = request.getQuery().getScope();
    final SortedMap<OID, Variable> tail = variableBindings.tailMap(scope.getLowerBound());
    OID first = tail.firstKey();
    if (scope.getLowerBound().equals(first) && !scope.isLowerIncluded()) {
        if (tail.size() > 1) {
            final Iterator<OID> it = tail.keySet().iterator();
            it.next();
            first = it.next();
        } else {
            return false;
        }
    }
    if (first != null) {
        final Variable variable = variableBindings.get(first);
        // TODO remove try / catch if no more errors occur
        // TODO add configuration check with types though (e.g. UInt32 == UInt32 Modifier?)
        try {
            if (variable == null) {
                request.getVariableBinding().setVariable(Null.noSuchInstance);
            } else {
                request.getVariableBinding().setVariable((Variable) variable.clone());
            }
            request.getVariableBinding().setOid(first);
        } catch (IllegalArgumentException e) {
            if (variable != null) {
                log.error("error occurred on variable class " + variable.getClass().getName() + " with first OID " + first.toDottedString(), e);
            }
        }
        request.completed();
        return true;
    }
    return false;
}