Hello,
How to configure SNMP4J to send traps with the same msgAuthoritativeEngineID after each restart system?
IP address and secure parameter in this case are not changed.
But each time after reboot it has new last 4 bytes despite my constant definition (without random value).
I will be very appreciated for your help.
Best Regards
Alex Fooks
Below short examples I use
Example:
80000a2b010a6e77234f93885d
after restart:
80000a2b010a6e7723ee979349
Below method generates engineId:
private static byte[] createLocalEngineID() {
-
int enterpriseID = SNMP4JSettings.getEnterpriseID();*
-
byte[] engineID = new byte[5];*
-
engineID[0] = (byte) (0x80 | ((enterpriseID >> 24) & 0xFF));*
-
engineID[1] = (byte) ((enterpriseID >> 16) & 0xFF);*
-
engineID[2] = (byte) ((enterpriseID >> 8) & 0xFF);*
-
engineID[3] = (byte) (enterpriseID & 0xFF);*
-
engineID[4] = 2;*
-
OctetString os = new OctetString();*
-
try {*
-
ConfigurationHelper ch = new ConfigurationHelper();*
-
byte[] b = InetAddress.getLocalHost().getAddress();*
-
if (b.length == 4) {*
-
engineID[4] = 1;*
-
}*
-
os.setValue(b);*
-
} catch (UnknownHostException ex) {*
-
//logger.debug("Local host cannot be determined for creation of local engine ID");*
-
engineID[4] = 4;*
-
os.setValue("SNMP4J".getBytes());*
-
}*
-
OctetString ownEngineID = new OctetString(engineID);*
-
ownEngineID.append(os);*
-
ownEngineID.append(longToBytes(11111111));*
-
return ownEngineID.getValue();*
- }*
and initialization of USM:
|MPv3 mpv3 = new MPv3(localEngineIdFixed.toByteArray());
usm = new USM(SecurityProtocols.getInstance(), new OctetString(mpv3.getLocalEngineID()), 0);