@Override public OID getUpperBound() { if (upperBound == null) { upperBound = new OID(getLowerBound().nextPeer()); } return upperBound; }
public OID getUpperBound() { if (upperBound == null) { upperBound = new OID(getLowerBound().nextPeer()); } return upperBound; }
public MOSubtreeProxy(Session session, SnmpTargetMIB targetMIB, OctetString proxyName, OID subtreeOID, OctetString contextEngineID, OctetString contextName, OctetString targetName) { this.session = session; this.targetMIB = targetMIB; this.proxyName = proxyName; this.contextName = contextName; this.scope = new DefaultMOScope(subtreeOID, true, subtreeOID.nextPeer(), false); this.targetName = targetName; this.contextEngineID = contextEngineID; this.pduFactory = new DefaultPDUFactory(PDU.GETNEXT, contextEngineID, contextName); }
@Override public int viewTreeFamilyEntryCount(OctetString viewName) { OID lowerBound = viewName.toSubIndex(false); OID upperBound = new OID(lowerBound).nextPeer(); return vacmViewTreeFamilyTableModel.getRows(lowerBound, upperBound).size(); }
@Override public int accessEntryCount(OctetString groupName) { OID lowerBound = groupName.toSubIndex(false); OID upperBound = new OID(lowerBound).nextPeer(); return vacmAccessTableModel.getRows(lowerBound, upperBound).size(); }
public List<VariableBinding> walkMib(String strOid, int count) { OID oid = new OID(strOid); DefaultMOContextScope scope = new DefaultMOContextScope( new OctetString(FILEMIB_CONTEXT), oid, true, oid.nextPeer(), false ); ManagedObject mo = server.lookup(new DefaultMOQuery(scope, false)); if (mo == null) { return new ArrayList<VariableBinding>(0); } if (mo instanceof MutableStaticMOGroup) { return ((MutableStaticMOGroup)mo).walk(oid, count); } else { return new ArrayList<VariableBinding>(0); } }
private synchronized void listLoggers(Snmp snmp, Target target, PDUFactory pduFactory) { TableUtils tableUtils = new TableUtils(snmp, pduFactory); OID lowerBound = null; OID upperBound = null; String filter = (String) ArgumentParser.getValue(parameters, "filter", 0); if (filter != null) { OctetString filterString = new OctetString(filter); lowerBound = filterString.toSubIndex(true); upperBound = lowerBound.nextPeer(); } LoggerListListener lll = new LoggerListListener(); tableUtils.getTable(target, SNMP4J_LOGGER_OIDS, lll, this, lowerBound, upperBound); while (!lll.isFinished()) { try { wait(); } catch (InterruptedException ex) { // ignore } } }
private synchronized void listLoggers(Snmp snmp, Target target, PDUFactory pduFactory) { TableUtils tableUtils = new TableUtils(snmp, pduFactory); OID lowerBound = null; OID upperBound = null; String filter = (String) ArgumentParser.getValue(parameters, "filter", 0); if (filter != null) { OctetString filterString = new OctetString(filter); lowerBound = filterString.toSubIndex(true); upperBound = lowerBound.nextPeer(); } LoggerListListener lll = new LoggerListListener(); tableUtils.getTable(target, SNMP4J_LOGGER_OIDS, lll, this, lowerBound, upperBound); while (!lll.isFinished()) { try { wait(); } catch (InterruptedException ex) { } } }
private synchronized void listLoggers(Snmp snmp, Target target, PDUFactory pduFactory) { TableUtils tableUtils = new TableUtils(snmp, pduFactory); OID lowerBound = null; OID upperBound = null; String filter = (String) ArgumentParser.getValue(parameters, "filter", 0); if (filter != null) { OctetString filterString = new OctetString(filter); lowerBound = filterString.toSubIndex(true); upperBound = lowerBound.nextPeer(); } LoggerListListener lll = new LoggerListListener(); tableUtils.getTable(target, SNMP4J_LOGGER_OIDS, lll, this, lowerBound, upperBound); while (!lll.isFinished()) { try { wait(); } catch (InterruptedException ex) { // ignore } } }
public VariableBinding getMib(String strOid, String communityStringIndex) { if ( communityStringIndex.length() != 0 && !communityStringIndexes.contains(communityStringIndex) ) { return null; } OID oid = new OID(strOid); DefaultMOContextScope scope = new DefaultMOContextScope( new OctetString( getContextNameForCommunityStringIndex(communityStringIndex) ), oid, true, oid.nextPeer(), false ); ManagedObject mo = server.lookup(new DefaultMOQuery(scope, false)); if (mo == null) { return null; } if (mo instanceof MutableStaticMOGroup) { return new VariableBinding(oid, ((MutableStaticMOGroup)mo).get(oid)); } else { return null; } }
/** * Creates a static managed object group for the sub-tree with the specified * root OID. * @param root * the root OID of the sub-tree to be registered by this managed object. * @param vbs * the variable bindings to be returned in this sub-tree. */ public MutableStaticMOGroup(OID root, VariableBinding[] vbs) { this.root = root; this.scope = new DefaultMOScope(root, true, root.nextPeer(), false); variableBindings = new TreeMap<OID, Variable>(); for (int i = 0; i < vbs.length; i++) { if ((vbs[i].getOid() != null) && (vbs[i].getVariable() != null)) { if ( (vbs[i].getOid().size() >= root.size()) && (vbs[i].getOid().leftMostCompare(root.size(), root) == 0) ) { this.variableBindings.put(vbs[i].getOid(), vbs[i].getVariable()); } } } }
/** * Returns the next following OID with the same or lesser size (length). * * @return OID * the next OID on the same or upper level or a clone of this OID, if * it has a zero length or is 2^32-1. * @since 1.7 */ public final OID nextPeer() { OID next = new OID(this); if ((next.size() > 0) && (last() != MAX_SUBID_VALUE)) { next.set(next.size() - 1, last() + 1); } else if (next.size() > 1) { next.trim(1); next = next.nextPeer(); } return next; }
/** * Creates a static managed object group for the sub-tree with the specified * root OID. * @param root * the root OID of the sub-tree to be registered by this managed object. * @param vbs * the variable bindings to be returned in this sub-tree. */ public StaticMOGroup(OID root, VariableBinding[] vbs) { this.root = root; this.scope = new DefaultMOScope(root, true, root.nextPeer(), false); for (VariableBinding vb : vbs) { if ((vb.getOid() != null) && (vb.getVariable() != null)) { if ((vb.getOid().size() >= root.size()) && (vb.getOid().leftMostCompare(root.size(), root) == 0)) { this.vbs.put(vb.getOid(), vb.getVariable()); } } } }
public VariableBinding getMib(String strOid) { OID oid = new OID(strOid); DefaultMOContextScope scope = new DefaultMOContextScope( new OctetString(FILEMIB_CONTEXT), oid, true, oid.nextPeer(), false ); ManagedObject mo = server.lookup(new DefaultMOQuery(scope, false)); if (mo == null) { return null; } if (mo instanceof MutableStaticMOGroup) { return new VariableBinding(oid, ((MutableStaticMOGroup)mo).get(oid)); } else { return null; } }
/** * Returns the next following OID with the same or lesser size (length). * @return OID * the next OID on the same or upper level or a clone of this OID, if * it has a zero length or is 2^32-1. * @since 1.7 */ public final OID nextPeer() { OID next = new OID(this); if ((next.size() > 0) && (last() != MAX_SUBID_VALUE)) { next.set(next.size()-1, last()+1); } else if (next.size() > 1) { next.trim(1); next = next.nextPeer(); } return next; }
/** * Creates a static managed object group for the sub-tree with the specified * root OID. * @param root * the root OID of the sub-tree to be registered by this managed object. * @param vbs * the variable bindings to be returned in this sub-tree. */ public StaticMOGroup(OID root, VariableBinding[] vbs) { this.root = root; this.scope = new DefaultMOScope(root, true, root.nextPeer(), false); for (int i=0; i<vbs.length; i++) { if ((vbs[i].getOid() != null) && (vbs[i].getVariable() != null)) { if ((vbs[i].getOid().size() >= root.size()) && (vbs[i].getOid().leftMostCompare(root.size(), root) == 0)) { this.vbs.put(vbs[i].getOid(), vbs[i].getVariable()); } } } }
/** * Returns the next following OID with the same or lesser size (length). * @return OID * the next OID on the same or upper level or a clone of this OID, if * it has a zero length or is 2^32-1. * @since 1.7 */ public final OID nextPeer() { OID next = new OID(this); if ((next.size() > 0) && (last() != MAX_SUBID_VALUE)) { next.set(next.size()-1, last()+1); } else if (next.size() > 1) { next.trim(1); next = nextPeer(); } return next; }
private void deleteLogRows(long limit, OctetString profileName) { long delta = nlmLogEntry.getModel().getRowCount() - limit; if (delta > 0) { synchronized (nlmLogEntries) { for (int i=0; (i<delta) && (nlmLogEntries.size()>0); i++) { OID firstIndex = (OID) nlmLogEntries.remove(0); if (firstIndex != null) { nlmLogEntry.removeRow(firstIndex); ((DefaultMOMutableTableModel) nlmLogVariableEntryModel).removeRows(firstIndex, firstIndex.nextPeer()); NlmStatsLogEntryRow statsRow = (NlmStatsLogEntryRow) nlmStatsLogEntryModel.getRow(firstIndex.trim()); if (statsRow != null) { statsRow.getNlmStatsLogNotificationsBumped().increment(); } ((Counter32)nlmStatsGlobalNotificationsBumped.getValue()).increment(); if (profileName != null) { NlmStatsLogEntryRow profile = (NlmStatsLogEntryRow) nlmStatsLogEntry.getModel().getRow(profileName.toSubIndex(false)); if (profile != null) { profile.getNlmStatsLogNotificationsBumped().increment(); } } } } } } }
public Variable setMib(String strVarBind) throws ParseException { VariableBinding varBind = ColonSeparatedOidTypeValueVariableTextFormat.getInstance() .parseVariableBinding(strVarBind); OID oid = varBind.getOid(); DefaultMOContextScope scope = new DefaultMOContextScope( new OctetString(FILEMIB_CONTEXT), oid, true, oid.nextPeer(), false ); ManagedObject mo = server.lookup(new DefaultMOQuery(scope, true)); if (mo == null) { return Null.noSuchObject; } if (!(mo instanceof MutableStaticMOGroup)) { return Null.noSuchObject; } return ((MutableStaticMOGroup)mo).set( oid, varBind.getVariable() ); }
@Override public OID forwardTranslate(OID oid) { if (oid != null) { OID translated; if ((oid.size() >= scope.getLowerBound().size()) && (oid.startsWith(scope.getLowerBound()))) { OID remote = new OID(remoteOID); int[] suffix = new int[oid.size() - scope.getLowerBound().size()]; if (suffix.length > 0) { System.arraycopy(oid.getValue(), scope.getLowerBound().size(), suffix, 0, suffix.length); remote.append(new OID(suffix)); } translated = remote; } else if (oid.compareTo(scope.getLowerBound()) < 0) { translated = new OID(remoteOID); } else { translated = remoteOID.nextPeer(); } if (logger.isDebugEnabled()) { logger.debug("Forward OID translation '"+oid+"'->'"+translated); } return translated; } return null; }