Skip to content

Commit

Permalink
[SNMP] Process enterprise OID in V1TRAP PDUs (#6511)
Browse files Browse the repository at this point in the history
Add processing of Enterprise OID for V1TRAP PDUs

Signed-off-by: Vladimir Velev <[email protected]>
  • Loading branch information
sharo1k authored and J-N-K committed Dec 22, 2019
1 parent 8ba4a58 commit ade9115
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import org.snmp4j.CommandResponderEvent;
import org.snmp4j.CommunityTarget;
import org.snmp4j.PDU;
import org.snmp4j.PDUv1;
import org.snmp4j.event.ResponseEvent;
import org.snmp4j.event.ResponseListener;
import org.snmp4j.mp.SnmpConstants;
Expand Down Expand Up @@ -209,6 +210,16 @@ public void processPdu(@Nullable CommandResponderEvent event) {
final String address = ((UdpAddress) event.getPeerAddress()).getInetAddress().getHostAddress();
final String community = new String(event.getSecurityName());

if ((pdu.getType() == PDU.V1TRAP) && config.community.equals(community) && (pdu instanceof PDUv1)) {
logger.trace("{} received trap is PDUv1.", thing.getUID());
PDUv1 pduv1 = (PDUv1) pdu;
OID oidEnterprise = pduv1.getEnterprise();
int trapValue = pduv1.getGenericTrap();
if (trapValue == PDUv1.ENTERPRISE_SPECIFIC) {
trapValue = pduv1.getSpecificTrap();
}
updateChannels(oidEnterprise, new UnsignedInteger32(trapValue), trapChannelSet);
}
if ((pdu.getType() == PDU.TRAP || pdu.getType() == PDU.V1TRAP) && config.community.equals(community)
&& targetAddressString.equals(address)) {
pdu.getVariableBindings().forEach(variable -> {
Expand Down

0 comments on commit ade9115

Please sign in to comment.