/** * Will create an instance of {@link SNMPGetter} */ @Override protected SNMPGetter finishBuildingTargetResource(ProcessContext context) { String oid = context.getProperty(OID).getValue(); return new SNMPGetter(this.snmp, this.snmpTarget, new OID(oid)); }
VariableBinding varBind = new VariableBinding(new OID(snmpPropName), var); pdu.add(varBind); result = true;
private OID getOID(String oidString) { return new OID(oidString); } }
public static void main(String[] args) throws Exception { // Create PDU PDU trap = new PDU(); trap.setType(PDU.TRAP); OID oid = new OID("1.2.3.4.5"); trap.add(new VariableBinding(SnmpConstants.snmpTrapOID, oid)); trap.add(new VariableBinding(SnmpConstants.sysUpTime, new TimeTicks(5000))); // put your uptime here trap.add(new VariableBinding(SnmpConstants.sysDescr, new OctetString("System Description"))); //Add Payload Variable var = new OctetString("some string"); trap.add(new VariableBinding(oid, var)); // Specify receiver Address targetaddress = new UdpAddress("10.101.21.32/162"); CommunityTarget target = new CommunityTarget(); target.setCommunity(new OctetString("public")); target.setVersion(SnmpConstants.version2c); target.setAddress(targetaddress); // Send Snmp snmp = new Snmp(new DefaultUdpTransportMapping()); snmp.send(trap, target, null, null); }
public Variable createInitialValue() { Variable v = new OID(); // further modify value to comply with TC constraints here: //--AgentGen BEGIN=TDomain::createInitialValue //--AgentGen END return v; }
/** * Creates a variable binding with a zero length OID and a {@link Null} value. */ public VariableBinding() { oid = new OID(); this.variable = Null.instance; }
/** * Appends a dotted String OID to this {@code OID}. * @param oid * a dotted String with numerical sub-identifiers. * @return * a pointer to this OID instance (useful for chaining). */ public final OID append(String oid) { OID suffix = new OID(oid); return append(suffix); }
public OID toSubIndex(boolean impliedLength) { byte[] address = new byte[4]; System.arraycopy(inetAddress.getAddress(), 0, address, 0, 4); OID subIndex = new OID(new int[4]); for (int i=0; i<address.length; i++) { subIndex.set(i, address[i] & 0xFF); } return subIndex; }
/** * Appends a dotted String OID to this <code>OID</code>. * @param oid * a dotted String with numerical sub-identifiers. * @return * a pointer to this OID instance (useful for chaining). */ public final OID append(String oid) { OID suffix = new OID(oid); return append(suffix); }
public OID toSubIndex(boolean impliedLength) { byte[] address = new byte[4]; System.arraycopy(inetAddress.getAddress(), 0, address, 0, 4); OID subIndex = new OID(new int[4]); for (int i=0; i<address.length; i++) { subIndex.set(i, address[i] & 0xFF); } return subIndex; }
@Override public void addOid(SnmpObjId snmpObjId) { VariableBinding varBind = new VariableBinding(new OID(snmpObjId.getIds())); m_nextPdu.add(varBind); }
@Override public OID getLowerBound() { if (lowerBound == null) { lowerBound = new OID(oid.getValue(), 0, oid.size() - 1); } return lowerBound; }
@Override public int viewTreeFamilyEntryCount(OctetString viewName) { OID lowerBound = viewName.toSubIndex(false); OID upperBound = new OID(lowerBound).nextPeer(); return vacmViewTreeFamilyTableModel.getRows(lowerBound, upperBound).size(); }
public void put(String oid, Variable value) { OID oidKey = new OID(m_base); oidKey.append(oid); m_values.put(oidKey, value); }
@Override public void addVarBind(SnmpObjId name, SnmpValue value) { OID oid = new OID(name.getIds()); Variable val = ((Snmp4JValue) value).getVariable(); m_pdu.add(new VariableBinding(oid, val)); }
public void addVarBind(SnmpObjId name, SnmpValue value) { OID oid = new OID(name.getIds()); Variable val = ((Snmp4JValue) value).getVariable(); m_pdu.add(new VariableBinding(oid, val)); }
public final OID getIndexPart(OID anyOID) { int offset = oid.size() + 1; if ((anyOID.size() <= offset) || (!anyOID.startsWith(oid))) { return null; } return new OID(anyOID.getValue(), offset, anyOID.size() - offset); }
private OID getCloneFromIndex(MOTableRow changeSet) { OID cloneFrom = (OID) changeSet.getValue(colUsmUserCloneFrom); if (cloneFrom == null) { cloneFrom = (OID) getValue(colUsmUserCloneFrom); } if ((cloneFrom == null) || (cloneFrom.size() <= usmUserEntryOID.size())) { return null; } return new OID(cloneFrom.getValue(), usmUserEntryOID.size()+1, cloneFrom.size() - (usmUserEntryOID.size()+1)); }
private OID getCloneFromIndex(MOTableRow changeSet) { OID cloneFrom = (OID) changeSet.getValue(colUsmUserCloneFrom); if (cloneFrom == null) { cloneFrom = (OID) getValue(colUsmUserCloneFrom); } if ((cloneFrom == null) || (cloneFrom.size() <= usmUserEntryOID.size())) { return null; } return new OID(cloneFrom.getValue(), usmUserEntryOID.size()+1, cloneFrom.size() - (usmUserEntryOID.size()+1)); }