Search in sources :

Example 1 with TcpAddress

use of org.snmp4j.smi.TcpAddress in project camel by apache.

the class SnmpTrapConsumer method doStart.

@Override
protected void doStart() throws Exception {
    super.doStart();
    // load connection data only if the endpoint is enabled
    if (LOG.isInfoEnabled()) {
        LOG.info("Starting trap consumer on {}", this.endpoint.getAddress());
    }
    this.listenGenericAddress = GenericAddress.parse(this.endpoint.getAddress());
    // either tcp or udp
    if ("tcp".equals(endpoint.getProtocol())) {
        this.transport = new DefaultTcpTransportMapping((TcpAddress) this.listenGenericAddress);
    } else if ("udp".equals(endpoint.getProtocol())) {
        this.transport = new DefaultUdpTransportMapping((UdpAddress) this.listenGenericAddress);
    } else {
        throw new IllegalArgumentException("Unknown protocol: " + endpoint.getProtocol());
    }
    this.snmp = new Snmp(transport);
    this.snmp.addCommandResponder(this);
    // listen to the transport
    if (LOG.isDebugEnabled()) {
        LOG.debug("Starting trap consumer on {} using {} protocol", endpoint.getAddress(), endpoint.getProtocol());
    }
    this.transport.listen();
    if (LOG.isInfoEnabled()) {
        LOG.info("Started trap consumer on {} using {} protocol", endpoint.getAddress(), endpoint.getProtocol());
    }
}
Also used : TcpAddress(org.snmp4j.smi.TcpAddress) DefaultTcpTransportMapping(org.snmp4j.transport.DefaultTcpTransportMapping) Snmp(org.snmp4j.Snmp) DefaultUdpTransportMapping(org.snmp4j.transport.DefaultUdpTransportMapping)

Aggregations

Snmp (org.snmp4j.Snmp)1 TcpAddress (org.snmp4j.smi.TcpAddress)1 DefaultTcpTransportMapping (org.snmp4j.transport.DefaultTcpTransportMapping)1 DefaultUdpTransportMapping (org.snmp4j.transport.DefaultUdpTransportMapping)1