public boolean processChildError(int errorStatus, int errorIndex) throws SnmpException { int canonicalIndex = getCanonicalIndex(errorIndex-1); ChildTrackerPduBuilder childBuilder = getChildBuilder(canonicalIndex); int childIndex = childBuilder.getChildIndex(canonicalIndex); return childBuilder.getResponseProcessor().processErrors(errorStatus, childIndex+1); }
public static SnmpStrategy getStrategy() { if (isClassBasedStrategyInstantiable()) { return s_classBasedStrategyResolver.getStrategy(); } return getStrategyResolver().getStrategy(); }
@Override public void addVarBind(SnmpTrapBuilder trap, String name, String encoding, String value) { trap.addVarBind(SnmpObjId.get(name), SnmpUtils.getValueFactory().getNull()); } }
public void testStoreResultWithValueThenEndOfMibView() { String baseOid = ".1.3.6.1.2.1.31.1.1.1.18"; String ifAliasName = "ifAlias"; String ifAliasValue = "Foo!"; SnmpStore store = new SnmpStore(new NamedSnmpVar[] { new NamedSnmpVar(NamedSnmpVar.SNMPOCTETSTRING, ifAliasName, baseOid, 18) }); SnmpObjId base = SnmpObjId.get(baseOid); SnmpInstId inst = new SnmpInstId("1"); store.storeResult(new SnmpResult(base, inst, SnmpUtils.getValueFactory().getOctetString(ifAliasValue.getBytes()))); store.storeResult(new SnmpResult(base, inst, SnmpUtils.getValueFactory().getValue(SnmpValue.SNMP_END_OF_MIB, null))); assertEquals("ifAlias value", ifAliasValue, store.getDisplayString(ifAliasName)); } }
@Override public String toString() { return new ToStringBuilder(this) .append("base", getBase()) .append("instance", getInstance()) .append("value", getValue()) .toString(); }
/** * @param base * @return */ public SnmpValue getValue(SnmpObjId base) { for(SnmpResult result : getResults()) { if (base.equals(result.getBase())) { return result.getValue(); } } return null; }
void storeResult(SnmpResult result) { SnmpInstId instId = result.getInstance(); if ( !m_pendingData.containsKey( instId ) ) { m_pendingData.put( instId, m_rowResultFactory.createRowResult( getColumnCount(), instId ) ); } SnmpRowResult row = m_pendingData.get( instId ); row.addResult( result.getBase(), result ); handleCompleteRows(); }
@Override public void processResponse(SnmpObjId responseObjId, SnmpValue val) { LOG.debug("Processing varBind: {} = {}", responseObjId, val); if (val.isEndOfMib()) { receivedEndOfMib(); } if (m_oid.equals(responseObjId)) { storeResult(new SnmpResult(m_base, m_inst, val)); } setFinished(true); }
public int getChildIndex(int canonicalIndex) throws SnmpException { if (isNonRepeater(canonicalIndex)) { return canonicalIndex - getNonRepeaterStartIndex(); } if (isRepeater(canonicalIndex)) { return canonicalIndex - getRepeaterStartIndex() + getNonRepeaters(); } throw new SnmpException("index out of range for tracker "+this); } }
public SnmpValue[] generateRowStatusValues() { SnmpValueFactory vf = SnmpUtils.getValueFactory(); SnmpValue[] values = { vf.getInt32(m_ciscoPingEntryStatus) }; return values; }
protected void buildAndSendNextPdu() throws SnmpException { if (m_tracker.isFinished()) { handleDone(); } else { m_pduBuilder.reset(); m_responseProcessor = m_tracker.buildNextPdu(m_pduBuilder); sendNextPdu(m_pduBuilder); } }
@Override public SnmpValue unmarshal(JaxbSnmpValue value) throws Exception { final SnmpValueFactory valueFactory = SnmpUtils.getValueFactory(); return valueFactory.getValue(value.getType(), value.getBytes()); } }
private ChildTrackerPduBuilder getChildBuilder(int zeroBasedIndex) throws SnmpException { int canonicalIndex = getCanonicalIndex(zeroBasedIndex); for (ChildTrackerPduBuilder childBuilder : m_childPduBuilders) { if (childBuilder.isNonRepeater(canonicalIndex) || childBuilder.isRepeater(canonicalIndex)) { return childBuilder; } } throw new SnmpException("Unable to find childBuilder for index "+zeroBasedIndex); }
@Override public void processResponse(SnmpObjId snmpObjId, SnmpValue val) throws SnmpException { ChildTrackerPduBuilder childBuilder = getChildBuilder(m_currResponseIndex++); childBuilder.getResponseProcessor().processResponse(snmpObjId, val); }
@Override public String toString() { return new ToStringBuilder(this) .append("base", m_base) .append("last oid", m_last) .append("max repetitions", m_maxRepetitions) .append("finished?", isFinished()) .toString(); } @Override
protected void handleError(String msg, Throwable t) { // XXX why do we set timedOut to false here? should we be doing this everywhere? m_tracker.setTimedOut(false); processError("Error retrieving", msg, t); }
public AggregateTracker(Collectable[] children, CollectionTracker parent) { super(parent); m_children = new CollectionTracker[children.length]; for (int i = 0; i < m_children.length; i++) { m_children[i] = children[i].getCollectionTracker(); m_children[i].setParent(this); } }
@Override public int compare(ColumnTracker o1, ColumnTracker o2) { SnmpInstId lhs = o1.getLastInstance(); SnmpInstId rhs = o2.getLastInstance(); if (lhs == rhs) return 0; if (lhs == null) return -1; if (rhs == null) return 1; return lhs.compareTo(rhs); } });
public boolean processChildError(int errorStatus, int errorIndex) { int canonicalIndex = getCanonicalIndex(errorIndex-1); ChildTrackerPduBuilder childBuilder = getChildBuilder(canonicalIndex); int childIndex = childBuilder.getChildIndex(canonicalIndex); return childBuilder.getResponseProcessor().processErrors(errorStatus, childIndex+1); }
protected void handleError(String msg) { // XXX why do we set timedOut to false here? should we be doing this everywhere? m_tracker.setTimedOut(false); processError("Error retrieving", msg, null); }