1
votes

I wrote an application based on SNMP4J for sending SNMP requests and receiving traps. all works fine but I couldn't find how to set the community string for received traps or even how to see the community string for each received trap.

help will be highly appriciated

2

2 Answers

1
votes

I'm afraid it's not the true "community name".

The method "event.getSecurityName()" only gives you the "SecurityName" of this trap package. And it is set when you config a trap information on your device.

The true "community name" is used for config the device by SNMPv2 API. For example, the community of device is "public", and you can set a SNMPv2c trap information with security name of "mypublic". Then you will get "mypublic" by calling event.getSecurityName() but not the "public".

1
votes

Inside public void processPdu(CommandResponderEvent event), the following will get the community name :

String community = new String(event.getSecurityName());