use of org.snmp4j.smi.UdpAddress in project opennms by OpenNMS.
the class LLDPMibIT method sendRequestV1V2.
private PDU sendRequestV1V2(PDU pdu, int version) throws Exception {
PDU response;
CommunityTarget target = new CommunityTarget();
target.setCommunity(new OctetString("public"));
target.setAddress(new UdpAddress(m_agent.getInetAddress(), m_agent.getPort()));
target.setVersion(version);
if (m_timeout > 0) {
target.setTimeout(m_timeout);
}
TransportMapping<UdpAddress> transport = null;
try {
transport = new DefaultUdpTransportMapping();
Snmp snmp = new Snmp(transport);
transport.listen();
ResponseEvent e = snmp.send(pdu, target);
response = e.getResponse();
} finally {
if (transport != null) {
transport.close();
}
}
return response;
}
Aggregations