I had problem in retrieving the target ip address from received pdu. The "getPeerAddress()" gave me the sender's ip address. But what I want is the ip iddress or host name in the command/received pdu.
Eg "10.255.255.221" from
snmpset -v 1 -c M 10.255.**.221 1.3.6.1.4.1.161.3.6.37.2.6.1.1.4.2 i 3.
I tried the getAgentAdress for pduV1 but nothing display.
public synchronized void processPdu(CommandResponderEvent cmdRespEvent) {
System.out.println("Received PDU...");
String retrieveIP = cmdRespEvent.getPeerAddress().toString().split("/")[0];
System.out.println("Received PDU from " + retrieveIP +"\n");
PDU pdu = cmdRespEvent.getPDU();
System.out.println(" PDU Type = " + PDU.getTypeString(pdu.getType()));
System.out.println("Trap Type = " + pdu.getType());
System.out.println("IP Address = " + ((PDUv1) pdu).getAgentAddress().toString());
String updateValue = pdu.get(0).getVariable().toString();
System.out.println("updateValue ="+updateValue);
}
EDITED : My machine have multiple IP Addresses