Reputation: 21
I'm using snmp4j 2.8.4 and Java 1.8
It works when I use the command line to send traps.for example
snmptrapd.conf
authCommunity log,execute,net public
createUser -e 0x8000000001020304 myuser MD5 mypassword DES mypassword1
authUser log,execute,net myuser noauth
The command is
snmptrap -e 0x8000000001020304 -v 3 -u myuser -a MD5 -A myjjpassword -x DES -X myjjpassword1 -l noAuthNoPriv 192.168.135.18:162 "" 1.3.6.1.4.1.48183 1.3.6.1.4.1.48183.1 s "smartmon"
It was ok at this point, but when I used SNMP4J, I didn't know if my engine ID was not set up correctly, which caused the trap failure or some other reason
USM usm = new USM(SecurityProtocols.getInstance(), localEngineID, 0);
SecurityModels.getInstance().addSecurityModel(usm);
usm.updateUser(new UsmUserEntry(new OctetString("myuser"),
new OctetString("0x8000000001020304".getBytes()), new UsmUser(new OctetString("myuser"),
null,
null,
null,
null)));
snmp = new Snmp(transport);
snmp.setLocalEngine(new OctetString("0x8000000001020304".getBytes()).getValue(),0,0);
snmp.getMessageDispatcher().addMessageProcessingModel(new MPv3(usm));
transport.listen();
Could you tell me where I have a problem setting?How should I set the Engine ID?Thank you very much for your answers
Upvotes: 2
Views: 1086
Reputation: 21
OctetString uses a different string representation than NET-SNMP does. Thus, you need to specify your engine ID as:
OctetString.fromString("8000000001020304", 16);
Upvotes: 0