Package org.snmp4j.transport

Examples of org.snmp4j.transport.DefaultUdpTransportMapping


        if (_connectors[i].getPort() <= 0)
          _connectors[i].setPort(161);
        if (_connectors[i].isUdp())
        {
          UdpAddress address = new UdpAddress(_connectors[i].getInetAddress(), _connectors[i].getPort());
          transportMappings[i] = new DefaultUdpTransportMapping(address);
        }
        else
        {
          TcpAddress address = new TcpAddress(_connectors[i].getInetAddress(), _connectors[i].getPort());
          transportMappings[i] = new DefaultTcpTransportMapping(address);
View Full Code Here


          }
        }
      }

      UdpAddress udpAddr = new UdpAddress(UdpAddress.ANY_IPADDRESS, 0);
      Snmp snmp = new Snmp(new DefaultUdpTransportMapping(udpAddr));
      /* the snmp connection is open... add a seprate try/catch so we can make sure we close it */
      try {
        if ((version.equals("1")) || (version.equals("2c"))) {
          target = getCommunityTarget(targetAddress, Integer.parseInt(timeout), community, version);
        }
View Full Code Here

        _target = new CommunityTarget();
        _target.setCommunity(new OctetString(community));
        _target.setVersion(SnmpConstants.version2c);
        _target.setAddress(new UdpAddress(address));
        try {
            _snmp = new Snmp(new DefaultUdpTransportMapping());
        } catch (IOException e) {
            _snmp = null;
            throw new CloudRuntimeException(" Error in crearting snmp object, " + e.getMessage());
        }
    }
View Full Code Here

    private Snmp createSnmpSession() throws IOException {
        AbstractTransportMapping transport;
        if (address instanceof TcpAddress) {
            transport = new DefaultTcpTransportMapping();
        } else {
            transport = new DefaultUdpTransportMapping();
        }

        // Could save some CPU cycles:
        // transport.setAsyncMsgProcessingSupported(false);
        Snmp snmp = new Snmp(transport);
View Full Code Here

    @BeforeMethod
    public void setUp() throws Exception {
        receivedTraps = new ConcurrentLinkedQueue<PDU>();

        snmp = new Snmp(new DefaultUdpTransportMapping());
        Address targetAddress = new UdpAddress(getTestPort());
        boolean installedTrapListener = snmp.addNotificationListener(targetAddress, new CommandResponder() {
            @Override
            public void processPdu(CommandResponderEvent event) {
                receivedTraps.offer(event.getPDU());
View Full Code Here

    protected void before() throws Exception {
        super.before();
        port = configuration.getSimple("port").getIntegerValue();
        try {
            address = InetAddress.getLocalHost();
            peer = new DefaultUdpTransportMapping(); //new UdpAddress(address, getPort()));
            snmp = new Snmp(peer);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

        // TODO: check if the engine is already alive
        try {
            UdpAddress targetAddress = new UdpAddress(port);
            // TransportMapping transport = new DefaultUdpTransportMapping(targetAddress);
            snmp = new Snmp(new DefaultUdpTransportMapping());
            snmpTrapEventPoller = new SnmpTrapEventPoller(severityOid);
            eventContext.registerEventPoller(snmpTrapEventPoller, pollInterval);
            // TODO set up the community here
            if (!snmp.addNotificationListener(targetAddress, snmpTrapEventPoller))
                throw new IOException("cannot attach to " + targetAddress);
View Full Code Here

    private Snmp initSession() throws SNMPException {
        try {
            InetAddress host = InetAddress.getByName(ANY_LOCAL_ADDRESS);
            int port = ANY_FREE_PORT;
            UdpAddress addr = new UdpAddress(host, port);
            session = new Snmp(new DefaultUdpTransportMapping(addr));
            session.listen();
        } catch (IOException e) {
            throw new SNMPException("Failed to initialize SNMP session.", e);
        }
View Full Code Here

        // 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);
View Full Code Here

        // either tcp or udp
        if ("tcp".equals(endpoint.getProtocol())) {
            this.transport = new DefaultTcpTransportMapping();
        } else if ("udp".equals(endpoint.getProtocol())) {
            this.transport = new DefaultUdpTransportMapping();
        } else {
            throw new IllegalArgumentException("Unknown protocol: " + endpoint.getProtocol());
        }

        this.snmp = new Snmp(this.transport);
View Full Code Here

TOP

Related Classes of org.snmp4j.transport.DefaultUdpTransportMapping

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.