/** * Sets the local engine ID for the SNMP entity represented by this * <code>Snmp</code> instance. This is a convenience method that sets * the local engine ID in the associated <code>MPv3</code> and * <code>USM</code>. * @param engineID * a byte array containing the local engine ID. The length and content * has to comply with the constraints defined in the SNMP-FRAMEWORK-MIB. * @param engineBoots * the number of boots of this SNMP engine (zero based). * @param engineTime * the number of seconds since the value of engineBoots last changed. * @see MPv3 * @see USM */ public void setLocalEngine(byte[] engineID, int engineBoots, int engineTime) { MPv3 mpv3 = getMPv3(); mpv3.setLocalEngineID(engineID); USM usm = (USM) mpv3.getSecurityModel(SecurityModel.SECURITY_MODEL_USM); usm.setLocalEngine(new OctetString(engineID), engineBoots, engineTime); }
@Override public int setValue(Integer32 value) { int updateResult = super.setValue(value); if (updateUsmFromMIB) { getUSM().setLocalEngine(snmpEngineID.getValue(), snmpEngineBoots.getValue().toInt(),value.toInt()); } return updateResult; } };
@Override public int setValue(OctetString value) { int updateResult = super.setValue(value); if (updateUsmFromMIB) { getUSM().setLocalEngine(value, snmpEngineBoots.getValue().toInt(), snmpEngineTime.getValue().toInt()); } return updateResult; } };
@Override public int setValue(Integer32 value) { // we increase the set value by one Integer32 newBoots = new Integer32(value.getValue()+1); int updateResult = super.setValue(newBoots); if (updateUsmFromMIB) { getUSM().setLocalEngine(snmpEngineID.getValue(), newBoots.toInt(), snmpEngineTime.getValue().toInt()); } return updateResult; } };
/** * Sets the local engine ID for the SNMP entity represented by this * <code>Snmp</code> instance. This is a convenience method that sets * the local engine ID in the associated <code>MPv3</code> and * <code>USM</code>. * @param engineID * a byte array containing the local engine ID. The length and content * has to comply with the constraints defined in the SNMP-FRAMEWORK-MIB. * @param engineBoots * the number of boots of this SNMP engine (zero based). * @param engineTime * the number of seconds since the value of engineBoots last changed. * @see MPv3 * @see USM */ public void setLocalEngine(byte[] engineID, int engineBoots, int engineTime) { MPv3 mpv3 = getMPv3(); mpv3.setLocalEngineID(engineID); mpv3.setCurrentMsgID(MPv3.randomMsgID(engineBoots)); USM usm = (USM) mpv3.getSecurityModel(SecurityModel.SECURITY_MODEL_USM); usm.setLocalEngine(new OctetString(engineID), engineBoots, engineTime); }
/** * Sets the local engine ID for the SNMP entity represented by this * <code>Snmp</code> instance. This is a convenience method that sets * the local engine ID in the associated <code>MPv3</code> and * <code>USM</code>. * * @param engineID * a byte array containing the local engine ID. The length and content * has to comply with the constraints defined in the SNMP-FRAMEWORK-MIB. * @param engineBoots * the number of boots of this SNMP engine (zero based). * @param engineTime * the number of seconds since the value of engineBoots last changed. * * @see MPv3 * @see USM */ @Override public void setLocalEngine(byte[] engineID, int engineBoots, int engineTime) { MPv3 mpv3 = getMPv3(); mpv3.setLocalEngineID(engineID); mpv3.setCurrentMsgID(MPv3.randomMsgID(engineBoots)); USM usm = (USM) mpv3.getSecurityModel(SecurityModel.SECURITY_MODEL_USM); if (usm != null) { usm.setLocalEngine(new OctetString(engineID), engineBoots, engineTime); } }