Search in sources :

Example 16 with UdpAddress

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;
}
Also used : ScopedPDU(org.snmp4j.ScopedPDU) PDU(org.snmp4j.PDU) OctetString(org.snmp4j.smi.OctetString) UdpAddress(org.snmp4j.smi.UdpAddress) Snmp(org.snmp4j.Snmp) DefaultUdpTransportMapping(org.snmp4j.transport.DefaultUdpTransportMapping) ResponseEvent(org.snmp4j.event.ResponseEvent) CommunityTarget(org.snmp4j.CommunityTarget)

Aggregations

UdpAddress (org.snmp4j.smi.UdpAddress)16 Snmp (org.snmp4j.Snmp)13 OctetString (org.snmp4j.smi.OctetString)13 DefaultUdpTransportMapping (org.snmp4j.transport.DefaultUdpTransportMapping)12 CommunityTarget (org.snmp4j.CommunityTarget)7 PDU (org.snmp4j.PDU)7 ResponseEvent (org.snmp4j.event.ResponseEvent)7 IOException (java.io.IOException)6 ScopedPDU (org.snmp4j.ScopedPDU)6 UsmUser (org.snmp4j.security.UsmUser)5 UserTarget (org.snmp4j.UserTarget)3 USM (org.snmp4j.security.USM)3 InetAddress (java.net.InetAddress)2 PDUv1 (org.snmp4j.PDUv1)2 Target (org.snmp4j.Target)2 Address (org.snmp4j.smi.Address)2 OID (org.snmp4j.smi.OID)2 Config (com.sun.enterprise.config.serverbeans.Config)1 InvalidSnmpVersion (fish.payara.notification.snmp.exception.InvalidSnmpVersion)1 BlockingQueueHandler (fish.payara.nucleus.notification.BlockingQueueHandler)1