first draft implementation of openflowjava-core 95/895/3
authormichal.polkorab <michal.polkorab@pantheon.sk>
Fri, 16 Aug 2013 14:16:15 +0000 (16:16 +0200)
committermichal.polkorab <michal.polkorab@pantheon.sk>
Fri, 30 Aug 2013 00:18:51 +0000 (17:18 -0700)
fix change packaging from pom to jar

adding targets to ignore list

improved logging, response support, comments resolved

Signed-off-by: michal.polkorab <michal.polkorab@pantheon.sk>
Change-Id: Ibada27dbc9de8028e6eee044ed08e1c699e32e2f

25 files changed:
.gitignore [new file with mode: 0644]
openflow-protocol-api/pom.xml
openflow-protocol-impl/pom.xml
openflow-protocol-impl/src/main/java/org/openflow/clients/SecureSimpleClient.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/openflow/clients/SecureSimpleClientHandler.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/openflow/clients/SecureSimpleClientInitializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/openflow/clients/SimpleClient.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/openflow/clients/SimpleClientHandler.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/openflow/core/DeserializationFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/openflow/core/OF13Codec.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/openflow/core/OFFrameDecoder.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/openflow/core/OFVersionDetector.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/openflow/core/SerializationFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/openflow/core/SslContextFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/openflow/core/SslKeyStore.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/openflow/core/SslTrustManagerFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/openflow/core/TCPHandler.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/openflow/core/TLSDetector.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/openflow/util/ByteBufUtils.java [new file with mode: 0644]
openflow-protocol-impl/src/main/resources/key.bin [new file with mode: 0644]
openflow-protocol-impl/src/main/resources/key.raw [new file with mode: 0644]
openflow-protocol-impl/src/main/resources/log4j.xml [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/openflow/example/TCPHandlerTest.java [new file with mode: 0644]
openflow-protocol-spi/pom.xml
pom.xml

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..3b80eeb
--- /dev/null
@@ -0,0 +1,6 @@
+**/target\r
+**/.classpath\r
+**/.project\r
+**/.settings\r
+**/.externalToolBuilders\r
+**/maven-eclipse.xml
\ No newline at end of file
index 0be94c211317bedc50482e3d429a824cd1a1fa8e..b54aa23e0b9ead51a5ec841cceb92cfd71956fc7 100644 (file)
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.opendaylight.openflow</groupId>
-               <artifactId>openflow-protocol-parent</artifactId>
-               <version>0.1-SNAPSHOT</version>
-       </parent>
-       <artifactId>openflow-protocol-api</artifactId>
-       <name>Openflow Protocol Library - API</name>
-
-       <build>
-        <plugins>
-            <plugin>
-                <groupId>org.opendaylight.yangtools</groupId>
-                <artifactId>yang-maven-plugin</artifactId>
-                <version>0.5.7-SNAPSHOT</version>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>generate-sources</goal>
-                        </goals>
-                        <configuration>
-                            <yangFilesRootDir>src/main/yang</yangFilesRootDir>
-                            <codeGenerators>
-                                <generator>
-                                    <codeGeneratorClass>
-                                        org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl
-                                    </codeGeneratorClass>
-                                    <outputBaseDir>
-                                        target/generated-sources/sal
-                                    </outputBaseDir>
-                                </generator>
-                            </codeGenerators >
-                            <inspectDependencies>false</inspectDependencies>
-                        </configuration>
-                    </execution>
-                </executions>
-
-                <dependencies>
-                    <dependency>
-                        <groupId>org.opendaylight.yangtools</groupId>
-                        <artifactId>maven-sal-api-gen-plugin</artifactId>
-                        <version>0.5.7-SNAPSHOT</version>
-                        <type>jar</type>
-                    </dependency>
-                </dependencies>
-            </plugin>
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>build-helper-maven-plugin</artifactId>
-                <version>1.7</version>
-                <executions>
-                    <execution>
-                        <phase>generate-sources</phase>
-                        <goals>
-                            <goal>add-source</goal>
-                        </goals>
-                        <configuration>
-                            <sources>
-                                <source>target/generated-sources/sal</source>
-                            </sources>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
-        <pluginManagement>
-            <plugins>
-                <!--This plugin's configuration is used to store Eclipse 
-                    m2e settings only. It has no influence on the Maven build itself. -->
-                <plugin>
-                    <groupId>org.eclipse.m2e</groupId>
-                    <artifactId>lifecycle-mapping</artifactId>
-                    <version>1.0.0</version>
-                    <configuration>
-                        <lifecycleMappingMetadata>
-                            <pluginExecutions>
-                                <pluginExecution>
-                                    <pluginExecutionFilter>
-                                        <groupId>
-                                            org.opendaylight.controller
-                                        </groupId>
-                                        <artifactId>
-                                            yang-maven-plugin
-                                        </artifactId>
-                                        <versionRange>
-                                            [0.5,)
-                                        </versionRange>
-                                        <goals>
-                                            <goal>
-                                                generate-sources
-                                            </goal>
-                                        </goals>
-                                    </pluginExecutionFilter>
-                                    <action>
-                                        <ignore></ignore>
-                                    </action>
-                                </pluginExecution>
-                            </pluginExecutions>
-                        </lifecycleMappingMetadata>
-                    </configuration>
-                </plugin>
-            </plugins>
-        </pluginManagement>
-    </build>
-    <dependencies>
-        <dependency>
-            <groupId>org.opendaylight.yangtools</groupId>
-            <artifactId>yang-binding</artifactId>
-            <version>0.5.7-SNAPSHOT</version>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.yangtools</groupId>
-            <artifactId>yang-common</artifactId>
-            <version>0.5.7-SNAPSHOT</version>
-        </dependency>
-    </dependencies>
-</project>
\ No newline at end of file
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
+       <modelVersion>4.0.0</modelVersion>\r
+       <parent>\r
+               <groupId>org.opendaylight.openflow</groupId>\r
+               <artifactId>openflow-protocol-parent</artifactId>\r
+               <version>0.1-SNAPSHOT</version>\r
+       </parent>\r
+       <artifactId>openflow-protocol-api</artifactId>\r
+       <name>Openflow Protocol Library - API</name>\r
+\r
+       <build>\r
+        <plugins>\r
+            <plugin>\r
+                <groupId>org.opendaylight.yangtools</groupId>\r
+                <artifactId>yang-maven-plugin</artifactId>\r
+                <version>0.5.7-SNAPSHOT</version>\r
+                <executions>\r
+                    <execution>\r
+                        <goals>\r
+                            <goal>generate-sources</goal>\r
+                        </goals>\r
+                        <configuration>\r
+                            <yangFilesRootDir>src/main/yang</yangFilesRootDir>\r
+                            <codeGenerators>\r
+                                <generator>\r
+                                    <codeGeneratorClass>\r
+                                        org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl\r
+                                    </codeGeneratorClass>\r
+                                    <outputBaseDir>\r
+                                        target/generated-sources/sal\r
+                                    </outputBaseDir>\r
+                                </generator>\r
+                            </codeGenerators >\r
+                            <inspectDependencies>false</inspectDependencies>\r
+                        </configuration>\r
+                    </execution>\r
+                </executions>\r
+\r
+                <dependencies>\r
+                    <dependency>\r
+                        <groupId>org.opendaylight.yangtools</groupId>\r
+                        <artifactId>maven-sal-api-gen-plugin</artifactId>\r
+                        <version>0.5.7-SNAPSHOT</version>\r
+                        <type>jar</type>\r
+                    </dependency>\r
+                </dependencies>\r
+            </plugin>\r
+            <plugin>\r
+                <groupId>org.codehaus.mojo</groupId>\r
+                <artifactId>build-helper-maven-plugin</artifactId>\r
+                <version>1.7</version>\r
+                <executions>\r
+                    <execution>\r
+                        <phase>generate-sources</phase>\r
+                        <goals>\r
+                            <goal>add-source</goal>\r
+                        </goals>\r
+                        <configuration>\r
+                            <sources>\r
+                                <source>target/generated-sources/sal</source>\r
+                            </sources>\r
+                        </configuration>\r
+                    </execution>\r
+                </executions>\r
+            </plugin>\r
+        </plugins>\r
+        <pluginManagement>\r
+            <plugins>\r
+                <!--This plugin's configuration is used to store Eclipse \r
+                    m2e settings only. It has no influence on the Maven build itself. -->\r
+                <plugin>\r
+                    <groupId>org.eclipse.m2e</groupId>\r
+                    <artifactId>lifecycle-mapping</artifactId>\r
+                    <version>1.0.0</version>\r
+                    <configuration>\r
+                        <lifecycleMappingMetadata>\r
+                            <pluginExecutions>\r
+                                <pluginExecution>\r
+                                    <pluginExecutionFilter>\r
+                                        <groupId>\r
+                                            org.opendaylight.controller\r
+                                        </groupId>\r
+                                        <artifactId>\r
+                                            yang-maven-plugin\r
+                                        </artifactId>\r
+                                        <versionRange>\r
+                                            [0.5,)\r
+                                        </versionRange>\r
+                                        <goals>\r
+                                            <goal>\r
+                                                generate-sources\r
+                                            </goal>\r
+                                        </goals>\r
+                                    </pluginExecutionFilter>\r
+                                    <action>\r
+                                        <ignore></ignore>\r
+                                    </action>\r
+                                </pluginExecution>\r
+                            </pluginExecutions>\r
+                        </lifecycleMappingMetadata>\r
+                    </configuration>\r
+                </plugin>\r
+            </plugins>\r
+        </pluginManagement>\r
+    </build>\r
+    <dependencies>\r
+        <dependency>\r
+            <groupId>org.opendaylight.yangtools</groupId>\r
+            <artifactId>yang-binding</artifactId>\r
+            <version>0.5.7-SNAPSHOT</version>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.opendaylight.yangtools</groupId>\r
+            <artifactId>yang-common</artifactId>\r
+            <version>0.5.7-SNAPSHOT</version>\r
+        </dependency>\r
+    </dependencies>\r
+</project>\r
index 9db59434daf2450ac2dffc61a0ecdd16fcbb585b..41e99deb10341e4b16b247d659c53f57029c6309 100644 (file)
@@ -1,31 +1,45 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.opendaylight.openflow</groupId>
-               <artifactId>openflow-protocol-parent</artifactId>
-               <version>0.1-SNAPSHOT</version>
-       </parent>
-       <artifactId>openflow-protocol-impl</artifactId>
-       <name>Openflow Protocol Library - Implementation</name>
-
-
-       <dependencies>
-               <dependency>
-                       <groupId>org.opendaylight.openflow</groupId>
-                       <artifactId>openflow-protocol-api</artifactId>
-                       <version>${project.version}</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.opendaylight.openflow</groupId>
-                       <artifactId>openflow-protocol-spi</artifactId>
-                       <version>${project.version}</version>
-               </dependency>
-               <dependency>
-                       <!-- TODO: Pick netty-* dependencies which are required, leave all optional -->
-                       <groupId>io.netty</groupId>
-                       <artifactId>netty-all</artifactId>
-                       <version>4.0.4.Final</version>
-               </dependency>
-       </dependencies>
-</project>
\ No newline at end of file
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.opendaylight.openflow</groupId>
+        <artifactId>openflow-protocol-parent</artifactId>
+        <version>0.1-SNAPSHOT</version>
+    </parent>
+    <artifactId>openflow-protocol-impl</artifactId>
+    <packaging>jar</packaging>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.opendaylight.openflow</groupId>
+            <artifactId>openflow-protocol-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.openflow</groupId>
+            <artifactId>openflow-protocol-spi</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>io.netty</groupId>
+            <artifactId>netty-all</artifactId>
+            <version>4.0.4.Final</version>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <version>1.7.5</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <version>14.0.1</version>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.10</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/openflow-protocol-impl/src/main/java/org/openflow/clients/SecureSimpleClient.java b/openflow-protocol-impl/src/main/java/org/openflow/clients/SecureSimpleClient.java
new file mode 100644 (file)
index 0000000..c73c4e9
--- /dev/null
@@ -0,0 +1,123 @@
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+package org.openflow.clients;
+
+import io.netty.bootstrap.Bootstrap;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.nio.NioSocketChannel;
+
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.InetAddress;
+import java.nio.charset.Charset;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Simple client with TLS connection to host
+ *
+ * @author michal.polkorab
+ */
+public class SecureSimpleClient {
+    
+    private final String host;
+    private final int port;
+    private static String filename;
+    private static final Logger logger = LoggerFactory.getLogger(SecureSimpleClient.class);
+
+    /**
+     * Constructor of class
+     *
+     * @param host address of host
+     * @param port host listening port
+     */
+    public SecureSimpleClient(String host, int port) {
+        this.host = host;
+        this.port = port;
+    }
+
+    /**
+     * Starting class of {@link SecureSimpleClient}
+     *
+     * @throws Exception connection exception
+     */
+    public void run() throws Exception {
+        EventLoopGroup group = new NioEventLoopGroup();
+        try {
+            Bootstrap b = new Bootstrap();
+            b.group(group)
+                    .channel(NioSocketChannel.class)
+                    .handler(new SecureSimpleClientInitializer());
+            
+            Channel ch = b.connect(host, port).sync().channel();
+            
+            byte[] bytearray = new byte[64];
+            ByteBuf buffy = ch.alloc().buffer(128);
+            
+            if (filename != null) {
+                FileInputStream fis = null;
+                try {
+                    fis = new FileInputStream(filename);
+                    logger.debug("Size to read (in bytes) : " + fis.available());
+                    int lenght;
+                    while ((lenght = fis.read(bytearray)) != -1) {
+                        buffy.writeBytes(bytearray, 0, lenght);
+                    }
+                    ch.writeAndFlush(buffy);
+                    fis.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            
+            BufferedReader in = new BufferedReader(new InputStreamReader(System.in, Charset.defaultCharset()));
+            for (;;) {
+                String line = in.readLine();
+                if (line == null) {
+                    break;
+                }
+                buffy = ch.alloc().buffer(128);
+                buffy.writeBytes(line.getBytes(Charset.defaultCharset()));
+                ch.writeAndFlush(buffy);
+                
+                if ("bye".equals(line.toLowerCase())) {
+                    logger.info("Bye");
+                    in.close();
+                    break;
+                }
+            }
+        } finally {
+            group.shutdownGracefully();
+        }
+    }
+
+    /**
+     * Sets up {@link SecureSimpleClient} and fires run()
+     *
+     * @param args
+     * @throws Exception
+     */
+    public static void main(String[] args) throws Exception {
+        String host;
+        int port;
+        if (args.length != 3) {
+            logger.error("Usage: " + SecureSimpleClient.class.getSimpleName()
+                    + " <host> <port> <filename>");
+            logger.error("Trying to use default setting.");
+            InetAddress ia = InetAddress.getLocalHost();
+            InetAddress[] all = InetAddress.getAllByName(ia.getHostName());
+            host = all[0].getHostAddress();
+            port = 6633;
+            filename = null;
+        } else {
+            host = args[0];
+            port = Integer.parseInt(args[1]);
+            filename = args[2];
+        }
+        new SecureSimpleClient(host, port).run();
+    }
+}
\ No newline at end of file
diff --git a/openflow-protocol-impl/src/main/java/org/openflow/clients/SecureSimpleClientHandler.java b/openflow-protocol-impl/src/main/java/org/openflow/clients/SecureSimpleClientHandler.java
new file mode 100644 (file)
index 0000000..fdd410d
--- /dev/null
@@ -0,0 +1,27 @@
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+
+package org.openflow.clients;
+
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+
+/** InboundHanler for {@link SecureSimpleClient}
+ * 
+ * @author michal.polkorab
+ */
+public class SecureSimpleClientHandler extends ChannelInboundHandlerAdapter/*SimpleChannelInboundHandler<Object>*/ {
+
+    private static final Logger logger = LoggerFactory.getLogger(SecureSimpleClientHandler.class);
+
+    @Override
+    public void channelRead(ChannelHandlerContext ctx, Object msg)
+            throws Exception {
+        // TODO Auto-generated method stub
+        logger.info(msg.toString());
+    }
+}
\ No newline at end of file
diff --git a/openflow-protocol-impl/src/main/java/org/openflow/clients/SecureSimpleClientInitializer.java b/openflow-protocol-impl/src/main/java/org/openflow/clients/SecureSimpleClientInitializer.java
new file mode 100644 (file)
index 0000000..99192be
--- /dev/null
@@ -0,0 +1,28 @@
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+
+package org.openflow.clients;
+
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelPipeline;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.handler.ssl.SslHandler;
+
+import javax.net.ssl.SSLEngine;
+import org.openflow.core.SslContextFactory;
+
+/** Initializes {@link SecureSimpleClient} pipeline
+ * 
+ * @author michal.polkorab
+ */
+public class SecureSimpleClientInitializer extends ChannelInitializer<SocketChannel> {
+
+    @Override
+    public void initChannel(SocketChannel ch) throws Exception {
+        ChannelPipeline pipeline = ch.pipeline();
+        SSLEngine engine =
+            SslContextFactory.getClientContext().createSSLEngine();
+        engine.setUseClientMode(true);
+        pipeline.addLast("ssl", new SslHandler(engine));
+        pipeline.addLast("handler", new SecureSimpleClientHandler());
+    }
+}
\ No newline at end of file
diff --git a/openflow-protocol-impl/src/main/java/org/openflow/clients/SimpleClient.java b/openflow-protocol-impl/src/main/java/org/openflow/clients/SimpleClient.java
new file mode 100644 (file)
index 0000000..7136b83
--- /dev/null
@@ -0,0 +1,108 @@
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+package org.openflow.clients;
+
+import io.netty.bootstrap.Bootstrap;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.nio.NioSocketChannel;
+
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.InetAddress;
+import java.nio.charset.Charset;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** Simple client
+*
+* @author michal.polkorab
+*/
+public class SimpleClient {
+
+    private static final Logger logger = LoggerFactory.getLogger(SimpleClient.class);
+    private static String filename = null;
+
+    /** 
+     * Starts the client with passed parameters or tries default settings
+     * @param args 
+     * @throws Exception
+     */
+    public static void main(String[] args) throws Exception {
+        String host;
+        int port;
+        if (args.length != 3) {
+            logger.error("Usage: " + SimpleClient.class.getSimpleName()
+                    + " <host> <port> <filename>");
+            logger.error("Trying to use default setting.");
+            InetAddress ia = InetAddress.getLocalHost();
+            InetAddress[] all = InetAddress.getAllByName(ia.getHostName());
+            host = all[0].getHostAddress();
+            port = 6633;
+            filename = null;
+        } else {
+            host = args[0];
+            port = Integer.parseInt(args[1]);
+            filename = args[2];
+        }
+
+        EventLoopGroup group = new NioEventLoopGroup();
+        ByteBuf buffy = null;
+        Channel ch = null;
+        Bootstrap b = null;
+        byte[] bytearray = new byte[64];
+
+        try {
+            logger.info("SimpleClient - Creating TCP connection");
+            b = new Bootstrap();
+            b.group(group)
+                    .channel(NioSocketChannel.class)
+                    .handler(new SimpleClientHandler());
+
+            ch = b.connect(host, port).sync().channel();
+
+            buffy = ch.alloc().buffer(128);
+
+            if (filename != null) {
+                FileInputStream fis = null;
+                try {
+                    fis = new FileInputStream(filename);
+                    logger.debug("Size to read (in bytes) : " + fis.available());
+                    int lenght;
+                    while ((lenght = fis.read(bytearray)) != -1) {
+                        buffy.writeBytes(bytearray, 0, lenght);
+                    }
+                    ch.writeAndFlush(buffy);
+                    fis.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+
+            BufferedReader in = new BufferedReader(new InputStreamReader(System.in, Charset.defaultCharset()));
+            for (;;) {
+                String line = in.readLine();
+                if (line == null) {
+                    break;
+                }
+                if ("bye".equals(line.toLowerCase())) {
+                    logger.info("bye");
+                    in.close();
+                    break;
+                }
+                buffy = ch.alloc().buffer(128);
+                buffy.writeBytes(line.getBytes(Charset.defaultCharset()));
+                ch.writeAndFlush(buffy);
+            }
+
+            ch.closeFuture().sync();
+        } finally {
+            logger.info("Exiting");
+            group.shutdownGracefully();
+        }
+    }
+}
diff --git a/openflow-protocol-impl/src/main/java/org/openflow/clients/SimpleClientHandler.java b/openflow-protocol-impl/src/main/java/org/openflow/clients/SimpleClientHandler.java
new file mode 100644 (file)
index 0000000..eb4171c
--- /dev/null
@@ -0,0 +1,32 @@
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
+\r
+package org.openflow.clients;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+import io.netty.channel.ChannelHandlerContext;\r
+import io.netty.channel.ChannelInboundHandlerAdapter;\r
+import org.openflow.util.ByteBufUtils;\r
+\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+/**\r
+ *\r
+ * @author michal.polkorab\r
+ */\r
+public class SimpleClientHandler extends ChannelInboundHandlerAdapter/*ChannelOutboundHandlerAdapter*/ {\r
+\r
+    private static final Logger logger = LoggerFactory.getLogger(SimpleClientHandler.class);\r
+\r
+    @Override\r
+    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {\r
+        logger.info("SimpleClientHandler - start of read");\r
+        ByteBuf bb = (ByteBuf) msg;\r
+        if (logger.isDebugEnabled()) {\r
+            logger.debug(ByteBufUtils.byteBufToHexString(bb));\r
+        }\r
+        logger.info(msg.toString());\r
+        logger.info("SimpleClientHandler - end of read");\r
+    }\r
+    \r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/openflow/core/DeserializationFactory.java b/openflow-protocol-impl/src/main/java/org/openflow/core/DeserializationFactory.java
new file mode 100644 (file)
index 0000000..6ab6ceb
--- /dev/null
@@ -0,0 +1,155 @@
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
+package org.openflow.core;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+import java.util.logging.Level;\r
+import java.util.logging.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+/**\r
+ *\r
+ * @author michal.polkorab\r
+ */\r
+public class DeserializationFactory {\r
+\r
+    private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(DeserializationFactory.class);\r
+\r
+    public DeserializationFactory(ByteBuf bb) {\r
+        short type = bb.readUnsignedByte();\r
+\r
+        switch (type) {\r
+            // HELLO\r
+            case 0: {\r
+                LOGGER.info("OFPT_HELLO received");\r
+                byte[] hello = new byte[]{0x04, 0x0, 0x0, 0x08, 0x0, 0x0, 0x0, 0x01};\r
+                //out.writeBytes(hello);\r
+                break;\r
+            }\r
+            // ERROR\r
+            case 1:\r
+                LOGGER.info("OFPT_ERROR received");\r
+                break;\r
+            // ECHO_REQUEST\r
+            case 2: {\r
+                LOGGER.info("OFPT_ECHO_REQUEST received");\r
+                byte[] echoReply = new byte[]{0x04, 0x03, 0x00, 0x08};\r
+//                out.writeBytes(echoReply);\r
+//                out.writeInt((int) xid);\r
+                // TODO - append original data field\r
+                break;\r
+            }\r
+            // ECHO_REPLY\r
+            case 3:\r
+                LOGGER.info("OFPT_ECHO_REPLY received");\r
+                break;\r
+            // EXPERIMENTER\r
+            case 4:\r
+                LOGGER.info("OFPT_ECHO_REPLY received");\r
+                break;\r
+            // FEATURES_REQUEST\r
+            case 5:\r
+                LOGGER.info("OFPT_FEATURES_REQUEST received");\r
+                break;\r
+            // FEATURES_REPLY\r
+            case 6:\r
+                LOGGER.info("OFPT_FEATURES_REPLY received");\r
+                break;\r
+            // GET_CONFIG_REQUEST\r
+            case 7:\r
+                LOGGER.info("OFPT_ECHO_REPLY received");\r
+                break;\r
+            // GET_CONFIG_REPLY\r
+            case 8:\r
+                LOGGER.info("OFPT_ECHO_REPLY received");\r
+                break;\r
+            // SET_CONFIG\r
+            case 9:\r
+                LOGGER.info("OFPT_ECHO_REPLY received");\r
+                break;\r
+            // PACKET_IN\r
+            case 10:\r
+                LOGGER.info("OFPT_ECHO_REPLY received");\r
+                break;\r
+            // FLOW_REMOVED\r
+            case 11:\r
+                LOGGER.info("OFPT_ECHO_REPLY received");\r
+                break;\r
+            // PORT_STATUS\r
+            case 12:\r
+                LOGGER.info("OFPT_ECHO_REPLY received");\r
+                break;\r
+            // PACKET_OUT\r
+            case 13:\r
+                LOGGER.info("OFPT_ECHO_REPLY received");\r
+                break;\r
+            // FLOW_MOD\r
+            case 14:\r
+                LOGGER.info("OFPT_ECHO_REPLY received");\r
+                break;\r
+            // GROUP_MOD\r
+            case 15:\r
+                LOGGER.info("OFPT_ECHO_REPLY received");\r
+                break;\r
+            // PORT_MOD\r
+            case 16:\r
+                LOGGER.info("OFPT_ECHO_REPLY received");\r
+                break;\r
+            // TABLE_MOD\r
+            case 17:\r
+                LOGGER.info("OFPT_ECHO_REPLY received");\r
+                break;\r
+            // MULTIPART_REQUEST\r
+            case 18:\r
+                LOGGER.info("OFPT_ECHO_REPLY received");\r
+                break;\r
+            // MULTIPART_REPLY\r
+            case 19:\r
+                LOGGER.info("OFPT_ECHO_REPLY received");\r
+                break;\r
+            // BARRIER_REQUEST\r
+            case 20:\r
+                LOGGER.info("OFPT_ECHO_REPLY received");\r
+                break;\r
+            // BARRIER_REPLY\r
+            case 21:\r
+                LOGGER.info("OFPT_ECHO_REPLY received");\r
+                break;\r
+            // QUEUE_GET_CONFIG_REQUEST\r
+            case 22:\r
+                LOGGER.info("OFPT_ECHO_REPLY received");\r
+                break;\r
+            // QUEUE_GET_CONFIG_REPLY\r
+            case 23:\r
+                LOGGER.info("OFPT_ECHO_REPLY received");\r
+                break;\r
+            // ROLE_REQUEST\r
+            case 24:\r
+                LOGGER.info("OFPT_ECHO_REPLY received");\r
+                break;\r
+            // ROLE_REPLY    \r
+            case 25:\r
+                LOGGER.info("OFPT_ECHO_REPLY received");\r
+                break;\r
+            // GET_ASYNC_REQUEST\r
+            case 26:\r
+                LOGGER.info("OFPT_ECHO_REPLY received");\r
+                break;\r
+            // GET_ASYNC_REPLY\r
+            case 27:\r
+                LOGGER.info("OFPT_ECHO_REPLY received");\r
+                break;\r
+            // SET_ASYNC\r
+            case 28:\r
+                LOGGER.info("OFPT_ECHO_REPLY received");\r
+                break;\r
+            // METER_MOD\r
+            case 29:\r
+                LOGGER.info("OFPT_ECHO_REPLY received");\r
+                break;\r
+\r
+            default:\r
+                LOGGER.info("Received message type: " + type);\r
+                break;\r
+        }\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/openflow/core/OF13Codec.java b/openflow-protocol-impl/src/main/java/org/openflow/core/OF13Codec.java
new file mode 100644 (file)
index 0000000..a9e6d31
--- /dev/null
@@ -0,0 +1,104 @@
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
+package org.openflow.core;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+import io.netty.channel.ChannelHandlerContext;\r
+import io.netty.channel.ChannelInboundHandlerAdapter;\r
+import org.openflow.util.ByteBufUtils;\r
+\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+/**\r
+ * Transforms OpenFlow Protocol messages to Java messages / objects and takes appropriate\r
+ * actions\r
+ *\r
+ * @author michal.polkorab\r
+ */\r
+public class OF13Codec extends ChannelInboundHandlerAdapter {\r
+\r
+    // TODO - fix with enum in API\r
+    private static final int MESSAGE_TYPES = 29;\r
+    private static final byte LATEST_WIRE_PROTOCOL = 0x04;\r
+    private static final Logger LOGGER = LoggerFactory.getLogger(OF13Codec.class);\r
+\r
+    /**\r
+     * Constructor of class\r
+     */\r
+    public OF13Codec() {\r
+        LOGGER.info("Creating OF 1.3 Codec");\r
+        \r
+    }\r
+\r
+    @Override\r
+    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {\r
+        LOGGER.info("Reading frame");\r
+        LOGGER.debug("Received msg is of type: " + msg.getClass().getName());\r
+        ByteBuf bb = (ByteBuf) msg;\r
+        if (LOGGER.isDebugEnabled()) {\r
+            LOGGER.debug(ByteBufUtils.byteBufToHexString(bb));\r
+        }\r
+\r
+        short type = bb.readUnsignedByte();\r
+        int length = bb.readUnsignedShort();\r
+        long xid = bb.readUnsignedInt();\r
+\r
+\r
+        if (!checkOFHeader(type, length)) {\r
+            bb.discardReadBytes();\r
+            LOGGER.info("Non-OF Protocol message received (discarding)");\r
+            return;\r
+        }\r
+\r
+        ByteBuf out = ctx.alloc().buffer();\r
+        switch (type) {\r
+            case 0: {\r
+                LOGGER.info("OFPT_HELLO received");\r
+                byte[] hello = new byte[]{0x04, 0x0, 0x0, 0x08, 0x0, 0x0, 0x0, 0x01};\r
+                out.writeBytes(hello);\r
+                break;\r
+            }\r
+            case 1:\r
+                LOGGER.info("OFPT_ERROR received");\r
+                break;\r
+            case 2: {\r
+                LOGGER.info("OFPT_ECHO_REQUEST received");\r
+                byte[] echoReply = new byte[]{0x04, 0x03, 0x00, 0x08};\r
+                out.writeBytes(echoReply);\r
+                out.writeInt((int) xid);\r
+                // TODO - append original data field\r
+                break;\r
+            }\r
+            case 3:\r
+                LOGGER.info("OFPT_ECHO_REPLY received");\r
+                break;\r
+            case 5:\r
+                LOGGER.info("OFPT_FEATURES_REQUEST received");\r
+                break;\r
+            case 6:\r
+                LOGGER.info("OFPT_FEATURES_REPLY received");\r
+                break;\r
+            default:\r
+                LOGGER.info("Received message type: " + type);\r
+                break;\r
+        }\r
+        if (LOGGER.isDebugEnabled()) {\r
+            LOGGER.debug(ByteBufUtils.byteBufToHexString(out));\r
+        }\r
+\r
+        ctx.writeAndFlush(out);\r
+        LOGGER.info("Flushed");\r
+\r
+        int bytesRemaining = bb.readableBytes();\r
+        LOGGER.debug("Skipping unread bytes");\r
+        bb.skipBytes(bytesRemaining);\r
+        LOGGER.debug("Discarding read bytes");\r
+        LOGGER.debug("RI: " + bb.readerIndex());\r
+        LOGGER.debug("WI: " + bb.writerIndex());\r
+\r
+    }\r
+\r
+    private boolean checkOFHeader(short type, int length) {\r
+        return !((type > MESSAGE_TYPES) || (length < OFFrameDecoder.LENGTH_OF_HEADER));\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/openflow/core/OFFrameDecoder.java b/openflow-protocol-impl/src/main/java/org/openflow/core/OFFrameDecoder.java
new file mode 100644 (file)
index 0000000..2ad4402
--- /dev/null
@@ -0,0 +1,68 @@
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+package org.openflow.core;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.ByteToMessageDecoder;
+import java.util.List;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.openflow.core.TCPHandler.COMPONENT_NAMES;
+
+/**
+ * Class for decoding incoming messages into message frames.
+ *
+ * @author michal.polkorab
+ */
+public class OFFrameDecoder extends ByteToMessageDecoder {
+
+    public static final byte LENGTH_OF_HEADER = 8;
+    private static final byte LENGTH_INDEX_IN_HEADER = 2;
+    private static final Logger LOGGER = LoggerFactory.getLogger(OFFrameDecoder.class);
+
+    /**
+     * Constructor of class.
+     */
+    public OFFrameDecoder() {
+        LOGGER.info("Creating OFFrameDecoder");
+    }
+
+    @Override
+    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
+        LOGGER.warn("Unexpected exception from downstream.", cause);
+        ctx.close();
+    }
+
+    @Override
+    protected void decode(ChannelHandlerContext chc, ByteBuf bb, List<Object> list) throws Exception {
+        if (bb.readableBytes() < LENGTH_OF_HEADER) {
+            return;
+        }
+
+        int length = bb.getUnsignedShort(LENGTH_INDEX_IN_HEADER);
+        if (bb.readableBytes() < length) {
+            return;
+        }
+
+        LOGGER.info("OF Protocol message received");
+
+        enableOFVersionDetector(chc);
+
+        List<String> componentList = chc.pipeline().names();
+        LOGGER.debug(componentList.toString());
+
+        ByteBuf messageBuffer = bb.slice(bb.readerIndex(), length);
+        list.add(messageBuffer);
+        messageBuffer.retain();
+        bb.skipBytes(length);
+    }
+
+    private void enableOFVersionDetector(ChannelHandlerContext ctx) {
+        if (ctx.pipeline().get(COMPONENT_NAMES.OF_VERSION_DETECTOR.name()) == null) {
+            LOGGER.info("Adding OFVD");
+            ctx.pipeline().addLast(COMPONENT_NAMES.OF_VERSION_DETECTOR.name(), new OFVersionDetector());
+        } else {
+            LOGGER.debug("OFVD already in pipeline");
+        }
+    }
+}
diff --git a/openflow-protocol-impl/src/main/java/org/openflow/core/OFVersionDetector.java b/openflow-protocol-impl/src/main/java/org/openflow/core/OFVersionDetector.java
new file mode 100644 (file)
index 0000000..0cd8b3a
--- /dev/null
@@ -0,0 +1,59 @@
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+package org.openflow.core;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.ByteToMessageDecoder;
+import java.util.List;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.openflow.core.TCPHandler.COMPONENT_NAMES;
+
+/**
+ * Class that detects version of used OpenFlow Protocol and engages right OFCodec into
+ * pipeline.
+ *
+ * @author michal.polkorab
+ */
+public class OFVersionDetector extends ByteToMessageDecoder {
+
+    private static final byte OF13_VERSION_ID = 0x04;
+    private static final Logger LOGGER = LoggerFactory.getLogger(OFVersionDetector.class);
+
+    /**
+     * Constructor of class.
+     */
+    public OFVersionDetector() {
+        LOGGER.info("Creating OFVersionDetector");
+    }
+
+    @Override
+    protected void decode(ChannelHandlerContext chc, ByteBuf bb, List<Object> list) throws Exception {
+        LOGGER.info("Decoding frame");
+
+        LOGGER.debug("RI: " + bb.readerIndex());
+        byte version = bb.readByte();
+
+        if (version == OF13_VERSION_ID) {
+            LOGGER.debug("detected version: " + version);
+            enableOF13Codec(chc);
+        } else {
+            LOGGER.warn("detected version: " + version + " - currently not supported");
+            return;
+        }
+
+        ByteBuf messageBuffer = bb.slice();
+        list.add(messageBuffer);
+        messageBuffer.retain();
+        bb.skipBytes(bb.readableBytes());
+    }
+
+    private void enableOF13Codec(ChannelHandlerContext chc) {
+        if (chc.pipeline().get(COMPONENT_NAMES.OF_CODEC.name()) == null) {
+            LOGGER.info("Engaging OF13Codec");
+            chc.pipeline().addLast(COMPONENT_NAMES.OF_CODEC.name(), new OF13Codec());
+        } else {
+            LOGGER.debug("OF13Codec already in pipeline");
+        }
+    }
+}
diff --git a/openflow-protocol-impl/src/main/java/org/openflow/core/SerializationFactory.java b/openflow-protocol-impl/src/main/java/org/openflow/core/SerializationFactory.java
new file mode 100644 (file)
index 0000000..aedb1c4
--- /dev/null
@@ -0,0 +1,13 @@
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
+\r
+package org.openflow.core;\r
+\r
+/**\r
+ *\r
+ * @author michal.polkorab\r
+ */\r
+public abstract class SerializationFactory {\r
+    \r
+    \r
+    \r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/openflow/core/SslContextFactory.java b/openflow-protocol-impl/src/main/java/org/openflow/core/SslContextFactory.java
new file mode 100644 (file)
index 0000000..65f8fd8
--- /dev/null
@@ -0,0 +1,64 @@
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+package org.openflow.core;
+
+import java.security.KeyStore;
+import java.security.Security;
+
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+
+/**
+ * Class for setting up TLS connection.
+ *
+ * @author michal.polkorab
+ */
+public final class SslContextFactory {
+
+    // "TLS" - supports some version of TLS
+    // Use "TLSv1", "TLSv1.1", "TLSv1.2" for specific TLS version
+    private static final String PROTOCOL = "TLS";
+    private static final SSLContext SERVER_CONTEXT;
+    private static final SSLContext CLIENT_CONTEXT;
+
+    static {
+        String algorithm = Security.getProperty("ssl.KeyManagerFactory.algorithm");
+        if (algorithm == null) {
+            algorithm = "SunX509";
+        }
+
+        SSLContext serverContext;
+        SSLContext clientContext;
+        try {
+            KeyStore ks = KeyStore.getInstance("JKS");
+            ks.load(SslKeyStore.asInputStream(),
+                    SslKeyStore.getKeyStorePassword());
+
+            KeyManagerFactory kmf = KeyManagerFactory.getInstance(algorithm);
+            kmf.init(ks, SslKeyStore.getCertificatePassword());
+
+            serverContext = SSLContext.getInstance(PROTOCOL);
+            serverContext.init(kmf.getKeyManagers(), null, null);
+        } catch (Exception e) {
+            throw new Error(
+                    "Failed to initialize the server-side SSLContext", e);
+        }
+        try {
+            clientContext = SSLContext.getInstance(PROTOCOL);
+            clientContext.init(null, SslTrustManagerFactory.getTrustManagers(), null);
+        } catch (Exception e) {
+            throw new Error(
+                    "Failed to initialize the client-side SSLContext", e);
+        }
+
+        SERVER_CONTEXT = serverContext;
+        CLIENT_CONTEXT = clientContext;
+    }
+
+    public static SSLContext getServerContext() {
+        return SERVER_CONTEXT;
+    }
+
+    public static SSLContext getClientContext() {
+        return CLIENT_CONTEXT;
+    }
+}
\ No newline at end of file
diff --git a/openflow-protocol-impl/src/main/java/org/openflow/core/SslKeyStore.java b/openflow-protocol-impl/src/main/java/org/openflow/core/SslKeyStore.java
new file mode 100644 (file)
index 0000000..1acc7a6
--- /dev/null
@@ -0,0 +1,40 @@
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+package org.openflow.core;
+
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+
+/**
+ * Class for storing keys
+ *
+ * @author michal.polkorab
+ */
+public final class SslKeyStore {
+
+    private static final String filename = "/key.bin";
+
+    /**
+     * InputStream instance of key
+     *
+     * @return key as InputStream
+     * @throws FileNotFoundException
+     */
+    public static InputStream asInputStream() throws FileNotFoundException {
+        InputStream in = SslKeyStore.class.getResourceAsStream(filename);
+        return in;
+    }
+
+    /**
+     * @return certificate password as char[]
+     */
+    public static char[] getCertificatePassword() {
+        return "secret".toCharArray();
+    }
+
+    /**
+     * @return KeyStore password as char[]
+     */
+    public static char[] getKeyStorePassword() {
+        return "secret".toCharArray();
+    }
+}
\ No newline at end of file
diff --git a/openflow-protocol-impl/src/main/java/org/openflow/core/SslTrustManagerFactory.java b/openflow-protocol-impl/src/main/java/org/openflow/core/SslTrustManagerFactory.java
new file mode 100644 (file)
index 0000000..e656737
--- /dev/null
@@ -0,0 +1,65 @@
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+package org.openflow.core;
+
+import javax.net.ssl.ManagerFactoryParameters;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.TrustManagerFactorySpi;
+import javax.net.ssl.X509TrustManager;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.cert.X509Certificate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * @author michal.polkorab
+ */
+public class SslTrustManagerFactory extends TrustManagerFactorySpi {
+
+    /**
+     * Logger for SslTrustManagerFactory
+     */
+    public static final Logger logger = LoggerFactory.getLogger(SslTrustManagerFactory.class);
+    private static final TrustManager DUMMY_TRUST_MANAGER = new X509TrustManager() {
+        @Override
+        public X509Certificate[] getAcceptedIssuers() {
+            return new X509Certificate[0];
+        }
+
+        @Override
+        public void checkClientTrusted(X509Certificate[] chain, String authType) {
+            logger.error("UNKNOWN CLIENT CERTIFICATE: " + chain[0].getSubjectDN());
+        }
+
+        @Override
+        public void checkServerTrusted(X509Certificate[] chain, String authType) {
+            logger.error("UNKNOWN SERVER CERTIFICATE: " + chain[0].getSubjectDN());
+        }
+    };
+
+    /**
+     * Getter for TrustManagers
+     *
+     * @return TrustManager[]
+     */
+    public static TrustManager[] getTrustManagers() {
+        return new TrustManager[]{DUMMY_TRUST_MANAGER};
+    }
+
+    @Override
+    protected TrustManager[] engineGetTrustManagers() {
+        return getTrustManagers();
+    }
+
+    @Override
+    protected void engineInit(KeyStore ks) throws KeyStoreException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    protected void engineInit(ManagerFactoryParameters mfp) throws InvalidAlgorithmParameterException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+}
\ No newline at end of file
diff --git a/openflow-protocol-impl/src/main/java/org/openflow/core/TCPHandler.java b/openflow-protocol-impl/src/main/java/org/openflow/core/TCPHandler.java
new file mode 100644 (file)
index 0000000..81e52ab
--- /dev/null
@@ -0,0 +1,114 @@
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+package org.openflow.core;
+
+import io.netty.bootstrap.ServerBootstrap;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelOption;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.channel.socket.nio.NioServerSocketChannel;
+import io.netty.handler.logging.LogLevel;
+import io.netty.handler.logging.LoggingHandler;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Class implementing server over TCP for handling incoming connections.
+ *
+ * @author michal.polkorab
+ */
+public class TCPHandler {
+
+    private int port;
+
+    /**
+     * Enum used for storing names of used components (in pipeline).
+     */
+    public static enum COMPONENT_NAMES {
+
+        /**
+         * First component in pipeline - detecting TLS connections
+         */
+        TLS_DETECTOR,
+        /**
+         * Component for handling TLS frames
+         */
+        SSL_HANDLER,
+        /**
+         * Decodes incoming messages into message frames
+         */
+        OF_FRAME_DECODER,
+        /**
+         * Detects version of incoming OpenFlow Protocol message
+         */
+        OF_VERSION_DETECTOR,
+        /**
+         * Transforms OpenFlow Protocol messages
+         */
+        OF_CODEC,
+        /**
+         * Communicates with upper layers (outside OF Library)
+         */
+        OF_FACADE
+    }
+    private static final Logger logger = LoggerFactory.getLogger(TCPHandler.class);
+
+    /**
+     * Constructor of TCPHandler that listens on selected port.
+     *
+     * @param port listening port of TCPHandler server
+     */
+    public TCPHandler(int port) {
+        this.port = port;
+    }
+
+    /**
+     * Starts server on selected port.
+     *
+     * @throws Exception on connection failure
+     */
+    public void run() throws Exception {
+        EventLoopGroup bossGroup = new NioEventLoopGroup();
+        EventLoopGroup workerGroup = new NioEventLoopGroup();
+        try {
+            ServerBootstrap b = new ServerBootstrap();
+            b.group(bossGroup, workerGroup)
+                    .channel(NioServerSocketChannel.class)
+                    .handler(new LoggingHandler(LogLevel.DEBUG))
+                    .childHandler(new ChannelInitializer<SocketChannel>() {
+                @Override
+                public void initChannel(SocketChannel ch) throws Exception {
+                    ch.pipeline().addLast(COMPONENT_NAMES.TLS_DETECTOR.name(), new TLSDetector());
+                }
+            })
+                    .option(ChannelOption.SO_BACKLOG, 128)
+                    .childOption(ChannelOption.SO_KEEPALIVE, true);
+
+            ChannelFuture f = b.bind(port).sync();
+            logger.info("Switch listener started and ready to accept incoming connections on port: " + port);
+            f.channel().closeFuture().sync();
+        } finally {
+            workerGroup.shutdownGracefully();
+            bossGroup.shutdownGracefully();
+        }
+    }
+
+    /**
+     * Sets and starts TCPHandler.
+     *
+     * @param args
+     * @throws Exception
+     */
+    public static void main(String[] args) throws Exception {
+        int port;
+        if (args.length > 0) {
+            port = Integer.parseInt(args[0]);
+        } else {
+            port = 6633;
+        }
+        new TCPHandler(port).run();
+    }
+}
diff --git a/openflow-protocol-impl/src/main/java/org/openflow/core/TLSDetector.java b/openflow-protocol-impl/src/main/java/org/openflow/core/TLSDetector.java
new file mode 100644 (file)
index 0000000..13b71f9
--- /dev/null
@@ -0,0 +1,89 @@
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+package org.openflow.core;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelPipeline;
+import io.netty.handler.codec.ByteToMessageDecoder;
+import io.netty.handler.ssl.SslHandler;
+import java.util.List;
+import javax.net.ssl.SSLEngine;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.openflow.core.TCPHandler.COMPONENT_NAMES;
+
+/**
+ * Class for detecting TLS encrypted connection. If TLS encrypted connection is detected,
+ * TLSDetector engages SSLHandler and OFFrameDecoder into pipeline else it engages only
+ * OFFrameDecoder.
+ *
+ * @author michal.polkorab
+ */
+public class TLSDetector extends ByteToMessageDecoder {
+
+    private boolean detectSsl;
+    private static final Logger logger = LoggerFactory
+            .getLogger(TLSDetector.class);
+
+    /**
+     * Constructor of class
+     */
+    public TLSDetector() {
+        logger.info("Creating TLS Detector");
+        detectSsl = true;
+    }
+
+    @Override
+    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
+        logger.warn("Unexpected exception from downstream.",
+                cause);
+        cause.printStackTrace();
+        ctx.close();
+    }
+
+    private boolean isSsl(ByteBuf bb) {
+        if (detectSsl) {
+            logger.info("Testing connection for TLS");
+            return SslHandler.isEncrypted(bb);
+        }
+        return false;
+    }
+
+    private static void enableSsl(ChannelHandlerContext ctx) {
+        if (ctx.pipeline().get(COMPONENT_NAMES.SSL_HANDLER.name()) == null) {
+            logger.info("Engaging TLS handler");
+            ChannelPipeline p = ctx.channel().pipeline();
+            SSLEngine engine = SslContextFactory.getServerContext()
+                    .createSSLEngine();
+            engine.setUseClientMode(false);
+            p.addLast(COMPONENT_NAMES.SSL_HANDLER.name(),
+                    new SslHandler(engine));
+        }
+    }
+
+    private static void enableOFFrameDecoder(ChannelHandlerContext ctx) {
+        ChannelPipeline p = ctx.channel().pipeline();
+        if (p.get(COMPONENT_NAMES.OF_FRAME_DECODER.name()) == null) {
+            logger.debug("Engaging OFFrameDecoder");
+            p.addLast(COMPONENT_NAMES.OF_FRAME_DECODER.name(), new OFFrameDecoder());
+        } else {
+            logger.debug("OFFD already in pipeline");
+        }
+    }
+
+    @Override
+    protected void decode(ChannelHandlerContext ctx, ByteBuf bb,
+            List<Object> list) throws Exception {
+        if (bb.readableBytes() < 5) {
+            return;
+        }
+        if (isSsl(bb)) {
+            logger.info("Connection is encrypted");
+            enableSsl(ctx);
+        } else {
+            logger.info("Connection is not encrypted");
+        }
+        enableOFFrameDecoder(ctx);
+        ctx.pipeline().remove(COMPONENT_NAMES.TLS_DETECTOR.name());
+    }
+}
diff --git a/openflow-protocol-impl/src/main/java/org/openflow/util/ByteBufUtils.java b/openflow-protocol-impl/src/main/java/org/openflow/util/ByteBufUtils.java
new file mode 100644 (file)
index 0000000..c4f7a96
--- /dev/null
@@ -0,0 +1,26 @@
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
+\r
+package org.openflow.util;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+/** Class for common operations on ByteBuf\r
+ *\r
+ * @author michal.polkorab\r
+ */\r
+public abstract class ByteBufUtils {\r
+\r
+    /**\r
+     * Converts ByteBuf into String\r
+     * @param bb input ByteBuf\r
+     * @return String\r
+     */\r
+    public static String byteBufToHexString(ByteBuf bb) {\r
+        StringBuffer sb = new StringBuffer();\r
+        for (int i = 0; i < bb.readableBytes(); i++) {\r
+            short b = bb.getUnsignedByte(i);\r
+            sb.append(String.format("%02x ", b));\r
+        }\r
+        return sb.toString();\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/resources/key.bin b/openflow-protocol-impl/src/main/resources/key.bin
new file mode 100644 (file)
index 0000000..439ef0d
Binary files /dev/null and b/openflow-protocol-impl/src/main/resources/key.bin differ
diff --git a/openflow-protocol-impl/src/main/resources/key.raw b/openflow-protocol-impl/src/main/resources/key.raw
new file mode 100644 (file)
index 0000000..ad7108e
--- /dev/null
@@ -0,0 +1,258 @@
+fe ed fe ed 00 00 00 02
+00 00 00 02 00 00 00 01
+00 07 65 78 61 6d 70 6c
+65 00 00 01 1a 9f 57 a5
+27 00 00 01 9a 30 82 01
+96 30 0e 06 0a 2b 06 01
+04 01 2a 02 11 01 01 05
+00 04 82 01 82 48 6d cf
+16 b5 50 95 36 bf 47 27
+50 58 0d a2 52 7e 25 ab
+14 1a 26 5e 2d 8a 23 90
+60 7f 12 20 56 d1 43 a2
+6b 47 5d ed 9d d4 e5 83
+28 89 c2 16 4c 76 06 ad
+8e 8c 29 1a 9b 0f dd 60
+4b b4 62 82 9e 4a 63 83
+2e d2 43 78 c2 32 1f 60
+a9 8a 7f 0f 7c a6 1d e6
+92 9e 52 c7 7d bb 35 3b
+aa 89 73 4c fb 99 54 97
+99 28 6e 66 5b f7 9b 7e
+6d 8a 2f fa c3 1e 71 b9
+bd 8f c5 63 25 31 20 02
+ff 02 f0 c9 2c dd 3a 10
+30 ab e5 ad 3d 1a 82 77
+46 ed 03 38 a4 73 6d 36
+36 33 70 b2 63 20 ca 03
+bf 5a f4 7c 35 f0 63 1a
+12 33 12 58 d9 a2 63 6b
+63 82 41 65 70 37 4b 99
+04 9f dd 5e 07 01 95 9f
+36 e8 c3 66 2a 21 69 68
+40 e6 bc bb 85 81 21 13
+e6 a4 cf d3 67 e3 fd 75
+f0 df 83 e0 c5 36 09 ac
+1b d4 f7 2a 23 57 1c 5c
+0f f4 cf a2 cf f5 bd 9c
+69 98 78 3a 25 e4 fd 85
+11 cc 7d ef eb 74 60 b1
+b7 fb 1f 0e 62 ff fe 09
+0a c3 80 2f 10 49 89 78
+d2 08 fa 89 22 45 91 21
+bc 90 3e ad b3 0a b4 0e
+1c a1 93 92 d8 72 07 54
+60 e7 91 fc d9 3c e1 6f
+08 e4 56 f6 0b b0 3c 39
+8a 2d 48 44 28 13 ca e9
+f7 a3 b6 8a 5f 31 a9 72
+f2 de 96 f2 b1 53 b1 3e
+24 57 fd 18 45 1f c5 33
+1b a4 e8 21 fa 0e b2 b9
+cb c7 07 41 dd 2f b6 6a
+23 18 ed c1 ef e2 4b ec
+c9 ba fb 46 43 90 d7 b5
+68 28 31 2b 8d a8 51 63
+f7 53 99 19 68 85 66 00
+00 00 01 00 05 58 2e 35
+30 39 00 00 02 3a 30 82
+02 36 30 82 01 e0 a0 03
+02 01 02 02 04 48 59 f1
+92 30 0d 06 09 2a 86 48
+86 f7 0d 01 01 05 05 00
+30 81 a0 31 0b 30 09 06
+03 55 04 06 13 02 4b 52
+31 13 30 11 06 03 55 04
+08 13 0a 4b 79 75 6e 67
+67 69 2d 64 6f 31 14 30
+12 06 03 55 04 07 13 0b
+53 65 6f 6e 67 6e 61 6d
+2d 73 69 31 1a 30 18 06
+03 55 04 0a 13 11 54 68
+65 20 4e 65 74 74 79 20
+50 72 6f 6a 65 63 74 31
+18 30 16 06 03 55 04 0b
+13 0f 45 78 61 6d 70 6c
+65 20 41 75 74 68 6f 72
+73 31 30 30 2e 06 03 55
+04 03 13 27 73 65 63 75
+72 65 63 68 61 74 2e 65
+78 61 6d 70 6c 65 2e 6e
+65 74 74 79 2e 67 6c 65
+61 6d 79 6e 6f 64 65 2e
+6e 65 74 30 20 17 0d 30
+38 30 36 31 39 30 35 34
+31 33 38 5a 18 0f 32 31
+38 37 31 31 32 34 30 35
+34 31 33 38 5a 30 81 a0
+31 0b 30 09 06 03 55 04
+06 13 02 4b 52 31 13 30
+11 06 03 55 04 08 13 0a
+4b 79 75 6e 67 67 69 2d
+64 6f 31 14 30 12 06 03
+55 04 07 13 0b 53 65 6f
+6e 67 6e 61 6d 2d 73 69
+31 1a 30 18 06 03 55 04
+0a 13 11 54 68 65 20 4e
+65 74 74 79 20 50 72 6f
+6a 65 63 74 31 18 30 16
+06 03 55 04 0b 13 0f 45
+78 61 6d 70 6c 65 20 41
+75 74 68 6f 72 73 31 30
+30 2e 06 03 55 04 03 13
+27 73 65 63 75 72 65 63
+68 61 74 2e 65 78 61 6d
+70 6c 65 2e 6e 65 74 74
+79 2e 67 6c 65 61 6d 79
+6e 6f 64 65 2e 6e 65 74
+30 5c 30 0d 06 09 2a 86
+48 86 f7 0d 01 01 01 05
+00 03 4b 00 30 48 02 41
+00 c3 e3 5e 41 a7 87 11
+00 42 2a b0 4b ed b2 e0
+23 db b1 3d 58 97 35 60
+0b 82 59 d3 00 ea d4 61
+b8 79 3f b6 3c 12 05 93
+2e 9a 59 68 14 77 3a c8
+50 25 57 a4 49 18 63 41
+f0 2d 28 ec 06 fb b4 9f
+bf 02 03 01 00 01 30 0d
+06 09 2a 86 48 86 f7 0d
+01 01 05 05 00 03 41 00
+65 6c 30 01 c2 8e 3e cb
+b3 77 48 e9 66 61 9a 40
+86 af f6 03 eb ba 6a f2
+fd e2 af 36 5e 7b aa 22
+04 dd 2c 20 c4 fc dd d0
+82 20 1c 3d d7 9e 5e 5c
+92 5a 76 71 28 f5 07 7d
+a2 81 ba 77 9f 2a d9 44
+00 00 00 01 00 05 6d 79
+6b 65 79 00 00 01 1a 9f
+5b 56 a0 00 00 01 99 30
+82 01 95 30 0e 06 0a 2b
+06 01 04 01 2a 02 11 01
+01 05 00 04 82 01 81 29
+a8 b6 08 0c 85 75 3e dd
+b5 e5 1a 87 68 d1 90 4b
+29 31 ee 90 bc 9d 73 a0
+3f e9 0b a4 ef 30 9b 36
+9a b2 54 77 81 07 4b aa
+a5 77 98 e1 eb b5 7c 4e
+48 d5 08 fc 2c 36 e2 65
+03 ac e5 f3 96 b7 d0 b5
+3b 92 e4 14 05 7a 6a 92
+56 fe 4e ab d3 0e 32 04
+22 22 74 47 7d ec 21 99
+30 31 64 46 64 9b c7 13
+bf be d0 31 49 e7 3c bf
+ba b1 20 f9 42 f4 a9 a9
+e5 13 65 32 bf 7c cc 91
+d3 fd 24 47 0b e5 53 ad
+50 30 56 d1 fa 9c 37 a8
+c1 ce f6 0b 18 aa 7c ab
+bd 1f df e4 80 b8 a7 e0
+ad 7d 50 74 f1 98 78 bc
+58 b9 c2 52 be d2 5b 81
+94 83 8f b9 4c ee 01 2b
+5e c9 6e 9b f5 63 69 e4
+d8 0b 47 d8 fd d8 e0 ed
+a8 27 03 74 1e 5d 32 e6
+5c 63 c2 fb 3f ee b4 13
+c6 0e 6e 74 e0 22 ac ce
+79 f9 43 68 c1 03 74 2b
+e1 18 f8 7f 76 9a ea 82
+3f c2 a6 a7 4c fe ae 29
+3b c1 10 7c d5 77 17 79
+5f cb ad 1f d8 a1 fd 90
+e1 6b b2 ef b9 41 26 a4
+0b 4f c6 83 05 6f f0 64
+40 e1 44 c4 f9 40 2b 3b
+40 db af 35 a4 9b 9f c4
+74 07 e5 18 60 c5 fe 15
+0e 3a 25 2a 11 ee 78 2f
+b8 d1 6e 4e 3c 0a b5 b9
+40 86 27 6d 8f 53 b7 77
+36 ec 5d ed 32 40 43 82
+c3 52 58 c4 26 39 f3 b3
+ad 58 ab b7 f7 8e 0e ba
+8e 78 9d bf 58 34 bd 77
+73 a6 50 55 00 60 26 bf
+6d b4 98 8a 18 83 89 f8
+cd 0d 49 06 ae 51 6e af
+bd e2 07 13 d8 64 cc bf
+00 00 00 01 00 05 58 2e
+35 30 39 00 00 02 34 30
+82 02 30 30 82 01 da a0
+03 02 01 02 02 04 48 59
+f2 84 30 0d 06 09 2a 86
+48 86 f7 0d 01 01 05 05
+00 30 81 9d 31 0b 30 09
+06 03 55 04 06 13 02 4b
+52 31 13 30 11 06 03 55
+04 08 13 0a 4b 79 75 6e
+67 67 69 2d 64 6f 31 14
+30 12 06 03 55 04 07 13
+0b 53 65 6f 6e 67 6e 61
+6d 2d 73 69 31 1a 30 18
+06 03 55 04 0a 13 11 54
+68 65 20 4e 65 74 74 79
+20 50 72 6f 6a 65 63 74
+31 15 30 13 06 03 55 04
+0b 13 0c 43 6f 6e 74 72
+69 62 75 74 6f 72 73 31
+30 30 2e 06 03 55 04 03
+13 27 73 65 63 75 72 65
+63 68 61 74 2e 65 78 61
+6d 70 6c 65 2e 6e 65 74
+74 79 2e 67 6c 65 61 6d
+79 6e 6f 64 65 2e 6e 65
+74 30 20 17 0d 30 38 30
+36 31 39 30 35 34 35 34
+30 5a 18 0f 32 31 38 37
+31 31 32 33 30 35 34 35
+34 30 5a 30 81 9d 31 0b
+30 09 06 03 55 04 06 13
+02 4b 52 31 13 30 11 06
+03 55 04 08 13 0a 4b 79
+75 6e 67 67 69 2d 64 6f
+31 14 30 12 06 03 55 04
+07 13 0b 53 65 6f 6e 67
+6e 61 6d 2d 73 69 31 1a
+30 18 06 03 55 04 0a 13
+11 54 68 65 20 4e 65 74
+74 79 20 50 72 6f 6a 65
+63 74 31 15 30 13 06 03
+55 04 0b 13 0c 43 6f 6e
+74 72 69 62 75 74 6f 72
+73 31 30 30 2e 06 03 55
+04 03 13 27 73 65 63 75
+72 65 63 68 61 74 2e 65
+78 61 6d 70 6c 65 2e 6e
+65 74 74 79 2e 67 6c 65
+61 6d 79 6e 6f 64 65 2e
+6e 65 74 30 5c 30 0d 06
+09 2a 86 48 86 f7 0d 01
+01 01 05 00 03 4b 00 30
+48 02 41 00 95 b3 47 17
+95 0f 57 cf 66 72 0a 7e
+5b 54 ea 8c 6f 79 de 94
+ac 0b 5a d4 d6 1b 58 12
+1a 16 3d fe df a5 2b 86
+bc 64 d4 80 1e 3f f9 e2
+04 03 79 9b c1 5c f0 f1
+f3 f1 e3 bf 3f c0 1f dd
+db c0 5b 21 02 03 01 00
+01 30 0d 06 09 2a 86 48
+86 f7 0d 01 01 05 05 00
+03 41 00 02 d7 dd bd 0c
+8e 21 20 ef 9e 4f 1f f5
+49 f1 ae 58 9b 94 3a 1f
+70 33 f0 9b bb e9 c0 f3
+72 cb de b6 56 72 cc 1c
+f0 d6 5a 2a bc a1 7e 23
+83 e9 e7 cf 9e a5 f9 cc
+c2 61 f4 db 40 93 1d 63
+8a 50 4c 11 39 b1 91 c1
+e6 9d d9 1a 62 1b b8 d3
+d6 9a 6d b9 8e 15 51 
\ No newline at end of file
diff --git a/openflow-protocol-impl/src/main/resources/log4j.xml b/openflow-protocol-impl/src/main/resources/log4j.xml
new file mode 100644 (file)
index 0000000..62f3ef5
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">\r
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">\r
+\r
+    <appender name="console" class="org.apache.log4j.ConsoleAppender">\r
+        <layout class="org.apache.log4j.PatternLayout">\r
+            <param name="ConversionPattern" value="%-6p %d{HH:mm:ss.SSS} [%10.10t] %30.30c %x - %m%n" />\r
+        </layout>\r
+    </appender>\r
+\r
+    <logger name="org.openflow.example" additivity="false">\r
+        <level value="DEBUG" />\r
+        <appender-ref ref="console" />\r
+    </logger>\r
+\r
+    <root>\r
+        <priority value="INFO" />\r
+        <appender-ref ref="console" />\r
+    </root>\r
+</log4j:configuration>\r
diff --git a/openflow-protocol-impl/src/test/java/org/openflow/example/TCPHandlerTest.java b/openflow-protocol-impl/src/test/java/org/openflow/example/TCPHandlerTest.java
new file mode 100644 (file)
index 0000000..a638fb6
--- /dev/null
@@ -0,0 +1,28 @@
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.openflow.example;
+
+import static org.junit.Assert.assertTrue;
+
+/**
+ *
+ * @author michal.polkorab
+ */
+public class TCPHandlerTest {
+
+    /**
+     * Test of run method, of class TCPHandler.
+     */
+    @org.junit.Test
+    public void testRun() {
+//        System.out.println("run");
+//        TCPHandler instance = null;
+//        instance.run();
+//        // TODO review the generated test code and remove the default call to fail.
+//        fail("The test case is a prototype.");
+        assertTrue(true);
+    }
+}
index 61b6143ae0f5a1f61d019babf528cd94ef419b2d..954ed4385d12d25fc3cf80c2400334fa7620d6d8 100644 (file)
@@ -1,19 +1,19 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>org.opendaylight.openflow</groupId>
-        <artifactId>openflow-protocol-parent</artifactId>
-        <version>0.1-SNAPSHOT</version>
-    </parent>
-    <artifactId>openflow-protocol-spi</artifactId>
-       <name>Openflow Protocol Library SPI</name>
-       
-    <dependencies>
-       <dependency>
-           <groupId>org.opendaylight.openflow</groupId>
-            <artifactId>openflow-protocol-api</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-    </dependencies>
-</project>
\ No newline at end of file
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
+    <modelVersion>4.0.0</modelVersion>\r
+    <parent>\r
+        <groupId>org.opendaylight.openflow</groupId>\r
+        <artifactId>openflow-protocol-parent</artifactId>\r
+        <version>0.1-SNAPSHOT</version>\r
+    </parent>\r
+    <artifactId>openflow-protocol-spi</artifactId>\r
+       <name>Openflow Protocol Library SPI</name>\r
+       \r
+    <dependencies>\r
+       <dependency>\r
+           <groupId>org.opendaylight.openflow</groupId>\r
+            <artifactId>openflow-protocol-api</artifactId>\r
+            <version>${project.version}</version>\r
+        </dependency>\r
+    </dependencies>\r
+</project>\r
diff --git a/pom.xml b/pom.xml
index 98366c5f88ee477d2c11f1cfd8d56e85377a6eee..02fc2fc37e1317c73369fc486d74fd658bb9feb2 100644 (file)
--- a/pom.xml
+++ b/pom.xml
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <groupId>org.opendaylight.openflow</groupId>
-       <artifactId>openflow-protocol-parent</artifactId>
-       <version>0.1-SNAPSHOT</version>
-       <packaging>pom</packaging>
-       <modules>
-               <module>openflow-protocol-api</module>
-               <module>openflow-protocol-spi</module>
-               <module>openflow-protocol-impl</module>
-        <module>third-party/openflow-codec</module>
-        <module>third-party/openflowj_netty</module>
-       </modules>
-
-       <name>Openflow Protocol Library</name>
-
-       <developers>
-               <developer>
-                       <name>Adam BrĨek</name>
-                       <email>adam.brcek@pantheon.sk</email>
-               </developer>
-       </developers>
-
-
-       <properties>
-               <sonar.host.url>https://sonar.opendaylight.org/</sonar.host.url>
-               <nexusproxy>http://nexus.opendaylight.org/content</nexusproxy>
-               <sitedeploy>dav:http://nexus.opendaylight.org/content/sites/site</sitedeploy>
-               <siteplugin>3.2</siteplugin>
-               <projectinfo>2.6</projectinfo>
-               <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-               <compiler.version>2.3.2</compiler.version>
-               <surefire.version>2.13</surefire.version>
-               <exam.version>3.0.0</exam.version>
-               <url.version>1.5.0</url.version>
-               <enunciate.version>1.26.2</enunciate.version>
-               <sonar.branch>${user.name}-private-view</sonar.branch>
-               <sonar.skippedModules>org.openflow.openflowj,net.sf.jung2</sonar.skippedModules>
-               <logback.version>1.0.9</logback.version>
-               <slf4j.version>1.7.2</slf4j.version>
-       </properties>
-
-       <pluginRepositories>
-               <pluginRepository>
-                       <id>central2</id>
-                       <name>central2</name>
-                       <url>${nexusproxy}/repositories/central2/</url>
-               </pluginRepository>
-               
-               <!-- OpenDayLight Released artifact -->
-               <pluginRepository>
-                       <id>opendaylight-release</id>
-                       <name>opendaylight-release</name>
-                       <url>${nexusproxy}/repositories/opendaylight.release/</url>
-               </pluginRepository>
-               <!-- OpenDayLight Snapshot artifact -->
-               <pluginRepository>
-                       <id>opendaylight-snapshot</id>
-                       <name>opendaylight-snapshot</name>
-                       <url>${nexusproxy}/repositories/opendaylight.snapshot/</url>
-               </pluginRepository>
-       </pluginRepositories>
-
-
-       <repositories>
-               <!-- EBR release -->
-               <!-- http://repository.springsource.com/maven/bundles/release -->
-               <repository>
-                       <id>ebr-bundles-release</id>
-                       <name>ebr-bundles-release</name>
-                       <url>${nexusproxy}/repositories/ebr-bundles-release/</url>
-               </repository>
-               <!-- EBR external -->
-               <!-- http://repository.springsource.com/maven/bundles/external -->
-               <repository>
-                       <id>ebr-bundles-external</id>
-                       <name>ebr-bundles-external</name>
-                       <url>${nexusproxy}/repositories/ebr-bundles-external/</url>
-               </repository>
-               <!-- Maven repo2 mirror -->
-               <!-- http://repo2.maven.org/maven2 -->
-               <repository>
-                       <id>central2</id>
-                       <name>central2</name>
-                       <url>${nexusproxy}/repositories/central2/</url>
-               </repository>
-               <!-- Maven repo1 mirror -->
-               <!-- http://repo1.maven.org/maven2 -->
-               <repository>
-                       <id>central</id>
-                       <name>central</name>
-                       <url>${nexusproxy}/repositories/central/</url>
-               </repository>
-               <!-- Pax mirror -->
-               <!-- https://oss.sonatype.org/content/repositories/ops4j-releases -->
-               <repository>
-                       <id>ops4j-releases</id>
-                       <name>ops4j-releases</name>
-                       <url>${nexusproxy}/repositories/ops4j-releases/</url>
-               </repository>
-               <!-- Third Packages hosted in local maven because not available in other 
-                       places -->
-               <repository>
-                       <id>thirdparty</id>
-                       <name>thirdparty</name>
-                       <url>${nexusproxy}/repositories/thirdparty/</url>
-               </repository>
-               <!-- Jboss mirror -->
-               <!-- https://repository.jboss.org/nexus/content/repositories/releases -->
-               <repository>
-                       <id>jboss.releases</id>
-                       <name>jboss.releases</name>
-                       <url>${nexusproxy}/repositories/jboss.releases/</url>
-               </repository>
-               <!-- OpenDayLight Released artifact -->
-               <repository>
-                       <id>opendaylight-release</id>
-                       <name>opendaylight-release</name>
-                       <url>${nexusproxy}/repositories/opendaylight.release/</url>
-               </repository>
-               <!-- OpenDayLight Snapshot artifact -->
-               <repository>
-                       <id>opendaylight-snapshot</id>
-                       <name>opendaylight-snapshot</name>
-                       <url>${nexusproxy}/repositories/opendaylight.snapshot/</url>
-               </repository>
-       </repositories>
-       <distributionManagement>
-               <!-- OpenDayLight Released artifact -->
-               <repository>
-                       <id>opendaylight-release</id>
-                       <url>${nexusproxy}/repositories/opendaylight.release/</url>
-               </repository>
-               <!-- OpenDayLight Snapshot artifact -->
-               <snapshotRepository>
-                       <id>opendaylight-snapshot</id>
-                       <url>${nexusproxy}/repositories/opendaylight.snapshot/</url>
-               </snapshotRepository>
-               <!-- Site deployment -->
-               <!-- site> <id>website</id> <url>${sitedeploy}</url> </site -->
-       </distributionManagement>
-
-
-       <dependencyManagement>
-               <dependencies>
-                       <dependency>
-                               <groupId>junit</groupId>
-                               <artifactId>junit</artifactId>
-                               <version>4.10</version>
-                               <scope>test</scope>
-                               <optional>true</optional>
-                       </dependency>
-                       <dependency>
-                               <groupId>org.slf4j</groupId>
-                               <artifactId>slf4j-api</artifactId>
-                               <version>1.7.2</version>
-                       </dependency>
-               </dependencies>
-       </dependencyManagement>
-       <build>
-               <plugins>
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-compiler-plugin</artifactId>
-                               <version>${compiler.version}</version>
-                               <inherited>true</inherited>
-                               <configuration>
-                                       <source>1.7</source>
-                                       <target>1.7</target>
-                               </configuration>
-                       </plugin>
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-javadoc-plugin</artifactId>
-                               <version>2.8.1</version>
-                               <configuration>
-                                       <stylesheet>maven</stylesheet>
-                               </configuration>
-                               <executions>
-                                       <execution>
-                                               <goals>
-                                                       <goal>aggregate</goal>
-                                               </goals>
-                                               <phase>site</phase>
-                                       </execution>
-                                       <execution>
-                                               <id>attach-javadocs</id>
-                                               <phase>deploy</phase>
-                                               <goals>
-                                                       <goal>jar</goal>
-                                               </goals>
-                                       </execution>
-                               </executions>
-                       </plugin>
-                       <plugin>
-                               <artifactId>maven-source-plugin</artifactId>
-                               <executions>
-                                       <execution>
-                                               <id>attach-sources</id>
-                                               <phase>deploy</phase>
-                                               <goals>
-                                                       <goal>jar-no-fork</goal>
-                                               </goals>
-                                       </execution>
-                               </executions>
-                       </plugin>
-                       <plugin>
-                               <!-- explicitly define maven-deploy-plugin after other to force exec 
-                                       order -->
-                               <artifactId>maven-deploy-plugin</artifactId>
-                               <executions>
-                                       <execution>
-                                               <id>deploy</id>
-                                               <phase>deploy</phase>
-                                               <goals>
-                                                       <goal>deploy</goal>
-                                               </goals>
-                                       </execution>
-                               </executions>
-                       </plugin>
-               </plugins>
-       </build>
-       <reporting>
-               <plugins>
-                       <plugin>
-                               <groupId>org.codehaus.mojo</groupId>
-                               <artifactId>findbugs-maven-plugin</artifactId>
-                               <version>2.4.0</version>
-                               <configuration>
-                                       <effort>Max</effort>
-                                       <threshold>Low</threshold>
-                                       <goal>site</goal>
-                               </configuration>
-                       </plugin>
-                       <plugin>
-                               <groupId>org.codehaus.mojo</groupId>
-                               <artifactId>jdepend-maven-plugin</artifactId>
-                               <version>2.0-beta-2</version>
-                       </plugin>
-               </plugins>
-       </reporting>
-       <profiles>
-               <profile>
-                       <id>viewbuild</id>
-                       <activation>
-                               <activeByDefault>true</activeByDefault>
-                       </activation>
-                       <properties>
-                               <build.suffix>${project.version}</build.suffix>
-                       </properties>
-               </profile>
-               <profile>
-                       <id>jenkins</id>
-                       <activation>
-                               <property>
-                                       <name>BUILDSUFFIX</name>
-                               </property>
-                       </activation>
-                       <properties>
-                               <build.suffix>${BUILDSUFFIX}</build.suffix>
-                       </properties>
-               </profile>
-       </profiles>
-</project>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
+       <modelVersion>4.0.0</modelVersion>\r
+       <groupId>org.opendaylight.openflow</groupId>\r
+       <artifactId>openflow-protocol-parent</artifactId>\r
+       <version>0.1-SNAPSHOT</version>\r
+       <packaging>pom</packaging>\r
+       <modules>\r
+               <module>openflow-protocol-api</module>\r
+               <module>openflow-protocol-spi</module>\r
+               <module>openflow-protocol-impl</module>\r
+        <module>third-party/openflow-codec</module>\r
+        <module>third-party/openflowj_netty</module>\r
+       </modules>\r
+\r
+       <name>Openflow Protocol Library</name>\r
+\r
+       <developers>\r
+               <developer>\r
+                       <name>Adam BrĨek</name>\r
+                       <email>adam.brcek@pantheon.sk</email>\r
+               </developer>\r
+       </developers>\r
+\r
+\r
+       <properties>\r
+               <sonar.host.url>https://sonar.opendaylight.org/</sonar.host.url>\r
+               <nexusproxy>http://nexus.opendaylight.org/content</nexusproxy>\r
+               <sitedeploy>dav:http://nexus.opendaylight.org/content/sites/site</sitedeploy>\r
+               <siteplugin>3.2</siteplugin>\r
+               <projectinfo>2.6</projectinfo>\r
+               <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\r
+               <compiler.version>2.3.2</compiler.version>\r
+               <surefire.version>2.13</surefire.version>\r
+               <exam.version>3.0.0</exam.version>\r
+               <url.version>1.5.0</url.version>\r
+               <enunciate.version>1.26.2</enunciate.version>\r
+               <sonar.branch>${user.name}-private-view</sonar.branch>\r
+               <sonar.skippedModules>org.openflow.openflowj,net.sf.jung2</sonar.skippedModules>\r
+               <logback.version>1.0.9</logback.version>\r
+               <slf4j.version>1.7.2</slf4j.version>\r
+       </properties>\r
+\r
+       <pluginRepositories>\r
+               <pluginRepository>\r
+                       <id>central2</id>\r
+                       <name>central2</name>\r
+                       <url>${nexusproxy}/repositories/central2/</url>\r
+               </pluginRepository>\r
+               \r
+               <!-- OpenDayLight Released artifact -->\r
+               <pluginRepository>\r
+                       <id>opendaylight-release</id>\r
+                       <name>opendaylight-release</name>\r
+                       <url>${nexusproxy}/repositories/opendaylight.release/</url>\r
+               </pluginRepository>\r
+               <!-- OpenDayLight Snapshot artifact -->\r
+               <pluginRepository>\r
+                       <id>opendaylight-snapshot</id>\r
+                       <name>opendaylight-snapshot</name>\r
+                       <url>${nexusproxy}/repositories/opendaylight.snapshot/</url>\r
+               </pluginRepository>\r
+       </pluginRepositories>\r
+\r
+\r
+       <repositories>\r
+               <!-- EBR release -->\r
+               <!-- http://repository.springsource.com/maven/bundles/release -->\r
+               <repository>\r
+                       <id>ebr-bundles-release</id>\r
+                       <name>ebr-bundles-release</name>\r
+                       <url>${nexusproxy}/repositories/ebr-bundles-release/</url>\r
+               </repository>\r
+               <!-- EBR external -->\r
+               <!-- http://repository.springsource.com/maven/bundles/external -->\r
+               <repository>\r
+                       <id>ebr-bundles-external</id>\r
+                       <name>ebr-bundles-external</name>\r
+                       <url>${nexusproxy}/repositories/ebr-bundles-external/</url>\r
+               </repository>\r
+               <!-- Maven repo2 mirror -->\r
+               <!-- http://repo2.maven.org/maven2 -->\r
+               <repository>\r
+                       <id>central2</id>\r
+                       <name>central2</name>\r
+                       <url>${nexusproxy}/repositories/central2/</url>\r
+               </repository>\r
+               <!-- Maven repo1 mirror -->\r
+               <!-- http://repo1.maven.org/maven2 -->\r
+               <repository>\r
+                       <id>central</id>\r
+                       <name>central</name>\r
+                       <url>${nexusproxy}/repositories/central/</url>\r
+               </repository>\r
+               <!-- Pax mirror -->\r
+               <!-- https://oss.sonatype.org/content/repositories/ops4j-releases -->\r
+               <repository>\r
+                       <id>ops4j-releases</id>\r
+                       <name>ops4j-releases</name>\r
+                       <url>${nexusproxy}/repositories/ops4j-releases/</url>\r
+               </repository>\r
+               <!-- Third Packages hosted in local maven because not available in other \r
+                       places -->\r
+               <repository>\r
+                       <id>thirdparty</id>\r
+                       <name>thirdparty</name>\r
+                       <url>${nexusproxy}/repositories/thirdparty/</url>\r
+               </repository>\r
+               <!-- Jboss mirror -->\r
+               <!-- https://repository.jboss.org/nexus/content/repositories/releases -->\r
+               <repository>\r
+                       <id>jboss.releases</id>\r
+                       <name>jboss.releases</name>\r
+                       <url>${nexusproxy}/repositories/jboss.releases/</url>\r
+               </repository>\r
+               <!-- OpenDayLight Released artifact -->\r
+               <repository>\r
+                       <id>opendaylight-release</id>\r
+                       <name>opendaylight-release</name>\r
+                       <url>${nexusproxy}/repositories/opendaylight.release/</url>\r
+               </repository>\r
+               <!-- OpenDayLight Snapshot artifact -->\r
+               <repository>\r
+                       <id>opendaylight-snapshot</id>\r
+                       <name>opendaylight-snapshot</name>\r
+                       <url>${nexusproxy}/repositories/opendaylight.snapshot/</url>\r
+               </repository>\r
+       </repositories>\r
+       <distributionManagement>\r
+               <!-- OpenDayLight Released artifact -->\r
+               <repository>\r
+                       <id>opendaylight-release</id>\r
+                       <url>${nexusproxy}/repositories/opendaylight.release/</url>\r
+               </repository>\r
+               <!-- OpenDayLight Snapshot artifact -->\r
+               <snapshotRepository>\r
+                       <id>opendaylight-snapshot</id>\r
+                       <url>${nexusproxy}/repositories/opendaylight.snapshot/</url>\r
+               </snapshotRepository>\r
+               <!-- Site deployment -->\r
+               <!-- site> <id>website</id> <url>${sitedeploy}</url> </site -->\r
+       </distributionManagement>\r
+\r
+\r
+       <dependencyManagement>\r
+               <dependencies>\r
+                       <dependency>\r
+                               <groupId>junit</groupId>\r
+                               <artifactId>junit</artifactId>\r
+                               <version>4.10</version>\r
+                               <scope>test</scope>\r
+                               <optional>true</optional>\r
+                       </dependency>\r
+                       <dependency>\r
+                               <groupId>org.slf4j</groupId>\r
+                               <artifactId>slf4j-api</artifactId>\r
+                               <version>1.7.2</version>\r
+                       </dependency>\r
+               </dependencies>\r
+       </dependencyManagement>\r
+       <build>\r
+               <plugins>\r
+                       <plugin>\r
+                               <groupId>org.apache.maven.plugins</groupId>\r
+                               <artifactId>maven-compiler-plugin</artifactId>\r
+                               <version>${compiler.version}</version>\r
+                               <inherited>true</inherited>\r
+                               <configuration>\r
+                                       <source>1.7</source>\r
+                                       <target>1.7</target>\r
+                               </configuration>\r
+                       </plugin>\r
+                       <plugin>\r
+                               <groupId>org.apache.maven.plugins</groupId>\r
+                               <artifactId>maven-javadoc-plugin</artifactId>\r
+                               <version>2.8.1</version>\r
+                               <configuration>\r
+                                       <stylesheet>maven</stylesheet>\r
+                               </configuration>\r
+                               <executions>\r
+                                       <execution>\r
+                                               <goals>\r
+                                                       <goal>aggregate</goal>\r
+                                               </goals>\r
+                                               <phase>site</phase>\r
+                                       </execution>\r
+                                       <execution>\r
+                                               <id>attach-javadocs</id>\r
+                                               <phase>deploy</phase>\r
+                                               <goals>\r
+                                                       <goal>jar</goal>\r
+                                               </goals>\r
+                                       </execution>\r
+                               </executions>\r
+                       </plugin>\r
+                       <plugin>\r
+                               <artifactId>maven-source-plugin</artifactId>\r
+                               <executions>\r
+                                       <execution>\r
+                                               <id>attach-sources</id>\r
+                                               <phase>deploy</phase>\r
+                                               <goals>\r
+                                                       <goal>jar-no-fork</goal>\r
+                                               </goals>\r
+                                       </execution>\r
+                               </executions>\r
+                       </plugin>\r
+                       <plugin>\r
+                               <!-- explicitly define maven-deploy-plugin after other to force exec \r
+                                       order -->\r
+                               <artifactId>maven-deploy-plugin</artifactId>\r
+                               <executions>\r
+                                       <execution>\r
+                                               <id>deploy</id>\r
+                                               <phase>deploy</phase>\r
+                                               <goals>\r
+                                                       <goal>deploy</goal>\r
+                                               </goals>\r
+                                       </execution>\r
+                               </executions>\r
+                       </plugin>\r
+               </plugins>\r
+       </build>\r
+       <reporting>\r
+               <plugins>\r
+                       <plugin>\r
+                               <groupId>org.codehaus.mojo</groupId>\r
+                               <artifactId>findbugs-maven-plugin</artifactId>\r
+                               <version>2.4.0</version>\r
+                               <configuration>\r
+                                       <effort>Max</effort>\r
+                                       <threshold>Low</threshold>\r
+                                       <goal>site</goal>\r
+                               </configuration>\r
+                       </plugin>\r
+                       <plugin>\r
+                               <groupId>org.codehaus.mojo</groupId>\r
+                               <artifactId>jdepend-maven-plugin</artifactId>\r
+                               <version>2.0-beta-2</version>\r
+                       </plugin>\r
+               </plugins>\r
+       </reporting>\r
+       <profiles>\r
+               <profile>\r
+                       <id>viewbuild</id>\r
+                       <activation>\r
+                               <activeByDefault>true</activeByDefault>\r
+                       </activation>\r
+                       <properties>\r
+                               <build.suffix>${project.version}</build.suffix>\r
+                       </properties>\r
+               </profile>\r
+               <profile>\r
+                       <id>jenkins</id>\r
+                       <activation>\r
+                               <property>\r
+                                       <name>BUILDSUFFIX</name>\r
+                               </property>\r
+                       </activation>\r
+                       <properties>\r
+                               <build.suffix>${BUILDSUFFIX}</build.suffix>\r
+                       </properties>\r
+               </profile>\r
+       </profiles>\r
+</project>\r