Java 类net.floodlightcontroller.core.internal.OFChannelHandler 实例源码

项目:fresco_floodlight    文件:OFChannelInitializer.java   
@Override
protected void initChannel(Channel ch) throws Exception {
    ChannelPipeline pipeline = ch.pipeline();
    OFChannelHandler handler = new OFChannelHandler(
            switchManager,
            connectionListener,
            pipeline,
            debugCounters,
            timer,
            ofBitmaps,
            defaultFactory);

    if (keyStore != null && keyStorePassword != null) {
        try {
            /* Set up factories and stores. */
            TrustManagerFactory tmFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
            KeyStore tmpKS = null;
            tmFactory.init(tmpKS);

            /* Use keystore/pass defined in properties file. */
            KeyStore ks = KeyStore.getInstance("JKS");
            ks.load(new FileInputStream(keyStore), keyStorePassword.toCharArray());

            KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
            kmf.init(ks, keyStorePassword.toCharArray());

            KeyManager[] km = kmf.getKeyManagers();
            TrustManager[] tm = tmFactory.getTrustManagers();

            /* Set up SSL prereqs for Netty. */
            SSLContext sslContext = SSLContext.getInstance("TLS");
            sslContext.init(km, tm, null);
            SSLEngine sslEngine = sslContext.createSSLEngine();

            /* We are the server and we will create secure sessions. */
            sslEngine.setUseClientMode(false);
            sslEngine.setEnableSessionCreation(true);

            /* These are redundant (default), but for clarity... */
            sslEngine.setEnabledProtocols(sslEngine.getSupportedProtocols()); 
            sslEngine.setEnabledCipherSuites(sslEngine.getSupportedCipherSuites());

            /* First, decrypt w/handler+engine; then, proceed with rest of handlers. */
            pipeline.addLast(PipelineHandler.SSL_TLS_ENCODER_DECODER, new SslHandler(sslEngine));
            log.info("SSL OpenFlow socket initialized and handler ready for switch.");
        } catch (Exception e) { /* There are lots of possible exceptions to catch, so this should get them all. */
            log.error("Exception initializing SSL OpenFlow socket: {}", e.getMessage());
            throw e; /* If we wanted secure but didn't get it, we should bail. */
        }
    }

    pipeline.addLast(PipelineHandler.OF_MESSAGE_DECODER,
            new OFMessageDecoder());
    pipeline.addLast(PipelineHandler.OF_MESSAGE_ENCODER,
            new OFMessageEncoder());
    pipeline.addLast(PipelineHandler.MAIN_IDLE,
            new IdleStateHandler(PipelineIdleReadTimeout.MAIN,
                    PipelineIdleWriteTimeout.MAIN,
                    0));
    pipeline.addLast(PipelineHandler.READ_TIMEOUT, new ReadTimeoutHandler(30));
    pipeline.addLast(PipelineHandler.CHANNEL_HANDSHAKE_TIMEOUT,
            new HandshakeTimeoutHandler(
                    handler,
                    timer,
                    PipelineHandshakeTimeout.CHANNEL));

    pipeline.addLast(PipelineHandler.CHANNEL_HANDLER, handler);
}
项目:SDN-Multicast    文件:OFChannelInitializer.java   
@Override
protected void initChannel(Channel ch) throws Exception {
    ChannelPipeline pipeline = ch.pipeline();
    OFChannelHandler handler = new OFChannelHandler(
            switchManager,
            connectionListener,
            pipeline,
            debugCounters,
            timer,
            ofBitmaps,
            defaultFactory);

    if (keyStore != null && keyStorePassword != null) {
        try {
            /* Set up factories and stores. */
            TrustManagerFactory tmFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
            KeyStore tmpKS = null;
            tmFactory.init(tmpKS);

            /* Use keystore/pass defined in properties file. */
            KeyStore ks = KeyStore.getInstance("JKS");
            ks.load(new FileInputStream(keyStore), keyStorePassword.toCharArray());

            KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
            kmf.init(ks, keyStorePassword.toCharArray());

            KeyManager[] km = kmf.getKeyManagers();
            TrustManager[] tm = tmFactory.getTrustManagers();

            /* Set up SSL prereqs for Netty. */
            SSLContext sslContext = SSLContext.getInstance("TLS");
            sslContext.init(km, tm, null);
            SSLEngine sslEngine = sslContext.createSSLEngine();

            /* We are the server and we will create secure sessions. */
            sslEngine.setUseClientMode(false);
            sslEngine.setEnableSessionCreation(true);

            /* These are redundant (default), but for clarity... */
            sslEngine.setEnabledProtocols(sslEngine.getSupportedProtocols()); 
            sslEngine.setEnabledCipherSuites(sslEngine.getSupportedCipherSuites());

            /* First, decrypt w/handler+engine; then, proceed with rest of handlers. */
            pipeline.addLast(PipelineHandler.SSL_TLS_ENCODER_DECODER, new SslHandler(sslEngine));
            log.info("SSL OpenFlow socket initialized and handler ready for switch.");
        } catch (Exception e) { /* There are lots of possible exceptions to catch, so this should get them all. */
            log.error("Exception initializing SSL OpenFlow socket: {}", e.getMessage());
            throw e; /* If we wanted secure but didn't get it, we should bail. */
        }
    }

    pipeline.addLast(PipelineHandler.OF_MESSAGE_DECODER,
            new OFMessageDecoder());
    pipeline.addLast(PipelineHandler.OF_MESSAGE_ENCODER,
            new OFMessageEncoder());
    pipeline.addLast(PipelineHandler.MAIN_IDLE,
            new IdleStateHandler(PipelineIdleReadTimeout.MAIN,
                    PipelineIdleWriteTimeout.MAIN,
                    0));
    pipeline.addLast(PipelineHandler.READ_TIMEOUT, new ReadTimeoutHandler(30));
    pipeline.addLast(PipelineHandler.CHANNEL_HANDSHAKE_TIMEOUT,
            new HandshakeTimeoutHandler(
                    handler,
                    timer,
                    PipelineHandshakeTimeout.CHANNEL));

    pipeline.addLast(PipelineHandler.CHANNEL_HANDLER, handler);
}
项目:arscheduler    文件:OFChannelInitializer.java   
@Override
protected void initChannel(Channel ch) throws Exception {
    ChannelPipeline pipeline = ch.pipeline();
    OFChannelHandler handler = new OFChannelHandler(
            switchManager,
            connectionListener,
            pipeline,
            debugCounters,
            timer,
            ofBitmaps,
            defaultFactory);

    if (keyStore != null && keyStorePassword != null) {
        try {
            /* Set up factories and stores. */
            TrustManagerFactory tmFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
            KeyStore tmpKS = null;
            tmFactory.init(tmpKS);

            /* Use keystore/pass defined in properties file. */
            KeyStore ks = KeyStore.getInstance("JKS");
            ks.load(new FileInputStream(keyStore), keyStorePassword.toCharArray());

            KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
            kmf.init(ks, keyStorePassword.toCharArray());

            KeyManager[] km = kmf.getKeyManagers();
            TrustManager[] tm = tmFactory.getTrustManagers();

            /* Set up SSL prereqs for Netty. */
            SSLContext sslContext = SSLContext.getInstance("TLS");
            sslContext.init(km, tm, null);
            SSLEngine sslEngine = sslContext.createSSLEngine();

            /* We are the server and we will create secure sessions. */
            sslEngine.setUseClientMode(false);
            sslEngine.setEnableSessionCreation(true);

            /* These are redundant (default), but for clarity... */
            sslEngine.setEnabledProtocols(sslEngine.getSupportedProtocols()); 
            sslEngine.setEnabledCipherSuites(sslEngine.getSupportedCipherSuites());

            /* First, decrypt w/handler+engine; then, proceed with rest of handlers. */
            pipeline.addLast(PipelineHandler.SSL_TLS_ENCODER_DECODER, new SslHandler(sslEngine));
            log.info("SSL OpenFlow socket initialized and handler ready for switch.");
        } catch (Exception e) { /* There are lots of possible exceptions to catch, so this should get them all. */
            log.error("Exception initializing SSL OpenFlow socket: {}", e.getMessage());
            throw e; /* If we wanted secure but didn't get it, we should bail. */
        }
    }

    pipeline.addLast(PipelineHandler.OF_MESSAGE_DECODER,
            new OFMessageDecoder());
    pipeline.addLast(PipelineHandler.OF_MESSAGE_ENCODER,
            new OFMessageEncoder());
    pipeline.addLast(PipelineHandler.MAIN_IDLE,
            new IdleStateHandler(PipelineIdleReadTimeout.MAIN,
                    PipelineIdleWriteTimeout.MAIN,
                    0));
    pipeline.addLast(PipelineHandler.READ_TIMEOUT, new ReadTimeoutHandler(30));
    pipeline.addLast(PipelineHandler.CHANNEL_HANDSHAKE_TIMEOUT,
            new HandshakeTimeoutHandler(
                    handler,
                    timer,
                    PipelineHandshakeTimeout.CHANNEL));

    pipeline.addLast(PipelineHandler.CHANNEL_HANDLER, handler);
}
项目:floodlight1.2-delay    文件:OFChannelInitializer.java   
@Override
protected void initChannel(Channel ch) throws Exception {
    ChannelPipeline pipeline = ch.pipeline();
    OFChannelHandler handler = new OFChannelHandler(
            switchManager,
            connectionListener,
            pipeline,
            debugCounters,
            timer,
            ofBitmaps,
            defaultFactory);

    if (keyStore != null && keyStorePassword != null) {
        try {
            /* Set up factories and stores. */
            TrustManagerFactory tmFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
            KeyStore tmpKS = null;
            tmFactory.init(tmpKS);

            /* Use keystore/pass defined in properties file. */
            KeyStore ks = KeyStore.getInstance("JKS");
            ks.load(new FileInputStream(keyStore), keyStorePassword.toCharArray());

            KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
            kmf.init(ks, keyStorePassword.toCharArray());

            KeyManager[] km = kmf.getKeyManagers();
            TrustManager[] tm = tmFactory.getTrustManagers();

            /* Set up SSL prereqs for Netty. */
            SSLContext sslContext = SSLContext.getInstance("TLS");
            sslContext.init(km, tm, null);
            SSLEngine sslEngine = sslContext.createSSLEngine();

            /* We are the server and we will create secure sessions. */
            sslEngine.setUseClientMode(false);
            sslEngine.setEnableSessionCreation(true);

            /* These are redundant (default), but for clarity... */
            sslEngine.setEnabledProtocols(sslEngine.getSupportedProtocols()); 
            sslEngine.setEnabledCipherSuites(sslEngine.getSupportedCipherSuites());

            /* First, decrypt w/handler+engine; then, proceed with rest of handlers. */
            pipeline.addLast(PipelineHandler.SSL_TLS_ENCODER_DECODER, new SslHandler(sslEngine));
            log.info("SSL OpenFlow socket initialized and handler ready for switch.");
        } catch (Exception e) { /* There are lots of possible exceptions to catch, so this should get them all. */
            log.error("Exception initializing SSL OpenFlow socket: {}", e.getMessage());
            throw e; /* If we wanted secure but didn't get it, we should bail. */
        }
    }

    pipeline.addLast(PipelineHandler.OF_MESSAGE_DECODER,
            new OFMessageDecoder());
    pipeline.addLast(PipelineHandler.OF_MESSAGE_ENCODER,
            new OFMessageEncoder());
    pipeline.addLast(PipelineHandler.MAIN_IDLE,
            new IdleStateHandler(PipelineIdleReadTimeout.MAIN,
                    PipelineIdleWriteTimeout.MAIN,
                    0));
    pipeline.addLast(PipelineHandler.READ_TIMEOUT, new ReadTimeoutHandler(30));
    pipeline.addLast(PipelineHandler.CHANNEL_HANDSHAKE_TIMEOUT,
            new HandshakeTimeoutHandler(
                    handler,
                    timer,
                    PipelineHandshakeTimeout.CHANNEL));

    pipeline.addLast(PipelineHandler.CHANNEL_HANDLER, handler);
}
项目:floodlight-hardware    文件:OFChannelInitializer.java   
@Override
protected void initChannel(Channel ch) throws Exception {
    ChannelPipeline pipeline = ch.pipeline();
    OFChannelHandler handler = new OFChannelHandler(
            switchManager,
            connectionListener,
            pipeline,
            debugCounters,
            timer,
            ofBitmaps,
            defaultFactory);

    if (keyStore != null && keyStorePassword != null) {
        try {
            /* Set up factories and stores. */
            TrustManagerFactory tmFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
            KeyStore tmpKS = null;
            tmFactory.init(tmpKS);

            /* Use keystore/pass defined in properties file. */
            KeyStore ks = KeyStore.getInstance("JKS");
            ks.load(new FileInputStream(keyStore), keyStorePassword.toCharArray());

            KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
            kmf.init(ks, keyStorePassword.toCharArray());

            KeyManager[] km = kmf.getKeyManagers();
            TrustManager[] tm = tmFactory.getTrustManagers();

            /* Set up SSL prereqs for Netty. */
            SSLContext sslContext = SSLContext.getInstance("TLS");
            sslContext.init(km, tm, null);
            SSLEngine sslEngine = sslContext.createSSLEngine();

            /* We are the server and we will create secure sessions. */
            sslEngine.setUseClientMode(false);
            sslEngine.setEnableSessionCreation(true);

            /* These are redundant (default), but for clarity... */
            sslEngine.setEnabledProtocols(sslEngine.getSupportedProtocols());
            sslEngine.setEnabledCipherSuites(sslEngine.getSupportedCipherSuites());

            /* First, decrypt w/handler+engine; then, proceed with rest of handlers. */
            pipeline.addLast(PipelineHandler.SSL_TLS_ENCODER_DECODER, new SslHandler(sslEngine));
            log.info("SSL OpenFlow socket initialized and handler ready for switch.");
        } catch (Exception e) { /* There are lots of possible exceptions to catch, so this should get them all. */
            log.error("Exception initializing SSL OpenFlow socket: {}", e.getMessage());
            throw e; /* If we wanted secure but didn't get it, we should bail. */
        }
    }

    pipeline.addLast(PipelineHandler.OF_MESSAGE_DECODER,
            new OFMessageDecoder());
    pipeline.addLast(PipelineHandler.OF_MESSAGE_ENCODER,
            new OFMessageEncoder());
    pipeline.addLast(PipelineHandler.MAIN_IDLE,
            new IdleStateHandler(PipelineIdleReadTimeout.MAIN,
                    PipelineIdleWriteTimeout.MAIN,
                    0));
    pipeline.addLast(PipelineHandler.READ_TIMEOUT, new ReadTimeoutHandler(30));
    pipeline.addLast(PipelineHandler.CHANNEL_HANDSHAKE_TIMEOUT,
            new HandshakeTimeoutHandler(
                    handler,
                    timer,
                    PipelineHandshakeTimeout.CHANNEL));

    pipeline.addLast(PipelineHandler.CHANNEL_HANDLER, handler);
}
项目:ACAMPController    文件:OFChannelInitializer.java   
@Override
protected void initChannel(Channel ch) throws Exception {
    ChannelPipeline pipeline = ch.pipeline();
    OFChannelHandler handler = new OFChannelHandler(
            switchManager,
            connectionListener,
            pipeline,
            debugCounters,
            timer,
            ofBitmaps,
            defaultFactory);

    if (keyStore != null && keyStorePassword != null) {
        try {
            /* Set up factories and stores. */
            TrustManagerFactory tmFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
            KeyStore tmpKS = null;
            tmFactory.init(tmpKS);

            /* Use keystore/pass defined in properties file. */
            KeyStore ks = KeyStore.getInstance("JKS");
            ks.load(new FileInputStream(keyStore), keyStorePassword.toCharArray());

            KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
            kmf.init(ks, keyStorePassword.toCharArray());

            KeyManager[] km = kmf.getKeyManagers();
            TrustManager[] tm = tmFactory.getTrustManagers();

            /* Set up SSL prereqs for Netty. */
            SSLContext sslContext = SSLContext.getInstance("TLS");
            sslContext.init(km, tm, null);
            SSLEngine sslEngine = sslContext.createSSLEngine();

            /* We are the server and we will create secure sessions. */
            sslEngine.setUseClientMode(false);
            sslEngine.setEnableSessionCreation(true);

            /* These are redundant (default), but for clarity... */
            sslEngine.setEnabledProtocols(sslEngine.getSupportedProtocols()); 
            sslEngine.setEnabledCipherSuites(sslEngine.getSupportedCipherSuites());

            /* First, decrypt w/handler+engine; then, proceed with rest of handlers. */
            pipeline.addLast(PipelineHandler.SSL_TLS_ENCODER_DECODER, new SslHandler(sslEngine));
            log.info("SSL OpenFlow socket initialized and handler ready for switch.");
        } catch (Exception e) { /* There are lots of possible exceptions to catch, so this should get them all. */
            log.error("Exception initializing SSL OpenFlow socket: {}", e.getMessage());
            throw e; /* If we wanted secure but didn't get it, we should bail. */
        }
    }

    pipeline.addLast(PipelineHandler.OF_MESSAGE_DECODER,
            new OFMessageDecoder());
    pipeline.addLast(PipelineHandler.OF_MESSAGE_ENCODER,
            new OFMessageEncoder());
    pipeline.addLast(PipelineHandler.MAIN_IDLE,
            new IdleStateHandler(PipelineIdleReadTimeout.MAIN,
                    PipelineIdleWriteTimeout.MAIN,
                    0));
    pipeline.addLast(PipelineHandler.READ_TIMEOUT, new ReadTimeoutHandler(30));
    pipeline.addLast(PipelineHandler.CHANNEL_HANDSHAKE_TIMEOUT,
            new HandshakeTimeoutHandler(
                    handler,
                    timer,
                    PipelineHandshakeTimeout.CHANNEL));

    pipeline.addLast(PipelineHandler.CHANNEL_HANDLER, handler);
}